From 3e70a1fc74100001e4775d5a4faa33aee5d9d064 Mon Sep 17 00:00:00 2001 From: Michael Ehrenreich Date: Thu, 23 Jun 2022 00:06:50 +0200 Subject: [PATCH] Pull fixCommonParams and sendCommand out of driving modes --- main/modes.cpp | 5 +++++ main/modes/defaultmode.cpp | 2 -- main/modes/gametrakmode.cpp | 4 ---- main/modes/ignoreinputmode.cpp | 4 ---- main/modes/larsmmode.cpp | 4 ---- main/modes/mickmode.cpp | 4 ---- main/modes/motortestmode.cpp | 3 --- main/modes/remotecontrolmode.cpp | 4 ---- main/modes/tempomatmode.cpp | 4 ---- main/modes/wheelchairmode.cpp | 2 -- 10 files changed, 5 insertions(+), 31 deletions(-) diff --git a/main/modes.cpp b/main/modes.cpp index 7e46328..4be2e63 100644 --- a/main/modes.cpp +++ b/main/modes.cpp @@ -21,4 +21,9 @@ void updateDrivingMode() if (currentMode) currentMode->update(); + + fixCommonParams(); + + // Last, send values to motor controllers + sendCommands(); } diff --git a/main/modes/defaultmode.cpp b/main/modes/defaultmode.cpp index 8473d25..9750a26 100644 --- a/main/modes/defaultmode.cpp +++ b/main/modes/defaultmode.cpp @@ -258,8 +258,6 @@ void DefaultMode::update() motor.cruiseCtrlEna = false; motor.nCruiseMotTgt = 0; } - fixCommonParams(); } } - sendCommands(); } diff --git a/main/modes/gametrakmode.cpp b/main/modes/gametrakmode.cpp index b714c85..62aeb0d 100644 --- a/main/modes/gametrakmode.cpp +++ b/main/modes/gametrakmode.cpp @@ -76,9 +76,5 @@ void GametrakMode::update() motor.nCruiseMotTgt = 0; } } - - fixCommonParams(); - - sendCommands(); } #endif diff --git a/main/modes/ignoreinputmode.cpp b/main/modes/ignoreinputmode.cpp index 5f87739..5399597 100644 --- a/main/modes/ignoreinputmode.cpp +++ b/main/modes/ignoreinputmode.cpp @@ -14,8 +14,4 @@ void IgnoreInputMode::update() motor.cruiseCtrlEna = false; motor.nCruiseMotTgt = 0; } - - fixCommonParams(); - - sendCommands(); } diff --git a/main/modes/larsmmode.cpp b/main/modes/larsmmode.cpp index 9d7decb..828fcec 100644 --- a/main/modes/larsmmode.cpp +++ b/main/modes/larsmmode.cpp @@ -105,8 +105,4 @@ void LarsmMode::update() motor.nCruiseMotTgt = 0; } } - - fixCommonParams(); - - sendCommands(); } diff --git a/main/modes/mickmode.cpp b/main/modes/mickmode.cpp index 255533a..cc5efce 100644 --- a/main/modes/mickmode.cpp +++ b/main/modes/mickmode.cpp @@ -78,8 +78,4 @@ void MickMode::update() motor.nCruiseMotTgt = 0; } } - - fixCommonParams(); - - sendCommands(); } diff --git a/main/modes/motortestmode.cpp b/main/modes/motortestmode.cpp index 6dbea6a..03b36d4 100644 --- a/main/modes/motortestmode.cpp +++ b/main/modes/motortestmode.cpp @@ -34,7 +34,4 @@ void MotortestMode::update() motor.cruiseCtrlEna = false; motor.nCruiseMotTgt = 0; } - - fixCommonParams(); - sendCommands(); } diff --git a/main/modes/remotecontrolmode.cpp b/main/modes/remotecontrolmode.cpp index 6b2c9a2..1dbe9f2 100644 --- a/main/modes/remotecontrolmode.cpp +++ b/main/modes/remotecontrolmode.cpp @@ -42,10 +42,6 @@ void RemoteControlMode::update() controllers.back.command.left.pwm = m_remoteCommand->backLeft; controllers.back.command.right.pwm = m_remoteCommand->backRight; } - - fixCommonParams(); - - sendCommands(); } void RemoteControlMode::setCommand(const RemoteCommand &command) diff --git a/main/modes/tempomatmode.cpp b/main/modes/tempomatmode.cpp index aa227ab..51cdba2 100644 --- a/main/modes/tempomatmode.cpp +++ b/main/modes/tempomatmode.cpp @@ -53,8 +53,4 @@ void TempomatMode::update() motor.nCruiseMotTgt = nCruiseMotTgt; } } - - fixCommonParams(); - - sendCommands(); } diff --git a/main/modes/wheelchairmode.cpp b/main/modes/wheelchairmode.cpp index 13db7a8..84325c4 100644 --- a/main/modes/wheelchairmode.cpp +++ b/main/modes/wheelchairmode.cpp @@ -219,9 +219,7 @@ void WheelchairMode::update() controller.command.right.cruiseCtrlEna = false; controller.command.right.nCruiseMotTgt = 0; } - fixCommonParams(); } } - sendCommands(); } #endif