mirror of
https://github.com/esphome/esphome.git
synced 2024-11-23 15:38:11 +01:00
[kp18058]: clang_tidy problems. this starts to be frustrating.
This commit is contained in:
parent
6c06a826e9
commit
f4a2baa8d0
2 changed files with 6 additions and 6 deletions
|
@ -60,7 +60,7 @@ void KP18058::program_led_driver() {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create the settings struct
|
// Create the settings struct
|
||||||
KP18058_Settings settings{};
|
KP18058Settings settings{};
|
||||||
|
|
||||||
settings.address_identification = 1;
|
settings.address_identification = 1;
|
||||||
settings.working_mode = all_channels_zero() ? STANDBY_MODE : RGBCW_MODE;
|
settings.working_mode = all_channels_zero() ? STANDBY_MODE : RGBCW_MODE;
|
||||||
|
@ -91,13 +91,13 @@ void KP18058::program_led_driver() {
|
||||||
|
|
||||||
// Calculate parity bits for each byte
|
// Calculate parity bits for each byte
|
||||||
uint8_t *settings_bytes = reinterpret_cast<uint8_t *>(&settings);
|
uint8_t *settings_bytes = reinterpret_cast<uint8_t *>(&settings);
|
||||||
for (size_t i = 0; i < sizeof(KP18058_Settings); i++) {
|
for (size_t i = 0; i < sizeof(KP18058Settings); i++) {
|
||||||
settings_bytes[i] |= get_parity_bit(settings_bytes[i]);
|
settings_bytes[i] |= get_parity_bit(settings_bytes[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the I2C message
|
// Send the I2C message
|
||||||
i2c_.start();
|
i2c_.start();
|
||||||
for (size_t i = 0; i < sizeof(KP18058_Settings); i++) {
|
for (size_t i = 0; i < sizeof(KP18058Settings); i++) {
|
||||||
// On error, try to repeat the byte transmission I2C_MAX_RETRY times
|
// On error, try to repeat the byte transmission I2C_MAX_RETRY times
|
||||||
bool write_succeeded;
|
bool write_succeeded;
|
||||||
for (int attempt = 0; attempt < I2C_MAX_RETRY; attempt++) {
|
for (int attempt = 0; attempt < I2C_MAX_RETRY; attempt++) {
|
||||||
|
|
|
@ -94,7 +94,7 @@ enum CDFrequency : uint8_t {
|
||||||
/**
|
/**
|
||||||
* @brief the structure of the I2C message for configuring the KP18058 LED driver settings.
|
* @brief the structure of the I2C message for configuring the KP18058 LED driver settings.
|
||||||
*/
|
*/
|
||||||
struct KP18058_Settings {
|
struct KP18058Settings {
|
||||||
// Byte 0
|
// Byte 0
|
||||||
uint8_t byte0_parity_bit : 1;
|
uint8_t byte0_parity_bit : 1;
|
||||||
uint8_t start_byte_address : 4;
|
uint8_t start_byte_address : 4;
|
||||||
|
@ -132,8 +132,8 @@ struct KP18058_Settings {
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
// Ensures that KP18058_Settings size is exactly 14 bytes during compilation
|
// Ensures that KP18058Settings size is exactly 14 bytes during compilation
|
||||||
static_assert(sizeof(KP18058_Settings) == 14, "Size of KP18058_Settings must be exactly 14 bytes");
|
static_assert(sizeof(KP18058Settings) == 14, "Size of KP18058Settings must be exactly 14 bytes");
|
||||||
|
|
||||||
} // namespace kp18058
|
} // namespace kp18058
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
|
Loading…
Reference in a new issue