lego-powered-up 0.1.0

Control Lego PoweredUp hubs and devices
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

//! Various constants defined by the specification, but translated into Rust
//! types

use num_derive::FromPrimitive;
use num_traits::FromPrimitive;
use std::fmt::{self, Display};

/// ```ignore
/// @typedef HubType
/// @property {number} UNKNOWN 0
/// @property {number} WEDO2_SMART_HUB 1
/// @property {number} MOVE_HUB 2
/// @property {number} POWERED_UP_HUB 3
/// @property {number} POWERED_UP_REMOTE 4
/// @property {number} DUPLO_TRAIN_HUB 5
/// @property {number} CONTROL_PLUS_HUB 6
/// @property {number} MARIO 7
/// ```
#[repr(u8)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum HubType {
    Unknown = 0,
    Wedo2SmartHub = 1,
    MoveHub = 2,
    Hub = 3,
    RemoteControl = 4,
    DuploTrainBase = 5,
    TechnicMediumHub = 6,
    Mario = 7,
}

impl Display for HubType {
    fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
        use HubType::*;
        match self {
            Unknown | MoveHub | Hub | Mario => write!(fmt, "{:?}", self),
            Wedo2SmartHub => write!(fmt, "Wedo 2 Smart Hub"),
            RemoteControl => write!(fmt, "Remote Control"),
            DuploTrainBase => write!(fmt, "Duplo Train Base"),
            TechnicMediumHub => write!(fmt, "Technic Medium Hub"),
        }
    }
}

/// ```ignore
/// @typedef DeviceType
/// @property {number} UNKNOWN 0
/// @property {number} SIMPLE_MEDIUM_LINEAR_MOTOR 1
/// @property {number} TRAIN_MOTOR 2
/// @property {number} LED_LIGHTS 8
/// @property {number} VOLTAGE 20
/// @property {number} CURRENT 21
/// @property {number} PIEZO_TONE 22
/// @property {number} RGB_LIGHT 23
/// @property {number} WEDO2_TILT 34
/// @property {number} WEDO2_DISTANCE 35
/// @property {number} COLOR_DISTANCE_SENSOR 37
/// @property {number} MEDIUM_LINEAR_MOTOR 38
/// @property {number} MOVE_HUB_MEDIUM_LINEAR_MOTOR 39
/// @property {number} BOOST_TILT 40
/// @property {number} DUPLO_TRAIN_BASE_MOTOR 41
/// @property {number} DUPLO_TRAIN_BASE_SPEAKER 42
/// @property {number} DUPLO_TRAIN_BASE_COLOR 43
/// @property {number} DUPLO_TRAIN_BASE_SPEEDOMETER 44
/// @property {number} CONTROL_PLUS_LARGE_MOTOR 46
/// @property {number} CONTROL_PLUS_XLARGE_MOTOR 47
/// @property {number} POWERED_UP_REMOTE_BUTTON 55
/// @property {number} RSSI 56
/// @property {number} CONTROL_PLUS_ACCELEROMETER 58
/// @property {number} CONTROL_PLUS_TILT 59
/// ```
#[repr(u8)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum DeviceType {
    Unknown = 0,
    SimpleMediumLinearMotor = 1,
    TrainMotor = 2,
    Light = 8,
    VoltageSensor = 20,
    CurrentSensor = 21,
    PiezoBuzzer = 22,
    HubLed = 23,
    TiltSensor = 34,
    MotionSensor = 35,
    ColorDistanceSensor = 37,
    MediumLinearMotor = 38,
    MoveHubMediumLinearMotor = 39,
    MoveHubTiltSensor = 40,
    DuploTrainBaseMotor = 41,
    DuploTrainBaseSpeaker = 42,
    DuploTrainBaseColorSensor = 43,
    DuploTrainBaseSpeedometer = 44,
    TechnicLargeLinearMotor = 46, // Technic Control+
    TechnicXlargeLinearMotor = 47, // Technic Control+
    TechnicMediumAngularMotor = 48, // Spike Prime
    TechnicLargeAngularMotor = 49, // Spike Prime
    TechnicMediumHubGestSensor = 54,
    RemoteControlButton = 55,
    RemoteControlRssi = 56,
    TechnicMediumHubAccelerometer = 57,
    TechnicMediumHubGyroSensor = 58,
    TechnicMediumHubTiltSensor = 59,
    TechnicMediumHubTemperatureSensor = 60,
    TechnicColorSensor = 61,    // Spike Prime
    TechnicDistanceSensor = 62, // Spike Prime
    TechnicForceSensor = 63,    // Spike Prime
    MarioAccelerometer = 71,
    MarioBarcodeSensor = 73,
    MarioPantsSensor = 74,
    TechnicMediumAngularMotorGrey = 75, // Mindstorms
    TechnicLargeAngularMotorGrey = 76,  // Technic Control+
}

/// ```ignore
/// @typedef Color
/// @property {number} BLACK 0
/// @property {number} PINK 1
/// @property {number} PURPLE 2
/// @property {number} BLUE 3
/// @property {number} LIGHT_BLUE 4
/// @property {number} CYAN 5
/// @property {number} GREEN 6
/// @property {number} YELLOW 7
/// @property {number} ORANGE 8
/// @property {number} RED 9
/// @property {number} WHITE 10
/// @property {number} NONE 255
/// ```
#[repr(u8)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum Color {
    Black = 0,
    Pink = 1,
    Purple = 2,
    Blue = 3,
    LightBlue = 4,
    Cyan = 5,
    Green = 6,
    Yellow = 7,
    Orange = 8,
    Red = 9,
    White = 10,
    None = 255,
}

// @typedef ButtonState
// @property {number} PRESSED 0
// @property {number} RELEASED 1
// @property {number} UP 2
// @property {number} DOWN 3
// @property {number} STOP 4

/// ```ignore
/// @typedef BrakingStyle
/// @property {number} HOLD 127
/// @property {number} BRAKE 128
/// ```
#[repr(u8)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum BrakingStyle {
    Float = 0,
    Hold = 126,
    Brake = 127,
}

/// ```ignore
/// @typedef DuploTrainBaseSound
/// @property {number} BRAKE 3
/// @property {number} STATION_DEPARTURE 5
/// @property {number} WATER_REFILL 7
/// @property {number} HORN 9
/// @property {number} STEAM 10
/// ```
#[repr(u8)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum DuploTrainBaseSound {
    Brake = 3,
    StationDeparture = 5,
    WaterRefill = 7,
    Horn = 9,
    Steam = 10,
}

#[repr(u8)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive)]
pub enum BLEManufacturerData {
    DuploTrainBaseId = 32,
    MoveHubId = 64,
    HubId = 65,
    RemoteControlId = 66,
    MarioId = 67,
    TechnicMediumHubId = 128,
}

pub mod bleservice {
    use lazy_static::lazy_static;
    use uuid::Uuid;

    pub const WEDO2_SMART_HUB_2: &str = "00004f0e-1212-efde-1523-785feabcd123";
    pub const WEDO2_SMART_HUB_3: &str = "2a19";
    pub const WEDO2_SMART_HUB_4: &str = "180f";
    pub const WEDO2_SMART_HUB_5: &str = "180a";
    lazy_static! {
        pub static ref WEDO2_SMART_HUB: Uuid =
            Uuid::parse_str("00001523-1212-efde-1523-785feabcd123").unwrap();
        pub static ref LPF2_HUB: Uuid =
            Uuid::parse_str("00001623-1212-efde-1623-785feabcd123").unwrap();
    }
}

pub mod blecharacteristic {
    use lazy_static::lazy_static;
    use uuid::Uuid;

    pub const WEDO2_BATTERY: &str = "2a19";
    pub const WEDO2_FIRMWARE_REVISION: &str = "2a26";
    pub const WEDO2_BUTTON: &str = "00001526-1212-efde-1523-785feabcd123"; // "1526"
    pub const WEDO2_PORT_TYPE: &str = "00001527-1212-efde-1523-785feabcd123"; // "1527" // Handles plugging and unplugging of devices on WeDo 2.0 Smart Hub
    pub const WEDO2_LOW_VOLTAGE_ALERT: &str =
        "00001528-1212-efde-1523-785feabcd123"; // "1528"
    pub const WEDO2_HIGH_CURRENT_ALERT: &str =
        "00001529-1212-efde-1523-785feabcd123"; // "1529"
    pub const WEDO2_LOW_SIGNAL_ALERT: &str =
        "0000152a-1212-efde-1523-785feabcd123"; // "152a",
    pub const WEDO2_DISCONNECT: &str = "0000152b-1212-efde-1523-785feabcd123"; // "152b"
    pub const WEDO2_SENSOR_VALUE: &str = "00001560-1212-efde-1523-785feabcd123"; // "1560"
    pub const WEDO2_VALUE_FORMAT: &str = "00001561-1212-efde-1523-785feabcd123"; // "1561"
    pub const WEDO2_PORT_TYPE_WRITE: &str =
        "00001563-1212-efde-1523-785feabcd123"; // "1563"
    pub const WEDO2_MOTOR_VALUE_WRITE: &str =
        "00001565-1212-efde-1523-785feabcd123"; // "1565"
    pub const WEDO2_NAME_ID: &str = "00001524-1212-efde-1523-785feabcd123"; // "1524"
    lazy_static! {
        pub static ref LPF2_ALL: Uuid =
            Uuid::parse_str("00001624-1212-efde-1623-785feabcd123").unwrap();
    }
}

/// ```ignore
/// @typedef MessageType
/// @property {number} HUB_PROPERTIES 0x01
/// @property {number} HUB_ACTIONS 0x02
/// @property {number} HUB_ALERTS 0x03
/// @property {number} HUB_ATTACHED_IO 0x04
/// @property {number} GENERIC_ERROR_MESSAGES 0x05
/// @property {number} HW_NETWORK_COMMANDS 0x08
/// @property {number} FW_UPDATE_GO_INTO_BOOT_MODE 0x10
/// @property {number} FW_UPDATE_LOCK_MEMORY 0x11
/// @property {number} FW_UPDATE_LOCK_STATUS_REQUEST 0x12
/// @property {number} FW_LOCK_STATUS 0x13
/// @property {number} PORT_INFORMATION_REQUEST 0x21
/// @property {number} PORT_MODE_INFORMATION_REQUEST 0x22
/// @property {number} PORT_INPUT_FORMAT_SETUP_SINGLE 0x41
/// @property {number} PORT_INPUT_FORMAT_SETUP_COMBINEDMODE 0x42
/// @property {number} PORT_INFORMATION 0x43
/// @property {number} PORT_MODE_INFORMATION 0x44
/// @property {number} PORT_VALUE_SINGLE 0x45
/// @property {number} PORT_VALUE_COMBINEDMODE 0x46
/// @property {number} PORT_INPUT_FORMAT_SINGLE 0x47
/// @property {number} PORT_INPUT_FORMAT_COMBINEDMODE 0x48
/// @property {number} VIRTUAL_PORT_SETUP 0x61
/// @property {number} PORT_OUTPUT_COMMAND 0x81
/// @property {number} PORT_OUTPUT_COMMAND_FEEDBACK 0x82
/// @description <https://lego.github.io/lego-ble-wireless-protocol-docs/index.html#message-types>
/// ```
#[repr(u8)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive)]
pub enum MessageType {
    HubProperties = 0x01,
    HubActions = 0x02,
    HubAlerts = 0x03,
    HubAttachedIo = 0x04,
    GenericErrorMessages = 0x05,
    HwNetworkCommands = 0x08,
    FwUpdateGoIntoBootMode = 0x10,
    FwUpdateLockMemory = 0x11,
    FwUpdateLockStatusRequest = 0x12,
    FwLockStatus = 0x13,
    PortInformationRequest = 0x21,
    PortModeInformationRequest = 0x22,
    PortInputFormatSetupSingle = 0x41,
    PortInputFormatSetupCombinedmode = 0x42,
    PortInformation = 0x43,
    PortModeInformation = 0x44,
    PortValueSingle = 0x45,
    PortValueCombinedmode = 0x46,
    PortInputFormatSingle = 0x47,
    PortInputFormatCombinedmode = 0x48,
    VirtualPortSetup = 0x61,
    PortOutputCommand = 0x81,
    PortOutputCommandFeedback = 0x82,
}

/// ```ignore
/// @typedef HubPropertyReference
/// @param {number} ADVERTISING_NAME 0x01
/// @param {number} BUTTON 0x02
/// @param {number} FW_VERSION 0x03
/// @param {number} HW_VERSION 0x04
/// @param {number} RSSI 0x05
/// @param {number} BATTERY_VOLTAGE 0x06
/// @param {number} BATTERY_TYPE 0x07
/// @param {number} MANUFACTURER_NAME 0x08
/// @param {number} RADIO_FIRMWARE_VERSION 0x09
/// @param {number} LEGO_WIRELESS_PROTOCOL_VERSION 0x0A
/// @param {number} SYSTEM_TYPE_ID 0x0B
/// @param {number} HW_NETWORK_ID 0x0C
/// @param {number} PRIMARY_MAC_ADDRESS 0x0D
/// @param {number} SECONDARY_MAC_ADDRESS 0x0E
/// @param {number} HARDWARE_NETWORK_FAMILY 0x0F
/// @description <https://lego.github.io/lego-ble-wireless-protocol-docs/index.html#hub-property-reference>
/// ```
#[repr(u8)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive)]
pub enum HubPropertyReference {
    AdvertisingName = 0x01,
    Button = 0x02,
    FwVersion = 0x03,
    HwVersion = 0x04,
    Rssi = 0x05,
    BatteryVoltage = 0x06,
    BatteryType = 0x07,
    ManufacturerName = 0x08,
    RadioFirmwareVersion = 0x09,
    LegoWirelessProtocolVersion = 0x0A,
    SystemTypeId = 0x0B,
    HwNetworkId = 0x0C,
    PrimaryMacAddress = 0x0D,
    SecondaryMacAddress = 0x0E,
    HardwareNetworkFamily = 0x0F,
}

/// ```ignore
/// @typedef HubPropertyOperation
/// @param {number} SET_DOWNSTREAM 0x01
/// @param {number} ENABLE_UPDATES_DOWNSTREAM 0x02
/// @param {number} DISABLE_UPDATES_DOWNSTREAM 0x03
/// @param {number} RESET_DOWNSTREAM 0x04
/// @param {number} REQUEST_UPDATE_DOWNSTREAM 0x05
/// @param {number} UPDATE_UPSTREAM 0x06
/// @description <https://lego.github.io/lego-ble-wireless-protocol-docs/index.html#hub-property-reference>
/// ```
#[repr(u8)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive)]
pub enum HubPropertyOperation {
    SetDownstream = 0x01,
    EnableUpdatesDownstream = 0x02,
    DisableUpdatesDownstream = 0x03,
    ResetDownstream = 0x04,
    RequestUpdateDownstream = 0x05,
    UpdateUpstream = 0x06,
}

/// ```ignore
/// @typedef HubPropertyPayload
/// @param {number} ADVERTISING_NAME 0x01
/// @param {number} BUTTON_STATE 0x02
/// @param {number} FW_VERSION 0x03
/// @param {number} HW_VERSION 0x04
/// @param {number} RSSI 0x05
/// @param {number} BATTERY_VOLTAGE 0x06
/// @param {number} BATTERY_TYPE 0x07
/// @param {number} MANUFACTURER_NAME 0x08
/// @param {number} RADIO_FIRMWARE_VERSION 0x09
/// @param {number} LWP_PROTOCOL_VERSION 0x0A
/// @param {number} SYSTEM_TYPE_ID 0x0B
/// @param {number} HW_NETWORK_ID 0x0C
/// @param {number} PRIMARY_MAC_ADDRESS 0x0D
/// @param {number} SECONDARY_MAC_ADDRESS 0x0E
/// @param {number} HW_NETWORK_FAMILY 0x0F
/// @description <https://lego.github.io/lego-ble-wireless-protocol-docs/index.html#hub-property-reference>
/// ```
#[repr(u8)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive)]
pub enum HubPropertyPayload {
    AdvertisingName = 0x01,
    ButtonState = 0x02,
    FwVersion = 0x03,
    HwVersion = 0x04,
    Rssi = 0x05,
    BatteryVoltage = 0x06,
    BatteryType = 0x07,
    ManufacturerName = 0x08,
    RadioFirmwareVersion = 0x09,
    LwpProtocolVersion = 0x0A,
    SystemTypeId = 0x0B,
    HwNetworkId = 0x0C,
    PrimaryMacAddress = 0x0D,
    SecondaryMacAddress = 0x0E,
    HwNetworkFamily = 0x0F,
}

/// ```ignore
/// @typedef ActionType
/// @param {number} SWITCH_OFF_HUB 0x01
/// @param {number} DISCONNECT 0x02
/// @param {number} VCC_PORT_CONTROL_ON 0x03
/// @param {number} VCC_PORT_CONTROL_OFF 0x04
/// @param {number} ACTIVATE_BUSY_INDICATION 0x05
/// @param {number} RESET_BUSY_INDICATION 0x06
/// @param {number} SHUTDOWN 0x2F
/// @param {number} HUB_WILL_SWITCH_OFF 0x30
/// @param {number} HUB_WILL_DISCONNECT 0x31
/// @param {number} HUB_WILL_GO_INTO_BOOT_MODE 0x32
/// @description <https://lego.github.io/lego-ble-wireless-protocol-docs/index.html#action-types>
/// ```
#[repr(u8)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum ActionType {
    SwitchOffHub = 0x01,
    Disconnect = 0x02,
    VccPortControlOn = 0x03,
    VccPortControlOff = 0x04,
    ActivateBusyIndication = 0x05,
    ResetBusyIndication = 0x06,
    Shutdown = 0x2F,
    HubWillSwitchOff = 0x30,
    HubWillDisconnect = 0x31,
    HubWillGoIntoBootMode = 0x32,
}

/// ```ignore
/// @typedef AlertPayload
/// @param {number} STATUS_OK 0x00
/// @param {number} ALERT 0xFF
/// @description <https://lego.github.io/lego-ble-wireless-protocol-docs/index.html#alert-payload>
/// ```
#[repr(u8)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum AlertPayload {
    StatusOk = 0x00,
    Alert = 0xFF,
}

/// ```ignore
/// @typedef Event
/// @param {number} DETACHED_IO 0x00
/// @param {number} ATTACHED_IO 0x01
/// @param {number} ATTACHED_VIRTUAL_IO 0x02
/// @description <https://lego.github.io/lego-ble-wireless-protocol-docs/index.html#event>
/// ```
#[repr(u8)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive)]
pub enum Event {
    DetachedIo = 0x00,
    AttachedIo = 0x01,
    AttachedVirtualIo = 0x02,
}

/// ```ignore
/// @typedef HWNetWorkCommandType
/// @param {number} CONNECTION_REQUEST 0x02
/// @param {number} FAMILY_REQUEST 0x03
/// @param {number} FAMILY_SET 0x04
/// @param {number} JOIN_DENIED 0x05
/// @param {number} GET_FAMILY 0x06
/// @param {number} FAMILY 0x07
/// @param {number} GET_SUBFAMILY 0x08
/// @param {number} SUBFAMILY 0x09
/// @param {number} SUBFAMILY_SET 0x0A
/// @param {number} GET_EXTENDED_FAMILY 0x0B
/// @param {number} EXTENDED_FAMILY 0x0C
/// @param {number} EXTENDED_FAMILY_SET 0x0D
/// @param {number} RESET_LONG_PRESS_TIMING 0x0E
/// @description <https://lego.github.io/lego-ble-wireless-protocol-docs/index.html#h-w-network-command-type>
/// ```
#[repr(u8)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive)]
pub enum HwNetworkCommandType {
    ConnectionRequest = 0x02,
    FamilyRequest = 0x03,
    FamilySet = 0x04,
    JoinDenied = 0x05,
    GetFamily = 0x06,
    Family = 0x07,
    GetSubfamily = 0x08,
    Subfamily = 0x09,
    SubfamilySet = 0x0A,
    GetExtendedFamily = 0x0B,
    ExtendedFamily = 0x0C,
    ExtendedFamilySet = 0x0D,
    ResetLongPressTiming = 0x0E,
}

/// ```ignore
/// @typedef PortInputFormatSetupSubCommand
/// @param {number} SET_MODEANDDATASET_COMBINATIONS 0x01
/// @param {number} LOCK_LPF2_DEVICE_FOR_SETUP 0x02
/// @param {number} UNLOCKANDSTARTWITHMULTIUPDATEENABLED 0x03
/// @param {number} UNLOCKANDSTARTWITHMULTIUPDATEDISABLED 0x04
/// @param {number} NOT_USED 0x05
/// @param {number} RESET_SENSOR 0x06
/// @description <https://lego.github.io/lego-ble-wireless-protocol-docs/index.html#port-input-format-setup-sub-commands>
/// ```
#[repr(u8)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive)]
pub enum PortInputFormatSetupSubCommand {
    SetModeanddatasetCombinations = 0x01,
    LockLpf2DeviceForSetup = 0x02,
    UnlockAndStartMultiEnabled = 0x03,
    UnlockAndStartMultiDisabled = 0x04,
    NotUsed = 0x05,
    ResetSensor = 0x06,
}

/// ```ignore
/// @typedef MarioPantsType
/// @param {number} NONE 0x00
/// @param {number} PROPELLER 0x06
/// @param {number} CAT 0x11
/// @param {number} FIRE 0x12
/// @param {number} NORMAL 0x21
/// @param {number} BUILDER 0x22
/// ```
#[repr(u8)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum MarioPantsType {
    None = 0x00,
    Propeller = 0x06,
    Cat = 0x11,
    Fire = 0x12,
    Normal = 0x21,
    Builder = 0x22,
}

/// ```ignore
/// @typedef MarioColor
/// @param {number} WHITE 0x1300
/// @param {number} RED 0x1500
/// @param {number} BLUE 0x1700
/// @param {number} YELLOW 0x1800
/// @param {number} BLACK 0x1a00
/// @param {number} GREEN 0x2500
/// @param {number} BROWN 0x6a00
/// @param {number} CYAN 0x4201
/// ```
#[repr(u16)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum MarioColor {
    White = 0x1300,
    Red = 0x1500,
    Blue = 0x1700,
    Yellow = 0x1800,
    Black = 0x1a00,
    Green = 0x2500,
    Brown = 0x6a00,
    Cyan = 0x4201,
}