2022-05-14 05:39:08 -07:00
|
|
|
/**
|
|
|
|
* @file frequency_sensor.h
|
|
|
|
*/
|
2021-08-01 12:58:39 -07:00
|
|
|
#include "functional_sensor.h"
|
|
|
|
#include "timer.h"
|
2022-01-26 14:33:04 -08:00
|
|
|
#include "biquad.h"
|
2021-08-01 12:58:39 -07:00
|
|
|
|
|
|
|
class FrequencySensor : public FunctionalSensor {
|
|
|
|
public:
|
2022-04-09 06:00:19 -07:00
|
|
|
FrequencySensor(SensorType type, efitick_t timeoutPeriod)
|
2022-01-26 14:33:04 -08:00
|
|
|
: FunctionalSensor(type, timeoutPeriod)
|
2022-04-09 06:00:19 -07:00
|
|
|
{ }
|
2021-08-01 12:58:39 -07:00
|
|
|
|
2022-04-09 06:00:19 -07:00
|
|
|
void initIfValid(brain_pin_e pin, SensorConverter &converter, float filterParameter);
|
2021-08-20 23:02:05 -07:00
|
|
|
void deInit();
|
2021-08-01 12:58:39 -07:00
|
|
|
|
|
|
|
void onEdge(efitick_t nowNt);
|
|
|
|
|
2022-05-14 05:39:08 -07:00
|
|
|
int eventCounter = 0;
|
2021-08-01 12:58:39 -07:00
|
|
|
private:
|
|
|
|
Timer m_edgeTimer;
|
2022-04-28 14:32:39 -07:00
|
|
|
brain_pin_e m_pin = Gpio::Unassigned;
|
2022-01-26 14:33:04 -08:00
|
|
|
|
|
|
|
Biquad m_filter;
|
2021-08-01 12:58:39 -07:00
|
|
|
};
|