Fix light scheme 4 speed

Fix light scheme 4 speed (#7072)
This commit is contained in:
Theo Arends 2019-11-30 17:53:49 +01:00
parent f6302dbeca
commit 8cf2d15ed1
2 changed files with 12 additions and 19 deletions

View File

@ -4,6 +4,7 @@
- Fix slider for devices with one or two channels like only white or white/yellow
- Fix TasmotaSlave buffer overrun on Tele
- Fix light scheme 4 speed (#7072)
- Add support for TasmotaSlave executing commands on Tasmota
## Released

View File

@ -242,6 +242,7 @@ struct LIGHT {
uint8_t color_remap[LST_MAX];
uint8_t wheel = 0;
uint8_t random = 0;
uint8_t subtype = 0; // LST_ subtype
uint8_t device = 0;
uint8_t old_power = 1;
@ -1541,28 +1542,19 @@ void LightCycleColor(int8_t direction)
if (Light.strip_timer_counter % (Settings.light_speed * 2)) {
return;
}
Light.wheel += direction;
if (0 == direction) {
if (Light.random == Light.wheel) {
Light.random = random(255);
}
Light.wheel += (Light.random < Light.wheel) ? -1 : 1;
} else {
Light.wheel += direction;
}
LightWheel(Light.wheel);
memcpy(Light.new_color, Light.entry_color, sizeof(Light.new_color));
}
void LightRandomColor(void)
{
bool update = false;
for (uint32_t i = 0; i < LST_RGB; i++) {
if (Light.new_color[i] != Light.current_color[i]) {
update = true;
}
}
if (!update) {
Light.wheel = random(255);
LightWheel(Light.wheel);
memcpy(Light.current_color, Light.entry_color, sizeof(Light.current_color));
}
memcpy(Light.new_color, Light.current_color, sizeof(Light.new_color));
}
void LightSetPower(void)
{
// Light.power = XdrvMailbox.index;
@ -1652,7 +1644,7 @@ void LightAnimate(void)
LightCycleColor(-1);
break;
case LS_RANDOM:
LightRandomColor();
LightCycleColor(0);
break;
default:
XlgtCall(FUNC_SET_SCHEME);