![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
run this here
Dependencies: Hexi_KW40Z Hexi_OLED_SSD1351
Diff: main.cpp
- Revision:
- 4:1ae9f76749b9
- Parent:
- 3:f34bbdea0786
diff -r f34bbdea0786 -r 1ae9f76749b9 main.cpp --- a/main.cpp Tue Jun 12 00:27:26 2018 +0000 +++ b/main.cpp Thu Jun 14 19:39:23 2018 +0000 @@ -20,7 +20,7 @@ const float interval = 0.1; int numTicks = 0; int prevNumTicks = 0; -float timingError = 0.0; +float intervalError = 0.0; char prevTime[11] = "00:00:00.0"; char displayTime[11] = "00:00:00.0"; @@ -42,7 +42,6 @@ EventQueue receiveTimeQueue; int main() { -// pc.printf("main started!!\r\n"); kw40z_device.attach_alert(&AlertReceived); @@ -140,12 +139,13 @@ // time and hopefully it will be more accurate. void updateError() { - float secsToAdd = interval * prevNumTicks + timingError; + // + float secsToAdd = prevNumTicks * (interval + intervalError); float T1 = currTimeSecs(displayTime); float T0 = currTimeSecs(prevTime); - timingError += (T1 - (T0+secsToAdd)) / prevNumTicks; + intervalError = (T1 - (T0+secsToAdd)) / prevNumTicks; } int numPrints = 20; @@ -156,7 +156,7 @@ void updateDisplayString() { numTicks++; - float offset = interval * numTicks + timingError; + float offset = numTicks * (interval + intervalError); addSecondsToCurrentTime(prevTime, displayTime, offset);