Skip to content

Commit 87d3740

Browse files
committed
Merge tag 'v1.16'
2 parents a4d6452 + 7c51cb2 commit 87d3740

File tree

194 files changed

+5374
-603
lines changed

Some content is hidden

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

194 files changed

+5374
-603
lines changed

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# tools/gen-cpydiff.py: Fix formatting of doc strings for new Black.
2+
0f78c36c5aa458a954eed39a46942209107a553e
3+
14
# tests/run-tests.py: Reformat with Black.
25
2a38d7103672580882fb621a5b76e8d26805d593
36

.github/workflows/ports_mimxrt.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: mimxrt port
2+
3+
on:
4+
push:
5+
pull_request:
6+
paths:
7+
- '.github/workflows/*.yml'
8+
- 'tools/**'
9+
- 'py/**'
10+
- 'extmod/**'
11+
- 'lib/**'
12+
- 'drivers/**'
13+
- 'ports/mimxrt/**'
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-20.04
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: Install packages
21+
run: source tools/ci.sh && ci_mimxrt_setup
22+
- name: Build
23+
run: source tools/ci.sh && ci_mimxrt_build

docs/esp8266/tutorial/ssd1306.rst

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
.. _ssd1306:
2+
3+
Using a SSD1306 OLED display
4+
============================
5+
6+
The SSD1306 OLED display uses either a SPI or I2C interface and comes in a variety of
7+
sizes (128x64, 128x32, 72x40, 64x48) and colours (white, yellow, blue, yellow + blue).
8+
9+
Hardware SPI interface::
10+
11+
from machine import Pin, SPI
12+
import ssd1306
13+
14+
hspi = SPI(1) # sck=14 (scl), mosi=13 (sda), miso=12 (unused)
15+
16+
dc = Pin(4) # data/command
17+
rst = Pin(5) # reset
18+
cs = Pin(15) # chip select, some modules do not have a pin for this
19+
20+
display = ssd1306.SSD1306_SPI(128, 64, hspi, dc, rst, cs)
21+
22+
Software SPI interface::
23+
24+
from machine import Pin, SoftSPI
25+
import ssd1306
26+
27+
spi = SoftSPI(baudrate=500000, polarity=1, phase=0, sck=Pin(14), mosi=Pin(13), miso=Pin(12))
28+
29+
dc = Pin(4) # data/command
30+
rst = Pin(5) # reset
31+
cs = Pin(15) # chip select, some modules do not have a pin for this
32+
33+
display = ssd1306.SSD1306_SPI(128, 64, spi, dc, rst, cs)
34+
35+
I2C interface::
36+
37+
from machine import Pin, I2C
38+
import ssd1306
39+
40+
# using default address 0x3C
41+
i2c = I2C(sda=Pin(4), scl=Pin(5))
42+
display = ssd1306.SSD1306_I2C(128, 64, i2c)
43+
44+
Print Hello World on the first line::
45+
46+
display.text('Hello, World!', 0, 0, 1)
47+
display.show()
48+
49+
Basic functions::
50+
51+
display.poweroff() # power off the display, pixels persist in memory
52+
display.poweron() # power on the display, pixels redrawn
53+
display.contrast(0) # dim
54+
display.contrast(255) # bright
55+
display.invert(1) # display inverted
56+
display.invert(0) # display normal
57+
display.rotate(True) # rotate 180 degrees
58+
display.rotate(False) # rotate 0 degrees
59+
display.show() # write the contents of the FrameBuffer to display memory
60+
61+
Subclassing FrameBuffer provides support for graphics primitives::
62+
63+
display.fill(0) # fill entire screen with colour=0
64+
display.pixel(0, 10) # get pixel at x=0, y=10
65+
display.pixel(0, 10, 1) # set pixel at x=0, y=10 to colour=1
66+
display.hline(0, 8, 4, 1) # draw horizontal line x=0, y=8, width=4, colour=1
67+
display.vline(0, 8, 4, 1) # draw vertical line x=0, y=8, height=4, colour=1
68+
display.line(0, 0, 127, 63, 1) # draw a line from 0,0 to 127,63
69+
display.rect(10, 10, 107, 43, 1) # draw a rectangle outline 10,10 to 107,43, colour=1
70+
display.fill_rect(10, 10, 107, 43, 1) # draw a solid rectangle 10,10 to 107,43, colour=1
71+
display.text('Hello World', 0, 0, 1) # draw some text at x=0, y=0, colour=1
72+
display.scroll(20, 0) # scroll 20 pixels to the right
73+
74+
# draw another FrameBuffer on top of the current one at the given coordinates
75+
import framebuf
76+
fbuf = framebuf.FrameBuffer(bytearray(8 * 8 * 1), 8, 8, framebuf.MONO_VLSB)
77+
fbuf.line(0, 0, 7, 7, 1)
78+
display.blit(fbuf, 10, 10, 0) # draw on top at x=10, y=10, key=0
79+
display.show()
80+
81+
Draw the MicroPython logo and print some text::
82+
83+
display.fill(0)
84+
display.fill_rect(0, 0, 32, 32, 1)
85+
display.fill_rect(2, 2, 28, 28, 0)
86+
display.vline(9, 8, 22, 1)
87+
display.vline(16, 2, 22, 1)
88+
display.vline(23, 8, 22, 1)
89+
display.fill_rect(26, 24, 2, 4, 1)
90+
display.text('MicroPython', 40, 0, 1)
91+
display.text('SSD1306', 40, 12, 1)
92+
display.text('OLED 128x64', 40, 24, 1)
93+
display.show()

docs/library/builtins.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,6 @@ Exceptions
182182

183183
.. exception:: OSError
184184

185-
|see_cpython| :py:class:`cpython:OSError`. CircuitPython doesn't implement the ``errno``
186-
attribute, instead use the standard way to access exception arguments:
187-
``exc.args[0]``.
188-
189185
.. exception:: RuntimeError
190186

191187
.. exception:: ReloadException

docs/library/machine.PWM.rst

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
.. currentmodule:: machine
2+
.. _machine.PWM:
3+
4+
class PWM -- pulse width modulation
5+
===================================
6+
7+
This class provides pulse width modulation output.
8+
9+
Example usage::
10+
11+
from machine import PWM
12+
13+
pwm = PWM(pin) # create a PWM object on a pin
14+
pwm.duty_u16(32768) # set duty to 50%
15+
16+
# reinitialise with a period of 200us, duty of 5us
17+
pwm.init(freq=5000, duty_ns=5000)
18+
19+
pwm.duty_ns(3000) # set pulse width to 3us
20+
21+
pwm.deinit()
22+
23+
Constructors
24+
------------
25+
26+
.. class:: PWM(dest, \*, freq, duty_u16, duty_ns)
27+
28+
Construct and return a new PWM object using the following parameters:
29+
30+
- *dest* is the entity on which the PWM is output, which is usually a
31+
:ref:`machine.Pin <machine.Pin>` object, but a port may allow other values,
32+
like integers.
33+
- *freq* should be an integer which sets the frequency in Hz for the
34+
PWM cycle.
35+
- *duty_u16* sets the duty cycle as a ratio ``duty_u16 / 65535``.
36+
- *duty_ns* sets the pulse width in nanoseconds.
37+
38+
Setting *freq* may affect other PWM objects if the objects share the same
39+
underlying PWM generator (this is hardware specific).
40+
Only one of *duty_u16* and *duty_ns* should be specified at a time.
41+
42+
Methods
43+
-------
44+
45+
.. method:: PWM.init(\*, freq, duty_u16, duty_ns)
46+
47+
Modify settings for the PWM object. See the above constructor for details
48+
about the parameters.
49+
50+
.. method:: PWM.deinit()
51+
52+
Disable the PWM output.
53+
54+
.. method:: PWM.freq([value])
55+
56+
Get or set the current frequency of the PWM output.
57+
58+
With no arguments the frequency in Hz is returned.
59+
60+
With a single *value* argument the frequency is set to that value in Hz. The
61+
method may raise a ``ValueError`` if the frequency is outside the valid range.
62+
63+
.. method:: PWM.duty_u16([value])
64+
65+
Get or set the current duty cycle of the PWM output, as an unsigned 16-bit
66+
value in the range 0 to 65535 inclusive.
67+
68+
With no arguments the duty cycle is returned.
69+
70+
With a single *value* argument the duty cycle is set to that value, measured
71+
as the ratio ``value / 65535``.
72+
73+
.. method:: PWM.duty_ns([value])
74+
75+
Get or set the current pulse width of the PWM output, as a value in nanoseconds.
76+
77+
With no arguments the pulse width in nanoseconds is returned.
78+
79+
With a single *value* argument the pulse width is set to that value.

docs/library/rp2.Flash.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.. currentmodule:: rp2
2+
.. _rp2.Flash:
3+
4+
class Flash -- access to built-in flash storage
5+
===============================================
6+
7+
This class gives access to the SPI flash memory.
8+
9+
In most cases, to store persistent data on the device, you'll want to use a
10+
higher-level abstraction, for example the filesystem via Python's standard file
11+
API, but this interface is useful to :ref:`customise the filesystem
12+
configuration <filesystem>` or implement a low-level storage system for your
13+
application.
14+
15+
16+
Constructors
17+
------------
18+
19+
.. class:: Flash()
20+
21+
Gets the singleton object for accessing the SPI flash memory.
22+
23+
24+
Methods
25+
-------
26+
27+
.. method:: Flash.readblocks(block_num, buf)
28+
Flash.readblocks(block_num, buf, offset)
29+
.. method:: Flash.writeblocks(block_num, buf)
30+
Flash.writeblocks(block_num, buf, offset)
31+
.. method:: Flash.ioctl(cmd, arg)
32+
33+
These methods implement the simple and extended
34+
:ref:`block protocol <block-device-interface>` defined by
35+
:class:`uos.AbstractBlockDev`.
36+

docs/library/rp2.PIO.rst

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
.. currentmodule:: rp2
2+
.. _rp2.PIO:
3+
4+
class PIO -- advanced PIO usage
5+
===============================
6+
7+
The :class:`PIO` class gives access to an instance of the RP2040's PIO
8+
(programmable I/O) interface.
9+
10+
The preferred way to interact with PIO is using :class:`rp2.StateMachine`, the
11+
PIO class is for advanced use.
12+
13+
For assembling PIO programs, see :func:`rp2.asm_pio`.
14+
15+
16+
Constructors
17+
------------
18+
19+
.. class:: PIO(id)
20+
21+
Gets the PIO instance numbered *id*. The RP2040 has two PIO instances,
22+
numbered 0 and 1.
23+
24+
Raises a ``ValueError`` if any other argument is provided.
25+
26+
27+
Methods
28+
-------
29+
30+
.. method:: PIO.add_program(program)
31+
32+
Add the *program* to the instruction memory of this PIO instance.
33+
34+
The amount of memory available for programs on each PIO instance is
35+
limited. If there isn't enough space left in the PIO's program memory
36+
this method will raise ``OSError(ENOMEM)``.
37+
38+
.. method:: PIO.remove_program([program])
39+
40+
Remove *program* from the instruction memory of this PIO instance.
41+
42+
If no program is provided, it removes all programs.
43+
44+
It is not an error to remove a program which has already been removed.
45+
46+
.. method:: PIO.state_machine(id, [program, ...])
47+
48+
Gets the state machine numbered *id*. On the RP2040, each PIO instance has
49+
four state machines, numbered 0 to 3.
50+
51+
Optionally initialize it with a *program*: see `StateMachine.init`.
52+
53+
>>> rp2.PIO(1).state_machine(3)
54+
StateMachine(7)
55+
56+
.. method:: PIO.irq(handler=None, trigger=IRQ_SM0|IRQ_SM1|IRQ_SM2|IRQ_SM3, hard=False)
57+
58+
Returns the IRQ object for this PIO instance.
59+
60+
MicroPython only uses IRQ 0 on each PIO instance. IRQ 1 is not available.
61+
62+
Optionally configure it.
63+
64+
65+
Constants
66+
---------
67+
68+
.. data:: PIO.IN_LOW
69+
PIO.IN_HIGH
70+
PIO.OUT_LOW
71+
PIO.OUT_HIGH
72+
73+
These constants are used for the *out_init*, *set_init*, and *sideset_init*
74+
arguments to `asm_pio`.
75+
76+
.. data:: PIO.SHIFT_LEFT
77+
PIO.SHIFT_RIGHT
78+
79+
These constants are used for the *in_shiftdir* and *out_shiftdir* arguments
80+
to `asm_pio` or `StateMachine.init`.
81+
82+
.. data:: PIO.JOIN_NONE
83+
PIO.JOIN_TX
84+
PIO.JOIN_RX
85+
86+
These constants are used for the *fifo_join* argument to `asm_pio`.
87+
88+
.. data:: PIO.IRQ_SM0
89+
PIO.IRQ_SM1
90+
PIO.IRQ_SM2
91+
PIO.IRQ_SM3
92+
93+
These constants are used for the *trigger* argument to `PIO.irq`.
94+

0 commit comments

Comments
 (0)