Compare commits
2 Commits
c271df4bce
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 7ac157a4d3 | |||
| 8b5ff4ef93 |
@ -60,7 +60,7 @@ const UUID_BUTTON_STOP: BleUuid = uuid128!("c1401123-8dda-45a3-959b-d23a0f8f53d7
|
||||
const UUID_BUTTON_AUX: BleUuid = uuid128!("c1401124-8dda-45a3-959b-d23a0f8f53d7");
|
||||
const UUID_BUTTON_LEARN: BleUuid = uuid128!("c1401223-8dda-45a3-959b-d23a0f8f53d7");
|
||||
const UUID_BUTTON_AUTO: BleUuid = uuid128!("c1401225-8dda-45a3-959b-d23a0f8f53d7");
|
||||
const UUID_BLUETOOTH_NAME: BleUuid = uuid128!("c1411224-8dda-45a3-959b-d23a0f8f53d7");
|
||||
const UUID_BLUETOOTH_NAME: BleUuid = uuid128!("c1401224-8dda-45a3-959b-d23a0f8f53d7");
|
||||
|
||||
// Status Characteristics
|
||||
const UUID_STATUS_LIMITS: BleUuid = uuid128!("c1401321-8dda-45a3-959b-d23a0f8f53d7");
|
||||
|
||||
@ -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)]
|
||||
|
||||
@ -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<()> {
|
||||
|
||||
Reference in New Issue
Block a user