From a30d2f291c47c79159c4a1eef8445ca50bcfc5e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20B=C3=ADr=C3=B3?= <1202136+andrasbiro@users.noreply.github.com> Date: Sun, 12 Jan 2020 16:25:32 +0100 Subject: [PATCH] Fix dump/tx of 64 bit codes (#940) * Fix dump/tx of 64 bit codes * fixed source format --- esphome/components/remote_base/rc_switch_protocol.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/components/remote_base/rc_switch_protocol.cpp b/esphome/components/remote_base/rc_switch_protocol.cpp index 754b2fae49..b2ff22eb2a 100644 --- a/esphome/components/remote_base/rc_switch_protocol.cpp +++ b/esphome/components/remote_base/rc_switch_protocol.cpp @@ -56,7 +56,7 @@ void RCSwitchBase::sync(RemoteTransmitData *dst) const { void RCSwitchBase::transmit(RemoteTransmitData *dst, uint64_t code, uint8_t len) const { dst->set_carrier_frequency(0); for (int16_t i = len - 1; i >= 0; i--) { - if (code & (1 << i)) + if (code & ((uint64_t) 1 << i)) this->one(dst); else this->zero(dst); @@ -237,7 +237,7 @@ bool RCSwitchDumper::dump(RemoteReceiveData src) { if (protocol->decode(src, &out_data, &out_nbits) && out_nbits >= 3) { char buffer[65]; for (uint8_t j = 0; j < out_nbits; j++) - buffer[j] = (out_data & (1 << (out_nbits - j - 1))) ? '1' : '0'; + buffer[j] = (out_data & ((uint64_t) 1 << (out_nbits - j - 1))) ? '1' : '0'; buffer[out_nbits] = '\0'; ESP_LOGD(TAG, "Received RCSwitch Raw: protocol=%u data='%s'", i, buffer);