From 3f6d05dce074ea263fa54630a0e90dd23c339ef6 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Fri, 9 Sep 2022 20:17:02 -0400 Subject: [PATCH] Proteus with SD card outside of vehicle looses a second #4557 --- firmware/controllers/algo/engine.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 5f1b75f8bc..e880043d7d 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -452,18 +452,18 @@ void Engine::efiWatchdog() { } if (engine->configBurnTimer.hasElapsedSec(5) && engineConfiguration->tempBooleanForVerySpecialLogic) { - static float mostRecentSecond = 0; + static efitimems_t mostRecentMs = 0; - float secondsNow = currentTimeMillis(); - if (mostRecentSecond != 0) { - float gapInSeconds = secondsNow - mostRecentSecond; - if (gapInSeconds > 500) { + float msNow = currentTimeMillis(); + if (msNow != 0) { + float gapInMs = msNow - mostRecentMs; + if (gapInMs > 500) { // float has 24 bits in the mantissa, which should allow up to 8 significant figures // we loose precision here after about 1,000,000 seconds which is 11 days - firmwareError(WATCH_DOG_SECONDS, "gap in seconds %f %f", secondsNow, gapInSeconds); + firmwareError(WATCH_DOG_SECONDS, "gap in time: now=%fsec gap=%f", msNow, gapInMs); } } - mostRecentSecond = secondsNow; + mostRecentMs = msNow; } if (!isSpinning) {