MyoLinux
myoapi.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
5 /* Copyright (c) 2015, Thalmic Labs Inc.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  * * Neither the copyright holder(s) nor the
16  * names of its contributors may be used to endorse or promote products
17  * derived from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
23  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 
30 #pragma once
31 #ifndef MYOAPI_H
32 #define MYOAPI_H
33 #define PACKED __attribute__ ((__packed__))
34 
35 #include "myolinux.h"
36 
37 #include <array>
38 #include <cinttypes>
39 #include <vector>
40 
41 namespace MYOLINUX_NAMESPACE {
42 namespace myo {
43 
47 const std::vector<std::uint8_t> MyoUuid = {
48  0x42, 0x48, 0x12, 0x4a,
49  0x7f, 0x2c, 0x48, 0x47,
50  0xb9, 0xde, 0x04, 0xa9,
51  0x01, 0x00, 0x06, 0xd5
52 };
53 
54 constexpr float OrientationScale = 16384.0f;
55 constexpr float AccelerometerScale = 2048.0f;
56 constexpr float GyroscopeScale = 16.0f;
57 
59 enum class EmgMode {
60  None = 0x00,
61  SendEmg = 0x02,
62  SendEmgRaw = 0x03,
63 };
64 
66 enum class ImuMode {
67  None = 0x00,
68  SendData = 0x01,
69  SendEvents = 0x02,
70  SendAll = 0x03,
71  SendRaw = 0x04,
72 };
73 
75 enum class ClassifierMode {
76  Disabled = 0x00,
77  Enabled = 0x01,
78 };
79 
81 enum class SleepMode {
82  Normal = 0,
83  NeverSleep = 1,
84 };
85 
87 enum class Vibration {
88  None = 0x00,
89  Short = 0x01,
90  Medium = 0x02,
91  Long = 0x03,
92 };
93 
96 struct PACKED FwInfo {
97  uint8_t serial_number[6];
98  uint16_t unlock_pose;
103  uint8_t sku;
104  uint8_t reserved[7];
105 };
106 
111 struct PACKED FwVersion {
112  uint16_t major;
113  uint16_t minor;
114  uint16_t patch;
115  uint16_t hardware_rev;
116 };
117 
119 using EmgSample = std::array<std::int8_t, 8>;
120 
123 using OrientationSample = std::array<std::int16_t, 4>;
124 
128 using AccelerometerSample = std::array<std::int16_t, 3>;
129 
133 using GyroscopeSample = std::array<std::int16_t, 3>;
134 
135 }
136 }
137 
138 #undef PACKED
139 #endif // MYOAPI_H
std::array< std::int16_t, 3 > GyroscopeSample
GyroscopeSample Gyroscope data.
Definition: myoapi.h:133
uint8_t active_classifier_type
Whether Myo is currently using a built-in or a custom classifier.
Definition: myoapi.h:99
std::array< std::int16_t, 3 > AccelerometerSample
AccelerometerSample Accelerometer data.
Definition: myoapi.h:128
Do not send EMG data.
Send raw (unfiltered) EMG data.
uint8_t has_custom_classifier
Whether Myo contains a valid custom classifier. 1 if it does, otherwise 0.
Definition: myoapi.h:101
uint8_t stream_indicating
Set if the Myo uses BLE indicates to stream data, for reliable capture.
Definition: myoapi.h:102
Send motion events detected by the IMU (e.g. taps).
constexpr float GyroscopeScale
Gyroscope data multiplier, see GyroscopeSample.
Definition: myoapi.h:56
Vibrate for a long amount of time.
std::array< std::int16_t, 4 > OrientationSample
OrientationSample Orientation data, represented as a unit quaternion.
Definition: myoapi.h:123
Disable and reset the internal state of the onboard classifier.
constexpr float AccelerometerScale
Accelerometer data multiplier, see AccelerometerSample.
Definition: myoapi.h:55
Version information for the Myo firmware.
Definition: myoapi.h:111
uint8_t active_classifier_index
Index of the classifier that is currently active.
Definition: myoapi.h:100
uint16_t hardware_rev
Myo hardware revision. See myohw_hardware_rev_t.
Definition: myoapi.h:115
constexpr float OrientationScale
Orientation data multiplier, see OrientationSample.
Definition: myoapi.h:54
ImuMode
IMU modes.
Definition: myoapi.h:66
Send classifier events (poses and arm events).
Vibration
Kinds of vibrations.
Definition: myoapi.h:87
const std::vector< std::uint8_t > MyoUuid
UUID of the info service.
Definition: myoapi.h:47
Vibrate for a short amount of time.
Send both IMU data streams and motion events.
Send filtered EMG data.
uint8_t sku
SKU value of the device.
Definition: myoapi.h:103
Send IMU data streams (accelerometer, gyroscope, and orientation).
Various parameters that may affect the behaviour of this Myo armband.
Definition: myoapi.h:96
SleepMode
Sleep modes.
Definition: myoapi.h:81
uint16_t unlock_pose
Pose that should be interpreted as the unlock pose.
Definition: myoapi.h:98
Vibrate for a medium amount of time.
EmgMode
EMG modes.
Definition: myoapi.h:59
Send raw IMU data streams.
std::array< std::int8_t, 8 > EmgSample
EmgSample.
Definition: myoapi.h:119
Normal sleep mode; Myo will sleep after a period of inactivity.
ClassifierMode
Classifier modes.
Definition: myoapi.h:75