rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
gear_detector.h
Go to the documentation of this file.
1#pragma once
2#include "sensor.h"
3
4class GearDetector : public EngineModule, public Sensor {
5public:
8
9 void onSlowCallback() override;
10 void onConfigurationChange(engine_configuration_s const * /*previousConfig*/) override;
11
12 float getGearboxRatio() const;
13
14 // Returns 0 for neutral, 1 for 1st, 5 for 5th, etc.
15 size_t determineGearFromRatio(float ratio) const;
16
17 float getRpmInGear(size_t gear) const;
18
19 SensorResult get() const override;
20 void showInfo(const char* sensorName) const override;
21
22private:
23 float computeGearboxRatio() const;
24 float getDriveshaftRpm() const;
25 void initGearDetector();
26 bool isInitialized = false;
27
28 float m_gearboxRatio = 0;
29 size_t m_currentGear = 0;
30
31 float m_gearThresholds[TCU_GEAR_COUNT - 1];
32};
size_t m_currentGear
SensorResult get() const override
void onConfigurationChange(engine_configuration_s const *) override
float m_gearboxRatio
float computeGearboxRatio() const
size_t determineGearFromRatio(float ratio) const
void onSlowCallback() override
void initGearDetector()
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]
Base class for sensors. Inherit this class to implement a new type of sensor.
expected< float > SensorResult
Definition sensor.h:46