Pass argument from epprom to a class constructor
Posted: Mon Mar 07, 2022 9:35 pm
Helow, i´m using the simplified subsequent code to initate a NeoPixel Strip in a ESP32 on arduino framework
I nedd to pass the 1 byte parameter from eeprom to the class constructor, cause this is the Leds qtty attached to the strip.
The issue is when i declare the class, can´t read the eeprom, cause, it isnt initialized yet, but i cant declare the class into "setup", after eeprom.begin (), cause this must be a global class. I need to be able to read the eeprom during global class and variables declaration or bypass this and declare a global class inside a function. idk if this can be possible, or there is any way to jump this. In other words, i need to read eeprom during global variables initialization, like this.
Best Regards.
Code: Select all
//creates the class "strip" at the begin code
NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(EEPROM.read(MNPIXEL), PinNeoPixel);
....
void setup ()
{
EEPROM.begin ();
strip.Begin ();
}
void loop {}......
The issue is when i declare the class, can´t read the eeprom, cause, it isnt initialized yet, but i cant declare the class into "setup", after eeprom.begin (), cause this must be a global class. I need to be able to read the eeprom during global class and variables declaration or bypass this and declare a global class inside a function. idk if this can be possible, or there is any way to jump this. In other words, i need to read eeprom during global variables initialization, like this.
Code: Select all
byte qtty=EEPROM.read(MNPIXEL);
......
void setup () {....}
void loop () {......}