From 05f506549a2ad42d3032c7bef3f49c6269f1a69d Mon Sep 17 00:00:00 2001 From: Maxime Date: Thu, 9 Aug 2018 17:01:06 +0200 Subject: [PATCH] Fixed LEDs reminiscence issue when changing num_pixels to a smaller value - "deactivated" pixels were not controlled anymore and stayed in their previous state. --- periph_sw/nRF52_RGB_Strip/led_lib.h | 18 +++++++++--------- periph_sw/nRF52_RGB_Strip/nRF52_RGB_Strip.ino | 1 + 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/periph_sw/nRF52_RGB_Strip/led_lib.h b/periph_sw/nRF52_RGB_Strip/led_lib.h index d15711f..9362395 100644 --- a/periph_sw/nRF52_RGB_Strip/led_lib.h +++ b/periph_sw/nRF52_RGB_Strip/led_lib.h @@ -116,6 +116,15 @@ class CtrlLED writeEach(strip.Color(255, 255, 255)); } + // Set all pixels off. Not calling show. + void setPixelsOff(void) + { + for (unsigned int i = 0; i < this->p_settings->num_pixels; ++i) + { + strip.setPixelColor(i, strip.Color(0, 0, 0)); + } + } + void switchOff() { analogWrite(pinDebug, 0); @@ -292,15 +301,6 @@ class CtrlLED b = map(b, 0, 255, 0, intensity); return strip.Color(r, g, b); } - - // Set all pixels off. Not calling show. - void setPixelsOff(void) - { - for (unsigned int i = 0; i < this->p_settings->num_pixels; ++i) - { - strip.setPixelColor(i, strip.Color(0, 0, 0)); - } - } }; const CtrlLED::Color CtrlLED::presetColors[CtrlLED::NB_PRESET_COLORS] = { diff --git a/periph_sw/nRF52_RGB_Strip/nRF52_RGB_Strip.ino b/periph_sw/nRF52_RGB_Strip/nRF52_RGB_Strip.ino index f2f276b..a9083f2 100644 --- a/periph_sw/nRF52_RGB_Strip/nRF52_RGB_Strip.ino +++ b/periph_sw/nRF52_RGB_Strip/nRF52_RGB_Strip.ino @@ -132,6 +132,7 @@ void readUART(uint8_t *const p_ledMode) break; case 'A': Serial.println("[SETTINGS] getting cfg chunk#1 ask for chunk#2"); + led.setPixelsOff(); // First switch pixels off to avoid reminiscence. settings.num_pixels = packetPayload[1]; //Serial.println(String(settings.num_pixels)); settings.device_name = "";