proper fix for flex temp sensing

This commit is contained in:
Matthew Kennedy 2024-04-03 14:18:52 -07:00
parent 47d727fd9c
commit e4258d6b86
2 changed files with 9 additions and 8 deletions

View File

@ -44,6 +44,7 @@ or
- Improve performance with Lua CAN reception of a high volume of frames
- Displayed units in TunerStudio change when switching between volume vs. mass injector flow modes #42
- Make Toyota "3 Tooth Cam" decoder more robust #382
- Flex sensor-derived fuel temperature indication works properly
## December 2023 Release

View File

@ -15,14 +15,8 @@ static Biquad flexTempFilter;
static Timer flexFreq, flexPulse;
static void flexCallback(efitick_t nowNt, bool value) {
if (!value) {
float frequency = 1 / flexFreq.getElapsedSecondsAndReset(nowNt);
flexSensor.postRawValue(frequency, nowNt);
// Start timing pulse width on rising edge
flexPulse.reset(nowNt);
} else {
// End pulse timing on falling edge
if (value) {
// End pulse timing on rising edge
float pulseWidthUs = flexPulse.getElapsedUs(nowNt);
if (pulseWidthUs < 900) {
@ -36,6 +30,12 @@ static void flexCallback(efitick_t nowNt, bool value) {
tempC = flexTempFilter.filter(tempC);
flexFuelTemp.setValidValue(tempC, nowNt);
}
} else {
float frequency = 1 / flexFreq.getElapsedSecondsAndReset(nowNt);
flexSensor.postRawValue(frequency, nowNt);
// Start timing pulse width on falling edge
flexPulse.reset(nowNt);
}
}