Module esp_idf_hal::rmt

source ·
Expand description

Remote Control (RMT) module driver.

The RMT (Remote Control) module driver can be used to send infrared remote control signals. Due to flexibility of RMT module, the driver can also be used to generate or receive many other types of signals.

This module is an abstraction around the IDF RMT implementation. It is recommended to read before using this module.

This is implementation currently supports transmission only.

Not supported:

  • Interrupts.
  • Receiving.
  • Change of config after initialisation.

Example

// Prepare the config.
let config = Config::new().clock_divider(1);

// Retrieve the output pin and channel from peripherals.
let peripherals = Peripherals::take().unwrap();
let channel = peripherals.rmt.channel0;
let pin = peripherals.pins.gpio18;

// Create an RMT transmitter.
let tx = TxRmtDriver::new(channel, pin, &config)?;

// Prepare signal pulse signal to be sent.
let low = Pulse::new(PinState::Low, PulseTicks::new(10)?);
let high = Pulse::new(PinState::High, PulseTicks::new(10)?);
let mut signal = FixedLengthSignal::<2>::new();
signal.set(0, &(low, high))?;
signal.set(1, &(high, low))?;

// Transmit the signal.
tx.start(signal)?;

See the examples/ folder of this repository for more.

Loading pulses

There are two ways of preparing pulse signal. FixedLengthSignal and VariableLengthSignal. These implement the Signal trait.

FixedLengthSignal lives on the stack and must have the items set in pairs of Pulses. This is due to the internal implementation of RMT, and const generics limitations.

VariableLengthSignal allows you to use the heap and incrementally add pulse items without knowing the size ahead of time.

Modules

Types used for configuring the rmt module.

Structs

Stack based signal storage for an RMT signal.
A Pulse contains a pin state and a tick count, used in creating a Signal.
Number of ticks, restricting the range to 0 to 32,767.
The RMT receiver.
The RMT transmitter driver.
Vec heap based storage for an RMT signal.

Enums

A Low (0) or High (1) state for a pin.

Traits

RMT peripheral channel.
Signal storage for [Transmit] in a format ready for the RMT driver.

Functions

A utility to convert a duration into ticks, depending on the clock ticks.
A utility to convert ticks into duration, depending on the clock ticks.

Type Definitions