Created
June 26, 2015 06:03
-
-
Save AVGP/0e64123b62317f739fdf to your computer and use it in GitHub Desktop.
Python script to listen to Myo "WAVE" poses to send left/right key events under Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
sys.path.append('../lib/') | |
from device_listener import DeviceListener | |
from pose_type import PoseType | |
class WavePoseListener(DeviceListener): | |
def on_pose(self, pose): | |
pose_type = PoseType(pose) | |
if pose_type.name == 'WAVE_OUT': | |
os.system('xdotool key Right') | |
elif pose_type.name == 'WAVE_IN': | |
os.system('xdotool key Left') | |
def main(): | |
print('Start Myo for Linux') | |
listener = WavePoseListener() | |
myo = Myo() | |
try: | |
myo.connect() | |
myo.add_listener(listener) | |
while True: | |
myo.run() | |
except KeyboardInterrupt: | |
pass | |
except ValueError as ex: | |
print(ex) | |
finally: | |
myo.safely_disconnect() | |
print('Finished.') | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment