Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5536

MicroPython • Re: Aligning actions to a specific time-gap before a second

$
0
0
Pico MicroPython's time() does not include fractions, and the fractions from ticks_*() are not synchronized with the moments that the integer time increments. So I think you need to use time_ns() to calculate a sleep to the next whole second:

Code:

import utimewhile True:  utime.sleep_us(1000000 - utime.time_ns()//1000 % 1000000)  print(utime.time_ns())

Statistics: Posted by jojopi — Wed Apr 10, 2024 8:54 pm



Viewing all articles
Browse latest Browse all 5536

Trending Articles