Skip to content

Commit

Permalink
Adjust step factor at getTime function
Browse files Browse the repository at this point in the history
  • Loading branch information
lo1ol committed Nov 11, 2024
1 parent 8c7b2c9 commit 4b18b1d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
13 changes: 10 additions & 3 deletions src/Tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int16_t>(time) / factor) * factor);
Expand Down

0 comments on commit 4b18b1d

Please sign in to comment.