mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 09:18:00 +01:00
run script/lint-cpp
This commit is contained in:
parent
f6b753a1ea
commit
e9c12e47f6
2 changed files with 25 additions and 25 deletions
|
@ -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
|
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
|
uint8_t checksum = 0; // Initialize checksum
|
||||||
const uint8_t *ptr = data->raw; // Point to the start of the raw data
|
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)
|
// Add stray bits from last byte to the checksum (if any)
|
||||||
const uint8_t maskPayload = 0xFF >> (8 - (payloadSizeBits % 8));
|
const uint8_t mask_payload = 0xFF >> (8 - (payload_size_bits % 8));
|
||||||
checksum += (ptr[length - 1] & maskPayload);
|
checksum += (ptr[length - 1] & mask_payload);
|
||||||
|
|
||||||
const uint8_t maskChecksum = 0xFF >> (payloadSizeBits % 8);
|
const uint8_t mask_checksum = 0xFF >> (payload_size_bits % 8);
|
||||||
return checksum & maskChecksum;
|
return checksum & mask_checksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArgoUlisseClimate::transmit_state() {
|
void ArgoUlisseClimate::transmit_state() {
|
||||||
|
@ -61,7 +61,7 @@ void ArgoUlisseClimate::transmit_state() {
|
||||||
// Set up the header
|
// Set up the header
|
||||||
ac_packet.Pre1 = ARGO_PREAMBLE;
|
ac_packet.Pre1 = ARGO_PREAMBLE;
|
||||||
ac_packet.IrChannel = 0; // Assume channel 0, adjust if needed
|
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
|
// Set default HA clima features
|
||||||
ESP_LOGV(TAG, " Setting default HA climate features..");
|
ESP_LOGV(TAG, " Setting default HA climate features..");
|
||||||
|
@ -90,7 +90,7 @@ void ArgoUlisseClimate::transmit_state() {
|
||||||
|
|
||||||
// Calculate checksum
|
// Calculate checksum
|
||||||
ESP_LOGV(TAG, " Calculating AC 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
|
// Transmit the IR signal
|
||||||
auto transmit = this->transmitter_->transmit();
|
auto transmit = this->transmitter_->transmit();
|
||||||
|
@ -102,7 +102,7 @@ void ArgoUlisseClimate::transmit_state() {
|
||||||
data->space(ARGO_HEADER_SPACE);
|
data->space(ARGO_HEADER_SPACE);
|
||||||
|
|
||||||
// Transmit the data
|
// 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) {
|
for (uint8_t mask = 1; mask > 0; mask <<= 1) {
|
||||||
data->mark(ARGO_BIT_MARK);
|
data->mark(ARGO_BIT_MARK);
|
||||||
bool bit = ac_packet.raw[i] & mask;
|
bool bit = ac_packet.raw[i] & mask;
|
||||||
|
@ -126,13 +126,13 @@ void ArgoUlisseClimate::transmit_ifeel_() {
|
||||||
// Set up the header
|
// Set up the header
|
||||||
ifeel_packet.Pre1 = ARGO_PREAMBLE;
|
ifeel_packet.Pre1 = ARGO_PREAMBLE;
|
||||||
ifeel_packet.IrChannel = 0; // Assume channel 0, adjust if needed
|
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_();
|
ifeel_packet.ifeelreport.SensorT = this->sensor_temperature_();
|
||||||
|
|
||||||
// Calculate checksum
|
// Calculate checksum
|
||||||
ESP_LOGV(TAG, " Calculating iFeel 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
|
// Transmit the IR signal
|
||||||
auto transmit = this->transmitter_->transmit();
|
auto transmit = this->transmitter_->transmit();
|
||||||
|
@ -144,7 +144,7 @@ void ArgoUlisseClimate::transmit_ifeel_() {
|
||||||
data->space(ARGO_HEADER_SPACE);
|
data->space(ARGO_HEADER_SPACE);
|
||||||
|
|
||||||
// Transmit the data
|
// 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) {
|
for (uint8_t mask = 1; mask > 0; mask <<= 1) {
|
||||||
data->mark(ARGO_BIT_MARK);
|
data->mark(ARGO_BIT_MARK);
|
||||||
bool bit = ifeel_packet.raw[i] & mask;
|
bool bit = ifeel_packet.raw[i] & mask;
|
||||||
|
|
|
@ -84,7 +84,7 @@ union ArgoProtocolWREM3 {
|
||||||
// Byte5
|
// Byte5
|
||||||
uint8_t Sum : 8; /// Checksum
|
uint8_t Sum : 8; /// Checksum
|
||||||
};
|
};
|
||||||
struct iFeelReport {
|
struct IFeelReport {
|
||||||
// Byte 0 (same definition across the union)
|
// Byte 0 (same definition across the union)
|
||||||
uint8_t : 8; // {Pre1 | IrChannel | IrCommandType}
|
uint8_t : 8; // {Pre1 | IrChannel | IrCommandType}
|
||||||
// Byte 1
|
// Byte 1
|
||||||
|
@ -128,20 +128,20 @@ union ArgoProtocolWREM3 {
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
typedef enum _ArgoIRMessageType {
|
using ArgoIRMessageType = enum _ArgoIRMessageType {
|
||||||
ArgoIRMessageType_AC_CONTROL = 0,
|
ARGO_IR_MESSAGE_TYPE_AC_CONTROL = 0,
|
||||||
ArgoIRMessageType_IFEEL_TEMP_REPORT = 1,
|
ARGO_IR_MESSAGE_TYPE_IFEEL_TEMP_REPORT = 1,
|
||||||
ArgoIRMessageType_TIMER_COMMAND = 2,
|
ARGO_IR_MESSAGE_TYPE_TIMER_COMMAND = 2,
|
||||||
ArgoIRMessageType_CONFIG_PARAM_SET = 3,
|
ARGO_IR_MESSAGE_TYPE_CONFIG_PARAM_SET = 3,
|
||||||
} ArgoIRMessageType;
|
};
|
||||||
|
|
||||||
// raw byte length depends on message type
|
// raw byte length depends on message type
|
||||||
typedef enum _ArgoIRMessageLength {
|
using ArgoIRMessageLength = enum _ArgoIRMessageLength {
|
||||||
ArgoIRMessageLength_AC_CONTROL = 6,
|
ARGO_IR_MESSAGE_LENGTH_AC_CONTROL = 6,
|
||||||
ArgoIRMessageLength_IFEEL_TEMP_REPORT = 2,
|
ARGO_IR_MESSAGE_LENGTH_IFEEL_TEMP_REPORT = 2,
|
||||||
ArgoIRMessageLength_TIMER_COMMAND = 9,
|
ARGO_IR_MESSAGE_LENGTH_TIMER_COMMAND = 9,
|
||||||
ArgoIRMessageLength_CONFIG_PARAM_SET = 4,
|
ARGO_IR_MESSAGE_LENGTH_CONFIG_PARAM_SET = 4,
|
||||||
} ArgoIRMessageLength;
|
};
|
||||||
|
|
||||||
class ArgoUlisseClimate : public climate_ir::ClimateIR {
|
class ArgoUlisseClimate : public climate_ir::ClimateIR {
|
||||||
public:
|
public:
|
||||||
|
@ -184,7 +184,7 @@ class ArgoUlisseClimate : public climate_ir::ClimateIR {
|
||||||
int32_t last_transmit_time_{};
|
int32_t last_transmit_time_{};
|
||||||
void transmit_state() override;
|
void transmit_state() override;
|
||||||
void transmit_ifeel_();
|
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;
|
climate::ClimateTraits traits() override;
|
||||||
uint8_t operation_mode_();
|
uint8_t operation_mode_();
|
||||||
uint8_t fan_speed_();
|
uint8_t fan_speed_();
|
||||||
|
|
Loading…
Reference in a new issue