2021-07-25 22:05:17 -07:00
|
|
|
#include "pch.h"
|
|
|
|
|
2020-10-09 20:34:45 -07:00
|
|
|
#include "gear_controller.h"
|
|
|
|
|
2022-04-23 04:34:39 -07:00
|
|
|
#if EFI_TCU
|
2021-11-16 01:15:29 -08:00
|
|
|
void GearControllerBase::init() {
|
2022-04-06 14:37:30 -07:00
|
|
|
initTransmissionController();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GearControllerBase::initTransmissionController() {
|
|
|
|
switch (engineConfiguration->transmissionControllerMode) {
|
|
|
|
case TransmissionControllerMode::SimpleTransmissionController :
|
|
|
|
transmissionController = getSimpleTransmissionController();
|
|
|
|
break;
|
2024-04-03 20:02:51 -07:00
|
|
|
case TransmissionControllerMode::Generic4 :
|
|
|
|
transmissionController = getGeneric4TransmissionController();
|
|
|
|
break;
|
2022-04-06 14:37:30 -07:00
|
|
|
case TransmissionControllerMode::Gm4l6x :
|
|
|
|
transmissionController = getGm4l6xTransmissionController();
|
|
|
|
break;
|
|
|
|
default :
|
|
|
|
transmissionController = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
transmissionController->init();
|
2020-10-09 20:34:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void GearControllerBase::update() {
|
2022-04-06 14:37:30 -07:00
|
|
|
if (transmissionController == NULL) {
|
|
|
|
initTransmissionController();
|
2022-04-18 17:09:27 -07:00
|
|
|
} else if (transmissionController->getMode() != engineConfiguration->transmissionControllerMode) {
|
2024-04-09 20:04:58 -07:00
|
|
|
// TODO de-init here
|
2022-04-06 14:37:30 -07:00
|
|
|
initTransmissionController();
|
|
|
|
}
|
2024-04-09 17:17:56 -07:00
|
|
|
|
|
|
|
// check if it was init'd (it wouldn't be if set to NONE)
|
|
|
|
if (transmissionController != NULL) {
|
|
|
|
// We are responsible for telling the transmission controller
|
|
|
|
// what gear we want.
|
|
|
|
transmissionController->update(getDesiredGear());
|
|
|
|
}
|
|
|
|
|
2022-04-06 14:37:30 -07:00
|
|
|
// Post state to TS
|
|
|
|
postState();
|
2020-10-09 20:34:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
gear_e GearControllerBase::getDesiredGear() const {
|
|
|
|
return desiredGear;
|
|
|
|
}
|
|
|
|
|
|
|
|
gear_e GearControllerBase::setDesiredGear(gear_e gear) {
|
|
|
|
desiredGear = gear;
|
|
|
|
return getDesiredGear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GearControllerBase::postState() {
|
|
|
|
#if EFI_TUNER_STUDIO
|
2021-12-07 17:18:47 -08:00
|
|
|
engine->outputChannels.tcuDesiredGear = getDesiredGear();
|
2020-10-09 20:34:45 -07:00
|
|
|
#endif
|
|
|
|
}
|
2022-04-06 14:37:30 -07:00
|
|
|
|
|
|
|
void initGearController() {
|
|
|
|
switch (engineConfiguration->gearControllerMode) {
|
|
|
|
case GearControllerMode::ButtonShift :
|
|
|
|
engine->gearController = getButtonShiftController();
|
|
|
|
break;
|
2023-02-25 13:18:28 -08:00
|
|
|
case GearControllerMode::Generic :
|
|
|
|
engine->gearController = getGenericGearController();
|
|
|
|
break;
|
2022-04-06 14:37:30 -07:00
|
|
|
default :
|
|
|
|
engine->gearController = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
engine->gearController->init();
|
|
|
|
}
|
2023-02-25 13:18:28 -08:00
|
|
|
|
2024-04-04 21:01:27 -07:00
|
|
|
float* GearControllerBase::getRangeStateArray(int i) {
|
2023-02-25 13:18:28 -08:00
|
|
|
switch (i) {
|
|
|
|
case 1 :
|
|
|
|
return config->tcu_rangePlus;
|
|
|
|
break;
|
|
|
|
case 2 :
|
|
|
|
return config->tcu_rangeMinus;
|
|
|
|
break;
|
|
|
|
case 3 :
|
|
|
|
return config->tcu_rangeP;
|
|
|
|
break;
|
|
|
|
case 4 :
|
|
|
|
return config->tcu_rangeR;
|
|
|
|
break;
|
|
|
|
case 5 :
|
|
|
|
return config->tcu_rangeN;
|
|
|
|
break;
|
|
|
|
case 6 :
|
|
|
|
return config->tcu_rangeD;
|
|
|
|
break;
|
|
|
|
case 7 :
|
|
|
|
return config->tcu_rangeM;
|
|
|
|
break;
|
|
|
|
case 8 :
|
|
|
|
return config->tcu_rangeM3;
|
|
|
|
break;
|
|
|
|
case 9 :
|
|
|
|
return config->tcu_rangeM2;
|
|
|
|
break;
|
|
|
|
case 10 :
|
|
|
|
return config->tcu_rangeM1;
|
|
|
|
break;
|
|
|
|
case 11 :
|
|
|
|
return config->tcu_rangeLow;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2022-04-23 04:34:39 -07:00
|
|
|
#endif // EFI_TCU
|