1
0
Fork 0

Update functions used to write to EEPROM

This commit is contained in:
Eric Tang 2016-04-21 19:35:18 -07:00
parent 9828aba2a1
commit 620ac4b260
14 changed files with 52 additions and 52 deletions

View file

@ -107,17 +107,17 @@ void setrgb(uint8_t r, uint8_t g, uint8_t b, struct cRGB *led1) {
uint32_t eeconfig_read_rgblight(void) {
return eeprom_read_dword(EECONFIG_RGBLIGHT);
}
void eeconfig_write_rgblight(uint32_t val) {
eeprom_write_dword(EECONFIG_RGBLIGHT, val);
void eeconfig_update_rgblight(uint32_t val) {
eeprom_update_dword(EECONFIG_RGBLIGHT, val);
}
void eeconfig_write_rgblight_default(void) {
dprintf("eeconfig_write_rgblight_default\n");
void eeconfig_update_rgblight_default(void) {
dprintf("eeconfig_update_rgblight_default\n");
rgblight_config.enable = 1;
rgblight_config.mode = 1;
rgblight_config.hue = 200;
rgblight_config.sat = 204;
rgblight_config.val = 204;
eeconfig_write_rgblight(rgblight_config.raw);
eeconfig_update_rgblight(rgblight_config.raw);
}
void eeconfig_debug_rgblight(void) {
dprintf("rgblight_config eprom\n");
@ -136,12 +136,12 @@ void rgblight_init(void) {
if (!eeconfig_is_enabled()) {
dprintf("rgblight_init eeconfig is not enabled.\n");
eeconfig_init();
eeconfig_write_rgblight_default();
eeconfig_update_rgblight_default();
}
rgblight_config.raw = eeconfig_read_rgblight();
if (!rgblight_config.mode) {
dprintf("rgblight_init rgblight_config.mode = 0. Write default values to EEPROM.\n");
eeconfig_write_rgblight_default();
eeconfig_update_rgblight_default();
rgblight_config.raw = eeconfig_read_rgblight();
}
eeconfig_debug_rgblight(); // display current eeprom values
@ -189,7 +189,7 @@ void rgblight_mode(uint8_t mode) {
} else {
rgblight_config.mode = mode;
}
eeconfig_write_rgblight(rgblight_config.raw);
eeconfig_update_rgblight(rgblight_config.raw);
dprintf("rgblight mode: %u\n", rgblight_config.mode);
if (rgblight_config.mode == 1) {
rgblight_timer_disable();
@ -206,7 +206,7 @@ void rgblight_mode(uint8_t mode) {
void rgblight_toggle(void) {
rgblight_config.enable ^= 1;
eeconfig_write_rgblight(rgblight_config.raw);
eeconfig_update_rgblight(rgblight_config.raw);
dprintf("rgblight toggle: rgblight_config.enable = %u\n", rgblight_config.enable);
if (rgblight_config.enable) {
rgblight_mode(rgblight_config.mode);
@ -299,7 +299,7 @@ void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val){
rgblight_config.hue = hue;
rgblight_config.sat = sat;
rgblight_config.val = val;
eeconfig_write_rgblight(rgblight_config.raw);
eeconfig_update_rgblight(rgblight_config.raw);
dprintf("rgblight set hsv [EEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
}
}