Class Out

An RMT channel.
The channel must be configured after construction.
The channel can be configured for either RX or TX.

Class summary


constructor pin/any --resolution/int --memory-blocks/int= --open-drain/bool= --pull-up/bool= --dma/bool=
Constructs an output channel on the given pin.

Constructors

constructor pin/any --resolution/int --memory-blocks/int=1 --open-drain/bool=false --pull-up/bool=false --dma/bool=false
Constructs an output channel on the given pin.
The pin is the GPIO number the channel drives. The channel reserves the pin and releases it again when the channel is closed.
The resolution is the frequency of the clock that the RMT controller uses to emit the output signal. It ranges from 312500Hz (312.5KHz) to 80000000Hz (80MHz). Signals are specified in ticks of this frequency.
The memory-blocks parameter specifies the channel buffer capacity in units of RMT memory blocks. Each unit has BYTES-PER-MEMORY-BLOCK bytes. Since each signal is 2 bytes long, the number of signals that can be stored in each block is memory-blocks * BYTES-PER-MEMORY-BLOCK / 2.
Generally, output channels don't need extra blocks as interrupts will copy data into the buffer when necessary.
If dma is true, memory-blocks sizes an internal-RAM DMA buffer instead of allocating dedicated RMT memory blocks. DMA is only supported on some chips, including the ESP32P4 and ESP32S3, and consumes an internal DMA channel.
If open-drain is set and pull-up is true, the internal pull-up resistor is enabled.
If an Out channel is in open-drain mode, and an In channel is on the same pin, then the In channel must be created first.
Passing a gpio.Pin as pin is deprecated; provide the integer GPIO number instead. The gpio.Pin form will be removed in a future release.

Methods

apply-carrier frequency-hz/int --duty-factor/float --active-low/bool=false --always-on/bool=false -> none
Applies a carrier signal to the channel.
If active-low is true, the carrier is applied when the signal is low. Otherwise (the default) the carrier is applied when the signal is high.
The always-on parameter indicates whether the carrier is always applied, or only when signals are being sent. In other words, whether the carrier is also applied to the idle level. The ESP32 RMT controller *always* applies the carrier to the idle level, even if this parameter is set to false. This is a limitation of the hardware.

close -> none
Closes the channel.

flush -> none
Blocks until a previous write operation has finished.
Returns immediately if no write operation is in process.

operator == other/any -> bool
Whether this object is equal to the other.
By default, identical is used for equality.
Inheritance
Classes overwrite this operator to get an equality specific to their needs. Equality operators often compare the type and field contents. For example:

class Pin:
  number/int

  constructor .number:

  operator == other:
    if other is not Pin: return false
    return number == other.number
A class doesn't have to follow the above format, but it must keep the operator in sync with any hash-code method. That is, if a class has a hash-code member, then the equality and hash-code must agree. If two instances are equal (a == b), then their hash codes must also be equal (a.hash-code == b.hash-code).

reset -> none
Resets the channel.
If the channel was reading or writing, these operations are aborted and the corresponding resources are released.

Stringifies this object.
Inheritance
Objects that need a human-friendly string representation should overwrite this method. The default string is based on the internal class-ID.

write signals/Signals --flush/bool=true --done-level/int=0 --loop-count/int=1 -> none
Transmits the given signals.
If flush is true (the default) waits for the write to finish before returning. In that case, if the write operation is aborted (for example with a with-timeout), then the transmission is aborted and the channel is reset.
The loop-count parameter specifies how many times the signals are repeated. If it is set to -1, the signals are repeated indefinitely. The ESP32 only supports -1 (infinite) and 1. Other variants, like the ESP32C3, ESP32C6, ESP32P4, ESP32S2, and ESP32S3, support other positive values.
The done-level parameter specifies the level of the pin when the transmission is done.

write data/Data --bit-size/int=(data.byte-size * 8) --encoder/Encoder --flush/bool=true --done-level/int=0 --loop-count/int=1 -> none
Variant of write signals
Encodes the data using the given encoder.