fix button shift inheritance (#2027)

* fix button shift inheritance

* extra

Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
Matthew Kennedy 2020-12-06 06:32:38 -06:00 committed by GitHub
parent 2d9be1077b
commit 9238aa454e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 16 deletions

View File

@ -20,12 +20,12 @@ ButtonShiftController::ButtonShiftController() :
}
void ButtonShiftController::init (DECLARE_ENGINE_PARAMETER_SIGNATURE) {
// 500 millisecond is maybe a little long?
debounceUp.init(500, CONFIG(tcuUpshiftButtonPin), CONFIG(tcuUpshiftButtonPinMode));
debounceDown.init(500, CONFIG(tcuDownshiftButtonPin), CONFIG(tcuDownshiftButtonPinMode));
INJECT_ENGINE_REFERENCE(&transmissionController);
transmissionController.init();
void ButtonShiftController::init(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
// 500 millisecond is maybe a little long?
debounceUp.init(500, CONFIG(tcuUpshiftButtonPin), CONFIG(tcuUpshiftButtonPinMode));
debounceDown.init(500, CONFIG(tcuDownshiftButtonPin), CONFIG(tcuDownshiftButtonPinMode));
GearControllerBase::init(PASS_ENGINE_PARAMETER_SIGNATURE);
}
void ButtonShiftController::update() {
@ -77,11 +77,8 @@ void ButtonShiftController::update() {
break;
}
}
// We are responsible for telling the transmission controller
// what gear we want.
transmissionController.update(getDesiredGear());
// Post state to TS
postState();
GearControllerBase::update();
}

View File

@ -14,9 +14,9 @@
class ButtonShiftController: public GearControllerBase {
public:
ButtonShiftController();
DECLARE_ENGINE_PTR;
void update();
void init(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void update() override;
void init(DECLARE_ENGINE_PARAMETER_SIGNATURE) override;
private:
ButtonDebounce debounceUp;
ButtonDebounce debounceDown;

View File

@ -1,13 +1,16 @@
#include "gear_controller.h"
#include "tunerstudio_outputs.h"
void GearControllerBase::init() {
void GearControllerBase::init(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
INJECT_ENGINE_REFERENCE(&transmissionController);
transmissionController.init();
}
void GearControllerBase::update() {
// We are responsible for telling the transmission controller
// what gear we want.
transmissionController.update(getDesiredGear());
// Post state to TS
postState();
}

View File

@ -13,11 +13,13 @@ public:
virtual void update();
gear_e getDesiredGear() const;
virtual void init();
virtual void init(DECLARE_ENGINE_PARAMETER_SIGNATURE);
private:
gear_e desiredGear = NEUTRAL;
protected:
gear_e setDesiredGear(gear_e);
private:
void postState();
SimpleTransmissionController transmissionController;
};