mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 10:46:31 +00:00
Fix exception 0 when width is 0
This commit is contained in:
parent
476c2b3dc0
commit
6999f87566
@ -24,15 +24,15 @@
|
|||||||
*
|
*
|
||||||
* light_scheme WS2812 3+ Colors 1+2 Colors Effect
|
* light_scheme WS2812 3+ Colors 1+2 Colors Effect
|
||||||
* ------------ ------ --------- ---------- -----------------
|
* ------------ ------ --------- ---------- -----------------
|
||||||
* 0 yes no no Clock
|
* 0 (5) yes no no Clock
|
||||||
* 1 yes no no Incandescent
|
* 1 (6) yes no no Incandescent
|
||||||
* 2 yes no no RGB
|
* 2 (7) yes no no RGB
|
||||||
* 3 yes no no Christmas
|
* 3 (8) yes no no Christmas
|
||||||
* 4 yes no no Hanukkah
|
* 4 (9) yes no no Hanukkah
|
||||||
* 5 yes no no Kwanzaa
|
* 5 (10) yes no no Kwanzaa
|
||||||
* 6 yes no no Rainbow
|
* 6 (11) yes no no Rainbow
|
||||||
* 7 yes no no Fire
|
* 7 (12) yes no no Fire
|
||||||
*
|
* 8 (13) yes no no Stairs
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
#define XLGT_01 1
|
#define XLGT_01 1
|
||||||
@ -401,8 +401,7 @@ void Ws2812Bars(uint32_t schemenr)
|
|||||||
Ws2812StripShow();
|
Ws2812StripShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ws2812Steps(uint32_t schemenr)
|
void Ws2812Steps(uint32_t schemenr) {
|
||||||
{
|
|
||||||
#if (USE_WS2812_CTYPE > NEO_3LED)
|
#if (USE_WS2812_CTYPE > NEO_3LED)
|
||||||
RgbwColor c;
|
RgbwColor c;
|
||||||
c.W = 0;
|
c.W = 0;
|
||||||
@ -417,16 +416,19 @@ void Ws2812Steps(uint32_t schemenr)
|
|||||||
scheme.colors[1].green = Settings->light_color[1];
|
scheme.colors[1].green = Settings->light_color[1];
|
||||||
scheme.colors[1].blue = Settings->light_color[2];
|
scheme.colors[1].blue = Settings->light_color[2];
|
||||||
}
|
}
|
||||||
uint8_t scheme_count=scheme.count;
|
|
||||||
|
|
||||||
|
uint8_t scheme_count = scheme.count;
|
||||||
if (Settings->light_fade) {
|
if (Settings->light_fade) {
|
||||||
scheme_count = Settings->ws_width[WS_HOUR]; // Width4
|
scheme_count = Settings->ws_width[WS_HOUR]; // Width4
|
||||||
}
|
}
|
||||||
|
if (scheme_count < 2) {
|
||||||
|
scheme_count = 2;
|
||||||
|
}
|
||||||
|
|
||||||
WsColor mcolor[scheme_count];
|
WsColor mcolor[scheme_count];
|
||||||
|
|
||||||
uint8_t color_start = 0;
|
uint8_t color_start = 0;
|
||||||
uint8_t color_end = 1;
|
uint8_t color_end = 1;
|
||||||
|
|
||||||
if (Settings->light_rotation & 0x01) {
|
if (Settings->light_rotation & 0x01) {
|
||||||
color_start = 1;
|
color_start = 1;
|
||||||
color_end = 0;
|
color_end = 0;
|
||||||
@ -442,7 +444,7 @@ void Ws2812Steps(uint32_t schemenr)
|
|||||||
} else {
|
} else {
|
||||||
memcpy(mcolor, scheme.colors, sizeof(mcolor));
|
memcpy(mcolor, scheme.colors, sizeof(mcolor));
|
||||||
}
|
}
|
||||||
// repair first & last color in gradient; apply scheme rotation if fade==0
|
// Repair first & last color in gradient; apply scheme rotation if fade==0
|
||||||
mcolor[0].red = scheme.colors[color_start].red;
|
mcolor[0].red = scheme.colors[color_start].red;
|
||||||
mcolor[0].green = scheme.colors[color_start].green;
|
mcolor[0].green = scheme.colors[color_start].green;
|
||||||
mcolor[0].blue = scheme.colors[color_start].blue;
|
mcolor[0].blue = scheme.colors[color_start].blue;
|
||||||
@ -450,7 +452,6 @@ void Ws2812Steps(uint32_t schemenr)
|
|||||||
mcolor[scheme_count-1].green = scheme.colors[color_end].green;
|
mcolor[scheme_count-1].green = scheme.colors[color_end].green;
|
||||||
mcolor[scheme_count-1].blue = scheme.colors[color_end].blue;
|
mcolor[scheme_count-1].blue = scheme.colors[color_end].blue;
|
||||||
|
|
||||||
|
|
||||||
// Adjust to dimmer value
|
// Adjust to dimmer value
|
||||||
float dimmer = 100 / (float)Settings->light_dimmer;
|
float dimmer = 100 / (float)Settings->light_dimmer;
|
||||||
for (uint32_t i = 0; i < scheme_count; i++) {
|
for (uint32_t i = 0; i < scheme_count; i++) {
|
||||||
@ -476,8 +477,8 @@ void Ws2812Steps(uint32_t schemenr)
|
|||||||
for (uint32_t i = 0; i < Settings->light_pixels; i++) {
|
for (uint32_t i = 0; i < Settings->light_pixels; i++) {
|
||||||
step_nr = i / Settings->light_step_pixels;
|
step_nr = i / Settings->light_step_pixels;
|
||||||
colorIndex = current_position - step_nr;
|
colorIndex = current_position - step_nr;
|
||||||
if(colorIndex < 0) colorIndex = 0;
|
if (colorIndex < 0) { colorIndex = 0; }
|
||||||
if(colorIndex > scheme_count - 1) colorIndex = scheme_count - 1;
|
if (colorIndex > scheme_count - 1) { colorIndex = scheme_count - 1; }
|
||||||
c.R = mcolor[colorIndex].red;
|
c.R = mcolor[colorIndex].red;
|
||||||
c.G = mcolor[colorIndex].green;
|
c.G = mcolor[colorIndex].green;
|
||||||
c.B = mcolor[colorIndex].blue;
|
c.B = mcolor[colorIndex].blue;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user