diff --git a/examples/IRMQTTServer/IRMQTTServer.ino b/examples/IRMQTTServer/IRMQTTServer.ino index 399cf55a5..b301adac3 100644 --- a/examples/IRMQTTServer/IRMQTTServer.ino +++ b/examples/IRMQTTServer/IRMQTTServer.ino @@ -1659,7 +1659,8 @@ bool parseStringAndSendAirCon(IRsend *irsend, const decode_type_t irType, stateSize = inputLength / 2; // Every two hex chars is a byte. // Use at least the minimum size. stateSize = std::max(stateSize, - static_cast(kFujitsuAcStateLengthShort - 1)); + static_cast(kFujitsuAcStateLengthShort - + 1)); // If we think it isn't a "short" message. if (stateSize > kFujitsuAcStateLengthShort) // Then it has to be at least the smaller version of the "normal" size. @@ -1703,12 +1704,13 @@ bool parseStringAndSendAirCon(IRsend *irsend, const decode_type_t irType, // the correct length/byte size. stateSize = inputLength / 2; // Every two hex chars is a byte. // Use at least the minimum size. - stateSize = std::max(stateSize, static_cast(kSamsungAcStateLength)); + stateSize = std::max(stateSize, + static_cast(kSamsungAcStateLength)); // If we think it isn't a "normal" message. if (stateSize > kSamsungAcStateLength) // Then it probably the extended size. - stateSize = std::max(stateSize, - static_cast(kSamsungAcExtendedStateLength)); + stateSize = std::max( + stateSize, static_cast(kSamsungAcExtendedStateLength)); // Lastly, it should never exceed the maximum "extended" size. stateSize = std::min(stateSize, kSamsungAcExtendedStateLength); break; diff --git a/src/IRac.h b/src/IRac.h index e3c261d0d..ae78b8ce3 100644 --- a/src/IRac.h +++ b/src/IRac.h @@ -574,8 +574,8 @@ static stdAc::state_t handleToggles(const stdAc::state_t desired, /// Common functions for use with all A/Cs supported by the IRac class. namespace IRAcUtils { - String resultAcToString(const decode_results * const results); - bool decodeToState(const decode_results *decode, stdAc::state_t *result, - const stdAc::state_t *prev = NULL); +String resultAcToString(const decode_results * const results); +bool decodeToState(const decode_results *decode, stdAc::state_t *result, + const stdAc::state_t *prev = NULL); } // namespace IRAcUtils #endif // IRAC_H_ diff --git a/src/IRrecv.cpp b/src/IRrecv.cpp index 2b73f0682..f8496feb3 100644 --- a/src/IRrecv.cpp +++ b/src/IRrecv.cpp @@ -1231,8 +1231,8 @@ uint32_t IRrecv::ticksLow(const uint32_t usecs, const uint8_t tolerance, /// @return Nr. of ticks. uint32_t IRrecv::ticksHigh(const uint32_t usecs, const uint8_t tolerance, const uint16_t delta) { - return ((uint32_t)(usecs * (1.0 + _validTolerance(tolerance) / 100.0)) + 1 + - delta); + return (static_cast(usecs * (1.0 + _validTolerance(tolerance) / + 100.0)) + 1 + delta); } /// Check if we match a pulse(measured) with the desired within @@ -1283,7 +1283,8 @@ bool IRrecv::matchAtLeast(uint32_t measured, uint32_t desired, DPRINT(". Matching: "); DPRINT(measured); DPRINT(" >= "); - DPRINT(ticksLow(std::min(desired, static_cast(MS_TO_USEC(params.timeout))), + DPRINT(ticksLow(std::min(desired, + static_cast(MS_TO_USEC(params.timeout))), tolerance, delta)); DPRINT(" [min("); DPRINT(ticksLow(desired, tolerance, delta)); @@ -1305,7 +1306,8 @@ bool IRrecv::matchAtLeast(uint32_t measured, uint32_t desired, // in the buffer. If that is the case, then assume infinity and return true. if (measured == 0) return true; return measured >= ticksLow(std::min( - desired, static_cast(MS_TO_USEC(params.timeout))), tolerance, delta); + desired, static_cast(MS_TO_USEC(params.timeout))), tolerance, + delta); } /// Check if we match a mark signal(measured) with the desired within diff --git a/src/IRremoteESP8266.h b/src/IRremoteESP8266.h index b5daffaf8..4a0e60bf2 100644 --- a/src/IRremoteESP8266.h +++ b/src/IRremoteESP8266.h @@ -1507,12 +1507,24 @@ const uint16_t kYorkStateLength = 17; #ifdef DEBUG #ifdef UNIT_TEST -#define DPRINT(x) do { std::cout << x; } while (0) -#define DPRINTLN(x) do { std::cout << x << std::endl; } while (0) +#define DPRINT(x) do { \ + std::cout << x; \ + } \ + while (0) +#define DPRINTLN(x) do { \ + std::cout << x << std::endl; \ + } \ + while (0) #endif // UNIT_TEST #ifdef ARDUINO -#define DPRINT(x) do { Serial.print(x); } while (0) -#define DPRINTLN(x) do { Serial.println(x); } while (0) +#define DPRINT(x) do { \ + Serial.print(x); \ + } \ + while (0) +#define DPRINTLN(x) do { \ + Serial.println(x); \ + } \ + while (0) #endif // ARDUINO #else // DEBUG #define DPRINT(x) diff --git a/src/IRsend.cpp b/src/IRsend.cpp index 1864ee2a3..8b2309b8f 100644 --- a/src/IRsend.cpp +++ b/src/IRsend.cpp @@ -74,9 +74,9 @@ uint32_t IRsend::calcUSecPeriod(uint32_t hz, bool use_offset) { (1000000UL + hz / 2) / hz; // The equiv of round(1000000/hz). // Apply the offset and ensure we don't result in a <= 0 value. if (use_offset) - return std::max((uint32_t)1, period + periodOffset); + return std::max(static_cast(1), period + periodOffset); else - return std::max((uint32_t)1, period); + return std::max(static_cast(1), period); } /// Set the output frequency modulation and duty cycle. @@ -174,14 +174,16 @@ uint16_t IRsend::mark(uint16_t usec) { ledOn(); // Calculate how long we should pulse on for. // e.g. Are we to close to the end of our requested mark time (usec)? - _delayMicroseconds(std::min((uint32_t)onTimePeriod, usec - elapsed)); + _delayMicroseconds(std::min(static_cast(onTimePeriod), + usec - elapsed)); ledOff(); counter++; if (elapsed + onTimePeriod >= usec) return counter; // LED is now off & we've passed our allotted time. // Wait for the lesser of the rest of the duty cycle, or the time remaining. _delayMicroseconds( - std::min(usec - elapsed - onTimePeriod, (uint32_t)offTimePeriod)); + std::min(usec - elapsed - onTimePeriod, + static_cast(offTimePeriod))); elapsed = usecTimer.elapsed(); // Update & recache the actual elapsed time. } return counter; @@ -214,7 +216,7 @@ int8_t IRsend::calibrate(uint16_t hz) { uint32_t timeTaken = usecTimer.elapsed(); // Record the time it took. // While it shouldn't be necessary, assume at least 1 pulse, to avoid a // divide by 0 situation. - pulses = std::max(pulses, (uint16_t)1U); + pulses = std::max(pulses, static_cast(1U)); uint32_t calcPeriod = calcUSecPeriod(hz); // e.g. @38kHz it should be 26us. // Assuming 38kHz for the example calculations: // In a 65535us pulse, we should have 2520.5769 pulses @ 26us periods. diff --git a/src/IRutils.cpp b/src/IRutils.cpp index 45e631098..299545484 100644 --- a/src/IRutils.cpp +++ b/src/IRutils.cpp @@ -1422,7 +1422,7 @@ uint8_t lowLevelSanityCheck(void) { uint64_t _usused_2:18; // 44-61st bits uint64_t highest2bits:2; // 62-63rd bits }; - uint64_t all; + uint64_t all; }; bitpackdata data; diff --git a/src/IRutils.h b/src/IRutils.h index 971d6eebc..65a9b4dea 100644 --- a/src/IRutils.h +++ b/src/IRutils.h @@ -122,17 +122,17 @@ bool getBit(const uint8_t data, const uint8_t position); #define GETBIT32(a, b) ((a) & (static_cast(1) << (b))) #define GETBIT64(a, b) ((a) & (static_cast(1) << (b))) #define GETBITS8(data, offset, size) \ - (((data) & ((static_cast(UINT8_MAX) >> (8 - (size))) << (offset))) >> \ - (offset)) + (((data) & ((static_cast(UINT8_MAX) >> (8 - (size))) << \ + (offset))) >> (offset)) #define GETBITS16(data, offset, size) \ - (((data) & ((static_cast(UINT16_MAX) >> (16 - (size))) << (offset))) >> \ - (offset)) + (((data) & ((static_cast(UINT16_MAX) >> (16 - (size))) << \ + (offset))) >> (offset)) #define GETBITS32(data, offset, size) \ - (((data) & ((static_cast(UINT32_MAX) >> (32 - (size))) << (offset))) >> \ - (offset)) + (((data) & ((static_cast(UINT32_MAX) >> (32 - (size))) << \ + (offset))) >> (offset)) #define GETBITS64(data, offset, size) \ - (((data) & ((static_cast(UINT64_MAX) >> (64 - (size))) << (offset))) >> \ - (offset)) + (((data) & ((static_cast(UINT64_MAX) >> (64 - (size))) << \ + (offset))) >> (offset)) uint64_t setBit(const uint64_t data, const uint8_t position, const bool on = true, const uint8_t size = 64); uint8_t setBit(const uint8_t data, const uint8_t position, diff --git a/src/ir_Argo.cpp b/src/ir_Argo.cpp index ca177c515..ba72764a9 100644 --- a/src/ir_Argo.cpp +++ b/src/ir_Argo.cpp @@ -12,6 +12,8 @@ #include #include #include +#include +#include #ifndef UNIT_TEST #include #endif // UNIT_TEST diff --git a/src/ir_Daikin.cpp b/src/ir_Daikin.cpp index b96f150d6..fc93ef52a 100644 --- a/src/ir_Daikin.cpp +++ b/src/ir_Daikin.cpp @@ -74,7 +74,8 @@ void IRsend::sendDaikin(const unsigned char data[], const uint16_t nbytes, sendGeneric(0, 0, // No header for the header kDaikinBitMark, kDaikinOneSpace, kDaikinBitMark, kDaikinZeroSpace, kDaikinBitMark, kDaikinZeroSpace + kDaikinGap, - static_cast(0b00000), kDaikinHeaderLength, 38, false, 0, 50); + static_cast(0b00000), kDaikinHeaderLength, 38, false, + 0, 50); // Data #1 if (nbytes < kDaikinStateLength) { // Are we using the legacy size? // Do this as a constant to save RAM and keep in flash memory diff --git a/src/ir_GlobalCache.cpp b/src/ir_GlobalCache.cpp index a498c7183..4fbc34050 100644 --- a/src/ir_GlobalCache.cpp +++ b/src/ir_GlobalCache.cpp @@ -37,7 +37,8 @@ void IRsend::sendGC(uint16_t buf[], uint16_t len) { enableIROut(hz); uint32_t periodic_time = calcUSecPeriod(hz, false); uint8_t emits = - std::min(buf[kGlobalCacheRptIndex], static_cast(kGlobalCacheMaxRepeat)); + std::min(buf[kGlobalCacheRptIndex], + static_cast(kGlobalCacheMaxRepeat)); // Repeat for (uint8_t repeat = 0; repeat < emits; repeat++) { // First time through, start at the beginning (kGlobalCacheStartIndex), diff --git a/src/ir_Kelon.cpp b/src/ir_Kelon.cpp index 45a1fc1a6..c891b738f 100644 --- a/src/ir_Kelon.cpp +++ b/src/ir_Kelon.cpp @@ -318,8 +318,9 @@ void IRKelonAc::setTimer(uint16_t mins) { /// @return The timer set minutes uint16_t IRKelonAc::getTimer() const { if (_.TimerHours >= 10) - return (static_cast((_.TimerHours << 1) | _.TimerHalfHour) - 10) * 60; - return (static_cast(_.TimerHours) * 60) + (_.TimerHalfHour ? 30 : 0); + return (static_cast((_.TimerHours << 1) | _.TimerHalfHour) - + 10) * 60; + return static_cast(_.TimerHours) * 60 + (_.TimerHalfHour ? 30 : 0); } /// Enable or disable the timer. Note that in order to enable the timer the diff --git a/src/ir_Mirage.cpp b/src/ir_Mirage.cpp index 899bdcdc1..caa72375a 100644 --- a/src/ir_Mirage.cpp +++ b/src/ir_Mirage.cpp @@ -389,8 +389,9 @@ void IRMirageAc::setClock(const uint32_t nr_of_seconds) { _.Minutes = _.Seconds = 0; // No clock setting. Clear it just in case. break; default: + // Limit to 23:59:59 uint32_t remaining = std::min( - nr_of_seconds, static_cast(24 * 60 * 60 - 1)); // Limit to 23:59:59 + nr_of_seconds, static_cast(24 * 60 * 60 - 1)); _.Seconds = uint8ToBcd(remaining % 60); remaining /= 60; _.Minutes = uint8ToBcd(remaining % 60); @@ -586,7 +587,7 @@ uint16_t IRMirageAc::getOnTimer(void) const { /// Set the number of minutes for the On Timer. /// @param[in] nr_of_mins How long to set the timer for. 0 disables the timer. void IRMirageAc::setOnTimer(const uint16_t nr_of_mins) { - uint16_t mins = std::min(nr_of_mins, (uint16_t)(24 * 60)); + uint16_t mins = std::min(nr_of_mins, static_cast(24 * 60)); switch (_model) { case mirage_ac_remote_model_t::KKG29AC1: _.OnTimerEnable = (mins > 0); diff --git a/src/ir_Panasonic.cpp b/src/ir_Panasonic.cpp index d45290f94..a9426e450 100644 --- a/src/ir_Panasonic.cpp +++ b/src/ir_Panasonic.cpp @@ -88,7 +88,8 @@ void IRsend::sendPanasonic64(const uint64_t data, const uint16_t nbits, /// @note This protocol is a modified version of Kaseikyo. void IRsend::sendPanasonic(const uint16_t address, const uint32_t data, const uint16_t nbits, const uint16_t repeat) { - sendPanasonic64((static_cast(address) << 32) | static_cast(data), + sendPanasonic64(static_cast(address) << 32 | + static_cast(data), nbits, repeat); } @@ -107,9 +108,9 @@ uint64_t IRsend::encodePanasonic(const uint16_t manufacturer, const uint8_t function) { uint8_t checksum = device ^ subdevice ^ function; return ((static_cast(manufacturer) << 32) | - (static_cast(device) << 24) | + (static_cast(device) << 24) | (static_cast(subdevice) << 16) | - (static_cast(function) << 8) | checksum); + (static_cast(function) << 8) | checksum); } #endif // (SEND_PANASONIC || SEND_DENON) diff --git a/src/ir_Pioneer.cpp b/src/ir_Pioneer.cpp index 2a8dc15ca..98f4420f1 100644 --- a/src/ir_Pioneer.cpp +++ b/src/ir_Pioneer.cpp @@ -80,7 +80,7 @@ void IRsend::sendPioneer(const uint64_t data, const uint16_t nbits, /// `irsend.sendPioneer(irsend.encodePioneer(0xAA1C, 0xAA1C), 64, 0);` /// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/1749#issuecomment-1028122645 uint64_t IRsend::encodePioneer(const uint16_t address, const uint16_t command) { - return (static_cast(encodeNEC(address >> 8, address & 0xFF)) << 32) | + return static_cast(encodeNEC(address >> 8, address & 0xFF)) << 32 | encodeNEC(command >> 8, command & 0xFF); } #endif // SEND_PIONEER diff --git a/src/ir_Pronto.cpp b/src/ir_Pronto.cpp index 2dc3d89cf..dcd513d10 100644 --- a/src/ir_Pronto.cpp +++ b/src/ir_Pronto.cpp @@ -62,7 +62,8 @@ void IRsend::sendPronto(uint16_t data[], uint16_t len, uint16_t repeat) { // Pronto frequency is in Hz. uint16_t hz = - static_cast(1000000U / (data[kProntoFreqOffset] * kProntoFreqFactor)); + static_cast(1000000U / (data[kProntoFreqOffset] * + kProntoFreqFactor)); enableIROut(hz); // Grab the length of the two sequences. diff --git a/src/ir_RCMM.cpp b/src/ir_RCMM.cpp index d33518a8d..36cbbd51a 100644 --- a/src/ir_RCMM.cpp +++ b/src/ir_RCMM.cpp @@ -101,13 +101,15 @@ bool IRrecv::decodeRCMM(decode_results *results, uint16_t offset, // Calc the maximum size in bits, the message can be, or that we can accept. int16_t maxBitSize = - std::min(static_cast(results->rawlen) - 5, (uint16_t)sizeof(data) * 8); + std::min(static_cast(results->rawlen) - 5, + static_cast(sizeof(data)) * 8); // Compliance if (strict) { // Technically the spec says bit sizes should be 12 xor 24. however // 32 bits has been seen from a device. We are going to assume // 12 <= bits <= 32 is the 'required' bit length for the spec. - if (maxBitSize < 12 || maxBitSize > 32) return false; + if (maxBitSize < 12 || maxBitSize > 32) + return false; if (maxBitSize < nbits) return false; // Short cut, we can never reach the expected nr. of bits. } diff --git a/src/ir_Sherwood.cpp b/src/ir_Sherwood.cpp index 04155279c..e3a7eb506 100644 --- a/src/ir_Sherwood.cpp +++ b/src/ir_Sherwood.cpp @@ -19,6 +19,7 @@ /// @note Sherwood remote codes appear to be NEC codes with a mandatory repeat /// code. i.e. repeat should be >= kSherwoodMinRepeat (1). void IRsend::sendSherwood(uint64_t data, uint16_t nbits, uint16_t repeat) { - sendNEC(data, nbits, std::max(static_cast(kSherwoodMinRepeat), repeat)); + sendNEC(data, nbits, + std::max(static_cast(kSherwoodMinRepeat), repeat)); } #endif // SEND_SHERWOOD diff --git a/src/ir_Teco.cpp b/src/ir_Teco.cpp index b06db1366..a8845fb05 100644 --- a/src/ir_Teco.cpp +++ b/src/ir_Teco.cpp @@ -231,7 +231,8 @@ uint16_t IRTecoAc::getTimer(void) const { /// `0` will clear the timer. Max is 24 hrs. /// @note Time is stored internally in increments of 30 mins. void IRTecoAc::setTimer(const uint16_t nr_mins) { - uint16_t mins = std::min(nr_mins, static_cast(24 * 60)); // Limit to 24 hrs + // Limit to 24 hrs + uint16_t mins = std::min(nr_mins, static_cast(24 * 60)); uint8_t hours = mins / 60; _.TimerOn = mins > 0; // Set the timer flag. _.HalfHour = (mins % 60) >= 30; diff --git a/test/IRutils_test.cpp b/test/IRutils_test.cpp index 819197555..d0d15c896 100644 --- a/test/IRutils_test.cpp +++ b/test/IRutils_test.cpp @@ -611,7 +611,8 @@ TEST(TestUtils, setBit) { EXPECT_EQ(0b100, irutils::setBit(static_cast(0b110), 1, false)); EXPECT_EQ(0b111, irutils::setBit(static_cast(0b101), 1, true)); EXPECT_EQ(0b110, irutils::setBit(static_cast(0b110), 1, true)); - EXPECT_EQ(0b11111111, irutils::setBit(static_cast(0b01111111), 7, true)); + EXPECT_EQ(0b11111111, + irutils::setBit(static_cast(0b01111111), 7, true)); EXPECT_EQ(0, irutils::setBit(static_cast(0b10000000), 7, false)); // uint8_t Pointer method. uint8_t data = 0; diff --git a/tools/gc_decode.cpp b/tools/gc_decode.cpp index 77edb48c8..d1a543867 100644 --- a/tools/gc_decode.cpp +++ b/tools/gc_decode.cpp @@ -5,8 +5,8 @@ #include #include #include -#include #include +#include #include #include #include "IRac.h" diff --git a/tools/mode2_decode.cpp b/tools/mode2_decode.cpp index 1c46f70e2..e81df390b 100644 --- a/tools/mode2_decode.cpp +++ b/tools/mode2_decode.cpp @@ -20,8 +20,8 @@ space 500000 #include #include #include -#include #include +#include #include #include #include