omnitiles/protocol/
messages.rs

1// SPDX-License-Identifier: MIT
2// © 2025–2026 Christopher Liu
3
4//! Command message protocol used to communicate with OmniTiles.
5
6/// Sync byte for the protocol.
7pub const START_BYTE: u8 = 0xA5;
8
9// Message IDs
10pub const MSG_M1_EXTEND: u8 = 0x30;
11pub const MSG_M1_RETRACT: u8 = 0x31;
12pub const MSG_M1_BRAKE: u8 = 0x32;
13pub const MSG_M1_SET_POSITION: u8 = 0x33;
14
15pub const MSG_M2_EXTEND: u8 = 0x40;
16pub const MSG_M2_RETRACT: u8 = 0x41;
17pub const MSG_M2_BRAKE: u8 = 0x42;
18pub const MSG_M2_SET_POSITION: u8 = 0x43;
19
20pub const MSG_PING: u8 = 0x50;
21
22pub const MSG_TELEMETRY: u8 = 0x60;
23
24/// Direct motor commands.
25#[derive(Debug, Clone, Copy, PartialEq)]
26pub enum Command {
27    Ping,
28    M1Extend(u8),
29    M1Retract(u8),
30    M1Brake,
31    M1SetPosition(u8),
32    M2Extend(u8),
33    M2Retract(u8),
34    M2Brake,
35    M2SetPosition(u8),
36}