├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── download ├── MyoForProcessing.txt └── MyoForProcessing.zip ├── examples ├── Myo_1_Application │ ├── Myo_1_Application.pde │ └── data │ │ ├── double_tab.png │ │ ├── make_a_fist.png │ │ ├── spread_fingers.png │ │ ├── wave_left.png │ │ └── wave_right.png ├── Myo_2_Callbacks │ └── Myo_2_Callbacks.pde └── Myo_3_EMG_Data │ └── Myo_3_EMG_Data.pde ├── library ├── MyoForProcessing.jar ├── macosx │ ├── libmyo.jnilib │ └── myo.framework │ │ ├── Headers │ │ ├── cxx │ │ │ ├── DeviceListener.hpp │ │ │ ├── Hub.hpp │ │ │ ├── Myo.hpp │ │ │ ├── Pose.hpp │ │ │ ├── Quaternion.hpp │ │ │ ├── Vector3.hpp │ │ │ ├── detail │ │ │ │ └── ThrowOnError.hpp │ │ │ └── impl │ │ │ │ ├── Hub_impl.hpp │ │ │ │ ├── Myo_impl.hpp │ │ │ │ └── Pose_impl.hpp │ │ ├── libmyo.h │ │ ├── libmyo │ │ │ └── detail │ │ │ │ └── visibility.h │ │ └── myo.hpp │ │ ├── Versions │ │ ├── A │ │ │ ├── Headers │ │ │ │ ├── cxx │ │ │ │ │ ├── DeviceListener.hpp │ │ │ │ │ ├── Hub.hpp │ │ │ │ │ ├── Myo.hpp │ │ │ │ │ ├── Pose.hpp │ │ │ │ │ ├── Quaternion.hpp │ │ │ │ │ ├── Vector3.hpp │ │ │ │ │ ├── detail │ │ │ │ │ │ └── ThrowOnError.hpp │ │ │ │ │ └── impl │ │ │ │ │ │ ├── Hub_impl.hpp │ │ │ │ │ │ ├── Myo_impl.hpp │ │ │ │ │ │ └── Pose_impl.hpp │ │ │ │ ├── libmyo.h │ │ │ │ ├── libmyo │ │ │ │ │ └── detail │ │ │ │ │ │ └── visibility.h │ │ │ │ └── myo.hpp │ │ │ ├── _CodeSignature │ │ │ │ └── CodeResources │ │ │ └── myo │ │ └── Current │ │ │ ├── Headers │ │ │ ├── cxx │ │ │ │ ├── DeviceListener.hpp │ │ │ │ ├── Hub.hpp │ │ │ │ ├── Myo.hpp │ │ │ │ ├── Pose.hpp │ │ │ │ ├── Quaternion.hpp │ │ │ │ ├── Vector3.hpp │ │ │ │ ├── detail │ │ │ │ │ └── ThrowOnError.hpp │ │ │ │ └── impl │ │ │ │ │ ├── Hub_impl.hpp │ │ │ │ │ ├── Myo_impl.hpp │ │ │ │ │ └── Pose_impl.hpp │ │ │ ├── libmyo.h │ │ │ ├── libmyo │ │ │ │ └── detail │ │ │ │ │ └── visibility.h │ │ │ └── myo.hpp │ │ │ ├── _CodeSignature │ │ │ └── CodeResources │ │ │ └── myo │ │ └── myo ├── myo-java-0.9.1-SNAPSHOT.jar ├── windows │ ├── JNIJavaMyoLib.dll │ └── myo32.dll └── windows64 │ ├── JNIJavaMyoLib.dll │ └── myo64.dll ├── reference ├── allclasses-frame.html ├── allclasses-noframe.html ├── constant-values.html ├── de │ └── voidplus │ │ └── myo │ │ ├── Arm.Type.html │ │ ├── Arm.html │ │ ├── Collector.html │ │ ├── Device.html │ │ ├── Myo.Event.html │ │ ├── Myo.LockingPolicy.html │ │ ├── Myo.Unlock.html │ │ ├── Myo.html │ │ ├── Pose.Type.html │ │ ├── Pose.html │ │ ├── package-frame.html │ │ ├── package-summary.html │ │ └── package-tree.html ├── deprecated-list.html ├── example_application.png ├── github_cover.png ├── help-doc.html ├── index-all.html ├── index.html ├── overview-tree.html ├── package-list └── stylesheet.css └── src └── de └── voidplus └── myo ├── Arm.java ├── Collector.java ├── Device.java ├── Myo.java └── Pose.java /.gitattributes: -------------------------------------------------------------------------------- 1 | reference/* linguist-documentation 2 | library/* linguist-vendored 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # System 2 | .DS_Store 3 | .svn 4 | 5 | # Eclipse 6 | .project 7 | .classpath 8 | .settings/ 9 | 10 | # Project 11 | src/development/ 12 | lib/ 13 | resources/ 14 | distribution/ 15 | web/ 16 | bin/ 17 | tmp/ 18 | *.psd 19 | 20 | # IntelliJ IDEA 21 | myo-processing.iml 22 | .idea/ 23 | out/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Join the chat at https://gitter.im/nok/myo-processing](https://badges.gitter.im/nok/myo-processing.svg)](https://gitter.im/nok/myo-processing?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nok/myo-processing/master/LICENSE) 2 | 3 | --- 4 | 5 | ![Myo for Processing](reference/github_cover.png) 6 | 7 | === 8 | 9 | Contributed library to use the [Myo](https://www.thalmic.com) in [Processing](http://processing.org/). 10 | 11 | 12 | ## Table of Contents 13 | 14 | - [About](#about) 15 | - [Download](#download) 16 | - [Installation](#installation) 17 | - [Dependencies](#dependencies) 18 | - [Tested](#tested) 19 | - [Examples](#examples) 20 | - [Usage](#usage) 21 | - [Questions?](#questions) 22 | - [License](#license) 23 | 24 | 25 | ## About 26 | 27 | The [Myo](https://www.thalmic.com) armband lets you use the electrical activity in your muscles to wirelessly control your computer, phone, and other favorite digital technologies. With the wave of your hand, it will transform how you interact with your digital world. 28 | 29 | 30 | ## Download 31 | 32 | - [Myo for Processing v0.9.0.3](download/MyoForProcessing.zip?raw=true) 33 | 34 | 35 | ## Installation 36 | 37 | Unzip and put the extracted *MyoForProcessing* folder into the libraries directory of your Processing sketches. The References and examples are stored in the *MyoForProcessing* directory. For more help read the [tutorial](http://www.learningprocessing.com/tutorials/libraries/) by [Daniel Shiffman](https://github.com/shiffman). 38 | 39 | 40 | ## Dependencies 41 | 42 | - [Myo Connect v0.9.0](https://developer.thalmic.com/downloads) 43 | - [Myo Firmware v1.5.1970](https://developer.thalmic.com/downloads) 44 | 45 | 46 | ## Tested 47 | 48 | System: 49 | 50 | - **OSX** (*Mac OS X 10.7 and higher - tested with Mac OS X 10.10 Yosemite*) 51 | - **Windows** (*not tested yet, but x86 and x64 should work*) (*Windows 7 and 8*) 52 | 53 | Myo SDK version: 54 | 55 | - **0.9.0** 56 | 57 | Processing version: 58 | 59 | - **3.1.1** 60 | - 3.0.2 61 | - 3.0a4 62 | 63 | 64 | ## Examples 65 | 66 | - Application → [Myo_1_Application.pde](examples/Myo_1_Application/Myo_1_Application.pde) 67 | - [Callbacks of events](#basics) → [Myo_2_Callbacks.pde](examples/Myo_2_Callbacks/Myo_2_Callbacks.pde) 68 | - EMG data streams → [Myo_3_EMG_Data.pde](examples/Myo_3_EMG_Data/Myo_3_EMG_Data.pde) 69 | 70 | Here you see a screenshot of the viewable example [Myo_1_Application.pde](examples/Myo_1_Application/Myo_1_Application.pde): 71 | 72 | ![First example Myo_1_Application.pde](reference/example_application.png) 73 | 74 | 75 | ## Basics 76 | 77 | ```java 78 | import de.voidplus.myo.*; 79 | 80 | Myo myo; 81 | 82 | void setup() { 83 | size(800, 400); 84 | background(255); 85 | // ... 86 | 87 | myo = new Myo(this); 88 | // myo = new Myo(this, true); // enable EMG data 89 | } 90 | 91 | void draw() { 92 | background(255); 93 | // ... 94 | } 95 | 96 | 97 | // ========================================================== 98 | // Executable commands: 99 | 100 | void mousePressed() { 101 | if (myo.hasDevices()) { 102 | myo.vibrate(); 103 | myo.requestRssi(); 104 | myo.requestBatteryLevel(); 105 | } 106 | } 107 | 108 | 109 | // ========================================================== 110 | // Application lifecycle: 111 | 112 | void myoOnPair(Device myo, long timestamp) { 113 | println("Sketch: myoOnPair() has been called"); 114 | int deviceId = myo.getId(); 115 | int deviceBatteryLevel = myo.getBatteryLevel(); 116 | int deviceRssi = myo.getRssi(); 117 | String deviceFirmware = myo.getFirmware(); 118 | } 119 | void myoOnUnpair(Device myo, long timestamp) { 120 | println("Sketch: myoOnUnpair() has been called"); 121 | } 122 | 123 | void myoOnConnect(Device myo, long timestamp) { 124 | println("Sketch: myoOnConnect() has been called"); 125 | int deviceId = myo.getId(); 126 | int deviceBatteryLevel = myo.getBatteryLevel(); 127 | int deviceRssi = myo.getRssi(); 128 | String deviceFirmware = myo.getFirmware(); 129 | } 130 | void myoOnDisconnect(Device myo, long timestamp) { 131 | println("Sketch: myoOnDisconnect() has been called"); 132 | } 133 | 134 | void myoOnWarmupCompleted(Device myo, long timestamp) { 135 | println("Sketch: myoOnWarmupCompleted() has been called"); 136 | } 137 | 138 | void myoOnArmSync(Device myo, long timestamp, Arm arm) { 139 | println("Sketch: myoOnArmSync() has been called"); 140 | 141 | switch (arm.getType()) { 142 | case LEFT: 143 | println("Left arm"); 144 | break; 145 | case RIGHT: 146 | println("Right arm"); 147 | break; 148 | default: 149 | println("Unknown arm"); 150 | break; 151 | } 152 | } 153 | 154 | void myoOnArmUnsync(Device myo, long timestamp) { 155 | println("Sketch: myoOnArmUnsync()"); 156 | } 157 | 158 | void myoOnLock(Device myo, long timestamp) { 159 | println("Sketch: myoOnLock() has been called"); 160 | } 161 | 162 | void myoOnUnLock(Device myo, long timestamp) { 163 | println("Sketch: myoOnUnLock() has been called"); 164 | } 165 | 166 | 167 | // ---------------------------------------------------------- 168 | // Gestures or poses: 169 | 170 | void myoOnPose(Device myo, long timestamp, Pose pose) { 171 | println("Sketch: myoOnPose() has been called"); 172 | switch (pose.getType()) { 173 | case REST: 174 | println("Pose: REST"); 175 | break; 176 | case FIST: 177 | println("Pose: FIST"); 178 | break; 179 | case FINGERS_SPREAD: 180 | println("Pose: FINGERS_SPREAD"); 181 | break; 182 | case DOUBLE_TAP: 183 | println("Pose: DOUBLE_TAP"); 184 | break; 185 | case WAVE_IN: 186 | println("Pose: WAVE_IN"); 187 | break; 188 | case WAVE_OUT: 189 | println("Pose: WAVE_OUT"); 190 | break; 191 | } 192 | } 193 | 194 | 195 | // ---------------------------------------------------------- 196 | // Additional information: 197 | 198 | void myoOnRssi(Device myo, long timestamp, int rssi) { 199 | println("Sketch: myoOnRssi() has been called, rssi: " + rssi); 200 | } 201 | 202 | void myoOnBatteryLevelReceived(Device myo, long timestamp, int batteryLevel) { 203 | println("Sketch: myoOnBatteryLevel() has been called, batteryLevel: " + batteryLevel); 204 | } 205 | 206 | 207 | // ---------------------------------------------------------- 208 | // Data streams: 209 | 210 | void myoOnOrientationData(Device myo, long timestamp, PVector orientation) { 211 | // println("Sketch: myoOnOrientationData() has been called"); 212 | } 213 | 214 | void myoOnAccelerometerData(Device myo, long timestamp, PVector accelerometer) { 215 | // println("Sketch: myoOnAccelerometerData() has been called"); 216 | } 217 | 218 | void myoOnGyroscopeData(Device myo, long timestamp, PVector gyroscope) { 219 | // println("Sketch: myoOnGyroscopeData() has been called"); 220 | } 221 | 222 | void myoOnEmgData(Device myo, long timestamp, int[] data) { 223 | // println("Sketch: myoOnEmgData() has been called"); 224 | } 225 | 226 | 227 | // ========================================================== 228 | // Alternatively you can use a global callback: 229 | 230 | void myoOn(Myo.Event event, Device myo, long timestamp) { 231 | switch(event) { 232 | case PAIR: 233 | // println("Sketch: myoOn() of type 'PAIR' has been called"); 234 | break; 235 | case UNPAIR: 236 | // println("Sketch: myoOn() of type 'UNPAIR' has been called"); 237 | break; 238 | case CONNECT: 239 | // println("Sketch: myoOn() of type 'CONNECT' has been called"); 240 | String firmware = myo.getFirmware(); 241 | int deviceId = myo.getId(); 242 | break; 243 | case DISCONNECT: 244 | // println("Sketch: myoOn() of type 'DISCONNECT' has been called"); 245 | break; 246 | case ARM_SYNC: 247 | // println("Sketch: myoOn() of type 'ARM_SYNC' has been called"); 248 | break; 249 | case ARM_UNSYNC: 250 | // println("Sketch: myoOn() of type 'ARM_UNSYNC' has been called"); 251 | break; 252 | case WARMUP_COMPLETED: 253 | // println("Sketch: myoOn() of type 'WARMUP_COMPLETED' has been called"); 254 | break; 255 | case POSE: 256 | switch (myo.getPose().getType()) { 257 | case FIST: 258 | // println("Pose: FIST"); 259 | break; 260 | } 261 | // println("Sketch: myoOn() of type 'POSE' has been called"); 262 | break; 263 | case LOCK: 264 | // println("Sketch: myoOn() of type 'LOCK' has been called"); 265 | case UNLOCK: 266 | // println("Sketch: myoOn() of type 'UNLOCK' has been called"); 267 | break; 268 | case BATTERY_LEVEL: 269 | // println("Sketch: myoOn() of type 'BATTERY_LEVEL' has been called"); 270 | int batteryLevel = myo.getBatteryLevel(); 271 | break; 272 | case RSSI: 273 | // println("Sketch: myoOn() of type 'RSSI' has been called"); 274 | int rssi = myo.getRssi(); 275 | break; 276 | case ORIENTATION_DATA: 277 | // println("Sketch: myoOn() of type 'ORIENTATION_DATA' has been called"); 278 | PVector orientation = myo.getOrientation(); 279 | break; 280 | case ACCELEROMETER_DATA: 281 | // println("Sketch: myoOn() of type 'ACCELEROMETER_DATA' has been called"); 282 | PVector accelerometer = myo.getAccelerometer(); 283 | break; 284 | case GYROSCOPE_DATA: 285 | // println("Sketch: myoOn() of type 'GYROSCOPE_DATA' has been called"); 286 | PVector gyroscope = myo.getGyroscope(); 287 | break; 288 | case EMG_DATA: 289 | // println("Sketch: myoOn() of type 'EMG_DATA' has been called"); 290 | int[] data = myo.getEmg(); 291 | break; 292 | } 293 | } 294 | ``` 295 | 296 | ## Verbose logging table 297 | 298 | You can monitor console outputs by enabling the verbose mode and setting a verbose level. In most cases it's helpful for debugging. 299 | 300 | ```java 301 | Myo myo = new Myo(this); 302 | myo.setVerbose(true); // Default level: 1 303 | myo.setVerboseLevel(2); // Levels: [1, 2, 3] 304 | // myo.setVerbose(false); // Disable logging 305 | ``` 306 | 307 | | Method | Level | 308 | | ------------------------- | :-------: | 309 | | myoOnPair | 1 | 310 | | myoOnUnpair | 1 | 311 | | myoOnConnect | 1 | 312 | | myoOnDisconnect | 1 | 313 | | myoOnWarmupCompleted | 1 | 314 | | myoOnArmSync | 1 | 315 | | myoOnArmUnsync | 1 | 316 | | myoOnPose | 2 | 317 | | myoOnLock | 2 | 318 | | myoOnUnlock | 2 | 319 | | myoOnRssi | 2 | 320 | | myoOnBatteryLevel | 2 | 321 | | myoOnOrientationData | 3 | 322 | | myoOnAccelerometerData | 3 | 323 | | myoOnGyroscopeData | 3 | 324 | | myoOnEmgData | 3 | 325 | 326 | ## Questions? 327 | 328 | Don't be shy and feel free to contact me on [Twitter](https://twitter.com/darius_morawiec) or [Gitter](https://gitter.im/nok/myo-processing). 329 | 330 | 331 | ## License 332 | 333 | The library is Open Source Software released under the [license](LICENSE). 334 | -------------------------------------------------------------------------------- /download/MyoForProcessing.txt: -------------------------------------------------------------------------------- 1 | name = Myo for Processing 2 | authorList = [Darius Morawiec](http://nok.onl) 3 | url = https://github.com/nok/myo-processing 4 | categories = Hardware 5 | sentence = Library to use the [Myo](https://www.thalmic.com) in [Processing](http://processing.org/). 6 | paragraph = The [Myo](https://www.thalmic.com) armband lets you use the electrical activity in your muscles to wirelessly control your computer, phone, and other favorite digital technologies. With the wave of your hand, it will transform how you interact with your digital world. 7 | version = 21 8 | prettyVersion = 0.9.0.3 9 | minRevision = 0 10 | maxRevision = 0 -------------------------------------------------------------------------------- /download/MyoForProcessing.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nok/myo-processing/4fd7503f89325eb835be7bd11bf8b26ff3d64225/download/MyoForProcessing.zip -------------------------------------------------------------------------------- /examples/Myo_1_Application/Myo_1_Application.pde: -------------------------------------------------------------------------------- 1 | import de.voidplus.myo.*; 2 | 3 | Myo myo; 4 | 5 | PImage[] img; 6 | boolean[] active; 7 | 8 | void setup() { 9 | size(800, 200); 10 | background(255); 11 | // ... 12 | 13 | myo = new Myo(this); 14 | // myo.setVerbose(true); 15 | // myo.setVerboseLevel(2); // Default: 1 (1-3) 16 | 17 | myo.setFrequency(10); 18 | 19 | img = new PImage[5]; 20 | img[0] = loadImage("data/double_tab.png"); 21 | img[1] = loadImage("data/spread_fingers.png"); 22 | img[2] = loadImage("data/wave_right.png"); 23 | img[3] = loadImage("data/wave_left.png"); 24 | img[4] = loadImage("data/make_a_fist.png"); 25 | 26 | active = new boolean[5]; 27 | resetImages(); 28 | } 29 | 30 | void resetImages(){ 31 | for(int i = 0; i<5; i++){ 32 | active[i] = false; 33 | } 34 | } 35 | 36 | void draw() { 37 | background(255); 38 | // ... 39 | 40 | for (int i = 0; i<5; i++) { 41 | tint(255, (active[i]) ? 100 : 50); 42 | image(img[i], ((140*i)+(i*10))+30, 30, 140, 140); 43 | } 44 | } 45 | 46 | void myoOnPose(Device myo, long timestamp, Pose pose) { 47 | 48 | if (!pose.getType().toString().equals("REST")) { 49 | resetImages(); 50 | } 51 | 52 | switch (pose.getType()) { 53 | case REST: 54 | // resetImages(); 55 | break; 56 | case FIST: 57 | active[4] = true; 58 | myo.vibrate(); 59 | break; 60 | case FINGERS_SPREAD: 61 | active[1] = true; 62 | break; 63 | case DOUBLE_TAP: 64 | active[0] = true; 65 | break; 66 | case WAVE_IN: 67 | active[2] = true; 68 | break; 69 | case WAVE_OUT: 70 | active[3] = true; 71 | break; 72 | default: 73 | break; 74 | } 75 | } 76 | 77 | void myoOnLock(Device myo, long timestamp) { 78 | resetImages(); 79 | } 80 | 81 | void myoOnUnLock(Device myo, long timestamp) { 82 | resetImages(); 83 | } -------------------------------------------------------------------------------- /examples/Myo_1_Application/data/double_tab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nok/myo-processing/4fd7503f89325eb835be7bd11bf8b26ff3d64225/examples/Myo_1_Application/data/double_tab.png -------------------------------------------------------------------------------- /examples/Myo_1_Application/data/make_a_fist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nok/myo-processing/4fd7503f89325eb835be7bd11bf8b26ff3d64225/examples/Myo_1_Application/data/make_a_fist.png -------------------------------------------------------------------------------- /examples/Myo_1_Application/data/spread_fingers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nok/myo-processing/4fd7503f89325eb835be7bd11bf8b26ff3d64225/examples/Myo_1_Application/data/spread_fingers.png -------------------------------------------------------------------------------- /examples/Myo_1_Application/data/wave_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nok/myo-processing/4fd7503f89325eb835be7bd11bf8b26ff3d64225/examples/Myo_1_Application/data/wave_left.png -------------------------------------------------------------------------------- /examples/Myo_1_Application/data/wave_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nok/myo-processing/4fd7503f89325eb835be7bd11bf8b26ff3d64225/examples/Myo_1_Application/data/wave_right.png -------------------------------------------------------------------------------- /examples/Myo_2_Callbacks/Myo_2_Callbacks.pde: -------------------------------------------------------------------------------- 1 | import de.voidplus.myo.*; 2 | 3 | Myo myo; 4 | 5 | void setup() { 6 | size(800, 400); 7 | background(255); 8 | // ... 9 | 10 | myo = new Myo(this); 11 | // myo = new Myo(this, true); // enable EMG data 12 | } 13 | 14 | void draw() { 15 | background(255); 16 | // ... 17 | } 18 | 19 | 20 | // ========================================================== 21 | // Executable commands: 22 | 23 | void mousePressed() { 24 | if (myo.hasDevices()) { 25 | myo.vibrate(); 26 | myo.requestRssi(); 27 | myo.requestBatteryLevel(); 28 | } 29 | } 30 | 31 | 32 | // ========================================================== 33 | // Application lifecycle: 34 | 35 | void myoOnPair(Device myo, long timestamp) { 36 | println("Sketch: myoOnPair() has been called"); 37 | int deviceId = myo.getId(); 38 | int deviceBatteryLevel = myo.getBatteryLevel(); 39 | int deviceRssi = myo.getRssi(); 40 | String deviceFirmware = myo.getFirmware(); 41 | } 42 | void myoOnUnpair(Device myo, long timestamp) { 43 | println("Sketch: myoOnUnpair() has been called"); 44 | } 45 | 46 | void myoOnConnect(Device myo, long timestamp) { 47 | println("Sketch: myoOnConnect() has been called"); 48 | int deviceId = myo.getId(); 49 | int deviceBatteryLevel = myo.getBatteryLevel(); 50 | int deviceRssi = myo.getRssi(); 51 | String deviceFirmware = myo.getFirmware(); 52 | } 53 | void myoOnDisconnect(Device myo, long timestamp) { 54 | println("Sketch: myoOnDisconnect() has been called"); 55 | } 56 | 57 | void myoOnWarmupCompleted(Device myo, long timestamp) { 58 | println("Sketch: myoOnWarmupCompleted() has been called"); 59 | } 60 | 61 | void myoOnArmSync(Device myo, long timestamp, Arm arm) { 62 | println("Sketch: myoOnArmSync() has been called"); 63 | 64 | switch (arm.getType()) { 65 | case LEFT: 66 | println("Left arm"); 67 | break; 68 | case RIGHT: 69 | println("Right arm"); 70 | break; 71 | default: 72 | println("Unknown arm"); 73 | break; 74 | } 75 | } 76 | 77 | void myoOnArmUnsync(Device myo, long timestamp) { 78 | println("Sketch: myoOnArmUnsync()"); 79 | } 80 | 81 | void myoOnLock(Device myo, long timestamp) { 82 | println("Sketch: myoOnLock() has been called"); 83 | } 84 | 85 | void myoOnUnLock(Device myo, long timestamp) { 86 | println("Sketch: myoOnUnLock() has been called"); 87 | } 88 | 89 | 90 | // ---------------------------------------------------------- 91 | // Gestures or poses: 92 | 93 | void myoOnPose(Device myo, long timestamp, Pose pose) { 94 | println("Sketch: myoOnPose() has been called"); 95 | switch (pose.getType()) { 96 | case REST: 97 | println("Pose: REST"); 98 | break; 99 | case FIST: 100 | println("Pose: FIST"); 101 | break; 102 | case FINGERS_SPREAD: 103 | println("Pose: FINGERS_SPREAD"); 104 | break; 105 | case DOUBLE_TAP: 106 | println("Pose: DOUBLE_TAP"); 107 | break; 108 | case WAVE_IN: 109 | println("Pose: WAVE_IN"); 110 | break; 111 | case WAVE_OUT: 112 | println("Pose: WAVE_OUT"); 113 | break; 114 | } 115 | } 116 | 117 | 118 | // ---------------------------------------------------------- 119 | // Additional information: 120 | 121 | void myoOnRssi(Device myo, long timestamp, int rssi) { 122 | println("Sketch: myoOnRssi() has been called, rssi: " + rssi); 123 | } 124 | 125 | void myoOnBatteryLevelReceived(Device myo, long timestamp, int batteryLevel) { 126 | println("Sketch: myoOnBatteryLevel() has been called, batteryLevel: " + batteryLevel); 127 | } 128 | 129 | 130 | // ---------------------------------------------------------- 131 | // Data streams: 132 | 133 | void myoOnOrientationData(Device myo, long timestamp, PVector orientation) { 134 | // println("Sketch: myoOnOrientationData() has been called"); 135 | } 136 | 137 | void myoOnAccelerometerData(Device myo, long timestamp, PVector accelerometer) { 138 | // println("Sketch: myoOnAccelerometerData() has been called"); 139 | } 140 | 141 | void myoOnGyroscopeData(Device myo, long timestamp, PVector gyroscope) { 142 | // println("Sketch: myoOnGyroscopeData() has been called"); 143 | } 144 | 145 | void myoOnEmgData(Device myo, long timestamp, int[] data) { 146 | // println("Sketch: myoOnEmgData() has been called"); 147 | } 148 | 149 | 150 | // ========================================================== 151 | // Alternatively you can use a global callback: 152 | 153 | void myoOn(Myo.Event event, Device myo, long timestamp) { 154 | switch(event) { 155 | case PAIR: 156 | // println("Sketch: myoOn() of type 'PAIR' has been called"); 157 | break; 158 | case UNPAIR: 159 | // println("Sketch: myoOn() of type 'UNPAIR' has been called"); 160 | break; 161 | case CONNECT: 162 | // println("Sketch: myoOn() of type 'CONNECT' has been called"); 163 | String firmware = myo.getFirmware(); 164 | int deviceId = myo.getId(); 165 | break; 166 | case DISCONNECT: 167 | // println("Sketch: myoOn() of type 'DISCONNECT' has been called"); 168 | break; 169 | case ARM_SYNC: 170 | // println("Sketch: myoOn() of type 'ARM_SYNC' has been called"); 171 | break; 172 | case ARM_UNSYNC: 173 | // println("Sketch: myoOn() of type 'ARM_UNSYNC' has been called"); 174 | break; 175 | case WARMUP_COMPLETED: 176 | // println("Sketch: myoOn() of type 'WARMUP_COMPLETED' has been called"); 177 | break; 178 | case POSE: 179 | switch (myo.getPose().getType()) { 180 | case FIST: 181 | // println("Pose: FIST"); 182 | break; 183 | } 184 | // println("Sketch: myoOn() of type 'POSE' has been called"); 185 | break; 186 | case LOCK: 187 | // println("Sketch: myoOn() of type 'LOCK' has been called"); 188 | case UNLOCK: 189 | // println("Sketch: myoOn() of type 'UNLOCK' has been called"); 190 | break; 191 | case BATTERY_LEVEL: 192 | // println("Sketch: myoOn() of type 'BATTERY_LEVEL' has been called"); 193 | int batteryLevel = myo.getBatteryLevel(); 194 | break; 195 | case RSSI: 196 | // println("Sketch: myoOn() of type 'RSSI' has been called"); 197 | int rssi = myo.getRssi(); 198 | break; 199 | case ORIENTATION_DATA: 200 | // println("Sketch: myoOn() of type 'ORIENTATION_DATA' has been called"); 201 | PVector orientation = myo.getOrientation(); 202 | break; 203 | case ACCELEROMETER_DATA: 204 | // println("Sketch: myoOn() of type 'ACCELEROMETER_DATA' has been called"); 205 | PVector accelerometer = myo.getAccelerometer(); 206 | break; 207 | case GYROSCOPE_DATA: 208 | // println("Sketch: myoOn() of type 'GYROSCOPE_DATA' has been called"); 209 | PVector gyroscope = myo.getGyroscope(); 210 | break; 211 | case EMG_DATA: 212 | // println("Sketch: myoOn() of type 'EMG_DATA' has been called"); 213 | int[] data = myo.getEmg(); 214 | break; 215 | } 216 | } -------------------------------------------------------------------------------- /examples/Myo_3_EMG_Data/Myo_3_EMG_Data.pde: -------------------------------------------------------------------------------- 1 | import de.voidplus.myo.*; 2 | 3 | Myo myo; 4 | ArrayList> sensors; 5 | 6 | void setup() { 7 | size(800, 400); 8 | background(255); 9 | noFill(); 10 | stroke(0); 11 | // ... 12 | 13 | myo = new Myo(this, true); // true, with EMG data 14 | 15 | sensors = new ArrayList>(); 16 | for (int i=0; i<8; i++) { 17 | sensors.add(new ArrayList()); 18 | } 19 | } 20 | 21 | void draw() { 22 | background(255); 23 | // ... 24 | 25 | // Drawing: 26 | synchronized (this) { 27 | for (int i=0; i<8; i++) { 28 | if (!sensors.get(i).isEmpty()) { 29 | beginShape(); 30 | for (int j=0; j width) { 51 | for(ArrayList sensor : sensors) { 52 | sensor.remove(0); 53 | } 54 | } 55 | } 56 | } 57 | 58 | // ---------------------------------------------------------- 59 | 60 | /* 61 | void myoOn(Myo.Event event, Device myo, long timestamp) { 62 | switch(event) { 63 | case EMG_DATA: 64 | // println("myoOn EMG & Device: "+myo.getId()); 65 | // int[] data <- 8 values from -128 to 127 66 | int[] data = myo.getEmg(); 67 | for(int i = 0; i 6 | 7 | #include "Pose.hpp" 8 | 9 | namespace myo { 10 | 11 | class Myo; 12 | template 13 | class Quaternion; 14 | template 15 | class Vector3; 16 | 17 | /// Enumeration identifying a right arm or left arm. 18 | enum Arm { 19 | armLeft = libmyo_arm_left, 20 | armRight = libmyo_arm_right, 21 | armUnknown = libmyo_arm_unknown 22 | }; 23 | 24 | /// Possible directions for Myo's +x axis relative to a user's arm. 25 | enum XDirection { 26 | xDirectionTowardWrist = libmyo_x_direction_toward_wrist, 27 | xDirectionTowardElbow = libmyo_x_direction_toward_elbow, 28 | xDirectionUnknown = libmyo_x_direction_unknown 29 | }; 30 | 31 | /// Possible warmup states for a Myo. 32 | enum WarmupState { 33 | warmupStateUnknown = libmyo_warmup_state_unknown, 34 | warmupStateCold = libmyo_warmup_state_cold, 35 | warmupStateWarm = libmyo_warmup_state_warm, 36 | }; 37 | 38 | /// Possible warmup results for a Myo. 39 | enum WarmupResult { 40 | warmupResultUnknown = libmyo_warmup_result_unknown, 41 | warmupResultSuccess = libmyo_warmup_result_success, 42 | warmupResultFailedTimeout = libmyo_warmup_result_failed_timeout, 43 | }; 44 | 45 | /// Firmware version of Myo. 46 | struct FirmwareVersion { 47 | unsigned int firmwareVersionMajor; ///< Myo's major version must match the required major version. 48 | unsigned int firmwareVersionMinor; ///< Myo's minor version must match the required minor version. 49 | unsigned int firmwareVersionPatch; ///< Myo's patch version must greater or equal to the required patch version. 50 | unsigned int firmwareVersionHardwareRev; ///< Myo's hardware revision; not used to detect firmware version mismatch. 51 | }; 52 | 53 | /// A DeviceListener receives events about a Myo. 54 | /// @see Hub::addListener() 55 | class DeviceListener { 56 | public: 57 | virtual ~DeviceListener() {} 58 | 59 | /// Called when a Myo has been paired. 60 | /// @param myo The Myo for this event. 61 | /// @param timestamp The timestamp of when the event is received by the SDK. Timestamps are 64 bit unsigned 62 | /// integers that correspond to a number of microseconds since some (unspecified) period in time. Timestamps 63 | /// are monotonically non-decreasing. 64 | /// @param firmwareVersion The firmware version of \a myo. 65 | virtual void onPair(Myo* myo, uint64_t timestamp, FirmwareVersion firmwareVersion) {} 66 | 67 | /// Called when a Myo has been unpaired. 68 | /// @param myo The Myo for this event. 69 | /// @param timestamp The timestamp of when the event is received by the SDK. Timestamps are 64 bit unsigned 70 | /// integers that correspond to a number of microseconds since some (unspecified) period in time. Timestamps 71 | /// are monotonically non-decreasing. 72 | virtual void onUnpair(Myo* myo, uint64_t timestamp) {} 73 | 74 | /// Called when a paired Myo has been connected. 75 | /// @param myo The Myo for this event. 76 | /// @param timestamp The timestamp of when the event is received by the SDK. Timestamps are 64 bit unsigned 77 | /// integers that correspond to a number of microseconds since some (unspecified) period in time. Timestamps 78 | /// are monotonically non-decreasing. 79 | /// @param firmwareVersion The firmware version of \a myo. 80 | virtual void onConnect(Myo* myo, uint64_t timestamp, FirmwareVersion firmwareVersion) {} 81 | 82 | /// Called when a paired Myo has been disconnected. 83 | /// @param myo The Myo for this event. 84 | /// @param timestamp The timestamp of when the event is received by the SDK. Timestamps are 64 bit unsigned 85 | /// integers that correspond to a number of microseconds since some (unspecified) period in time. Timestamps 86 | /// are monotonically non-decreasing. 87 | virtual void onDisconnect(Myo* myo, uint64_t timestamp) {} 88 | 89 | /// Called when a paired Myo recognizes that it is on an arm. 90 | /// @param myo The Myo for this event. 91 | /// @param timestamp The timestamp of when the event is received by the SDK. Timestamps are 64 bit unsigned 92 | /// integers that correspond to a number of microseconds since some (unspecified) period in time. Timestamps 93 | /// are monotonically non-decreasing. 94 | /// @param arm The identified Arm of \a myo. 95 | /// @param xDirection The identified XDirection of \a myo. 96 | /// @param rotation The estimated rotation of Myo on the user's arm after a sync. 97 | /// @param warmupState The warmup state of \a myo. If \a warmupState is equal to WarmupState::warmupStateCold, 98 | /// onWarmupCompleted() will be called when the warmup period has completed. 99 | virtual void onArmSync(Myo* myo, uint64_t timestamp, Arm arm, XDirection xDirection, float rotation, 100 | WarmupState warmupState) {} 101 | 102 | /// Called when a paired Myo is moved or removed from the arm. 103 | /// @param myo The Myo for this event. 104 | /// @param timestamp The timestamp of when the event is received by the SDK. Timestamps are 64 bit unsigned 105 | /// integers that correspond to a number of microseconds since some (unspecified) period in time. Timestamps 106 | /// are monotonically non-decreasing. 107 | virtual void onArmUnsync(Myo* myo, uint64_t timestamp) {} 108 | 109 | /// Called when a paired Myo becomes unlocked. 110 | /// @param myo The Myo for this event. 111 | /// @param timestamp The timestamp of when the event is received by the SDK. Timestamps are 64 bit unsigned 112 | /// integers that correspond to a number of microseconds since some (unspecified) period in time. Timestamps 113 | /// are monotonically non-decreasing. 114 | virtual void onUnlock(Myo* myo, uint64_t timestamp) {} 115 | 116 | /// Called when a paired Myo becomes locked. 117 | /// @param myo The Myo for this event. 118 | /// @param timestamp The timestamp of when the event is received by the SDK. Timestamps are 64 bit unsigned 119 | /// integers that correspond to a number of microseconds since some (unspecified) period in time. Timestamps 120 | /// are monotonically non-decreasing. 121 | virtual void onLock(Myo* myo, uint64_t timestamp) {} 122 | 123 | /// Called when a paired Myo has provided a new pose. 124 | /// @param myo The Myo for this event. 125 | /// @param timestamp The timestamp of when the event is received by the SDK. Timestamps are 64 bit unsigned 126 | /// integers that correspond to a number of microseconds since some (unspecified) period in time. Timestamps 127 | /// are monotonically non-decreasing. 128 | /// @param pose The identified Pose of \a myo. 129 | virtual void onPose(Myo* myo, uint64_t timestamp, Pose pose) {} 130 | 131 | /// Called when a paired Myo has provided new orientation data. 132 | /// @param myo The Myo for this event. 133 | /// @param timestamp The timestamp of when the event is received by the SDK. Timestamps are 64 bit unsigned 134 | /// integers that correspond to a number of microseconds since some (unspecified) period in time. Timestamps 135 | /// are monotonically non-decreasing. 136 | /// @param rotation The orientation data of \a myo, as a Quaternion. 137 | virtual void onOrientationData(Myo* myo, uint64_t timestamp, const Quaternion& rotation) {} 138 | 139 | /// Called when a paired Myo has provided new accelerometer data in units of g. 140 | /// @param myo The Myo for this event. 141 | /// @param timestamp The timestamp of when the event is received by the SDK. Timestamps are 64 bit unsigned 142 | /// integers that correspond to a number of microseconds since some (unspecified) period in time. Timestamps 143 | /// are monotonically non-decreasing. 144 | /// @param accel The accelerometer data of \a myo, in units of g. 145 | virtual void onAccelerometerData(Myo* myo, uint64_t timestamp, const Vector3& accel) {} 146 | 147 | /// Called when a paired Myo has provided new gyroscope data in units of deg/s. 148 | /// @param myo The Myo for this event. 149 | /// @param timestamp The timestamp of when the event is received by the SDK. Timestamps are 64 bit unsigned 150 | /// integers that correspond to a number of microseconds since some (unspecified) period in time. Timestamps 151 | /// are monotonically non-decreasing. 152 | /// @param gyro The gyroscope data of \a myo, in units of deg/s. 153 | virtual void onGyroscopeData(Myo* myo, uint64_t timestamp, const Vector3& gyro) {} 154 | 155 | /// Called when a paired Myo has provided a new RSSI value. 156 | /// @param myo The Myo for this event. 157 | /// @param timestamp The timestamp of when the event is received by the SDK. Timestamps are 64 bit unsigned 158 | /// integers that correspond to a number of microseconds since some (unspecified) period in time. Timestamps 159 | /// are monotonically non-decreasing. 160 | /// @param rssi The RSSI (received signal strength indication) of \a myo. 161 | /// @see Myo::requestRssi() to request an RSSI value from the Myo. 162 | virtual void onRssi(Myo* myo, uint64_t timestamp, int8_t rssi) {} 163 | 164 | /// Called when a paired Myo receives an battery level update. 165 | /// Updates occur when the battery level changes and when the battery level is explicitly requested. 166 | /// @param myo The Myo for this event. 167 | /// @param timestamp The timestamp of when the event is received by the SDK. Timestamps are 64 bit unsigned 168 | /// integers that correspond to a number of microseconds since some (unspecified) period in time. Timestamps 169 | /// are monotonically non-decreasing. 170 | /// @param level battery level reported by the myo the value is a number from 0 to 100 representing the percentage 171 | /// of battery life remaining. 172 | virtual void onBatteryLevelReceived(myo::Myo* myo, uint64_t timestamp, uint8_t level) {} 173 | 174 | /// Called when a paired Myo has provided new EMG data. 175 | /// @param myo The Myo for this event. 176 | /// @param timestamp The timestamp of when the event is received by the SDK. Timestamps are 64 bit unsigned 177 | /// integers that correspond to a number of microseconds since some (unspecified) period in time. Timestamps 178 | /// are monotonically non-decreasing. 179 | /// @param emg An array of 8 elements, each corresponding to one sensor. 180 | virtual void onEmgData(myo::Myo* myo, uint64_t timestamp, const int8_t* emg) {} 181 | 182 | /// Called when the warmup period for a Myo has completed. 183 | /// @param myo The Myo for this event. 184 | /// @param timestamp The timestamp of when the event is received by the SDK. Timestamps are 64 bit unsigned 185 | /// integers that correspond to a number of microseconds since some (unspecified) period in time. Timestamps 186 | /// are monotonically non-decreasing. 187 | /// @param warmupResult The warmup result of \a myo. 188 | virtual void onWarmupCompleted(myo::Myo* myo, uint64_t timestamp, WarmupResult warmupResult) {} 189 | 190 | /// @cond LIBMYO_INTERNALS 191 | 192 | virtual void onOpaqueEvent(libmyo_event_t event) {} 193 | 194 | /// @endcond 195 | }; 196 | 197 | } // namespace myo 198 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Headers/cxx/Hub.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #pragma once 4 | 5 | #include 6 | 7 | #include 8 | 9 | namespace myo { 10 | 11 | class Myo; 12 | class DeviceListener; 13 | 14 | /// @brief A Hub provides access to one or more Myo instances. 15 | class Hub { 16 | public: 17 | /// Construct a hub. 18 | /// \a applicationIdentifier must follow a reverse domain name format (ex. com.domainname.appname). Application 19 | /// identifiers can be formed from the set of alphanumeric ASCII characters (a-z, A-Z, 0-9). The hyphen (-) and 20 | /// underscore (_) characters are permitted if they are not adjacent to a period (.) character (i.e. not at the 21 | /// start or end of each segment), but are not permitted in the top-level domain. Application identifiers must have 22 | /// three or more segments. For example, if a company's domain is example.com and the application is named 23 | /// hello-world, one could use "com.example.hello-world" as a valid application identifier. \a applicationIdentifier 24 | /// can be an empty string. 25 | /// Throws an exception of type std::invalid_argument if \a applicationIdentifier is not in the proper reverse 26 | /// domain name format or is longer than 255 characters. 27 | /// Throws an exception of type std::runtime_error if the hub initialization failed for some reason, typically 28 | /// because Myo Connect is not running and a connection can thus not be established. 29 | Hub(const std::string& applicationIdentifier = ""); 30 | 31 | /// Deallocate any resources associated with a Hub. 32 | /// This will cause all Myo instances retrieved from this Hub to become invalid. 33 | ~Hub(); 34 | 35 | /// Wait for a Myo to become paired, or time out after \a timeout_ms milliseconds if provided. 36 | /// If \a timeout_ms is zero, this function blocks until a Myo is found. 37 | /// This function must not be called concurrently with run() or runOnce(). 38 | Myo* waitForMyo(unsigned int milliseconds = 0); 39 | 40 | /// Register a listener to be called when device events occur. 41 | void addListener(DeviceListener* listener); 42 | 43 | /// Remove a previously registered listener. 44 | void removeListener(DeviceListener* listener); 45 | 46 | /// Locking policies supported by Myo. 47 | enum LockingPolicy { 48 | lockingPolicyNone = libmyo_locking_policy_none, 49 | lockingPolicyStandard = libmyo_locking_policy_standard 50 | }; 51 | 52 | /// Set the locking policy for Myos connected to the Hub. 53 | void setLockingPolicy(LockingPolicy lockingPolicy); 54 | 55 | /// Run the event loop for the specified duration (in milliseconds). 56 | void run(unsigned int duration_ms); 57 | 58 | /// Run the event loop until a single event occurs, or the specified duration (in milliseconds) has elapsed. 59 | void runOnce(unsigned int duration_ms); 60 | 61 | /// @cond MYO_INTERNALS 62 | 63 | /// Return the internal libmyo object corresponding to this hub. 64 | libmyo_hub_t libmyoObject(); 65 | 66 | protected: 67 | void onDeviceEvent(libmyo_event_t event); 68 | 69 | Myo* lookupMyo(libmyo_myo_t opaqueMyo) const; 70 | 71 | Myo* addMyo(libmyo_myo_t opaqueMyo); 72 | 73 | libmyo_hub_t _hub; 74 | std::vector _myos; 75 | std::vector _listeners; 76 | 77 | /// @endcond 78 | 79 | private: 80 | // Not implemented 81 | Hub(const Hub&); 82 | Hub& operator=(const Hub&); 83 | }; 84 | 85 | /// @example hello-myo.cpp 86 | /// @example multiple-myos.cpp 87 | /// @example emg-data-sample.cpp 88 | 89 | } // namespace myo 90 | 91 | #include "impl/Hub_impl.hpp" 92 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Headers/cxx/Myo.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #pragma once 4 | 5 | #include 6 | 7 | namespace myo { 8 | 9 | /// Represents a Myo device with a specific MAC address. 10 | /// This class can not be instantiated directly; instead, use Hub to get access to a Myo. 11 | /// There is only one Myo instance corresponding to each device; thus, if the addresses of two Myo instances compare 12 | /// equal, they refer to the same device. 13 | class Myo { 14 | public: 15 | /// Types of vibration supported by the Myo. 16 | enum VibrationType { 17 | vibrationShort = libmyo_vibration_short, 18 | vibrationMedium = libmyo_vibration_medium, 19 | vibrationLong = libmyo_vibration_long 20 | }; 21 | 22 | /// Vibrate the Myo. 23 | void vibrate(VibrationType type); 24 | 25 | /// Request the RSSI of the Myo. An onRssi event will likely be generated with the value of the RSSI. 26 | /// @see DeviceListener::onRssi() 27 | void requestRssi() const; 28 | 29 | /// Request the battery level of the Myo. An onBatteryLevelReceived event will be generated with the value. 30 | /// @see DeviceListener::onBatteryLevelReceived(). 31 | void requestBatteryLevel() const; 32 | 33 | /// Unlock types supported by Myo. 34 | enum UnlockType { 35 | unlockTimed = libmyo_unlock_timed, 36 | unlockHold = libmyo_unlock_hold 37 | }; 38 | 39 | /// Unlock the Myo. 40 | /// Myo will remain unlocked for a short amount of time, after which it will automatically lock again. 41 | /// If Myo was locked, an onUnlock event will be generated. 42 | void unlock(UnlockType type); 43 | 44 | /// Force the Myo to lock immediately. 45 | /// If Myo was unlocked, an onLock event will be generated. 46 | void lock(); 47 | 48 | /// Notify the Myo that a user action was recognized. 49 | /// Will cause Myo to vibrate. 50 | void notifyUserAction(); 51 | 52 | /// Valid EMG streaming modes for a Myo. 53 | enum StreamEmgType { 54 | streamEmgDisabled = libmyo_stream_emg_disabled, 55 | streamEmgEnabled = libmyo_stream_emg_enabled 56 | }; 57 | 58 | /// Sets the EMG streaming mode for a Myo. 59 | void setStreamEmg(StreamEmgType type); 60 | 61 | /// @cond MYO_INTERNALS 62 | 63 | /// Return the internal libmyo object corresponding to this device. 64 | libmyo_myo_t libmyoObject() const; 65 | 66 | /// @endcond 67 | 68 | private: 69 | Myo(libmyo_myo_t myo); 70 | ~Myo(); 71 | 72 | libmyo_myo_t _myo; 73 | 74 | // Not implemented. 75 | Myo(const Myo&); 76 | Myo& operator=(const Myo&); 77 | 78 | friend class Hub; 79 | }; 80 | 81 | } // namespace myo 82 | 83 | #include "impl/Myo_impl.hpp" 84 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Headers/cxx/Pose.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #pragma once 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | namespace myo { 11 | 12 | /// A pose represents a detected configuration of the user's hand. 13 | class Pose { 14 | public: 15 | /// Types of poses supported by the SDK. 16 | enum Type { 17 | rest = libmyo_pose_rest, 18 | fist = libmyo_pose_fist, 19 | waveIn = libmyo_pose_wave_in, 20 | waveOut = libmyo_pose_wave_out, 21 | fingersSpread = libmyo_pose_fingers_spread, 22 | doubleTap = libmyo_pose_double_tap, 23 | unknown = libmyo_pose_unknown 24 | }; 25 | 26 | /// Construct a pose of type Pose::none. 27 | Pose(); 28 | 29 | /// Construct a pose with the given type. 30 | Pose(Type type); 31 | 32 | /// Returns true if and only if the two poses are of the same type. 33 | bool operator==(Pose other) const; 34 | 35 | /// Equivalent to `!(*this == other)`. 36 | bool operator!=(Pose other) const; 37 | 38 | /// Returns the type of this pose. 39 | Type type() const; 40 | 41 | /// Return a human-readable string representation of the pose. 42 | std::string toString() const; 43 | 44 | private: 45 | Type _type; 46 | }; 47 | 48 | /// @relates Pose 49 | /// Returns true if and only if the type of pose is the same as the provided type. 50 | bool operator==(Pose pose, Pose::Type t); 51 | 52 | /// @relates Pose 53 | /// Equivalent to `pose == type`. 54 | bool operator==(Pose::Type type, Pose pose); 55 | 56 | /// @relates Pose 57 | /// Equivalent to `!(pose == type)`. 58 | bool operator!=(Pose pose, Pose::Type type); 59 | 60 | /// @relates Pose 61 | /// Equivalent to `!(type == pose)`. 62 | bool operator!=(Pose::Type type, Pose pose); 63 | 64 | /// @relates Pose 65 | /// Write the name of the provided pose to the provided output stream. 66 | std::ostream& operator<<(std::ostream& out, const Pose& pose); 67 | 68 | } // namespace myo 69 | 70 | #include "impl/Pose_impl.hpp" 71 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Headers/cxx/Quaternion.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #pragma once 4 | 5 | #include 6 | 7 | #include "Vector3.hpp" 8 | 9 | namespace myo { 10 | 11 | /// A quaternion that can be used to represent a rotation. 12 | /// This type provides only very basic functionality to store quaternions that's sufficient to retrieve the data to 13 | /// be placed in a full featured quaternion type. 14 | template 15 | class Quaternion { 16 | public: 17 | /// Construct a quaternion that represents zero rotation (i.e. the multiplicative identity). 18 | Quaternion() 19 | : _x(0) 20 | , _y(0) 21 | , _z(0) 22 | , _w(1) 23 | { 24 | } 25 | 26 | /// Construct a quaternion with the provided components. 27 | Quaternion(T x, T y, T z, T w) 28 | : _x(x) 29 | , _y(y) 30 | , _z(z) 31 | , _w(w) 32 | { 33 | } 34 | 35 | /// Set the components of this quaternion to be those of the other. 36 | Quaternion& operator=(const Quaternion other) 37 | { 38 | _x = other._x; 39 | _y = other._y; 40 | _z = other._z; 41 | _w = other._w; 42 | 43 | return *this; 44 | } 45 | 46 | /// Return the x-component of this quaternion's vector. 47 | T x() const { return _x; } 48 | 49 | /// Return the y-component of this quaternion's vector. 50 | T y() const { return _y; } 51 | 52 | /// Return the z-component of this quaternion's vector. 53 | T z() const { return _z; } 54 | 55 | /// Return the w-component (scalar) of this quaternion. 56 | T w() const { return _w; } 57 | 58 | /// Return the quaternion multiplied by \a rhs. 59 | /// Note that quaternion multiplication is not commutative. 60 | Quaternion operator*(const Quaternion& rhs) const 61 | { 62 | return Quaternion( 63 | _w * rhs._x + _x * rhs._w + _y * rhs._z - _z * rhs._y, 64 | _w * rhs._y - _x * rhs._z + _y * rhs._w + _z * rhs._x, 65 | _w * rhs._z + _x * rhs._y - _y * rhs._x + _z * rhs._w, 66 | _w * rhs._w - _x * rhs._x - _y * rhs._y - _z * rhs._z 67 | ); 68 | } 69 | 70 | /// Multiply this quaternion by \a rhs. 71 | /// Return this quaternion updated with the result. 72 | Quaternion& operator*=(const Quaternion& rhs) 73 | { 74 | *this = *this * rhs; 75 | return *this; 76 | } 77 | 78 | /// Return the unit quaternion corresponding to the same rotation as this one. 79 | Quaternion normalized() const 80 | { 81 | T magnitude = std::sqrt(_x * _x + _y * _y + _z * _z + _w * _w); 82 | 83 | return Quaternion(_x / magnitude, _y / magnitude, _z / magnitude, _w / magnitude); 84 | } 85 | 86 | /// Return this quaternion's conjugate. 87 | Quaternion conjugate() const 88 | { 89 | return Quaternion(-_x, -_y, -_z, _w); 90 | } 91 | 92 | /// Return a quaternion that represents a right-handed rotation of \a angle radians about the given \a axis. 93 | /// \a axis The unit vector representing the axis of rotation. 94 | /// \a angle The angle of rotation, in radians. 95 | static Quaternion fromAxisAngle(const myo::Vector3& axis, T angle) 96 | { 97 | return Quaternion(axis.x() * std::sin(angle / 2), 98 | axis.y() * std::sin(angle / 2), 99 | axis.z() * std::sin(angle / 2), 100 | std::cos(angle / 2)); 101 | } 102 | 103 | private: 104 | T _x, _y, _z, _w; 105 | }; 106 | 107 | /// Return a copy of this \a vec rotated by \a quat. 108 | /// \relates myo::Quaternion 109 | template 110 | Vector3 rotate(const Quaternion& quat, const Vector3& vec) 111 | { 112 | myo::Quaternion qvec(vec.x(), vec.y(), vec.z(), 0); 113 | myo::Quaternion result = quat * qvec * quat.conjugate(); 114 | return Vector3(result.x(), result.y(), result.z()); 115 | } 116 | 117 | /// Return a quaternion that represents a rotation from vector \a from to \a to. 118 | /// \relates myo::Quaternion 119 | /// See http://stackoverflow.com/questions/1171849/finding-quaternion-representing-the-rotation-from-one-vector-to-another 120 | /// for some explanation. 121 | template 122 | Quaternion rotate(const Vector3& from, const Vector3& to) 123 | { 124 | Vector3 cross = from.cross(to); 125 | 126 | // The product of the square of magnitudes and the cosine of the angle between from and to. 127 | T cosTheta = from.dot(to); 128 | 129 | // Return identity if the vectors are the same direction. 130 | if (cosTheta >= 1) { 131 | return Quaternion(); 132 | } 133 | 134 | // The product of the square of the magnitudes 135 | T k = std::sqrt(from.dot(from) * to.dot(to)); 136 | 137 | // Return identity in the degenerate case. 138 | if (k <= 0) { 139 | return Quaternion(); 140 | } 141 | 142 | // Special handling for vectors facing opposite directions. 143 | if (cosTheta / k <= -1) { 144 | Vector3 xAxis(1, 0, 0); 145 | Vector3 yAxis(0, 1, 0); 146 | 147 | cross = from.cross(std::abs(from.dot(xAxis)) < 1 ? xAxis : yAxis); 148 | k = cosTheta = 0; 149 | } 150 | 151 | return Quaternion( 152 | cross.x(), 153 | cross.y(), 154 | cross.z(), 155 | k + cosTheta); 156 | } 157 | 158 | } // namespace myo 159 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Headers/cxx/Vector3.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #pragma once 4 | 5 | #define _USE_MATH_DEFINES 6 | #include 7 | 8 | namespace myo { 9 | 10 | /// A vector of three components. 11 | /// This type provides very basic functionality to store a three dimensional vector that's sufficient to retrieve 12 | /// the data to be placed in a full featured vector type. A few common vector operations, such as dot product and 13 | /// cross product, are also provided. 14 | template 15 | class Vector3 { 16 | public: 17 | /// Construct a vector of all zeroes. 18 | Vector3() 19 | { 20 | _data[0] = 0; 21 | _data[1] = 0; 22 | _data[2] = 0; 23 | } 24 | 25 | /// Construct a vector with the three provided components. 26 | Vector3(T x, T y, T z) 27 | { 28 | _data[0] = x; 29 | _data[1] = y; 30 | _data[2] = z; 31 | } 32 | 33 | /// Construct a vector with the same components as \a other. 34 | Vector3(const Vector3& other) 35 | { 36 | *this = other; 37 | } 38 | 39 | /// Set the components of this vector to be the same as \a other. 40 | Vector3& operator=(const Vector3& other) 41 | { 42 | _data[0] = other._data[0]; 43 | _data[1] = other._data[1]; 44 | _data[2] = other._data[2]; 45 | 46 | return *this; 47 | } 48 | 49 | /// Return a copy of the component of this vector at \a index, which should be 0, 1, or 2. 50 | T operator[](unsigned int index) const 51 | { 52 | return _data[index]; 53 | } 54 | 55 | /// Return the x-component of this vector. 56 | T x() const { return _data[0]; } 57 | 58 | /// Return the y-component of this vector. 59 | T y() const { return _data[1]; } 60 | 61 | /// Return the z-component of this vector. 62 | T z() const { return _data[2]; } 63 | 64 | /// Return the magnitude of this vector. 65 | T magnitude() const 66 | { 67 | return std::sqrt(x() * x() + y() * y() + z() * z()); 68 | } 69 | 70 | /// Return a normalized copy of this vector. 71 | Vector3 normalized() const 72 | { 73 | T norm = magnitude(); 74 | return Vector3(x() / norm, y() / norm, z() / norm); 75 | } 76 | 77 | /// Return the dot product of this vector and \a rhs. 78 | T dot(const Vector3& rhs) const 79 | { 80 | return x() * rhs.x() + y() * rhs.y() + z() * rhs.z(); 81 | } 82 | 83 | /// Return the cross product of this vector and \a rhs. 84 | Vector3 cross(const Vector3& rhs) const 85 | { 86 | return Vector3( 87 | y() * rhs.z() - z() * rhs.y(), 88 | z() * rhs.x() - x() * rhs.z(), 89 | x() * rhs.y() - y() * rhs.x() 90 | ); 91 | } 92 | 93 | /// Return the angle between this vector and \a rhs, in radians. 94 | T angleTo(const Vector3& rhs) const 95 | { 96 | return std::acos(dot(rhs) / (magnitude() * rhs.magnitude())); 97 | } 98 | 99 | private: 100 | T _data[3]; 101 | }; 102 | 103 | } // namespace myo 104 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Headers/cxx/detail/ThrowOnError.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #ifndef MYO_CXX_DETAIL_THROWONERROR_HPP 4 | #define MYO_CXX_DETAIL_THROWONERROR_HPP 5 | 6 | #include 7 | 8 | #include 9 | 10 | #if defined(_MSC_VER) && _MSC_VER <= 1800 11 | #define LIBMYO_NOEXCEPT(b) 12 | #else 13 | #if __cplusplus >= 201103L 14 | # define LIBMYO_NOEXCEPT(b) noexcept(b) 15 | #else 16 | # define LIBMYO_NOEXCEPT(b) 17 | #endif 18 | #endif 19 | 20 | namespace myo { 21 | 22 | class ThrowOnError { 23 | public: 24 | ThrowOnError() 25 | : _error() 26 | { 27 | } 28 | 29 | ~ThrowOnError() LIBMYO_NOEXCEPT(false) 30 | { 31 | if (_error) 32 | { 33 | switch (libmyo_error_kind(_error)) { 34 | case libmyo_error: 35 | case libmyo_error_runtime: 36 | { 37 | std::runtime_error exception(libmyo_error_cstring(_error)); 38 | libmyo_free_error_details(_error); 39 | throw exception; 40 | } 41 | case libmyo_error_invalid_argument: 42 | { 43 | std::invalid_argument exception(libmyo_error_cstring(_error)); 44 | libmyo_free_error_details(_error); 45 | throw exception; 46 | } 47 | case libmyo_success: 48 | { 49 | break; 50 | } 51 | } 52 | } 53 | } 54 | 55 | operator libmyo_error_details_t*() 56 | { 57 | return &_error; 58 | } 59 | 60 | private: 61 | libmyo_error_details_t _error; 62 | 63 | // Not implemented 64 | ThrowOnError(const ThrowOnError&); // = delete; 65 | ThrowOnError& operator=(const ThrowOnError&); // = delete; 66 | }; 67 | 68 | } //namespace libmyo 69 | 70 | #endif // MYO_CXX_DETAIL_THROWONERROR_HPP 71 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Headers/cxx/impl/Hub_impl.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #include "../Hub.hpp" 4 | 5 | #include 6 | #include 7 | 8 | #include "../DeviceListener.hpp" 9 | #include "../Myo.hpp" 10 | #include "../Pose.hpp" 11 | #include "../Quaternion.hpp" 12 | #include "../Vector3.hpp" 13 | #include "../detail/ThrowOnError.hpp" 14 | 15 | namespace myo { 16 | 17 | inline 18 | Hub::Hub(const std::string& applicationIdentifier) 19 | : _hub(0) 20 | , _myos() 21 | , _listeners() 22 | { 23 | libmyo_init_hub(&_hub, applicationIdentifier.c_str(), ThrowOnError()); 24 | } 25 | 26 | inline 27 | Hub::~Hub() 28 | { 29 | for (std::vector::iterator I = _myos.begin(), IE = _myos.end(); I != IE; ++I) { 30 | delete *I; 31 | } 32 | libmyo_shutdown_hub(_hub, 0); 33 | } 34 | 35 | inline 36 | Myo* Hub::waitForMyo(unsigned int timeout_ms) 37 | { 38 | std::size_t prevSize = _myos.size(); 39 | 40 | struct local { 41 | static libmyo_handler_result_t handler(void* user_data, libmyo_event_t event) { 42 | Hub* hub = static_cast(user_data); 43 | 44 | libmyo_myo_t opaque_myo = libmyo_event_get_myo(event); 45 | 46 | switch (libmyo_event_get_type(event)) { 47 | case libmyo_event_paired: 48 | hub->addMyo(opaque_myo); 49 | return libmyo_handler_stop; 50 | default: 51 | break; 52 | } 53 | 54 | return libmyo_handler_continue; 55 | } 56 | }; 57 | 58 | do { 59 | libmyo_run(_hub, timeout_ms ? timeout_ms : 1000, &local::handler, this, ThrowOnError()); 60 | } while (!timeout_ms && _myos.size() <= prevSize); 61 | 62 | if (_myos.size() <= prevSize) { 63 | return 0; 64 | } 65 | 66 | return _myos.back(); 67 | } 68 | 69 | inline 70 | void Hub::addListener(DeviceListener* listener) 71 | { 72 | if (std::find(_listeners.begin(), _listeners.end(), listener) != _listeners.end()) { 73 | // Listener was already added. 74 | return; 75 | } 76 | _listeners.push_back(listener); 77 | } 78 | 79 | inline 80 | void Hub::removeListener(DeviceListener* listener) 81 | { 82 | std::vector::iterator I = std::find(_listeners.begin(), _listeners.end(), listener); 83 | if (I == _listeners.end()) { 84 | // Don't have this listener. 85 | return; 86 | } 87 | 88 | _listeners.erase(I); 89 | } 90 | 91 | inline 92 | void Hub::setLockingPolicy(LockingPolicy lockingPolicy) 93 | { 94 | libmyo_set_locking_policy(_hub, static_cast(lockingPolicy), ThrowOnError()); 95 | } 96 | 97 | inline 98 | void Hub::onDeviceEvent(libmyo_event_t event) 99 | { 100 | libmyo_myo_t opaqueMyo = libmyo_event_get_myo(event); 101 | 102 | Myo* myo = lookupMyo(opaqueMyo); 103 | 104 | if (!myo && libmyo_event_get_type(event) == libmyo_event_paired) { 105 | myo = addMyo(opaqueMyo); 106 | } 107 | 108 | if (!myo) { 109 | // Ignore events for Myos we don't know about. 110 | return; 111 | } 112 | 113 | for (std::vector::iterator I = _listeners.begin(), IE = _listeners.end(); I != IE; ++I) { 114 | DeviceListener* listener = *I; 115 | 116 | listener->onOpaqueEvent(event); 117 | 118 | uint64_t time = libmyo_event_get_timestamp(event); 119 | 120 | switch (libmyo_event_get_type(event)) { 121 | case libmyo_event_paired: { 122 | FirmwareVersion version = {libmyo_event_get_firmware_version(event, libmyo_version_major), 123 | libmyo_event_get_firmware_version(event, libmyo_version_minor), 124 | libmyo_event_get_firmware_version(event, libmyo_version_patch), 125 | libmyo_event_get_firmware_version(event, libmyo_version_hardware_rev)}; 126 | listener->onPair(myo, time, version); 127 | break; 128 | } 129 | case libmyo_event_unpaired: 130 | listener->onUnpair(myo, time); 131 | break; 132 | case libmyo_event_connected: { 133 | FirmwareVersion version = {libmyo_event_get_firmware_version(event, libmyo_version_major), 134 | libmyo_event_get_firmware_version(event, libmyo_version_minor), 135 | libmyo_event_get_firmware_version(event, libmyo_version_patch), 136 | libmyo_event_get_firmware_version(event, libmyo_version_hardware_rev)}; 137 | listener->onConnect(myo, time, version); 138 | break; 139 | } 140 | case libmyo_event_disconnected: 141 | listener->onDisconnect(myo, time); 142 | break; 143 | case libmyo_event_arm_synced: 144 | listener->onArmSync(myo, time, 145 | static_cast(libmyo_event_get_arm(event)), 146 | static_cast(libmyo_event_get_x_direction(event)), 147 | libmyo_event_get_rotation_on_arm(event), 148 | static_cast(libmyo_event_get_warmup_state(event))); 149 | break; 150 | case libmyo_event_arm_unsynced: 151 | listener->onArmUnsync(myo, time); 152 | break; 153 | case libmyo_event_unlocked: 154 | listener->onUnlock(myo, time); 155 | break; 156 | case libmyo_event_locked: 157 | listener->onLock(myo, time); 158 | break; 159 | case libmyo_event_orientation: 160 | listener->onOrientationData(myo, time, 161 | Quaternion(libmyo_event_get_orientation(event, libmyo_orientation_x), 162 | libmyo_event_get_orientation(event, libmyo_orientation_y), 163 | libmyo_event_get_orientation(event, libmyo_orientation_z), 164 | libmyo_event_get_orientation(event, libmyo_orientation_w))); 165 | listener->onAccelerometerData(myo, time, 166 | Vector3(libmyo_event_get_accelerometer(event, 0), 167 | libmyo_event_get_accelerometer(event, 1), 168 | libmyo_event_get_accelerometer(event, 2))); 169 | 170 | listener->onGyroscopeData(myo, time, 171 | Vector3(libmyo_event_get_gyroscope(event, 0), 172 | libmyo_event_get_gyroscope(event, 1), 173 | libmyo_event_get_gyroscope(event, 2))); 174 | 175 | break; 176 | case libmyo_event_pose: 177 | listener->onPose(myo, time, Pose(static_cast(libmyo_event_get_pose(event)))); 178 | break; 179 | case libmyo_event_rssi: 180 | listener->onRssi(myo, time, libmyo_event_get_rssi(event)); 181 | break; 182 | case libmyo_event_battery_level: 183 | listener->onBatteryLevelReceived(myo, time, libmyo_event_get_battery_level(event)); 184 | break; 185 | case libmyo_event_emg: { 186 | int8_t emg[] = { libmyo_event_get_emg(event, 0), 187 | libmyo_event_get_emg(event, 1), 188 | libmyo_event_get_emg(event, 2), 189 | libmyo_event_get_emg(event, 3), 190 | libmyo_event_get_emg(event, 4), 191 | libmyo_event_get_emg(event, 5), 192 | libmyo_event_get_emg(event, 6), 193 | libmyo_event_get_emg(event, 7) }; 194 | listener->onEmgData(myo, time, emg); 195 | break; 196 | } 197 | case libmyo_event_warmup_completed: { 198 | listener->onWarmupCompleted(myo, time, static_cast(libmyo_event_get_warmup_result(event))); 199 | break; 200 | } 201 | } 202 | } 203 | } 204 | 205 | inline 206 | void Hub::run(unsigned int duration_ms) 207 | { 208 | struct local { 209 | static libmyo_handler_result_t handler(void* user_data, libmyo_event_t event) { 210 | Hub* hub = static_cast(user_data); 211 | 212 | hub->onDeviceEvent(event); 213 | 214 | return libmyo_handler_continue; 215 | } 216 | }; 217 | libmyo_run(_hub, duration_ms, &local::handler, this, ThrowOnError()); 218 | } 219 | 220 | inline 221 | void Hub::runOnce(unsigned int duration_ms) 222 | { 223 | struct local { 224 | static libmyo_handler_result_t handler(void* user_data, libmyo_event_t event) { 225 | Hub* hub = static_cast(user_data); 226 | 227 | hub->onDeviceEvent(event); 228 | 229 | return libmyo_handler_stop; 230 | } 231 | }; 232 | libmyo_run(_hub, duration_ms, &local::handler, this, ThrowOnError()); 233 | } 234 | 235 | inline 236 | libmyo_hub_t Hub::libmyoObject() 237 | { 238 | return _hub; 239 | } 240 | 241 | inline 242 | Myo* Hub::lookupMyo(libmyo_myo_t opaqueMyo) const 243 | { 244 | Myo* myo = 0; 245 | for (std::vector::const_iterator I = _myos.begin(), IE = _myos.end(); I != IE; ++I) { 246 | if ((*I)->libmyoObject() == opaqueMyo) { 247 | myo = *I; 248 | break; 249 | } 250 | } 251 | 252 | return myo; 253 | } 254 | 255 | inline 256 | Myo* Hub::addMyo(libmyo_myo_t opaqueMyo) 257 | { 258 | Myo* myo = new Myo(opaqueMyo); 259 | 260 | _myos.push_back(myo); 261 | 262 | return myo; 263 | } 264 | 265 | } // namespace myo 266 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Headers/cxx/impl/Myo_impl.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #include "../Myo.hpp" 4 | #include "../detail/ThrowOnError.hpp" 5 | 6 | #include 7 | 8 | namespace myo { 9 | 10 | inline 11 | void Myo::vibrate(VibrationType type) 12 | { 13 | libmyo_vibrate(_myo, static_cast(type), ThrowOnError()); 14 | } 15 | 16 | inline 17 | void Myo::requestRssi() const 18 | { 19 | libmyo_request_rssi(_myo, ThrowOnError()); 20 | } 21 | 22 | inline 23 | void Myo::requestBatteryLevel() const 24 | { 25 | libmyo_request_battery_level(_myo, myo::ThrowOnError()); 26 | } 27 | 28 | inline 29 | void Myo::unlock(UnlockType type) 30 | { 31 | libmyo_myo_unlock(_myo, static_cast(type), ThrowOnError()); 32 | } 33 | 34 | inline 35 | void Myo::lock() 36 | { 37 | libmyo_myo_lock(_myo, ThrowOnError()); 38 | } 39 | 40 | inline 41 | void Myo::notifyUserAction() 42 | { 43 | libmyo_myo_notify_user_action(_myo, libmyo_user_action_single, ThrowOnError()); 44 | } 45 | 46 | inline 47 | void Myo::setStreamEmg(StreamEmgType type) 48 | { 49 | libmyo_set_stream_emg(_myo, static_cast(type), ThrowOnError()); 50 | } 51 | 52 | inline 53 | libmyo_myo_t Myo::libmyoObject() const 54 | { 55 | return _myo; 56 | } 57 | 58 | inline 59 | Myo::Myo(libmyo_myo_t myo) 60 | : _myo(myo) 61 | { 62 | if (!_myo) { 63 | throw std::invalid_argument("Cannot construct Myo instance with null pointer"); 64 | } 65 | } 66 | 67 | inline 68 | Myo::~Myo() 69 | { 70 | } 71 | 72 | } // namespace myo 73 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Headers/cxx/impl/Pose_impl.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #ifndef MYO_CXX_IMPL_POSE_IMPL_HPP 4 | #define MYO_CXX_IMPL_POSE_IMPL_HPP 5 | 6 | #include "../Pose.hpp" 7 | 8 | #include 9 | 10 | namespace myo { 11 | 12 | inline 13 | Pose::Pose() 14 | : _type(unknown) 15 | { 16 | } 17 | 18 | inline 19 | Pose::Pose(Pose::Type type) 20 | : _type(type) 21 | { 22 | } 23 | 24 | inline 25 | bool Pose::operator==(Pose other) const 26 | { 27 | return _type == other._type; 28 | } 29 | 30 | inline 31 | bool Pose::operator!=(Pose other) const 32 | { 33 | return !(*this == other); 34 | } 35 | 36 | inline 37 | Pose::Type Pose::type() const 38 | { 39 | return _type; 40 | } 41 | 42 | inline 43 | bool operator==(Pose pose, Pose::Type type) 44 | { 45 | return pose.type() == type; 46 | } 47 | 48 | inline 49 | bool operator==(Pose::Type type, Pose pose) 50 | { 51 | return pose == type; 52 | } 53 | 54 | inline 55 | bool operator!=(Pose pose, Pose::Type type) 56 | { 57 | return !(pose == type); 58 | } 59 | 60 | inline 61 | bool operator!=(Pose::Type type, Pose pose) 62 | { 63 | return !(type == pose); 64 | } 65 | 66 | inline 67 | std::string Pose::toString() const 68 | { 69 | switch (type()) { 70 | case Pose::rest: 71 | return "rest"; 72 | case Pose::fist: 73 | return "fist"; 74 | case Pose::waveIn: 75 | return "waveIn"; 76 | case Pose::waveOut: 77 | return "waveOut"; 78 | case Pose::fingersSpread: 79 | return "fingersSpread"; 80 | case Pose::doubleTap: 81 | return "doubleTap"; 82 | case Pose::unknown: 83 | return "unknown"; 84 | } 85 | 86 | return ""; 87 | } 88 | 89 | inline 90 | std::ostream& operator<<(std::ostream& out, const Pose& pose) 91 | { 92 | return out << pose.toString(); 93 | } 94 | 95 | } // namespace myo 96 | 97 | #endif // MYO_CXX_IMPL_POSE_IMPL_HPP 98 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Headers/libmyo/detail/visibility.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #ifndef MYO_LIBMYO_DETAIL_VISIBILITY_H 4 | #define MYO_LIBMYO_DETAIL_VISIBILITY_H 5 | 6 | #if defined(_WIN32) || defined(__CYGWIN__) 7 | #ifdef myo_EXPORTS 8 | #ifdef __GNUC__ 9 | #define LIBMYO_EXPORT __attribute__ ((dllexport)) 10 | #else 11 | #define LIBMYO_EXPORT __declspec(dllexport) 12 | #endif 13 | #else 14 | #ifdef LIBMYO_STATIC_BUILD 15 | #define LIBMYO_EXPORT 16 | #else 17 | #ifdef __GNUC__ 18 | #define LIBMYO_EXPORT __attribute__ ((dllimport)) 19 | #else 20 | #define LIBMYO_EXPORT __declspec(dllimport) 21 | #endif 22 | #endif 23 | #endif 24 | #else 25 | #if __GNUC__ >= 4 26 | #define LIBMYO_EXPORT __attribute__ ((visibility ("default"))) 27 | #else 28 | #define LIBMYO_EXPORT 29 | #endif 30 | #endif 31 | 32 | #endif // MYO_LIBMYO_DETAIL_VISIBILITY_H 33 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Headers/myo.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #pragma once 4 | 5 | /// The namespace in which all of the %Myo C++ bindings are contained. 6 | namespace myo {} 7 | 8 | #include "cxx/DeviceListener.hpp" 9 | #include "cxx/Hub.hpp" 10 | #include "cxx/Myo.hpp" 11 | #include "cxx/Pose.hpp" 12 | #include "cxx/Quaternion.hpp" 13 | #include "cxx/Vector3.hpp" 14 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Versions/A/Headers/cxx/Hub.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #pragma once 4 | 5 | #include 6 | 7 | #include 8 | 9 | namespace myo { 10 | 11 | class Myo; 12 | class DeviceListener; 13 | 14 | /// @brief A Hub provides access to one or more Myo instances. 15 | class Hub { 16 | public: 17 | /// Construct a hub. 18 | /// \a applicationIdentifier must follow a reverse domain name format (ex. com.domainname.appname). Application 19 | /// identifiers can be formed from the set of alphanumeric ASCII characters (a-z, A-Z, 0-9). The hyphen (-) and 20 | /// underscore (_) characters are permitted if they are not adjacent to a period (.) character (i.e. not at the 21 | /// start or end of each segment), but are not permitted in the top-level domain. Application identifiers must have 22 | /// three or more segments. For example, if a company's domain is example.com and the application is named 23 | /// hello-world, one could use "com.example.hello-world" as a valid application identifier. \a applicationIdentifier 24 | /// can be an empty string. 25 | /// Throws an exception of type std::invalid_argument if \a applicationIdentifier is not in the proper reverse 26 | /// domain name format or is longer than 255 characters. 27 | /// Throws an exception of type std::runtime_error if the hub initialization failed for some reason, typically 28 | /// because Myo Connect is not running and a connection can thus not be established. 29 | Hub(const std::string& applicationIdentifier = ""); 30 | 31 | /// Deallocate any resources associated with a Hub. 32 | /// This will cause all Myo instances retrieved from this Hub to become invalid. 33 | ~Hub(); 34 | 35 | /// Wait for a Myo to become paired, or time out after \a timeout_ms milliseconds if provided. 36 | /// If \a timeout_ms is zero, this function blocks until a Myo is found. 37 | /// This function must not be called concurrently with run() or runOnce(). 38 | Myo* waitForMyo(unsigned int milliseconds = 0); 39 | 40 | /// Register a listener to be called when device events occur. 41 | void addListener(DeviceListener* listener); 42 | 43 | /// Remove a previously registered listener. 44 | void removeListener(DeviceListener* listener); 45 | 46 | /// Locking policies supported by Myo. 47 | enum LockingPolicy { 48 | lockingPolicyNone = libmyo_locking_policy_none, 49 | lockingPolicyStandard = libmyo_locking_policy_standard 50 | }; 51 | 52 | /// Set the locking policy for Myos connected to the Hub. 53 | void setLockingPolicy(LockingPolicy lockingPolicy); 54 | 55 | /// Run the event loop for the specified duration (in milliseconds). 56 | void run(unsigned int duration_ms); 57 | 58 | /// Run the event loop until a single event occurs, or the specified duration (in milliseconds) has elapsed. 59 | void runOnce(unsigned int duration_ms); 60 | 61 | /// @cond MYO_INTERNALS 62 | 63 | /// Return the internal libmyo object corresponding to this hub. 64 | libmyo_hub_t libmyoObject(); 65 | 66 | protected: 67 | void onDeviceEvent(libmyo_event_t event); 68 | 69 | Myo* lookupMyo(libmyo_myo_t opaqueMyo) const; 70 | 71 | Myo* addMyo(libmyo_myo_t opaqueMyo); 72 | 73 | libmyo_hub_t _hub; 74 | std::vector _myos; 75 | std::vector _listeners; 76 | 77 | /// @endcond 78 | 79 | private: 80 | // Not implemented 81 | Hub(const Hub&); 82 | Hub& operator=(const Hub&); 83 | }; 84 | 85 | /// @example hello-myo.cpp 86 | /// @example multiple-myos.cpp 87 | /// @example emg-data-sample.cpp 88 | 89 | } // namespace myo 90 | 91 | #include "impl/Hub_impl.hpp" 92 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Versions/A/Headers/cxx/Myo.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #pragma once 4 | 5 | #include 6 | 7 | namespace myo { 8 | 9 | /// Represents a Myo device with a specific MAC address. 10 | /// This class can not be instantiated directly; instead, use Hub to get access to a Myo. 11 | /// There is only one Myo instance corresponding to each device; thus, if the addresses of two Myo instances compare 12 | /// equal, they refer to the same device. 13 | class Myo { 14 | public: 15 | /// Types of vibration supported by the Myo. 16 | enum VibrationType { 17 | vibrationShort = libmyo_vibration_short, 18 | vibrationMedium = libmyo_vibration_medium, 19 | vibrationLong = libmyo_vibration_long 20 | }; 21 | 22 | /// Vibrate the Myo. 23 | void vibrate(VibrationType type); 24 | 25 | /// Request the RSSI of the Myo. An onRssi event will likely be generated with the value of the RSSI. 26 | /// @see DeviceListener::onRssi() 27 | void requestRssi() const; 28 | 29 | /// Request the battery level of the Myo. An onBatteryLevelReceived event will be generated with the value. 30 | /// @see DeviceListener::onBatteryLevelReceived(). 31 | void requestBatteryLevel() const; 32 | 33 | /// Unlock types supported by Myo. 34 | enum UnlockType { 35 | unlockTimed = libmyo_unlock_timed, 36 | unlockHold = libmyo_unlock_hold 37 | }; 38 | 39 | /// Unlock the Myo. 40 | /// Myo will remain unlocked for a short amount of time, after which it will automatically lock again. 41 | /// If Myo was locked, an onUnlock event will be generated. 42 | void unlock(UnlockType type); 43 | 44 | /// Force the Myo to lock immediately. 45 | /// If Myo was unlocked, an onLock event will be generated. 46 | void lock(); 47 | 48 | /// Notify the Myo that a user action was recognized. 49 | /// Will cause Myo to vibrate. 50 | void notifyUserAction(); 51 | 52 | /// Valid EMG streaming modes for a Myo. 53 | enum StreamEmgType { 54 | streamEmgDisabled = libmyo_stream_emg_disabled, 55 | streamEmgEnabled = libmyo_stream_emg_enabled 56 | }; 57 | 58 | /// Sets the EMG streaming mode for a Myo. 59 | void setStreamEmg(StreamEmgType type); 60 | 61 | /// @cond MYO_INTERNALS 62 | 63 | /// Return the internal libmyo object corresponding to this device. 64 | libmyo_myo_t libmyoObject() const; 65 | 66 | /// @endcond 67 | 68 | private: 69 | Myo(libmyo_myo_t myo); 70 | ~Myo(); 71 | 72 | libmyo_myo_t _myo; 73 | 74 | // Not implemented. 75 | Myo(const Myo&); 76 | Myo& operator=(const Myo&); 77 | 78 | friend class Hub; 79 | }; 80 | 81 | } // namespace myo 82 | 83 | #include "impl/Myo_impl.hpp" 84 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Versions/A/Headers/cxx/Pose.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #pragma once 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | namespace myo { 11 | 12 | /// A pose represents a detected configuration of the user's hand. 13 | class Pose { 14 | public: 15 | /// Types of poses supported by the SDK. 16 | enum Type { 17 | rest = libmyo_pose_rest, 18 | fist = libmyo_pose_fist, 19 | waveIn = libmyo_pose_wave_in, 20 | waveOut = libmyo_pose_wave_out, 21 | fingersSpread = libmyo_pose_fingers_spread, 22 | doubleTap = libmyo_pose_double_tap, 23 | unknown = libmyo_pose_unknown 24 | }; 25 | 26 | /// Construct a pose of type Pose::none. 27 | Pose(); 28 | 29 | /// Construct a pose with the given type. 30 | Pose(Type type); 31 | 32 | /// Returns true if and only if the two poses are of the same type. 33 | bool operator==(Pose other) const; 34 | 35 | /// Equivalent to `!(*this == other)`. 36 | bool operator!=(Pose other) const; 37 | 38 | /// Returns the type of this pose. 39 | Type type() const; 40 | 41 | /// Return a human-readable string representation of the pose. 42 | std::string toString() const; 43 | 44 | private: 45 | Type _type; 46 | }; 47 | 48 | /// @relates Pose 49 | /// Returns true if and only if the type of pose is the same as the provided type. 50 | bool operator==(Pose pose, Pose::Type t); 51 | 52 | /// @relates Pose 53 | /// Equivalent to `pose == type`. 54 | bool operator==(Pose::Type type, Pose pose); 55 | 56 | /// @relates Pose 57 | /// Equivalent to `!(pose == type)`. 58 | bool operator!=(Pose pose, Pose::Type type); 59 | 60 | /// @relates Pose 61 | /// Equivalent to `!(type == pose)`. 62 | bool operator!=(Pose::Type type, Pose pose); 63 | 64 | /// @relates Pose 65 | /// Write the name of the provided pose to the provided output stream. 66 | std::ostream& operator<<(std::ostream& out, const Pose& pose); 67 | 68 | } // namespace myo 69 | 70 | #include "impl/Pose_impl.hpp" 71 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Versions/A/Headers/cxx/Quaternion.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #pragma once 4 | 5 | #include 6 | 7 | #include "Vector3.hpp" 8 | 9 | namespace myo { 10 | 11 | /// A quaternion that can be used to represent a rotation. 12 | /// This type provides only very basic functionality to store quaternions that's sufficient to retrieve the data to 13 | /// be placed in a full featured quaternion type. 14 | template 15 | class Quaternion { 16 | public: 17 | /// Construct a quaternion that represents zero rotation (i.e. the multiplicative identity). 18 | Quaternion() 19 | : _x(0) 20 | , _y(0) 21 | , _z(0) 22 | , _w(1) 23 | { 24 | } 25 | 26 | /// Construct a quaternion with the provided components. 27 | Quaternion(T x, T y, T z, T w) 28 | : _x(x) 29 | , _y(y) 30 | , _z(z) 31 | , _w(w) 32 | { 33 | } 34 | 35 | /// Set the components of this quaternion to be those of the other. 36 | Quaternion& operator=(const Quaternion other) 37 | { 38 | _x = other._x; 39 | _y = other._y; 40 | _z = other._z; 41 | _w = other._w; 42 | 43 | return *this; 44 | } 45 | 46 | /// Return the x-component of this quaternion's vector. 47 | T x() const { return _x; } 48 | 49 | /// Return the y-component of this quaternion's vector. 50 | T y() const { return _y; } 51 | 52 | /// Return the z-component of this quaternion's vector. 53 | T z() const { return _z; } 54 | 55 | /// Return the w-component (scalar) of this quaternion. 56 | T w() const { return _w; } 57 | 58 | /// Return the quaternion multiplied by \a rhs. 59 | /// Note that quaternion multiplication is not commutative. 60 | Quaternion operator*(const Quaternion& rhs) const 61 | { 62 | return Quaternion( 63 | _w * rhs._x + _x * rhs._w + _y * rhs._z - _z * rhs._y, 64 | _w * rhs._y - _x * rhs._z + _y * rhs._w + _z * rhs._x, 65 | _w * rhs._z + _x * rhs._y - _y * rhs._x + _z * rhs._w, 66 | _w * rhs._w - _x * rhs._x - _y * rhs._y - _z * rhs._z 67 | ); 68 | } 69 | 70 | /// Multiply this quaternion by \a rhs. 71 | /// Return this quaternion updated with the result. 72 | Quaternion& operator*=(const Quaternion& rhs) 73 | { 74 | *this = *this * rhs; 75 | return *this; 76 | } 77 | 78 | /// Return the unit quaternion corresponding to the same rotation as this one. 79 | Quaternion normalized() const 80 | { 81 | T magnitude = std::sqrt(_x * _x + _y * _y + _z * _z + _w * _w); 82 | 83 | return Quaternion(_x / magnitude, _y / magnitude, _z / magnitude, _w / magnitude); 84 | } 85 | 86 | /// Return this quaternion's conjugate. 87 | Quaternion conjugate() const 88 | { 89 | return Quaternion(-_x, -_y, -_z, _w); 90 | } 91 | 92 | /// Return a quaternion that represents a right-handed rotation of \a angle radians about the given \a axis. 93 | /// \a axis The unit vector representing the axis of rotation. 94 | /// \a angle The angle of rotation, in radians. 95 | static Quaternion fromAxisAngle(const myo::Vector3& axis, T angle) 96 | { 97 | return Quaternion(axis.x() * std::sin(angle / 2), 98 | axis.y() * std::sin(angle / 2), 99 | axis.z() * std::sin(angle / 2), 100 | std::cos(angle / 2)); 101 | } 102 | 103 | private: 104 | T _x, _y, _z, _w; 105 | }; 106 | 107 | /// Return a copy of this \a vec rotated by \a quat. 108 | /// \relates myo::Quaternion 109 | template 110 | Vector3 rotate(const Quaternion& quat, const Vector3& vec) 111 | { 112 | myo::Quaternion qvec(vec.x(), vec.y(), vec.z(), 0); 113 | myo::Quaternion result = quat * qvec * quat.conjugate(); 114 | return Vector3(result.x(), result.y(), result.z()); 115 | } 116 | 117 | /// Return a quaternion that represents a rotation from vector \a from to \a to. 118 | /// \relates myo::Quaternion 119 | /// See http://stackoverflow.com/questions/1171849/finding-quaternion-representing-the-rotation-from-one-vector-to-another 120 | /// for some explanation. 121 | template 122 | Quaternion rotate(const Vector3& from, const Vector3& to) 123 | { 124 | Vector3 cross = from.cross(to); 125 | 126 | // The product of the square of magnitudes and the cosine of the angle between from and to. 127 | T cosTheta = from.dot(to); 128 | 129 | // Return identity if the vectors are the same direction. 130 | if (cosTheta >= 1) { 131 | return Quaternion(); 132 | } 133 | 134 | // The product of the square of the magnitudes 135 | T k = std::sqrt(from.dot(from) * to.dot(to)); 136 | 137 | // Return identity in the degenerate case. 138 | if (k <= 0) { 139 | return Quaternion(); 140 | } 141 | 142 | // Special handling for vectors facing opposite directions. 143 | if (cosTheta / k <= -1) { 144 | Vector3 xAxis(1, 0, 0); 145 | Vector3 yAxis(0, 1, 0); 146 | 147 | cross = from.cross(std::abs(from.dot(xAxis)) < 1 ? xAxis : yAxis); 148 | k = cosTheta = 0; 149 | } 150 | 151 | return Quaternion( 152 | cross.x(), 153 | cross.y(), 154 | cross.z(), 155 | k + cosTheta); 156 | } 157 | 158 | } // namespace myo 159 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Versions/A/Headers/cxx/Vector3.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #pragma once 4 | 5 | #define _USE_MATH_DEFINES 6 | #include 7 | 8 | namespace myo { 9 | 10 | /// A vector of three components. 11 | /// This type provides very basic functionality to store a three dimensional vector that's sufficient to retrieve 12 | /// the data to be placed in a full featured vector type. A few common vector operations, such as dot product and 13 | /// cross product, are also provided. 14 | template 15 | class Vector3 { 16 | public: 17 | /// Construct a vector of all zeroes. 18 | Vector3() 19 | { 20 | _data[0] = 0; 21 | _data[1] = 0; 22 | _data[2] = 0; 23 | } 24 | 25 | /// Construct a vector with the three provided components. 26 | Vector3(T x, T y, T z) 27 | { 28 | _data[0] = x; 29 | _data[1] = y; 30 | _data[2] = z; 31 | } 32 | 33 | /// Construct a vector with the same components as \a other. 34 | Vector3(const Vector3& other) 35 | { 36 | *this = other; 37 | } 38 | 39 | /// Set the components of this vector to be the same as \a other. 40 | Vector3& operator=(const Vector3& other) 41 | { 42 | _data[0] = other._data[0]; 43 | _data[1] = other._data[1]; 44 | _data[2] = other._data[2]; 45 | 46 | return *this; 47 | } 48 | 49 | /// Return a copy of the component of this vector at \a index, which should be 0, 1, or 2. 50 | T operator[](unsigned int index) const 51 | { 52 | return _data[index]; 53 | } 54 | 55 | /// Return the x-component of this vector. 56 | T x() const { return _data[0]; } 57 | 58 | /// Return the y-component of this vector. 59 | T y() const { return _data[1]; } 60 | 61 | /// Return the z-component of this vector. 62 | T z() const { return _data[2]; } 63 | 64 | /// Return the magnitude of this vector. 65 | T magnitude() const 66 | { 67 | return std::sqrt(x() * x() + y() * y() + z() * z()); 68 | } 69 | 70 | /// Return a normalized copy of this vector. 71 | Vector3 normalized() const 72 | { 73 | T norm = magnitude(); 74 | return Vector3(x() / norm, y() / norm, z() / norm); 75 | } 76 | 77 | /// Return the dot product of this vector and \a rhs. 78 | T dot(const Vector3& rhs) const 79 | { 80 | return x() * rhs.x() + y() * rhs.y() + z() * rhs.z(); 81 | } 82 | 83 | /// Return the cross product of this vector and \a rhs. 84 | Vector3 cross(const Vector3& rhs) const 85 | { 86 | return Vector3( 87 | y() * rhs.z() - z() * rhs.y(), 88 | z() * rhs.x() - x() * rhs.z(), 89 | x() * rhs.y() - y() * rhs.x() 90 | ); 91 | } 92 | 93 | /// Return the angle between this vector and \a rhs, in radians. 94 | T angleTo(const Vector3& rhs) const 95 | { 96 | return std::acos(dot(rhs) / (magnitude() * rhs.magnitude())); 97 | } 98 | 99 | private: 100 | T _data[3]; 101 | }; 102 | 103 | } // namespace myo 104 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Versions/A/Headers/cxx/detail/ThrowOnError.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #ifndef MYO_CXX_DETAIL_THROWONERROR_HPP 4 | #define MYO_CXX_DETAIL_THROWONERROR_HPP 5 | 6 | #include 7 | 8 | #include 9 | 10 | #if defined(_MSC_VER) && _MSC_VER <= 1800 11 | #define LIBMYO_NOEXCEPT(b) 12 | #else 13 | #if __cplusplus >= 201103L 14 | # define LIBMYO_NOEXCEPT(b) noexcept(b) 15 | #else 16 | # define LIBMYO_NOEXCEPT(b) 17 | #endif 18 | #endif 19 | 20 | namespace myo { 21 | 22 | class ThrowOnError { 23 | public: 24 | ThrowOnError() 25 | : _error() 26 | { 27 | } 28 | 29 | ~ThrowOnError() LIBMYO_NOEXCEPT(false) 30 | { 31 | if (_error) 32 | { 33 | switch (libmyo_error_kind(_error)) { 34 | case libmyo_error: 35 | case libmyo_error_runtime: 36 | { 37 | std::runtime_error exception(libmyo_error_cstring(_error)); 38 | libmyo_free_error_details(_error); 39 | throw exception; 40 | } 41 | case libmyo_error_invalid_argument: 42 | { 43 | std::invalid_argument exception(libmyo_error_cstring(_error)); 44 | libmyo_free_error_details(_error); 45 | throw exception; 46 | } 47 | case libmyo_success: 48 | { 49 | break; 50 | } 51 | } 52 | } 53 | } 54 | 55 | operator libmyo_error_details_t*() 56 | { 57 | return &_error; 58 | } 59 | 60 | private: 61 | libmyo_error_details_t _error; 62 | 63 | // Not implemented 64 | ThrowOnError(const ThrowOnError&); // = delete; 65 | ThrowOnError& operator=(const ThrowOnError&); // = delete; 66 | }; 67 | 68 | } //namespace libmyo 69 | 70 | #endif // MYO_CXX_DETAIL_THROWONERROR_HPP 71 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Versions/A/Headers/cxx/impl/Hub_impl.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #include "../Hub.hpp" 4 | 5 | #include 6 | #include 7 | 8 | #include "../DeviceListener.hpp" 9 | #include "../Myo.hpp" 10 | #include "../Pose.hpp" 11 | #include "../Quaternion.hpp" 12 | #include "../Vector3.hpp" 13 | #include "../detail/ThrowOnError.hpp" 14 | 15 | namespace myo { 16 | 17 | inline 18 | Hub::Hub(const std::string& applicationIdentifier) 19 | : _hub(0) 20 | , _myos() 21 | , _listeners() 22 | { 23 | libmyo_init_hub(&_hub, applicationIdentifier.c_str(), ThrowOnError()); 24 | } 25 | 26 | inline 27 | Hub::~Hub() 28 | { 29 | for (std::vector::iterator I = _myos.begin(), IE = _myos.end(); I != IE; ++I) { 30 | delete *I; 31 | } 32 | libmyo_shutdown_hub(_hub, 0); 33 | } 34 | 35 | inline 36 | Myo* Hub::waitForMyo(unsigned int timeout_ms) 37 | { 38 | std::size_t prevSize = _myos.size(); 39 | 40 | struct local { 41 | static libmyo_handler_result_t handler(void* user_data, libmyo_event_t event) { 42 | Hub* hub = static_cast(user_data); 43 | 44 | libmyo_myo_t opaque_myo = libmyo_event_get_myo(event); 45 | 46 | switch (libmyo_event_get_type(event)) { 47 | case libmyo_event_paired: 48 | hub->addMyo(opaque_myo); 49 | return libmyo_handler_stop; 50 | default: 51 | break; 52 | } 53 | 54 | return libmyo_handler_continue; 55 | } 56 | }; 57 | 58 | do { 59 | libmyo_run(_hub, timeout_ms ? timeout_ms : 1000, &local::handler, this, ThrowOnError()); 60 | } while (!timeout_ms && _myos.size() <= prevSize); 61 | 62 | if (_myos.size() <= prevSize) { 63 | return 0; 64 | } 65 | 66 | return _myos.back(); 67 | } 68 | 69 | inline 70 | void Hub::addListener(DeviceListener* listener) 71 | { 72 | if (std::find(_listeners.begin(), _listeners.end(), listener) != _listeners.end()) { 73 | // Listener was already added. 74 | return; 75 | } 76 | _listeners.push_back(listener); 77 | } 78 | 79 | inline 80 | void Hub::removeListener(DeviceListener* listener) 81 | { 82 | std::vector::iterator I = std::find(_listeners.begin(), _listeners.end(), listener); 83 | if (I == _listeners.end()) { 84 | // Don't have this listener. 85 | return; 86 | } 87 | 88 | _listeners.erase(I); 89 | } 90 | 91 | inline 92 | void Hub::setLockingPolicy(LockingPolicy lockingPolicy) 93 | { 94 | libmyo_set_locking_policy(_hub, static_cast(lockingPolicy), ThrowOnError()); 95 | } 96 | 97 | inline 98 | void Hub::onDeviceEvent(libmyo_event_t event) 99 | { 100 | libmyo_myo_t opaqueMyo = libmyo_event_get_myo(event); 101 | 102 | Myo* myo = lookupMyo(opaqueMyo); 103 | 104 | if (!myo && libmyo_event_get_type(event) == libmyo_event_paired) { 105 | myo = addMyo(opaqueMyo); 106 | } 107 | 108 | if (!myo) { 109 | // Ignore events for Myos we don't know about. 110 | return; 111 | } 112 | 113 | for (std::vector::iterator I = _listeners.begin(), IE = _listeners.end(); I != IE; ++I) { 114 | DeviceListener* listener = *I; 115 | 116 | listener->onOpaqueEvent(event); 117 | 118 | uint64_t time = libmyo_event_get_timestamp(event); 119 | 120 | switch (libmyo_event_get_type(event)) { 121 | case libmyo_event_paired: { 122 | FirmwareVersion version = {libmyo_event_get_firmware_version(event, libmyo_version_major), 123 | libmyo_event_get_firmware_version(event, libmyo_version_minor), 124 | libmyo_event_get_firmware_version(event, libmyo_version_patch), 125 | libmyo_event_get_firmware_version(event, libmyo_version_hardware_rev)}; 126 | listener->onPair(myo, time, version); 127 | break; 128 | } 129 | case libmyo_event_unpaired: 130 | listener->onUnpair(myo, time); 131 | break; 132 | case libmyo_event_connected: { 133 | FirmwareVersion version = {libmyo_event_get_firmware_version(event, libmyo_version_major), 134 | libmyo_event_get_firmware_version(event, libmyo_version_minor), 135 | libmyo_event_get_firmware_version(event, libmyo_version_patch), 136 | libmyo_event_get_firmware_version(event, libmyo_version_hardware_rev)}; 137 | listener->onConnect(myo, time, version); 138 | break; 139 | } 140 | case libmyo_event_disconnected: 141 | listener->onDisconnect(myo, time); 142 | break; 143 | case libmyo_event_arm_synced: 144 | listener->onArmSync(myo, time, 145 | static_cast(libmyo_event_get_arm(event)), 146 | static_cast(libmyo_event_get_x_direction(event)), 147 | libmyo_event_get_rotation_on_arm(event), 148 | static_cast(libmyo_event_get_warmup_state(event))); 149 | break; 150 | case libmyo_event_arm_unsynced: 151 | listener->onArmUnsync(myo, time); 152 | break; 153 | case libmyo_event_unlocked: 154 | listener->onUnlock(myo, time); 155 | break; 156 | case libmyo_event_locked: 157 | listener->onLock(myo, time); 158 | break; 159 | case libmyo_event_orientation: 160 | listener->onOrientationData(myo, time, 161 | Quaternion(libmyo_event_get_orientation(event, libmyo_orientation_x), 162 | libmyo_event_get_orientation(event, libmyo_orientation_y), 163 | libmyo_event_get_orientation(event, libmyo_orientation_z), 164 | libmyo_event_get_orientation(event, libmyo_orientation_w))); 165 | listener->onAccelerometerData(myo, time, 166 | Vector3(libmyo_event_get_accelerometer(event, 0), 167 | libmyo_event_get_accelerometer(event, 1), 168 | libmyo_event_get_accelerometer(event, 2))); 169 | 170 | listener->onGyroscopeData(myo, time, 171 | Vector3(libmyo_event_get_gyroscope(event, 0), 172 | libmyo_event_get_gyroscope(event, 1), 173 | libmyo_event_get_gyroscope(event, 2))); 174 | 175 | break; 176 | case libmyo_event_pose: 177 | listener->onPose(myo, time, Pose(static_cast(libmyo_event_get_pose(event)))); 178 | break; 179 | case libmyo_event_rssi: 180 | listener->onRssi(myo, time, libmyo_event_get_rssi(event)); 181 | break; 182 | case libmyo_event_battery_level: 183 | listener->onBatteryLevelReceived(myo, time, libmyo_event_get_battery_level(event)); 184 | break; 185 | case libmyo_event_emg: { 186 | int8_t emg[] = { libmyo_event_get_emg(event, 0), 187 | libmyo_event_get_emg(event, 1), 188 | libmyo_event_get_emg(event, 2), 189 | libmyo_event_get_emg(event, 3), 190 | libmyo_event_get_emg(event, 4), 191 | libmyo_event_get_emg(event, 5), 192 | libmyo_event_get_emg(event, 6), 193 | libmyo_event_get_emg(event, 7) }; 194 | listener->onEmgData(myo, time, emg); 195 | break; 196 | } 197 | case libmyo_event_warmup_completed: { 198 | listener->onWarmupCompleted(myo, time, static_cast(libmyo_event_get_warmup_result(event))); 199 | break; 200 | } 201 | } 202 | } 203 | } 204 | 205 | inline 206 | void Hub::run(unsigned int duration_ms) 207 | { 208 | struct local { 209 | static libmyo_handler_result_t handler(void* user_data, libmyo_event_t event) { 210 | Hub* hub = static_cast(user_data); 211 | 212 | hub->onDeviceEvent(event); 213 | 214 | return libmyo_handler_continue; 215 | } 216 | }; 217 | libmyo_run(_hub, duration_ms, &local::handler, this, ThrowOnError()); 218 | } 219 | 220 | inline 221 | void Hub::runOnce(unsigned int duration_ms) 222 | { 223 | struct local { 224 | static libmyo_handler_result_t handler(void* user_data, libmyo_event_t event) { 225 | Hub* hub = static_cast(user_data); 226 | 227 | hub->onDeviceEvent(event); 228 | 229 | return libmyo_handler_stop; 230 | } 231 | }; 232 | libmyo_run(_hub, duration_ms, &local::handler, this, ThrowOnError()); 233 | } 234 | 235 | inline 236 | libmyo_hub_t Hub::libmyoObject() 237 | { 238 | return _hub; 239 | } 240 | 241 | inline 242 | Myo* Hub::lookupMyo(libmyo_myo_t opaqueMyo) const 243 | { 244 | Myo* myo = 0; 245 | for (std::vector::const_iterator I = _myos.begin(), IE = _myos.end(); I != IE; ++I) { 246 | if ((*I)->libmyoObject() == opaqueMyo) { 247 | myo = *I; 248 | break; 249 | } 250 | } 251 | 252 | return myo; 253 | } 254 | 255 | inline 256 | Myo* Hub::addMyo(libmyo_myo_t opaqueMyo) 257 | { 258 | Myo* myo = new Myo(opaqueMyo); 259 | 260 | _myos.push_back(myo); 261 | 262 | return myo; 263 | } 264 | 265 | } // namespace myo 266 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Versions/A/Headers/cxx/impl/Myo_impl.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #include "../Myo.hpp" 4 | #include "../detail/ThrowOnError.hpp" 5 | 6 | #include 7 | 8 | namespace myo { 9 | 10 | inline 11 | void Myo::vibrate(VibrationType type) 12 | { 13 | libmyo_vibrate(_myo, static_cast(type), ThrowOnError()); 14 | } 15 | 16 | inline 17 | void Myo::requestRssi() const 18 | { 19 | libmyo_request_rssi(_myo, ThrowOnError()); 20 | } 21 | 22 | inline 23 | void Myo::requestBatteryLevel() const 24 | { 25 | libmyo_request_battery_level(_myo, myo::ThrowOnError()); 26 | } 27 | 28 | inline 29 | void Myo::unlock(UnlockType type) 30 | { 31 | libmyo_myo_unlock(_myo, static_cast(type), ThrowOnError()); 32 | } 33 | 34 | inline 35 | void Myo::lock() 36 | { 37 | libmyo_myo_lock(_myo, ThrowOnError()); 38 | } 39 | 40 | inline 41 | void Myo::notifyUserAction() 42 | { 43 | libmyo_myo_notify_user_action(_myo, libmyo_user_action_single, ThrowOnError()); 44 | } 45 | 46 | inline 47 | void Myo::setStreamEmg(StreamEmgType type) 48 | { 49 | libmyo_set_stream_emg(_myo, static_cast(type), ThrowOnError()); 50 | } 51 | 52 | inline 53 | libmyo_myo_t Myo::libmyoObject() const 54 | { 55 | return _myo; 56 | } 57 | 58 | inline 59 | Myo::Myo(libmyo_myo_t myo) 60 | : _myo(myo) 61 | { 62 | if (!_myo) { 63 | throw std::invalid_argument("Cannot construct Myo instance with null pointer"); 64 | } 65 | } 66 | 67 | inline 68 | Myo::~Myo() 69 | { 70 | } 71 | 72 | } // namespace myo 73 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Versions/A/Headers/cxx/impl/Pose_impl.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #ifndef MYO_CXX_IMPL_POSE_IMPL_HPP 4 | #define MYO_CXX_IMPL_POSE_IMPL_HPP 5 | 6 | #include "../Pose.hpp" 7 | 8 | #include 9 | 10 | namespace myo { 11 | 12 | inline 13 | Pose::Pose() 14 | : _type(unknown) 15 | { 16 | } 17 | 18 | inline 19 | Pose::Pose(Pose::Type type) 20 | : _type(type) 21 | { 22 | } 23 | 24 | inline 25 | bool Pose::operator==(Pose other) const 26 | { 27 | return _type == other._type; 28 | } 29 | 30 | inline 31 | bool Pose::operator!=(Pose other) const 32 | { 33 | return !(*this == other); 34 | } 35 | 36 | inline 37 | Pose::Type Pose::type() const 38 | { 39 | return _type; 40 | } 41 | 42 | inline 43 | bool operator==(Pose pose, Pose::Type type) 44 | { 45 | return pose.type() == type; 46 | } 47 | 48 | inline 49 | bool operator==(Pose::Type type, Pose pose) 50 | { 51 | return pose == type; 52 | } 53 | 54 | inline 55 | bool operator!=(Pose pose, Pose::Type type) 56 | { 57 | return !(pose == type); 58 | } 59 | 60 | inline 61 | bool operator!=(Pose::Type type, Pose pose) 62 | { 63 | return !(type == pose); 64 | } 65 | 66 | inline 67 | std::string Pose::toString() const 68 | { 69 | switch (type()) { 70 | case Pose::rest: 71 | return "rest"; 72 | case Pose::fist: 73 | return "fist"; 74 | case Pose::waveIn: 75 | return "waveIn"; 76 | case Pose::waveOut: 77 | return "waveOut"; 78 | case Pose::fingersSpread: 79 | return "fingersSpread"; 80 | case Pose::doubleTap: 81 | return "doubleTap"; 82 | case Pose::unknown: 83 | return "unknown"; 84 | } 85 | 86 | return ""; 87 | } 88 | 89 | inline 90 | std::ostream& operator<<(std::ostream& out, const Pose& pose) 91 | { 92 | return out << pose.toString(); 93 | } 94 | 95 | } // namespace myo 96 | 97 | #endif // MYO_CXX_IMPL_POSE_IMPL_HPP 98 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Versions/A/Headers/libmyo/detail/visibility.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #ifndef MYO_LIBMYO_DETAIL_VISIBILITY_H 4 | #define MYO_LIBMYO_DETAIL_VISIBILITY_H 5 | 6 | #if defined(_WIN32) || defined(__CYGWIN__) 7 | #ifdef myo_EXPORTS 8 | #ifdef __GNUC__ 9 | #define LIBMYO_EXPORT __attribute__ ((dllexport)) 10 | #else 11 | #define LIBMYO_EXPORT __declspec(dllexport) 12 | #endif 13 | #else 14 | #ifdef LIBMYO_STATIC_BUILD 15 | #define LIBMYO_EXPORT 16 | #else 17 | #ifdef __GNUC__ 18 | #define LIBMYO_EXPORT __attribute__ ((dllimport)) 19 | #else 20 | #define LIBMYO_EXPORT __declspec(dllimport) 21 | #endif 22 | #endif 23 | #endif 24 | #else 25 | #if __GNUC__ >= 4 26 | #define LIBMYO_EXPORT __attribute__ ((visibility ("default"))) 27 | #else 28 | #define LIBMYO_EXPORT 29 | #endif 30 | #endif 31 | 32 | #endif // MYO_LIBMYO_DETAIL_VISIBILITY_H 33 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Versions/A/Headers/myo.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #pragma once 4 | 5 | /// The namespace in which all of the %Myo C++ bindings are contained. 6 | namespace myo {} 7 | 8 | #include "cxx/DeviceListener.hpp" 9 | #include "cxx/Hub.hpp" 10 | #include "cxx/Myo.hpp" 11 | #include "cxx/Pose.hpp" 12 | #include "cxx/Quaternion.hpp" 13 | #include "cxx/Vector3.hpp" 14 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Versions/A/_CodeSignature/CodeResources: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | files 6 | 7 | Resources/Info.plist 8 | 9 | tUgLZV94WtJ7c7dl1ZQDEnyfe2U= 10 | 11 | 12 | files2 13 | 14 | Headers/cxx/DeviceListener.hpp 15 | 16 | 5frQIrDj5Rod49qbH8F/ODv03cg= 17 | 18 | Headers/cxx/Hub.hpp 19 | 20 | i2GwmXkJaAf8ZK1boAQLVFA9FuQ= 21 | 22 | Headers/cxx/Myo.hpp 23 | 24 | zkwa8CxGu7CxuY09ncg4cs2C0Ik= 25 | 26 | Headers/cxx/Pose.hpp 27 | 28 | bV/b65asnTpOQVVUseBE2Jks2yY= 29 | 30 | Headers/cxx/Quaternion.hpp 31 | 32 | bvsi/ZwGqVs0ZiHbWPUtsWlsK8k= 33 | 34 | Headers/cxx/Vector3.hpp 35 | 36 | OQUYhjK6FE/MwW8eyy24OtbHO4I= 37 | 38 | Headers/cxx/detail/ThrowOnError.hpp 39 | 40 | ZG7+E/cEH4UadH/3StifiGVjRxE= 41 | 42 | Headers/cxx/impl/Hub_impl.hpp 43 | 44 | jPk/hrtJnF4CumxpYjsOPpHH8PM= 45 | 46 | Headers/cxx/impl/Myo_impl.hpp 47 | 48 | 1IleanLjzRkjPeQaDU5tHCnz3+k= 49 | 50 | Headers/cxx/impl/Pose_impl.hpp 51 | 52 | dimtyDcx8DWcpkDi1creWJADmRA= 53 | 54 | Headers/libmyo.h 55 | 56 | 0nJ1nA0iCBjWxuXv2VZ2vRHjXnY= 57 | 58 | Headers/libmyo/detail/visibility.h 59 | 60 | dPUWLcemRGRDAJVc1Gonqqzo2K0= 61 | 62 | Headers/myo.hpp 63 | 64 | JeFdPeQ4BqtfHJyJxRiXrDHj6xw= 65 | 66 | Resources/Info.plist 67 | 68 | tUgLZV94WtJ7c7dl1ZQDEnyfe2U= 69 | 70 | 71 | rules 72 | 73 | ^Resources/ 74 | 75 | ^Resources/.*\.lproj/ 76 | 77 | optional 78 | 79 | weight 80 | 1000 81 | 82 | ^Resources/.*\.lproj/locversion.plist$ 83 | 84 | omit 85 | 86 | weight 87 | 1100 88 | 89 | ^version.plist$ 90 | 91 | 92 | rules2 93 | 94 | .*\.dSYM($|/) 95 | 96 | weight 97 | 11 98 | 99 | ^(.*/)?\.DS_Store$ 100 | 101 | omit 102 | 103 | weight 104 | 2000 105 | 106 | ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/ 107 | 108 | nested 109 | 110 | weight 111 | 10 112 | 113 | ^.* 114 | 115 | ^Info\.plist$ 116 | 117 | omit 118 | 119 | weight 120 | 20 121 | 122 | ^PkgInfo$ 123 | 124 | omit 125 | 126 | weight 127 | 20 128 | 129 | ^Resources/ 130 | 131 | weight 132 | 20 133 | 134 | ^Resources/.*\.lproj/ 135 | 136 | optional 137 | 138 | weight 139 | 1000 140 | 141 | ^Resources/.*\.lproj/locversion.plist$ 142 | 143 | omit 144 | 145 | weight 146 | 1100 147 | 148 | ^[^/]+$ 149 | 150 | nested 151 | 152 | weight 153 | 10 154 | 155 | ^embedded\.provisionprofile$ 156 | 157 | weight 158 | 20 159 | 160 | ^version\.plist$ 161 | 162 | weight 163 | 20 164 | 165 | 166 | 167 | 168 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Versions/A/myo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nok/myo-processing/4fd7503f89325eb835be7bd11bf8b26ff3d64225/library/macosx/myo.framework/Versions/A/myo -------------------------------------------------------------------------------- /library/macosx/myo.framework/Versions/Current/Headers/cxx/Hub.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #pragma once 4 | 5 | #include 6 | 7 | #include 8 | 9 | namespace myo { 10 | 11 | class Myo; 12 | class DeviceListener; 13 | 14 | /// @brief A Hub provides access to one or more Myo instances. 15 | class Hub { 16 | public: 17 | /// Construct a hub. 18 | /// \a applicationIdentifier must follow a reverse domain name format (ex. com.domainname.appname). Application 19 | /// identifiers can be formed from the set of alphanumeric ASCII characters (a-z, A-Z, 0-9). The hyphen (-) and 20 | /// underscore (_) characters are permitted if they are not adjacent to a period (.) character (i.e. not at the 21 | /// start or end of each segment), but are not permitted in the top-level domain. Application identifiers must have 22 | /// three or more segments. For example, if a company's domain is example.com and the application is named 23 | /// hello-world, one could use "com.example.hello-world" as a valid application identifier. \a applicationIdentifier 24 | /// can be an empty string. 25 | /// Throws an exception of type std::invalid_argument if \a applicationIdentifier is not in the proper reverse 26 | /// domain name format or is longer than 255 characters. 27 | /// Throws an exception of type std::runtime_error if the hub initialization failed for some reason, typically 28 | /// because Myo Connect is not running and a connection can thus not be established. 29 | Hub(const std::string& applicationIdentifier = ""); 30 | 31 | /// Deallocate any resources associated with a Hub. 32 | /// This will cause all Myo instances retrieved from this Hub to become invalid. 33 | ~Hub(); 34 | 35 | /// Wait for a Myo to become paired, or time out after \a timeout_ms milliseconds if provided. 36 | /// If \a timeout_ms is zero, this function blocks until a Myo is found. 37 | /// This function must not be called concurrently with run() or runOnce(). 38 | Myo* waitForMyo(unsigned int milliseconds = 0); 39 | 40 | /// Register a listener to be called when device events occur. 41 | void addListener(DeviceListener* listener); 42 | 43 | /// Remove a previously registered listener. 44 | void removeListener(DeviceListener* listener); 45 | 46 | /// Locking policies supported by Myo. 47 | enum LockingPolicy { 48 | lockingPolicyNone = libmyo_locking_policy_none, 49 | lockingPolicyStandard = libmyo_locking_policy_standard 50 | }; 51 | 52 | /// Set the locking policy for Myos connected to the Hub. 53 | void setLockingPolicy(LockingPolicy lockingPolicy); 54 | 55 | /// Run the event loop for the specified duration (in milliseconds). 56 | void run(unsigned int duration_ms); 57 | 58 | /// Run the event loop until a single event occurs, or the specified duration (in milliseconds) has elapsed. 59 | void runOnce(unsigned int duration_ms); 60 | 61 | /// @cond MYO_INTERNALS 62 | 63 | /// Return the internal libmyo object corresponding to this hub. 64 | libmyo_hub_t libmyoObject(); 65 | 66 | protected: 67 | void onDeviceEvent(libmyo_event_t event); 68 | 69 | Myo* lookupMyo(libmyo_myo_t opaqueMyo) const; 70 | 71 | Myo* addMyo(libmyo_myo_t opaqueMyo); 72 | 73 | libmyo_hub_t _hub; 74 | std::vector _myos; 75 | std::vector _listeners; 76 | 77 | /// @endcond 78 | 79 | private: 80 | // Not implemented 81 | Hub(const Hub&); 82 | Hub& operator=(const Hub&); 83 | }; 84 | 85 | /// @example hello-myo.cpp 86 | /// @example multiple-myos.cpp 87 | /// @example emg-data-sample.cpp 88 | 89 | } // namespace myo 90 | 91 | #include "impl/Hub_impl.hpp" 92 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Versions/Current/Headers/cxx/Myo.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #pragma once 4 | 5 | #include 6 | 7 | namespace myo { 8 | 9 | /// Represents a Myo device with a specific MAC address. 10 | /// This class can not be instantiated directly; instead, use Hub to get access to a Myo. 11 | /// There is only one Myo instance corresponding to each device; thus, if the addresses of two Myo instances compare 12 | /// equal, they refer to the same device. 13 | class Myo { 14 | public: 15 | /// Types of vibration supported by the Myo. 16 | enum VibrationType { 17 | vibrationShort = libmyo_vibration_short, 18 | vibrationMedium = libmyo_vibration_medium, 19 | vibrationLong = libmyo_vibration_long 20 | }; 21 | 22 | /// Vibrate the Myo. 23 | void vibrate(VibrationType type); 24 | 25 | /// Request the RSSI of the Myo. An onRssi event will likely be generated with the value of the RSSI. 26 | /// @see DeviceListener::onRssi() 27 | void requestRssi() const; 28 | 29 | /// Request the battery level of the Myo. An onBatteryLevelReceived event will be generated with the value. 30 | /// @see DeviceListener::onBatteryLevelReceived(). 31 | void requestBatteryLevel() const; 32 | 33 | /// Unlock types supported by Myo. 34 | enum UnlockType { 35 | unlockTimed = libmyo_unlock_timed, 36 | unlockHold = libmyo_unlock_hold 37 | }; 38 | 39 | /// Unlock the Myo. 40 | /// Myo will remain unlocked for a short amount of time, after which it will automatically lock again. 41 | /// If Myo was locked, an onUnlock event will be generated. 42 | void unlock(UnlockType type); 43 | 44 | /// Force the Myo to lock immediately. 45 | /// If Myo was unlocked, an onLock event will be generated. 46 | void lock(); 47 | 48 | /// Notify the Myo that a user action was recognized. 49 | /// Will cause Myo to vibrate. 50 | void notifyUserAction(); 51 | 52 | /// Valid EMG streaming modes for a Myo. 53 | enum StreamEmgType { 54 | streamEmgDisabled = libmyo_stream_emg_disabled, 55 | streamEmgEnabled = libmyo_stream_emg_enabled 56 | }; 57 | 58 | /// Sets the EMG streaming mode for a Myo. 59 | void setStreamEmg(StreamEmgType type); 60 | 61 | /// @cond MYO_INTERNALS 62 | 63 | /// Return the internal libmyo object corresponding to this device. 64 | libmyo_myo_t libmyoObject() const; 65 | 66 | /// @endcond 67 | 68 | private: 69 | Myo(libmyo_myo_t myo); 70 | ~Myo(); 71 | 72 | libmyo_myo_t _myo; 73 | 74 | // Not implemented. 75 | Myo(const Myo&); 76 | Myo& operator=(const Myo&); 77 | 78 | friend class Hub; 79 | }; 80 | 81 | } // namespace myo 82 | 83 | #include "impl/Myo_impl.hpp" 84 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Versions/Current/Headers/cxx/Pose.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #pragma once 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | namespace myo { 11 | 12 | /// A pose represents a detected configuration of the user's hand. 13 | class Pose { 14 | public: 15 | /// Types of poses supported by the SDK. 16 | enum Type { 17 | rest = libmyo_pose_rest, 18 | fist = libmyo_pose_fist, 19 | waveIn = libmyo_pose_wave_in, 20 | waveOut = libmyo_pose_wave_out, 21 | fingersSpread = libmyo_pose_fingers_spread, 22 | doubleTap = libmyo_pose_double_tap, 23 | unknown = libmyo_pose_unknown 24 | }; 25 | 26 | /// Construct a pose of type Pose::none. 27 | Pose(); 28 | 29 | /// Construct a pose with the given type. 30 | Pose(Type type); 31 | 32 | /// Returns true if and only if the two poses are of the same type. 33 | bool operator==(Pose other) const; 34 | 35 | /// Equivalent to `!(*this == other)`. 36 | bool operator!=(Pose other) const; 37 | 38 | /// Returns the type of this pose. 39 | Type type() const; 40 | 41 | /// Return a human-readable string representation of the pose. 42 | std::string toString() const; 43 | 44 | private: 45 | Type _type; 46 | }; 47 | 48 | /// @relates Pose 49 | /// Returns true if and only if the type of pose is the same as the provided type. 50 | bool operator==(Pose pose, Pose::Type t); 51 | 52 | /// @relates Pose 53 | /// Equivalent to `pose == type`. 54 | bool operator==(Pose::Type type, Pose pose); 55 | 56 | /// @relates Pose 57 | /// Equivalent to `!(pose == type)`. 58 | bool operator!=(Pose pose, Pose::Type type); 59 | 60 | /// @relates Pose 61 | /// Equivalent to `!(type == pose)`. 62 | bool operator!=(Pose::Type type, Pose pose); 63 | 64 | /// @relates Pose 65 | /// Write the name of the provided pose to the provided output stream. 66 | std::ostream& operator<<(std::ostream& out, const Pose& pose); 67 | 68 | } // namespace myo 69 | 70 | #include "impl/Pose_impl.hpp" 71 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Versions/Current/Headers/cxx/Quaternion.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #pragma once 4 | 5 | #include 6 | 7 | #include "Vector3.hpp" 8 | 9 | namespace myo { 10 | 11 | /// A quaternion that can be used to represent a rotation. 12 | /// This type provides only very basic functionality to store quaternions that's sufficient to retrieve the data to 13 | /// be placed in a full featured quaternion type. 14 | template 15 | class Quaternion { 16 | public: 17 | /// Construct a quaternion that represents zero rotation (i.e. the multiplicative identity). 18 | Quaternion() 19 | : _x(0) 20 | , _y(0) 21 | , _z(0) 22 | , _w(1) 23 | { 24 | } 25 | 26 | /// Construct a quaternion with the provided components. 27 | Quaternion(T x, T y, T z, T w) 28 | : _x(x) 29 | , _y(y) 30 | , _z(z) 31 | , _w(w) 32 | { 33 | } 34 | 35 | /// Set the components of this quaternion to be those of the other. 36 | Quaternion& operator=(const Quaternion other) 37 | { 38 | _x = other._x; 39 | _y = other._y; 40 | _z = other._z; 41 | _w = other._w; 42 | 43 | return *this; 44 | } 45 | 46 | /// Return the x-component of this quaternion's vector. 47 | T x() const { return _x; } 48 | 49 | /// Return the y-component of this quaternion's vector. 50 | T y() const { return _y; } 51 | 52 | /// Return the z-component of this quaternion's vector. 53 | T z() const { return _z; } 54 | 55 | /// Return the w-component (scalar) of this quaternion. 56 | T w() const { return _w; } 57 | 58 | /// Return the quaternion multiplied by \a rhs. 59 | /// Note that quaternion multiplication is not commutative. 60 | Quaternion operator*(const Quaternion& rhs) const 61 | { 62 | return Quaternion( 63 | _w * rhs._x + _x * rhs._w + _y * rhs._z - _z * rhs._y, 64 | _w * rhs._y - _x * rhs._z + _y * rhs._w + _z * rhs._x, 65 | _w * rhs._z + _x * rhs._y - _y * rhs._x + _z * rhs._w, 66 | _w * rhs._w - _x * rhs._x - _y * rhs._y - _z * rhs._z 67 | ); 68 | } 69 | 70 | /// Multiply this quaternion by \a rhs. 71 | /// Return this quaternion updated with the result. 72 | Quaternion& operator*=(const Quaternion& rhs) 73 | { 74 | *this = *this * rhs; 75 | return *this; 76 | } 77 | 78 | /// Return the unit quaternion corresponding to the same rotation as this one. 79 | Quaternion normalized() const 80 | { 81 | T magnitude = std::sqrt(_x * _x + _y * _y + _z * _z + _w * _w); 82 | 83 | return Quaternion(_x / magnitude, _y / magnitude, _z / magnitude, _w / magnitude); 84 | } 85 | 86 | /// Return this quaternion's conjugate. 87 | Quaternion conjugate() const 88 | { 89 | return Quaternion(-_x, -_y, -_z, _w); 90 | } 91 | 92 | /// Return a quaternion that represents a right-handed rotation of \a angle radians about the given \a axis. 93 | /// \a axis The unit vector representing the axis of rotation. 94 | /// \a angle The angle of rotation, in radians. 95 | static Quaternion fromAxisAngle(const myo::Vector3& axis, T angle) 96 | { 97 | return Quaternion(axis.x() * std::sin(angle / 2), 98 | axis.y() * std::sin(angle / 2), 99 | axis.z() * std::sin(angle / 2), 100 | std::cos(angle / 2)); 101 | } 102 | 103 | private: 104 | T _x, _y, _z, _w; 105 | }; 106 | 107 | /// Return a copy of this \a vec rotated by \a quat. 108 | /// \relates myo::Quaternion 109 | template 110 | Vector3 rotate(const Quaternion& quat, const Vector3& vec) 111 | { 112 | myo::Quaternion qvec(vec.x(), vec.y(), vec.z(), 0); 113 | myo::Quaternion result = quat * qvec * quat.conjugate(); 114 | return Vector3(result.x(), result.y(), result.z()); 115 | } 116 | 117 | /// Return a quaternion that represents a rotation from vector \a from to \a to. 118 | /// \relates myo::Quaternion 119 | /// See http://stackoverflow.com/questions/1171849/finding-quaternion-representing-the-rotation-from-one-vector-to-another 120 | /// for some explanation. 121 | template 122 | Quaternion rotate(const Vector3& from, const Vector3& to) 123 | { 124 | Vector3 cross = from.cross(to); 125 | 126 | // The product of the square of magnitudes and the cosine of the angle between from and to. 127 | T cosTheta = from.dot(to); 128 | 129 | // Return identity if the vectors are the same direction. 130 | if (cosTheta >= 1) { 131 | return Quaternion(); 132 | } 133 | 134 | // The product of the square of the magnitudes 135 | T k = std::sqrt(from.dot(from) * to.dot(to)); 136 | 137 | // Return identity in the degenerate case. 138 | if (k <= 0) { 139 | return Quaternion(); 140 | } 141 | 142 | // Special handling for vectors facing opposite directions. 143 | if (cosTheta / k <= -1) { 144 | Vector3 xAxis(1, 0, 0); 145 | Vector3 yAxis(0, 1, 0); 146 | 147 | cross = from.cross(std::abs(from.dot(xAxis)) < 1 ? xAxis : yAxis); 148 | k = cosTheta = 0; 149 | } 150 | 151 | return Quaternion( 152 | cross.x(), 153 | cross.y(), 154 | cross.z(), 155 | k + cosTheta); 156 | } 157 | 158 | } // namespace myo 159 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Versions/Current/Headers/cxx/Vector3.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #pragma once 4 | 5 | #define _USE_MATH_DEFINES 6 | #include 7 | 8 | namespace myo { 9 | 10 | /// A vector of three components. 11 | /// This type provides very basic functionality to store a three dimensional vector that's sufficient to retrieve 12 | /// the data to be placed in a full featured vector type. A few common vector operations, such as dot product and 13 | /// cross product, are also provided. 14 | template 15 | class Vector3 { 16 | public: 17 | /// Construct a vector of all zeroes. 18 | Vector3() 19 | { 20 | _data[0] = 0; 21 | _data[1] = 0; 22 | _data[2] = 0; 23 | } 24 | 25 | /// Construct a vector with the three provided components. 26 | Vector3(T x, T y, T z) 27 | { 28 | _data[0] = x; 29 | _data[1] = y; 30 | _data[2] = z; 31 | } 32 | 33 | /// Construct a vector with the same components as \a other. 34 | Vector3(const Vector3& other) 35 | { 36 | *this = other; 37 | } 38 | 39 | /// Set the components of this vector to be the same as \a other. 40 | Vector3& operator=(const Vector3& other) 41 | { 42 | _data[0] = other._data[0]; 43 | _data[1] = other._data[1]; 44 | _data[2] = other._data[2]; 45 | 46 | return *this; 47 | } 48 | 49 | /// Return a copy of the component of this vector at \a index, which should be 0, 1, or 2. 50 | T operator[](unsigned int index) const 51 | { 52 | return _data[index]; 53 | } 54 | 55 | /// Return the x-component of this vector. 56 | T x() const { return _data[0]; } 57 | 58 | /// Return the y-component of this vector. 59 | T y() const { return _data[1]; } 60 | 61 | /// Return the z-component of this vector. 62 | T z() const { return _data[2]; } 63 | 64 | /// Return the magnitude of this vector. 65 | T magnitude() const 66 | { 67 | return std::sqrt(x() * x() + y() * y() + z() * z()); 68 | } 69 | 70 | /// Return a normalized copy of this vector. 71 | Vector3 normalized() const 72 | { 73 | T norm = magnitude(); 74 | return Vector3(x() / norm, y() / norm, z() / norm); 75 | } 76 | 77 | /// Return the dot product of this vector and \a rhs. 78 | T dot(const Vector3& rhs) const 79 | { 80 | return x() * rhs.x() + y() * rhs.y() + z() * rhs.z(); 81 | } 82 | 83 | /// Return the cross product of this vector and \a rhs. 84 | Vector3 cross(const Vector3& rhs) const 85 | { 86 | return Vector3( 87 | y() * rhs.z() - z() * rhs.y(), 88 | z() * rhs.x() - x() * rhs.z(), 89 | x() * rhs.y() - y() * rhs.x() 90 | ); 91 | } 92 | 93 | /// Return the angle between this vector and \a rhs, in radians. 94 | T angleTo(const Vector3& rhs) const 95 | { 96 | return std::acos(dot(rhs) / (magnitude() * rhs.magnitude())); 97 | } 98 | 99 | private: 100 | T _data[3]; 101 | }; 102 | 103 | } // namespace myo 104 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Versions/Current/Headers/cxx/detail/ThrowOnError.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #ifndef MYO_CXX_DETAIL_THROWONERROR_HPP 4 | #define MYO_CXX_DETAIL_THROWONERROR_HPP 5 | 6 | #include 7 | 8 | #include 9 | 10 | #if defined(_MSC_VER) && _MSC_VER <= 1800 11 | #define LIBMYO_NOEXCEPT(b) 12 | #else 13 | #if __cplusplus >= 201103L 14 | # define LIBMYO_NOEXCEPT(b) noexcept(b) 15 | #else 16 | # define LIBMYO_NOEXCEPT(b) 17 | #endif 18 | #endif 19 | 20 | namespace myo { 21 | 22 | class ThrowOnError { 23 | public: 24 | ThrowOnError() 25 | : _error() 26 | { 27 | } 28 | 29 | ~ThrowOnError() LIBMYO_NOEXCEPT(false) 30 | { 31 | if (_error) 32 | { 33 | switch (libmyo_error_kind(_error)) { 34 | case libmyo_error: 35 | case libmyo_error_runtime: 36 | { 37 | std::runtime_error exception(libmyo_error_cstring(_error)); 38 | libmyo_free_error_details(_error); 39 | throw exception; 40 | } 41 | case libmyo_error_invalid_argument: 42 | { 43 | std::invalid_argument exception(libmyo_error_cstring(_error)); 44 | libmyo_free_error_details(_error); 45 | throw exception; 46 | } 47 | case libmyo_success: 48 | { 49 | break; 50 | } 51 | } 52 | } 53 | } 54 | 55 | operator libmyo_error_details_t*() 56 | { 57 | return &_error; 58 | } 59 | 60 | private: 61 | libmyo_error_details_t _error; 62 | 63 | // Not implemented 64 | ThrowOnError(const ThrowOnError&); // = delete; 65 | ThrowOnError& operator=(const ThrowOnError&); // = delete; 66 | }; 67 | 68 | } //namespace libmyo 69 | 70 | #endif // MYO_CXX_DETAIL_THROWONERROR_HPP 71 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Versions/Current/Headers/cxx/impl/Hub_impl.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #include "../Hub.hpp" 4 | 5 | #include 6 | #include 7 | 8 | #include "../DeviceListener.hpp" 9 | #include "../Myo.hpp" 10 | #include "../Pose.hpp" 11 | #include "../Quaternion.hpp" 12 | #include "../Vector3.hpp" 13 | #include "../detail/ThrowOnError.hpp" 14 | 15 | namespace myo { 16 | 17 | inline 18 | Hub::Hub(const std::string& applicationIdentifier) 19 | : _hub(0) 20 | , _myos() 21 | , _listeners() 22 | { 23 | libmyo_init_hub(&_hub, applicationIdentifier.c_str(), ThrowOnError()); 24 | } 25 | 26 | inline 27 | Hub::~Hub() 28 | { 29 | for (std::vector::iterator I = _myos.begin(), IE = _myos.end(); I != IE; ++I) { 30 | delete *I; 31 | } 32 | libmyo_shutdown_hub(_hub, 0); 33 | } 34 | 35 | inline 36 | Myo* Hub::waitForMyo(unsigned int timeout_ms) 37 | { 38 | std::size_t prevSize = _myos.size(); 39 | 40 | struct local { 41 | static libmyo_handler_result_t handler(void* user_data, libmyo_event_t event) { 42 | Hub* hub = static_cast(user_data); 43 | 44 | libmyo_myo_t opaque_myo = libmyo_event_get_myo(event); 45 | 46 | switch (libmyo_event_get_type(event)) { 47 | case libmyo_event_paired: 48 | hub->addMyo(opaque_myo); 49 | return libmyo_handler_stop; 50 | default: 51 | break; 52 | } 53 | 54 | return libmyo_handler_continue; 55 | } 56 | }; 57 | 58 | do { 59 | libmyo_run(_hub, timeout_ms ? timeout_ms : 1000, &local::handler, this, ThrowOnError()); 60 | } while (!timeout_ms && _myos.size() <= prevSize); 61 | 62 | if (_myos.size() <= prevSize) { 63 | return 0; 64 | } 65 | 66 | return _myos.back(); 67 | } 68 | 69 | inline 70 | void Hub::addListener(DeviceListener* listener) 71 | { 72 | if (std::find(_listeners.begin(), _listeners.end(), listener) != _listeners.end()) { 73 | // Listener was already added. 74 | return; 75 | } 76 | _listeners.push_back(listener); 77 | } 78 | 79 | inline 80 | void Hub::removeListener(DeviceListener* listener) 81 | { 82 | std::vector::iterator I = std::find(_listeners.begin(), _listeners.end(), listener); 83 | if (I == _listeners.end()) { 84 | // Don't have this listener. 85 | return; 86 | } 87 | 88 | _listeners.erase(I); 89 | } 90 | 91 | inline 92 | void Hub::setLockingPolicy(LockingPolicy lockingPolicy) 93 | { 94 | libmyo_set_locking_policy(_hub, static_cast(lockingPolicy), ThrowOnError()); 95 | } 96 | 97 | inline 98 | void Hub::onDeviceEvent(libmyo_event_t event) 99 | { 100 | libmyo_myo_t opaqueMyo = libmyo_event_get_myo(event); 101 | 102 | Myo* myo = lookupMyo(opaqueMyo); 103 | 104 | if (!myo && libmyo_event_get_type(event) == libmyo_event_paired) { 105 | myo = addMyo(opaqueMyo); 106 | } 107 | 108 | if (!myo) { 109 | // Ignore events for Myos we don't know about. 110 | return; 111 | } 112 | 113 | for (std::vector::iterator I = _listeners.begin(), IE = _listeners.end(); I != IE; ++I) { 114 | DeviceListener* listener = *I; 115 | 116 | listener->onOpaqueEvent(event); 117 | 118 | uint64_t time = libmyo_event_get_timestamp(event); 119 | 120 | switch (libmyo_event_get_type(event)) { 121 | case libmyo_event_paired: { 122 | FirmwareVersion version = {libmyo_event_get_firmware_version(event, libmyo_version_major), 123 | libmyo_event_get_firmware_version(event, libmyo_version_minor), 124 | libmyo_event_get_firmware_version(event, libmyo_version_patch), 125 | libmyo_event_get_firmware_version(event, libmyo_version_hardware_rev)}; 126 | listener->onPair(myo, time, version); 127 | break; 128 | } 129 | case libmyo_event_unpaired: 130 | listener->onUnpair(myo, time); 131 | break; 132 | case libmyo_event_connected: { 133 | FirmwareVersion version = {libmyo_event_get_firmware_version(event, libmyo_version_major), 134 | libmyo_event_get_firmware_version(event, libmyo_version_minor), 135 | libmyo_event_get_firmware_version(event, libmyo_version_patch), 136 | libmyo_event_get_firmware_version(event, libmyo_version_hardware_rev)}; 137 | listener->onConnect(myo, time, version); 138 | break; 139 | } 140 | case libmyo_event_disconnected: 141 | listener->onDisconnect(myo, time); 142 | break; 143 | case libmyo_event_arm_synced: 144 | listener->onArmSync(myo, time, 145 | static_cast(libmyo_event_get_arm(event)), 146 | static_cast(libmyo_event_get_x_direction(event)), 147 | libmyo_event_get_rotation_on_arm(event), 148 | static_cast(libmyo_event_get_warmup_state(event))); 149 | break; 150 | case libmyo_event_arm_unsynced: 151 | listener->onArmUnsync(myo, time); 152 | break; 153 | case libmyo_event_unlocked: 154 | listener->onUnlock(myo, time); 155 | break; 156 | case libmyo_event_locked: 157 | listener->onLock(myo, time); 158 | break; 159 | case libmyo_event_orientation: 160 | listener->onOrientationData(myo, time, 161 | Quaternion(libmyo_event_get_orientation(event, libmyo_orientation_x), 162 | libmyo_event_get_orientation(event, libmyo_orientation_y), 163 | libmyo_event_get_orientation(event, libmyo_orientation_z), 164 | libmyo_event_get_orientation(event, libmyo_orientation_w))); 165 | listener->onAccelerometerData(myo, time, 166 | Vector3(libmyo_event_get_accelerometer(event, 0), 167 | libmyo_event_get_accelerometer(event, 1), 168 | libmyo_event_get_accelerometer(event, 2))); 169 | 170 | listener->onGyroscopeData(myo, time, 171 | Vector3(libmyo_event_get_gyroscope(event, 0), 172 | libmyo_event_get_gyroscope(event, 1), 173 | libmyo_event_get_gyroscope(event, 2))); 174 | 175 | break; 176 | case libmyo_event_pose: 177 | listener->onPose(myo, time, Pose(static_cast(libmyo_event_get_pose(event)))); 178 | break; 179 | case libmyo_event_rssi: 180 | listener->onRssi(myo, time, libmyo_event_get_rssi(event)); 181 | break; 182 | case libmyo_event_battery_level: 183 | listener->onBatteryLevelReceived(myo, time, libmyo_event_get_battery_level(event)); 184 | break; 185 | case libmyo_event_emg: { 186 | int8_t emg[] = { libmyo_event_get_emg(event, 0), 187 | libmyo_event_get_emg(event, 1), 188 | libmyo_event_get_emg(event, 2), 189 | libmyo_event_get_emg(event, 3), 190 | libmyo_event_get_emg(event, 4), 191 | libmyo_event_get_emg(event, 5), 192 | libmyo_event_get_emg(event, 6), 193 | libmyo_event_get_emg(event, 7) }; 194 | listener->onEmgData(myo, time, emg); 195 | break; 196 | } 197 | case libmyo_event_warmup_completed: { 198 | listener->onWarmupCompleted(myo, time, static_cast(libmyo_event_get_warmup_result(event))); 199 | break; 200 | } 201 | } 202 | } 203 | } 204 | 205 | inline 206 | void Hub::run(unsigned int duration_ms) 207 | { 208 | struct local { 209 | static libmyo_handler_result_t handler(void* user_data, libmyo_event_t event) { 210 | Hub* hub = static_cast(user_data); 211 | 212 | hub->onDeviceEvent(event); 213 | 214 | return libmyo_handler_continue; 215 | } 216 | }; 217 | libmyo_run(_hub, duration_ms, &local::handler, this, ThrowOnError()); 218 | } 219 | 220 | inline 221 | void Hub::runOnce(unsigned int duration_ms) 222 | { 223 | struct local { 224 | static libmyo_handler_result_t handler(void* user_data, libmyo_event_t event) { 225 | Hub* hub = static_cast(user_data); 226 | 227 | hub->onDeviceEvent(event); 228 | 229 | return libmyo_handler_stop; 230 | } 231 | }; 232 | libmyo_run(_hub, duration_ms, &local::handler, this, ThrowOnError()); 233 | } 234 | 235 | inline 236 | libmyo_hub_t Hub::libmyoObject() 237 | { 238 | return _hub; 239 | } 240 | 241 | inline 242 | Myo* Hub::lookupMyo(libmyo_myo_t opaqueMyo) const 243 | { 244 | Myo* myo = 0; 245 | for (std::vector::const_iterator I = _myos.begin(), IE = _myos.end(); I != IE; ++I) { 246 | if ((*I)->libmyoObject() == opaqueMyo) { 247 | myo = *I; 248 | break; 249 | } 250 | } 251 | 252 | return myo; 253 | } 254 | 255 | inline 256 | Myo* Hub::addMyo(libmyo_myo_t opaqueMyo) 257 | { 258 | Myo* myo = new Myo(opaqueMyo); 259 | 260 | _myos.push_back(myo); 261 | 262 | return myo; 263 | } 264 | 265 | } // namespace myo 266 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Versions/Current/Headers/cxx/impl/Myo_impl.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #include "../Myo.hpp" 4 | #include "../detail/ThrowOnError.hpp" 5 | 6 | #include 7 | 8 | namespace myo { 9 | 10 | inline 11 | void Myo::vibrate(VibrationType type) 12 | { 13 | libmyo_vibrate(_myo, static_cast(type), ThrowOnError()); 14 | } 15 | 16 | inline 17 | void Myo::requestRssi() const 18 | { 19 | libmyo_request_rssi(_myo, ThrowOnError()); 20 | } 21 | 22 | inline 23 | void Myo::requestBatteryLevel() const 24 | { 25 | libmyo_request_battery_level(_myo, myo::ThrowOnError()); 26 | } 27 | 28 | inline 29 | void Myo::unlock(UnlockType type) 30 | { 31 | libmyo_myo_unlock(_myo, static_cast(type), ThrowOnError()); 32 | } 33 | 34 | inline 35 | void Myo::lock() 36 | { 37 | libmyo_myo_lock(_myo, ThrowOnError()); 38 | } 39 | 40 | inline 41 | void Myo::notifyUserAction() 42 | { 43 | libmyo_myo_notify_user_action(_myo, libmyo_user_action_single, ThrowOnError()); 44 | } 45 | 46 | inline 47 | void Myo::setStreamEmg(StreamEmgType type) 48 | { 49 | libmyo_set_stream_emg(_myo, static_cast(type), ThrowOnError()); 50 | } 51 | 52 | inline 53 | libmyo_myo_t Myo::libmyoObject() const 54 | { 55 | return _myo; 56 | } 57 | 58 | inline 59 | Myo::Myo(libmyo_myo_t myo) 60 | : _myo(myo) 61 | { 62 | if (!_myo) { 63 | throw std::invalid_argument("Cannot construct Myo instance with null pointer"); 64 | } 65 | } 66 | 67 | inline 68 | Myo::~Myo() 69 | { 70 | } 71 | 72 | } // namespace myo 73 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Versions/Current/Headers/cxx/impl/Pose_impl.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #ifndef MYO_CXX_IMPL_POSE_IMPL_HPP 4 | #define MYO_CXX_IMPL_POSE_IMPL_HPP 5 | 6 | #include "../Pose.hpp" 7 | 8 | #include 9 | 10 | namespace myo { 11 | 12 | inline 13 | Pose::Pose() 14 | : _type(unknown) 15 | { 16 | } 17 | 18 | inline 19 | Pose::Pose(Pose::Type type) 20 | : _type(type) 21 | { 22 | } 23 | 24 | inline 25 | bool Pose::operator==(Pose other) const 26 | { 27 | return _type == other._type; 28 | } 29 | 30 | inline 31 | bool Pose::operator!=(Pose other) const 32 | { 33 | return !(*this == other); 34 | } 35 | 36 | inline 37 | Pose::Type Pose::type() const 38 | { 39 | return _type; 40 | } 41 | 42 | inline 43 | bool operator==(Pose pose, Pose::Type type) 44 | { 45 | return pose.type() == type; 46 | } 47 | 48 | inline 49 | bool operator==(Pose::Type type, Pose pose) 50 | { 51 | return pose == type; 52 | } 53 | 54 | inline 55 | bool operator!=(Pose pose, Pose::Type type) 56 | { 57 | return !(pose == type); 58 | } 59 | 60 | inline 61 | bool operator!=(Pose::Type type, Pose pose) 62 | { 63 | return !(type == pose); 64 | } 65 | 66 | inline 67 | std::string Pose::toString() const 68 | { 69 | switch (type()) { 70 | case Pose::rest: 71 | return "rest"; 72 | case Pose::fist: 73 | return "fist"; 74 | case Pose::waveIn: 75 | return "waveIn"; 76 | case Pose::waveOut: 77 | return "waveOut"; 78 | case Pose::fingersSpread: 79 | return "fingersSpread"; 80 | case Pose::doubleTap: 81 | return "doubleTap"; 82 | case Pose::unknown: 83 | return "unknown"; 84 | } 85 | 86 | return ""; 87 | } 88 | 89 | inline 90 | std::ostream& operator<<(std::ostream& out, const Pose& pose) 91 | { 92 | return out << pose.toString(); 93 | } 94 | 95 | } // namespace myo 96 | 97 | #endif // MYO_CXX_IMPL_POSE_IMPL_HPP 98 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Versions/Current/Headers/libmyo/detail/visibility.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #ifndef MYO_LIBMYO_DETAIL_VISIBILITY_H 4 | #define MYO_LIBMYO_DETAIL_VISIBILITY_H 5 | 6 | #if defined(_WIN32) || defined(__CYGWIN__) 7 | #ifdef myo_EXPORTS 8 | #ifdef __GNUC__ 9 | #define LIBMYO_EXPORT __attribute__ ((dllexport)) 10 | #else 11 | #define LIBMYO_EXPORT __declspec(dllexport) 12 | #endif 13 | #else 14 | #ifdef LIBMYO_STATIC_BUILD 15 | #define LIBMYO_EXPORT 16 | #else 17 | #ifdef __GNUC__ 18 | #define LIBMYO_EXPORT __attribute__ ((dllimport)) 19 | #else 20 | #define LIBMYO_EXPORT __declspec(dllimport) 21 | #endif 22 | #endif 23 | #endif 24 | #else 25 | #if __GNUC__ >= 4 26 | #define LIBMYO_EXPORT __attribute__ ((visibility ("default"))) 27 | #else 28 | #define LIBMYO_EXPORT 29 | #endif 30 | #endif 31 | 32 | #endif // MYO_LIBMYO_DETAIL_VISIBILITY_H 33 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Versions/Current/Headers/myo.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Thalmic Labs Inc. 2 | // Distributed under the Myo SDK license agreement. See LICENSE.txt for details. 3 | #pragma once 4 | 5 | /// The namespace in which all of the %Myo C++ bindings are contained. 6 | namespace myo {} 7 | 8 | #include "cxx/DeviceListener.hpp" 9 | #include "cxx/Hub.hpp" 10 | #include "cxx/Myo.hpp" 11 | #include "cxx/Pose.hpp" 12 | #include "cxx/Quaternion.hpp" 13 | #include "cxx/Vector3.hpp" 14 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Versions/Current/_CodeSignature/CodeResources: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | files 6 | 7 | Resources/Info.plist 8 | 9 | tUgLZV94WtJ7c7dl1ZQDEnyfe2U= 10 | 11 | 12 | files2 13 | 14 | Headers/cxx/DeviceListener.hpp 15 | 16 | 5frQIrDj5Rod49qbH8F/ODv03cg= 17 | 18 | Headers/cxx/Hub.hpp 19 | 20 | i2GwmXkJaAf8ZK1boAQLVFA9FuQ= 21 | 22 | Headers/cxx/Myo.hpp 23 | 24 | zkwa8CxGu7CxuY09ncg4cs2C0Ik= 25 | 26 | Headers/cxx/Pose.hpp 27 | 28 | bV/b65asnTpOQVVUseBE2Jks2yY= 29 | 30 | Headers/cxx/Quaternion.hpp 31 | 32 | bvsi/ZwGqVs0ZiHbWPUtsWlsK8k= 33 | 34 | Headers/cxx/Vector3.hpp 35 | 36 | OQUYhjK6FE/MwW8eyy24OtbHO4I= 37 | 38 | Headers/cxx/detail/ThrowOnError.hpp 39 | 40 | ZG7+E/cEH4UadH/3StifiGVjRxE= 41 | 42 | Headers/cxx/impl/Hub_impl.hpp 43 | 44 | jPk/hrtJnF4CumxpYjsOPpHH8PM= 45 | 46 | Headers/cxx/impl/Myo_impl.hpp 47 | 48 | 1IleanLjzRkjPeQaDU5tHCnz3+k= 49 | 50 | Headers/cxx/impl/Pose_impl.hpp 51 | 52 | dimtyDcx8DWcpkDi1creWJADmRA= 53 | 54 | Headers/libmyo.h 55 | 56 | 0nJ1nA0iCBjWxuXv2VZ2vRHjXnY= 57 | 58 | Headers/libmyo/detail/visibility.h 59 | 60 | dPUWLcemRGRDAJVc1Gonqqzo2K0= 61 | 62 | Headers/myo.hpp 63 | 64 | JeFdPeQ4BqtfHJyJxRiXrDHj6xw= 65 | 66 | Resources/Info.plist 67 | 68 | tUgLZV94WtJ7c7dl1ZQDEnyfe2U= 69 | 70 | 71 | rules 72 | 73 | ^Resources/ 74 | 75 | ^Resources/.*\.lproj/ 76 | 77 | optional 78 | 79 | weight 80 | 1000 81 | 82 | ^Resources/.*\.lproj/locversion.plist$ 83 | 84 | omit 85 | 86 | weight 87 | 1100 88 | 89 | ^version.plist$ 90 | 91 | 92 | rules2 93 | 94 | .*\.dSYM($|/) 95 | 96 | weight 97 | 11 98 | 99 | ^(.*/)?\.DS_Store$ 100 | 101 | omit 102 | 103 | weight 104 | 2000 105 | 106 | ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/ 107 | 108 | nested 109 | 110 | weight 111 | 10 112 | 113 | ^.* 114 | 115 | ^Info\.plist$ 116 | 117 | omit 118 | 119 | weight 120 | 20 121 | 122 | ^PkgInfo$ 123 | 124 | omit 125 | 126 | weight 127 | 20 128 | 129 | ^Resources/ 130 | 131 | weight 132 | 20 133 | 134 | ^Resources/.*\.lproj/ 135 | 136 | optional 137 | 138 | weight 139 | 1000 140 | 141 | ^Resources/.*\.lproj/locversion.plist$ 142 | 143 | omit 144 | 145 | weight 146 | 1100 147 | 148 | ^[^/]+$ 149 | 150 | nested 151 | 152 | weight 153 | 10 154 | 155 | ^embedded\.provisionprofile$ 156 | 157 | weight 158 | 20 159 | 160 | ^version\.plist$ 161 | 162 | weight 163 | 20 164 | 165 | 166 | 167 | 168 | -------------------------------------------------------------------------------- /library/macosx/myo.framework/Versions/Current/myo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nok/myo-processing/4fd7503f89325eb835be7bd11bf8b26ff3d64225/library/macosx/myo.framework/Versions/Current/myo -------------------------------------------------------------------------------- /library/macosx/myo.framework/myo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nok/myo-processing/4fd7503f89325eb835be7bd11bf8b26ff3d64225/library/macosx/myo.framework/myo -------------------------------------------------------------------------------- /library/myo-java-0.9.1-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nok/myo-processing/4fd7503f89325eb835be7bd11bf8b26ff3d64225/library/myo-java-0.9.1-SNAPSHOT.jar -------------------------------------------------------------------------------- /library/windows/JNIJavaMyoLib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nok/myo-processing/4fd7503f89325eb835be7bd11bf8b26ff3d64225/library/windows/JNIJavaMyoLib.dll -------------------------------------------------------------------------------- /library/windows/myo32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nok/myo-processing/4fd7503f89325eb835be7bd11bf8b26ff3d64225/library/windows/myo32.dll -------------------------------------------------------------------------------- /library/windows64/JNIJavaMyoLib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nok/myo-processing/4fd7503f89325eb835be7bd11bf8b26ff3d64225/library/windows64/JNIJavaMyoLib.dll -------------------------------------------------------------------------------- /library/windows64/myo64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nok/myo-processing/4fd7503f89325eb835be7bd11bf8b26ff3d64225/library/windows64/myo64.dll -------------------------------------------------------------------------------- /reference/allclasses-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | All Classes (Javadocs: MyoForProcessing) 7 | 8 | 9 | 10 | 11 |

All Classes

12 |
13 | 25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /reference/allclasses-noframe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | All Classes (Javadocs: MyoForProcessing) 7 | 8 | 9 | 10 | 11 |

All Classes

12 |
13 | 25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /reference/constant-values.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Constant Field Values (Javadocs: MyoForProcessing) 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 34 |
35 | 62 | 63 |
64 |

Constant Field Values

65 |

Contents

66 |
67 | 68 |
69 | 70 | 71 | 72 | 73 | 81 |
82 | 109 | 110 |

Processing library MyoForProcessing by Darius Morawiec. (C) 2014

111 | 112 | 113 | -------------------------------------------------------------------------------- /reference/de/voidplus/myo/Pose.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Pose (Javadocs: MyoForProcessing) 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 34 |
35 | 77 | 78 | 79 |
80 |
de.voidplus.myo
81 |

Class Pose

82 |
83 |
84 | 92 |
93 |
    94 |
  • 95 |
    96 |
    97 |
    public class Pose
     98 | extends Object
    99 |
  • 100 |
101 |
102 |
103 | 154 |
155 |
156 |
    157 |
  • 158 | 159 |
      160 |
    • 161 | 162 | 163 |

      Method Detail

      164 | 165 | 166 | 167 |
        168 |
      • 169 |

        getType

        170 |
        public Pose.Type getType()
        171 |
        Get the type of pose.
        172 |
        Returns:
        173 |
      • 174 |
      175 |
    • 176 |
    177 |
  • 178 |
179 |
180 |
181 | 182 | 183 |
184 | 185 | 186 | 187 | 188 | 196 |
197 | 239 | 240 |

Processing library MyoForProcessing by Darius Morawiec. (C) 2014

241 | 242 | 243 | -------------------------------------------------------------------------------- /reference/de/voidplus/myo/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | de.voidplus.myo (Javadocs: MyoForProcessing) 7 | 8 | 9 | 10 | 11 |

de.voidplus.myo

12 |
13 |

Classes

14 | 21 |

Enums

22 | 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /reference/de/voidplus/myo/package-summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | de.voidplus.myo (Javadocs: MyoForProcessing) 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 34 |
35 | 62 | 63 |
64 |

Package de.voidplus.myo

65 |
66 |
67 |
    68 |
  • 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 85 | 86 | 87 | 88 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 |
    Class Summary 
    ClassDescription
    Arm 
    Collector 83 |
    Internal class which organize the event handling.
    84 |
    Device 89 |
    Class which represents a single Myo device.
    90 |
    Myo 
    Pose 
    102 |
  • 103 |
  • 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 |
    Enum Summary 
    EnumDescription
    Arm.Type 
    Myo.Event 
    Myo.LockingPolicy 
    Myo.Unlock 
    Pose.Type 
    133 |
  • 134 |
135 |
136 | 137 |
138 | 139 | 140 | 141 | 142 | 150 |
151 | 178 | 179 |

Processing library MyoForProcessing by Darius Morawiec. (C) 2014

180 | 181 | 182 | -------------------------------------------------------------------------------- /reference/de/voidplus/myo/package-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | de.voidplus.myo Class Hierarchy (Javadocs: MyoForProcessing) 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 34 |
35 | 62 | 63 |
64 |

Hierarchy For Package de.voidplus.myo

65 |
66 |
67 |

Class Hierarchy

68 |
    69 |
  • java.lang.Object 70 |
      71 |
    • de.voidplus.myo.Arm
    • 72 |
    • de.voidplus.myo.Collector
    • 73 |
    • de.voidplus.myo.Device
    • 74 |
    • de.voidplus.myo.Myo
    • 75 |
    • de.voidplus.myo.Pose
    • 76 |
    77 |
  • 78 |
79 |

Enum Hierarchy

80 | 95 |
96 | 97 |
98 | 99 | 100 | 101 | 102 | 110 |
111 | 138 | 139 |

Processing library MyoForProcessing by Darius Morawiec. (C) 2014

140 | 141 | 142 | -------------------------------------------------------------------------------- /reference/deprecated-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Deprecated List (Javadocs: MyoForProcessing) 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 34 |
35 | 62 | 63 |
64 |

Deprecated API

65 |

Contents

66 |
67 | 68 |
69 | 70 | 71 | 72 | 73 | 81 |
82 | 109 | 110 |

Processing library MyoForProcessing by Darius Morawiec. (C) 2014

111 | 112 | 113 | -------------------------------------------------------------------------------- /reference/example_application.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nok/myo-processing/4fd7503f89325eb835be7bd11bf8b26ff3d64225/reference/example_application.png -------------------------------------------------------------------------------- /reference/github_cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nok/myo-processing/4fd7503f89325eb835be7bd11bf8b26ff3d64225/reference/github_cover.png -------------------------------------------------------------------------------- /reference/help-doc.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | API Help (Javadocs: MyoForProcessing) 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 34 |
35 | 62 | 63 |
64 |

How This API Document Is Organized

65 |
This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
66 |
67 |
68 |
    69 |
  • 70 |

    Package

    71 |

    Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:

    72 |
      73 |
    • Interfaces (italic)
    • 74 |
    • Classes
    • 75 |
    • Enums
    • 76 |
    • Exceptions
    • 77 |
    • Errors
    • 78 |
    • Annotation Types
    • 79 |
    80 |
  • 81 |
  • 82 |

    Class/Interface

    83 |

    Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

    84 |
      85 |
    • Class inheritance diagram
    • 86 |
    • Direct Subclasses
    • 87 |
    • All Known Subinterfaces
    • 88 |
    • All Known Implementing Classes
    • 89 |
    • Class/interface declaration
    • 90 |
    • Class/interface description
    • 91 |
    92 |
      93 |
    • Nested Class Summary
    • 94 |
    • Field Summary
    • 95 |
    • Constructor Summary
    • 96 |
    • Method Summary
    • 97 |
    98 |
      99 |
    • Field Detail
    • 100 |
    • Constructor Detail
    • 101 |
    • Method Detail
    • 102 |
    103 |

    Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.

    104 |
  • 105 |
  • 106 |

    Annotation Type

    107 |

    Each annotation type has its own separate page with the following sections:

    108 |
      109 |
    • Annotation Type declaration
    • 110 |
    • Annotation Type description
    • 111 |
    • Required Element Summary
    • 112 |
    • Optional Element Summary
    • 113 |
    • Element Detail
    • 114 |
    115 |
  • 116 |
  • 117 |

    Enum

    118 |

    Each enum has its own separate page with the following sections:

    119 |
      120 |
    • Enum declaration
    • 121 |
    • Enum description
    • 122 |
    • Enum Constant Summary
    • 123 |
    • Enum Constant Detail
    • 124 |
    125 |
  • 126 |
  • 127 |

    Tree (Class Hierarchy)

    128 |

    There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.

    129 |
      130 |
    • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
    • 131 |
    • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
    • 132 |
    133 |
  • 134 |
  • 135 |

    Deprecated API

    136 |

    The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.

    137 |
  • 138 |
  • 139 |

    Index

    140 |

    The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.

    141 |
  • 142 |
  • 143 |

    Prev/Next

    144 |

    These links take you to the next or previous class, interface, package, or related page.

    145 |
  • 146 |
  • 147 |

    Frames/No Frames

    148 |

    These links show and hide the HTML frames. All pages are available with or without frames.

    149 |
  • 150 |
  • 151 |

    All Classes

    152 |

    The All Classes link shows all classes and interfaces except non-static nested types.

    153 |
  • 154 |
  • 155 |

    Serialized Form

    156 |

    Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.

    157 |
  • 158 |
  • 159 |

    Constant Field Values

    160 |

    The Constant Field Values page lists the static final fields and their values.

    161 |
  • 162 |
163 | This help file applies to API documentation generated using the standard doclet.
164 | 165 |
166 | 167 | 168 | 169 | 170 | 178 |
179 | 206 | 207 |

Processing library MyoForProcessing by Darius Morawiec. (C) 2014

208 | 209 | 210 | -------------------------------------------------------------------------------- /reference/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Javadocs: MyoForProcessing 7 | 59 | 60 | 61 | 62 | 63 | 64 | <noscript> 65 | <div>JavaScript is disabled on your browser.</div> 66 | </noscript> 67 | <h2>Frame Alert</h2> 68 | <p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="de/voidplus/myo/package-summary.html">Non-frame version</a>.</p> 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /reference/overview-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Class Hierarchy (Javadocs: MyoForProcessing) 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 34 |
35 | 62 | 63 |
64 |

Hierarchy For All Packages

65 | Package Hierarchies: 66 | 69 |
70 |
71 |

Class Hierarchy

72 |
    73 |
  • java.lang.Object 74 |
      75 |
    • de.voidplus.myo.Arm
    • 76 |
    • de.voidplus.myo.Collector
    • 77 |
    • de.voidplus.myo.Device
    • 78 |
    • de.voidplus.myo.Myo
    • 79 |
    • de.voidplus.myo.Pose
    • 80 |
    81 |
  • 82 |
83 |

Enum Hierarchy

84 | 99 |
100 | 101 |
102 | 103 | 104 | 105 | 106 | 114 |
115 | 142 | 143 |

Processing library MyoForProcessing by Darius Morawiec. (C) 2014

144 | 145 | 146 | -------------------------------------------------------------------------------- /reference/package-list: -------------------------------------------------------------------------------- 1 | de.voidplus.myo 2 | -------------------------------------------------------------------------------- /reference/stylesheet.css: -------------------------------------------------------------------------------- 1 | /* Javadoc style sheet */ 2 | /* Define colors, fonts and other style attributes here to override the defaults */ 3 | /* processingLibs style by andreas schlegel, sojamo */ 4 | 5 | 6 | body { 7 | margin : 0; 8 | padding : 0; 9 | padding-left : 10px; 10 | padding-right : 8px; 11 | background-color : #FFFFFF; 12 | font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; 13 | font-size : 100%; 14 | font-size : 0.7em; 15 | font-weight : normal; 16 | line-height : normal; 17 | margin-bottom:30px; 18 | } 19 | 20 | 21 | 22 | 23 | /* Headings */ 24 | h1, h2, h3, h4, h5, th { 25 | font-family :Arial, Helvetica, sans-serif; 26 | font-size:1.2em; 27 | } 28 | 29 | 30 | p { 31 | font-size : 1em; 32 | width:80%; 33 | } 34 | 35 | pre, code { 36 | font-family : "Courier New", Courier, monospace; 37 | font-size : 12px; 38 | line-height : normal; 39 | } 40 | 41 | 42 | 43 | table { 44 | border:0; 45 | margin-bottom:10px; 46 | margin-top:10px; 47 | } 48 | 49 | 50 | tr, td { 51 | border-top: 0px solid; 52 | border-left: 0px solid; 53 | padding-top:8px; 54 | padding-bottom:8px; 55 | } 56 | 57 | 58 | 59 | hr { 60 | border:0; 61 | height:1px; 62 | padding:0; 63 | margin:0; 64 | margin-bottom:4px; 65 | 66 | } 67 | 68 | 69 | 70 | dd, th, td, font { 71 | font-size:1.0em; 72 | line-height:1.0em; 73 | } 74 | 75 | 76 | 77 | dt { 78 | margin-bottom:0px; 79 | } 80 | 81 | 82 | 83 | dd { 84 | margin-top:2px; 85 | margin-bottom:4px; 86 | } 87 | 88 | 89 | 90 | a { 91 | text-decoration: underline; 92 | font-weight: normal; 93 | } 94 | 95 | a:hover, 96 | a:active { 97 | text-decoration: underline; 98 | font-weight: normal; 99 | } 100 | 101 | a:visited, 102 | a:link:visited { 103 | text-decoration: underline; 104 | font-weight: normal; 105 | } 106 | 107 | 108 | img { 109 | border: 0px solid #000000; 110 | } 111 | 112 | 113 | 114 | /* Navigation bar fonts */ 115 | .NavBarCell1 { 116 | border:0; 117 | } 118 | 119 | .NavBarCell1Rev { 120 | border:0; 121 | } 122 | 123 | .NavBarFont1 { 124 | font-family: Arial, Helvetica, sans-serif; 125 | font-size:1.1em; 126 | } 127 | 128 | 129 | .NavBarFont1 b { 130 | font-weight:normal; 131 | } 132 | 133 | 134 | 135 | .NavBarFont1:after, .NavBarFont1Rev:after { 136 | font-weight:normal; 137 | content: " \\"; 138 | } 139 | 140 | 141 | .NavBarFont1Rev { 142 | font-family: Arial, Helvetica, sans-serif; 143 | font-size:1.1em; 144 | } 145 | 146 | .NavBarFont1Rev b { 147 | font-family: Arial, Helvetica, sans-serif; 148 | font-size:1.1em; 149 | font-weight:normal; 150 | } 151 | 152 | .NavBarCell2 { 153 | font-family: Arial, Helvetica, sans-serif; 154 | } 155 | 156 | .NavBarCell3 { 157 | font-family: Arial, Helvetica, sans-serif; 158 | } 159 | 160 | 161 | 162 | font.FrameItemFont { 163 | font-family: Helvetica, Arial, sans-serif; 164 | font-size:1.1em; 165 | line-height:1.1em; 166 | } 167 | 168 | font.FrameHeadingFont { 169 | font-family: Helvetica, Arial, sans-serif; 170 | line-height:32px; 171 | } 172 | 173 | /* Font used in left-hand frame lists */ 174 | .FrameTitleFont { 175 | font-family: Helvetica, Arial, sans-serif 176 | } 177 | 178 | 179 | .toggleList { 180 | padding:0; 181 | margin:0; 182 | margin-top:12px; 183 | } 184 | 185 | .toggleList dt { 186 | font-weight:bold; 187 | font-size:12px; 188 | font-family:arial,sans-serif; 189 | padding:0px; 190 | margin:10px 0px 10px 0px; 191 | } 192 | 193 | .toggleList dt span { 194 | font-family: monospace; 195 | padding:0; 196 | margin:0; 197 | } 198 | 199 | 200 | .toggleList dd { 201 | margin:0; 202 | padding:0; 203 | } 204 | 205 | html.isjs .toggleList dd { 206 | display: none; 207 | } 208 | 209 | .toggleList pre { 210 | padding: 4px 4px 4px 4px; 211 | } 212 | 213 | 214 | 215 | 216 | 217 | /* COLORS */ 218 | 219 | pre, code { 220 | color: #000000; 221 | } 222 | 223 | 224 | body { 225 | color : #333333; 226 | background-color :#FFFFFF; 227 | } 228 | 229 | 230 | h1, h2, h3, h4, h5, h6 { 231 | color:#555; 232 | } 233 | 234 | a, 235 | .toggleList dt { 236 | color: #1a7eb0; 237 | } 238 | 239 | a:hover, 240 | a:active { 241 | color: #1a7eb0; 242 | } 243 | 244 | a:visited, 245 | a:link:visited { 246 | color: #1a7eb0; 247 | } 248 | 249 | td,tr { 250 | border-color: #999999; 251 | } 252 | 253 | hr { 254 | color:#999999; 255 | background:#999999; 256 | } 257 | 258 | 259 | .TableHeadingColor { 260 | background: #dcdcdc; 261 | color: #555; 262 | } 263 | 264 | 265 | .TableSubHeadingColor { 266 | background: #EEEEFF 267 | } 268 | 269 | .TableRowColor { 270 | background: #FFFFFF 271 | } 272 | 273 | 274 | .NavBarCell1 { 275 | background-color:#dcdcdc; 276 | color:#000; 277 | } 278 | 279 | .NavBarCell1 a { 280 | color:#333; 281 | } 282 | 283 | 284 | .NavBarCell1Rev { 285 | background-color:transparent; 286 | } 287 | 288 | .NavBarFont1 { 289 | color:#333; 290 | } 291 | 292 | 293 | .NavBarFont1Rev { 294 | color:#fff; 295 | } 296 | 297 | .NavBarCell2 { 298 | background-color:#999; 299 | } 300 | 301 | .NavBarCell2 a { 302 | color:#fff; 303 | } 304 | 305 | 306 | 307 | .NavBarCell3 { 308 | background-color:#dcdcdc; 309 | } 310 | 311 | -------------------------------------------------------------------------------- /src/de/voidplus/myo/Arm.java: -------------------------------------------------------------------------------- 1 | package de.voidplus.myo; 2 | 3 | 4 | public class Arm { 5 | 6 | 7 | protected Type type; 8 | 9 | protected Arm() { 10 | type = Type.UNKNOWN; 11 | } 12 | 13 | /** 14 | * Get the type of arm. 15 | * 16 | * @return 17 | */ 18 | public de.voidplus.myo.Arm.Type getType() { 19 | return this.type; 20 | } 21 | 22 | /** 23 | * Left arm? 24 | * 25 | * @return 26 | */ 27 | public Boolean isLeft() { 28 | switch (this.type) { 29 | case LEFT: 30 | return true; 31 | case RIGHT: 32 | return false; 33 | } 34 | return false; 35 | } 36 | 37 | /** 38 | * Right arm? 39 | *

40 | * For humans with more than two arms. ;-) 41 | * 42 | * @return 43 | */ 44 | public Boolean isRight() { 45 | return !this.isLeft(); 46 | } 47 | 48 | public enum Type { 49 | LEFT(com.thalmic.myo.enums.Arm.ARM_LEFT), 50 | RIGHT(com.thalmic.myo.enums.Arm.ARM_RIGHT), 51 | UNKNOWN(com.thalmic.myo.enums.Arm.ARM_UNKNOWN); 52 | 53 | private final com.thalmic.myo.enums.Arm arm; 54 | 55 | Type(com.thalmic.myo.enums.Arm arm) { 56 | this.arm = arm; 57 | } 58 | 59 | protected com.thalmic.myo.enums.Arm asRaw() { 60 | return this.arm; 61 | } 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/de/voidplus/myo/Device.java: -------------------------------------------------------------------------------- 1 | package de.voidplus.myo; 2 | 3 | 4 | import com.thalmic.myo.FirmwareVersion; 5 | import com.thalmic.myo.enums.StreamEmgType; 6 | import de.voidplus.myo.Myo.Unlock; 7 | import processing.core.PVector; 8 | 9 | 10 | //===================================================================================== 11 | // Table of Content 12 | //===================================================================================== 13 | // 14 | // 1 Properties 15 | // 2 Constructors 16 | // 3 Commands 17 | // 4 Setters 18 | // 5 Getters 19 | 20 | 21 | /** 22 | * Class which represents a single Myo device. 23 | */ 24 | public class Device { 25 | 26 | 27 | //================================================================================= 28 | // 1 Properties 29 | //================================================================================= 30 | 31 | protected com.thalmic.myo.Myo _myo; 32 | protected int id; 33 | 34 | protected Arm arm; 35 | protected Pose pose; 36 | protected String firmware; 37 | protected PVector orientation, accelerometer, gyroscope; 38 | protected int rssi; 39 | protected boolean withEmg; 40 | protected int[] emg; 41 | protected int batteryLevel; 42 | 43 | 44 | //================================================================================= 45 | // 2 Constructors 46 | //================================================================================= 47 | 48 | public Device(com.thalmic.myo.Myo _myo, int id) { 49 | this._myo = _myo; 50 | this.id = id; 51 | this.firmware = ""; 52 | 53 | this.rssi = 0; 54 | this.requestRssi(); 55 | 56 | this.batteryLevel = 0; 57 | this.requestBatteryLevel(); 58 | 59 | this.arm = new Arm(); 60 | this.pose = new Pose(); 61 | 62 | this.orientation = new PVector(); 63 | this.accelerometer = new PVector(); 64 | this.gyroscope = new PVector(); 65 | this.withEmg = false; 66 | } 67 | 68 | //================================================================================ 69 | // 3 Commands 70 | //================================================================================ 71 | 72 | /** 73 | * Vibrate device. 74 | * 75 | * @param level 76 | * @return 77 | */ 78 | public Device vibrate(int level) { 79 | switch (level) { 80 | case 1: 81 | de.voidplus.myo.Myo.log("Vibrating short ..."); 82 | this._myo.vibrate(com.thalmic.myo.enums.VibrationType.VIBRATION_SHORT); 83 | break; 84 | case 2: 85 | de.voidplus.myo.Myo.log("Vibrating medium ..."); 86 | this._myo.vibrate(com.thalmic.myo.enums.VibrationType.VIBRATION_MEDIUM); 87 | break; 88 | case 3: 89 | de.voidplus.myo.Myo.log("Vibrating long ..."); 90 | this._myo.vibrate(com.thalmic.myo.enums.VibrationType.VIBRATION_LONG); 91 | break; 92 | } 93 | return this; 94 | } 95 | 96 | /** 97 | * Vibrate device with medium strength. 98 | * 99 | * @return 100 | */ 101 | public Device vibrate() { 102 | return this.vibrate(2); 103 | } 104 | 105 | /** 106 | * An myoOnRssi(Myo, long, int) event will likely be generated with the value of the RSSI. 107 | * 108 | * @return 109 | */ 110 | public Device requestRssi() { 111 | this._myo.requestRssi(); 112 | return this; 113 | } 114 | 115 | public Device requestBatteryLevel() { 116 | this._myo.requestBatteryLevel(); 117 | return this; 118 | } 119 | 120 | /** 121 | * Force the Myo locking immediately. 122 | * 123 | * @return 124 | */ 125 | public Device lock() { 126 | this._myo.lock(); 127 | return this; 128 | } 129 | 130 | /** 131 | * Unlock the Myo. 132 | * 133 | * @param mode 134 | * @return 135 | */ 136 | public Device unlock(Unlock mode) { 137 | switch (mode) { 138 | case HOLD: 139 | this._myo.unlock(com.thalmic.myo.enums.UnlockType.UNLOCK_HOLD); 140 | break; 141 | case TIMED: 142 | default: 143 | this._myo.unlock(com.thalmic.myo.enums.UnlockType.UNLOCK_TIMED); 144 | break; 145 | } 146 | return this; 147 | } 148 | 149 | 150 | //================================================================================ 151 | // 4 Setters 152 | //================================================================================ 153 | 154 | /** 155 | * Enable EMG mode. 156 | * 157 | * @return 158 | */ 159 | protected Device withEmg() { 160 | this.withEmg = true; 161 | this.emg = new int[8]; 162 | this._myo.setStreamEmg(StreamEmgType.STREAM_EMG_ENABLED); 163 | return this; 164 | } 165 | 166 | /** 167 | * Disable EMG mode. 168 | * 169 | * @return 170 | */ 171 | protected Device withoutEmg() { 172 | this.withEmg = false; 173 | this._myo.setStreamEmg(StreamEmgType.STREAM_EMG_DISABLED); 174 | return this; 175 | } 176 | 177 | /** 178 | * Set firmware of device. 179 | * 180 | * @param firmwareVersion 181 | * @return 182 | */ 183 | protected Device setFirmware(FirmwareVersion firmwareVersion) { 184 | if (firmwareVersion == null) { 185 | this.firmware = ""; 186 | } else { 187 | this.firmware = firmwareVersion.getFirmwareVersionMajor() + "." 188 | + firmwareVersion.getFirmwareVersionMinor() + "." 189 | + firmwareVersion.getFirmwareVersionPath(); 190 | } 191 | return this; 192 | } 193 | 194 | //================================================================================ 195 | // 5 Getters 196 | //================================================================================ 197 | 198 | //-------------------------------------------------------------------------------- 199 | // 5.1 Raw or original objects 200 | 201 | public com.thalmic.myo.Myo getMyo() { 202 | return this._myo; 203 | } 204 | 205 | //-------------------------------------------------------------------------------- 206 | // 5.2 Device 207 | 208 | /** 209 | * Get ID of device. 210 | * 211 | * @return 212 | */ 213 | public Integer getId() { 214 | return this.id; 215 | } 216 | 217 | /** 218 | * Get the firmware of device. 219 | * 220 | * @return 221 | */ 222 | public String getFirmware() { 223 | if (this.firmware == null) { 224 | return ""; 225 | } 226 | return this.firmware; 227 | } 228 | 229 | public int getRssi() { 230 | return this.rssi; 231 | } 232 | 233 | public int getBatteryLevel() { 234 | return this.batteryLevel; 235 | } 236 | 237 | //-------------------------------------------------------------------------------- 238 | // 5.3 Objects 239 | 240 | //---------------------------------------- 241 | // 5.3.1 Pose 242 | 243 | /** 244 | * Get the name of the latest pose. 245 | * 246 | * @return Name of latest pose. 247 | */ 248 | public Pose getPose() { 249 | return this.pose; 250 | } 251 | 252 | //---------------------------------------- 253 | // 5.3.2 Arm 254 | 255 | /** 256 | * Get the type of recognized arm. 257 | * 258 | * @return Type of recognized arm. 259 | */ 260 | public Arm getArm() { 261 | return this.arm; 262 | } 263 | 264 | /** 265 | * Arm recognized? 266 | * 267 | * @return 268 | */ 269 | public boolean hasArm() { 270 | return this.arm.type != Arm.Type.UNKNOWN; 271 | } 272 | 273 | /** 274 | * Left arm? 275 | * 276 | * @return 277 | */ 278 | public Boolean isArmLeft() { 279 | return this.arm.isLeft(); 280 | } 281 | 282 | /** 283 | * Right arm? 284 | * 285 | * @return 286 | */ 287 | public Boolean isArmRight() { 288 | return !this.isArmLeft(); 289 | } 290 | 291 | //-------------------------------------------------------------------------------- 292 | // 5.4 Sensors 293 | 294 | /** 295 | * Get orientation values of device. 296 | * 297 | * @return Orientation as PVector, where 'x' is the 'roll' value, 'y' is the 298 | * 'pitch' value and 'z' the 'yaw' value. 299 | */ 300 | public PVector getOrientation() { 301 | return this.orientation; 302 | } 303 | 304 | /** 305 | * Get gyroscope values of device. 306 | * 307 | * @return 308 | */ 309 | public PVector getAccelerometer() { 310 | return this.accelerometer; 311 | } 312 | 313 | /** 314 | * Get gyroscope values of device. 315 | * 316 | * @return 317 | */ 318 | public PVector getGyroscope() { 319 | return this.gyroscope; 320 | } 321 | 322 | /** 323 | * Get raw data of EMG sensors. 324 | * 325 | * @return 326 | */ 327 | public int[] getEmg() { 328 | return this.emg; 329 | } 330 | 331 | } 332 | -------------------------------------------------------------------------------- /src/de/voidplus/myo/Pose.java: -------------------------------------------------------------------------------- 1 | package de.voidplus.myo; 2 | 3 | 4 | public class Pose { 5 | 6 | 7 | protected Type type; 8 | 9 | protected Pose() { 10 | type = Type.UNKNOWN; 11 | } 12 | 13 | /** 14 | * Get the type of pose. 15 | * 16 | * @return 17 | */ 18 | public de.voidplus.myo.Pose.Type getType() { 19 | return this.type; 20 | } 21 | 22 | public enum Type { 23 | REST(com.thalmic.myo.enums.PoseType.REST), 24 | FIST(com.thalmic.myo.enums.PoseType.FIST), 25 | WAVE_IN(com.thalmic.myo.enums.PoseType.WAVE_IN), 26 | WAVE_OUT(com.thalmic.myo.enums.PoseType.WAVE_OUT), 27 | FINGERS_SPREAD(com.thalmic.myo.enums.PoseType.FINGERS_SPREAD), 28 | DOUBLE_TAP(com.thalmic.myo.enums.PoseType.DOUBLE_TAP), 29 | UNKNOWN(com.thalmic.myo.enums.PoseType.UNKNOWN); 30 | 31 | private final com.thalmic.myo.enums.PoseType pose; 32 | 33 | Type(com.thalmic.myo.enums.PoseType pose) { 34 | this.pose = pose; 35 | } 36 | 37 | protected com.thalmic.myo.enums.PoseType asRaw() { 38 | return this.pose; 39 | } 40 | } 41 | 42 | } 43 | --------------------------------------------------------------------------------