Moved settings from preprocessor directives to variables. Also added a way to (for now only) display them via HTTP server.

This commit is contained in:
2019-10-02 06:13:55 +02:00
parent 382631d7d7
commit 3f6d4cb0be
16 changed files with 154 additions and 79 deletions

View File

@ -11,7 +11,7 @@ void SingleDynamicEffect::init() {
}
void SingleDynamicEffect::loop(uint16_t ms) {
EVERY_N_MILLISECONDS( EFFECT_SINGLE_DYNAMIC_LOOP_TIME ) {
EVERY_N_MILLISECONDS( settings.effects.dynamic.single_loop_time ) {
tiles[random8(tile_count)] = CHSV(baseHue + random8(64), 180, 255);
}
this->draw();
@ -29,7 +29,7 @@ boolean SingleDynamicEffect::can_be_shown_with_clock() {
}
void MultiDynamicEffect::loop(uint16_t ms) {
EVERY_N_MILLISECONDS( EFFECT_MULTI_DYNAMIC_LOOP_TIME ) {
EVERY_N_MILLISECONDS( settings.effects.dynamic.multi_loop_time ) {
for (int i=0; i<tile_count; i++) tiles[i] = CHSV(baseHue + random8(64), 180, 255);
}
this->draw();
@ -40,23 +40,15 @@ BigDynamicEffect::~BigDynamicEffect() {
}
void BigDynamicEffect::loop(uint16_t ms) {
EVERY_N_MILLISECONDS( EFFECT_BIG_DYNAMIC_LOOP_TIME ) {
uint8_t x = random8(0, window->width - EFFECT_BIG_DYNAMIC_SIZE + 1);
uint8_t y = random8(0, window->height - EFFECT_BIG_DYNAMIC_SIZE + 1);
EVERY_N_MILLISECONDS( settings.effects.dynamic.big_loop_time ) {
uint8_t x = random8(0, window->width - settings.effects.dynamic.big_size + 1);
uint8_t y = random8(0, window->height - settings.effects.dynamic.big_size + 1);
CRGB color = CHSV(random8(), 255, 255);
CRGB black(0x000000);
for (uint8_t ix=0; ix<EFFECT_BIG_DYNAMIC_SIZE; ix++) for (uint8_t iy=0; iy<EFFECT_BIG_DYNAMIC_SIZE; iy++) {
for (uint8_t ix=0; ix<settings.effects.dynamic.big_size; ix++) for (uint8_t iy=0; iy<settings.effects.dynamic.big_size; iy++) {
window->setPixel(x+ix, y+iy, &color);
}
/*for (uint8_t ix=0; ix<EFFECT_BIG_DYNAMIC_SIZE+2; ix++) {
window->setPixel(x-1+ix, y-1, &black);
window->setPixel(x-1+ix, y+EFFECT_BIG_DYNAMIC_SIZE+1, &black);
}
for (uint8_t iy=0; iy<EFFECT_BIG_DYNAMIC_SIZE+2; iy++) {
window->setPixel(x-1, y-1+iy, &black);
window->setPixel(x+EFFECT_BIG_DYNAMIC_SIZE+1, y-1+iy, &black);
}*/
}
}