gear detector doesn't need StoredValueSensor
This commit is contained in:
parent
e118c0dae4
commit
f10f7fa569
|
@ -5,9 +5,8 @@ static constexpr float geometricMean(float x, float y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
GearDetector::GearDetector()
|
GearDetector::GearDetector()
|
||||||
: StoredValueSensor(SensorType::DetectedGear, MS2NT(100))
|
: Sensor(SensorType::DetectedGear)
|
||||||
{
|
{
|
||||||
Register();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GearDetector::~GearDetector() {
|
GearDetector::~GearDetector() {
|
||||||
|
@ -48,14 +47,15 @@ void GearDetector::onConfigurationChange(engine_configuration_s const * /*previo
|
||||||
|
|
||||||
m_gearThresholds[i] = geometricMean(gearI, gearIplusOne);
|
m_gearThresholds[i] = geometricMean(gearI, gearIplusOne);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Register();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GearDetector::onSlowCallback() {
|
void GearDetector::onSlowCallback() {
|
||||||
float ratio = computeGearboxRatio();
|
float ratio = computeGearboxRatio();
|
||||||
m_gearboxRatio = ratio;
|
m_gearboxRatio = ratio;
|
||||||
|
|
||||||
auto gear = determineGearFromRatio(ratio);
|
m_currentGear = determineGearFromRatio(ratio);
|
||||||
setValidValue(gear, getTimeNowNt());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t GearDetector::determineGearFromRatio(float ratio) const {
|
size_t GearDetector::determineGearFromRatio(float ratio) const {
|
||||||
|
@ -135,3 +135,13 @@ float GearDetector::getRpmInGear(size_t gear) const {
|
||||||
float GearDetector::getGearboxRatio() const {
|
float GearDetector::getGearboxRatio() const {
|
||||||
return m_gearboxRatio;
|
return m_gearboxRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SensorResult GearDetector::get() const {
|
||||||
|
return m_currentGear;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GearDetector::showInfo(const char* sensorName) const {
|
||||||
|
efiPrintf("Sensor \"%s\" is gear detector.", sensorName);
|
||||||
|
efiPrintf(" Gearbox ratio: %.3f", m_gearboxRatio);
|
||||||
|
efiPrintf(" Detected gear: %d", m_currentGear);
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class GearDetector : public EngineModule, public StoredValueSensor {
|
class GearDetector : public EngineModule, public Sensor {
|
||||||
public:
|
public:
|
||||||
GearDetector();
|
GearDetector();
|
||||||
~GearDetector();
|
~GearDetector();
|
||||||
|
@ -15,6 +15,9 @@ public:
|
||||||
|
|
||||||
float getRpmInGear(size_t gear) const;
|
float getRpmInGear(size_t gear) const;
|
||||||
|
|
||||||
|
SensorResult get() const;
|
||||||
|
void showInfo(const char* sensorName) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float computeGearboxRatio() const;
|
float computeGearboxRatio() const;
|
||||||
float getDriveshaftRpm() const;
|
float getDriveshaftRpm() const;
|
||||||
|
|
Loading…
Reference in New Issue