ESPHome 2025.5.0
Loading...
Searching...
No Matches
remote_transmitter.h
Go to the documentation of this file.
1#pragma once
2
5
6#include <vector>
7
8#if defined(USE_ESP32) && ESP_IDF_VERSION_MAJOR >= 5
9#include <driver/rmt_tx.h>
10#endif
11
12namespace esphome {
13namespace remote_transmitter {
14
16 public Component
17#ifdef USE_ESP32
18 ,
20#endif
21{
22 public:
23#if defined(USE_ESP32) && ESP_IDF_VERSION_MAJOR < 5
24 RemoteTransmitterComponent(InternalGPIOPin *pin, uint8_t mem_block_num = 1)
25 : remote_base::RemoteTransmitterBase(pin), remote_base::RemoteRMTChannel(mem_block_num) {}
26
27 RemoteTransmitterComponent(InternalGPIOPin *pin, rmt_channel_t channel, uint8_t mem_block_num = 1)
28 : remote_base::RemoteTransmitterBase(pin), remote_base::RemoteRMTChannel(channel, mem_block_num) {}
29#else
31#endif
32 void setup() override;
33
34 void dump_config() override;
35
36 // transmitter setup must run after receiver setup to allow the same GPIO to be used by both
37 float get_setup_priority() const override { return setup_priority::DATA - 1; }
38
39 void set_carrier_duty_percent(uint8_t carrier_duty_percent) { this->carrier_duty_percent_ = carrier_duty_percent; }
40
41#if defined(USE_ESP32) && ESP_IDF_VERSION_MAJOR >= 5
42 void set_with_dma(bool with_dma) { this->with_dma_ = with_dma; }
43 void set_eot_level(bool eot_level) { this->eot_level_ = eot_level; }
44 void digital_write(bool value);
45#endif
46
49
50 protected:
51 void send_internal(uint32_t send_times, uint32_t send_wait) override;
52#if defined(USE_ESP8266) || defined(USE_LIBRETINY)
53 void calculate_on_off_time_(uint32_t carrier_frequency, uint32_t *on_time_period, uint32_t *off_time_period);
54
55 void mark_(uint32_t on_time, uint32_t off_time, uint32_t usec);
56
57 void space_(uint32_t usec);
58
59 void await_target_time_();
60 uint32_t target_time_;
61#endif
62
63#ifdef USE_ESP32
64 void configure_rmt_();
65
67 bool initialized_{false};
68#if ESP_IDF_VERSION_MAJOR >= 5
69 std::vector<rmt_symbol_word_t> rmt_temp_;
70 bool with_dma_{false};
71 bool eot_level_{false};
72 rmt_channel_handle_t channel_{NULL};
73 rmt_encoder_handle_t encoder_{NULL};
74#else
75 std::vector<rmt_item32_t> rmt_temp_;
76#endif
77 esp_err_t error_code_{ESP_OK};
78 std::string error_string_{""};
79 bool inverted_{false};
80#endif
82
85};
86
87} // namespace remote_transmitter
88} // namespace esphome
RemoteRMTChannel(uint8_t mem_block_num=1)
void send_internal(uint32_t send_times, uint32_t send_wait) override
void calculate_on_off_time_(uint32_t carrier_frequency, uint32_t *on_time_period, uint32_t *off_time_period)
RemoteTransmitterComponent(InternalGPIOPin *pin, uint8_t mem_block_num=1)
void mark_(uint32_t on_time, uint32_t off_time, uint32_t usec)
void set_carrier_duty_percent(uint8_t carrier_duty_percent)
RemoteTransmitterComponent(InternalGPIOPin *pin, rmt_channel_t channel, uint8_t mem_block_num=1)
const float DATA
For components that import data from directly connected sensors like DHT.
Definition component.cpp:19
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7