Skip to content

Commit afd0e86

Browse files
authored
Merge pull request #708 from adafruit/fix-neopixel-bug-c6
Fix Issues: Pixel and Status Pixel
2 parents 0bf00bc + 47f306c commit afd0e86

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

platformio.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ lib_deps =
9595

9696
; Common build environment for ESP32 platform
9797
[common:esp32]
98-
platform = https://github.com/pioarduino/platform-espressif32/releases/download/51.03.07/platform-espressif32.zip
98+
platform = https://github.com/pioarduino/platform-espressif32/releases/download/53.03.13/platform-espressif32.zip
9999
; This is needed for occasional new features and bug fixes
100100
; platform = https://github.com/pioarduino/platform-espressif32#develop
101101
lib_ignore = WiFiNINA, WiFi101, OneWire
@@ -167,7 +167,7 @@ board = adafruit_feather_esp32c6
167167
build_flags =
168168
-DARDUINO_ADAFRUIT_FEATHER_ESP32C6
169169
-DARDUINO_USB_CDC_ON_BOOT=1
170-
-DCORE_DEBUG_LEVEL=3
170+
-DCORE_DEBUG_LEVEL=5
171171
board_build.filesystem = littlefs
172172
board_build.partitions = min_spiffs.csv
173173

src/Wippersnapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
#endif
143143

144144
#define WS_VERSION \
145-
"1.0.0-beta.97" ///< WipperSnapper app. version (semver-formatted)
145+
"1.0.0-beta.98" ///< WipperSnapper app. version (semver-formatted)
146146

147147
// Reserved Adafruit IO MQTT topics
148148
#define TOPIC_IO_THROTTLE "/throttle" ///< Adafruit IO Throttle MQTT Topic

src/components/pixels/ws_pixels.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,19 @@ int16_t ws_pixels::allocateStrand() {
6464
*/
6565
/**************************************************************************/
6666
void ws_pixels::deallocateStrand(int16_t strandIdx) {
67-
6867
// delete the pixel object
69-
if (strands[strandIdx].neoPixelPtr != nullptr)
68+
if (strands[strandIdx].neoPixelPtr != nullptr) {
69+
// Fill with "off"
70+
strands[strandIdx].neoPixelPtr->clear();
71+
strands[strandIdx].neoPixelPtr->show();
72+
// Delete the NeoPixel object
7073
delete strands[strandIdx].neoPixelPtr;
71-
if ((strands[strandIdx].dotStarPtr != nullptr))
74+
} else if ((strands[strandIdx].dotStarPtr != nullptr)) {
75+
// Fill with "off"
76+
strands[strandIdx].dotStarPtr->clear();
77+
strands[strandIdx].dotStarPtr->show();
7278
delete strands[strandIdx].dotStarPtr;
79+
}
7380

7481
// re-initialize status pixel (if pixel was prvsly used)
7582
if (strands[strandIdx].pinNeoPixel == getStatusNeoPixelPin() ||
@@ -243,6 +250,7 @@ bool ws_pixels::addStrand(
243250
releaseStatusLED(); // release it!
244251

245252
// Create a new strand of NeoPixels
253+
WS_DEBUG_PRINTLN("Setting up new NeoPixel Strand...");
246254
strands[strandIdx].neoPixelPtr = new Adafruit_NeoPixel(
247255
pixelsCreateReqMsg->pixels_num, strands[strandIdx].pinNeoPixel,
248256
getNeoPixelStrandOrder(pixelsCreateReqMsg->pixels_ordering));

src/components/statusLED/Wippersnapper_StatusLED.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ void initStatusLED() {
5151
statusPixel = new Adafruit_NeoPixel(
5252
STATUS_NEOPIXEL_NUM, STATUS_NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800);
5353
statusPixel->begin();
54+
statusPixel->clear();
5455
statusPixel->show(); // turn OFF all pixels
5556
WS.lockStatusNeoPixel = true;
5657
}
@@ -69,6 +70,7 @@ void initStatusLED() {
6970
STATUS_DOTSTAR_PIN_CLK, STATUS_DOTSTAR_COLOR_ORDER)
7071
#endif
7172
statusPixelDotStar->begin();
73+
statusPixelDotStar->clear();
7274
statusPixelDotStar->show(); // turn OFF all pixels
7375
WS.lockStatusDotStar = true;
7476
}
@@ -99,10 +101,12 @@ void initStatusLED() {
99101
*/
100102
/****************************************************************************/
101103
void releaseStatusLED() {
104+
WS_DEBUG_PRINTLN("Releasing status LED");
102105
#ifdef USE_STATUS_NEOPIXEL
103-
delete statusPixel; // Deallocate Adafruit_NeoPixel object, set data pin back
104-
// to INPUT.
105-
WS.lockStatusNeoPixel = false; // unlock
106+
// Deallocate Adafruit_NeoPixel object, set data pin back to INPUT,
107+
// and unlock pixel for use by pixels component
108+
delete statusPixel;
109+
WS.lockStatusNeoPixel = false;
106110
#endif
107111

108112
#ifdef USE_STATUS_DOTSTAR

0 commit comments

Comments
 (0)