mirror of
https://github.com/esphome/esphome.git
synced 2025-09-27 23:52:28 +01:00
Allow pulse light effect to have separate on and off transition lengths (#5659)
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "light_effect.h"
|
||||
#include "esphome/core/automation.h"
|
||||
#include "light_effect.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace light {
|
||||
@@ -27,8 +27,8 @@ class PulseLightEffect : public LightEffect {
|
||||
auto call = this->state_->turn_on();
|
||||
float out = this->on_ ? this->max_brightness : this->min_brightness;
|
||||
call.set_brightness_if_supported(out);
|
||||
call.set_transition_length_if_supported(this->on_ ? this->transition_on_length_ : this->transition_off_length_);
|
||||
this->on_ = !this->on_;
|
||||
call.set_transition_length_if_supported(this->transition_length_);
|
||||
// don't tell HA every change
|
||||
call.set_publish(false);
|
||||
call.set_save(false);
|
||||
@@ -37,7 +37,8 @@ class PulseLightEffect : public LightEffect {
|
||||
this->last_color_change_ = now;
|
||||
}
|
||||
|
||||
void set_transition_length(uint32_t transition_length) { this->transition_length_ = transition_length; }
|
||||
void set_transition_on_length(uint32_t transition_length) { this->transition_on_length_ = transition_length; }
|
||||
void set_transition_off_length(uint32_t transition_length) { this->transition_off_length_ = transition_length; }
|
||||
|
||||
void set_update_interval(uint32_t update_interval) { this->update_interval_ = update_interval; }
|
||||
|
||||
@@ -49,7 +50,8 @@ class PulseLightEffect : public LightEffect {
|
||||
protected:
|
||||
bool on_ = false;
|
||||
uint32_t last_color_change_{0};
|
||||
uint32_t transition_length_{};
|
||||
uint32_t transition_on_length_{};
|
||||
uint32_t transition_off_length_{};
|
||||
uint32_t update_interval_{};
|
||||
float min_brightness{0.0};
|
||||
float max_brightness{1.0};
|
||||
|
Reference in New Issue
Block a user