register/unregister

(cherry picked from commit c682c49d46)
This commit is contained in:
Matthew Kennedy 2023-04-01 23:17:50 -07:00 committed by rusefillc
parent 4e7e25585e
commit 831e016bc4
3 changed files with 7 additions and 1 deletions

View File

@ -7,6 +7,11 @@ static constexpr float geometricMean(float x, float y) {
GearDetector::GearDetector()
: StoredValueSensor(SensorType::DetectedGear, MS2NT(100))
{
Register();
}
GearDetector::~GearDetector() {
unregister();
}
void GearDetector::onConfigurationChange(engine_configuration_s const * /*previousConfig*/) {

View File

@ -3,6 +3,7 @@
class GearDetector : public EngineModule, public StoredValueSensor {
public:
GearDetector();
~GearDetector();
void onSlowCallback() override;
void onConfigurationChange(engine_configuration_s const * /*previousConfig*/) override;

View File

@ -12,7 +12,7 @@ float GetGearRatioFor(float revPerKm, float axle, float kph, float rpm) {
GearDetector dut;
dut.onSlowCallback();
return dut.get().value_or(0);
return Sensor::getOrZero(SensorType::DetectedGear);
}
TEST(GearDetector, ComputeGearRatio) {