feat: add variable to toggle the rainbow effect on or off

This commit is contained in:
Philip Stark 2023-06-10 14:01:29 +02:00
parent 03a012650f
commit e4bdcf71dc
2 changed files with 8 additions and 0 deletions

View file

@ -114,10 +114,15 @@ Color Wordclock::get_next_color_base_(uint32_t position, uint32_t speed, uint16_
} }
Color Wordclock::get_next_color(uint32_t position, const Color &current_color) { Color Wordclock::get_next_color(uint32_t position, const Color &current_color) {
if (this->effect_active) {
uint32_t speed_ = 3; uint32_t speed_ = 3;
uint16_t width_ = 100; // Original width_ = 50 uint16_t width_ = 100; // Original width_ = 50
return get_next_color_base_(position, speed_, width_, current_color); return get_next_color_base_(position, speed_, width_, current_color);
} }
else {
return Color(this->on_color);
}
}
int8_t Wordclock::find_hour(uint8_t target_value) { int8_t Wordclock::find_hour(uint8_t target_value) {
std::vector<Hour> *elements = this->hours; std::vector<Hour> *elements = this->hours;

View file

@ -81,6 +81,8 @@ public:
void set_brightness(uint8_t brightness) { void set_brightness(uint8_t brightness) {
this->brightness = brightness; this->brightness = brightness;
} }
bool get_effect_active() { return this->effect_active; }
void set_effect_active(bool x) { this->effect_active = x; }
void set_on_color(Color on_color) { void set_on_color(Color on_color) {
this->on_color = on_color; this->on_color = on_color;
} }
@ -144,6 +146,7 @@ protected:
std::vector<uint16_t> *previous_segments; std::vector<uint16_t> *previous_segments;
uint32_t current_position{0}; uint32_t current_position{0};
bool effect_active{true};
Color get_next_color_base_(uint32_t position, uint32_t speed, uint16_t width, const Color &current_color); Color get_next_color_base_(uint32_t position, uint32_t speed, uint16_t width, const Color &current_color);
Color get_next_color(uint32_t position, const Color &current_color); Color get_next_color(uint32_t position, const Color &current_color);