Skip to content

Commit 1cb1e6c

Browse files
committed
ports/esp32: Update RMT module to use the new RMT API.
Signed-off-by: Elvis Pfutzenreuter <elvis.pfutzenreuter@gmail.com>
1 parent 78d017f commit 1cb1e6c

File tree

5 files changed

+100
-232
lines changed

5 files changed

+100
-232
lines changed

docs/esp32/quickref.rst

+3-4
Original file line numberDiff line numberDiff line change
@@ -680,8 +680,8 @@ The RMT is ESP32-specific and allows generation of accurate digital pulses with
680680
import esp32
681681
from machine import Pin
682682

683-
r = esp32.RMT(0, pin=Pin(18), clock_div=8)
684-
r # RMT(channel=0, pin=18, source_freq=80000000, clock_div=8)
683+
r = esp32.RMT(pin=Pin(18), clock_div=8)
684+
r # RMT(pin=18, source_freq=80000000, clock_div=8)
685685
# The channel resolution is 100ns (1/(source_freq/clock_div)).
686686
r.write_pulses((1, 20, 2, 40), 0) # Send 0 for 100ns, 1 for 2000ns, 0 for 200ns, 1 for 4000ns
687687

@@ -743,8 +743,7 @@ The APA106 driver extends NeoPixel, but internally uses a different colour order
743743
``NeoPixel`` object.
744744

745745
For low-level driving of a NeoPixel see `machine.bitstream`.
746-
This low-level driver uses an RMT channel by default. To configure this see
747-
`RMT.bitstream_channel`.
746+
This low-level driver uses an RMT channel by default.
748747

749748
APA102 (DotStar) uses a different driver as it has an additional clock pin.
750749

docs/library/esp32.rst

+13-20
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,11 @@ used to transmit or receive many other types of digital signals::
177177
import esp32
178178
from machine import Pin
179179

180-
r = esp32.RMT(0, pin=Pin(18), clock_div=8)
181-
r # RMT(channel=0, pin=18, source_freq=80000000, clock_div=8, idle_level=0)
180+
r = esp32.RMT(pin=Pin(18), clock_div=8)
181+
r # RMT(pin=18, source_freq=80000000, clock_div=8, idle_level=0)
182182

183183
# To apply a carrier frequency to the high output
184-
r = esp32.RMT(0, pin=Pin(18), clock_div=8, tx_carrier=(38000, 50, 1))
184+
r = esp32.RMT(pin=Pin(18), clock_div=8, tx_carrier=(38000, 50, 1))
185185

186186
# The channel resolution is 100ns (1/(source_freq/clock_div)).
187187
r.write_pulses((1, 20, 2, 40), 0) # Send 0 for 100ns, 1 for 2000ns, 0 for 200ns, 1 for 4000ns
@@ -210,13 +210,17 @@ For more details see Espressif's `ESP-IDF RMT documentation.
210210
*beta feature* and the interface may change in the future.
211211

212212

213-
.. class:: RMT(channel, *, pin=None, clock_div=8, idle_level=False, tx_carrier=None)
213+
.. class:: RMT(channel, *, pin=None, clock_div=8, idle_level=False, num_symbols=64, tx_carrier=None)
214214

215215
This class provides access to one of the eight RMT channels. *channel* is
216-
required and identifies which RMT channel (0-7) will be configured. *pin*,
217-
also required, configures which Pin is bound to the RMT channel. *clock_div*
216+
optional and a dummy parameter for backward compatibility. *pin* is required
217+
and configures which Pin is bound to the RMT channel. *clock_div*
218218
is an 8-bit clock divider that divides the source clock (80MHz) to the RMT
219-
channel allowing the resolution to be specified. *idle_level* specifies
219+
channel allowing the resolution to be specified. *num_symbols* specifies the
220+
RMT buffer allocated for this channel (minimum 64), from a small pool of
221+
512 symbols that are shared by all channels. This buffer does not limit the
222+
size of the pulse train that you can send, but bigger buffers reduce the
223+
CPU load and the potential of glitches/imprecise pulse lengths. *idle_level* specifies
220224
what level the output will be when no transmission is in progress and can
221225
be any value that converts to a boolean, with ``True`` representing high
222226
voltage and ``False`` representing low.
@@ -241,7 +245,8 @@ For more details see Espressif's `ESP-IDF RMT documentation.
241245
Returns ``True`` if the channel is idle or ``False`` if a sequence of
242246
pulses started with `RMT.write_pulses` is being transmitted. If the
243247
*timeout* keyword argument is given then block for up to this many
244-
milliseconds for transmission to complete.
248+
milliseconds for transmission to complete. Timeout of -1 blocks until
249+
transmission is complete (and blocks forever if loop is enabled).
245250

246251
.. method:: RMT.loop(enable_loop)
247252

@@ -278,18 +283,6 @@ For more details see Espressif's `ESP-IDF RMT documentation.
278283
new sequence of pulses. Looping sequences longer than 126 pulses is not
279284
supported by the hardware.
280285

281-
.. staticmethod:: RMT.bitstream_channel([value])
282-
283-
Select which RMT channel is used by the `machine.bitstream` implementation.
284-
*value* can be ``None`` or a valid RMT channel number. The default RMT
285-
channel is the highest numbered one.
286-
287-
Passing in ``None`` disables the use of RMT and instead selects a bit-banging
288-
implementation for `machine.bitstream`.
289-
290-
Passing in no argument will not change the channel. This function returns
291-
the current channel number.
292-
293286
Constants
294287
---------
295288

0 commit comments

Comments
 (0)