2021-08-03 19:05:01 -07:00
|
|
|
#include "pch.h"
|
|
|
|
|
2021-01-05 04:57:26 -08:00
|
|
|
#include "init.h"
|
2021-08-01 12:58:39 -07:00
|
|
|
#include "frequency_sensor.h"
|
2021-08-01 20:21:53 -07:00
|
|
|
#include "flex_sensor.h"
|
2021-08-01 12:58:39 -07:00
|
|
|
|
2022-01-26 14:33:04 -08:00
|
|
|
// 0.01 means filter bandwidth of ~1hz with ~100hz sensor
|
|
|
|
static FrequencySensor flexSensor(SensorType::FuelEthanolPercent, MS2NT(500), 0.01f);
|
2021-08-01 12:58:39 -07:00
|
|
|
static FlexConverter converter;
|
2021-01-05 14:13:56 -08:00
|
|
|
|
2021-01-05 04:57:26 -08:00
|
|
|
// https://rusefi.com/forum/viewtopic.php?p=37452&sid=829804c90d5b2e1fecd1b900cf1b1811#p37452
|
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void initFlexSensor() {
|
2021-11-17 00:54:21 -08:00
|
|
|
auto pin = engineConfiguration->flexSensorPin;
|
2021-01-05 04:57:26 -08:00
|
|
|
|
|
|
|
// Nothing to do if no sensor configured
|
2021-01-08 17:01:26 -08:00
|
|
|
if (!isBrainPinValid(pin)) {
|
2021-01-05 04:57:26 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-08-01 12:58:39 -07:00
|
|
|
flexSensor.setFunction(converter);
|
2021-09-20 12:39:41 -07:00
|
|
|
flexSensor.init(pin);
|
2021-01-05 14:13:56 -08:00
|
|
|
flexSensor.Register();
|
2021-01-05 04:57:26 -08:00
|
|
|
}
|
2021-08-20 23:02:05 -07:00
|
|
|
|
|
|
|
void deInitFlexSensor() {
|
|
|
|
flexSensor.deInit();
|
|
|
|
}
|