7 namespace remote_base {
9 static const char *
const TAG =
"remote_base";
13 static rmt_channel_t next_rmt_channel = RMT_CHANNEL_0;
15 next_rmt_channel = rmt_channel_t(
int(next_rmt_channel) + mem_block_num);
21 ESP_LOGW(TAG,
"Not enough RMT memory blocks available, reduced to %i blocks.", this->
mem_block_num_);
32 if (!this->is_valid(offset))
34 const int32_t value = this->peek(offset);
35 const int32_t lo = this->lower_bound_(length);
36 const int32_t hi = this->upper_bound_(length);
37 return value >= 0 && lo <= value && value <= hi;
41 if (!this->is_valid(offset))
43 const int32_t value = this->peek(offset);
44 const int32_t lo = this->lower_bound_(length);
45 const int32_t hi = this->upper_bound_(length);
46 return value <= 0 && lo <= -value && -value <= hi;
50 if (!this->is_valid(offset))
52 const int32_t value = this->peek(offset);
53 const int32_t lo = this->lower_bound_(length);
54 return value <= 0 && lo <= -value;
58 if (!this->peek_mark(length))
65 if (!this->peek_space(length))
72 if (!this->peek_item(mark, space))
79 if (!this->peek_space_at_least(space, 1) || !this->peek_mark(mark))
88 if (!this->matches(src))
90 this->publish_state(
true);
92 this->publish_state(
false);
100 this->secondary_dumpers_.push_back(dumper);
102 this->dumpers_.push_back(dumper);
107 for (
auto *listener : this->listeners_)
112 bool success =
false;
113 for (
auto *dumper : this->dumpers_) {
118 for (
auto *dumper : this->secondary_dumpers_)
126 #ifdef ESPHOME_LOG_HAS_VERY_VERBOSE 127 const auto &vec = this->temp_.get_data();
129 uint32_t buffer_offset = 0;
130 buffer_offset += sprintf(buffer,
"Sending times=%" PRIu32
" wait=%" PRIu32
"ms: ", send_times, send_wait);
132 for (
size_t i = 0; i < vec.size(); i++) {
133 const int32_t value = vec[i];
134 const uint32_t remaining_length =
sizeof(buffer) - buffer_offset;
137 if (i + 1 < vec.size()) {
138 written = snprintf(buffer + buffer_offset, remaining_length,
"%" PRId32
", ", value);
140 written = snprintf(buffer + buffer_offset, remaining_length,
"%" PRId32, value);
143 if (written < 0 || written >=
int(remaining_length)) {
145 buffer[buffer_offset] =
'\0';
146 ESP_LOGVV(TAG,
"%s", buffer);
148 written = sprintf(buffer,
" ");
149 if (i + 1 < vec.size()) {
150 written += sprintf(buffer + written,
"%" PRId32
", ", value);
152 written += sprintf(buffer + written,
"%" PRId32, value);
156 buffer_offset += written;
158 if (buffer_offset != 0) {
159 ESP_LOGVV(TAG,
"%s", buffer);
162 this->send_internal(send_times, send_wait);
void config_rmt(rmt_config_t &rmt)
bool expect_pulse_with_gap(uint32_t mark, uint32_t space)
RemoteRMTChannel(uint8_t mem_block_num=1)
bool peek_space(uint32_t length, uint32_t offset=0) const
bool expect_space(uint32_t length)
bool expect_mark(uint32_t length)
bool peek_mark(uint32_t length, uint32_t offset=0) const
void dump_config() override
bool on_receive(RemoteReceiveData src) override
void IRAM_ATTR HOT yield()
Implementation of SPI Controller mode.
void register_dumper(RemoteReceiverDumperBase *dumper)
virtual bool is_secondary()
bool expect_item(uint32_t mark, uint32_t space)
void send_(uint32_t send_times, uint32_t send_wait)
bool peek_space_at_least(uint32_t length, uint32_t offset=0) const