How read, write and clear EEPROM from struct class

I have a ESP8266 board, I want to dynamic set to array struct class in animList class and write to eeprom from json array. could you give me example write, read and clear eepprom?
my code

struct animations
{
  textEffect_t   effecIn;       // Animation type In
  textEffect_t   effecOut;      // Animation type Out - In this example there are the same, but you can mix them.
  const char *   pText;         // Text to display
  uint16_t       speed;         // Animation speed (multiplier for library default) larger number = SLOWER
  uint16_t       pause;         // pause (multiplier for library default)  larger number = SLOWER
  textPosition_t align;         // PA_LEFT, PA_CENTER, PA_RIGHT
};

animations animList[] =
{
  {  { PA_PRINT,             PA_PRINT,             "PRINT",                            3, 2, PA_CENTER } 
};


Welcome to the forum

You can write a struct to EEPROM using the put() function

EEPROM.put(0, nameOfStruct);  //save a struct

and read it back using the get() function

EEPROM.get(0, nameOfStruct);  //load a struct

If you want to write an array of structs to EEPROM treat it as though it were any other array

EEPROM.put(0, arrayOfStructs);  //save array of structs

and load it back the same way

EEPROM.get(0, arrayOfStructs);  //load an array of structs

What exactly do you mean when you say that you want to clear the EEPROM ?
Bear in mind that each cell of the EEPROM will always contain a value

If you declare a pointer to text, then the text is not in the struct. If you would write that struct to EEPROM, then the text is not stored.

The ESP8266 does not have a EEPROM. It can be emulated by the Flash memory.

1 Like

Yeah, I'm newbie in the forum.
Thanks buddy!

Take note of what @Koepel says about storing pointers

@developer_lg Please post follow-up questions and code here rather than sending PM's

There is a fundamental flaw in your new code that others may benefit from seeing

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.