@@ -34,6 +34,9 @@ def handle_sample(sample):
34
34
except :
35
35
DefaultDelegate = object
36
36
STUB_BTLE = True
37
+ else :
38
+ from bluepy .btle import Scanner , DefaultDelegate , Peripheral
39
+
37
40
38
41
SAMPLE_RATE = 200.0 # Hz
39
42
scale_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,
78
81
self .timeout = timeout
79
82
self .max_packets_to_skip = max_packets_to_skip
80
83
self .scaling_output = scaled_output
81
- self .impedance = False
84
+ self .impedance = impedance
82
85
83
86
# might be handy to know API
84
87
self .board_type = "ganglion"
@@ -562,11 +565,11 @@ def parse18bit(self, packet_id, packet):
562
565
563
566
def parseImpedance (self , packet_id , packet ):
564
567
""" 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 " :
566
569
print ('Wrong format for impedance check, should be ASCII ending with "Z\\ n"' )
567
570
568
571
# convert from ASCII to actual value
569
- imp_value = int (packet [:- 2 ])
572
+ imp_value = int (packet [:- 2 ]) / 2
570
573
# from 201 to 205 codes to the right array size
571
574
self .lastImpedance [packet_id - 201 ] = imp_value
572
575
self .pushSample (packet_id - 200 , self .lastChannelData , self .lastAcceleromoter , self .lastImpedance )
0 commit comments