52 static void type_a_code(uint8_t switch_group, uint8_t switch_device,
bool state, uint64_t *out_code,
55 static void type_b_code(uint8_t address_code, uint8_t channel_code,
bool state, uint64_t *out_code,
58 static void type_c_code(uint8_t family, uint8_t group, uint8_t device,
bool state, uint64_t *out_code,
61 static void type_d_code(uint8_t group, uint8_t device,
bool state, uint64_t *out_code, uint8_t *out_nbits);
73 static_assert(std::is_same_v<
decltype(
inverted_),
uint32_t>,
"inverted_ must stay a word for flash reads");
79static_assert(
sizeof(RCSwitchBase) == 7 *
sizeof(
uint32_t),
"RCSwitchBase must stay word-only for flash reads");
80inline constexpr RCSwitchBase RC_SWITCH_PROTOCOLS[] PROGMEM = {
81 {0, 0, 0, 0, 0, 0,
false},
82 {350, 10850, 350, 1050, 1050, 350,
false},
83 {650, 6500, 650, 1300, 1300, 650,
false},
84 {3000, 7100, 400, 1100, 900, 600,
false},
85 {380, 2280, 380, 1140, 1140, 380,
false},
86 {3000, 7000, 500, 1000, 1000, 500,
false},
87 {10350, 450, 450, 900, 900, 450,
true},
88 {300, 9300, 150, 900, 900, 150,
false},
89 {250, 2500, 250, 1250, 250, 250,
false},
109 auto code = this->code_.value(
x...);
111 uint8_t nbits = code.size();
113 auto proto = this->protocol_.value(
x...);
114 proto.transmit(dst, the_code, nbits);
126 auto group = this->group_.value(
x...);
127 auto device = this->device_.value(
x...);
128 auto state = this->state_.value(
x...);
136 auto proto = this->protocol_.value(
x...);
137 proto.transmit(dst, code, nbits);
149 auto address = this->address_.value(
x...);
150 auto channel = this->channel_.value(
x...);
151 auto state = this->state_.value(
x...);
157 auto proto = this->protocol_.value(
x...);
158 proto.transmit(dst, code, nbits);
171 auto family = this->family_.value(
x...);
172 auto group = this->group_.value(
x...);
173 auto device = this->device_.value(
x...);
174 auto state = this->state_.value(
x...);
176 auto u_family =
static_cast<uint8_t
>(tolower(family[0]) -
'a');
182 auto proto = this->protocol_.value(
x...);
183 proto.transmit(dst, code, nbits);
194 auto group = this->group_.value(
x...);
195 auto device = this->device_.value(
x...);
196 auto state = this->state_.value(
x...);
198 auto u_group =
static_cast<uint8_t
>(tolower(group[0]) -
'a');
204 auto proto = this->protocol_.value(
x...);
205 proto.transmit(dst, code, nbits);
217 this->
nbits_ = code.size();
229 auto u_family =
static_cast<uint8_t
>(tolower(family[0]) -
'a');
233 auto u_group =
static_cast<uint8_t
>(tolower(group[0]) -
'a');
bool state
The current state of this binary sensor. Also used as the backing storage for StatefulEntityBase.
constexpr RCSwitchBase()=default
void zero(RemoteTransmitData *dst) const
static void type_b_code(uint8_t address_code, uint8_t channel_code, bool state, uint64_t *out_code, uint8_t *out_nbits)
bool expect_one(RemoteReceiveData &src) const
bool expect_zero(RemoteReceiveData &src) const
bool decode(RemoteReceiveData &src, uint64_t *out_data, uint8_t *out_nbits) const
static void type_c_code(uint8_t family, uint8_t group, uint8_t device, bool state, uint64_t *out_code, uint8_t *out_nbits)
void transmit(RemoteTransmitData *dst, uint64_t code, uint8_t len) const
static void type_a_code(uint8_t switch_group, uint8_t switch_device, bool state, uint64_t *out_code, uint8_t *out_nbits)
void one(RemoteTransmitData *dst) const
constexpr RCSwitchBase(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)
bool expect_sync(RemoteReceiveData &src) const
static void type_d_code(uint8_t group, uint8_t device, bool state, uint64_t *out_code, uint8_t *out_nbits)
static void simple_code_to_tristate(uint16_t code, uint8_t nbits, uint64_t *out_code)
bool dump(RemoteReceiveData src) override
TEMPLATABLE_VALUE(RCSwitchBase, protocol)
void encode(RemoteTransmitData *dst, Ts... x) override
TEMPLATABLE_VALUE(std::string, code)
void set_nbits(uint8_t nbits)
void set_type_d(std::string group, uint8_t device, bool state)
void set_protocol(const RCSwitchBase *protocol)
protocol must outlive the receiver: a RC_SWITCH_PROTOCOLS entry or a codegen flash table.
void set_type_b(uint8_t address_code, uint8_t channel_code, bool state)
void set_code(const std::string &code)
void set_type_a(const std::string &group, const std::string &device, bool state)
void set_code(uint64_t code)
bool matches(RemoteReceiveData src) override
const RCSwitchBase * protocol_
void set_type_c(std::string family, uint8_t group, uint8_t device, bool state)
TEMPLATABLE_VALUE(bool, state)
TEMPLATABLE_VALUE(std::string, device)
TEMPLATABLE_VALUE(std::string, group)
void encode(RemoteTransmitData *dst, Ts... x) override
TEMPLATABLE_VALUE(RCSwitchBase, protocol)
TEMPLATABLE_VALUE(RCSwitchBase, protocol)
void encode(RemoteTransmitData *dst, Ts... x) override
TEMPLATABLE_VALUE(uint8_t, address)
TEMPLATABLE_VALUE(uint8_t, channel)
TEMPLATABLE_VALUE(bool, state)
TEMPLATABLE_VALUE(bool, state)
void encode(RemoteTransmitData *dst, Ts... x) override
TEMPLATABLE_VALUE(uint8_t, device)
TEMPLATABLE_VALUE(uint8_t, group)
TEMPLATABLE_VALUE(std::string, family)
TEMPLATABLE_VALUE(RCSwitchBase, protocol)
void encode(RemoteTransmitData *dst, Ts... x) override
TEMPLATABLE_VALUE(std::string, group)
TEMPLATABLE_VALUE(uint8_t, device)
TEMPLATABLE_VALUE(RCSwitchBase, protocol)
TEMPLATABLE_VALUE(bool, state)
uint64_t decode_binary_string_mask(const std::string &data)
RCSwitchBase rc_switch_protocol_copy(const RCSwitchBase *protocol)
RAM copy of a protocol stored in flash, made with progmem_memcpy (own name: rc_switch_protocol(0) sta...
uint64_t decode_binary_string(const std::string &data)
RCSwitchBase rc_switch_protocol(uint8_t index)
RAM copy of RC_SWITCH_PROTOCOLS[index] (0 when out of range) for the transmit actions and the dumper,...
bool operator==(const RCSwitchData &rhs) const