diff options
Diffstat (limited to 'docs/library')
-rw-r--r-- | docs/library/index.rst | 23 | ||||
-rw-r--r-- | docs/library/pyb.SPI.rst | 18 | ||||
-rw-r--r-- | docs/library/struct.rst | 25 |
3 files changed, 52 insertions, 14 deletions
diff --git a/docs/library/index.rst b/docs/library/index.rst index 8a93b8c4d0..eb6a466255 100644 --- a/docs/library/index.rst +++ b/docs/library/index.rst @@ -4,6 +4,11 @@ Micro Python libraries Python standard libraries ------------------------- +The following standard Python libraries are built in to Micro Python. + +For additional libraries, please download them from the `micropython-lib repository +<https://github.com/micropython/micropython-lib>`_. + .. toctree:: :maxdepth: 1 @@ -12,11 +17,23 @@ Python standard libraries math.rst os.rst select.rst + struct.rst sys.rst time.rst -Micro Python reduced libraries ------------------------------- +Python micro-libraries +---------------------- + +The following standard Python libraries have been "micro-ified" to fit in with +the philosophy of Micro Python. They provide the core functionality of that +module and are intended to be a drop-in replacement for the standard Python +library. + +The modules are available by their u-name, and also by their non-u-name. The +non-u-name can be overridden by a file of that name in your package path. +For example, ``import json`` will first search for a file ``json.py`` or +directory ``json`` and load that package if it is found. If nothing is found, +it will fallback to loading the built-in ``ujson`` module. .. toctree:: :maxdepth: 1 @@ -28,6 +45,8 @@ Micro Python reduced libraries Libraries specific to the pyboard --------------------------------- +The following libraries are specific to the pyboard. + .. toctree:: :maxdepth: 2 diff --git a/docs/library/pyb.SPI.rst b/docs/library/pyb.SPI.rst index 7ad3a90e2d..7b765e6b06 100644 --- a/docs/library/pyb.SPI.rst +++ b/docs/library/pyb.SPI.rst @@ -93,18 +93,12 @@ Methods Constants --------- -.. data:: LSB +.. data:: SPI.MASTER +.. data:: SPI.SLAVE - set the first bit to LSB + for initialising the SPI bus to master or slave mode -.. data:: MASTER +.. data:: SPI.LSB +.. data:: SPI.MSB - for initialising the bus to master mode - -.. data:: MSB - - set the first bit to MSB - -.. data:: SLAVE - - for initialising the bus to slave mode + set the first bit to be the least or most significant bit diff --git a/docs/library/struct.rst b/docs/library/struct.rst new file mode 100644 index 0000000000..71ee5c9b70 --- /dev/null +++ b/docs/library/struct.rst @@ -0,0 +1,25 @@ +:mod:`struct` -- pack and unpack primitive data types +===================================================== + +.. module:: struct + :synopsis: pack and unpack primitive data types + +See `Python struct <https://docs.python.org/3/library/struct.html>`_ for more +information. + +Functions +--------- + +.. function:: calcsize(fmt) + + Return the number of bytes needed to store the given ``fmt``. + +.. function:: pack(fmt, v1, v2, ...) + + Pack the values ``v1``, ``v2``, ... according to the format string ``fmt``. + The return value is a bytes object encoding the values. + +.. function:: unpack(fmt, data) + + Unpack from the ``data`` according to the format string ``fmt``. + The return value is a tuple of the unpacked values. |