mirror of
https://github.com/Makuna/NeoPixelBus.git
synced 2025-08-10 06:14:26 +02:00
It is strongly recommended to check the new allocated pointer is not null
@@ -39,12 +39,17 @@ void setup() {
|
|||||||
...
|
...
|
||||||
}
|
}
|
||||||
|
|
||||||
void PixelCountChanged(uint16_t newCount) {
|
bool PixelCountChanged(uint16_t newCount) {
|
||||||
if (strip != NULL) {
|
if (strip != NULL) {
|
||||||
delete strip; // delete the previous dynamically created strip
|
delete strip; // delete the previous dynamically created strip
|
||||||
}
|
}
|
||||||
strip = new NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod>(newCount, Pin); // and recreate with new count
|
strip = new NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod>(newCount, Pin); // and recreate with new count
|
||||||
|
if (strip == NULL) {
|
||||||
|
Serial.println("OUT OF MEMORY");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
strip->Begin();
|
strip->Begin();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
Reference in New Issue
Block a user