Permalink
Browse files

Merge pull request #255 from CerebralPower/master

increase render.py variance.
  • Loading branch information...
2 parents 0fbc4cf + d5e1803 commit 7f25321a1c3a240f5b64a1572e5f106807b1beea Bill Schumacher committed on GitHub Apr 17, 2017
Showing with 35 additions and 17 deletions.
  1. +7 −7 python/emokit/packet.py
  2. +23 −7 python/emokit/util.py
  3. +4 −3 python/example_render_encrypted_data.py
  4. +1 −0 python/render.py
View
@@ -178,12 +178,12 @@ def __init__(self, data, timestamp=None, verbose=False):
:param verbose - Flag for outputting debug values.
"""
- bit_list = []
- for i in range(len(data) * 8):
- byte = (i // 8)
- print(byte)
- bit_list.append(str((ord(data[byte]) & i)))
- print(bit_list)
+ # bit_list = []
+ # for i in range(len(data) * 8):
+ # byte = (i // 8)
+ # print(byte)
+ # bit_list.append(str((ord(data[byte]) & i)))
+ # print(bit_list)
if timestamp is None:
self.timestamp = datetime.now()
else:
@@ -238,7 +238,7 @@ def __init__(self, data, timestamp=None, verbose=False):
for name, bits in sensors_14_bits.items():
if not 'GYRO' in name:
- value = get_level(self.raw_data, bits, verbose) * 0.51
+ value = get_level(self.raw_data, bits, verbose)
setattr(self, name, (value,))
self.sensors[name]['value'] = value
self.quality_bit, self.quality_value = self.handle_quality(self.sensors, verbose)
View
@@ -24,14 +24,14 @@ def bits(bytes):
value = 0
bits_list = []
for byte in bytes:
- print(byte)
+ # print(byte)
bit_list = []
for i in range(8, -1, -1):
binary = ''.join(bit_list)
bits_list.append(int(binary, 2))
- print()
+ # print()
bit_list = []
- print(''.join(map(chr, bin(bits_list[0] & bits_list[1]), 2)))
+ # print(''.join(map(chr, bin(bits_list[0] & bits_list[1]), 2)))
for i in range(8, -1, -1):
bit_list.append(str((ord(bin(bits_list[0] & bits_list[1])) >> i) & 1))
return value
@@ -41,8 +41,8 @@ def get_level(data, bits, verbose=False):
"""
Returns sensor level value from data using sensor bit mask in micro volts (uV).
"""
- if verbose:
- return detailed_get_level(data, bits)
+ # if verbose:
+ # return detailed_get_level(data, bits)
level = 0
bit_list = []
for i in range(13, -1, -1):
@@ -54,8 +54,24 @@ def get_level(data, bits, verbose=False):
level |= (data[b] >> o) & 1
else:
level |= (ord(data[b]) >> o) & 1
- print(bit_list)
- return level
+ # print(level)
+ # print(bit_list)
+ # whole_bits = list(reversed(bit_list[0:7]))
+ # whole_bits.append('0')
+ # whole = int(''.join(whole_bits), 2)
+ # print(whole)
+ # print(whole / 0.051)
+ # precision_bits = bit_list[7:14]
+ # precision_bits.append('0')
+ # precision_bits.append('0')
+ # print(int(''.join(precision_bits), 2))
+ # precision = int(''.join(precision_bits), 2)
+ # print(precision / 0.51)
+ # level = whole / 0.051
+ # level += precision / 0.51
+ # level = level * 2
+ # print((level) * 0.5151515151)
+ return level * 0.5151515151
def get_gyro(data, bits, verbose=False):
@@ -56,7 +56,7 @@ def calc_y(self, val):
"""
Calculates line height from value.
"""
- return val - self.y_offset + gheight
+ return (val * 1.5) - self.y_offset + gheight
def draw(self):
"""
@@ -66,7 +66,8 @@ def draw(self):
return
if self.first_packet:
- self.y_offset = self.buffer[0][0]
+ self.y_offset = self.buffer[0][0] * 1.5
+ # print(self.y_offset)
self.first_packet = False
pos = self.x_offset, self.calc_y(self.buffer[0][0]) + self.y
for i, (value, quality) in enumerate(self.buffer):
@@ -94,7 +95,7 @@ def main():
"emotiv_encrypted_data_UD20160103001874_2017-04-05.17-42-23.292665.csv"
"emotiv_encrypted_data_UD20160103001874_2017-04-05.17-39-48.516489.csv"
"emotiv_encrypted_data_UD20160103001874_2017-04-05.17-21-32.384061.csv"
- with Emotiv(display_output=True, verbose=True, is_research=True, force_epoc_mode=False, force_old_crypto=False,
+ with Emotiv(display_output=False, verbose=False, is_research=False, force_epoc_mode=False, force_old_crypto=False,
input_source="emotiv_encrypted_data_UD20160103001874_2017-04-05.17-39-48.516489.csv") as emotiv:
for name in 'AF3 F7 F3 FC5 T7 P7 O1 O2 P8 T8 FC6 F4 F8 AF4'.split(' '):
graphers.append(Grapher(screen, name, len(graphers), emotiv.old_model))
View
@@ -66,6 +66,7 @@ def draw(self):
if self.first_packet:
self.y_offset = self.buffer[0][0]
+ # print(self.y_offset)
self.first_packet = False
pos = self.x_offset, self.calc_y(self.buffer[0][0]) + self.y
for i, (value, quality) in enumerate(self.buffer):

0 comments on commit 7f25321

Please sign in to comment.