diff --git a/gem-remotes-esp32/src/main.rs b/gem-remotes-esp32/src/main.rs index 8713d10..49d8472 100644 --- a/gem-remotes-esp32/src/main.rs +++ b/gem-remotes-esp32/src/main.rs @@ -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::::new_on_dispatch( Commands::ButtonTimerRestart, diff --git a/gem-remotes-lib/src/fake_pic.rs b/gem-remotes-lib/src/fake_pic.rs index 86e35cd..915cf96 100644 --- a/gem-remotes-lib/src/fake_pic.rs +++ b/gem-remotes-lib/src/fake_pic.rs @@ -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;