Fixed auto mode in fake pic
This commit is contained in:
@ -115,8 +115,10 @@ impl FakePic {
|
||||
else {
|
||||
info!("Starting motors moving up!");
|
||||
self.motor_state.update_status(MotorStatus::GoingUp);
|
||||
self.send_q.send(Commands::ButtonTimerRestart).await?;
|
||||
self.send_q.send(Commands::BluetoothStatusMotor{ data: self.motor_state }).await?;
|
||||
if self.status_state.intersection(Statuses::AUTO).is_empty() {
|
||||
self.send_q.send(Commands::ButtonTimerRestart).await?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@ -136,15 +138,17 @@ impl FakePic {
|
||||
else {
|
||||
info!("Starting motors moving down!");
|
||||
self.motor_state.update_status(MotorStatus::GoingDown);
|
||||
self.send_q.send(Commands::ButtonTimerRestart).await?;
|
||||
self.send_q.send(Commands::BluetoothStatusMotor{ data: self.motor_state }).await?;
|
||||
if self.status_state.intersection(Statuses::AUTO).is_empty() {
|
||||
self.send_q.send(Commands::ButtonTimerRestart).await?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
pub async fn press_stop(&mut self) -> Result<()> {
|
||||
self.motor_state.stop();
|
||||
self.send_q.send(Commands::BluetoothStatusMotor { data: self.motor_state }).await?;
|
||||
//self.send_q.send(Commands::ButtonTimerClear).await?; // Stop waiting on button timeouts
|
||||
info!("Stopping motors");
|
||||
Ok(())
|
||||
}
|
||||
pub async fn toggle_panic(&mut self) -> Result<()> {
|
||||
@ -224,14 +228,14 @@ impl FakePic {
|
||||
Commands::BluetoothUp { data } => {
|
||||
if data.is_pressed() {
|
||||
self.press_up().await?;
|
||||
} else {
|
||||
self.press_stop().await?; // Releasing up is equivalent to stop
|
||||
} else if self.status_state.intersection(Statuses::AUTO).is_empty() {
|
||||
self.press_stop().await?; // Releasing up is equivalent to stop, if not in auto
|
||||
}
|
||||
}
|
||||
Commands::BluetoothDown { data } => {
|
||||
if data.is_pressed() {
|
||||
self.press_down().await?;
|
||||
} else {
|
||||
} else if self.status_state.intersection(Statuses::AUTO).is_empty(){
|
||||
self.press_stop().await?; // Releasing down is equivalent to stop
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user