Hi All,
Firstly, great work on this project. I'm pleased to say it all seems to be working nicely.
I'm wearing the garmin heart rate strap and have a USB2 garmin stick in the laptop. The Eventlistener is printing the HR to the CMD ad infinitum and that is great.....
My question is how can I send the output of the HRMListener to another Class? My knowledge of python is patchy to say the least and based on figuring things out on Stackover flow but this one has me a bit lost...
What I'm trying to achieve is to send the stream of hr information to pygame and update a moving bar graph.
Do I need to look at Threading? (running simultaneous classes?) Although this doesn't look like it handles the looping of the eventlistener?
The other idea was to figure out the pygame.get.event() as it is receiving constant input a bit like a mouse moving? But not sure as the examples are quite simlistic.
Ultimate aim is to hash some kind of racing game for my bike turbo trainer. If anyone has better places to send the data then I'm happy to hear about them. pygame appeals as I can animate against the results of hr and speed from the garmin sensors etc.
Cheers,
Rob
from pygamehelper import *
from pygame import *
from pygame.locals import *
from vec2d import *
from math import e, pi, cos, sin, sqrt
from random import uniform
class Starter(PygameHelper):
def __init__(self):
self.w, self.h = 800, 600
PygameHelper.__init__(self, size=(self.w, self.h), fill=((255,255,255)))
def update(self):
#print "draw hr "
#y = 50 #start at hr of 50
#self.screen.fill((255,255,255))
#pygame.draw.line(self.screen, (0,0,0), (50,500), (50,500-(y*1.5)),20) # drawing the bar graph - this where the input from the HRMListener would likely end up
pass
def keyUp(self, key):
pass
def mouseUp(self, button, pos):
pass
def mouseMotion(self, buttons, pos, rel):
pass
def draw(self):
pass
s = Starter()
s.mainLoop(40)