Help for Setup LED Strip in Setup Code #898
Replies: 1 comment
-
|
You have run into a core design issue with the current NeoPixelBus. It was never meant for dynamic LED type projects, but it was optimized for smaller code and memory for a hardcoded type. When this library was first designed bytes for code and memory were precious, ATTINY sized chips. With more modern units like ESP32 that has become less of an issue and has warranted a complete redesign sometime in the future. The key design problem is that every time you have one of these "dynamic branching points" in code, it will cost you. It may be any number of the following: Instruction Memory (larging code), RAM (larger dynamic memory), slower (branching cost instructions if done in inner loops). Due to the template use for optimizations, it makes almost every instance of a NPB a unique class, so you can't have one pointer type. Right now, your code will be peppered with switch statements/branching tests for almost every call into it. But the cost of calling SetPixelColor() (usually an inner loop call) will be problematic, and I have a generalized solution for that. WLED has scaffolding in place doing exactly what you are trying to do, and I am working on solutions to make it easier. One approach I like but I have never implemented (I personally don't implement dynamic pixel switching in my projects as they are one offs) is the multiple pointer solution. Requires checking if the pointer is not null before making every call. The cost is small, a pointer per type, often you don't another variable to define type as you are just checking if the pointer is null before making a call. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have code. i need to make using a global variable using user data i need to start led strip led count and chipset.
These things i cant define in code. i need to make interface selecting and store eeprom and according to that data start in setup.
anyone can help me to fix this ?
Here is my code
Beta Was this translation helpful? Give feedback.
All reactions