Register / Login | Desktop view |
void CALLBACK_FUNCTION restoreDefaults(int id) {
String pgmHeaderText = "TEST DIALOG TEXT";
bool remoteAllowed = true;
BaseDialog* dlg = renderer.getDialog();
dlg->setButtons(BTNTYPE_OK, BTNTYPE_CANCEL, 1);
dlg->show(pgmHeaderText, remoteAllowed, onDialogFinished); // true = shows on remote sessions.
dlg->copyIntoBuffer("Hello");
}
void onDialogFinished(ButtonType btnPressed, void* /*userdata*/) {
if(btnPressed != BTNTYPE_OK) {
renderer.takeOverDisplay(restoreFactoryDefaults);
}
}
void restoreFactoryDefaults() {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(F("--------------------"));
lcd.setCursor(0, 1);
lcd.print(F("| RESTORING FACTORY|"));
lcd.setCursor(0, 2);
lcd.print(F("| DEFAULTS - WAIT! |"));
lcd.setCursor(0, 3);
lcd.print(F("--------------------"));
Serial.println(F("Wiping EEPROM settings and setting back to default."));
Serial.println(F("WAIT UNTIL COMPLETED!"));
/* Test EEPROM write - commented out for testing
EEPROM.write(2, 100); // LCD Brightness to 100%
*/
delay(5000);
Serial.println(F("Factory Reset Complete"));
lcd.clear();
renderer.giveBackDisplay();
}
void onDialogFinished(ButtonType btnPressed, void* /*userdata*/);
// Near the top, right after includes
void onDialogFinished(ButtonType btnPressed, void* /*userdata*/);
void CALLBACK_FUNCTION restoreDefaults(int id) {
BaseDialog* dlg = renderer.getDialog();
dlg->setButtons(BTNTYPE_OK, BTNTYPE_CANCEL, 1);
dlg->show("Test Dialog Text", true, onDialogFinished); // true = shows on remote sessions.
dlg->copyIntoBuffer("Factory Defaults?");
}
void onDialogFinished(ButtonType btnPressed, void* /*userdata*/) {
if(btnPressed != BTNTYPE_OK) {
renderer.takeOverDisplay(restoreFactoryDefaults);
}
}
void restoreFactoryDefaults() {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(F("--------------------"));
lcd.setCursor(0, 1);
lcd.print(F("| RESTORING FACTORY|"));
lcd.setCursor(0, 2);
lcd.print(F("| DEFAULTS - WAIT! |"));
lcd.setCursor(0, 3);
lcd.print(F("--------------------"));
Serial.println(F("Wiping EEPROM settings and setting back to default."));
Serial.println(F("WAIT UNTIL COMPLETED!"));
EEPROM.write(2, 100); // LCD Brightness to 100%
EEPROM.write(4, 50); // LCD Contrast to 50%
EEPROM.write(6, 0); // Serial Output Disabled
EEPROM.write(7, 2); // Serial Output Speed to 2
EEPROM.write(9, 3); // LED Display to 100%
EEPROM.write(11, 0); // Preinfuse Time ????
EEPROM.write(13, 0); // Preinfuse Disabled
EEPROM.write(14, 5); // Service Boiler Temperature Calibration Value
EEPROM.write(16, 80); // Service Boiler Set Temp F
EEPROM.write(18, 1); // Enable LED Display
EEPROM.write(20, 5); // Coffee Boiler/Group Temperature Calibration Value
EEPROM.write(22, 80); // Coffee Boiler/Group Set Temp F
EEPROM.write(24, 0); // Dose 1 Impulses
EEPROM.write(26, 0); // Dose 2 Impulses
EEPROM.write(28, 0); // Service Boiler Set Pressure
delay(5000);
Serial.println(F("Factory Reset Complete"));
lcd.clear();
renderer.giveBackDisplay();
}
// declare as follows
const char warningPgm[] PROGMEM = "Warning!";
// and then use it as follow
dlg->show(warningPgm, true);