Permalink
Browse files

Fixed typo in the announcement. Modified reader script to attempt to …

…read from the second HID interface. Added psyco support to the renderer and made the window thinner for performance reasons.
  • Loading branch information...
1 parent fd43743 commit 87ee0ad35ff5e9b8f64cc3f3a045b6b046d262bf @daeken committed Sep 13, 2010
Showing with 31 additions and 13 deletions.
  1. +1 −1 Announcement.md
  2. +20 −8 read.py
  3. +10 −4 render.py
View
@@ -3,7 +3,7 @@ Intro
I've been interested in the [Emotiv EPOC](http://emotiv.com/) headset for a while; a $300 14-sensor EEG. It's intended for gaming, but it's quite high quality. There's a research SDK available for $750, but it's Windows-only and totally proprietary. I decided to hack it, and open the consumer headset up to development. Thanks to [donations](http://pledgie.com/campaigns/12906) I got some hardware in hand this weekend.
-I'm happy to announce the Emokit project, an open source interface to the EPOC. The goal is to open it up to develompent and enable new products and research. For the first time, we have access to a high-quality EEG for $300 -- this is huge.
+I'm happy to announce the Emokit project, an open source interface to the EPOC. The goal is to open it up to development and enable new products and research. For the first time, we have access to a high-quality EEG for $300 -- this is huge.
Code
====
View
28 read.py
@@ -25,18 +25,30 @@ def sample_handler(data):
print ' '.join('%02x' % ord(c) for c in decrypt(data))
count += 1
+def bci_handler(data):
+ print '!!!', `data`
+
def main(fn=None):
if fn == None:
- for device in hid.find_all_hid_devices():
- if device.vendor_id == 0x21A1 and device.product_name == 'Brain Waves':
- try:
+ devices = []
+ try:
+ for device in hid.find_all_hid_devices():
+ if device.vendor_id != 0x21A1:
+ continue
+ if device.product_name == 'Brain Waves':
+ devices.append(device)
device.open()
device.set_raw_data_handler(sample_handler)
- while device.is_plugged() and count < 1000:
- time.sleep(0.1)
- finally:
- device.close()
- break
+ elif device.product_name == 'EPOC BCI':
+ print 'foo'
+ devices.append(device)
+ device.open()
+ device.set_raw_data_handler(bci_handler)
+ while True:#device.is_plugged() and count < 1000:
+ time.sleep(0.1)
+ finally:
+ for device in devices:
+ device.close()
else:
for line in file(fn, 'r').readlines():
data = [0] + [int(x, 16) for x in line.strip().split(' ')]
View
@@ -1,3 +1,9 @@
+try:
+ import psyco
+ psyco.full()
+except:
+ print 'No psyco. Expect poor performance.'
+
import emotiv, pygame, sys, time
emotiv = emotiv.Emotiv()
@@ -19,7 +25,7 @@ def __init__(self, screen, name, i):
self.textpos.centery = self.y
def update(self, packet):
- if len(self.buffer) == 1024 - self.xoff:
+ if len(self.buffer) == 800 - self.xoff:
self.buffer = self.buffer[1:]
self.buffer.append(getattr(packet, self.name))
@@ -52,9 +58,9 @@ def main(debug=False):
global gheight
pygame.init()
- screen = pygame.display.set_mode((1024, 600))
+ screen = pygame.display.set_mode((800, 600))
- curX, curY = 512, 300
+ curX, curY = 400, 300
graphers = []
if debug == False:
@@ -89,7 +95,7 @@ def main(debug=False):
curX -= packet.gyroX - 1
if abs(packet.gyroY) > 1:
curY += packet.gyroY
- curX = max(0, min(curX, 1024))
+ curX = max(0, min(curX, 800))
curY = max(0, min(curY, 600))
map(lambda x: x.update(packet), graphers)

0 comments on commit 87ee0ad

Please sign in to comment.