Skip to content

Commit

Permalink
Fix light scheme 4 speed
Browse files Browse the repository at this point in the history
Fix light scheme 4 speed (#7072)
  • Loading branch information
arendst committed Nov 30, 2019
1 parent f6302db commit 8cf2d15
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
1 change: 1 addition & 0 deletions tasmota/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 10 additions & 18 deletions tasmota/xdrv_04_light.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1541,26 +1542,17 @@ void LightCycleColor(int8_t direction)
if (Light.strip_timer_counter % (Settings.light_speed * 2)) {
return;
}
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 (0 == direction) {
if (Light.random == Light.wheel) {
Light.random = random(255);
}
Light.wheel += (Light.random < Light.wheel) ? -1 : 1;
} else {
Light.wheel += direction;
}
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));
LightWheel(Light.wheel);
memcpy(Light.new_color, Light.entry_color, sizeof(Light.new_color));
}

void LightSetPower(void)
Expand Down Expand Up @@ -1652,7 +1644,7 @@ void LightAnimate(void)
LightCycleColor(-1);
break;
case LS_RANDOM:
LightRandomColor();
LightCycleColor(0);
break;
default:
XlgtCall(FUNC_SET_SCHEME);
Expand Down

0 comments on commit 8cf2d15

Please sign in to comment.