Quantcast
Viewing all articles
Browse latest Browse all 651

Angular Clock bug at 56 minutes past the hour

@ambanmba anything new from you on this topic? Sorry for the long delay on my end. I've been studying to code and chatting with the original author off and on. I think it's the offsets basically causing a wrap-around on the high end. Your getting some pretty significant offsets there on the minutes meter (offset of 16 for both 30 and 45 minutes).

So here's what happens. On this line, when tm.Minute equals 56, map(tm.Minute,0,59,0,255) results in a value of 242. Then getOffset(MINUTES,tm.Minute) results in a value of 16 (based on your Serial output). The sum of 242 and 16 equals 258, which happily gets passed on to setMeter here. analogWrite doesn't understand values greater than 255, and truncates the value to 8-bits (which is the same as a modulo 256 operation. So analogWrite(meter, 258) is exactly the same thing as analogWrite(meter, 2), which probably doesn't look so different from pointing at 0 minutes.

Miinutes = 57 yields 262 for the value, which is congruent with 6 for analogWrite.
Minutes = 58 yields 266 for the value, which is congruent with 10 for analogWrite.
Minutes = 59 yields 271 for the value, which is congruent with 15 for analogWrite.

So I think I understand why it's happening. I still don't quite have the solution to how to fix it, but knowing is half the battle!


Viewing all articles
Browse latest Browse all 651

Trending Articles