ESPHome 2026.1.0-dev
Loading...
Searching...
No Matches
remote_receiver.h
Go to the documentation of this file.
1#pragma once
2
5
6#include <cinttypes>
7
8#if defined(USE_ESP32)
9#include <driver/rmt_rx.h>
10#endif
11
13
14#if defined(USE_ESP8266) || defined(USE_LIBRETINY) || defined(USE_RP2040)
15struct RemoteReceiverComponentStore {
16 static void gpio_intr(RemoteReceiverComponentStore *arg);
17
21 volatile int32_t *buffer{nullptr};
23 volatile uint32_t buffer_write{0};
25 volatile uint32_t buffer_start{0};
27 uint32_t buffer_read{0};
28 volatile uint32_t commit_micros{0};
29 volatile uint32_t prev_micros{0};
30 uint32_t buffer_size{1000};
31 uint32_t filter_us{10};
32 uint32_t idle_us{10000};
34 volatile bool commit_level{false};
35 volatile bool prev_level{false};
36 volatile bool overflow{false};
37};
38#elif defined(USE_ESP32)
41 volatile uint8_t *buffer{nullptr};
43 volatile uint32_t buffer_write{0};
45 volatile uint32_t buffer_read{0};
46 bool overflow{false};
47 uint32_t buffer_size{1000};
48 uint32_t receive_size{0};
49 uint32_t filter_symbols{0};
50 esp_err_t error{ESP_OK};
51 rmt_receive_config_t config;
52};
53#endif
54
56 public Component
57#ifdef USE_ESP32
58 ,
60#endif
61
62{
63 public:
65 void setup() override;
66 void dump_config() override;
67 void loop() override;
68
69#ifdef USE_ESP32
70 void set_filter_symbols(uint32_t filter_symbols) { this->filter_symbols_ = filter_symbols; }
71 void set_receive_symbols(uint32_t receive_symbols) { this->receive_symbols_ = receive_symbols; }
72 void set_with_dma(bool with_dma) { this->with_dma_ = with_dma; }
73 void set_carrier_duty_percent(uint8_t carrier_duty_percent) { this->carrier_duty_percent_ = carrier_duty_percent; }
74 void set_carrier_frequency(uint32_t carrier_frequency) { this->carrier_frequency_ = carrier_frequency; }
75#endif
76 void set_buffer_size(uint32_t buffer_size) { this->buffer_size_ = buffer_size; }
77 void set_filter_us(uint32_t filter_us) { this->filter_us_ = filter_us; }
78 void set_idle_us(uint32_t idle_us) { this->idle_us_ = idle_us; }
79
80 protected:
81#ifdef USE_ESP32
82 void decode_rmt_(rmt_symbol_word_t *item, size_t item_count);
83 rmt_channel_handle_t channel_{NULL};
84 uint32_t filter_symbols_{0};
85 uint32_t receive_symbols_{0};
86 bool with_dma_{false};
87 uint32_t carrier_frequency_{0};
89 esp_err_t error_code_{ESP_OK};
90 std::string error_string_{""};
91#endif
92
93#if defined(USE_ESP8266) || defined(USE_LIBRETINY) || defined(USE_RP2040) || defined(USE_ESP32)
95#endif
96
97#if defined(USE_ESP8266) || defined(USE_LIBRETINY) || defined(USE_RP2040)
99#endif
100
101 uint32_t buffer_size_{};
102 uint32_t filter_us_{10};
103 uint32_t idle_us_{10000};
104};
105
106} // namespace esphome::remote_receiver
Helper class to request loop() to be called as fast as possible.
Definition helpers.h:1211
Copy of GPIOPin that is safe to use from ISRs (with no virtual functions)
Definition gpio.h:73
void set_carrier_frequency(uint32_t carrier_frequency)
void set_carrier_duty_percent(uint8_t carrier_duty_percent)
void decode_rmt_(rmt_symbol_word_t *item, size_t item_count)
void set_receive_symbols(uint32_t receive_symbols)
static void gpio_intr(RemoteReceiverComponentStore *arg)
uint32_t buffer_read
The position last read from.
volatile uint32_t buffer_start
The start position of the last sequence.
volatile int32_t * buffer
Stores pulse durations in microseconds as signed integers.
volatile uint32_t buffer_write
The position last written to.