ESPHome  2024.10.2
remote_receiver.h
Go to the documentation of this file.
1 #pragma once
2 
5 
6 #include <cinttypes>
7 
8 namespace esphome {
9 namespace remote_receiver {
10 
11 #if defined(USE_ESP8266) || defined(USE_LIBRETINY)
13  static void gpio_intr(RemoteReceiverComponentStore *arg);
14 
18  volatile uint32_t *buffer{nullptr};
20  volatile uint32_t buffer_write_at;
22  uint32_t buffer_read_at{0};
23  bool overflow{false};
24  uint32_t buffer_size{1000};
25  uint32_t filter_us{10};
27 };
28 #endif
29 
31  public Component
32 #ifdef USE_ESP32
33  ,
35 #endif
36 {
37  public:
38 #ifdef USE_ESP32
39  RemoteReceiverComponent(InternalGPIOPin *pin, uint8_t mem_block_num = 1)
40  : RemoteReceiverBase(pin), remote_base::RemoteRMTChannel(mem_block_num) {}
41 
42  RemoteReceiverComponent(InternalGPIOPin *pin, rmt_channel_t channel, uint8_t mem_block_num = 1)
43  : RemoteReceiverBase(pin), remote_base::RemoteRMTChannel(channel, mem_block_num) {}
44 #else
45  RemoteReceiverComponent(InternalGPIOPin *pin) : RemoteReceiverBase(pin) {}
46 #endif
47  void setup() override;
48  void dump_config() override;
49  void loop() override;
50  float get_setup_priority() const override { return setup_priority::DATA; }
51 
52  void set_buffer_size(uint32_t buffer_size) { this->buffer_size_ = buffer_size; }
53  void set_filter_us(uint32_t filter_us) { this->filter_us_ = filter_us; }
54  void set_idle_us(uint32_t idle_us) { this->idle_us_ = idle_us; }
55 
56  protected:
57 #ifdef USE_ESP32
58  void decode_rmt_(rmt_item32_t *item, size_t len);
59  RingbufHandle_t ringbuf_;
60  esp_err_t error_code_{ESP_OK};
61  std::string error_string_{""};
62 #endif
63 
64 #if defined(USE_ESP8266) || defined(USE_LIBRETINY)
67 #endif
68 
69  uint32_t buffer_size_{};
70  uint32_t filter_us_{10};
71  uint32_t idle_us_{10000};
72 };
73 
74 } // namespace remote_receiver
75 } // namespace esphome
void setup()
void loop()
const float DATA
For components that import data from directly connected sensors like DHT.
Definition: component.cpp:19
Copy of GPIOPin that is safe to use from ISRs (with no virtual functions)
Definition: gpio.h:66
Helper class to request loop() to be called as fast as possible.
Definition: helpers.h:609
volatile uint32_t buffer_write_at
The position last written to.
RemoteReceiverComponent(InternalGPIOPin *pin, rmt_channel_t channel, uint8_t mem_block_num=1)
static void gpio_intr(RemoteReceiverComponentStore *arg)
uint32_t buffer_read_at
The position last read from.
volatile uint32_t * buffer
Stores the time (in micros) that the leading/falling edge happened at.
std::string size_t len
Definition: helpers.h:292
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
RemoteReceiverComponent(InternalGPIOPin *pin, uint8_t mem_block_num=1)