From 32cf1495d328f29cea7830caa5cfa37a02bb23f0 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Thu, 25 Oct 2018 20:55:29 +0200 Subject: [PATCH] Fixed tricolor chase modes Added a new palette --- readme.md | 2 +- wled00/WS2812FX.cpp | 45 ++++++++++++++++++++++++++++------- wled00/data/index.htm | 6 +++-- wled00/data/index_mobile.htm | 4 +++- wled00/data/settings_sec.htm | Bin 9120 -> 9120 bytes wled00/htmls00.h | 6 ++--- wled00/palettes.h | 25 +++++++++++++++++-- wled00/wled00.ino | 27 ++++++++++++++------- wled00/wled05_init.ino | 4 +--- 9 files changed, 89 insertions(+), 30 deletions(-) diff --git a/readme.md b/readme.md index 08a325b73..c7c80286b 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ ![WLED logo](https://raw.githubusercontent.com/Aircoookie/WLED/development/wled_logo.png) -## Welcome to my project WLED! (v0.8.0) +## Welcome to my project WLED! (v0.8.1-dev) A fast and feature-rich implementation of an ESP8266/ESP32 webserver to control NeoPixel (WS2812B) LEDs! diff --git a/wled00/WS2812FX.cpp b/wled00/WS2812FX.cpp index 26d9627de..f4de14e86 100644 --- a/wled00/WS2812FX.cpp +++ b/wled00/WS2812FX.cpp @@ -1129,12 +1129,6 @@ uint16_t WS2812FX::chase(uint32_t color1, uint32_t color2, uint32_t color3, uint return SPEED_FORMULA_L; } -/* - * Tricolor chase mode - */ -uint16_t WS2812FX::mode_tricolor_chase(void) { - return chase(SEGMENT.colors[1], SEGMENT.colors[0], SEGMENT.colors[2], 1); -} /* * Bicolor chase, more primary color. @@ -1143,6 +1137,7 @@ uint16_t WS2812FX::mode_chase_color(void) { return chase(SEGMENT.colors[1], SEGMENT.colors[0], SEGMENT.colors[0], 1); } + /* * Primary running followed by random color. */ @@ -1745,11 +1740,39 @@ uint16_t WS2812FX::mode_dual_color_wipe_out_in(void) { } +/* + * Tricolor chase function + */ +uint16_t WS2812FX::tricolor_chase(uint32_t color1, uint32_t color2, uint32_t color3) { + uint16_t index = SEGMENT_RUNTIME.counter_mode_step % 6; + for(uint16_t i=0; i < SEGMENT_LENGTH; i++, index++) { + if(index > 5) index = 0; + + uint32_t color = color1; + if(index > 3) color = color_from_palette(i, true, PALETTE_SOLID_WRAP, 2); + else if(index > 1) color = color2; + + setPixelColor(SEGMENT.stop - i, color); + } + + SEGMENT_RUNTIME.counter_mode_step++; + return 35 + ((350 * (uint32_t)(255 - SEGMENT.speed)) / 255); +} + + /* * Alternating white/red/black pixels running. PLACEHOLDER */ uint16_t WS2812FX::mode_circus_combustus(void) { - return chase(RED, WHITE, BLACK, 0); + return tricolor_chase(RED, WHITE, BLACK); +} + + +/* + * Tricolor chase mode + */ +uint16_t WS2812FX::mode_tricolor_chase(void) { + return tricolor_chase(SEGMENT.colors[1], SEGMENT.colors[0], SEGMENT.colors[2]); } @@ -1825,24 +1848,28 @@ uint16_t WS2812FX::mode_tricolor_wipe(void) uint16_t WS2812FX::mode_tricolor_fade(void) { uint32_t color1 = 0, color2 = 0; + byte stage = 0; if(SEGMENT_RUNTIME.counter_mode_step < 256) { color1 = SEGMENT.colors[0]; color2 = SEGMENT.colors[1]; + stage = 0; } else if(SEGMENT_RUNTIME.counter_mode_step < 512) { color1 = SEGMENT.colors[1]; color2 = SEGMENT.colors[2]; + stage = 1; } else { color1 = SEGMENT.colors[2]; color2 = SEGMENT.colors[0]; + stage = 2; } byte stp = SEGMENT_RUNTIME.counter_mode_step % 256; uint32_t color = 0; for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) { - if (color1 == SEGMENT.colors[2]) { + if (stage == 2) { color = color_blend(color_from_palette(i, true, PALETTE_SOLID_WRAP, 2), color2, stp); - } else if (color2 == SEGMENT.colors[2]) { + } else if (stage == 1) { color = color_blend(color1, color_from_palette(i, true, PALETTE_SOLID_WRAP, 2), stp); } else { color = color_blend(color1, color2, stp); diff --git a/wled00/data/index.htm b/wled00/data/index.htm index d35ee2b9b..106e8778b 100644 --- a/wled00/data/index.htm +++ b/wled00/data/index.htm @@ -2,7 +2,7 @@ - WLED 0.8.0 + WLED 0.8.1 + )====="; //head1 (css) @@ -133,7 +133,7 @@ Set secondary color to or

FastLED Palette

-
diff --git a/wled00/palettes.h b/wled00/palettes.h index 00d328230..881acd08f 100644 --- a/wled00/palettes.h +++ b/wled00/palettes.h @@ -515,7 +515,27 @@ DEFINE_GRADIENT_PALETTE( Tiamat_gp ) { 240, 193,213,253, //gc from 203,239,253 255, 255,249,255}; +//Custom palette by Aircoookie +DEFINE_GRADIENT_PALETTE( April_Night_gp ) { + 0, 1, 5, 45, //deep blue + 10, 1, 5, 45, + 25, 5,169,175, //light blue + 40, 1, 5, 45, + 61, 1, 5, 45, + 76, 45,175, 31, //green + 91, 1, 5, 45, + 112, 1, 5, 45, + 127, 249,150, 5, //yellow + 143, 1, 5, 45, + 162, 1, 5, 45, + 178, 255,92, 0, //pastel orange + 193, 1, 5, 45, + 214, 1, 5, 45, + 229, 223, 45, 72, //pink + 244, 1, 5, 45, + 255, 1, 5, 45}; + // Single array of defined cpt-city color palettes. // This will let us programmatically choose one based on @@ -560,8 +580,9 @@ const TProgmemRGBGradientPalettePtr gGradientPalettes[] = { BlacK_Red_Magenta_Yellow_gp, //42-29 Yelmag Blue_Cyan_Yellow_gp, //43-30 Yelblu Orange_Teal_gp, //44-31 Orange & Teal - Tiamat_gp //45-32 Tiamat - }; + Tiamat_gp, //45-32 Tiamat + April_Night_gp //46-33 April Night +}; // Count of how many cpt-city gradients are defined: diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 878d907da..c27ee7034 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -7,11 +7,24 @@ * @author Christian Schwinne */ -//ESP8266-01 got too little storage space to work with all features of WLED. To use it, you must use ESP8266 Arduino Core v2.3.0 and the setting 512K(64K SPIFFS). -//Uncomment the following line to disable some features (currently Mobile UI, welcome page and single digit + cronixie overlays) to compile for ESP8266-01 -//#define WLED_FLASH_512K_MODE -//CURRENTLY NOT WORKING +//ESP8266-01 (blue) got too little storage space to work with all features of WLED. To use it, you must use ESP8266 Arduino Core v2.3.0 and the setting 512K(64K SPIFFS). + +//ESP8266-01 (black) has 1MB flash and can thus fit the whole program. Use 1M(64K SPIFFS). +//If you want the OTA update function though, you need to make sure the sketch is smaller than 479kB. + +//Uncomment the following lines to disable some features to compile for ESP8266-01 (max flash size 438kB): + +//#define WLED_DISABLE_ALEXA +//#define WLED_DISABLE_BLYNK +//#define WLED_DISABLE_CRONIXIE +//#define WLED_DISABLE_HUESYNC +//#define WLED_DISABLE_MOBILE_UI +//#define WLED_DISABLE_OTA + + +//to toggle usb serial debug (un)comment following line(s) +//#define DEBUG //library inclusions #include @@ -45,7 +58,7 @@ //version code in format yymmddb (b = daily build) -#define VERSION 1810241 +#define VERSION 1810251 char versionString[] = "0.8.1"; @@ -54,10 +67,6 @@ char apPass[65] = "wled1234"; char otaPass[33] = "wledota"; -//to toggle usb serial debug (un)comment following line(s) -//#define DEBUG - - //spiffs FS only useful for debug (only ESP8266) //#define USEFS diff --git a/wled00/wled05_init.ino b/wled00/wled05_init.ino index 3eb96c37a..4ccc765a1 100644 --- a/wled00/wled05_init.ino +++ b/wled00/wled05_init.ino @@ -138,6 +138,7 @@ void initStrip() if (bootPreset>0) applyPreset(bootPreset, turnOnAtBoot, true, true); colorUpdated(0); if(digitalRead(buttonPin) == LOW) buttonEnabled = false; //disable button if it is "pressed" unintentionally + } void initAP(){ @@ -255,6 +256,3 @@ bool checkClientIsMobile(String useragent) if (useragent.indexOf("iPod") >= 0) return true; return false; } - - -