Add gap for Running Dual

This commit is contained in:
cschwinne 2021-04-11 00:50:14 +02:00
parent 1192d04391
commit 87c6f3c757
3 changed files with 27 additions and 28 deletions

View File

@ -450,24 +450,26 @@ uint16_t WS2812FX::running_base(bool saw, bool dual=false) {
uint32_t counter = (now * SEGMENT.speed) >> 9; uint32_t counter = (now * SEGMENT.speed) >> 9;
for(uint16_t i = 0; i < SEGLEN; i++) { for(uint16_t i = 0; i < SEGLEN; i++) {
uint8_t s = 0; uint16_t a = i*x_scale - counter;
uint8_t t = 0;
uint8_t a = i*x_scale - counter;
uint8_t b = (SEGLEN-1-i)*x_scale - counter;
if (saw) { if (saw) {
a &= 0xFF;
if (a < 16) if (a < 16)
{ {
a = 192 + a*8; a = 192 + a*8;
} else { } else {
a = map(a,16,255,64,192); a = map(a,16,255,64,192);
} }
a = 255 - a;
} }
s = sin8(a); uint8_t s = dual ? sin_gap(a) : sin8(a);
t = sin8(b); uint32_t ca = color_blend(SEGCOLOR(1), color_from_palette(i, true, PALETTE_SOLID_WRAP, 0), s);
uint32_t ca = color_blend(color_from_palette(i, true, PALETTE_SOLID_WRAP, 0), SEGCOLOR(1), s); if (dual) {
uint32_t cb = color_blend(color_from_palette(i, true, PALETTE_SOLID_WRAP, 2), SEGCOLOR(1), t); uint16_t b = (SEGLEN-1-i)*x_scale - counter;
uint32_t cl = dual ? color_blend(ca, cb, 127) : ca; uint8_t t = sin_gap(b);
setPixelColor(i, cl); uint32_t cb = color_blend(SEGCOLOR(1), color_from_palette(i, true, PALETTE_SOLID_WRAP, 2), t);
ca = color_blend(ca, cb, 127);
}
setPixelColor(i, ca);
} }
return FRAMETIME; return FRAMETIME;
} }
@ -475,6 +477,7 @@ uint16_t WS2812FX::running_base(bool saw, bool dual=false) {
/* /*
* Running lights in opposite directions. * Running lights in opposite directions.
* Idea: Make the gap width controllable with a third slider in the future
*/ */
uint16_t WS2812FX::mode_running_dual(void) { uint16_t WS2812FX::mode_running_dual(void) {
return running_base(false, true); return running_base(false, true);
@ -1349,14 +1352,6 @@ uint16_t WS2812FX::tricolor_chase(uint32_t color1, uint32_t color2) {
} }
/*
* Alternating white/red/black pixels running. PLACEHOLDER
*/
uint16_t WS2812FX::mode_circus_combustus(void) {
return tricolor_chase(RED, WHITE);
}
/* /*
* Tricolor chase mode * Tricolor chase mode
*/ */

View File

@ -114,7 +114,7 @@
#define IS_REVERSE ((SEGMENT.options & REVERSE ) == REVERSE ) #define IS_REVERSE ((SEGMENT.options & REVERSE ) == REVERSE )
#define IS_SELECTED ((SEGMENT.options & SELECTED ) == SELECTED ) #define IS_SELECTED ((SEGMENT.options & SELECTED ) == SELECTED )
#define MODE_COUNT 119 #define MODE_COUNT 118
#define FX_MODE_STATIC 0 #define FX_MODE_STATIC 0
#define FX_MODE_BLINK 1 #define FX_MODE_BLINK 1
@ -168,7 +168,7 @@
#define FX_MODE_POLICE_ALL 49 #define FX_MODE_POLICE_ALL 49
#define FX_MODE_TWO_DOTS 50 #define FX_MODE_TWO_DOTS 50
#define FX_MODE_TWO_AREAS 51 #define FX_MODE_TWO_AREAS 51
#define FX_MODE_CIRCUS_COMBUSTUS 52 #define FX_MODE_RUNNING_DUAL 52
#define FX_MODE_HALLOWEEN 53 #define FX_MODE_HALLOWEEN 53
#define FX_MODE_TRICOLOR_CHASE 54 #define FX_MODE_TRICOLOR_CHASE 54
#define FX_MODE_TRICOLOR_WIPE 55 #define FX_MODE_TRICOLOR_WIPE 55
@ -234,7 +234,6 @@
#define FX_MODE_BLENDS 115 #define FX_MODE_BLENDS 115
#define FX_MODE_TV_SIMULATOR 116 #define FX_MODE_TV_SIMULATOR 116
#define FX_MODE_DYNAMIC_SMOOTH 117 #define FX_MODE_DYNAMIC_SMOOTH 117
#define FX_MODE_RUNNING_DUAL 118
class WS2812FX { class WS2812FX {
@ -506,7 +505,7 @@ class WS2812FX {
_mode[FX_MODE_POLICE_ALL] = &WS2812FX::mode_police_all; _mode[FX_MODE_POLICE_ALL] = &WS2812FX::mode_police_all;
_mode[FX_MODE_TWO_DOTS] = &WS2812FX::mode_two_dots; _mode[FX_MODE_TWO_DOTS] = &WS2812FX::mode_two_dots;
_mode[FX_MODE_TWO_AREAS] = &WS2812FX::mode_two_areas; _mode[FX_MODE_TWO_AREAS] = &WS2812FX::mode_two_areas;
_mode[FX_MODE_CIRCUS_COMBUSTUS] = &WS2812FX::mode_circus_combustus; _mode[FX_MODE_RUNNING_DUAL] = &WS2812FX::mode_running_dual;
_mode[FX_MODE_HALLOWEEN] = &WS2812FX::mode_halloween; _mode[FX_MODE_HALLOWEEN] = &WS2812FX::mode_halloween;
_mode[FX_MODE_TRICOLOR_CHASE] = &WS2812FX::mode_tricolor_chase; _mode[FX_MODE_TRICOLOR_CHASE] = &WS2812FX::mode_tricolor_chase;
_mode[FX_MODE_TRICOLOR_WIPE] = &WS2812FX::mode_tricolor_wipe; _mode[FX_MODE_TRICOLOR_WIPE] = &WS2812FX::mode_tricolor_wipe;
@ -574,7 +573,6 @@ class WS2812FX {
_mode[FX_MODE_BLENDS] = &WS2812FX::mode_blends; _mode[FX_MODE_BLENDS] = &WS2812FX::mode_blends;
_mode[FX_MODE_TV_SIMULATOR] = &WS2812FX::mode_tv_simulator; _mode[FX_MODE_TV_SIMULATOR] = &WS2812FX::mode_tv_simulator;
_mode[FX_MODE_DYNAMIC_SMOOTH] = &WS2812FX::mode_dynamic_smooth; _mode[FX_MODE_DYNAMIC_SMOOTH] = &WS2812FX::mode_dynamic_smooth;
_mode[FX_MODE_RUNNING_DUAL] = &WS2812FX::mode_running_dual;
_brightness = DEFAULT_BRIGHTNESS; _brightness = DEFAULT_BRIGHTNESS;
currentPalette = CRGBPalette16(CRGB::Black); currentPalette = CRGBPalette16(CRGB::Black);
@ -638,6 +636,7 @@ class WS2812FX {
getColorOrder(void), getColorOrder(void),
gamma8(uint8_t), gamma8(uint8_t),
gamma8_cal(uint8_t, float), gamma8_cal(uint8_t, float),
sin_gap(uint16_t),
get_random_wheel_index(uint8_t); get_random_wheel_index(uint8_t);
int8_t int8_t
@ -731,7 +730,7 @@ class WS2812FX {
mode_police_all(void), mode_police_all(void),
mode_two_dots(void), mode_two_dots(void),
mode_two_areas(void), mode_two_areas(void),
mode_circus_combustus(void), mode_running_dual(void),
mode_bicolor_chase(void), mode_bicolor_chase(void),
mode_tricolor_chase(void), mode_tricolor_chase(void),
mode_tricolor_wipe(void), mode_tricolor_wipe(void),
@ -796,8 +795,7 @@ class WS2812FX {
mode_candy_cane(void), mode_candy_cane(void),
mode_blends(void), mode_blends(void),
mode_tv_simulator(void), mode_tv_simulator(void),
mode_dynamic_smooth(void), mode_dynamic_smooth(void);
mode_running_dual(void);
private: private:
uint32_t crgb_to_col(CRGB fastled); uint32_t crgb_to_col(CRGB fastled);
@ -887,13 +885,13 @@ const char JSON_mode_names[] PROGMEM = R"=====([
"Sparkle","Sparkle Dark","Sparkle+","Strobe","Strobe Rainbow","Strobe Mega","Blink Rainbow","Android","Chase","Chase Random", "Sparkle","Sparkle Dark","Sparkle+","Strobe","Strobe Rainbow","Strobe Mega","Blink Rainbow","Android","Chase","Chase Random",
"Chase Rainbow","Chase Flash","Chase Flash Rnd","Rainbow Runner","Colorful","Traffic Light","Sweep Random","Running 2","Aurora","Stream", "Chase Rainbow","Chase Flash","Chase Flash Rnd","Rainbow Runner","Colorful","Traffic Light","Sweep Random","Running 2","Aurora","Stream",
"Scanner","Lighthouse","Fireworks","Rain","Tetrix","Fire Flicker","Gradient","Loading","Police","Police All", "Scanner","Lighthouse","Fireworks","Rain","Tetrix","Fire Flicker","Gradient","Loading","Police","Police All",
"Two Dots","Two Areas","Circus","Halloween","Tri Chase","Tri Wipe","Tri Fade","Lightning","ICU","Multi Comet", "Two Dots","Two Areas","Running Dual","Halloween","Tri Chase","Tri Wipe","Tri Fade","Lightning","ICU","Multi Comet",
"Scanner Dual","Stream 2","Oscillate","Pride 2015","Juggle","Palette","Fire 2012","Colorwaves","Bpm","Fill Noise", "Scanner Dual","Stream 2","Oscillate","Pride 2015","Juggle","Palette","Fire 2012","Colorwaves","Bpm","Fill Noise",
"Noise 1","Noise 2","Noise 3","Noise 4","Colortwinkles","Lake","Meteor","Meteor Smooth","Railway","Ripple", "Noise 1","Noise 2","Noise 3","Noise 4","Colortwinkles","Lake","Meteor","Meteor Smooth","Railway","Ripple",
"Twinklefox","Twinklecat","Halloween Eyes","Solid Pattern","Solid Pattern Tri","Spots","Spots Fade","Glitter","Candle","Fireworks Starburst", "Twinklefox","Twinklecat","Halloween Eyes","Solid Pattern","Solid Pattern Tri","Spots","Spots Fade","Glitter","Candle","Fireworks Starburst",
"Fireworks 1D","Bouncing Balls","Sinelon","Sinelon Dual","Sinelon Rainbow","Popcorn","Drip","Plasma","Percent","Ripple Rainbow", "Fireworks 1D","Bouncing Balls","Sinelon","Sinelon Dual","Sinelon Rainbow","Popcorn","Drip","Plasma","Percent","Ripple Rainbow",
"Heartbeat","Pacifica","Candle Multi", "Solid Glitter","Sunrise","Phased","Twinkleup","Noise Pal", "Sine","Phased Noise", "Heartbeat","Pacifica","Candle Multi", "Solid Glitter","Sunrise","Phased","Twinkleup","Noise Pal", "Sine","Phased Noise",
"Flow","Chunchun","Dancing Shadows","Washing Machine","Candy Cane","Blends","TV Simulator","Dynamic Smooth","Running Dual" "Flow","Chunchun","Dancing Shadows","Washing Machine","Candy Cane","Blends","TV Simulator","Dynamic Smooth"
])====="; ])=====";

View File

@ -738,6 +738,12 @@ uint16_t WS2812FX::triwave16(uint16_t in)
return 0xFFFF - (in - 0x8000)*2; return 0xFFFF - (in - 0x8000)*2;
} }
uint8_t WS2812FX::sin_gap(uint16_t in) {
if (in & 0x100) return 0;
//if (in > 255) return 0;
return sin8(in + 192); //correct phase shift of sine so that it starts and stops at 0
}
/* /*
* Generates a tristate square wave w/ attac & decay * Generates a tristate square wave w/ attac & decay
* @param x input value 0-255 * @param x input value 0-255