-
Notifications
You must be signed in to change notification settings - Fork 0
/
ppt.py
54 lines (45 loc) · 1.28 KB
/
ppt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from __future__ import print_function
from myo.utils import TimeInterval
import keyboard
import myo
import sys
import os
class Listener(myo.DeviceListener):
def __init__(self):
self.interval = TimeInterval(None, 0.05)
self.acceleration = None
self.gyroscope = None
self.orientation = None
self.pose = myo.Pose.rest
self.emg_enabled = True
self.locked = False
self.rssi = None
self.emg = None
self.temp = 0
def output(self):
if not self.interval.check_and_reset():
return
def on_connected(self, event):
event.device.request_rssi()
def on_pose(self, event):
self.pose = event.pose
if self.pose == myo.Pose.fist:
#self.locked = not self.locked
print(self.locked)
print("fist")
if self.pose == myo.Pose.rest:
print("rest")
if self.pose == myo.Pose.wave_in and not self.locked:
keyboard.press_and_release("left_arrow")
print("Wave In")
if self.pose == myo.Pose.wave_out and not self.locked:
keyboard.press_and_release("right_arrow")
print("Wave out")
if self.pose == myo.Pose.fingers_spread:
print("Fingers Spread")
if __name__ == '__main__':
myo.init()
hub = myo.Hub()
listener = Listener()
while hub.run(listener.on_event, 1000):
pass