Reputation: 5
typedef struct _color_swatch{
int16_t radius;
int16_t x;
int16_t y;
uint16_t color;
} myColorSwatch;
typedef struct _user_settings{
uint16_t userColor;
int8_t userBrightness;
int16_t userSleepTime;
} userSettingsType;
myColorSwatch swatch[6] = {
30, 35, 35, WHITE,
30, 100, 35, RED,
30, 165, 35, GREEN,
30, 230, 35, BLUE,
35, 335, 90, RED,
35, 409, 90, GREEN
};
Skip into setup function.
// Loading user settings.
userSettingsType userSettings = {0, 50, 10000};
/*
userSettings.userColor = 0;
userSettings.userBrightness = 50;
userSettings.userSleepTime = 10000;
*/
EEPROM.write(0, userSettings);
The error I'm getting:
... : In function 'void setup()':
...:249:32: error: no matching function for call to 'EEPROMClass::write(int, userSettingsType&)'
EEPROM.write(0, userSettings);
^
... :33:0:
C:\Users\--\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\EEPROM\src/EEPROM.h:121:10: note: candidate: void EEPROMClass::write(int, uint8_t)
void write( int idx, uint8_t val ) { (EERef( idx )) = val; }
^~~~~
C:\Users\--\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\EEPROM\src/EEPROM.h:121:10: note: no known conversion for argument 2 from 'userSettingsType {aka _user_settings}' to 'uint8_t {aka unsigned char}'
exit status 1
no matching function for call to 'EEPROMClass::write(int, userSettingsType&)'
Problem:
I am not particularly familiar with structs or c++ in general, and I believe that is the primary cause of the issue. I would like to save the userSettings struct to the arduino uno's EEPROM. I have been messing around and tried a bunch of variations including using the EEPROM.update function, which is the one I would prefer to use, but with no good results. That is why there is commented out stuff. The weird part to me is that I can use the other swatch array of structs for the value argument and it will compile fine, plus I have seen other examples online doing it with no problems. I have followed other examples including the official ones and done a bunch of research into the issue and unfortunately had no luck fixing it. So I'm lost as to what the difference is and have run out of ideas for trial and error. Any guidance would be appreciated.
-Nathan
Upvotes: -3
Views: 46