Go Down

Topic: EEprom storage using writeAnything.h (Read 1 time) previous topic - next topic


mySensVals   will be numbers anywhere from 100 to 2000
Does the Uno have enough eeprom to store this many settings?

Code: [Select]

struct config_settings
    int mySensVals[12];  //# of pulses in 2-12 cups
    boolean Enable_Audio;  //whether the user wants sound
    boolean Enable_Piezo;  //whether the user wants a knock sensor
    boolean Enable_PhotoCell;  //whether the user wants to use the photocell
} MySettings;

//...set up values to save. 

    EEPROM_writeAnything(0, MySettings);  //save the settings


I count 27 bytes of storage needed to store that structure into eeprom. As the Uno has a 1,000 byte eeprom it should fit rather nicely, if not lonely with all the extra eeprom space avalible.  ;)



Thanks! (that was quick).  I'll reread the ref section on sizes, an integer must be only 2 bytes, and a boolean 1, to only add up to 27...


Yeah, I just read the size of bolleans and integers.  strange a boolean only holds true or false, in 1 byte, and and integer at 2 bytes can hold a huge number.  I thought it would have been a lot more bytes than that.  I should be okay with all the settings I can think of changing!


strange a boolean only holds true or false, in 1 byte, and and integer at 2 bytes can hold a huge number.

The smallest addressible item on the AVR is a byte.
If you are really pushed for space (it doesn't look like you are!), you can use structs with bit-fields defined in them for boolean flags.
Code: [Select]
struct {
unsigned flag0:1; // defines eight, one bit fields.
unsigned flag1:1;
unsigned flag2:1;
unsigned flag3:1;
unsigned flag4:1;
unsigned flag5:1;
unsigned flag6:1;
unsigned flag7:1;};
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up