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-01-26 14:33:04 -08:00
|
|
|
FrequencySensor(SensorType type, efitick_t timeoutPeriod, float filterParameter)
|
|
|
|
: FunctionalSensor(type, timeoutPeriod)
|
|
|
|
{
|
|
|
|
m_filter.configureLowpass(1, filterParameter);
|
|
|
|
}
|
2021-08-01 12:58:39 -07:00
|
|
|
|
2021-09-20 12:39:41 -07:00
|
|
|
void init(brain_pin_e pin);
|
2022-03-28 20:30:37 -07:00
|
|
|
void initIfValid(brain_pin_e pin, SensorConverter &converter);
|
2021-08-20 23:02:05 -07:00
|
|
|
void deInit();
|
2021-08-01 12:58:39 -07:00
|
|
|
|
|
|
|
void onEdge(efitick_t nowNt);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Timer m_edgeTimer;
|
2021-08-20 23:02:05 -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
|
|
|
};
|