From 832aa123d3301daf338219e5a3dd4dda84ca7981 Mon Sep 17 00:00:00 2001 From: bpohvoodoo Date: Sat, 2 Feb 2019 18:45:24 +0100 Subject: [PATCH] Bugfixes Bugfixes --- Arduino/McLighting/McLighting.ino | 6 +++--- Arduino/McLighting/request_handlers.h | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Arduino/McLighting/McLighting.ino b/Arduino/McLighting/McLighting.ino index fbbfcf3..b600257 100644 --- a/Arduino/McLighting/McLighting.ino +++ b/Arduino/McLighting/McLighting.ino @@ -1082,18 +1082,18 @@ void loop() { if (mode == SETCOLOR) { strip.setColor(main_color.red, main_color.green, main_color.blue, main_color.white); strip.trigger(); - mode = (prevmode == SET_MODE) ? SETSPEED : HOLD; + mode = (prevmode == SET_MODE) ? SETSPEED : prevmode; } if (mode == SETSPEED) { strip.setSpeed(convertSpeed(ws2812fx_speed)); strip.trigger(); - mode = (prevmode == SET_MODE) ? BRIGHTNESS : HOLD; + mode = (prevmode == SET_MODE) ? BRIGHTNESS : prevmode; } if (mode == BRIGHTNESS) { strip.setBrightness(brightness); strip.trigger(); if (prevmode == SET_MODE) prevmode = HOLD; - mode = HOLD; + mode = prevmode; } #ifdef ENABLE_LEGACY_ANIMATIONS if (mode == WIPE) { diff --git a/Arduino/McLighting/request_handlers.h b/Arduino/McLighting/request_handlers.h index a31f487..596df82 100644 --- a/Arduino/McLighting/request_handlers.h +++ b/Arduino/McLighting/request_handlers.h @@ -129,6 +129,7 @@ void handleSetMainColor(uint8_t * mypayload) { main_color.green = ((rgb >> 8) & 0xFF); main_color.blue = ((rgb >> 0) & 0xFF); // strip.setColor(main_color.red, main_color.green, main_color.blue); + prevmode = mode; mode = SETCOLOR; } @@ -510,6 +511,7 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) { if (payload[0] == '?') { uint8_t d = (uint8_t) strtol((const char *) &payload[1], NULL, 10); ws2812fx_speed = constrain(d, 0, 255); + prevmode = mode; mode = SETSPEED; Dbg_Prefix(mqtt, num); DBG_OUTPUT_PORT.printf("Set speed to: [%u]\n", ws2812fx_speed); @@ -529,6 +531,7 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) { if (payload[0] == '%') { uint8_t b = (uint8_t) strtol((const char *) &payload[1], NULL, 10); brightness = constrain(b, 0, 255); + prevmode = mode; mode = BRIGHTNESS; Dbg_Prefix(mqtt, num); DBG_OUTPUT_PORT.printf("Set brightness to: [%u]\n", brightness);