Go Down

Topic: HOW TO SAVE USER DATA IN EEPROM WITH A TEXT LABEL? (Read 176 times) previous topic - next topic

Pritam_D

Hi! I'm replacing my guitar pots with 3 rotary encoder with led ring. I can save the rotary encoder positions, which is from 0-255 in EEPROM. My idea is to save the positions with different song name so that the user can write the song name to save the rotary positions of that particular song and recall it later by song name.

How to save user data with a label in EEPROM?

Lucario448

You could create a "data structure" (struct) that will contain those three values and a fixed size for a char array (aka C-style string).

The three values are pretty straightfoward to define: just 3 bytes; but not so much the "label". For the label, you have to define a maximum length (although the actual string doesn't necessarily have to fill all that space, that's why it's a maximum and not a minimum).

After defining your data structure, is just a matter of using it as a parameter for put() and get(). The address will be something like:
Code: [Select]
index * sizeof(yourStructure)

Go Up