def __init__(self): self.lead_count = 0 target_port = 'COM3' #target_port = 'devA/tty.XXXXXXX' #change this to work on OSX try: self.nskECG = NeuroskyECG(target_port) except serial.serialutil.SerialException: print("Could not open target serial port: %s" % target_port) sys.exit(1) #optional call, default is already 1 self.nskECG.setHRVUpdate(1) #update hrv every 1 detected pulses self.cur_lead_on = False self.cur_hrv = 0
def __init__(self): self.lead_count = 0 target_port = 'COM3' #target_port = 'devA/tty.XXXXXXX' #change this to work on OSX try: self.nskECG = NeuroskyECG(target_port) except serial.serialutil.SerialException: print "Could not open target serial port: %s" % target_port sys.exit(1) #optional call, default is already 1 self.nskECG.setHRVUpdate(1) #update hrv every 1 detected pulses # want the LEAD_TIMEOUT to hold on to values between baseline and test, but reset between users self.LEAD_TIMEOUT = 30 # reset algorithm if leadoff for more than this many seconds self.cur_lead_on = False self.cur_hrv = 0
# -*- coding: utf-8 -*- """ Test file for NeuroskyECG """ from neurosky_ecg import NeuroskyECG import sys target_port = 'COM12' #target_port = 'devA/tty.XXXXXXX' #change this to work on OSX try: nskECG = NeuroskyECG(target_port) except serial.serialutil.SerialException: print("Could not open target serial port: %s" % target_port) sys.exit(1) # optional call, default is already 1 nskECG.setHRVUpdate(1) #update hrv every 1 detected pulses # start running the serial producer thread nskECG.start() # this loop is the consumer thread, and will pop # dict values (with 'timestamp', 'ecg_raw', and 'leadoff' # from the internal buffer and run the analysis on the # data. cur_hrv = None # whatever the current hrv value is cur_hrv_t = None # timestamp with the current hrv