Skip to content

Commit

Permalink
extract eeprom write error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasjrossi committed May 18, 2023
1 parent d09491a commit 6e866e7
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions src/gaggiuino.ino
Original file line number Diff line number Diff line change
Expand Up @@ -375,37 +375,31 @@ static void lcdRefresh(void) {
//#############################################################################################
//###################################____SAVE_BUTTON____#######################################
//#############################################################################################
// Save the desired temp values to EEPROM
void lcdSaveSettingsTrigger(void) {
LOG_VERBOSE("Saving values to EEPROM");
bool rc;
eepromValues_t eepromCurrentValues = eepromGetCurrentValues();

lcdFetchPage(eepromCurrentValues, lcdCurrentPageId, runningCfg.activeProfile);

rc = eepromWrite(eepromCurrentValues);
void tryEepromWrite(eepromValues_t &eepromValues) {
bool success = eepromWrite(eepromValues);
watchdogReload(); // reload the watchdog timer on expensive operations
if (rc == true) {
if (success) {
lcdShowPopup("Update successful!");
} else {
lcdShowPopup("Data out of range!");
}
}

// Save the desired temp values to EEPROM
void lcdSaveSettingsTrigger(void) {
LOG_VERBOSE("Saving values to EEPROM");

eepromValues_t eepromCurrentValues = eepromGetCurrentValues();
lcdFetchPage(eepromCurrentValues, lcdCurrentPageId, runningCfg.activeProfile);
tryEepromWrite(eepromCurrentValues);
}

void lcdSaveProfileTrigger(void) {
LOG_VERBOSE("Saving profile to EEPROM");
bool rc;
eepromValues_t eepromCurrentValues = eepromGetCurrentValues();

eepromValues_t eepromCurrentValues = eepromGetCurrentValues();
lcdFetchCurrentProfile(eepromCurrentValues);

rc = eepromWrite(eepromCurrentValues);
watchdogReload(); // reload the watchdog timer on expensive operations
if (rc == true) {
lcdShowPopup("Update successful!");
} else {
lcdShowPopup("Data out of range!");
}
tryEepromWrite(eepromCurrentValues);
}

void lcdScalesTareTrigger(void) {
Expand Down

0 comments on commit 6e866e7

Please sign in to comment.