Initialize motor, limit, status states

This commit is contained in:
2025-09-18 23:02:58 -04:00
parent 28e8fdaa4a
commit c271df4bce
2 changed files with 10 additions and 0 deletions

View File

@ -72,6 +72,7 @@ async fn main_loop() -> Result<()> {
// Setup of various drivers that need to out-live the executor
let mut f_pic = FakePic::with_defaults(&mut dp);
f_pic.sync_pic().await?;
// Setup callback timers
let mut button_timer = MessageTimer::<Commands, Commands>::new_on_dispatch(
Commands::ButtonTimerRestart,

View File

@ -71,6 +71,15 @@ impl FakePic {
recv_q: dp.get_callback_channel(&cmd_filter),
}
}
// === Sync with the pic controller =========================================================
// Since we don't have a pic controller, just update the bluetooth with the internal state
// of the fake controller.
pub async fn sync_pic(&mut self) -> Result<()> {
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?;
Ok(())
}
// === Change Fake Hardware Parameters ======================================================
pub fn change_limits(&mut self, l: Limits) -> () {
self.limit_state = l;