Files
GemBluetoothEmbeddedDevice/gem-remotes-esp32/src/commands.rs

39 lines
1.0 KiB
Rust

/// An enum of all commands passed into and out of the microcontroller
use strum_macros::EnumCount as EnumCountMacro;
use std::mem::discriminant;
#[derive(Clone, Copy, EnumCountMacro, Debug)]
pub enum Commands {
// Inputs sent from the PIC microcontroller
PicRecvUp,
PicRecvDown,
PicRecvStop,
// Inputs from bluetooth
BluetoothUp {data: u8},
BluetoothDown {data: u8},
BluetoothStop {data: u8}, // There is no state where releasing the stop button induces a change.
// Internal messages
StopTimerExpired, // Sent when the 2 second stop sequence is complete
StopTimerRestart,
StopTimerClear,
ButtonTimerExpired,
ButtonTimerRestart,
ButtonTimerClear,
NotifyMotorUp,
NotifyMotorDown,
NotifyMotorStop,
}
pub type CmdType = std::mem::Discriminant<Commands>;
/// Consider commands equal if they have the same command type, but different values
impl PartialEq for Commands {
fn eq(&self, other: &Self) -> bool {
discriminant(self) == discriminant(other)
}
}