Maintenability: frequency sensors need a simple event counter in the logs #4173

This commit is contained in:
rusefillc 2022-05-14 08:39:08 -04:00
parent cbfae3bb88
commit cbc4a42954
5 changed files with 12 additions and 2 deletions

View File

@ -53,6 +53,7 @@
#include "binary_logging.h"
#include "buffered_writer.h"
#include "dynoview.h"
#include "frequency_sensor.h"
extern bool main_loop_started;
@ -782,6 +783,10 @@ void updateTunerStudioState() {
#endif
tsOutputChannels->turboSpeed = Sensor::getOrZero(SensorType::TurbochargerSpeed);
extern FrequencySensor inputShaftSpeedSensor;
tsOutputChannels->issEdgeCounter = inputShaftSpeedSensor.eventCounter;
extern FrequencySensor vehicleSpeedSensor;
tsOutputChannels->vssEdgeCounter = vehicleSpeedSensor.eventCounter;
#if HW_CHECK_MODE
tsOutputChannels->hasCriticalError = 1;

View File

@ -53,6 +53,7 @@ void FrequencySensor::deInit() {
}
void FrequencySensor::onEdge(efitick_t nowNt) {
eventCounter++;
float frequency = 1 / m_edgeTimer.getElapsedSecondsAndReset(nowNt);
frequency = m_filter.filter(frequency);

View File

@ -1,3 +1,6 @@
/**
* @file frequency_sensor.h
*/
#include "functional_sensor.h"
#include "timer.h"
#include "biquad.h"
@ -13,6 +16,7 @@ public:
void onEdge(efitick_t nowNt);
int eventCounter = 0;
private:
Timer m_edgeTimer;
brain_pin_e m_pin = Gpio::Unassigned;

View File

@ -4,7 +4,7 @@
#include "frequency_sensor.h"
#include "input_shaft_speed_converter.h"
static FrequencySensor inputShaftSpeedSensor(SensorType::InputShaftSpeed, MS2NT(500));
FrequencySensor inputShaftSpeedSensor(SensorType::InputShaftSpeed, MS2NT(500));
static InputShaftSpeedConverter inputSpeedConverter;
void initInputShaftSpeedSensor() {

View File

@ -5,7 +5,7 @@
#include "vehicle_speed_converter.h"
// 0.05 filter parameter means averaging over ~20 sensor teeth
static FrequencySensor vehicleSpeedSensor(SensorType::VehicleSpeed, MS2NT(500));
FrequencySensor vehicleSpeedSensor(SensorType::VehicleSpeed, MS2NT(500));
static VehicleSpeedConverter vehicleSpeedConverter;
void initVehicleSpeedSensor() {