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