Browse Source

Code cleanup.

oxan-light-transformation
Maurice Makaay 3 years ago
parent
commit
a8dc0b6dab
3 changed files with 13 additions and 18 deletions
  1. +1
    -1
      components/xiaomi_bslamp2/light/automation.h
  2. +5
    -10
      components/xiaomi_bslamp2/light/light_transition.h
  3. +7
    -7
      components/xiaomi_bslamp2/light/presets.h

+ 1
- 1
components/xiaomi_bslamp2/light/automation.h View File

@ -29,7 +29,7 @@ class BrightnessTrigger : public Trigger<float> {
} }
protected: protected:
float last_brightness_ = -1.0f;
float last_brightness_{-1.0f};
}; };
template<typename... Ts> class DiscoAction : public Action<Ts...> { template<typename... Ts> class DiscoAction : public Action<Ts...> {


+ 5
- 10
components/xiaomi_bslamp2/light/light_transition.h View File

@ -20,13 +20,8 @@ class XiaomiBslamp2LightTransition : public light::LightTransition {
light::LightTransition(name), light::LightTransition(name),
light_(light) { } light_(light) { }
// TODO deprecate or compile for 2018.8.* only.
bool is_finished() {
return is_completed();
}
bool is_completed() override { bool is_completed() override {
return force_finish_ || get_progress_() >= 1.0f;
return force_completed_ || get_progress_() >= 1.0f;
} }
void start() override { void start() override {
@ -60,9 +55,9 @@ class XiaomiBslamp2LightTransition : public light::LightTransition {
// transitions at the low levels as used for the night light. // transitions at the low levels as used for the night light.
if (end_->light_mode == LIGHT_MODE_NIGHT && start_->light_mode == LIGHT_MODE_NIGHT) { if (end_->light_mode == LIGHT_MODE_NIGHT && start_->light_mode == LIGHT_MODE_NIGHT) {
light_->set_state(end_); light_->set_state(end_);
force_finish_ = true;
force_completed_ = true;
} }
// Otherwise perform a standard transformation.
// Otherwise perform a standard transition.
else { else {
auto smoothed = smoothed_progress_(get_progress_()); auto smoothed = smoothed_progress_(get_progress_());
light_->set_rgbw( light_->set_rgbw(
@ -75,7 +70,7 @@ class XiaomiBslamp2LightTransition : public light::LightTransition {
} }
} }
if (is_finished()) {
if (is_completed()) {
light_->set_light_mode(end_->light_mode); light_->set_light_mode(end_->light_mode);
if (end_->light_mode == LIGHT_MODE_OFF) { if (end_->light_mode == LIGHT_MODE_OFF) {
light_->turn_off(); light_->turn_off();
@ -89,7 +84,7 @@ class XiaomiBslamp2LightTransition : public light::LightTransition {
protected: protected:
LightHAL *light_; LightHAL *light_;
bool force_finish_{false};
bool force_completed_{false};
GPIOOutputValues *start_ = new GPIOOutputValues(); GPIOOutputValues *start_ = new GPIOOutputValues();
ColorHandler *end_ = new ColorHandlerChain(); ColorHandler *end_ = new ColorHandlerChain();


+ 7
- 7
components/xiaomi_bslamp2/light/presets.h View File

@ -47,13 +47,13 @@ class Preset : public Component {
protected: protected:
light::LightState *light_state_; light::LightState *light_state_;
optional<uint32_t> transition_length_;
optional<float> brightness_;
optional<float> red_;
optional<float> green_;
optional<float> blue_;
optional<float> color_temperature_;
optional<std::string> effect_;
optional<uint32_t> transition_length_{};
optional<float> brightness_{};
optional<float> red_{};
optional<float> green_{};
optional<float> blue_{};
optional<float> color_temperature_{};
optional<std::string> effect_{};
}; };
class PresetGroup { class PresetGroup {


Loading…
Cancel
Save