@@ -34,6 +34,9 @@ def handle_sample(sample):
3434except :
3535 DefaultDelegate = object
3636 STUB_BTLE = True
37+ else :
38+ from bluepy .btle import Scanner , DefaultDelegate , Peripheral
39+
3740
3841SAMPLE_RATE = 200.0 # Hz
3942scale_fac_uVolts_per_count = 1200 / (8388607.0 * 1.5 * 51.0 )
@@ -78,7 +81,7 @@ def __init__(self, port=None, baud=0, filter_data=False,
7881 self .timeout = timeout
7982 self .max_packets_to_skip = max_packets_to_skip
8083 self .scaling_output = scaled_output
81- self .impedance = False
84+ self .impedance = impedance
8285
8386 # might be handy to know API
8487 self .board_type = "ganglion"
@@ -562,11 +565,11 @@ def parse18bit(self, packet_id, packet):
562565
563566 def parseImpedance (self , packet_id , packet ):
564567 """ Dealing with impedance data. packet: ASCII data. NB: will take few packet (seconds) to fill"""
565- if packet [- 2 :] != "Z\n " :
568+ if packet [- 2 :] != b "Z\n " :
566569 print ('Wrong format for impedance check, should be ASCII ending with "Z\\ n"' )
567570
568571 # convert from ASCII to actual value
569- imp_value = int (packet [:- 2 ])
572+ imp_value = int (packet [:- 2 ]) / 2
570573 # from 201 to 205 codes to the right array size
571574 self .lastImpedance [packet_id - 201 ] = imp_value
572575 self .pushSample (packet_id - 200 , self .lastChannelData , self .lastAcceleromoter , self .lastImpedance )
0 commit comments