diff --git a/firmware/console/binary/output_channels.txt b/firmware/console/binary/output_channels.txt index 3861937eed..f39a494f56 100644 --- a/firmware/console/binary/output_channels.txt +++ b/firmware/console/binary/output_channels.txt @@ -367,5 +367,8 @@ uint16_t rpmAcceleration;dRPM;"RPM/s",1, 0, 0, 0, 0 pid_status_s etbStatus pid_status_s boostStatus - uint8_t[76 iterate] unusedAtTheEnd;;"",1, 0, 0, 0, 0 + uint16_t auxSpeed1;"aux speed 1";"s",1, 0, 0, 0, 0 + uint16_t auxSpeed2;"aux speed 2";"s",1, 0, 0, 0, 0 + + uint8_t[72 iterate] unusedAtTheEnd;;"",1, 0, 0, 0, 0 end_struct diff --git a/firmware/init/init.h b/firmware/init/init.h index 8c409b58d9..f5e572db1f 100644 --- a/firmware/init/init.h +++ b/firmware/init/init.h @@ -32,6 +32,7 @@ void initBaro(); void initAuxSensors(); void initVehicleSpeedSensor(); void initTurbochargerSpeedSensor(); +void initAuxSpeedSensors(); // Sensor reconfiguration void deinitVbatt(); @@ -42,3 +43,4 @@ void deInitFlexSensor(); void deInitVehicleSpeedSensor(); void deinitTurbochargerSpeedSensor(); void deinitMap(); +void deinitAuxSpeedSensors(); diff --git a/firmware/init/sensor/init_aux_speed_sensor.cpp b/firmware/init/sensor/init_aux_speed_sensor.cpp index 030c0b24bc..422e3e9ca2 100644 --- a/firmware/init/sensor/init_aux_speed_sensor.cpp +++ b/firmware/init/sensor/init_aux_speed_sensor.cpp @@ -4,4 +4,30 @@ */ #include "pch.h" +#include "init.h" +#include "frequency_sensor.h" +static FrequencySensor auxSpeed1(SensorType::AuxSpeed1, MS2NT(500), 0.05f); +static FrequencySensor auxSpeed2(SensorType::AuxSpeed2, MS2NT(500), 0.05f); + +static class : public SensorConverter { +public: + SensorResult convert(float frequency) const override { + auto hz = frequency; + + auto rpm = hz * 60; + + return rpm; + } +} converter; + + +void initAuxSpeedSensors() { + auxSpeed1.initIfValid(engineConfiguration->auxSpeedSensorInputPin[0], converter); + auxSpeed2.initIfValid(engineConfiguration->auxSpeedSensorInputPin[1], converter); +} + +void deinitAuxSpeedSensors() { + auxSpeed1.deInit(); + auxSpeed2.deInit(); +} diff --git a/firmware/init/sensor/init_sensors.cpp b/firmware/init/sensor/init_sensors.cpp index 915028624f..f22818d2ba 100644 --- a/firmware/init/sensor/init_sensors.cpp +++ b/firmware/init/sensor/init_sensors.cpp @@ -61,6 +61,7 @@ void initNewSensors() { initAuxSensors(); initVehicleSpeedSensor(); initTurbochargerSpeedSensor(); + initAuxSpeedSensors(); #if !EFI_UNIT_TEST initFuelLevel(); @@ -83,6 +84,7 @@ void stopSensors() { deInitFlexSensor(); deInitVehicleSpeedSensor(); deinitTurbochargerSpeedSensor(); + deinitAuxSpeedSensors(); deinitMap(); }