1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-04 02:52:22 +01:00

[code-quality] fix readability-braces-around-statements (#7273)

This commit is contained in:
tomaszduda23
2024-08-14 04:14:29 +02:00
committed by GitHub
parent 56e05998ef
commit 4cb174585c
13 changed files with 108 additions and 65 deletions

View File

@@ -114,10 +114,11 @@ class AddressableColorWipeEffect : public AddressableLightEffect {
if (now - this->last_add_ < this->add_led_interval_)
return;
this->last_add_ = now;
if (this->reverse_)
if (this->reverse_) {
it.shift_left(1);
else
} else {
it.shift_right(1);
}
const AddressableColorWipeEffectColor &color = this->colors_[this->at_color_];
Color esp_color = Color(color.r, color.g, color.b, color.w);
if (color.gradient) {
@@ -127,10 +128,11 @@ class AddressableColorWipeEffect : public AddressableLightEffect {
uint8_t gradient = 255 * ((float) this->leds_added_ / color.num_leds);
esp_color = esp_color.gradient(next_esp_color, gradient);
}
if (this->reverse_)
if (this->reverse_) {
it[-1] = esp_color;
else
} else {
it[0] = esp_color;
}
if (++this->leds_added_ >= color.num_leds) {
this->leds_added_ = 0;
this->at_color_ = (this->at_color_ + 1) % this->colors_.size();
@@ -207,10 +209,11 @@ class AddressableTwinkleEffect : public AddressableLightEffect {
const uint8_t sine = half_sin8(view.get_effect_data());
view = current_color * sine;
const uint8_t new_pos = view.get_effect_data() + pos_add;
if (new_pos < view.get_effect_data())
if (new_pos < view.get_effect_data()) {
view.set_effect_data(0);
else
} else {
view.set_effect_data(new_pos);
}
} else {
view = Color::BLACK;
}
@@ -254,10 +257,11 @@ class AddressableRandomTwinkleEffect : public AddressableLightEffect {
view = Color(((color >> 2) & 1) * sine, ((color >> 1) & 1) * sine, ((color >> 0) & 1) * sine);
}
const uint8_t new_x = x + pos_add;
if (new_x > 0b11111)
if (new_x > 0b11111) {
view.set_effect_data(0);
else
} else {
view.set_effect_data((new_x << 3) | color);
}
} else {
view = Color(0, 0, 0, 0);
}