mirror of
https://github.com/esphome/esphome.git
synced 2024-11-26 00:48:19 +01:00
Fix byte order in NEC protocol implementation (#2534)
This commit is contained in:
parent
06994c0dfc
commit
6f9439e1bc
1 changed files with 4 additions and 4 deletions
|
@ -17,14 +17,14 @@ void NECProtocol::encode(RemoteTransmitData *dst, const NECData &data) {
|
||||||
dst->set_carrier_frequency(38000);
|
dst->set_carrier_frequency(38000);
|
||||||
|
|
||||||
dst->item(HEADER_HIGH_US, HEADER_LOW_US);
|
dst->item(HEADER_HIGH_US, HEADER_LOW_US);
|
||||||
for (uint32_t mask = 1UL << 15; mask; mask >>= 1) {
|
for (uint16_t mask = 1; mask; mask <<= 1) {
|
||||||
if (data.address & mask)
|
if (data.address & mask)
|
||||||
dst->item(BIT_HIGH_US, BIT_ONE_LOW_US);
|
dst->item(BIT_HIGH_US, BIT_ONE_LOW_US);
|
||||||
else
|
else
|
||||||
dst->item(BIT_HIGH_US, BIT_ZERO_LOW_US);
|
dst->item(BIT_HIGH_US, BIT_ZERO_LOW_US);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32_t mask = 1UL << 15; mask; mask >>= 1) {
|
for (uint16_t mask = 1; mask; mask <<= 1) {
|
||||||
if (data.command & mask)
|
if (data.command & mask)
|
||||||
dst->item(BIT_HIGH_US, BIT_ONE_LOW_US);
|
dst->item(BIT_HIGH_US, BIT_ONE_LOW_US);
|
||||||
else
|
else
|
||||||
|
@ -41,7 +41,7 @@ optional<NECData> NECProtocol::decode(RemoteReceiveData src) {
|
||||||
if (!src.expect_item(HEADER_HIGH_US, HEADER_LOW_US))
|
if (!src.expect_item(HEADER_HIGH_US, HEADER_LOW_US))
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
for (uint32_t mask = 1UL << 15; mask != 0; mask >>= 1) {
|
for (uint16_t mask = 1; mask; mask <<= 1) {
|
||||||
if (src.expect_item(BIT_HIGH_US, BIT_ONE_LOW_US)) {
|
if (src.expect_item(BIT_HIGH_US, BIT_ONE_LOW_US)) {
|
||||||
data.address |= mask;
|
data.address |= mask;
|
||||||
} else if (src.expect_item(BIT_HIGH_US, BIT_ZERO_LOW_US)) {
|
} else if (src.expect_item(BIT_HIGH_US, BIT_ZERO_LOW_US)) {
|
||||||
|
@ -51,7 +51,7 @@ optional<NECData> NECProtocol::decode(RemoteReceiveData src) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32_t mask = 1UL << 15; mask != 0; mask >>= 1) {
|
for (uint16_t mask = 1; mask; mask <<= 1) {
|
||||||
if (src.expect_item(BIT_HIGH_US, BIT_ONE_LOW_US)) {
|
if (src.expect_item(BIT_HIGH_US, BIT_ONE_LOW_US)) {
|
||||||
data.command |= mask;
|
data.command |= mask;
|
||||||
} else if (src.expect_item(BIT_HIGH_US, BIT_ZERO_LOW_US)) {
|
} else if (src.expect_item(BIT_HIGH_US, BIT_ZERO_LOW_US)) {
|
||||||
|
|
Loading…
Reference in a new issue