Skip to main content

lego_powered_up/
consts.rs

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 https://mozilla.org/MPL/2.0/.
4
5//! Various constants defined by the specification, but translated into Rust
6//! types
7
8use num_derive::FromPrimitive;
9use std::fmt::{self, Display};
10
11/// ```text,ignore
12/// @typedef DeviceType
13/// @property {number} UNKNOWN 0
14/// @property {number} SIMPLE_MEDIUM_LINEAR_MOTOR 1
15/// @property {number} TRAIN_MOTOR 2
16/// @property {number} LED_LIGHTS 8
17/// @property {number} VOLTAGE 20
18/// @property {number} CURRENT 21
19/// @property {number} PIEZO_TONE 22
20/// @property {number} RGB_LIGHT 23
21/// @property {number} WEDO2_TILT 34
22/// @property {number} WEDO2_DISTANCE 35
23/// @property {number} COLOR_DISTANCE_SENSOR 37
24/// @property {number} MEDIUM_LINEAR_MOTOR 38
25/// @property {number} MOVE_HUB_MEDIUM_LINEAR_MOTOR 39
26/// @property {number} BOOST_TILT 40
27/// @property {number} DUPLO_TRAIN_BASE_MOTOR 41
28/// @property {number} DUPLO_TRAIN_BASE_SPEAKER 42
29/// @property {number} DUPLO_TRAIN_BASE_COLOR 43
30/// @property {number} DUPLO_TRAIN_BASE_SPEEDOMETER 44
31/// @property {number} CONTROL_PLUS_LARGE_MOTOR 46
32/// @property {number} CONTROL_PLUS_XLARGE_MOTOR 47
33/// @property {number} POWERED_UP_REMOTE_BUTTON 55
34/// @property {number} RSSI 56
35/// @property {number} CONTROL_PLUS_ACCELEROMETER 58
36/// @property {number} CONTROL_PLUS_TILT 59
37/// ```
38
39// Added more IDs, some observed and some from
40// https://github.com/nathankellenicki/node-poweredup/blob/master/src/consts.ts
41#[repr(u8)]
42#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive, Default)]
43pub enum IoTypeId {
44    #[default]
45    Unknown = 0x00,
46    Motor = 0x01,
47    SystemTrainMotor = 0x02,
48    Button = 0x05,
49    LedLight = 0x08,
50    Voltage = 0x14,        //20
51    Current = 0x15,        //21
52    PiezoToneSound = 0x16, //22
53    HubLed = 0x17,         //23
54
55    ExternalTiltSensor = 0x22,      //34
56    MotionSensor = 0x23,            //35
57    VisionSensor = 0x25,            //37
58    ExternalMotorTacho = 0x26,      //38
59    InternalMotorTacho = 0x27,      //39
60    InternalTilt = 0x28,            //40
61    DuploTrainBaseMotor = 41,       //41
62    DuploTrainBaseSpeaker = 42,     //42
63    DuploTrainBaseColorSensor = 43, //43
64    DuploTrainBaseSpeedometer = 44, //44
65    TechnicLargeLinearMotor = 46,   //46   // Technic Control+
66    TechnicXLargeLinearMotor = 47,  //47   // Technic Control+
67    TechnicMediumAngularMotor = 48, //48   // Spike Prime
68    TechnicLargeAngularMotor = 49,  //49   // Spike Prime
69
70    TechnicHubGestSensor = 0x36,        //54
71    RemoteButtons = 0x37,               //55
72    Rssi = 0x38,                        //56
73    TechnicHubAccelerometer = 0x39,     //57
74    TechnicHubGyroSensor = 0x3a,        //58
75    TechnicHubTiltSensor = 0x3b,        //59
76    TechnicHubTemperatureSensor = 0x3c, //60
77    TechnicColorSensor = 61,            //61    // Spike Prime
78    TechnicDistanceSensor = 62,         //62    // Spike Prime
79    TechnicForceSensor = 63,            //63    // Spike Prime
80    Technic3x3ColorLightMatrix = 64,    //64    // Spike Essential
81    TechnicSmallAngularMotor = 65,      //65    // Spike Essential
82    UnknownMovehubDevice = 0x42, //66    // Unknown MoveHub device. Its 3 modes are named TRIGGER, CANVAS and VAR
83
84    MarioAccelerometer = 71,            //71
85    MarioBarcodeSensor = 73,            //73
86    MarioPantsSensor = 74,              //74
87    TechnicMediumAngularMotorGrey = 75, //75     // Mindstorms
88    TechnicLargeAngularMotorGrey = 76,  //76     // Technic Control+
89}
90
91/// ```text,ignore
92/// @typedef HubType
93/// @property {number} UNKNOWN 0
94/// @property {number} WEDO2_SMART_HUB 1
95/// @property {number} MOVE_HUB 2
96/// @property {number} POWERED_UP_HUB 3
97/// @property {number} POWERED_UP_REMOTE 4
98/// @property {number} DUPLO_TRAIN_HUB 5
99/// @property {number} CONTROL_PLUS_HUB 6
100/// @property {number} MARIO 7
101/// ```
102#[repr(u8)]
103#[derive(Copy, Clone, Debug, PartialEq, Eq)]
104pub enum HubType {
105    Unknown = 0,
106    Wedo2SmartHub = 1,
107    MoveHub = 2,
108    Hub = 3,
109    RemoteControl = 4,
110    DuploTrainBase = 5,
111    TechnicMediumHub = 6,
112    Mario = 7,
113}
114
115impl Display for HubType {
116    fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
117        use HubType::*;
118        match self {
119            Unknown | MoveHub | Hub | Mario => write!(fmt, "{:?}", self),
120            Wedo2SmartHub => write!(fmt, "Wedo 2 Smart Hub"),
121            RemoteControl => write!(fmt, "Remote Control"),
122            DuploTrainBase => write!(fmt, "Duplo Train Base"),
123            TechnicMediumHub => write!(fmt, "Technic Medium Hub"),
124        }
125    }
126}
127
128/// ```text,ignore
129/// @typedef Color
130/// @property {number} BLACK 0
131/// @property {number} PINK 1
132/// @property {number} PURPLE 2
133/// @property {number} BLUE 3
134/// @property {number} LIGHT_BLUE 4
135/// @property {number} CYAN 5
136/// @property {number} GREEN 6
137/// @property {number} YELLOW 7
138/// @property {number} ORANGE 8
139/// @property {number} RED 9
140/// @property {number} WHITE 10
141/// @property {number} NONE 255
142/// ```
143#[repr(u8)]
144#[derive(Copy, Clone, Debug, PartialEq, Eq)]
145pub enum Color {
146    Black = 0,
147    Pink = 1,
148    Purple = 2,
149    Blue = 3,
150    LightBlue = 4,
151    Cyan = 5,
152    Green = 6,
153    Yellow = 7,
154    Orange = 8,
155    Red = 9,
156    White = 10,
157    None = 255,
158}
159
160pub const LEGO_COLORS: [Color; 11] = [
161    Color::Pink,
162    Color::Purple,
163    Color::Blue,
164    Color::LightBlue,
165    Color::Cyan,
166    Color::Green,
167    Color::Yellow,
168    Color::Orange,
169    Color::Red,
170    Color::White,
171    Color::Black,
172];
173
174pub mod named_port {
175    pub const A: u8 = 0x00;
176    pub const B: u8 = 0x01;
177    pub const C: u8 = 0x02;
178    pub const D: u8 = 0x03;
179    pub const MOVE_AB: u8 = 0x10;
180}
181
182// @typedef ButtonState
183// @property {number} PRESSED 0
184// @property {number} RELEASED 1
185// @property {number} UP 2
186// @property {number} DOWN 3
187// @property {number} STOP 4
188
189/// ```text,ignore
190/// @typedef BrakingStyle
191/// @property {number} HOLD 127
192/// @property {number} BRAKE 128
193/// ```
194#[repr(u8)]
195#[derive(Copy, Clone, Debug, PartialEq, Eq)]
196pub enum BrakingStyle {
197    Float = 0,
198    Hold = 126,
199    Brake = 127,
200}
201
202/// ```text,ignore
203/// @typedef DuploTrainBaseSound
204/// @property {number} BRAKE 3
205/// @property {number} STATION_DEPARTURE 5
206/// @property {number} WATER_REFILL 7
207/// @property {number} HORN 9
208/// @property {number} STEAM 10
209/// ```
210#[repr(u8)]
211#[derive(Copy, Clone, Debug, PartialEq, Eq)]
212pub enum DuploTrainBaseSound {
213    Brake = 3,
214    StationDeparture = 5,
215    WaterRefill = 7,
216    Horn = 9,
217    Steam = 10,
218}
219
220#[repr(u8)]
221#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive)]
222pub enum BLEManufacturerData {
223    DuploTrainBaseId = 32,
224    MoveHubId = 64,
225    HubId = 65,
226    RemoteControlId = 66,
227    MarioId = 67,
228    TechnicMediumHubId = 128,
229}
230
231pub mod bleservice {
232    use lazy_static::lazy_static;
233    use uuid::Uuid;
234
235    pub const WEDO2_SMART_HUB_2: &str = "00004f0e-1212-efde-1523-785feabcd123";
236    pub const WEDO2_SMART_HUB_3: &str = "2a19";
237    pub const WEDO2_SMART_HUB_4: &str = "180f";
238    pub const WEDO2_SMART_HUB_5: &str = "180a";
239    lazy_static! {
240        pub static ref WEDO2_SMART_HUB: Uuid =
241            Uuid::parse_str("00001523-1212-efde-1523-785feabcd123").unwrap();
242        pub static ref LPF2_HUB: Uuid =
243            Uuid::parse_str("00001623-1212-efde-1623-785feabcd123").unwrap();
244    }
245}
246
247pub mod blecharacteristic {
248    use lazy_static::lazy_static;
249    use uuid::Uuid;
250
251    pub const WEDO2_BATTERY: &str = "2a19";
252    pub const WEDO2_FIRMWARE_REVISION: &str = "2a26";
253    pub const WEDO2_BUTTON: &str = "00001526-1212-efde-1523-785feabcd123"; // "1526"
254    pub const WEDO2_PORT_TYPE: &str = "00001527-1212-efde-1523-785feabcd123"; // "1527" // Handles plugging and unplugging of devices on WeDo 2.0 Smart Hub
255    pub const WEDO2_LOW_VOLTAGE_ALERT: &str =
256        "00001528-1212-efde-1523-785feabcd123"; // "1528"
257    pub const WEDO2_HIGH_CURRENT_ALERT: &str =
258        "00001529-1212-efde-1523-785feabcd123"; // "1529"
259    pub const WEDO2_LOW_SIGNAL_ALERT: &str =
260        "0000152a-1212-efde-1523-785feabcd123"; // "152a",
261    pub const WEDO2_DISCONNECT: &str = "0000152b-1212-efde-1523-785feabcd123"; // "152b"
262    pub const WEDO2_SENSOR_VALUE: &str = "00001560-1212-efde-1523-785feabcd123"; // "1560"
263    pub const WEDO2_VALUE_FORMAT: &str = "00001561-1212-efde-1523-785feabcd123"; // "1561"
264    pub const WEDO2_PORT_TYPE_WRITE: &str =
265        "00001563-1212-efde-1523-785feabcd123"; // "1563"
266    pub const WEDO2_MOTOR_VALUE_WRITE: &str =
267        "00001565-1212-efde-1523-785feabcd123"; // "1565"
268    pub const WEDO2_NAME_ID: &str = "00001524-1212-efde-1523-785feabcd123"; // "1524"
269    lazy_static! {
270        pub static ref LPF2_ALL: Uuid =
271            Uuid::parse_str("00001624-1212-efde-1623-785feabcd123").unwrap();
272    }
273}
274
275/// ```text,ignore
276/// @typedef MessageType
277/// @property {number} HUB_PROPERTIES 0x01
278/// @property {number} HUB_ACTIONS 0x02
279/// @property {number} HUB_ALERTS 0x03
280/// @property {number} HUB_ATTACHED_IO 0x04
281/// @property {number} GENERIC_ERROR_MESSAGES 0x05
282/// @property {number} HW_NETWORK_COMMANDS 0x08
283/// @property {number} FW_UPDATE_GO_INTO_BOOT_MODE 0x10
284/// @property {number} FW_UPDATE_LOCK_MEMORY 0x11
285/// @property {number} FW_UPDATE_LOCK_STATUS_REQUEST 0x12
286/// @property {number} FW_LOCK_STATUS 0x13
287/// @property {number} PORT_INFORMATION_REQUEST 0x21
288/// @property {number} PORT_MODE_INFORMATION_REQUEST 0x22
289/// @property {number} PORT_INPUT_FORMAT_SETUP_SINGLE 0x41
290/// @property {number} PORT_INPUT_FORMAT_SETUP_COMBINEDMODE 0x42
291/// @property {number} PORT_INFORMATION 0x43
292/// @property {number} PORT_MODE_INFORMATION 0x44
293/// @property {number} PORT_VALUE_SINGLE 0x45
294/// @property {number} PORT_VALUE_COMBINEDMODE 0x46
295/// @property {number} PORT_INPUT_FORMAT_SINGLE 0x47
296/// @property {number} PORT_INPUT_FORMAT_COMBINEDMODE 0x48
297/// @property {number} VIRTUAL_PORT_SETUP 0x61
298/// @property {number} PORT_OUTPUT_COMMAND 0x81
299/// @property {number} PORT_OUTPUT_COMMAND_FEEDBACK 0x82
300/// @description <https://lego.github.io/lego-ble-wireless-protocol-docs/index.html#message-types>
301/// ```
302#[repr(u8)]
303#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive, Hash)]
304pub enum MessageType {
305    HubProperties = 0x01,
306    HubActions = 0x02,
307    HubAlerts = 0x03,
308    HubAttachedIo = 0x04,
309    GenericErrorMessages = 0x05,
310    HwNetworkCommands = 0x08,
311    FwUpdateGoIntoBootMode = 0x10,
312    FwUpdateLockMemory = 0x11,
313    FwUpdateLockStatusRequest = 0x12,
314    FwLockStatus = 0x13,
315    PortInformationRequest = 0x21,
316    PortModeInformationRequest = 0x22,
317    PortInputFormatSetupSingle = 0x41,
318    PortInputFormatSetupCombined = 0x42,
319    PortInformation = 0x43,
320    PortModeInformation = 0x44,
321    PortValueSingle = 0x45,
322    PortValueCombined = 0x46,
323    PortInputFormatSingle = 0x47,
324    PortInputFormatCombined = 0x48,
325    VirtualPortSetup = 0x61,
326    PortOutputCommand = 0x81,
327    PortOutputCommandFeedback = 0x82,
328}
329
330/// ```text,ignore
331/// @typedef HubPropertyReference
332/// @param {number} ADVERTISING_NAME 0x01
333/// @param {number} BUTTON 0x02
334/// @param {number} FW_VERSION 0x03
335/// @param {number} HW_VERSION 0x04
336/// @param {number} RSSI 0x05
337/// @param {number} BATTERY_VOLTAGE 0x06
338/// @param {number} BATTERY_TYPE 0x07
339/// @param {number} MANUFACTURER_NAME 0x08
340/// @param {number} RADIO_FIRMWARE_VERSION 0x09
341/// @param {number} LEGO_WIRELESS_PROTOCOL_VERSION 0x0A
342/// @param {number} SYSTEM_TYPE_ID 0x0B
343/// @param {number} HW_NETWORK_ID 0x0C
344/// @param {number} PRIMARY_MAC_ADDRESS 0x0D
345/// @param {number} SECONDARY_MAC_ADDRESS 0x0E
346/// @param {number} HARDWARE_NETWORK_FAMILY 0x0F
347/// @description <https://lego.github.io/lego-ble-wireless-protocol-docs/index.html#hub-property-reference>
348/// ```
349#[repr(u8)]
350#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive)]
351pub enum HubPropertyRef {
352    AdvertisingName = 0x01,
353    Button = 0x02,
354    FwVersion = 0x03,
355    HwVersion = 0x04,
356    Rssi = 0x05,
357    BatteryVoltage = 0x06,
358    BatteryType = 0x07,
359    ManufacturerName = 0x08,
360    RadioFirmwareVersion = 0x09,
361    LegoWirelessProtocolVersion = 0x0A,
362    SystemTypeId = 0x0B,
363    HwNetworkId = 0x0C,
364    PrimaryMacAddress = 0x0D,
365    SecondaryMacAddress = 0x0E,
366    HardwareNetworkFamily = 0x0F,
367}
368
369/// ```text,ignore
370/// @typedef HubPropertyOperation
371/// @param {number} SET_DOWNSTREAM 0x01
372/// @param {number} ENABLE_UPDATES_DOWNSTREAM 0x02
373/// @param {number} DISABLE_UPDATES_DOWNSTREAM 0x03
374/// @param {number} RESET_DOWNSTREAM 0x04
375/// @param {number} REQUEST_UPDATE_DOWNSTREAM 0x05
376/// @param {number} UPDATE_UPSTREAM 0x06
377/// @description <https://lego.github.io/lego-ble-wireless-protocol-docs/index.html#hub-property-reference>
378/// ```
379#[repr(u8)]
380#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive)]
381pub enum HubPropertyOperation {
382    SetDownstream = 0x01,
383    EnableUpdatesDownstream = 0x02,
384    DisableUpdatesDownstream = 0x03,
385    ResetDownstream = 0x04,
386    RequestUpdateDownstream = 0x05,
387    UpdateUpstream = 0x06,
388}
389
390/// ```text,ignore
391/// @typedef HubPropertyPayload
392/// @param {number} ADVERTISING_NAME 0x01
393/// @param {number} BUTTON_STATE 0x02
394/// @param {number} FW_VERSION 0x03
395/// @param {number} HW_VERSION 0x04
396/// @param {number} RSSI 0x05
397/// @param {number} BATTERY_VOLTAGE 0x06
398/// @param {number} BATTERY_TYPE 0x07
399/// @param {number} MANUFACTURER_NAME 0x08
400/// @param {number} RADIO_FIRMWARE_VERSION 0x09
401/// @param {number} LWP_PROTOCOL_VERSION 0x0A
402/// @param {number} SYSTEM_TYPE_ID 0x0B
403/// @param {number} HW_NETWORK_ID 0x0C
404/// @param {number} PRIMARY_MAC_ADDRESS 0x0D
405/// @param {number} SECONDARY_MAC_ADDRESS 0x0E
406/// @param {number} HW_NETWORK_FAMILY 0x0F
407/// @description <https://lego.github.io/lego-ble-wireless-protocol-docs/index.html#hub-property-reference>
408/// ```
409#[repr(u8)]
410#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive)]
411pub enum HubPropertyPayload {
412    AdvertisingName = 0x01,
413    ButtonState = 0x02,
414    FwVersion = 0x03,
415    HwVersion = 0x04,
416    Rssi = 0x05,
417    BatteryVoltage = 0x06,
418    BatteryType = 0x07,
419    ManufacturerName = 0x08,
420    RadioFirmwareVersion = 0x09,
421    LwpProtocolVersion = 0x0A,
422    SystemTypeId = 0x0B,
423    HwNetworkId = 0x0C,
424    PrimaryMacAddress = 0x0D,
425    SecondaryMacAddress = 0x0E,
426    HwNetworkFamily = 0x0F,
427}
428
429/// ```text,ignore
430/// @typedef ActionType
431/// @param {number} SWITCH_OFF_HUB 0x01
432/// @param {number} DISCONNECT 0x02
433/// @param {number} VCC_PORT_CONTROL_ON 0x03
434/// @param {number} VCC_PORT_CONTROL_OFF 0x04
435/// @param {number} ACTIVATE_BUSY_INDICATION 0x05
436/// @param {number} RESET_BUSY_INDICATION 0x06
437/// @param {number} SHUTDOWN 0x2F
438/// @param {number} HUB_WILL_SWITCH_OFF 0x30
439/// @param {number} HUB_WILL_DISCONNECT 0x31
440/// @param {number} HUB_WILL_GO_INTO_BOOT_MODE 0x32
441/// @description <https://lego.github.io/lego-ble-wireless-protocol-docs/index.html#action-types>
442/// ```
443#[repr(u8)]
444#[derive(Copy, Clone, Debug, PartialEq, Eq)]
445pub enum ActionType {
446    SwitchOffHub = 0x01,
447    Disconnect = 0x02,
448    VccPortControlOn = 0x03,
449    VccPortControlOff = 0x04,
450    ActivateBusyIndication = 0x05,
451    ResetBusyIndication = 0x06,
452    Shutdown = 0x2F,
453    HubWillSwitchOff = 0x30,
454    HubWillDisconnect = 0x31,
455    HubWillGoIntoBootMode = 0x32,
456}
457
458/// ```text,ignore
459/// @typedef AlertPayload
460/// @param {number} STATUS_OK 0x00
461/// @param {number} ALERT 0xFF
462/// @description <https://lego.github.io/lego-ble-wireless-protocol-docs/index.html#alert-payload>
463/// ```
464#[repr(u8)]
465#[derive(Copy, Clone, Debug, PartialEq, Eq)]
466pub enum AlertPayload {
467    StatusOk = 0x00,
468    Alert = 0xFF,
469}
470
471/// ```text,ignore
472/// @typedef Event
473/// @param {number} DETACHED_IO 0x00
474/// @param {number} ATTACHED_IO 0x01
475/// @param {number} ATTACHED_VIRTUAL_IO 0x02
476/// @description <https://lego.github.io/lego-ble-wireless-protocol-docs/index.html#event>
477/// ```
478#[repr(u8)]
479#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive)]
480pub enum Event {
481    DetachedIo = 0x00,
482    AttachedIo = 0x01,
483    AttachedVirtualIo = 0x02,
484}
485
486/// ```text,ignore
487/// @typedef HWNetWorkCommandType
488/// @param {number} CONNECTION_REQUEST 0x02
489/// @param {number} FAMILY_REQUEST 0x03
490/// @param {number} FAMILY_SET 0x04
491/// @param {number} JOIN_DENIED 0x05
492/// @param {number} GET_FAMILY 0x06
493/// @param {number} FAMILY 0x07
494/// @param {number} GET_SUBFAMILY 0x08
495/// @param {number} SUBFAMILY 0x09
496/// @param {number} SUBFAMILY_SET 0x0A
497/// @param {number} GET_EXTENDED_FAMILY 0x0B
498/// @param {number} EXTENDED_FAMILY 0x0C
499/// @param {number} EXTENDED_FAMILY_SET 0x0D
500/// @param {number} RESET_LONG_PRESS_TIMING 0x0E
501/// @description <https://lego.github.io/lego-ble-wireless-protocol-docs/index.html#h-w-network-command-type>
502/// ```
503#[repr(u8)]
504#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive)]
505pub enum HwNetworkCommandType {
506    ConnectionRequest = 0x02,
507    FamilyRequest = 0x03,
508    FamilySet = 0x04,
509    JoinDenied = 0x05,
510    GetFamily = 0x06,
511    Family = 0x07,
512    GetSubfamily = 0x08,
513    Subfamily = 0x09,
514    SubfamilySet = 0x0A,
515    GetExtendedFamily = 0x0B,
516    ExtendedFamily = 0x0C,
517    ExtendedFamilySet = 0x0D,
518    ResetLongPressTiming = 0x0E,
519}
520
521/// ```text,ignore
522/// @typedef PortInputFormatSetupSubCommand
523/// @param {number} SET_MODEANDDATASET_COMBINATIONS 0x01
524/// @param {number} LOCK_LPF2_DEVICE_FOR_SETUP 0x02
525/// @param {number} UNLOCKANDSTARTWITHMULTIUPDATEENABLED 0x03
526/// @param {number} UNLOCKANDSTARTWITHMULTIUPDATEDISABLED 0x04
527/// @param {number} NOT_USED 0x05
528/// @param {number} RESET_SENSOR 0x06
529/// @description <https://lego.github.io/lego-ble-wireless-protocol-docs/index.html#port-input-format-setup-sub-commands>
530/// ```
531#[repr(u8)]
532#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive)]
533pub enum PortInputFormatSetupSubCommand {
534    SetModeanddatasetCombinations = 0x01,
535    LockLpf2DeviceForSetup = 0x02,
536    UnlockAndStartMultiEnabled = 0x03,
537    UnlockAndStartMultiDisabled = 0x04,
538    NotUsed = 0x05,
539    ResetSensor = 0x06,
540}
541
542/// ```text,ignore
543/// @typedef MarioPantsType
544/// @param {number} NONE 0x00
545/// @param {number} PROPELLER 0x06
546/// @param {number} CAT 0x11
547/// @param {number} FIRE 0x12
548/// @param {number} NORMAL 0x21
549/// @param {number} BUILDER 0x22
550/// ```
551#[repr(u8)]
552#[derive(Copy, Clone, Debug, PartialEq, Eq)]
553pub enum MarioPantsType {
554    None = 0x00,
555    Propeller = 0x06,
556    Cat = 0x11,
557    Fire = 0x12,
558    Normal = 0x21,
559    Builder = 0x22,
560}
561
562/// ```text,ignore
563/// @typedef MarioColor
564/// @param {number} WHITE 0x1300
565/// @param {number} RED 0x1500
566/// @param {number} BLUE 0x1700
567/// @param {number} YELLOW 0x1800
568/// @param {number} BLACK 0x1a00
569/// @param {number} GREEN 0x2500
570/// @param {number} BROWN 0x6a00
571/// @param {number} CYAN 0x4201
572/// ```
573#[repr(u16)]
574#[derive(Copy, Clone, Debug, PartialEq, Eq)]
575pub enum MarioColor {
576    White = 0x1300,
577    Red = 0x1500,
578    Blue = 0x1700,
579    Yellow = 0x1800,
580    Black = 0x1a00,
581    Green = 0x2500,
582    Brown = 0x6a00,
583    Cyan = 0x4201,
584}
585
586pub enum PortOutputSubCommandValue {
587    StartPower2 = 0x02,
588    SetAccTime = 0x05,
589    SetDecTime = 0x06,
590    StartSpeed = 0x07,
591    StartSpeed2 = 0x08,
592    StartSpeedForTime = 0x09,
593    StartSpeedForTime2 = 0x0a,
594    StartSpeedForDegrees = 0x0b,
595    StartSpeedForDegrees2 = 0x0c,
596    GotoAbsolutePosition = 0x0d,
597    GotoAbsolutePosition2 = 0x0e,
598    PresetEncoder2 = 0x14,
599}
600
601pub enum InputSetupCombinedSubcommandValue {
602    SetModeanddatasetCombinations = 0x01,
603    LockLpf2DeviceForSetup = 0x02,
604    UnlockAndStartMultiEnabled = 0x03,
605    UnlockAndStartMultiDisabled = 0x04,
606    NotUsed = 0x05,
607    ResetSensor = 0x06,
608}
609
610pub enum MotorSensorMode {
611    // Valid combinations: 1+2+3  (Speed, Pos, Apos)
612    Power = 0x0,
613    Speed = 0x1,
614    Pos = 0x2,
615    APos = 0x3,
616    // Load = 0x4,
617    Calib = 0x4,
618    Stats = 0x5,
619}
620
621pub enum VisionSensorMode {
622    // Valid combinations: 0+1+2+3+6	Color, Prox, Count, Reflt, Rgb I
623    Color = 0x0,
624    Prox = 0x1,
625    Count = 0x2,
626    Reflt = 0x3,
627    Ambi = 0x4,
628    ColO = 0x5,
629    RgbI = 0x6,
630    IrTx = 0x7,
631    Spec1 = 0x8,
632    Debug = 0x9,
633    Calib = 0xa,
634}
635
636// pub struct PortCapabilities(u8);
637// impl PortCapabilities {
638//     pub const LOGICAL_SYNCHRONIZABLE: u8 = 0b1000;
639//     pub const LOGICAL_COMBINABLE: u8 = 0b0100;
640//     pub const INPUT: u8 = 0b0010;
641//     pub const OUTPUT: u8 = 0b0001;
642// }