From e9c12e47f622cdbbefc65f1b12006f1fb272a693 Mon Sep 17 00:00:00 2001 From: yoziru Date: Sun, 4 Aug 2024 21:56:00 +0200 Subject: [PATCH] run script/lint-cpp --- .../components/argo_ulisse/argo_ulisse.cpp | 22 +++++++-------- esphome/components/argo_ulisse/argo_ulisse.h | 28 +++++++++---------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/esphome/components/argo_ulisse/argo_ulisse.cpp b/esphome/components/argo_ulisse/argo_ulisse.cpp index d6fb644b3d..d9028029e1 100644 --- a/esphome/components/argo_ulisse/argo_ulisse.cpp +++ b/esphome/components/argo_ulisse/argo_ulisse.cpp @@ -34,7 +34,7 @@ uint8_t ArgoUlisseClimate::calc_checksum_(const ArgoProtocolWREM3 *data, size_t return 0; // Changed from -1 to 0 as the return type is uint8_t } - size_t payloadSizeBits = (length - 1) * 8; // Last byte carries checksum + size_t payload_size_bits = (length - 1) * 8; // Last byte carries checksum uint8_t checksum = 0; // Initialize checksum const uint8_t *ptr = data->raw; // Point to the start of the raw data @@ -45,11 +45,11 @@ uint8_t ArgoUlisseClimate::calc_checksum_(const ArgoProtocolWREM3 *data, size_t } // Add stray bits from last byte to the checksum (if any) - const uint8_t maskPayload = 0xFF >> (8 - (payloadSizeBits % 8)); - checksum += (ptr[length - 1] & maskPayload); + const uint8_t mask_payload = 0xFF >> (8 - (payload_size_bits % 8)); + checksum += (ptr[length - 1] & mask_payload); - const uint8_t maskChecksum = 0xFF >> (payloadSizeBits % 8); - return checksum & maskChecksum; + const uint8_t mask_checksum = 0xFF >> (payload_size_bits % 8); + return checksum & mask_checksum; } void ArgoUlisseClimate::transmit_state() { @@ -61,7 +61,7 @@ void ArgoUlisseClimate::transmit_state() { // Set up the header ac_packet.Pre1 = ARGO_PREAMBLE; ac_packet.IrChannel = 0; // Assume channel 0, adjust if needed - ac_packet.IrCommandType = ArgoIRMessageType_AC_CONTROL; + ac_packet.IrCommandType = ARGO_IR_MESSAGE_TYPE_AC_CONTROL; // Set default HA clima features ESP_LOGV(TAG, " Setting default HA climate features.."); @@ -90,7 +90,7 @@ void ArgoUlisseClimate::transmit_state() { // Calculate checksum ESP_LOGV(TAG, " Calculating AC checksum.."); - ac_packet.Sum = this->calc_checksum_(&ac_packet, ArgoIRMessageLength_AC_CONTROL); + ac_packet.Sum = this->calc_checksum_(&ac_packet, ARGO_IR_MESSAGE_LENGTH_AC_CONTROL); // Transmit the IR signal auto transmit = this->transmitter_->transmit(); @@ -102,7 +102,7 @@ void ArgoUlisseClimate::transmit_state() { data->space(ARGO_HEADER_SPACE); // Transmit the data - for (uint8_t i = 0; i < ArgoIRMessageLength_AC_CONTROL; i++) { + for (uint8_t i = 0; i < ARGO_IR_MESSAGE_LENGTH_AC_CONTROL; i++) { for (uint8_t mask = 1; mask > 0; mask <<= 1) { data->mark(ARGO_BIT_MARK); bool bit = ac_packet.raw[i] & mask; @@ -126,13 +126,13 @@ void ArgoUlisseClimate::transmit_ifeel_() { // Set up the header ifeel_packet.Pre1 = ARGO_PREAMBLE; ifeel_packet.IrChannel = 0; // Assume channel 0, adjust if needed - ifeel_packet.IrCommandType = ArgoIRMessageType_IFEEL_TEMP_REPORT; + ifeel_packet.IrCommandType = ARGO_IR_MESSAGE_TYPE_IFEEL_TEMP_REPORT; ifeel_packet.ifeelreport.SensorT = this->sensor_temperature_(); // Calculate checksum ESP_LOGV(TAG, " Calculating iFeel checksum.."); - ifeel_packet.ifeelreport.CheckHi = this->calc_checksum_(&ifeel_packet, ArgoIRMessageLength_IFEEL_TEMP_REPORT); + ifeel_packet.ifeelreport.CheckHi = this->calc_checksum_(&ifeel_packet, ARGO_IR_MESSAGE_LENGTH_IFEEL_TEMP_REPORT); // Transmit the IR signal auto transmit = this->transmitter_->transmit(); @@ -144,7 +144,7 @@ void ArgoUlisseClimate::transmit_ifeel_() { data->space(ARGO_HEADER_SPACE); // Transmit the data - for (uint8_t i = 0; i < ArgoIRMessageLength_IFEEL_TEMP_REPORT; i++) { + for (uint8_t i = 0; i < ARGO_IR_MESSAGE_LENGTH_IFEEL_TEMP_REPORT; i++) { for (uint8_t mask = 1; mask > 0; mask <<= 1) { data->mark(ARGO_BIT_MARK); bool bit = ifeel_packet.raw[i] & mask; diff --git a/esphome/components/argo_ulisse/argo_ulisse.h b/esphome/components/argo_ulisse/argo_ulisse.h index 7c10824c5a..cab2fdddd0 100644 --- a/esphome/components/argo_ulisse/argo_ulisse.h +++ b/esphome/components/argo_ulisse/argo_ulisse.h @@ -84,7 +84,7 @@ union ArgoProtocolWREM3 { // Byte5 uint8_t Sum : 8; /// Checksum }; - struct iFeelReport { + struct IFeelReport { // Byte 0 (same definition across the union) uint8_t : 8; // {Pre1 | IrChannel | IrCommandType} // Byte 1 @@ -128,20 +128,20 @@ union ArgoProtocolWREM3 { }; #pragma pack(pop) -typedef enum _ArgoIRMessageType { - ArgoIRMessageType_AC_CONTROL = 0, - ArgoIRMessageType_IFEEL_TEMP_REPORT = 1, - ArgoIRMessageType_TIMER_COMMAND = 2, - ArgoIRMessageType_CONFIG_PARAM_SET = 3, -} ArgoIRMessageType; +using ArgoIRMessageType = enum _ArgoIRMessageType { + ARGO_IR_MESSAGE_TYPE_AC_CONTROL = 0, + ARGO_IR_MESSAGE_TYPE_IFEEL_TEMP_REPORT = 1, + ARGO_IR_MESSAGE_TYPE_TIMER_COMMAND = 2, + ARGO_IR_MESSAGE_TYPE_CONFIG_PARAM_SET = 3, +}; // raw byte length depends on message type -typedef enum _ArgoIRMessageLength { - ArgoIRMessageLength_AC_CONTROL = 6, - ArgoIRMessageLength_IFEEL_TEMP_REPORT = 2, - ArgoIRMessageLength_TIMER_COMMAND = 9, - ArgoIRMessageLength_CONFIG_PARAM_SET = 4, -} ArgoIRMessageLength; +using ArgoIRMessageLength = enum _ArgoIRMessageLength { + ARGO_IR_MESSAGE_LENGTH_AC_CONTROL = 6, + ARGO_IR_MESSAGE_LENGTH_IFEEL_TEMP_REPORT = 2, + ARGO_IR_MESSAGE_LENGTH_TIMER_COMMAND = 9, + ARGO_IR_MESSAGE_LENGTH_CONFIG_PARAM_SET = 4, +}; class ArgoUlisseClimate : public climate_ir::ClimateIR { public: @@ -184,7 +184,7 @@ class ArgoUlisseClimate : public climate_ir::ClimateIR { int32_t last_transmit_time_{}; void transmit_state() override; void transmit_ifeel_(); - uint8_t calc_checksum_(const ArgoProtocolWREM3 *data, size_t size); + uint8_t calc_checksum_(const ArgoProtocolWREM3 *data, size_t length); climate::ClimateTraits traits() override; uint8_t operation_mode_(); uint8_t fan_speed_();