From 4c611da6d17808dcdc0f1a913ceddc4c008de235 Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Fri, 11 Oct 2019 17:56:18 +0200 Subject: [PATCH 1/5] Finally, big_clock is working correctly with smoothly moving seconds and stuff. Also, the spacing of the moving seconds is now configurable. --- include/effect_big_clock.h | 6 ++++-- include/settings.h | 6 +++++- src/effect_big_clock.cpp | 37 +++++++++++++++++++------------------ src/settings.cpp | 18 ++++++++++-------- 4 files changed, 38 insertions(+), 29 deletions(-) diff --git a/include/effect_big_clock.h b/include/effect_big_clock.h index e4791df..c7fe495 100644 --- a/include/effect_big_clock.h +++ b/include/effect_big_clock.h @@ -6,10 +6,12 @@ class BigClockEffect : public Effect { private: CRGB _color_font = CRGB(0xAAAAAA); CRGB _color_seconds_light = CRGB(0xFFFF00); - CRGB _color_seconds_dark = CRGB(0xFF0000); + CRGB _color_seconds_dark = CRGB(0xAA0000); + CRGB _color_seconds_moving_light = CRGB(0x666600); + CRGB _color_seconds_moving_dark = CRGB(0x660000); void _draw_seconds(); - void _draw_border_pixel(uint8_t second, uint8_t part, CRGB* color); + void _draw_border_pixel(accum88 pos, CRGB* color); public: void loop(uint16_t ms); diff --git a/include/settings.h b/include/settings.h index f0349d0..07a5455 100644 --- a/include/settings.h +++ b/include/settings.h @@ -32,6 +32,10 @@ struct Settings { uint16_t random_count = 32; } matrix; + struct /* big_clock */ { + uint16_t spacing = 5; + } big_clock; + struct /* confetti */ { uint16_t pixels_per_loop = 2; } confetti; @@ -75,7 +79,7 @@ struct Settings { uint16_t direction_change = 5; uint16_t slowdown = 2; } snake; - + struct /* tv_static */ { uint16_t black_bar_speed = 3500; } tv_static; diff --git a/src/effect_big_clock.cpp b/src/effect_big_clock.cpp index dc5e9b6..33569d6 100644 --- a/src/effect_big_clock.cpp +++ b/src/effect_big_clock.cpp @@ -2,6 +2,7 @@ #include "effect_big_clock.h" #include "fonts.h" #include "ntp.h" +#include "settings.h" void BigClockEffect::loop(uint16_t ms) { window->clear(); @@ -25,35 +26,35 @@ void BigClockEffect::loop(uint16_t ms) { void BigClockEffect::_draw_seconds() { uint8_t seconds = ntpClient.getSeconds(); for (int i=1; i<=seconds; i++) { - _draw_border_pixel(i, 0, (i%5==0) ? &_color_seconds_light : &_color_seconds_dark); + _draw_border_pixel(i<<8, (i%5==0) ? &_color_seconds_light : &_color_seconds_dark); } uint16_t millis = ntpClient.getEpochMillis() % 1000; - uint8_t offset = 5 - (millis / 200); - uint8_t part = 255 - ((millis % 200) * 256 / 200); - uint8_t number_to_show = (60 - seconds - offset) / 5 + 1; - for(uint8_t i = 0; i 0) { int pos = s.lastIndexOf('\n'); String part = s.substring(pos + 1); From bbdb46c04d18e9a858363909dac1609131a92877 Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Fri, 11 Oct 2019 17:56:37 +0200 Subject: [PATCH 2/5] Twirl no longer uses a masked clock. --- src/effect_twirl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/effect_twirl.cpp b/src/effect_twirl.cpp index 794b324..32396ba 100644 --- a/src/effect_twirl.cpp +++ b/src/effect_twirl.cpp @@ -2,7 +2,7 @@ #include "functions.h" boolean TwirlEffect::can_be_shown_with_clock() { return true; }; -boolean TwirlEffect::clock_as_mask() { return true; }; +boolean TwirlEffect::clock_as_mask() { return false; }; void TwirlEffect::loop(uint16_t ms) { double center_x = _real_center_x; // - (cos8(_center_offset_angle)>>6); From efa9a73caead979a0667783f88a7538af61f5ecc Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Fri, 11 Oct 2019 17:57:00 +0200 Subject: [PATCH 3/5] Added switching of effects via the web interface. --- src/http_server.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/http_server.cpp b/src/http_server.cpp index e48fbd2..a5d872b 100644 --- a/src/http_server.cpp +++ b/src/http_server.cpp @@ -63,7 +63,7 @@ void http_server_setup() { Setting s = all_settings[i]; uint16_t default_value = setting_default(&s); uint16_t value = *(s.value); - + message += ""; if (default_value != value) { message += ""; @@ -155,11 +155,30 @@ void http_server_setup() { for (int i=0; i Date: Sat, 12 Oct 2019 23:27:49 +0200 Subject: [PATCH 4/5] Effect sinematrix now comes in additional variants with some more color palettes. --- include/effect_sinematrix3.h | 10 +++++++++- include/my_color_palettes.h | 1 + src/color_palettes.cpp | 11 +++++++++++ src/effect_sinematrix3.cpp | 20 +++++++++++++++++--- src/effects.cpp | 5 ++++- 5 files changed, 42 insertions(+), 5 deletions(-) diff --git a/include/effect_sinematrix3.h b/include/effect_sinematrix3.h index 5eef7d7..a120c3c 100644 --- a/include/effect_sinematrix3.h +++ b/include/effect_sinematrix3.h @@ -4,6 +4,12 @@ #include "functions.h" #include "Effect.h" +enum SinematrixColorScheme { + SINEMATRIX_COLOR_PASTEL_RAINBOW, + SINEMATRIX_COLOR_RAINBOW, + SINEMATRIX_COLOR_PURPLEFLY, +}; + class Sinematrix3Effect : public Effect { private: double pangle = 0; @@ -25,12 +31,14 @@ private: double fx = 1.0 / (LED_WIDTH / PI); double fy = 1.0 / (LED_HEIGHT / PI); Matrix rotate; + SinematrixColorScheme _color_scheme; + CRGB _get_color(int value); public: + Sinematrix3Effect(SinematrixColorScheme s = SINEMATRIX_COLOR_PASTEL_RAINBOW): _color_scheme(s) {}; boolean supports_window = true; boolean can_be_shown_with_clock(); boolean clock_as_mask(); void loop(uint16_t ms); String get_name() override { return "sinematrix3"; } }; - diff --git a/include/my_color_palettes.h b/include/my_color_palettes.h index 09baead..84885f2 100644 --- a/include/my_color_palettes.h +++ b/include/my_color_palettes.h @@ -6,3 +6,4 @@ extern const TProgmemRGBGradientPalette_byte palette_fire[] FL_PROGMEM; extern const TProgmemRGBGradientPalette_byte palette_matrix[] FL_PROGMEM; +extern const TProgmemRGBGradientPalette_byte palette_purplefly_gp[] FL_PROGMEM; diff --git a/src/color_palettes.cpp b/src/color_palettes.cpp index 8619a77..c6ab1b7 100644 --- a/src/color_palettes.cpp +++ b/src/color_palettes.cpp @@ -9,3 +9,14 @@ __attribute__ ((aligned(4))) extern const TProgmemRGBGradientPalette_byte palett __attribute__ ((aligned(4))) extern const TProgmemRGBGradientPalette_byte palette_matrix[] FL_PROGMEM = { 0, 0, 0, 0, // black 255, 0,255, 0 }; // green + +// Gradient palette "purplefly_gp", originally from +// http://soliton.vm.bytemark.co.uk/pub/cpt-city/rc/tn/purplefly.png.index.html +// converted for FastLED with gammas (2.6, 2.2, 2.5) +// Size: 16 bytes of program space. + +__attribute__ ((aligned(4))) extern const TProgmemRGBGradientPalette_byte palette_purplefly_gp[] FL_PROGMEM = { + 0, 0, 0, 0, + 63, 239, 0,122, + 191, 252,255, 78, + 255, 0, 0, 0}; diff --git a/src/effect_sinematrix3.cpp b/src/effect_sinematrix3.cpp index 709e282..cb36549 100644 --- a/src/effect_sinematrix3.cpp +++ b/src/effect_sinematrix3.cpp @@ -2,9 +2,9 @@ #include "prototypes.h" #include "functions.h" #include "Effect.h" +#include "my_color_palettes.h" boolean Sinematrix3Effect::can_be_shown_with_clock() { return true; }; -boolean Sinematrix3Effect::clock_as_mask() { return true; }; void Sinematrix3Effect::loop(uint16_t ms) { pangle = addmodpi( pangle, 0.0133 + (angle / 256) ); angle = cos(pangle) * PI; @@ -44,8 +44,22 @@ void Sinematrix3Effect::loop(uint16_t ms) { for ( int y = 0; y < LED_HEIGHT; y++ ) { Vector c = add(multiply( multiply(rotate, zoom), { .x1 = x - rcx, .x2 = y - rcy } ), translate); int sat = (basecol + basefield(c.x1, c.x2)) * 255; - CRGB color(CHSV(sat, 120, 255)); - window->setPixel(x, y, &color); + CRGB color(_get_color(sat)); + window->setPixel(x, y, &color); } } } + +CRGB Sinematrix3Effect::_get_color(int sat) { + switch(_color_scheme) { + case SINEMATRIX_COLOR_PASTEL_RAINBOW: return CRGB(CHSV(sat, 120, 255)); + case SINEMATRIX_COLOR_RAINBOW: return CRGB(CHSV(sat, 255, 255)); + case SINEMATRIX_COLOR_PURPLEFLY: return ColorFromPalette((CRGBPalette16)palette_purplefly_gp, (uint8_t)sat); + } + return CRGB(0xFF00FF); +} + +boolean Sinematrix3Effect::clock_as_mask() { + if (_color_scheme == SINEMATRIX_COLOR_PASTEL_RAINBOW) return true; + return false; +}; diff --git a/src/effects.cpp b/src/effects.cpp index 45b22d9..b340e85 100644 --- a/src/effects.cpp +++ b/src/effects.cpp @@ -55,8 +55,11 @@ const EffectEntry effects[] = { /* 23 */ {"marquee", 0, [](){ return new MarqueeEffect(); }}, /* 24 */ {"night_clock", false, [](){ return new NightClockEffect(); }}, /* 25 */ {"tv_static", false, [](){ return new TvStaticEffect(); }}, + /* 26 */ {"sinematrix3_rainbow", true,[](){ return new Sinematrix3Effect(SINEMATRIX_COLOR_RAINBOW); }}, + /* 27 */ {"sinematrix3_purplefly", true,[](){ return new Sinematrix3Effect(SINEMATRIX_COLOR_PURPLEFLY); }}, + }; -const uint8_t effects_size = 26; +const uint8_t effects_size = 28; Effect* select_effect(const char* name) { From 8568436fc16ba299768014413ec4631e5f8fc19b Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Sat, 12 Oct 2019 23:28:19 +0200 Subject: [PATCH 5/5] Ignore .vscode --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d0b5364..be52b85 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ include/config.h .piolibdeps .pioenvs .DS_Store +.vscode