diff --git a/gem-remotes-lib/src/commands.rs b/gem-remotes-lib/src/commands.rs index f9ed27a..533303a 100644 --- a/gem-remotes-lib/src/commands.rs +++ b/gem-remotes-lib/src/commands.rs @@ -81,6 +81,13 @@ impl Button { } } +pub fn button_from_bool(b: bool) -> Button { + match b { + true => Button::Pressed, + false => Button::Released, + } +} + // Distinguish toggles(like auto) which is on/off from buttons (which are pressed/released) //TODONOW: remove? #[derive(Copy, Clone, Debug)] diff --git a/gem-remotes-lib/src/fake_pic.rs b/gem-remotes-lib/src/fake_pic.rs index 915cf96..97b791c 100644 --- a/gem-remotes-lib/src/fake_pic.rs +++ b/gem-remotes-lib/src/fake_pic.rs @@ -15,7 +15,7 @@ use crate::fake_motor::{Motors,MotorStatus}; use crate::fake_limits::{Limits, LimitStatus, EMPTY_LIMITS}; use crate::fake_status::Statuses; use crate::dispatch::{Dispatch, DispatchRecvQ, DispatchSendQ}; -use crate::commands::{Commands}; +use crate::commands::{Commands, button_from_bool}; pub struct FakePic { motor_state: Motors, @@ -78,6 +78,9 @@ impl FakePic { self.send_q.send(Commands::BluetoothStatusMotor { data: self.motor_state }).await?; self.send_q.send(Commands::BluetoothStatusLimits { data: self.limit_state }).await?; self.send_q.send(Commands::BluetoothStatusStatus { data: self.status_state }).await?; + self.send_q.send(Commands::BluetoothAuto { data: button_from_bool(!self.status_state.intersection(Statuses::AUTO).is_empty()) }).await?; + self.send_q.send(Commands::BluetoothAux { data: button_from_bool(!self.status_state.intersection(Statuses::AUX).is_empty()) }).await?; + self.send_q.send(Commands::BluetoothLearn { data: button_from_bool(!self.status_state.intersection(Statuses::LEARN).is_empty()) }).await?; Ok(()) } // === Change Fake Hardware Parameters ====================================================== @@ -91,11 +94,13 @@ impl FakePic { pub async fn toggle_aux(&mut self) -> Result<()> { self.status_state ^= Statuses::AUX; self.send_q.send(Commands::BluetoothStatusStatus { data: self.status_state }).await?; + self.send_q.send(Commands::BluetoothAux { data: button_from_bool(!self.status_state.intersection(Statuses::AUX).is_empty()) }).await?; Ok(()) } pub async fn toggle_auto(&mut self) -> Result<()> { self.status_state ^= Statuses::AUTO; self.send_q.send(Commands::BluetoothStatusStatus { data: self.status_state }).await?; + self.send_q.send(Commands::BluetoothAuto { data: button_from_bool(!self.status_state.intersection(Statuses::AUTO).is_empty()) }).await?; Ok(()) } pub async fn press_learn(&mut self) -> Result<()> {