2020-09-02 12:39:50 -07:00
|
|
|
/**
|
|
|
|
* @file tcu.cpp
|
|
|
|
* @brief Base classes for gear selection and transmission control
|
|
|
|
*
|
|
|
|
* @date Aug 31, 2020
|
|
|
|
* @author David Holdeman, (c) 2020
|
|
|
|
*/
|
|
|
|
|
2021-07-25 22:05:17 -07:00
|
|
|
#include "pch.h"
|
|
|
|
|
2020-09-02 12:39:50 -07:00
|
|
|
#include "tcu.h"
|
2022-04-23 04:34:39 -07:00
|
|
|
#include "engine.h"
|
2020-09-02 12:39:50 -07:00
|
|
|
|
2022-04-23 04:34:39 -07:00
|
|
|
#if EFI_TCU
|
2022-04-06 14:37:30 -07:00
|
|
|
void TransmissionControllerBase::init() {
|
|
|
|
}
|
|
|
|
|
2022-10-30 06:47:53 -07:00
|
|
|
void TransmissionControllerBase::update(gear_e /*gear*/) {
|
2022-04-23 04:34:39 -07:00
|
|
|
postState();
|
2020-09-02 12:39:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
gear_e TransmissionControllerBase::setCurrentGear(gear_e gear) {
|
|
|
|
currentGear = gear;
|
|
|
|
return getCurrentGear();
|
|
|
|
}
|
|
|
|
|
|
|
|
gear_e TransmissionControllerBase::getCurrentGear() const {
|
|
|
|
return currentGear;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TransmissionControllerBase::postState() {
|
|
|
|
#if EFI_TUNER_STUDIO
|
2023-02-25 13:18:28 -08:00
|
|
|
auto iss = Sensor::get(SensorType::InputShaftSpeed);
|
|
|
|
auto rpm = Sensor::get(SensorType::Rpm);
|
|
|
|
if (iss.Valid && rpm.Valid) {
|
|
|
|
engine->outputChannels.tcRatio = rpm.Value / iss.Value;
|
|
|
|
}
|
|
|
|
engine->outputChannels.tcuCurrentGear = getCurrentGear();
|
2020-09-02 12:39:50 -07:00
|
|
|
#endif
|
|
|
|
}
|
2022-04-23 04:34:39 -07:00
|
|
|
|
|
|
|
void TransmissionControllerBase::measureShiftTime(gear_e gear) {
|
|
|
|
m_shiftTime = true;
|
|
|
|
m_shiftTimer.reset();
|
|
|
|
m_shiftTimeGear = gear;
|
|
|
|
}
|
|
|
|
|
|
|
|
float TransmissionControllerBase::isShiftCompleted() {
|
2023-04-01 23:08:06 -07:00
|
|
|
if (m_shiftTime && m_shiftTimeGear == Sensor::getOrZero(SensorType::DetectedGear)) {
|
2022-04-23 04:34:39 -07:00
|
|
|
m_shiftTime = false;
|
|
|
|
return m_shiftTimer.getElapsedSeconds();
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // EFI_TCU
|