Amount of new Pixels per loop for confetti effect is now configurable. Also, the color is based on a slowly rotating baseHue.

This commit is contained in:
Fabian Schlenz 2019-05-30 13:08:24 +02:00
parent 8e46327549
commit 646d3369fb
3 changed files with 11 additions and 1 deletions

View File

@ -34,4 +34,6 @@ typedef struct Matrix {
double a22;
} Matrix;
extern uint8_t baseHue;
#endif

View File

@ -1,10 +1,13 @@
#include "effect_confetti.h"
#include "config.h"
#include "functions.h"
#include "prototypes.h"
void ConfettiEffect::loop() {
fadeToBlackBy(leds, LED_COUNT, 1);
addPixelColor(random16(LED_COUNT), CHSV(random8(), 200, 255));
for (int i=0; i<EFFECT_CONFETTI_PIXELS_PER_LOOP; i++) {
addPixelColor(random16(LED_COUNT), CHSV(baseHue + random8(64), 200, 255));
}
}
boolean ConfettiEffect::can_be_shown_with_clock() { return true; };

View File

@ -19,6 +19,7 @@
uint8_t starting_up = OTA_STARTUP_DELAY;
int loop_timeouts = 0;
long loop_started_at = 0;
uint8_t baseHue = 0; // defined as extern in prototypes.h
void setup() {
Serial.begin(74880);
@ -52,6 +53,10 @@ void loop() {
ntpClient.update();
mqtt_loop();
EVERY_N_MILLISECONDS(100) {
baseHue++;
}
EVERY_N_MILLISECONDS(1000 / FPS) {
LOGln("Core * loop running");
current_effect->loop();