diff --git a/firmware/controllers/map_averaging.cpp b/firmware/controllers/map_averaging.cpp index b1af620e38..502e6a3048 100644 --- a/firmware/controllers/map_averaging.cpp +++ b/firmware/controllers/map_averaging.cpp @@ -280,6 +280,7 @@ static void mapAveragingTriggerCallback(trigger_event_e ckpEventType, angle_t samplingStart = ENGINE(engineState.mapAveragingStart[i]); angle_t samplingDuration = ENGINE(engineState.mapAveragingDuration); + assertAngleRange(samplingDuration, "samplingDuration", CUSTOM_ERR_6563); if (samplingDuration <= 0) { warning(CUSTOM_MAP_ANGLE_PARAM, "map sampling angle should be positive"); return; diff --git a/firmware/util/math/interpolation.cpp b/firmware/util/math/interpolation.cpp index a36fb01963..faab1aa0bd 100644 --- a/firmware/util/math/interpolation.cpp +++ b/firmware/util/math/interpolation.cpp @@ -101,6 +101,14 @@ float FastInterpolation::getValue(float x) const { * @note For example, "interpolateMsg("", engineConfiguration.tpsMin, 0, engineConfiguration.tpsMax, 100, adc);" */ float interpolateMsg(const char *msg, float x1, float y1, float x2, float y2, float x) { + if (cisnan(x1) || cisnan(x2) || cisnan(y1) || cisnan(y2)) { + warning(CUSTOM_INTEPOLATE_ERROR, "interpolate%s: why param", msg); + return NAN; + } + if (cisnan(x)) { + warning(CUSTOM_INTEPOLATE_ERROR, "interpolate%s: why X", msg); + return NAN; + } // todo: double comparison using EPS if (x1 == x2) { /** @@ -114,6 +122,10 @@ float interpolateMsg(const char *msg, float x1, float y1, float x2, float y2, fl // a*x2 + b = y2 // efiAssertVoid(CUSTOM_ERR_ASSERT_VOID, x1 != x2, "no way we can interpolate"); float a = INTERPOLATION_A(x1, y1, x2, y2); + if (cisnan(a)) { + warning(CUSTOM_INTEPOLATE_ERROR, "interpolate%s: why a", msg); + return NAN; + } float b = y1 - a * x1; float result = a * x + b; #if DEBUG_FUEL