Skip to content

Commit 076eb98

Browse files
author
AJ Keller
authored
Merge pull request #60 from CognitionIsKey/1.0.0
Impedance support
2 parents 6ef3a12 + 3636ea6 commit 076eb98

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

openbci/ganglion.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ def handle_sample(sample):
3434
except:
3535
DefaultDelegate = object
3636
STUB_BTLE = True
37+
else:
38+
from bluepy.btle import Scanner, DefaultDelegate, Peripheral
39+
3740

3841
SAMPLE_RATE = 200.0 # Hz
3942
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,
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

Comments
 (0)