Constructor does not initializes EEPROM. If in setup of .ino launch init(), EEPROM is correctly initialized, but Serial.print(_n); gives 0 and not 256.
For this reason i can't use in init(), the eeprom command EEPROM.begin(_n);
For instance of class in .ino i tried:
eep eep(256);
eep e=eep(256);
either way it doesn't work.
Can you help me?
Thanks in advance!
Now EEPROM.begin(_n); inside init() works, but if I don't put it in the init() and leave it only in the constructor the eeprom is not initialized.
I'm going crazy!
Library objects have a .begin() method because the Arduino runtime is not initialized until AFTER the global constructors are called. If they rely on anything done in the runtime initialization, they put that part in .begin() and require you to call it from setup().
That means calling a .begin() function in an object constructor won't work. Add a .begin() to your object and call the .begin() functions from there.
Note: The EEPROM.begin() doesn't actually do any setup.
//STL and C++11 iteration capability.
EEPtr begin() { return 0x00; }
EEPtr end() { return length(); } //Standards requires this to be the item after the last valid entry. The returned pointer is invalid.
uint16_t length() { return E2END + 1; }