mirror of
https://github.com/esphome/esphome.git
synced 2025-10-01 09:32:21 +01:00
[code-quality] fix readability-braces-around-statements (#7273)
This commit is contained in:
@@ -18,10 +18,11 @@ class BinaryLightOutput : public light::LightOutput {
|
||||
void write_state(light::LightState *state) override {
|
||||
bool binary;
|
||||
state->current_values_as_binary(&binary);
|
||||
if (binary)
|
||||
if (binary) {
|
||||
this->output_->turn_on();
|
||||
else
|
||||
} else {
|
||||
this->output_->turn_off();
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@@ -16,10 +16,11 @@ class DemoSensor : public sensor::Sensor, public PollingComponent {
|
||||
float base = std::isnan(this->state) ? 0.0f : this->state;
|
||||
this->publish_state(base + val * 10);
|
||||
} else {
|
||||
if (val < 0.1)
|
||||
if (val < 0.1) {
|
||||
this->publish_state(NAN);
|
||||
else
|
||||
} else {
|
||||
this->publish_state(val * 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -20,10 +20,11 @@ class LVGLNumber : public number::Number {
|
||||
|
||||
protected:
|
||||
void control(float value) override {
|
||||
if (this->control_lambda_ != nullptr)
|
||||
if (this->control_lambda_ != nullptr) {
|
||||
this->control_lambda_(value);
|
||||
else
|
||||
} else {
|
||||
this->initial_state_ = value;
|
||||
}
|
||||
}
|
||||
std::function<void(float)> control_lambda_{};
|
||||
optional<float> initial_state_{};
|
||||
|
@@ -20,10 +20,11 @@ class LVGLSwitch : public switch_::Switch {
|
||||
|
||||
protected:
|
||||
void write_state(bool value) override {
|
||||
if (this->state_lambda_ != nullptr)
|
||||
if (this->state_lambda_ != nullptr) {
|
||||
this->state_lambda_(value);
|
||||
else
|
||||
} else {
|
||||
this->initial_state_ = value;
|
||||
}
|
||||
}
|
||||
std::function<void(bool)> state_lambda_{};
|
||||
optional<bool> initial_state_{};
|
||||
|
@@ -20,10 +20,11 @@ class LVGLText : public text::Text {
|
||||
|
||||
protected:
|
||||
void control(const std::string &value) override {
|
||||
if (this->control_lambda_ != nullptr)
|
||||
if (this->control_lambda_ != nullptr) {
|
||||
this->control_lambda_(value);
|
||||
else
|
||||
} else {
|
||||
this->initial_state_ = value;
|
||||
}
|
||||
}
|
||||
std::function<void(const std::string)> control_lambda_{};
|
||||
optional<std::string> initial_state_{};
|
||||
|
@@ -23,10 +23,11 @@ class RGBCTLightOutput : public light::LightOutput {
|
||||
|
||||
light::LightTraits get_traits() override {
|
||||
auto traits = light::LightTraits();
|
||||
if (this->color_interlock_)
|
||||
if (this->color_interlock_) {
|
||||
traits.set_supported_color_modes({light::ColorMode::RGB, light::ColorMode::COLOR_TEMPERATURE});
|
||||
else
|
||||
} else {
|
||||
traits.set_supported_color_modes({light::ColorMode::RGB_COLOR_TEMPERATURE, light::ColorMode::COLOR_TEMPERATURE});
|
||||
}
|
||||
traits.set_min_mireds(this->cold_white_temperature_);
|
||||
traits.set_max_mireds(this->warm_white_temperature_);
|
||||
return traits;
|
||||
|
@@ -16,10 +16,11 @@ class RGBWLightOutput : public light::LightOutput {
|
||||
void set_color_interlock(bool color_interlock) { color_interlock_ = color_interlock; }
|
||||
light::LightTraits get_traits() override {
|
||||
auto traits = light::LightTraits();
|
||||
if (this->color_interlock_)
|
||||
if (this->color_interlock_) {
|
||||
traits.set_supported_color_modes({light::ColorMode::RGB, light::ColorMode::WHITE});
|
||||
else
|
||||
} else {
|
||||
traits.set_supported_color_modes({light::ColorMode::RGB_WHITE});
|
||||
}
|
||||
return traits;
|
||||
}
|
||||
void write_state(light::LightState *state) override {
|
||||
|
@@ -20,10 +20,11 @@ class RGBWWLightOutput : public light::LightOutput {
|
||||
void set_color_interlock(bool color_interlock) { color_interlock_ = color_interlock; }
|
||||
light::LightTraits get_traits() override {
|
||||
auto traits = light::LightTraits();
|
||||
if (this->color_interlock_)
|
||||
if (this->color_interlock_) {
|
||||
traits.set_supported_color_modes({light::ColorMode::RGB, light::ColorMode::COLD_WARM_WHITE});
|
||||
else
|
||||
} else {
|
||||
traits.set_supported_color_modes({light::ColorMode::RGB_COLD_WARM_WHITE});
|
||||
}
|
||||
traits.set_min_mireds(this->cold_white_temperature_);
|
||||
traits.set_max_mireds(this->warm_white_temperature_);
|
||||
return traits;
|
||||
|
@@ -46,10 +46,11 @@ class SpiLedStrip : public light::AddressableLight,
|
||||
void dump_config() override {
|
||||
esph_log_config(TAG, "SPI LED Strip:");
|
||||
esph_log_config(TAG, " LEDs: %d", this->num_leds_);
|
||||
if (this->data_rate_ >= spi::DATA_RATE_1MHZ)
|
||||
if (this->data_rate_ >= spi::DATA_RATE_1MHZ) {
|
||||
esph_log_config(TAG, " Data rate: %uMHz", (unsigned) (this->data_rate_ / 1000000));
|
||||
else
|
||||
} else {
|
||||
esph_log_config(TAG, " Data rate: %ukHz", (unsigned) (this->data_rate_ / 1000));
|
||||
}
|
||||
}
|
||||
|
||||
void write_state(light::LightState *state) override {
|
||||
|
Reference in New Issue
Block a user