|
39 | 39 | //| """time and timing related functions
|
40 | 40 | //|
|
41 | 41 | //| The `time` module is a strict subset of the CPython `cpython:time` module. So, code
|
42 |
| -//| written in MicroPython will work in CPython but not necessarily the other |
| 42 | +//| using `time` written in CircuitPython will work in CPython but not necessarily the other |
43 | 43 | //| way around."""
|
44 | 44 | //|
|
45 | 45 | //| def monotonic() -> float:
|
46 | 46 | //| """Returns an always increasing value of time with an unknown reference
|
47 |
| -//| point. Only use it to compare against other values from `monotonic`. |
| 47 | +//| point. Only use it to compare against other values from `time.monotonic()`. |
| 48 | +//| |
| 49 | +//| On most boards, `time.monotonic()` converts a 64-bit millisecond tick counter |
| 50 | +//| to a float. Floats on most boards are encoded in 30 bits internally, with |
| 51 | +//| effectively 22 bits of precision. The float returned by `time.monotonic()` will |
| 52 | +//| accurately represent time to millisecond precision only up to 2**22 milliseconds |
| 53 | +//| (about 1.165 hours). |
| 54 | +//| At that point it will start losing precision, and its value will change only |
| 55 | +//| every second millisecond. At 2**23 milliseconds it will change every fourth |
| 56 | +//| millisecond, and so forth. |
| 57 | +//| |
| 58 | +//| If you need more consistent precision, use `time.monotonic_ns()`, or `supervisor.ticks_ms()`. |
| 59 | +//| `time.monotonic_ns()` is not available on boards without long integer support. |
| 60 | +//| `supervisor.ticks_ms()` uses intervals of a millisecond, but wraps around, and is not |
| 61 | +//| CPython-compatible. |
48 | 62 | //|
|
49 | 63 | //| :return: the current monotonic time
|
50 | 64 | //| :rtype: float"""
|
@@ -216,7 +230,8 @@ STATIC mp_obj_t time_time(void) {
|
216 | 230 | MP_DEFINE_CONST_FUN_OBJ_0(time_time_obj, time_time);
|
217 | 231 |
|
218 | 232 | //| def monotonic_ns() -> int:
|
219 |
| -//| """Return the time of the monotonic clock, cannot go backward, in nanoseconds. |
| 233 | +//| """Return the time of the monotonic clock, which cannot go backward, in nanoseconds. |
| 234 | +//| Not available on boards without long integer support. |
220 | 235 | //|
|
221 | 236 | //| :return: the current time
|
222 | 237 | //| :rtype: int"""
|
|
0 commit comments