5 namespace remote_base {
7 static const char *
const TAG =
"remote.mirage";
9 constexpr uint32_t HEADER_MARK_US = 8360;
10 constexpr uint32_t HEADER_SPACE_US = 4248;
11 constexpr uint32_t BIT_MARK_US = 554;
12 constexpr uint32_t BIT_ONE_SPACE_US = 1592;
13 constexpr uint32_t BIT_ZERO_SPACE_US = 545;
21 dst->
mark(HEADER_MARK_US);
22 dst->
space(HEADER_SPACE_US);
23 dst->
mark(BIT_MARK_US);
25 for (uint8_t item : data.
data) {
27 checksum += (item >> 4) + (item & 0xF);
33 for (uint8_t b = 0; b < 8; b++) {
34 if (item & (1UL << b)) {
35 dst->
space(BIT_ONE_SPACE_US);
37 dst->
space(BIT_ZERO_SPACE_US);
39 dst->
mark(BIT_MARK_US);
44 if (!src.
expect_item(HEADER_MARK_US, HEADER_SPACE_US)) {
51 if (size < MIRAGE_IR_PACKET_BIT_SIZE * 2)
53 size = MIRAGE_IR_PACKET_BIT_SIZE * 2;
58 for (uint8_t b = 0; b < 8; b++) {
70 checksum += (data >> 4) + (data & 0xF);
71 out.
data.push_back(data);
72 }
else if (checksum != data) {
std::string format_hex_pretty(const uint8_t *data, size_t length)
Format the byte array data of length len in pretty-printed, human-readable hex.
void set_carrier_frequency(uint32_t carrier_frequency)
void encode(RemoteTransmitData *dst, const MirageData &data) override
std::vector< uint8_t > data
bool expect_space(uint32_t length)
bool expect_mark(uint32_t length)
void mark(uint32_t length)
uint32_t get_index() const
void encode_byte_(RemoteTransmitData *dst, uint8_t item)
void space(uint32_t length)
Implementation of SPI Controller mode.
optional< MirageData > decode(RemoteReceiveData src) override
void reserve(uint32_t len)
constexpr unsigned int MIRAGE_IR_PACKET_BIT_SIZE
bool expect_item(uint32_t mark, uint32_t space)
void dump(const MirageData &data) override