add additional status update for auto and aux

This commit is contained in:
2025-09-22 18:07:17 -04:00
parent c271df4bce
commit 8b5ff4ef93
2 changed files with 13 additions and 1 deletions

View File

@ -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)]

View File

@ -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<()> {