1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-11 06:13:47 +01:00

Migrate COLOR constants to Color class & disallow implicit conversions to Color (#2093)

Co-authored-by: Xo Wang <xo@geekshavefeelings.com>
This commit is contained in:
Oxan van Leeuwen
2021-08-03 23:21:57 +02:00
committed by GitHub
parent 9fa19df2ff
commit 441d5bd44d
14 changed files with 51 additions and 45 deletions

View File

@@ -16,7 +16,7 @@
namespace esphome {
namespace light {
using ESPColor = Color;
using ESPColor ESPDEPRECATED("esphome::light::ESPColor is deprecated, use esphome::Color instead.") = Color;
class AddressableLight : public LightOutput, public Component {
public:

View File

@@ -151,7 +151,7 @@ class AddressableScanEffect : public AddressableLightEffect {
void set_move_interval(uint32_t move_interval) { this->move_interval_ = move_interval; }
void set_scan_width(uint32_t scan_width) { this->scan_width_ = scan_width; }
void apply(AddressableLight &it, const Color &current_color) override {
it.all() = COLOR_BLACK;
it.all() = Color::BLACK;
for (auto i = 0; i < this->scan_width_; i++) {
it[this->at_led_ + i] = current_color;
@@ -201,7 +201,7 @@ class AddressableTwinkleEffect : public AddressableLightEffect {
else
view.set_effect_data(new_pos);
} else {
view = COLOR_BLACK;
view = Color::BLACK;
}
}
while (random_float() < this->twinkle_probability_) {
@@ -272,7 +272,7 @@ class AddressableFireworksEffect : public AddressableLightEffect {
explicit AddressableFireworksEffect(const std::string &name) : AddressableLightEffect(name) {}
void start() override {
auto &it = *this->get_addressable_();
it.all() = COLOR_BLACK;
it.all() = Color::BLACK;
}
void apply(AddressableLight &it, const Color &current_color) override {
const uint32_t now = millis();