ESPHome 2025.9.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
12namespace esphome {
13namespace remote_receiver {
14
15#if defined(USE_ESP8266) || defined(USE_LIBRETINY)
18
22 volatile uint32_t *buffer{nullptr};
24 volatile uint32_t buffer_write_at;
26 uint32_t buffer_read_at{0};
27 bool overflow{false};
28 uint32_t buffer_size{1000};
29 uint32_t filter_us{10};
31};
32#elif defined(USE_ESP32)
35 volatile uint8_t *buffer{nullptr};
37 volatile uint32_t buffer_write{0};
39 volatile uint32_t buffer_read{0};
40 bool overflow{false};
41 uint32_t buffer_size{1000};
42 uint32_t receive_size{0};
43 uint32_t filter_symbols{0};
44 esp_err_t error{ESP_OK};
45 rmt_receive_config_t config;
46};
47#endif
48
50 public Component
51#ifdef USE_ESP32
52 ,
54#endif
55
56{
57 public:
59 void setup() override;
60 void dump_config() override;
61 void loop() override;
62
63#ifdef USE_ESP32
64 void set_filter_symbols(uint32_t filter_symbols) { this->filter_symbols_ = filter_symbols; }
65 void set_receive_symbols(uint32_t receive_symbols) { this->receive_symbols_ = receive_symbols; }
66 void set_with_dma(bool with_dma) { this->with_dma_ = with_dma; }
67#endif
68 void set_buffer_size(uint32_t buffer_size) { this->buffer_size_ = buffer_size; }
69 void set_filter_us(uint32_t filter_us) { this->filter_us_ = filter_us; }
70 void set_idle_us(uint32_t idle_us) { this->idle_us_ = idle_us; }
71
72 protected:
73#ifdef USE_ESP32
74 void decode_rmt_(rmt_symbol_word_t *item, size_t item_count);
75 rmt_channel_handle_t channel_{NULL};
76 uint32_t filter_symbols_{0};
77 uint32_t receive_symbols_{0};
78 bool with_dma_{false};
79 esp_err_t error_code_{ESP_OK};
80 std::string error_string_{""};
81#endif
82
83#if defined(USE_ESP8266) || defined(USE_LIBRETINY) || defined(USE_ESP32)
86#endif
87
88 uint32_t buffer_size_{};
89 uint32_t filter_us_{10};
90 uint32_t idle_us_{10000};
91};
92
93} // namespace remote_receiver
94} // namespace esphome
Helper class to request loop() to be called as fast as possible.
Definition helpers.h:765
Copy of GPIOPin that is safe to use from ISRs (with no virtual functions)
Definition gpio.h:73
void decode_rmt_(rmt_symbol_word_t *item, size_t item_count)
void set_receive_symbols(uint32_t receive_symbols)
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
volatile uint32_t * buffer
Stores the time (in micros) that the leading/falling edge happened at.
static void gpio_intr(RemoteReceiverComponentStore *arg)
uint32_t buffer_read_at
The position last read from.
volatile uint32_t buffer_read
The position last read from.
volatile uint32_t buffer_write_at
The position last written to.
volatile uint32_t buffer_write
The position last written to.