only:reusing ExpAverage

This commit is contained in:
rusefillc 2024-12-16 23:40:39 -05:00
parent ab68587ce8
commit b8f40a9ee7
1 changed files with 5 additions and 9 deletions

View File

@ -22,7 +22,7 @@
*/ */
#include "pch.h" #include "pch.h"
#include "exp_average.h"
#if EFI_MAP_AVERAGING #if EFI_MAP_AVERAGING
@ -101,16 +101,12 @@ SensorResult MapAverager::submit(float volts) {
return result; return result;
} }
static ExpAverage expAverage;
// huh? why is this killing unit tests _linking_ only on WINDOWS?! PUBLIC_API_WEAK // huh? why is this killing unit tests _linking_ only on WINDOWS?! PUBLIC_API_WEAK
float filterMapValue(float value) { float filterMapValue(float value) {
static float state = 0; expAverage.setSmoothingFactor(engineConfiguration->mapExpAverageAlpha);
if (state == 0) { return expAverage.initOrAverage(value);
state = value;
return value;
}
float result = state + engineConfiguration->mapExpAverageAlpha * (value - state);
state = result;
return result;
} }
void MapAverager::stop() { void MapAverager::stop() {