コード例 #1
0
ファイル: mind_pulse.py プロジェクト: surejm/mens-amplio
from mindwave import BluetoothHeadset


def GetColorsForAttentionLevel(attention):
    redlevel = int((point.attention - 33) * 255 / 33.0)
    redlevel = max(min(redlevel, 255), 0)
    bluelevel = 255 - redlevel
    return redlevel, 0, bluelevel


led_strip = LedStrip("/dev/spidev0.0", 20)
# Set lights to a soft white to indicate the program is starting,
# but not reading your mind yet.
led_strip.setAll((64, 64, 64))
led_strip.update()
headset = BluetoothHeadset()
while True:
    point = headset.readDatapoint()
    if not point or not point.clean():
        print(
            "Not getting clean data yet. If you see this at startup, wait ~20s. "
            "If it persists, adjust the headset for a better fit.")
        led_strip.setAll((64, 64, 64))
        led_strip.update()
        continue
    print "Attention:", point.attention
    r, g, b = GetColorsForAttentionLevel(point.attention)
    print "Coloring LEDS to RGB:", (r, g, b)
    led_strip.setAll((g, b, r))  # LED strip uses funky ordering
    led_strip.update()
コード例 #2
0
#!/usr/bin/python

'''Simple example usage of Mindwave headset

Connects to the headset, and continuously prints the data it reads
in a legible format. Raw data is not shown.
'''

from mindwave import BluetoothHeadset, FakeHeadset

#h = FakeHeadset()
h = BluetoothHeadset()
while True:
  point = h.readDatapoint()
  print point

# That's it. Easy enough.
コード例 #3
0
import sys
sys.path.append(PATH_TO_PULSE_FOLDER)
from LedStrip_WS2801 import LedStrip_WS2801 as LedStrip
from mindwave import BluetoothHeadset

def GetColorsForAttentionLevel(attention):
  redlevel = int((point.attention - 33) * 255 / 33.0)
  redlevel = max(min(redlevel, 255), 0)
  bluelevel = 255 - redlevel
  return redlevel, 0, bluelevel

led_strip = LedStrip("/dev/spidev0.0", 20)
# Set lights to a soft white to indicate the program is starting,
# but not reading your mind yet.
led_strip.setAll((64, 64, 64))
led_strip.update()
headset = BluetoothHeadset()
while True:
  point = headset.readDatapoint()
  if not point or not point.clean():
    print ("Not getting clean data yet. If you see this at startup, wait ~20s. "
           "If it persists, adjust the headset for a better fit.")
    led_strip.setAll((64, 64, 64))
    led_strip.update()
    continue
  print "Attention:", point.attention
  r, g, b = GetColorsForAttentionLevel(point.attention)
  print "Coloring LEDS to RGB:", (r, g, b)
  led_strip.setAll((g, b, r))  # LED strip uses funky ordering
  led_strip.update()
コード例 #4
0
ファイル: pay_attention.py プロジェクト: surejm/mens-amplio
#!/usr/bin/python

'''A simple program to test your attention

Prints a different message based on your current attention level.

I have found that if I stare fixed at the output, my attention stays
medium-to-high. If I move my eyes around for a few seconds and look back,
it pretty reliably tells me I'm not paying attention.

...a second trial of this was far less reliable and I couldn't seem to
control it. Unclear how much we can do with this.
'''

from mindwave import BluetoothHeadset

h = BluetoothHeadset()
while True:
  point = h.readDatapoint(wait_for_clean_data=True)
  print "-----------------------------------"
  if point.attention > 70:
    print "You're paying super close attention!"
  elif point.attention < 30:
    print "HEY YOU -- quit daydreaming"
  else:
    print "You're sorta kinda paying attention..."
  print "-----------------------------------"
コード例 #5
0
#!/usr/bin/python
'''Simple example usage of Mindwave headset

Connects to the headset, and continuously prints the data it reads
in a legible format. Raw data is not shown.
'''

from mindwave import BluetoothHeadset, FakeHeadset

#h = FakeHeadset()
h = BluetoothHeadset()
while True:
    point = h.readDatapoint()
    print point

# That's it. Easy enough.