diff --git a/TFT/src/User/API/AddonHardware.c b/TFT/src/User/API/AddonHardware.c index 33c94ab34b..39fbc34b09 100644 --- a/TFT/src/User/API/AddonHardware.c +++ b/TFT/src/User/API/AddonHardware.c @@ -239,8 +239,7 @@ void FIL_FE_CheckRunout(void) if (printPause(true, PAUSE_NORMAL) && !getRunoutAlarm()) // If not printing, printPause() function will always fail { // so no useless error message is displayed setRunoutAlarmTrue(); - setDialogText(LABEL_WARNING, LABEL_FILAMENT_RUNOUT, LABEL_CONFIRM, LABEL_NULL); - showDialog(DIALOG_TYPE_ALERT, setRunoutAlarmFalse, NULL, NULL); + popupDialog(DIALOG_TYPE_ALERT, LABEL_WARNING, LABEL_FILAMENT_RUNOUT, LABEL_CONFIRM, LABEL_NULL, setRunoutAlarmFalse, NULL, NULL); } if ((OS_GetTimeMs() > nextReminderTime) && (getRunoutAlarm() == true)) diff --git a/TFT/src/User/API/Printing.c b/TFT/src/User/API/Printing.c index cff3f49496..2854128702 100644 --- a/TFT/src/User/API/Printing.c +++ b/TFT/src/User/API/Printing.c @@ -255,8 +255,7 @@ void shutdownStart(void) mustStoreCmd(fanCmd[i], infoSettings.fan_max[i]); } - setDialogText(LABEL_SHUT_DOWN, (uint8_t *)tempstr, LABEL_FORCE_SHUT_DOWN, LABEL_CANCEL); - showDialog(DIALOG_TYPE_INFO, shutdown, NULL, shutdownLoop); + popupDialog(DIALOG_TYPE_INFO, LABEL_SHUT_DOWN, (uint8_t *)tempstr, LABEL_FORCE_SHUT_DOWN, LABEL_CANCEL, shutdown, NULL, shutdownLoop); } void initPrintSummary(void) @@ -547,8 +546,7 @@ void printAbort(void) request_M0(); // M524 is not supported in RepRap firmware } - setDialogText(LABEL_SCREEN_INFO, LABEL_BUSY, LABEL_NULL, LABEL_NULL); - showDialog(DIALOG_TYPE_INFO, NULL, NULL, NULL); + popupSplash(DIALOG_TYPE_INFO, LABEL_SCREEN_INFO, LABEL_BUSY); // wait until infoHost.status is set to "HOST_STATUS_IDLE" by setPrintPause() loopProcessToCondition(&isHostPrinting); diff --git a/TFT/src/User/API/parseACK.c b/TFT/src/User/API/parseACK.c index beafcc9cfb..1a0121e2e5 100644 --- a/TFT/src/User/API/parseACK.c +++ b/TFT/src/User/API/parseACK.c @@ -382,20 +382,18 @@ void hostActionCommands(void) switch (hostAction.button) { case 0: - setDialogText((uint8_t *)"Message", (uint8_t *)hostAction.prompt_begin, LABEL_CONFIRM, LABEL_NULL); - showDialog(DIALOG_TYPE_ALERT, setRunoutAlarmFalse, NULL, NULL); + popupDialog(DIALOG_TYPE_ALERT, (uint8_t *)"Message", (uint8_t *)hostAction.prompt_begin, + LABEL_CONFIRM, LABEL_NULL, setRunoutAlarmFalse, NULL, NULL); break; case 1: - setDialogText((uint8_t *)"Action command", (uint8_t *)hostAction.prompt_begin, - (uint8_t *)hostAction.prompt_button[0], LABEL_NULL); - showDialog(DIALOG_TYPE_ALERT, breakAndContinue, NULL, NULL); + popupDialog(DIALOG_TYPE_ALERT, (uint8_t *)"Action command", (uint8_t *)hostAction.prompt_begin, + (uint8_t *)hostAction.prompt_button[0], LABEL_NULL, breakAndContinue, NULL, NULL); break; case 2: - setDialogText((uint8_t *)"Action command", (uint8_t *)hostAction.prompt_begin, - (uint8_t *)hostAction.prompt_button[0], (uint8_t *)hostAction.prompt_button[1]); - showDialog(DIALOG_TYPE_ALERT, resumeAndPurge, resumeAndContinue, NULL); + popupDialog(DIALOG_TYPE_ALERT, (uint8_t *)"Action command", (uint8_t *)hostAction.prompt_begin, + (uint8_t *)hostAction.prompt_button[0], (uint8_t *)hostAction.prompt_button[1], resumeAndPurge, resumeAndContinue, NULL); break; } } @@ -647,8 +645,8 @@ void parseACK(void) // parse pause message else if (!infoMachineSettings.promptSupport && ack_seen("paused for user")) { - setDialogText((uint8_t *)"Printer is Paused", (uint8_t *)"Paused for user\ncontinue?", LABEL_CONFIRM, LABEL_NULL); - showDialog(DIALOG_TYPE_QUESTION, breakAndContinue, NULL, NULL); + popupDialog(DIALOG_TYPE_QUESTION, (uint8_t *)"Printer is Paused", (uint8_t *)"Paused for user\ncontinue?", + LABEL_CONFIRM, LABEL_NULL, breakAndContinue, NULL, NULL); } // parse host action commands. Required "HOST_ACTION_COMMANDS" and other settings in Marlin else if (ack_seen("//action:")) @@ -744,8 +742,7 @@ void parseACK(void) if (ack_seen("Max: ")) sprintf(&tmpMsg[strlen(tmpMsg)], "\nMax: %0.5f", ack_value()); if (ack_seen("Range: ")) sprintf(&tmpMsg[strlen(tmpMsg)], "\nRange: %0.5f", ack_value()); - setDialogText((uint8_t *)"Repeatability Test", (uint8_t *)tmpMsg, LABEL_CONFIRM, LABEL_NULL); - showDialog(DIALOG_TYPE_INFO, NULL, NULL, NULL); + popupReminder(DIALOG_TYPE_INFO, (uint8_t *)"Repeatability Test", (uint8_t *)tmpMsg); } // parse M48, standard deviation else if (ack_seen("Standard Deviation: ")) @@ -760,8 +757,7 @@ void parseACK(void) levelingSetProbedPoint(-1, -1, ack_value()); // save probed Z value sprintf(tmpMsg, "%s\nStandard Deviation: %0.5f", (char *)getDialogMsgStr(), ack_value()); - setDialogText((uint8_t *)"Repeatability Test", (uint8_t *)tmpMsg, LABEL_CONFIRM, LABEL_NULL); - showDialog(DIALOG_TYPE_INFO, NULL, NULL, NULL); + popupReminder(DIALOG_TYPE_INFO, (uint8_t *)"Repeatability Test", (uint8_t *)tmpMsg); } } // parse and store M211 or M503, software endstops state (e.g. from Probe Offset, MBL, Mesh Editor menus) @@ -879,8 +875,8 @@ void parseACK(void) if (infoMachineSettings.EEPROM == 1) { - setDialogText(LABEL_DELTA_CONFIGURATION, LABEL_EEPROM_SAVE_INFO, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_SUCCESS, saveEepromSettings, NULL, NULL); + popupDialog(DIALOG_TYPE_SUCCESS, LABEL_DELTA_CONFIGURATION, LABEL_EEPROM_SAVE_INFO, + LABEL_CONFIRM, LABEL_CANCEL, saveEepromSettings, NULL, NULL); } else { diff --git a/TFT/src/User/Menu/ABL.c b/TFT/src/User/Menu/ABL.c index 908bb2d097..18b6fff3c3 100644 --- a/TFT/src/User/Menu/ABL.c +++ b/TFT/src/User/Menu/ABL.c @@ -38,8 +38,7 @@ void ablUpdateStatus(bool succeeded) if (savingEnabled && infoMachineSettings.EEPROM == 1) { sprintf(&tempMsg[strlen(tempMsg)], "\n %s", textSelect(LABEL_EEPROM_SAVE_INFO)); - setDialogText(tempTitle.index, (uint8_t *) tempMsg, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_SUCCESS, saveEepromSettings, NULL, NULL); + popupDialog(DIALOG_TYPE_SUCCESS, tempTitle.index, (uint8_t *) tempMsg, LABEL_CONFIRM, LABEL_CANCEL, saveEepromSettings, NULL, NULL); } else { @@ -138,18 +137,14 @@ void menuUBLSaveLoad(void) case KEY_ICON_2: case KEY_ICON_3: ublSlot = key_num; - - setDialogText(UBLSaveLoadItems.title.index, LABEL_CONFIRMATION, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_QUESTION, ublSaveloadConfirm, NULL, NULL); + popupDialog(DIALOG_TYPE_QUESTION, UBLSaveLoadItems.title.index, LABEL_CONFIRMATION, LABEL_CONFIRM, LABEL_CANCEL, ublSaveloadConfirm, NULL, NULL); break; case KEY_ICON_7: if (ublSlotSaved == true && infoMachineSettings.EEPROM == 1) { ublSlotSaved = false; - - setDialogText(LABEL_ABL_SETTINGS_UBL, LABEL_ABL_SLOT_EEPROM, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_QUESTION, saveEepromSettings, NULL, NULL); + popupDialog(DIALOG_TYPE_QUESTION, LABEL_ABL_SETTINGS_UBL, LABEL_ABL_SLOT_EEPROM, LABEL_CONFIRM, LABEL_CANCEL, saveEepromSettings, NULL, NULL); } else { diff --git a/TFT/src/User/Menu/Babystep.c b/TFT/src/User/Menu/Babystep.c index e0da524a2f..9765f6a8f0 100644 --- a/TFT/src/User/Menu/Babystep.c +++ b/TFT/src/User/Menu/Babystep.c @@ -152,9 +152,7 @@ void menuBabystep(void) if (infoMachineSettings.EEPROM == 1) { orig_z_offset = offsetSetValue(new_z_offset); // set new Z offset. Required if current Z offset is not changed applying babystep changes (e.g. no BABYSTEP_ZPROBE_OFFSET is set in Marlin FW) - - setDialogText(babyStepItems.title.index, LABEL_EEPROM_SAVE_INFO, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_QUESTION, saveEepromSettings, NULL, NULL); + popupDialog(DIALOG_TYPE_QUESTION, babyStepItems.title.index, LABEL_EEPROM_SAVE_INFO, LABEL_CONFIRM, LABEL_CANCEL, saveEepromSettings, NULL, NULL); } break; diff --git a/TFT/src/User/Menu/BedLeveling.c b/TFT/src/User/Menu/BedLeveling.c index f079a45abe..dde6e3df7b 100644 --- a/TFT/src/User/Menu/BedLeveling.c +++ b/TFT/src/User/Menu/BedLeveling.c @@ -102,8 +102,7 @@ void menuBedLeveling(void) #if DELTA_PROBE_TYPE != 2 // if not removable probe ablStart(); #else // if removable probe - setDialogText(LABEL_WARNING, LABEL_CONNECT_PROBE, LABEL_CONTINUE, LABEL_CANCEL); - showDialog(DIALOG_TYPE_ALERT, ablStart, NULL, NULL); + popupDialog(DIALOG_TYPE_ALERT, LABEL_WARNING, LABEL_CONNECT_PROBE, LABEL_CONTINUE, LABEL_CANCEL, ablStart, NULL, NULL); #endif } #endif @@ -113,8 +112,7 @@ void menuBedLeveling(void) #if DELTA_PROBE_TYPE != 2 OPEN_MENU(menuMeshEditor); #else - setDialogText(LABEL_WARNING, LABEL_DISCONNECT_PROBE, LABEL_CONTINUE, LABEL_CANCEL); - showDialog(DIALOG_TYPE_ALERT, deltaMeshEditor, NULL, NULL); + popupDialog(DIALOG_TYPE_ALERT, LABEL_WARNING, LABEL_DISCONNECT_PROBE, LABEL_CONTINUE, LABEL_CANCEL, deltaMeshEditor, NULL, NULL); #endif break; @@ -154,8 +152,7 @@ void menuBedLeveling(void) zOffsetSetMenu(true); // use Probe Offset menu OPEN_MENU(menuZOffset); #else - setDialogText(LABEL_WARNING, LABEL_DISCONNECT_PROBE, LABEL_CONTINUE, LABEL_CANCEL); - showDialog(DIALOG_TYPE_ALERT, deltaZOffset, NULL, NULL); + popupDialog(DIALOG_TYPE_ALERT, LABEL_WARNING, LABEL_DISCONNECT_PROBE, LABEL_CONTINUE, LABEL_CANCEL, deltaZOffset, NULL, NULL); #endif } break; diff --git a/TFT/src/User/Menu/BedLevelingLayer2.c b/TFT/src/User/Menu/BedLevelingLayer2.c index 319c6317d0..f2fd6c99a9 100644 --- a/TFT/src/User/Menu/BedLevelingLayer2.c +++ b/TFT/src/User/Menu/BedLevelingLayer2.c @@ -81,8 +81,7 @@ void menuBedLevelingLayer2(void) #if DELTA_PROBE_TYPE != 2 // if not removable probe ablStart(); #else // if removable probe - setDialogText(LABEL_WARNING, LABEL_CONNECT_PROBE, LABEL_CONTINUE, LABEL_CANCEL); - showDialog(DIALOG_TYPE_ALERT, ablStart, NULL, NULL); + popupDialog(DIALOG_TYPE_ALERT, LABEL_WARNING, LABEL_CONNECT_PROBE, LABEL_CONTINUE, LABEL_CANCEL, ablStart, NULL, NULL); #endif } else // if MBL diff --git a/TFT/src/User/Menu/FeatureSettings.c b/TFT/src/User/Menu/FeatureSettings.c index ab06759923..76913c935e 100644 --- a/TFT/src/User/Menu/FeatureSettings.c +++ b/TFT/src/User/Menu/FeatureSettings.c @@ -114,8 +114,7 @@ void updateFeatureSettings(uint8_t item_index) break; case SKEY_RESET_SETTINGS: - setDialogText(LABEL_SETTINGS_RESET, LABEL_SETTINGS_RESET_INFO, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_ALERT, resetSettings, NULL, NULL); + popupDialog(DIALOG_TYPE_ALERT, LABEL_SETTINGS_RESET, LABEL_SETTINGS_RESET_INFO, LABEL_CONFIRM, LABEL_CANCEL, resetSettings, NULL, NULL); break; default: diff --git a/TFT/src/User/Menu/LevelCorner.c b/TFT/src/User/Menu/LevelCorner.c index 710044c629..3c1c83aaca 100644 --- a/TFT/src/User/Menu/LevelCorner.c +++ b/TFT/src/User/Menu/LevelCorner.c @@ -142,10 +142,7 @@ void menuLevelCorner(void) getLevelEdgeDefault(), infoSettings.level_edge); if (curLevelEdge >= getLevelEdgeMin() && infoSettings.level_edge < getLevelEdgeMin()) // if new value is below min limit - { - setDialogText(LABEL_WARNING, LABEL_LEVEL_CORNER_INFO, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_QUESTION, setLevelEdgeMin, NULL, NULL); - } + popupDialog(DIALOG_TYPE_QUESTION, LABEL_WARNING, LABEL_LEVEL_CORNER_INFO, LABEL_CONFIRM, LABEL_CANCEL, setLevelEdgeMin, NULL, NULL); break; } diff --git a/TFT/src/User/Menu/MBL.c b/TFT/src/User/Menu/MBL.c index 538e7acfef..36aafc3f95 100644 --- a/TFT/src/User/Menu/MBL.c +++ b/TFT/src/User/Menu/MBL.c @@ -64,9 +64,7 @@ void mblUpdateStatus(bool succeeded) if (infoMachineSettings.EEPROM == 1) { sprintf(&tempMsg[strlen(tempMsg)], "\n %s", textSelect(LABEL_EEPROM_SAVE_INFO)); - - setDialogText(LABEL_MBL_SETTINGS, (uint8_t *) tempMsg, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_SUCCESS, saveEepromSettings, NULL, NULL); + popupDialog(DIALOG_TYPE_SUCCESS, LABEL_MBL_SETTINGS, (uint8_t *) tempMsg, LABEL_CONFIRM, LABEL_CANCEL, saveEepromSettings, NULL, NULL); } else { diff --git a/TFT/src/User/Menu/MPC.c b/TFT/src/User/Menu/MPC.c index ea989b5674..b50d5eacc1 100644 --- a/TFT/src/User/Menu/MPC.c +++ b/TFT/src/User/Menu/MPC.c @@ -198,8 +198,7 @@ void menuMPC(void) break; case KEY_ICON_6: - setDialogText(mpcItems.title.index, LABEL_TUNE_START_INFO, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_QUESTION, mpcStart, NULL, NULL); + popupDialog(DIALOG_TYPE_QUESTION, mpcItems.title.index, LABEL_TUNE_START_INFO, LABEL_CONFIRM, LABEL_CANCEL, mpcStart, NULL, NULL); break; case KEY_ICON_7: @@ -224,10 +223,7 @@ void menuMPC(void) else if (mpcTuning.status == ONGOING) { if (getMenuType() != MENU_TYPE_SPLASH) - { - setDialogText(LABEL_SCREEN_INFO, LABEL_BUSY, LABEL_NULL, LABEL_NULL); - showDialog(DIALOG_TYPE_INFO, NULL, NULL, NULL); - } + popupSplash(DIALOG_TYPE_INFO, LABEL_SCREEN_INFO, LABEL_BUSY); if (mpcTuning.result != NO_RESULT) { @@ -246,9 +242,7 @@ void menuMPC(void) if (infoMachineSettings.EEPROM == 1) { sprintf(&tempMsg[strlen(tempMsg)], "\n %s", textSelect(LABEL_EEPROM_SAVE_INFO)); - - setDialogText(LABEL_MPC_TITLE, (uint8_t *) tempMsg, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_SUCCESS, saveEepromSettings, NULL, NULL); + popupDialog(DIALOG_TYPE_SUCCESS, LABEL_MPC_TITLE, (uint8_t *) tempMsg, LABEL_CONFIRM, LABEL_CANCEL, saveEepromSettings, NULL, NULL); } else { diff --git a/TFT/src/User/Menu/MachineSettings.c b/TFT/src/User/Menu/MachineSettings.c index da834246bf..fa2dffe68a 100644 --- a/TFT/src/User/Menu/MachineSettings.c +++ b/TFT/src/User/Menu/MachineSettings.c @@ -65,28 +65,22 @@ void menuEepromSettings(void) case KEY_ICON_0: // save to EEPROM if (infoMachineSettings.EEPROM == 1) - { - setDialogText(eepromSettingsItems.title.index, LABEL_EEPROM_SAVE_INFO, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_QUESTION, saveEepromSettings, NULL, NULL); - } + popupDialog(DIALOG_TYPE_QUESTION, eepromSettingsItems.title.index, LABEL_EEPROM_SAVE_INFO, + LABEL_CONFIRM, LABEL_CANCEL, saveEepromSettings, NULL, NULL); break; case KEY_ICON_1: // restore from EEPROM if (infoMachineSettings.EEPROM == 1) - { - setDialogText(eepromSettingsItems.title.index, LABEL_EEPROM_RESTORE_INFO, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_QUESTION, restoreEepromSettings, NULL, NULL); - } + popupDialog(DIALOG_TYPE_QUESTION, eepromSettingsItems.title.index, LABEL_EEPROM_RESTORE_INFO, + LABEL_CONFIRM, LABEL_CANCEL, restoreEepromSettings, NULL, NULL); break; case KEY_ICON_2: // reset EEPROM if (infoMachineSettings.EEPROM == 1) - { - setDialogText(eepromSettingsItems.title.index, LABEL_EEPROM_RESET_INFO, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_QUESTION, resetEepromSettings, NULL, NULL); - } + popupDialog(DIALOG_TYPE_QUESTION, eepromSettingsItems.title.index, LABEL_EEPROM_RESET_INFO, + LABEL_CONFIRM, LABEL_CANCEL, resetEepromSettings, NULL, NULL); break; case KEY_ICON_7: diff --git a/TFT/src/User/Menu/MeshEditor.c b/TFT/src/User/Menu/MeshEditor.c index 3472f3c5fc..22a3d525fe 100644 --- a/TFT/src/User/Menu/MeshEditor.c +++ b/TFT/src/User/Menu/MeshEditor.c @@ -709,10 +709,7 @@ void meshSave(bool saveOnChange) return; if (infoMachineSettings.EEPROM == 1) - { - setDialogText((uint8_t *) meshData->saveTitle, LABEL_EEPROM_SAVE_INFO, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_QUESTION, meshSaveCallback, NULL, NULL); - } + popupDialog(DIALOG_TYPE_QUESTION, (uint8_t *) meshData->saveTitle, LABEL_EEPROM_SAVE_INFO, LABEL_CONFIRM, LABEL_CANCEL, meshSaveCallback, NULL, NULL); } bool meshIsWaitingFirstData(void) diff --git a/TFT/src/User/Menu/More.c b/TFT/src/User/Menu/More.c index 00c58a4892..1d571021a5 100644 --- a/TFT/src/User/Menu/More.c +++ b/TFT/src/User/Menu/More.c @@ -55,8 +55,7 @@ void menuMore(void) case KEY_ICON_2: if (isPrinting() && !isPaused()) // need paused before extrude { - setDialogText(LABEL_WARNING, LABEL_IS_PAUSE, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_ALERT, isPauseExtrude, NULL, NULL); + popupDialog(DIALOG_TYPE_ALERT, LABEL_WARNING, LABEL_IS_PAUSE, LABEL_CONFIRM, LABEL_CANCEL, isPauseExtrude, NULL, NULL); } else { @@ -80,8 +79,7 @@ void menuMore(void) #ifdef LOAD_UNLOAD_M701_M702 if (isPrinting() && !isPaused()) // need paused before extrude { - setDialogText(LABEL_WARNING, LABEL_IS_PAUSE, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_ALERT, isPauseLoadUnload, NULL, NULL); + popupDialog(DIALOG_TYPE_ALERT, LABEL_WARNING, LABEL_IS_PAUSE, LABEL_CONFIRM, LABEL_CANCEL, isPauseLoadUnload, NULL, NULL); } else { diff --git a/TFT/src/User/Menu/ParameterSettings.c b/TFT/src/User/Menu/ParameterSettings.c index 786969c2e6..734877065a 100644 --- a/TFT/src/User/Menu/ParameterSettings.c +++ b/TFT/src/User/Menu/ParameterSettings.c @@ -266,8 +266,7 @@ void menuParameterSettings(void) case KEY_BACK: if (parametersChanged && infoMachineSettings.EEPROM == 1) { - setDialogText(title.index, LABEL_EEPROM_SAVE_INFO, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_QUESTION, saveEepromSettings, NULL, NULL); + popupDialog(DIALOG_TYPE_QUESTION, title.index, LABEL_EEPROM_SAVE_INFO, LABEL_CONFIRM, LABEL_CANCEL, saveEepromSettings, NULL, NULL); parametersChanged = false; } else @@ -296,21 +295,18 @@ void menuParameterSettings(void) uint8_t curIndex_e = (curIndex - enabledParameterCount); if (curIndex_e == P_SAVE_SETTINGS) { - setDialogText(title.index, LABEL_EEPROM_SAVE_INFO, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_ALERT, saveEepromSettings, NULL, NULL); + popupDialog(DIALOG_TYPE_ALERT, title.index, LABEL_EEPROM_SAVE_INFO, LABEL_CONFIRM, LABEL_CANCEL, saveEepromSettings, NULL, NULL); parametersChanged = false; break; } else if (curIndex_e == P_RESET_SETTINGS) { - setDialogText(LABEL_SETTINGS_RESET, LABEL_SETTINGS_RESET_INFO, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_ALERT, resetEepromSettings, NULL, NULL); + popupDialog(DIALOG_TYPE_ALERT, LABEL_SETTINGS_RESET, LABEL_SETTINGS_RESET_INFO, LABEL_CONFIRM, LABEL_CANCEL, resetEepromSettings, NULL, NULL); break; } else if (curIndex_e == P_RESTORE_SETTINGS) { - setDialogText(LABEL_SETTINGS_RESTORE, LABEL_EEPROM_RESTORE_INFO, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_ALERT, restoreEepromSettings, NULL, NULL); + popupDialog(DIALOG_TYPE_ALERT, LABEL_SETTINGS_RESTORE, LABEL_EEPROM_RESTORE_INFO, LABEL_CONFIRM, LABEL_CANCEL, restoreEepromSettings, NULL, NULL); break; } } diff --git a/TFT/src/User/Menu/Pid.c b/TFT/src/User/Menu/Pid.c index f8e8d70c56..0f7988917c 100644 --- a/TFT/src/User/Menu/Pid.c +++ b/TFT/src/User/Menu/Pid.c @@ -88,9 +88,7 @@ void pidResultAction(void) if (infoMachineSettings.EEPROM == 1) { sprintf(&tempMsg[strlen(tempMsg)], "\n %s", textSelect(LABEL_EEPROM_SAVE_INFO)); - - setDialogText(LABEL_PID_TITLE, (uint8_t *) tempMsg, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_SUCCESS, saveEepromSettings, NULL, NULL); + popupDialog(DIALOG_TYPE_SUCCESS, LABEL_PID_TITLE, (uint8_t *) tempMsg, LABEL_CONFIRM, LABEL_CANCEL, saveEepromSettings, NULL, NULL); } else { @@ -215,8 +213,7 @@ void menuPid(void) } else { - setDialogText(pidItems.title.index, LABEL_TUNE_START_INFO, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_QUESTION, pidStart, NULL, NULL); + popupDialog(DIALOG_TYPE_QUESTION, pidItems.title.index, LABEL_TUNE_START_INFO, LABEL_CONFIRM, LABEL_CANCEL, pidStart, NULL, NULL); } break; @@ -235,10 +232,7 @@ void menuPid(void) else { if (getMenuType() != MENU_TYPE_SPLASH) - { - setDialogText(LABEL_SCREEN_INFO, LABEL_BUSY, LABEL_NULL, LABEL_NULL); - showDialog(DIALOG_TYPE_INFO, NULL, NULL, NULL); - } + popupSplash(DIALOG_TYPE_INFO, LABEL_SCREEN_INFO, LABEL_BUSY); if (OS_GetTimeMs() > pidTimeout) pidUpdateStatus(PID_TIMEOUT); diff --git a/TFT/src/User/Menu/Popup.c b/TFT/src/User/Menu/Popup.c index 8da3c99c13..eb171fdb0a 100644 --- a/TFT/src/User/Menu/Popup.c +++ b/TFT/src/User/Menu/Popup.c @@ -62,10 +62,8 @@ void windowReDrawButton(uint8_t position, uint8_t pressed) void popupDrawPage(DIALOG_TYPE type, BUTTON * btn, const uint8_t * title, const uint8_t * context, const uint8_t * yes, const uint8_t * no) { - setMenuType(btn == NULL ? MENU_TYPE_SPLASH : MENU_TYPE_DIALOG); - - if (btn != NULL) // set the following global variables only if buttons must be provided. - { // Otherwise, leave these variables unchanged so current values are maintained + if (btn != NULL) + { buttonNum = 0; windowButton = btn; @@ -77,20 +75,22 @@ void popupDrawPage(DIALOG_TYPE type, BUTTON * btn, const uint8_t * title, const { windowButton[buttonNum++].context = no; } - } - TSC_ReDrawIcon = windowReDrawButton; - window.type = type; - - if (btn != NULL) // draw a window with buttons bar - { + // draw a window with buttons bar GUI_DrawWindow(&window, title, context, true); for (uint8_t i = 0; i < buttonNum; i++) GUI_DrawButton(&windowButton[i], 0); + + setMenuType(MENU_TYPE_DIALOG); } - else // draw a window with no buttons bar - { + else + { // draw a window with no buttons bar GUI_DrawWindow(&window, title, context, false); + + setMenuType(MENU_TYPE_SPLASH); } + + TSC_ReDrawIcon = windowReDrawButton; + window.type = type; } void menuDialog(void) @@ -190,9 +190,13 @@ void _setDialogCancelTextLabel(int16_t index) popup_strcpy(popup_cancel, tempstr, sizeof(popup_cancel)); } -/** Show save setting dialog. Set dialog text before calling showDialog - * @param ok_action - pointer to a function to perform if ok is pressed. (pass NULL if no action need to be performed) - * @param cancel_action - pointer to a function to perform if Cancel is pressed.(pass NULL if no action need to be performed) +/** + * @brief Show a popup with a message. Set dialog text before calling showDialog + * + * @param type the type of the dialog (alert, question, error, etc) + * @param ok_action pointer to a function to perform if ok is pressed. (pass NULL if no action need to be performed) + * @param cancel_action pointer to a function to perform if Cancel is pressed.(pass NULL if no action need to be performed) + * @param loop_action pointer to a function to perform whilst the dialog is active (visible/not answered) */ void showDialog(DIALOG_TYPE type, void (*ok_action)(), void (*cancel_action)(), void (*loop_action)()) { diff --git a/TFT/src/User/Menu/Popup.h b/TFT/src/User/Menu/Popup.h index 9cbd82fc33..e19550f969 100644 --- a/TFT/src/User/Menu/Popup.h +++ b/TFT/src/User/Menu/Popup.h @@ -57,12 +57,52 @@ void menuDialog(void); void showDialog(DIALOG_TYPE type, void (*ok_action)(), void (*cancel_action)(), void (*loop_action)()); void loopPopup(void); +/** + * @brief Displays a popup for a dialog, it needs user interaction to close it. + * + * @param type the type of the dialog (alert, question, error, etc) + * @param title title of the message box + * @param msg the body of the dialog + * @param oktext the text to be displayed on the "OK" button + * @param canceltext the text to be displayed on the "cancel" button + * @param ok_action the action to be taken if "OK" button is pressed + * @param cancel_action the action to be taken if "Cancel" button is pressed + * @param loop_action the action to be taken while the dialog is active (visible/not answered) + */ +#define popupDialog(_type, _title, _msg, _oktext, _canceltext, _ok_action, _cancel_action, _loop_action) \ + { \ + setDialogText(_title, _msg, _oktext, _canceltext); \ + showDialog(_type, _ok_action, _cancel_action, _loop_action); \ + } + + +/** + * @brief Displays a popup for a reminder, it needs user confirmation to close it. + * + * @param type the type of the reminder (info, alert, error, etc) + * @param title title of the message box + * @param msg the body of the message/reminder to be displayed + */ #define popupReminder(_type, _title, _msg) \ { \ setDialogText(_title, _msg, LABEL_CONFIRM, LABEL_NULL); \ showDialog(_type, NULL, NULL, NULL); \ } +/** + * @brief Displays a popup with a message, the user cannot close it. + * + * @param type the type of the message (info, alert, error, etc) + * @param title title of the message box + * @param msg the body of the message/reminder to be displayed + */ +#define popupSplash(_type, _title, _msg) \ + { \ + setDialogText(_title, _msg, LABEL_NULL, LABEL_NULL); \ + showDialog(_type, NULL, NULL, NULL); \ + } + + #ifdef __cplusplus } #endif diff --git a/TFT/src/User/Menu/Print.c b/TFT/src/User/Menu/Print.c index 7517aa8795..902dad433c 100644 --- a/TFT/src/User/Menu/Print.c +++ b/TFT/src/User/Menu/Print.c @@ -165,8 +165,7 @@ bool printPageItemSelected(uint16_t index) sprintf(temp_info, (char *)textSelect(LABEL_START_PRINT), (uint8_t *)(filename)); // display short or long filename // confirm file selction - setDialogText(LABEL_PRINT, (uint8_t *)temp_info, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_QUESTION, startPrint, exitFolder, NULL); + popupDialog(DIALOG_TYPE_QUESTION, LABEL_PRINT, (uint8_t *)temp_info, LABEL_CONFIRM, LABEL_CANCEL, startPrint, exitFolder, NULL); hasUpdate = false; } diff --git a/TFT/src/User/Menu/PrintingMenu.c b/TFT/src/User/Menu/PrintingMenu.c index 1cad050e29..2e9cf06926 100644 --- a/TFT/src/User/Menu/PrintingMenu.c +++ b/TFT/src/User/Menu/PrintingMenu.c @@ -724,9 +724,9 @@ void menuPrinting(void) } else { - setDialogText(LABEL_WARNING, LABEL_STOP_PRINT, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_ALERT, printAbort, NULL, NULL); + popupDialog(DIALOG_TYPE_ALERT, LABEL_WARNING, LABEL_STOP_PRINT, LABEL_CONFIRM, LABEL_CANCEL, printAbort, NULL, NULL); } + } else { // Back button diff --git a/TFT/src/User/Menu/Touchmi.c b/TFT/src/User/Menu/Touchmi.c index 05d9a9c751..9c1c333766 100644 --- a/TFT/src/User/Menu/Touchmi.c +++ b/TFT/src/User/Menu/Touchmi.c @@ -44,10 +44,7 @@ void menuTouchMi(void) mustStoreCmd("G28 X Y\n"); if (infoMachineSettings.EEPROM == 1) - { - setDialogText(touchmiItems.title.index, LABEL_EEPROM_SAVE_INFO, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_QUESTION, saveEepromSettings, NULL, NULL); - } + popupDialog(DIALOG_TYPE_QUESTION, touchmiItems.title.index, LABEL_EEPROM_SAVE_INFO, LABEL_CONFIRM, LABEL_CANCEL, saveEepromSettings, NULL, NULL); break; case KEY_ICON_3: diff --git a/TFT/src/User/Menu/TuneExtruder.c b/TFT/src/User/Menu/TuneExtruder.c index 5c48fbe36f..15633200ee 100644 --- a/TFT/src/User/Menu/TuneExtruder.c +++ b/TFT/src/User/Menu/TuneExtruder.c @@ -159,8 +159,7 @@ void menuTuneExtruder(void) case KEY_ICON_7: if (heatGetTargetTemp(tool_index) > 0) { - setDialogText(tuneExtruderItems.title.index, LABEL_TUNE_EXT_HEATOFF, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_QUESTION, turnHeaterOff, returnToTuning, NULL); + popupDialog(DIALOG_TYPE_QUESTION, tuneExtruderItems.title.index, LABEL_TUNE_EXT_HEATOFF, LABEL_CONFIRM, LABEL_CANCEL, turnHeaterOff, returnToTuning, NULL); } else { @@ -190,8 +189,7 @@ void menuTuneExtruder(void) LABELCHAR(tempStr, LABEL_TUNE_EXT_MARK120MM); sprintf(tempMsg, tempStr, textSelect(LABEL_EXTRUDE)); - setDialogText(tuneExtruderItems.title.index, (uint8_t *) tempMsg, LABEL_EXTRUDE, LABEL_CANCEL); - showDialog(DIALOG_TYPE_QUESTION, extrudeFilament, NULL, NULL); + popupDialog(DIALOG_TYPE_QUESTION, tuneExtruderItems.title.index, (uint8_t *) tempMsg, LABEL_EXTRUDE, LABEL_CANCEL, extrudeFilament, NULL, NULL); } loadRequested = false; break; diff --git a/TFT/src/User/Menu/UnifiedMove.c b/TFT/src/User/Menu/UnifiedMove.c index 5496c8fc65..f33068f1b2 100644 --- a/TFT/src/User/Menu/UnifiedMove.c +++ b/TFT/src/User/Menu/UnifiedMove.c @@ -72,8 +72,7 @@ void menuUnifiedMove(void) #if DELTA_PROBE_TYPE != 2 // if not removable probe deltaCalibration(); #else // if removable probe - setDialogText(LABEL_WARNING, LABEL_CONNECT_PROBE, LABEL_CONTINUE, LABEL_CANCEL); - showDialog(DIALOG_TYPE_ALERT, deltaCalibration, NULL, NULL); + popupDialog(DIALOG_TYPE_ALERT, LABEL_WARNING, LABEL_CONNECT_PROBE, LABEL_CONTINUE, LABEL_CANCEL, deltaCalibration, NULL, NULL); #endif #endif break; diff --git a/TFT/src/User/Menu/ZOffset.c b/TFT/src/User/Menu/ZOffset.c index 70d4e6ba88..f368a6cccc 100644 --- a/TFT/src/User/Menu/ZOffset.c +++ b/TFT/src/User/Menu/ZOffset.c @@ -211,10 +211,7 @@ void menuZOffset(void) // save to EEPROM case 2: if (infoMachineSettings.EEPROM == 1) - { - setDialogText(zOffsetItems.title.index, LABEL_EEPROM_SAVE_INFO, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_QUESTION, saveEepromSettings, NULL, NULL); - } + popupDialog(DIALOG_TYPE_QUESTION, zOffsetItems.title.index, LABEL_EEPROM_SAVE_INFO, LABEL_CONFIRM, LABEL_CANCEL, saveEepromSettings, NULL, NULL); break; // unlock XY axis diff --git a/TFT/src/User/Menu/common.c b/TFT/src/User/Menu/common.c index 0d85dc5426..76309d90f6 100644 --- a/TFT/src/User/Menu/common.c +++ b/TFT/src/User/Menu/common.c @@ -317,9 +317,7 @@ NOZZLE_STATUS warmupNozzle(uint8_t toolIndex, void (* callback)(void)) sprintf(tempStr, (char *)textSelect(LABEL_HEAT_HOTEND), infoSettings.min_ext_temp); strcat(tempMsg, "\n"); strcat(tempMsg, tempStr); - - setDialogText(LABEL_WARNING, (uint8_t *)tempMsg, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_ERROR, callback, NULL, NULL); + popupDialog(DIALOG_TYPE_ERROR, LABEL_WARNING, (uint8_t *)tempMsg, LABEL_CONFIRM, LABEL_CANCEL, callback, NULL, NULL); return COLD; } @@ -342,8 +340,7 @@ NOZZLE_STATUS warmupNozzle(uint8_t toolIndex, void (* callback)(void)) strcat(tempMsg, "\n"); strcat(tempMsg, tempStr); - setDialogText(LABEL_WARNING, (uint8_t *)tempMsg, LABEL_CONFIRM, LABEL_NULL); - showDialog(DIALOG_TYPE_ERROR, NULL, NULL, NULL); + popupReminder(DIALOG_TYPE_ERROR, LABEL_WARNING, (uint8_t *)tempMsg); return COLD; } } @@ -362,8 +359,7 @@ void cooldownTemperature(void) { if (heatGetTargetTemp(i) > 0) { - setDialogText(LABEL_WARNING, LABEL_HEATERS_ON, LABEL_CONFIRM, LABEL_CANCEL); - showDialog(DIALOG_TYPE_QUESTION, heatCoolDown, NULL, NULL); + popupDialog(DIALOG_TYPE_QUESTION, LABEL_WARNING, LABEL_HEATERS_ON, LABEL_CONFIRM, LABEL_CANCEL, heatCoolDown, NULL, NULL); break; } }