95 return int32_t(100 - this->
tolerance_) * length / 100U;
103 return int32_t(100 + this->
tolerance_) * length / 100U;
123#include <soc/soc_caps.h>
133 return us * ticks_per_ten_us / 10;
137 return (ticks * 10) / ticks_per_ten_us;
148#ifdef USE_IR_RF_TRANSMIT_COMPLETE
159 { proto.decode(
src) } -> std::same_as<optional<typename T::ProtocolData>>;
167 proto.encode(dst, data);
194 template<RemoteProtocolEncoder Protocol>
197 Protocol().encode(call.get_data(), data);
198 call.set_send_times(send_times);
199 call.set_send_wait(send_wait);
210#ifdef USE_IR_RF_TRANSMIT_COMPLETE
244#ifdef REMOTE_BASE_LISTENER_COUNT
248 static_assert(
sizeof(T) == 0,
"No listener slot: register it from to_code() with remote_base.add_listener");
251#ifdef REMOTE_BASE_DUMPER_COUNT
255 static_assert(
sizeof(T) == 0,
"No dumper slot: register it from to_code() with remote_base.add_dumper");
266#ifdef REMOTE_BASE_LISTENER_COUNT
269#ifdef REMOTE_BASE_DUMPER_COUNT
304 auto res = proto.decode(
src);
305 return res.has_value() && *res == this->
data_;
315template<RemoteProtocolDecoder T>
320 auto res = proto.decode(
src);
321 if (res.has_value()) {
336 template<RemoteProtocolEncoder Protocol>
344 TEMPLATABLE_VALUE(
uint32_t, send_times)
345 TEMPLATABLE_VALUE(
uint32_t, send_wait)
348 void play(
const Ts &...
x)
override {
350 this->
encode(call.get_data(),
x...);
351 call.set_send_times(this->send_times_.value_or(
x..., 1));
352 call.set_send_wait(this->send_wait_.value_or(
x..., 0));
362 auto decoded = proto.decode(
src);
363 if (!decoded.has_value())
365 proto.dump(*decoded);
370#define DECLARE_REMOTE_PROTOCOL_(prefix) \
371 using prefix##BinarySensor = RemoteReceiverBinarySensor<prefix##Protocol>; \
372 using prefix##Trigger = RemoteReceiverTrigger<prefix##Protocol>; \
373 using prefix##Dumper = RemoteReceiverDumper<prefix##Protocol>;
374#define DECLARE_REMOTE_PROTOCOL(prefix) DECLARE_REMOTE_PROTOCOL_(prefix)
Minimal static vector - saves memory by avoiding std::vector overhead.
void trigger(const Ts &...x) ESPHOME_ALWAYS_INLINE
RemoteComponentBase(InternalGPIOPin *pin)
RemoteComponentBase * remote_base_
void set_rmt_symbols(uint32_t rmt_symbols)
uint32_t to_microseconds_(uint32_t ticks)
uint32_t clock_resolution_
uint32_t from_microseconds_(uint32_t us)
void set_clock_resolution(uint32_t clock_resolution)
int32_t operator[](uint32_t index) const
bool peek_mark_at_most(uint32_t length, uint32_t offset=0) const
uint32_t get_index() const
bool expect_item(uint32_t mark, uint32_t space)
bool peek_space(uint32_t length, uint32_t offset=0) const
bool peek_space_at_most(uint32_t length, uint32_t offset=0) const
int32_t peek(uint32_t offset=0) const
bool peek_item(uint32_t mark, uint32_t space, uint32_t offset=0) const
bool expect_space(uint32_t length)
int32_t upper_bound_(uint32_t length) const
bool expect_mark(uint32_t length)
bool is_valid(uint32_t offset=0) const
const RawTimings & get_raw_data() const
ToleranceMode tolerance_mode_
void advance(uint32_t amount=1)
RemoteReceiveData(const RawTimings &data, uint32_t tolerance, ToleranceMode tolerance_mode)
void set_tolerance(uint32_t tolerance, ToleranceMode tolerance_mode)
bool peek_space_at_least(uint32_t length, uint32_t offset=0) const
ToleranceMode get_tolerance_mode()
int32_t lower_bound_(uint32_t length) const
bool peek_mark(uint32_t length, uint32_t offset=0) const
bool expect_pulse_with_gap(uint32_t mark, uint32_t space)
bool peek_mark_at_least(uint32_t length, uint32_t offset=0) const
ToleranceMode tolerance_mode_
void register_dumper(T *)
void call_listeners_dumpers_()
void register_dumper(RemoteReceiverDumperBase *dumper)
void register_listener(T *)
StaticVector< RemoteReceiverDumperBase *, REMOTE_BASE_DUMPER_COUNT > dumpers_
void set_tolerance(uint32_t tolerance, ToleranceMode tolerance_mode)
void register_listener(RemoteReceiverListener *listener)
RemoteReceiverDumperBase * secondary_dumper_
RemoteReceiverBase(InternalGPIOPin *pin)
StaticVector< RemoteReceiverListener *, REMOTE_BASE_LISTENER_COUNT > listeners_
virtual bool matches(RemoteReceiveData src)=0
RemoteReceiverBinarySensorBase()
bool on_receive(RemoteReceiveData src) override
void dump_config() override
RemoteReceiverBinarySensor()
bool matches(RemoteReceiveData src) override
void set_data(T::ProtocolData data)
virtual bool is_secondary()
virtual bool dump(RemoteReceiveData src)=0
bool dump(RemoteReceiveData src) override
virtual bool on_receive(RemoteReceiveData data)=0
bool on_receive(RemoteReceiveData src) override
bool set_data_from_base64url(const std::string &base64url)
Set data from base64url-encoded little-endian int32 values Base64url is URL-safe: uses '-' instead of...
uint32_t get_carrier_frequency() const
void space(uint32_t length)
void set_carrier_frequency(uint32_t carrier_frequency)
void mark(uint32_t length)
void item(uint32_t mark, uint32_t space)
const RawTimings & get_data() const
void set_data(const RawTimings &data)
void reserve(uint32_t len)
void set_data_from_packed_sint32(const uint8_t *data, size_t len, size_t count)
Set data from packed protobuf sint32 buffer (zigzag + varint encoded)
uint32_t carrier_frequency_
RemoteTransmitterBase * transmitter_
void set_transmitter(RemoteTransmitterBase *transmitter)
void transmit_(const typename Protocol::ProtocolData &data, uint32_t send_times=1, uint32_t send_wait=0)
RemoteTransmittable(RemoteTransmitterBase *transmitter)
virtual void encode(RemoteTransmitData *dst, Ts... x)=0
void play(const Ts &...x) override
uint16_t get_seq() const
Identifies this transmission in the completion hook.
void set_send_times(uint32_t send_times)
void set_send_wait(uint32_t send_wait)
RemoteTransmitterBase * parent_
RemoteTransmitData * get_data()
TransmitCall(RemoteTransmitterBase *parent, uint16_t seq)
void notify_complete_(bool)
RemoteTransmitterBase(InternalGPIOPin *pin)
void send_(uint32_t send_times, uint32_t send_wait, uint16_t seq)
static uint16_t take_seq_()
void transmit(const typename Protocol::ProtocolData &data, uint32_t send_times=1, uint32_t send_wait=0)
virtual void send_internal(uint32_t send_times, uint32_t send_wait)=0
void notify_complete_(bool sent)
Reports the frame handed to the platform last, after its final repeat and before the on_complete trig...
RemoteTransmitData temp_
Use same vector for all transmits, avoids many allocations.
virtual void flush_pending_completion()
Platforms that report completion later wait out the previous frame here, before send_() assigns the n...
void ir_rf_transmit_complete(RemoteTransmitterBase *transmitter, uint16_t seq, bool sent)
Defined by ir_rf_base: answers the API request waiting on the entity that submitted seq; sent is fals...
std::vector< int32_t > RawTimings
@ TOLERANCE_MODE_PERCENTAGE