Plex is awesome. It’s an important part of our media centre at home. When I started playing with Myo apps, I figured Plex should be my first stop. I set to develop a small desktop app that would allow me to navigate in Plex and play/pause movies from my couch.
Developing small Myo desktop apps is easy: Thalmic wrote a few tutorials to cover the basics, and that also helps you grasp the basics of Lua.
My goals with this small app were simple:
- I wanted to learn as much as possible about Myo and Lua
- It should only be triggered in the Plex app
- I wanted to use the 5 basic Myo gestures
- I wanted to implement one of the combo gestures to understand how to monitor the position of the band on the arm.
The first 3 steps turned out to be easy: I had it working in less than an hour. This was mostly thanks to Myo API reference where I learned about the different functions I could use in the app, and the tutorials posted on Thalmic’s blog, they were very helpful.
The last step, however, took some time.
“Wave in” and “Wave out” are 2 of the basic Myo gestures. They’re often mapped with “Previous” and “Next” actions in Myo apps. That’s useful in Plex, but I also needed 2 more actions: Up and Down, to navigate the different Plex menus.
I figured I would use the same 2 basic gestures for all 4 actions, but change the output based on the rotation of the arm. If you think about it, if you rotate your arm 90 degrees and wave in or out, it’s really like you’d be waving up or down.
Detecting the arm rotation was the most difficult. 3 things were helpful there:
myo.getRoll()(#) detects the position of the band on your arm
onUnlock()(#) allows you to attach actions right when the band becomes unlocked. I used that to reset the roll value, since your arm should be resting when you unlock the band.
onPeriodic()(#) can be used to query the band every 10 milliseconds to check its position.
Here is the code I came up with. You can download it and install it on your computer through Myo’s application manager. Feel free to submit Pull Requests if you have ideas to improve the app.