Skip to main content

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
24pub const MSG_BASE_VELOCITY: u8 = 0x70;
25pub const MSG_BASE_BRAKE: u8 = 0x71;
26
27/// Direct motor commands.
28#[derive(Debug, Clone, Copy, PartialEq)]
29pub enum Command {
30    Ping,
31    M1Extend(u8),
32    M1Retract(u8),
33    M1Brake,
34    M1SetPosition(u8),
35    M2Extend(u8),
36    M2Retract(u8),
37    M2Brake,
38    M2SetPosition(u8),
39    BaseVelocity { vx: i8, vy: i8, omega: i8 },
40    BaseBrake,
41}