diff --git a/Inc/ws2812b_fx.h b/Inc/ws2812b_fx.h index 2d3e32d..72caac3 100644 --- a/Inc/ws2812b_fx.h +++ b/Inc/ws2812b_fx.h @@ -23,7 +23,7 @@ #define SPEED_MIN (10) #define DEFAULT_SPEED (150) #define SPEED_MAX (65535) -#define MODE_COUNT (58) +#define MODE_COUNT (59) #define DEFAULT_MODE (0) #define FADE_RATE (2) /* some common colors */ @@ -102,6 +102,7 @@ typedef enum { FX_MODE_HALLOWEEN, FX_MODE_BICOLOR_CHASE, FX_MODE_TRICOLOR_CHASE, + FX_MODE_QUADCOLOR_CHASE, FX_MODE_ICU } fx_mode; diff --git a/Src/ws2812b_fx.c b/Src/ws2812b_fx.c index 6012067..d556fc8 100644 --- a/Src/ws2812b_fx.c +++ b/Src/ws2812b_fx.c @@ -157,6 +157,7 @@ mode_circus_combustus(void), mode_halloween(void), mode_bicolor_chase(void), mode_tricolor_chase(void), +mode_quadcolor_chase(void), mode_icu(void) ; @@ -219,6 +220,7 @@ void (*mMode[MODE_COUNT])(void) = mode_halloween, mode_bicolor_chase, mode_tricolor_chase, + mode_quadcolor_chase, mode_icu }; @@ -1948,6 +1950,48 @@ void mode_tricolor_chase(void) } +/* + * Quadcolor chase function + */ +void quadcolor_chase(uint32_t color1, uint32_t color2, uint32_t color3, uint32_t color4) +{ + uint16_t index = Ws28b12b_Segments[mActualSegment].CounterModeStep % 8; + uint16_t i; + uint32_t color; + + for(i = 0; i < SEGMENT_LENGTH; i++, index++) + { + index %= 8; + + color = color1; + if(index < 2) color = color2; + else if(index < 4) color = color3; + else if(index < 6) color = color4; + + if(IS_REVERSE) { + ws2812_set_led_color_val(Ws28b12b_Segments[mActualSegment].IdStart + i, color); + } else { + ws2812_set_led_color_val(Ws28b12b_Segments[mActualSegment].IdStop - i, color); + } + } + + Ws28b12b_Segments[mActualSegment].CounterModeStep++; + Ws28b12b_Segments[mActualSegment].ModeDelay = Ws28b12b_Segments[mActualSegment].Speed; +} + + +/* + * Quadcolor chase mode + */ +void mode_quadcolor_chase(void) +{ + return quadcolor_chase(Ws28b12b_Segments[mActualSegment].ModeColor[0], + Ws28b12b_Segments[mActualSegment].ModeColor[1], + Ws28b12b_Segments[mActualSegment].ModeColor[2], + Ws28b12b_Segments[mActualSegment].ModeColor[3]); +} + + /* * Alternating white/red/black pixels running. */