diff --git a/Documentation/pycardium/bhi160.rst b/Documentation/pycardium/bhi160.rst index 1aaa362e0f238177fe59e2310f0659fd8b51ac89..97105387fd2e2e111eae4ed00f8589f3b01c4fad 100644 --- a/Documentation/pycardium/bhi160.rst +++ b/Documentation/pycardium/bhi160.rst @@ -28,18 +28,18 @@ The coordinate system of the BHI160 sensor data looks like this: .. code-block:: python import bhi160 - import utime + import time bhi = bhi160.BHI160Orientation() while True: samples = bhi.read() if len(samples) == 0: - utime.sleep(0.25) + time.sleep(0.25) continue # print the latest sample print(samples[-1]) - utime.sleep(0.25) + time.sleep(0.25) Orientation diff --git a/Documentation/pycardium/bme680.rst b/Documentation/pycardium/bme680.rst index 812173a625593f879580e196acff741cfcae13cf..9bdef0245e4fe81f7317adf495a44d80f17c7c10 100644 --- a/Documentation/pycardium/bme680.rst +++ b/Documentation/pycardium/bme680.rst @@ -8,7 +8,7 @@ Allows access to environmental data of card10's surroundings. .. code-block:: python - import bme680, utime + import bme680, time with bme680.Bme680() as environment: while True: @@ -19,7 +19,7 @@ Allows access to environmental data of card10's surroundings. print("Pressure: {:10.2f} hPa".format(d.pressure)) print("Gas Resistance: {:10.2f} ā¦".format(d.resistance)) - utime.sleep(1) + time.sleep(1) Sensor Class ------------ diff --git a/Documentation/pycardium/stdlib.rst b/Documentation/pycardium/stdlib.rst index 1d1b7af492d00fde5d79a4601e233c277bfd45a2..92d304e9ce469c81cdcf16265bacbbd312973971 100644 --- a/Documentation/pycardium/stdlib.rst +++ b/Documentation/pycardium/stdlib.rst @@ -1,7 +1,17 @@ MicroPython Standard Library ============================ -Pycardium contains some modules from the MicroPython standard library. These -are: +Pycardium contains some modules from the MicroPython standard library. + +Some modules below use a standard Python name, but prefixed with āuā, +e.g. ujson instead of json. This is to signify that such a module is a +micro-library, i.e. implements only a subset of CPython module +functionality. Please refer to the official `MicroPython docs`_ for an +explanation why. + +All u-name modules can also be imported using their non-u-name. E.g. +``import utime`` and import ``import time`` will both work. + +.. _MicroPython docs: http://docs.micropython.org/en/latest/library/index.html#python-standard-libraries-and-micro-libraries .. py:module:: framebuf diff --git a/Documentation/pycardium/utime.rst b/Documentation/pycardium/utime.rst index 03d333b20e85758b31871ada3b9371f85ef95d9f..0f5eff9f38b5408611b8da9dcd5126e763880795 100644 --- a/Documentation/pycardium/utime.rst +++ b/Documentation/pycardium/utime.rst @@ -8,6 +8,9 @@ CPython but wouldn't fit anywhere else in our implementation. Most prominently, this is the :py:func:`utime.alarm` function for setting an RTC alarm. +Like all other u-name modules, ``utime`` can also imported using the standard +``import time`` statement. + .. |time| replace:: ``time`` .. _time: https://docs.python.org/3/library/time.html @@ -135,13 +138,13 @@ alarm. .. code-block:: python - import utime + import time def minute_timer(x): - current = utime.time() + current = time.time() print("Current: " + str(current)) alarm = (current // 60 + 1) * 60 - utime.alarm(alarm, minute_timer) + time.alarm(alarm, minute_timer) minute_timer(None) @@ -150,13 +153,13 @@ alarm. .. code-block:: python - import interrupt, utime + import interrupt, time def 5_second_timer(x): - current = utime.time() + current = time.time() print("Current: " + str(current)) alarm = (current // 10) * 10 + 5 - utime.alarm(alarm) + time.alarm(alarm) # This time, we need to register and enable the callback manually interrupt.set_callback(interrupt.RTC_ALARM, 5_second_timer) diff --git a/Documentation/pycardium/ws2812.rst b/Documentation/pycardium/ws2812.rst index fe36f95926d813b07ed6bce395ee912d0f168811..00eba24c54644d1f0cd91d1fd696ac68575f7328 100644 --- a/Documentation/pycardium/ws2812.rst +++ b/Documentation/pycardium/ws2812.rst @@ -19,7 +19,7 @@ The ``ws2812`` module controls LEDs of the WS2812 type. Just as the ``leds`` mod .. code-block:: python - import color, utime, ws2812, gpio + import color, time, ws2812, gpio i = 0 while True: @@ -28,6 +28,6 @@ The ``ws2812`` module controls LEDs of the WS2812 type. Just as the ``leds`` mod col3 = color.from_hsv((i + 40) % 360, 1.0, 0.1) ws2812.set_all(gpio.WRISTBAND_2, [col1, col2, col3]) i += 1 - utime.sleep_ms(10) + time.sleep_ms(10) .. versionadded:: 1.10