rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
init_aux_speed_sensor.cpp
Go to the documentation of this file.
1/*
2 * @file init_aux_speed_sensor.cpp
3 *
4 */
5
6#include "pch.h"
7#include "init.h"
8#include "frequency_sensor.h"
9
12
13static class : public SensorConverter {
14public:
15 SensorResult convert(float frequency) const override {
16 return frequency;
17 }
19
20class WheelSlipBasedOnAuxSpeedSensor : public Sensor {
21public:
22 WheelSlipBasedOnAuxSpeedSensor() : Sensor(SensorType::WheelSlipRatio) { }
23
24 SensorResult get() const final override {
25 auto value1 = auxSpeed1.get();
27 if (!value1.Valid || !value2.Valid) {
28 return UnexpectedCode::Unknown;
29 }
30 // todo: remove handling of zero in July of 2024
31 float correctedAuxSpeed1Multiplier = engineConfiguration->auxSpeed1Multiplier == 0 ? 1 : engineConfiguration->auxSpeed1Multiplier;
32 float result = value1.Value * correctedAuxSpeed1Multiplier / value2.Value;
33 return result;
34 }
35
36 void showInfo(const char*) const override { }
37};
38
39static WheelSlipBasedOnAuxSpeedSensor wheelSlipSensor;
40
50
54 wheelSlipSensor.unregister();
55}
void initIfValid(brain_pin_e pin, SensorConverter &converter, float filterParameter)
virtual SensorResult get() const =0
virtual void showInfo(const char *sensorName) const =0
static SensorResult get(SensorType type)
Definition sensor.cpp:166
SensorResult get() const final override
static constexpr engine_configuration_s * engineConfiguration
static FrequencySensor auxSpeed2(SensorType::AuxSpeed2, MS2NT(500))
converter
static WheelSlipBasedOnAuxSpeedSensor wheelSlipSensor
void deinitAuxSpeedSensors()
void initAuxSpeedSensors()
static FrequencySensor auxSpeed1(SensorType::AuxSpeed1, MS2NT(500))
static float frequency
Definition init_flex.cpp:21
expected< float > SensorResult
Definition sensor.h:46
value1("SENT ch0 value1", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 1974, 1.0, 0.0, 4095.0, "RAW")
brain_input_pin_e auxSpeedSensorInputPin[AUX_SPEED_SENSOR_COUNT]