mirror of
https://github.com/esphome/esphome.git
synced 2025-10-26 12:43:48 +00:00
[light] Replace std::vector with FixedVector in strobe and color_wipe effects (#11455)
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "esphome/core/component.h"
|
#include "esphome/core/component.h"
|
||||||
|
#include "esphome/core/helpers.h"
|
||||||
#include "esphome/components/light/light_state.h"
|
#include "esphome/components/light/light_state.h"
|
||||||
#include "esphome/components/light/addressable_light.h"
|
#include "esphome/components/light/addressable_light.h"
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ struct AddressableColorWipeEffectColor {
|
|||||||
class AddressableColorWipeEffect : public AddressableLightEffect {
|
class AddressableColorWipeEffect : public AddressableLightEffect {
|
||||||
public:
|
public:
|
||||||
explicit AddressableColorWipeEffect(const std::string &name) : AddressableLightEffect(name) {}
|
explicit AddressableColorWipeEffect(const std::string &name) : AddressableLightEffect(name) {}
|
||||||
void set_colors(const std::vector<AddressableColorWipeEffectColor> &colors) { this->colors_ = colors; }
|
void set_colors(const std::initializer_list<AddressableColorWipeEffectColor> &colors) { this->colors_ = colors; }
|
||||||
void set_add_led_interval(uint32_t add_led_interval) { this->add_led_interval_ = add_led_interval; }
|
void set_add_led_interval(uint32_t add_led_interval) { this->add_led_interval_ = add_led_interval; }
|
||||||
void set_reverse(bool reverse) { this->reverse_ = reverse; }
|
void set_reverse(bool reverse) { this->reverse_ = reverse; }
|
||||||
void apply(AddressableLight &it, const Color ¤t_color) override {
|
void apply(AddressableLight &it, const Color ¤t_color) override {
|
||||||
@@ -155,7 +155,7 @@ class AddressableColorWipeEffect : public AddressableLightEffect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::vector<AddressableColorWipeEffectColor> colors_;
|
FixedVector<AddressableColorWipeEffectColor> colors_;
|
||||||
size_t at_color_{0};
|
size_t at_color_{0};
|
||||||
uint32_t last_add_{0};
|
uint32_t last_add_{0};
|
||||||
uint32_t add_led_interval_{};
|
uint32_t add_led_interval_{};
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "esphome/core/automation.h"
|
#include "esphome/core/automation.h"
|
||||||
|
#include "esphome/core/helpers.h"
|
||||||
#include "light_effect.h"
|
#include "light_effect.h"
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
@@ -188,10 +188,10 @@ class StrobeLightEffect : public LightEffect {
|
|||||||
this->last_switch_ = now;
|
this->last_switch_ = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_colors(const std::vector<StrobeLightEffectColor> &colors) { this->colors_ = colors; }
|
void set_colors(const std::initializer_list<StrobeLightEffectColor> &colors) { this->colors_ = colors; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::vector<StrobeLightEffectColor> colors_;
|
FixedVector<StrobeLightEffectColor> colors_;
|
||||||
uint32_t last_switch_{0};
|
uint32_t last_switch_{0};
|
||||||
size_t at_color_{0};
|
size_t at_color_{0};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user