Initial rough-in of motor controller
This commit is contained in:
35
gem-remotes-esp32/src/commands.rs
Normal file
35
gem-remotes-esp32/src/commands.rs
Normal file
@ -0,0 +1,35 @@
|
||||
/// 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,
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user