#include <gear_detector.h>
Definition at line 4 of file gear_detector.h.
◆ GearDetector()
GearDetector::GearDetector |
( |
| ) |
|
◆ ~GearDetector()
GearDetector::~GearDetector |
( |
| ) |
|
◆ computeGearboxRatio()
float GearDetector::computeGearboxRatio |
( |
| ) |
const |
|
private |
Definition at line 119 of file gear_detector.cpp.
119 {
121
122 if (driveshaftRpm == 0) {
123 return 0;
124 }
125
126 float engineRpm;
129 } else {
131 }
132
133 return engineRpm / driveshaftRpm;
134}
float getDriveshaftRpm() const
virtual bool hasSensor() const
static float getOrZero(SensorType type)
Referenced by onSlowCallback().
◆ determineGearFromRatio()
size_t GearDetector::determineGearFromRatio |
( |
float |
ratio | ) |
const |
Definition at line 71 of file gear_detector.cpp.
71 {
73 if (gearCount == 0) {
74
75 return 0;
76 }
77
78
80 return 0;
81 }
82
83
84 if (ratio < engineConfiguration->gearRatio[gearCount - 1] * 0.66f) {
85 return 0;
86 }
87
88 size_t currentGear = gearCount;
89
90 while (currentGear > 1) {
92 break;
93 }
94
95 currentGear--;
96 }
97
98 return currentGear;
99}
float m_gearThresholds[TCU_GEAR_COUNT - 1]
static constexpr engine_configuration_s * engineConfiguration
scaled_channel< uint16_t, 100, 1 > gearRatio[TCU_GEAR_COUNT]
Referenced by onSlowCallback().
◆ get()
◆ getDriveshaftRpm()
float GearDetector::getDriveshaftRpm |
( |
| ) |
const |
|
private |
◆ getGearboxRatio()
float GearDetector::getGearboxRatio |
( |
| ) |
const |
◆ getRpmInGear()
◆ initGearDetector()
void GearDetector::initGearDetector |
( |
| ) |
|
|
private |
Definition at line 17 of file gear_detector.cpp.
17 {
18
19
21
22 if (gearCount == 0) {
23
24 return;
25 }
26
27 if (gearCount > TCU_GEAR_COUNT) {
28 criticalError("too many gears");
29 return;
30 }
31
32
33 for (size_t i = 0; i < gearCount; i++) {
35 criticalError("Expecting positive gear ratio for #%d", i + 1);
36 return;
37 }
38 }
39
40 for (int i = 0; i < gearCount - 1; i++) {
41
44
45 if (gearI <= gearIplusOne) {
46 criticalError("Invalid gear ordering near gear #%d", i + 1);
47 }
48
50 }
51
53}
static constexpr float geometricMean(float x, float y)
Referenced by onConfigurationChange(), and onSlowCallback().
◆ onConfigurationChange()
◆ onSlowCallback()
void GearDetector::onSlowCallback |
( |
| ) |
|
|
overridevirtual |
Reimplemented from EngineModule.
Definition at line 59 of file gear_detector.cpp.
59 {
63 }
64
67
69}
float computeGearboxRatio() const
size_t determineGearFromRatio(float ratio) const
◆ showInfo()
void GearDetector::showInfo |
( |
const char * |
sensorName | ) |
const |
|
overridevirtual |
Implements Sensor.
Definition at line 153 of file gear_detector.cpp.
153 {
154 efiPrintf("Sensor \"%s\" is gear detector.", sensorName);
157}
◆ isInitialized
bool GearDetector::isInitialized = false |
|
private |
◆ m_currentGear
size_t GearDetector::m_currentGear = 0 |
|
private |
◆ m_gearboxRatio
float GearDetector::m_gearboxRatio = 0 |
|
private |
◆ m_gearThresholds
float GearDetector::m_gearThresholds[TCU_GEAR_COUNT - 1] |
|
private |
The documentation for this class was generated from the following files: