![]() If you need higher precision, use ticks_ms() and ticks_us() functions, if you need calendar time, localtime() without an argument is a better choice. If you want to develop portable MicroPython application, you should not rely on this function to provide higher than second precision. If an RTC is not set, this function returns number of seconds since power up or reset). Returns the number of seconds, as an integer, since the Epoch, assuming that underlying RTC is set. If time.ticks_diff(start, time.ticks_us()) > 500: The expected usage pattern is implementing event polling with timeout: # Wait for GPIO pin to be asserted, but at most 500us This function should not be used to measure arbitrarily long periods of time (because ticks_*() functions wrap around and usually would have short period). ![]() "old" value should actually precede "new" value in time, or result is undefined. The value returned by these functions may wrap around at any time, so directly subtracting them is not supported. Measure period between consecutive calls to ticks_ms(), ticks_us(), or ticks_cpu(). Just like ticks_ms above, but in microseconds. utime.sleep_us(us)ĭelay for given number of microseconds, should be positive or 0 utime.ticks_ms() utime.sleep_ms(ms)ĭelay for given number of milliseconds, should be positive or 0. Note that other MicroPython ports may not accept floating-point argument, for compatibility with them use sleep_ms() and sleep_us() functions. seconds can be a floating-point number to sleep for a fractional number of seconds. It returns an integer which is the number of seconds since Jan 1, 2000. It’s argument is a full 8-tuple which expresses a time as per localtime. If secs is not provided or None, the current time from the RTC is used. Like gmtime() but converts to local time. year includes the century (for example 2014).Functions utime.gmtime()Ĭonvert a time expressed in seconds since the Epoch (see above) into an 8-tuple which contains: (year, month, mday, hour, minute, second, weekday, yearday) If secs is not provided or None, then the current time from the RTC is used. If actual calendar time is not maintained with a system/MicroPython RTC, functions below which require reference to current absolute time may behave not as expected. Set manually by a user on each power-up (many boards then maintain RTC time across hard resets, though some may require setting it again in such case). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |