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);
24 ESP_LOGW(TAG,
"Not enough RMT memory blocks available, reduced to %i blocks.", this->
mem_block_num_);
35 if (!this->is_valid(offset))
37 const int32_t value = this->peek(offset);
38 const int32_t lo = this->lower_bound_(length);
39 const int32_t hi = this->upper_bound_(length);
40 return value >= 0 && lo <= value && value <= hi;
44 if (!this->is_valid(offset))
46 const int32_t value = this->peek(offset);
47 const int32_t lo = this->lower_bound_(length);
48 const int32_t hi = this->upper_bound_(length);
49 return value <= 0 && lo <= -value && -value <= hi;
53 if (!this->is_valid(offset))
55 const int32_t value = this->peek(offset);
56 const int32_t lo = this->lower_bound_(length);
57 return value <= 0 && lo <= -value;
61 if (!this->peek_mark(length))
68 if (!this->peek_space(length))
75 if (!this->peek_item(mark, space))
82 if (!this->peek_space_at_least(space, 1) || !this->peek_mark(mark))
91 if (!this->matches(src))
93 this->publish_state(
true);
95 this->publish_state(
false);
103 this->secondary_dumpers_.push_back(dumper);
105 this->dumpers_.push_back(dumper);
110 for (
auto *listener : this->listeners_)
111 listener->on_receive(
RemoteReceiveData(this->temp_, this->tolerance_, this->tolerance_mode_));
115 bool success =
false;
116 for (
auto *dumper : this->dumpers_) {
117 if (dumper->dump(
RemoteReceiveData(this->temp_, this->tolerance_, this->tolerance_mode_)))
121 for (
auto *dumper : this->secondary_dumpers_)
122 dumper->dump(
RemoteReceiveData(this->temp_, this->tolerance_, this->tolerance_mode_));
129 #ifdef ESPHOME_LOG_HAS_VERY_VERBOSE 130 const auto &vec = this->temp_.get_data();
132 uint32_t buffer_offset = 0;
133 buffer_offset += sprintf(buffer,
"Sending times=%" PRIu32
" wait=%" PRIu32
"ms: ", send_times, send_wait);
135 for (
size_t i = 0; i < vec.size(); i++) {
136 const int32_t value = vec[i];
137 const uint32_t remaining_length =
sizeof(buffer) - buffer_offset;
140 if (i + 1 < vec.size()) {
141 written = snprintf(buffer + buffer_offset, remaining_length,
"%" PRId32
", ", value);
143 written = snprintf(buffer + buffer_offset, remaining_length,
"%" PRId32, value);
146 if (written < 0 || written >=
int(remaining_length)) {
148 buffer[buffer_offset] =
'\0';
149 ESP_LOGVV(TAG,
"%s", buffer);
151 written = sprintf(buffer,
" ");
152 if (i + 1 < vec.size()) {
153 written += sprintf(buffer + written,
"%" PRId32
", ", value);
155 written += sprintf(buffer + written,
"%" PRId32, value);
159 buffer_offset += written;
161 if (buffer_offset != 0) {
162 ESP_LOGVV(TAG,
"%s", buffer);
165 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