Wrong duration after Reset ?
# help
k
After HW Reset wrong runtime duration is calculated ?

https://cdn.discordapp.com/attachments/1151822098700972034/1151822099397234769/2023-09-14_12h06_35.png

https://cdn.discordapp.com/attachments/1151822098700972034/1151822099594358824/testDuration.toit https://cdn.discordapp.com/attachments/1151822098700972034/1151822100022186064/helpers.toit
=> jag container install APP src/testDuration.toit --device Bread-Board
e
The system clock was set with NTP after you recorded the initial time.
Copy code
main:
  start := Time.monotonic-us
  sleep --ms=1234
  end := Time.monotonic-us

  print
      Duration --us=(end - start)
If you don't want the time affected by the clock then you need to use
monotonic-us
like this.
Monotonic-us is not affected by the clock being set, it always goes forwards at the same speed.
(If you have an older Toit then it's called
monotonic_us
with an underscore.)
k
👍🏻 Thank you. (Learned something again)
e
🙂
2 Views