Skip to content

Commit dcdf463

Browse files
committed
Update documentation
1 parent c29aa8c commit dcdf463

File tree

240 files changed

+7436
-5965
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

240 files changed

+7436
-5965
lines changed

docs/_sources/genrst/builtin_types.rst.txt

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
Builtin types
44
=============
5-
Generated Thu 05 Sep 2024 00:47:45 UTC
5+
Generated Sat 01 Feb 2025 20:08:46 UTC
66

77
Exception
88
---------
@@ -355,6 +355,37 @@ Sample code::
355355
| 84 | /bin/sh: 1: ../ports/unix/build-standard/micropython: not found |
356356
+-------------+---------------------------------------------------------------------+
357357

358+
.. _cpydiff_types_int_to_bytes:
359+
360+
``to_bytes`` method doesn't implement signed parameter.
361+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
362+
363+
**Cause:** The ``signed`` keyword-only parameter is not implemented for ``int.to_bytes()``.
364+
365+
When the integer is negative, MicroPython behaves the same as CPython ``int.to_bytes(..., signed=True)``
366+
367+
When the integer is non-negative, MicroPython behaves the same as CPython ``int.to_bytes(..., signed=False)``.
368+
369+
(The difference is subtle, but in CPython a positive integer converted with ``signed=True`` may require one byte more in the output length, in order to fit the 0 sign bit.)
370+
371+
**Workaround:** Take care when calling ``to_bytes()`` on an integer value which may be negative.
372+
373+
Sample code::
374+
375+
376+
x = -1
377+
print(x.to_bytes(1, "big"))
378+
379+
+-----------------------------------------------------------+---------------------------------------------------------------------+
380+
| CPy output: | uPy output: |
381+
+-----------------------------------------------------------+---------------------------------------------------------------------+
382+
| :: | :: |
383+
| | |
384+
| Traceback (most recent call last): | /bin/sh: 1: ../ports/unix/build-standard/micropython: not found |
385+
| File "<stdin>", line 16, in <module> | |
386+
| OverflowError: can't convert negative int to unsigned | |
387+
+-----------------------------------------------------------+---------------------------------------------------------------------+
388+
358389
list
359390
----
360391

docs/_sources/genrst/core_language.rst.txt

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
33
Core language
44
=============
5-
Generated Thu 05 Sep 2024 00:47:45 UTC
5+
Generated Sat 01 Feb 2025 20:08:46 UTC
66

77
.. _cpydiff_core_fstring_concat:
88

9-
f-strings don't support concatenation with adjacent literals if the adjacent literals contain braces or are f-strings
10-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9+
f-strings don't support concatenation with adjacent literals if the adjacent literals contain braces
10+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1111

1212
**Cause:** MicroPython is optimised for code space.
1313

14-
**Workaround:** Use the + operator between literal strings when either or both are f-strings
14+
**Workaround:** Use the + operator between literal strings when they are not both f-strings
1515

1616
Sample code::
1717

@@ -21,7 +21,6 @@ Sample code::
2121
print(f"{x}" "ab") # works
2222
print("a{}a" f"{x}") # fails
2323
print(f"{x}" "a{}b") # fails
24-
print(f"{x}" f"{y}") # fails
2524

2625
+-------------+---------------------------------------------------------------------+
2726
| CPy output: | uPy output: |
@@ -32,7 +31,6 @@ Sample code::
3231
| 1ab | |
3332
| a{}a1 | |
3433
| 1a{}b | |
35-
| 12 | |
3634
+-------------+---------------------------------------------------------------------+
3735

3836
.. _cpydiff_core_fstring_parser:
@@ -59,26 +57,6 @@ Sample code::
5957
| hello ] world | |
6058
+-------------------+---------------------------------------------------------------------+
6159

62-
.. _cpydiff_core_fstring_raw:
63-
64-
Raw f-strings are not supported
65-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
66-
67-
**Cause:** MicroPython is optimised for code space.
68-
69-
Sample code::
70-
71-
72-
rf"hello"
73-
74-
+-------------+---------------------------------------------------------------------+
75-
| CPy output: | uPy output: |
76-
+-------------+---------------------------------------------------------------------+
77-
| | :: |
78-
| | |
79-
| | /bin/sh: 1: ../ports/unix/build-standard/micropython: not found |
80-
+-------------+---------------------------------------------------------------------+
81-
8260
.. _cpydiff_core_fstring_repr:
8361

8462
f-strings don't support !a conversions
@@ -209,6 +187,52 @@ Sample code::
209187
| NameError: name '_Foo__print_string' is not defined | |
210188
+---------------------------------------------------------+---------------------------------------------------------------------+
211189

190+
.. _cpydiff_core_class_super_init:
191+
192+
When inheriting native types, calling a method in ``__init__(self, ...)`` before ``super().__init__()`` raises an ``AttributeError`` (or segfaults if ``MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG`` is not enabled).
193+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
194+
195+
**Cause:** MicroPython does not have separate ``__new__`` and ``__init__`` methods in native types.
196+
197+
**Workaround:** Call ``super().__init__()`` first.
198+
199+
Sample code::
200+
201+
202+
203+
class L1(list):
204+
def __init__(self, a):
205+
self.append(a)
206+
207+
208+
try:
209+
L1(1)
210+
print("OK")
211+
except AttributeError:
212+
print("AttributeError")
213+
214+
215+
class L2(list):
216+
def __init__(self, a):
217+
super().__init__()
218+
self.append(a)
219+
220+
221+
try:
222+
L2(1)
223+
print("OK")
224+
except AttributeError:
225+
print("AttributeError")
226+
227+
+-------------+---------------------------------------------------------------------+
228+
| CPy output: | uPy output: |
229+
+-------------+---------------------------------------------------------------------+
230+
| :: | :: |
231+
| | |
232+
| OK | /bin/sh: 1: ../ports/unix/build-standard/micropython: not found |
233+
| OK | |
234+
+-------------+---------------------------------------------------------------------+
235+
212236
.. _cpydiff_core_class_supermultiple:
213237

214238
When inheriting from multiple classes super() only calls one class

docs/_sources/genrst/modules.rst.txt

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
Modules
44
=======
5-
Generated Thu 05 Sep 2024 00:47:45 UTC
5+
Generated Sat 01 Feb 2025 20:08:46 UTC
66

77
.. Preamble section inserted into generated output
88
@@ -179,31 +179,6 @@ Sample code::
179179
| 42 | /bin/sh: 1: ../ports/unix/build-standard/micropython: not found |
180180
+-------------+---------------------------------------------------------------------+
181181

182-
deque
183-
-----
184-
185-
.. _cpydiff_modules_deque:
186-
187-
Deque not implemented
188-
~~~~~~~~~~~~~~~~~~~~~
189-
190-
**Workaround:** Use regular lists. micropython-lib has implementation of collections.deque.
191-
192-
Sample code::
193-
194-
import collections
195-
196-
D = collections.deque()
197-
print(D)
198-
199-
+---------------+---------------------------------------------------------------------+
200-
| CPy output: | uPy output: |
201-
+---------------+---------------------------------------------------------------------+
202-
| :: | :: |
203-
| | |
204-
| deque([]) | /bin/sh: 1: ../ports/unix/build-standard/micropython: not found |
205-
+---------------+---------------------------------------------------------------------+
206-
207182
json
208183
----
209184

@@ -310,13 +285,13 @@ Sample code::
310285
x = random.getrandbits(64)
311286
print("{}".format(x))
312287

313-
+--------------------------+---------------------------------------------------------------------+
314-
| CPy output: | uPy output: |
315-
+--------------------------+---------------------------------------------------------------------+
316-
| :: | :: |
317-
| | |
318-
| 13234793640459878723 | /bin/sh: 1: ../ports/unix/build-standard/micropython: not found |
319-
+--------------------------+---------------------------------------------------------------------+
288+
+-------------------------+---------------------------------------------------------------------+
289+
| CPy output: | uPy output: |
290+
+-------------------------+---------------------------------------------------------------------+
291+
| :: | :: |
292+
| | |
293+
| 5659439657125183944 | /bin/sh: 1: ../ports/unix/build-standard/micropython: not found |
294+
+-------------------------+---------------------------------------------------------------------+
320295

321296
.. _cpydiff_modules_random_randint:
322297

docs/_sources/genrst/syntax.rst.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
Syntax
44
======
5-
Generated Thu 05 Sep 2024 00:47:45 UTC
5+
Generated Sat 01 Feb 2025 20:08:46 UTC
66

77
.. _cpydiff_syntax_arg_unpacking:
88

docs/_sources/library/builtins.rst.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ Functions and types
8282
In MicroPython, `byteorder` parameter must be positional (this is
8383
compatible with CPython).
8484

85+
.. note:: The optional ``signed`` kwarg from CPython is not supported.
86+
MicroPython currently converts negative integers as signed,
87+
and positive as unsigned. (:ref:`Details <cpydiff_types_int_to_bytes>`.)
88+
8589
.. function:: isinstance()
8690

8791
.. function:: issubclass()

docs/_sources/library/index.rst.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ the following libraries.
9595
:maxdepth: 1
9696

9797
bluetooth.rst
98-
btree.rst
9998
cryptolib.rst
10099
deflate.rst
101100
machine.rst
@@ -105,7 +104,7 @@ the following libraries.
105104
uctypes.rst
106105
mutex.rst
107106
uping.rst
108-
urequests.rst
107+
requests.rst
109108
vfs.rst
110109

111110
Libraries specific to the OpenMV Cam
@@ -126,6 +125,7 @@ The following libraries are specific to the OpenMV Cam.
126125
omv.audio.rst
127126
omv.display.rst
128127
omv.fir.rst
128+
omv.tof.rst
129129
omv.tv.rst
130130
omv.cpufreq.rst
131131
omv.buzzer.rst
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
.. currentmodule:: machine
2+
.. _machine.LED:
3+
4+
class LED -- LED Control
5+
========================
6+
7+
The LED class provides an interface to control the on-board LED.
8+
9+
Example usage::
10+
11+
from machine import LED
12+
13+
r = LED("LED_RED")
14+
g = LED("LED_GREEN")
15+
b = LED("LED_BLUE")
16+
17+
r.on()
18+
g.off()
19+
b.toggle()
20+
21+
Constructors
22+
------------
23+
24+
.. class:: LED(pin_name) -> LED
25+
26+
Access the LED associated with a source identified by *pin_name*. This
27+
``pin_name`` may be a string (usually specifying a color), a
28+
:ref:`Pin <machine.Pin>` object, or other value supported by the
29+
underlying machine.
30+
31+
Methods
32+
-------
33+
34+
.. method:: LED.boardname() -> str
35+
36+
Returns the name of the board.
37+
38+
.. method:: LED.on() -> None
39+
40+
Turns the LED on.
41+
42+
.. method:: LED.() -> None
43+
44+
Turns the LED off.
45+
46+
.. method:: LED.toggle() -> None
47+
48+
Toggles the LED state.
49+
50+
.. method:: LED.value(v=None) -> int
51+
52+
If ``v`` is given, sets the LED to the given value. If ``v`` is not given,
53+
returns the current LED value.

docs/_sources/library/machine.Pin.rst.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,12 @@ The following methods are not part of the core Pin API and only implemented on c
238238

239239
Availability: cc3200 port.
240240

241+
.. method:: Pin.toggle()
242+
243+
Toggle output pin from "0" to "1" or vice-versa.
244+
245+
Availability: mimxrt, samd, rp2 ports.
246+
241247
Constants
242248
---------
243249

0 commit comments

Comments
 (0)