5 namespace remote_base {
7 static const char *
const TAG =
"remote.midea";
9 static const int32_t TICK_US = 560;
10 static const int32_t HEADER_MARK_US = 8 * TICK_US;
11 static const int32_t HEADER_SPACE_US = 8 * TICK_US;
12 static const int32_t BIT_MARK_US = 1 * TICK_US;
13 static const int32_t BIT_ONE_SPACE_US = 3 * TICK_US;
14 static const int32_t BIT_ZERO_SPACE_US = 1 * TICK_US;
15 static const int32_t FOOTER_MARK_US = 1 * TICK_US;
16 static const int32_t FOOTER_SPACE_US = 10 * TICK_US;
20 for (uint8_t idx = 0; idx <
OFFSET_CS; idx++)
26 return std::equal(this->
data_.begin(), this->
data_.end(), rhs.
data_.begin(),
27 [](
const uint8_t &a,
const uint8_t &b) {
return a + b == 255; });
32 dst->
reserve(2 + 48 * 2 + 2 + 2 + 48 * 2 + 1);
33 dst->
item(HEADER_MARK_US, HEADER_SPACE_US);
34 for (
unsigned idx = 0; idx < 6; idx++) {
35 for (uint8_t mask = 1 << 7; mask; mask >>= 1)
36 dst->
item(BIT_MARK_US, (src[idx] & mask) ? BIT_ONE_SPACE_US : BIT_ZERO_SPACE_US);
38 dst->
item(FOOTER_MARK_US, FOOTER_SPACE_US);
39 dst->
item(HEADER_MARK_US, HEADER_SPACE_US);
40 for (
unsigned idx = 0; idx < 6; idx++) {
41 for (uint8_t mask = 1 << 7; mask; mask >>= 1)
42 dst->
item(BIT_MARK_US, (src[idx] & mask) ? BIT_ZERO_SPACE_US : BIT_ONE_SPACE_US);
44 dst->
mark(FOOTER_MARK_US);
48 for (
unsigned idx = 0; idx < 6; idx++) {
50 for (uint8_t mask = 1 << 7; mask; mask >>= 1) {
66 if (src.
expect_item(HEADER_MARK_US, HEADER_SPACE_US) && decode_data(src, out) && out.
is_valid() &&
void set_carrier_frequency(uint32_t carrier_frequency)
void item(uint32_t mark, uint32_t space)
bool is_compliment(const MideaData &rhs) const
bool expect_space(uint32_t length)
void encode(RemoteTransmitData *dst, const MideaData &src) override
bool expect_mark(uint32_t length)
uint8_t reverse_bits(uint8_t x)
Reverse the order of 8 bits.
static const uint8_t OFFSET_CS
void mark(uint32_t length)
std::array< uint8_t, 6 > data_
std::string to_string() const
optional< MideaData > decode(RemoteReceiveData src) override
void dump(const MideaData &data) override
Implementation of SPI Controller mode.
void reserve(uint32_t len)
bool expect_item(uint32_t mark, uint32_t space)