From 4b18b1d8c82cb637b4ec6ed16cd85ff345b56d1a Mon Sep 17 00:00:00 2001 From: Petr Mikhalicin Date: Mon, 11 Nov 2024 12:56:35 +0500 Subject: [PATCH] Adjust step factor at getTime function --- src/Time.cpp | 2 +- src/Tools.cpp | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Time.cpp b/src/Time.cpp index 2736a5f..b1d5b66 100644 --- a/src/Time.cpp +++ b/src/Time.cpp @@ -8,7 +8,7 @@ void Time::getFormatedTime(char* buf, bool accurate, bool addZero) const { int16_t sec = secs(); uint8_t dec = tenth(); - if (!accurate && sec > 9) { + if (!accurate && sec > 19) { itoa(sec + (dec > 4), buf, 10); return; } diff --git a/src/Tools.cpp b/src/Tools.cpp index c23976d..465e28f 100644 --- a/src/Tools.cpp +++ b/src/Tools.cpp @@ -56,15 +56,22 @@ bool getTime(Time& time, bool smooth) { Time oldTime = time; + // Values are changing with accuracy 1/12 stop + // You can check accuracy range by this formule: + // t*(2**(1/12)-1) int16_t factor; - if ((time + shift) < 5_s) + if ((time + shift) < 10_s) factor = 1; - else if ((time + shift) < 10_s) + else if ((time + shift) < 20_s) factor = 5; else if ((time + shift) < 100_s) factor = 10; - else + else if ((time + shift) < 200_s) + factor = 50; + else if ((time + shift) < 1000_s) factor = 100; + else + factor = 500; time += shift * factor; time = Time((static_cast(time) / factor) * factor);