add additional status update for auto and aux
This commit is contained in:
@ -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)
|
// Distinguish toggles(like auto) which is on/off from buttons (which are pressed/released)
|
||||||
//TODONOW: remove?
|
//TODONOW: remove?
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
|
|||||||
@ -15,7 +15,7 @@ use crate::fake_motor::{Motors,MotorStatus};
|
|||||||
use crate::fake_limits::{Limits, LimitStatus, EMPTY_LIMITS};
|
use crate::fake_limits::{Limits, LimitStatus, EMPTY_LIMITS};
|
||||||
use crate::fake_status::Statuses;
|
use crate::fake_status::Statuses;
|
||||||
use crate::dispatch::{Dispatch, DispatchRecvQ, DispatchSendQ};
|
use crate::dispatch::{Dispatch, DispatchRecvQ, DispatchSendQ};
|
||||||
use crate::commands::{Commands};
|
use crate::commands::{Commands, button_from_bool};
|
||||||
|
|
||||||
pub struct FakePic {
|
pub struct FakePic {
|
||||||
motor_state: Motors,
|
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::BluetoothStatusMotor { data: self.motor_state }).await?;
|
||||||
self.send_q.send(Commands::BluetoothStatusLimits { data: self.limit_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::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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
// === Change Fake Hardware Parameters ======================================================
|
// === Change Fake Hardware Parameters ======================================================
|
||||||
@ -91,11 +94,13 @@ impl FakePic {
|
|||||||
pub async fn toggle_aux(&mut self) -> Result<()> {
|
pub async fn toggle_aux(&mut self) -> Result<()> {
|
||||||
self.status_state ^= Statuses::AUX;
|
self.status_state ^= Statuses::AUX;
|
||||||
self.send_q.send(Commands::BluetoothStatusStatus { data: self.status_state }).await?;
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
pub async fn toggle_auto(&mut self) -> Result<()> {
|
pub async fn toggle_auto(&mut self) -> Result<()> {
|
||||||
self.status_state ^= Statuses::AUTO;
|
self.status_state ^= Statuses::AUTO;
|
||||||
self.send_q.send(Commands::BluetoothStatusStatus { data: self.status_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?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
pub async fn press_learn(&mut self) -> Result<()> {
|
pub async fn press_learn(&mut self) -> Result<()> {
|
||||||
|
|||||||
Reference in New Issue
Block a user