27 if (gearCount > TCU_GEAR_COUNT) {
28 criticalError(
"too many gears");
33 for (
size_t i = 0; i < gearCount; i++) {
35 criticalError(
"Expecting positive gear ratio for #%d", i + 1);
40 for (
int i = 0; i < gearCount - 1; i++) {
45 if (gearI <= gearIplusOne) {
46 criticalError(
"Invalid gear ordering near gear #%d", i + 1);
84 if (ratio < engineConfiguration->gearRatio[gearCount - 1] * 0.66f) {
88 size_t currentGear = gearCount;
90 while (currentGear > 1) {
122 if (driveshaftRpm == 0) {
133 return engineRpm / driveshaftRpm;
154 efiPrintf(
"Sensor \"%s\" is gear detector.", sensorName);
SensorResult get() const override
void onConfigurationChange(engine_configuration_s const *) override
float computeGearboxRatio() const
size_t determineGearFromRatio(float ratio) const
void onSlowCallback() override
float getRpmInGear(size_t gear) const
void showInfo(const char *sensorName) const override
float getDriveshaftRpm() const
float getGearboxRatio() const
float m_gearThresholds[TCU_GEAR_COUNT - 1]
virtual bool hasSensor() const
static float getOrZero(SensorType type)
static constexpr engine_configuration_s * engineConfiguration
static constexpr float geometricMean(float x, float y)
expected< float > SensorResult
scaled_channel< uint16_t, 100, 1 > gearRatio[TCU_GEAR_COUNT]
scaled_channel< uint16_t, 100, 1 > finalGearRatio