Commit 0a00d50c authored by schneider's avatar schneider

fix(docs): Mention u-name and non-u-name modules in Documentation

parent 3e924664
Pipeline #4592 failed with stages
in 2 minutes and 6 seconds
......@@ -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
......
......@@ -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
------------
......
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
......
......@@ -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)
......
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment