Skip to content

Commit fce17a3

Browse files
committed
Fix for C6
1 parent 53c95ac commit fce17a3

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

src/components/pixels/ws_pixels.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,24 @@ 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+
#ifdef ARDUINO_ARCH_ESP32
73+
// Clear the pin used for RMT
74+
strands[strandIdx].neoPixelPtr->updateLength(0);
75+
strands[strandIdx].neoPixelPtr->show();
76+
#endif
77+
// Delete the NeoPixel object
7078
delete strands[strandIdx].neoPixelPtr;
71-
if ((strands[strandIdx].dotStarPtr != nullptr))
79+
} else if ((strands[strandIdx].dotStarPtr != nullptr)) {
80+
// Fill with "off"
81+
strands[strandIdx].dotStarPtr->clear();
82+
strands[strandIdx].dotStarPtr->show();
7283
delete strands[strandIdx].dotStarPtr;
84+
}
7385

7486
// re-initialize status pixel (if pixel was prvsly used)
7587
if (strands[strandIdx].pinNeoPixel == getStatusNeoPixelPin() ||

src/components/statusLED/Wippersnapper_StatusLED.cpp

Lines changed: 8 additions & 7 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,16 +101,15 @@ void initStatusLED() {
99101
*/
100102
/****************************************************************************/
101103
void releaseStatusLED() {
102-
WS_DEBUG_PRINTLN("Releasing status LED");
104+
WS_DEBUG_PRINTLN("Releasing status LED");
103105
#ifdef USE_STATUS_NEOPIXEL
104-
WS_DEBUG_PRINTLN("Deinit the RMT...");
105-
//Deinit the RMT
106+
#ifdef ARDUINO_ARCH_ESP32
107+
// Release the rmtPin for use by other peripherals
106108
statusPixel->updateLength(0);
107109
statusPixel->show();
108-
WS_DEBUG_PRINTLN("Deleting the statusPixel");
109-
delete statusPixel; // Deallocate Adafruit_NeoPixel object, set data pin back
110-
// to INPUT.
111-
statusPixel = nullptr;
110+
#endif
111+
// Dealloc. NeoPixel object
112+
delete statusPixel;
112113
WS.lockStatusNeoPixel = false; // unlock
113114
#endif
114115

0 commit comments

Comments
 (0)