ESPHome  2022.9.2
remote_receiver.h
Go to the documentation of this file.
1 #pragma once
2 
5 
6 namespace esphome {
7 namespace remote_receiver {
8 
9 #ifdef USE_ESP8266
11  static void gpio_intr(RemoteReceiverComponentStore *arg);
12 
16  volatile uint32_t *buffer{nullptr};
18  volatile uint32_t buffer_write_at;
20  uint32_t buffer_read_at{0};
21  bool overflow{false};
22  uint32_t buffer_size{1000};
23  uint8_t filter_us{10};
25 };
26 #endif
27 
29  public Component
30 #ifdef USE_ESP32
31  ,
33 #endif
34 {
35  public:
36 #ifdef USE_ESP32
37  RemoteReceiverComponent(InternalGPIOPin *pin, uint8_t mem_block_num = 1)
38  : RemoteReceiverBase(pin), remote_base::RemoteRMTChannel(mem_block_num) {}
39 #else
40  RemoteReceiverComponent(InternalGPIOPin *pin) : RemoteReceiverBase(pin) {}
41 #endif
42  void setup() override;
43  void dump_config() override;
44  void loop() override;
45  float get_setup_priority() const override { return setup_priority::DATA; }
46 
47  void set_buffer_size(uint32_t buffer_size) { this->buffer_size_ = buffer_size; }
48  void set_filter_us(uint8_t filter_us) { this->filter_us_ = filter_us; }
49  void set_idle_us(uint32_t idle_us) { this->idle_us_ = idle_us; }
50 
51  protected:
52 #ifdef USE_ESP32
53  void decode_rmt_(rmt_item32_t *item, size_t len);
54  RingbufHandle_t ringbuf_;
55  esp_err_t error_code_{ESP_OK};
56 #endif
57 
58 #ifdef USE_ESP8266
61 #endif
62 
63  uint32_t buffer_size_{};
64  uint8_t filter_us_{10};
65  uint32_t idle_us_{10000};
66 };
67 
68 } // namespace remote_receiver
69 } // namespace esphome
void setup()
void loop()
const float DATA
For components that import data from directly connected sensors like DHT.
Definition: component.cpp:18
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:555
volatile uint32_t buffer_write_at
The position last written to.
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:281
Definition: a4988.cpp:4
RemoteReceiverComponent(InternalGPIOPin *pin, uint8_t mem_block_num=1)