5 namespace remote_base {
7 static const char *
const TAG =
"remote.pioneer";
9 static const uint32_t HEADER_HIGH_US = 9000;
10 static const uint32_t HEADER_LOW_US = 4500;
11 static const uint32_t BIT_HIGH_US = 560;
12 static const uint32_t BIT_ONE_LOW_US = 1690;
13 static const uint32_t BIT_ZERO_LOW_US = 560;
14 static const uint32_t TRAILER_SPACE_US = 25500;
19 uint32_t command1 = 0;
20 uint32_t command2 = 0;
22 for (uint32_t bit = 0; bit < 4; bit++) {
24 command1 |= (1UL << (7 - bit));
27 for (uint32_t bit = 0; bit < 4; bit++) {
29 command1 |= (1UL << (3 - bit));
32 for (uint32_t bit = 0; bit < 4; bit++) {
34 command2 |= (1UL << (7 - bit));
37 for (uint32_t bit = 0; bit < 4; bit++) {
39 command2 |= (1UL << (3 - bit));
42 command1 = (command1 << 8) | ((~command1) & 0xff);
43 command2 = (command2 << 8) | ((~command2) & 0xff);
53 dst->
item(HEADER_HIGH_US, HEADER_LOW_US);
54 for (uint32_t mask = 1UL << 15; mask; mask >>= 1) {
55 if (address1 & mask) {
56 dst->
item(BIT_HIGH_US, BIT_ONE_LOW_US);
58 dst->
item(BIT_HIGH_US, BIT_ZERO_LOW_US);
62 for (uint32_t mask = 1UL << 15; mask; mask >>= 1) {
63 if (command1 & mask) {
64 dst->
item(BIT_HIGH_US, BIT_ONE_LOW_US);
66 dst->
item(BIT_HIGH_US, BIT_ZERO_LOW_US);
70 dst->
mark(BIT_HIGH_US);
73 dst->
space(TRAILER_SPACE_US);
74 dst->
item(HEADER_HIGH_US, HEADER_LOW_US);
75 for (uint32_t mask = 1UL << 15; mask; mask >>= 1) {
76 if (address2 & mask) {
77 dst->
item(BIT_HIGH_US, BIT_ONE_LOW_US);
79 dst->
item(BIT_HIGH_US, BIT_ZERO_LOW_US);
83 for (uint32_t mask = 1UL << 15; mask; mask >>= 1) {
84 if (command2 & mask) {
85 dst->
item(BIT_HIGH_US, BIT_ONE_LOW_US);
87 dst->
item(BIT_HIGH_US, BIT_ZERO_LOW_US);
91 dst->
mark(BIT_HIGH_US);
95 uint16_t address1 = 0;
96 uint16_t command1 = 0;
102 if (!src.
expect_item(HEADER_HIGH_US, HEADER_LOW_US))
105 for (uint32_t mask = 1UL << 15; mask != 0; mask >>= 1) {
106 if (src.
expect_item(BIT_HIGH_US, BIT_ONE_LOW_US)) {
108 }
else if (src.
expect_item(BIT_HIGH_US, BIT_ZERO_LOW_US)) {
115 for (uint32_t mask = 1UL << 15; mask != 0; mask >>= 1) {
116 if (src.
expect_item(BIT_HIGH_US, BIT_ONE_LOW_US)) {
118 }
else if (src.
expect_item(BIT_HIGH_US, BIT_ZERO_LOW_US)) {
128 if ((address1 >> 8) != ((~address1) & 0xff))
131 if ((command1 >> 8) != ((~command1) & 0xff))
134 for (uint32_t bit = 0; bit < 4; bit++) {
135 if ((~command1 >> bit) & 1)
136 data.rc_code_1 |= (1UL << (7 - bit));
139 for (uint32_t bit = 0; bit < 4; bit++) {
140 if ((~command1 >> (bit + 4)) & 1)
141 data.rc_code_1 |= (1UL << (3 - bit));
143 data.rc_code_1 |= address1 & 0xff00;
149 ESP_LOGI(TAG,
"Received Pioneer: rc_code_X=0x%04X", data.
rc_code_1);
151 ESP_LOGI(TAG,
"Received Pioneer: rc_code_1=0x%04X, rc_code_2=0x%04X", data.
rc_code_1, data.
rc_code_2);
void set_carrier_frequency(uint32_t carrier_frequency)
void item(uint32_t mark, uint32_t space)
void encode(RemoteTransmitData *dst, const PioneerData &data) override
bool expect_mark(uint32_t length)
void mark(uint32_t length)
optional< PioneerData > decode(RemoteReceiveData src) override
void space(uint32_t length)
Implementation of SPI Controller mode.
void dump(const PioneerData &data) override
void reserve(uint32_t len)
bool expect_item(uint32_t mark, uint32_t space)