Remote Transmitter

See Application::make_remote_transmitter_component() and Application::register_switch().

API Reference

class RemoteTransmitterComponent : public remote::RemoteControlComponentBase, public Component

Public Functions

RemoteTransmitterComponent(GPIOPin *pin)
RemoteTransmitter *add_transmitter(RemoteTransmitter *transmitter)
void setup()

Where the component’s initialization should happen.

Analogous to Arduino’s setup(). This method is guaranteed to only be called once. Defaults to doing nothing.

void dump_config()
float get_setup_priority() const

priority of setup().

higher -> executed earlier

Defaults to 0.

Return
The setup priority of this component

void set_carrier_duty_percent(uint8_t carrier_duty_percent)
RemoteTransmitterComponent::TransmitCall transmit()

Protected Functions

void send_(RemoteTransmitData *data, uint32_t send_times, uint32_t send_wait)
void calculate_on_off_time_(uint32_t carrier_frequency, uint32_t *on_time_period, uint32_t *off_time_period)
void mark_(uint32_t on_time, uint32_t off_time, uint32_t usec)
void space_(uint32_t usec)
void configure_rmt()

Protected Attributes

friend remote::RemoteTransmitterComponent::RemoteTransmitter
uint32_t current_carrier_frequency_ = {UINT32_MAX}
bool initialized_ = {false}
std::vector<rmt_item32_t> rmt_temp_
uint8_t carrier_duty_percent_ = {50}
std::vector<RemoteTransmitter *> transmitters_ = {}
RemoteTransmitData temp_
class TransmitCall

Public Functions

TransmitCall(RemoteTransmitterComponent *parent)
void set_lg(uint32_t data, uint8_t nbits)
void set_nec(uint16_t address, uint16_t command)
void set_panasonic(uint16_t address, uint32_t command)
void set_raw(std::vector<int32_t> data)
void set_rc_switch_raw(uint32_t code, uint8_t nbits, RCSwitchProtocol protocol = rc_switch_protocols[1])
void set_rc_switch_raw(const char *code, RCSwitchProtocol protocol = rc_switch_protocols[1])
void set_rc_switch_raw_tristate(const char *code, RCSwitchProtocol protocol = rc_switch_protocols[1])
void set_rc_switch_type_a(uint8_t switch_group, uint8_t switch_device, bool state, RCSwitchProtocol protocol = rc_switch_protocols[1])
void set_rc_switch_type_a(const char *switch_group, const char *switch_device, bool state, RCSwitchProtocol protocol = rc_switch_protocols[1])
void set_rc_switch_type_b(uint8_t address, uint8_t channel, bool state, RCSwitchProtocol protocol = rc_switch_protocols[1])
void set_rc_switch_type_c(uint8_t family, uint8_t group, uint8_t device, bool state, RCSwitchProtocol protocol = rc_switch_protocols[1])
void set_rc_switch_type_c(char family, uint8_t group, uint8_t device, bool state, RCSwitchProtocol protocol = rc_switch_protocols[1])
void set_rc_switch_type_d(uint8_t group, uint8_t device, bool state, RCSwitchProtocol protocol = rc_switch_protocols[1])
void set_rc_switch_type_d(char group, uint8_t device, bool state, RCSwitchProtocol protocol = rc_switch_protocols[1])
void set_samsung(uint32_t data)
void set_sony(uint32_t data, uint8_t nbits)
void perform()
RemoteTransmitData *get_data()

Protected Attributes

RemoteTransmitterComponent *parent_
uint32_t send_times_ = {1}
uint32_t send_wait_ = {0}
class RemoteTransmitter : public switch_::Switch

Subclassed by remote::LGTransmitter, remote::NECTransmitter, remote::PanasonicTransmitter, remote::RawTransmitter, remote::RCSwitchRawTransmitter, remote::SamsungTransmitter, remote::SonyTransmitter

Public Functions

RemoteTransmitter(const std::string &name)
virtual void to_data(RemoteTransmitData *data) = 0
void set_parent(RemoteTransmitterComponent *parent)
void set_repeat(uint32_t send_times, uint32_t send_wait)

Protected Functions

void write_state(bool state)

Write the given state to hardware.

You should implement this abstract method if you want to create your own switch.

In the implementation of this method, you should also call publish_state to acknowledge that the state was written to the hardware.

Parameters
  • state: The state to write. Inversion is already applied if user specified it.

Protected Attributes

RemoteTransmitterComponent *parent_
uint32_t send_times_ = {1}

How many times to send the data.

uint32_t send_wait_ = {0}

How many microseconds to wait between repeats.

class RemoteTransmitData

Public Functions

void mark(uint32_t length)
void space(uint32_t length)
void item(uint32_t mark, uint32_t space)
void reserve(uint32_t len)
void set_carrier_frequency(uint32_t carrier_frequency)
uint32_t get_carrier_frequency() const
const std::vector<int32_t> &get_data() const
void set_data(std::vector<int32_t> data)
void reset()
std::vector<int32_t>::iterator begin()
std::vector<int32_t>::iterator end()

Protected Attributes

std::vector<int32_t> data_ = {}
uint32_t carrier_frequency_
class RemoteControlComponentBase

Subclassed by remote::RemoteReceiverComponent, remote::RemoteTransmitterComponent

Public Functions

RemoteControlComponentBase(GPIOPin *pin)
void set_channel(rmt_channel_t channel)
void set_clock_divider(uint8_t clock_divider)

Protected Functions

uint32_t from_microseconds(uint32_t us)
uint32_t to_microseconds(uint32_t ticks)

Protected Attributes

GPIOPin *pin_
rmt_channel_t channel_ = {RMT_CHANNEL_0}
uint8_t clock_divider_ = {80}
esp_err_t error_code_ = {ESP_OK}
class LGTransmitter : public remote::RemoteTransmitter

Public Functions

LGTransmitter(const std::string &name, uint32_t data, uint8_t nbits)
void to_data(RemoteTransmitData *data)

Protected Attributes

uint32_t data_
uint8_t nbits_
class NECTransmitter : public remote::RemoteTransmitter

Public Functions

NECTransmitter(const std::string &name, uint16_t address, uint16_t command)
void to_data(RemoteTransmitData *data)

Protected Attributes

uint16_t address_
uint16_t command_
class PanasonicTransmitter : public remote::RemoteTransmitter

Public Functions

PanasonicTransmitter(const std::string &name, uint16_t address, uint32_t command)
void to_data(RemoteTransmitData *data)

Protected Attributes

uint16_t address_
uint32_t command_
class SamsungTransmitter : public remote::RemoteTransmitter

Public Functions

SamsungTransmitter(const std::string &name, uint32_t data)
void to_data(RemoteTransmitData *data)

Protected Attributes

uint32_t data_
class RawTransmitter : public remote::RemoteTransmitter

Public Functions

RawTransmitter(const std::string &name, std::vector<int32_t> data, uint32_t carrier_frequency = 0)
void to_data(RemoteTransmitData *data)

Protected Attributes

std::vector<int32_t> data_
uint32_t carrier_frequency_ = {0}
class RCSwitchProtocol

Public Functions

RCSwitchProtocol(uint32_t sync_high, uint32_t sync_low, uint32_t zero_high, uint32_t zero_low, uint32_t one_high, uint32_t one_low, bool inverted)
void one(RemoteTransmitData *data) const
void zero(RemoteTransmitData *data) const
void sync(RemoteTransmitData *data) const
void transmit(RemoteTransmitData *data, uint32_t code, uint8_t len) const
bool expect_one(RemoteReceiveData *data) const
bool expect_zero(RemoteReceiveData *data) const
bool expect_sync(RemoteReceiveData *data) const
bool decode(RemoteReceiveData *data, uint32_t *out_data, uint8_t *out_nbits) const

Public Static Functions

void simple_code_to_tristate(uint16_t code, uint8_t nbits, uint32_t *out_code)
void type_a_code(uint8_t switch_group, uint8_t switch_device, bool state, uint32_t *out_code, uint8_t *out_nbits)
void type_b_code(uint8_t address_code, uint8_t channel_code, bool state, uint32_t *out_code, uint8_t *out_nbits)
void type_c_code(uint8_t family, uint8_t group, uint8_t device, bool state, uint32_t *out_code, uint8_t *out_nbits)
void type_d_code(uint8_t group, uint8_t device, bool state, uint32_t *out_code, uint8_t *out_nbits)

Protected Attributes

uint32_t sync_high_
uint32_t sync_low_
uint32_t zero_high_
uint32_t zero_low_
uint32_t one_high_
uint32_t one_low_
bool inverted_
RCSwitchProtocol remote::rc_switch_protocols

= {

RCSwitchProtocol

(0, 0, 0, 0, 0, 0, false),

RCSwitchProtocol

(350, 10850, 350, 1050, 1050, 350, false),

RCSwitchProtocol

(650, 6500, 650, 1300, 1300, 650, false),

RCSwitchProtocol

(3000, 7100, 400, 1100, 900, 600, false),

RCSwitchProtocol

(380, 2280, 380, 1140, 1140, 380, false),

RCSwitchProtocol

(3000, 7000, 500, 1000, 1000, 500, false),

RCSwitchProtocol

(10350, 450, 450, 900, 900, 450, true),

RCSwitchProtocol

(300, 9300, 150, 900, 900, 150, false)

}


class RCSwitchRawTransmitter : public remote::RemoteTransmitter

Subclassed by remote::RCSwitchTypeATransmitter, remote::RCSwitchTypeBTransmitter, remote::RCSwitchTypeCTransmitter, remote::RCSwitchTypeDTransmitter

Public Functions

RCSwitchRawTransmitter(const std::string &name, RCSwitchProtocol aProtocol, uint32_t code, uint8_t nbits)
void to_data(RemoteTransmitData *data)

Protected Attributes

RCSwitchProtocol protocol_
uint32_t code_
uint8_t nbits_
class RCSwitchTypeATransmitter : public remote::RCSwitchRawTransmitter

Public Functions

RCSwitchTypeATransmitter(const std::string &name, RCSwitchProtocol aProtocol, uint8_t switch_group, uint8_t switch_device, bool state)
class RCSwitchTypeBTransmitter : public remote::RCSwitchRawTransmitter

Public Functions

RCSwitchTypeBTransmitter(const std::string &name, RCSwitchProtocol aProtocol, uint8_t address_code, uint8_t channel_code, bool state)
class RCSwitchTypeCTransmitter : public remote::RCSwitchRawTransmitter

Public Functions

RCSwitchTypeCTransmitter(const std::string &name, RCSwitchProtocol aProtocol, uint8_t family, uint8_t group, uint8_t device, bool state)
class RCSwitchTypeDTransmitter : public remote::RCSwitchRawTransmitter

Public Functions

RCSwitchTypeDTransmitter(const std::string &name, RCSwitchProtocol aProtocol, uint8_t group, uint8_t device, bool state)
class SonyTransmitter : public remote::RemoteTransmitter

Public Functions

SonyTransmitter(const std::string &name, uint32_t data, uint8_t nbits)
void to_data(RemoteTransmitData *data)

Protected Attributes

uint32_t data_
uint8_t nbits_