Merge pull request #5443 from dhalbert/time.monotonic-doc
Add precision info to time.monotonic() documentation
This commit is contained in:
commit
e174de8ed3
@ -1900,10 +1900,13 @@ msgid ""
|
||||
msgstr ""
|
||||
|
||||
#: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c
|
||||
#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c
|
||||
msgid "Pins must be sequential"
|
||||
msgstr ""
|
||||
|
||||
#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c
|
||||
msgid "Pins must be sequential GPIO pins"
|
||||
msgstr ""
|
||||
|
||||
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c
|
||||
msgid "Pins must share PWM slice"
|
||||
msgstr ""
|
||||
@ -3943,6 +3946,7 @@ msgstr ""
|
||||
#: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h
|
||||
#: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h
|
||||
#: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h
|
||||
#: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h
|
||||
#: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h
|
||||
#: ports/espressif/boards/artisense_rd00/mpconfigboard.h
|
||||
#: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h
|
||||
@ -3961,6 +3965,7 @@ msgstr ""
|
||||
#: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h
|
||||
#: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h
|
||||
#: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h
|
||||
#: ports/espressif/boards/microdev_micro_c3/mpconfigboard.h
|
||||
#: ports/espressif/boards/microdev_micro_s2/mpconfigboard.h
|
||||
#: ports/espressif/boards/morpheans_morphesp-240/mpconfigboard.h
|
||||
#: ports/espressif/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.h
|
||||
|
@ -68,7 +68,7 @@ void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencode
|
||||
pins[1] = MP_OBJ_FROM_PTR(pin_a);
|
||||
self->swapped = false;
|
||||
if (!common_hal_rp2pio_pins_are_sequential(2, pins)) {
|
||||
mp_raise_RuntimeError(translate("Pins must be sequential"));
|
||||
mp_raise_RuntimeError(translate("Pins must be sequential GPIO pins"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,12 +39,26 @@
|
||||
//| """time and timing related functions
|
||||
//|
|
||||
//| The `time` module is a strict subset of the CPython `cpython:time` module. So, code
|
||||
//| written in MicroPython will work in CPython but not necessarily the other
|
||||
//| using `time` written in CircuitPython will work in CPython but not necessarily the other
|
||||
//| way around."""
|
||||
//|
|
||||
//| def monotonic() -> float:
|
||||
//| """Returns an always increasing value of time with an unknown reference
|
||||
//| point. Only use it to compare against other values from `monotonic`.
|
||||
//| point. Only use it to compare against other values from `time.monotonic()`.
|
||||
//|
|
||||
//| On most boards, `time.monotonic()` converts a 64-bit millisecond tick counter
|
||||
//| to a float. Floats on most boards are encoded in 30 bits internally, with
|
||||
//| effectively 22 bits of precision. The float returned by `time.monotonic()` will
|
||||
//| accurately represent time to millisecond precision only up to 2**22 milliseconds
|
||||
//| (about 1.165 hours).
|
||||
//| At that point it will start losing precision, and its value will change only
|
||||
//| every second millisecond. At 2**23 milliseconds it will change every fourth
|
||||
//| millisecond, and so forth.
|
||||
//|
|
||||
//| If you need more consistent precision, use `time.monotonic_ns()`, or `supervisor.ticks_ms()`.
|
||||
//| `time.monotonic_ns()` is not available on boards without long integer support.
|
||||
//| `supervisor.ticks_ms()` uses intervals of a millisecond, but wraps around, and is not
|
||||
//| CPython-compatible.
|
||||
//|
|
||||
//| :return: the current monotonic time
|
||||
//| :rtype: float"""
|
||||
@ -216,7 +230,8 @@ STATIC mp_obj_t time_time(void) {
|
||||
MP_DEFINE_CONST_FUN_OBJ_0(time_time_obj, time_time);
|
||||
|
||||
//| def monotonic_ns() -> int:
|
||||
//| """Return the time of the monotonic clock, cannot go backward, in nanoseconds.
|
||||
//| """Return the time of the monotonic clock, which cannot go backward, in nanoseconds.
|
||||
//| Not available on boards without long integer support.
|
||||
//|
|
||||
//| :return: the current time
|
||||
//| :rtype: int"""
|
||||
|
Loading…
Reference in New Issue
Block a user