Abstration of the EEPROM library?


hello all,

i have application user configures settings through ui (16x2 lcd , few buttons) , lets arduino chug away turning things on , off according settings. i'd store these settings in onboard eeprom, preserved during power outages, can't think of "clean" way it.

i'm wondering - there libraries out there "abstract" eeprom usage? ideally, i'd love if there library allowed me to:

1) declare variables of type , designate them "eeprom" variables
2) read value of variable memory during start up
3) write value of variable eeprom time changed
4) automatically handle "messy" stuff keeping track of memory addresses, converting between data types, etc. don't have worry it.

anything exist?

a library may preferred some, if @ standard eeprom support included avr compiler, pretty powerful is:

code: [select]

#include <avr/eeprom.h>

// eeprom layout
byte eeprom_val1 eemem = 1;
word eeprom_val2 eemem = 2;
long eeprom_val3 eemem = 3;
float eeprom_val4 eemem = 4.0;

// initialized eeprom
byte val1;
word val2;
long val3;
float val4;

void setup()
{
 // reading eeprom
 eeprom_read_block(&val1, &eeprom_val1, sizeof(val1));
 eeprom_read_block(&val2, &eeprom_val2, sizeof(val2));
 eeprom_read_block(&val3, &eeprom_val3, sizeof(val3));
 eeprom_read_block(&val4, &eeprom_val4, sizeof(val4));

 // writing eeprom
 eeprom_write_block(&eeprom_val1, &val1, sizeof(val1));
 eeprom_write_block(&eeprom_val2, &val2, sizeof(val2));
 eeprom_write_block(&eeprom_val3, &val3, sizeof(val3));
 eeprom_write_block(&eeprom_val4, &val4, sizeof(val4));
}

void loop()
{
}


when using eemem directive in declaration, compiler figure out offsets you. juggling definitions issue if change order of declartions once data in eeprom.

there type specific functions included byte, word etc., standardizing on "block" (any-size) versions allow consistency.


Arduino Forum > Forum 2005-2010 (read only) > Software > Development > Abstration of the EEPROM library?


arduino

Comments