From 2450a8d12c00d161a88f9f49cde07782780354a0 Mon Sep 17 00:00:00 2001 From: Lorenzo Prosseda Date: Tue, 12 Nov 2024 00:16:16 +0100 Subject: [PATCH] Comply w clang-tidy: refactor names, use bool val. --- esphome/components/airton/airton.cpp | 14 +++++++------- esphome/components/airton/airton.h | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/esphome/components/airton/airton.cpp b/esphome/components/airton/airton.cpp index 834f05545a..a2a658443a 100644 --- a/esphome/components/airton/airton.cpp +++ b/esphome/components/airton/airton.cpp @@ -5,7 +5,7 @@ namespace esphome { namespace airton { static const char *const TAG = "airton.climate"; -uint8_t previous_mode = 0; +uint8_t previous_mode_ = 0; void AirtonClimate::transmit_state() { // Sampled valid state @@ -81,9 +81,9 @@ uint8_t AirtonClimate::operation_mode_() { break; case climate::CLIMATE_MODE_OFF: default: - operating_mode = 0b0111 & this->previous_mode; // Set previous mode with power state bit off + operating_mode = 0b0111 & this->previous_mode_; // Set previous mode with power state bit off } - this->previous_mode = operating_mode; + this->previous_mode_ = operating_mode; return operating_mode; } @@ -107,7 +107,7 @@ uint16_t AirtonClimate::fan_speed_() { } bool AirtonClimate::turbo_control_() { - bool turbo_control = 0; // My remote seems to always have this set to 0 + bool turbo_control = false; // My remote seems to always have this set to 0 return turbo_control; } @@ -148,7 +148,7 @@ uint8_t AirtonClimate::operation_settings_() { } // From IRutils.h of IRremoteESP8266 library -uint8_t AirtonClimate::sumBytes_(const uint8_t *const start, const uint16_t length) { +uint8_t AirtonClimate::sum_bytes_(const uint8_t *const start, const uint16_t length) { uint8_t checksum = 0; const uint8_t *ptr; for (ptr = start; ptr - start < length; ptr++) @@ -157,11 +157,11 @@ uint8_t AirtonClimate::sumBytes_(const uint8_t *const start, const uint16_t leng } // From IRutils.h of IRremoteESP8266 library uint8_t AirtonClimate::checksum_(const uint8_t *r_state) { - uint8_t checksum = (uint8_t) (0x7F - this->sumBytes_(r_state, 6)) ^ 0x2C; + uint8_t checksum = (uint8_t) (0x7F - this->sum_bytes_(r_state, 6)) ^ 0x2C; return checksum; } -bool AirtonClimate::parse_state_frame_(const uint8_t frame[]) { +bool AirtonClimate::parse_state_frame_(uint8_t frame[]) { uint8_t mode = frame[2]; if (mode & 0b00001000) { // Check if power state bit is set switch (mode & 0b00000111) { // Mask anything but the least significant 3 bits diff --git a/esphome/components/airton/airton.h b/esphome/components/airton/airton.h index 1942cc54f1..f8ddc43370 100644 --- a/esphome/components/airton/airton.h +++ b/esphome/components/airton/airton.h @@ -47,7 +47,7 @@ class AirtonClimate : public climate_ir::ClimateIR { protected: // Save the previous operation mode globally - uint8_t previous_mode; + uint8_t previous_mode_; // IR transmission payload builder void transmit_state() override; @@ -59,12 +59,12 @@ class AirtonClimate : public climate_ir::ClimateIR { uint8_t swing_mode_(); uint8_t operation_settings_(); - uint8_t sumBytes_(const uint8_t *const start, const uint16_t length); + uint8_t sum_bytes_(const uint8_t *start, uint16_t length); uint8_t checksum_(const uint8_t *r_state); // IR receiver buffer bool on_receive(remote_base::RemoteReceiveData data) override; - bool parse_state_frame_(const uint8_t frame[]); + bool parse_state_frame_(uint8_t frame[]); }; } // namespace airton