From e503621ef21f07256abbb72b68b9f60623d7f1bf Mon Sep 17 00:00:00 2001 From: yufanyufan Date: Fri, 17 Jul 2020 23:56:31 -0700 Subject: [PATCH 01/11] Fix write variable --- Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp | 4 ++++ Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp index b3325703dc21..1cef323926be 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp @@ -1180,6 +1180,10 @@ void DGUSDisplay::WriteVariable(uint16_t adr, const void* values, uint8_t values } } +void DGUSDisplay::WriteVariable(uint16_t adr, uint16_t value) { + WriteVariable(adr, static_cast(&value), sizeof(uint16_t)); +} + void DGUSDisplay::WriteVariablePGM(uint16_t adr, const void* values, uint8_t valueslen, bool isstr) { const char* myvalues = static_cast(values); bool strend = !myvalues; diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h index 9eddfcf3b5b8..fea33c73d4fb 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h @@ -54,10 +54,7 @@ class DGUSDisplay { // Variable access. static void WriteVariable(uint16_t adr, const void* values, uint8_t valueslen, bool isstr=false); static void WriteVariablePGM(uint16_t adr, const void* values, uint8_t valueslen, bool isstr=false); - template - static void WriteVariable(uint16_t adr, T value) { - WriteVariable(adr, static_cast(&value), sizeof(T)); - } + static void WriteVariable(uint16_t adr, uint16_t value); // Until now I did not need to actively read from the display. That's why there is no ReadVariable // (I extensively use the auto upload of the display) From 12cf2bff31cc3841a528456222b0dd268471e249 Mon Sep 17 00:00:00 2001 From: yufanyufan Date: Sat, 18 Jul 2020 00:06:50 -0700 Subject: [PATCH 02/11] Split DGUSDisplay and DGUSScreenVariableHandler --- Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp | 1134 +---------------- Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h | 217 ---- .../lib/dgus/DGUSScreenVariableHandler.cpp | 1110 ++++++++++++++++ .../lib/dgus/DGUSScreenVariableHandler.h | 224 ++++ .../extui/lib/dgus/fysetc/DGUSDisplayDef.cpp | 1 + .../extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp | 1 + .../extui/lib/dgus/origin/DGUSDisplayDef.cpp | 1 + Marlin/src/lcd/extui_dgus_lcd.cpp | 1 + 8 files changed, 1361 insertions(+), 1328 deletions(-) create mode 100644 Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.cpp create mode 100644 Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.h diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp index 1cef323926be..3cbee8d93e74 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp @@ -69,1085 +69,8 @@ constexpr uint8_t DGUS_CMD_READVAR = 0x83; static filament_data_t filament_data; #endif -uint16_t DGUSScreenVariableHandler::ConfirmVP; - -#if ENABLED(SDSUPPORT) - int16_t DGUSScreenVariableHandler::top_file = 0; - int16_t DGUSScreenVariableHandler::file_to_print = 0; - static ExtUI::FileList filelist; -#endif - -void (*DGUSScreenVariableHandler::confirm_action_cb)() = nullptr; - -//DGUSScreenVariableHandler ScreenHandler; - -DGUSLCD_Screens DGUSScreenVariableHandler::current_screen; -DGUSLCD_Screens DGUSScreenVariableHandler::past_screens[NUM_PAST_SCREENS]; -uint8_t DGUSScreenVariableHandler::update_ptr; -uint16_t DGUSScreenVariableHandler::skipVP; -bool DGUSScreenVariableHandler::ScreenComplete; - -//DGUSDisplay dgusdisplay; - -rx_datagram_state_t DGUSDisplay::rx_datagram_state = DGUS_IDLE; -uint8_t DGUSDisplay::rx_datagram_len = 0; -bool DGUSDisplay::Initialized = false; -bool DGUSDisplay::no_reentrance = false; - #define dgusserial DGUS_SERIAL -// endianness swap -uint16_t swap16(const uint16_t value) { return (value & 0xffU) << 8U | (value >> 8U); } - -bool populate_VPVar(const uint16_t VP, DGUS_VP_Variable * const ramcopy) { - // DEBUG_ECHOPAIR("populate_VPVar ", VP); - const DGUS_VP_Variable *pvp = DGUSLCD_FindVPVar(VP); - // DEBUG_ECHOLNPAIR(" pvp ", (uint16_t )pvp); - if (!pvp) return false; - memcpy_P(ramcopy, pvp, sizeof(DGUS_VP_Variable)); - return true; -} - -void DGUSScreenVariableHandler::sendinfoscreen(const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool l4inflash) { - DGUS_VP_Variable ramcopy; - if (populate_VPVar(VP_MSGSTR1, &ramcopy)) { - ramcopy.memadr = (void*) line1; - l1inflash ? DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplay(ramcopy); - } - if (populate_VPVar(VP_MSGSTR2, &ramcopy)) { - ramcopy.memadr = (void*) line2; - l2inflash ? DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplay(ramcopy); - } - if (populate_VPVar(VP_MSGSTR3, &ramcopy)) { - ramcopy.memadr = (void*) line3; - l3inflash ? DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplay(ramcopy); - } - if (populate_VPVar(VP_MSGSTR4, &ramcopy)) { - ramcopy.memadr = (void*) line4; - l4inflash ? DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplay(ramcopy); - } -} - -void DGUSScreenVariableHandler::HandleUserConfirmationPopUp(uint16_t VP, const char* line1, const char* line2, const char* line3, const char* line4, bool l1, bool l2, bool l3, bool l4) { - if (current_screen == DGUSLCD_SCREEN_CONFIRM) { - // Already showing a pop up, so we need to cancel that first. - PopToOldScreen(); - } - - ConfirmVP = VP; - sendinfoscreen(line1, line2, line3, line4, l1, l2, l3, l4); - ScreenHandler.GotoScreen(DGUSLCD_SCREEN_CONFIRM); -} - -void DGUSScreenVariableHandler::setstatusmessage(const char *msg) { - DGUS_VP_Variable ramcopy; - if (populate_VPVar(VP_M117, &ramcopy)) { - ramcopy.memadr = (void*) msg; - DGUSLCD_SendStringToDisplay(ramcopy); - } -} - -void DGUSScreenVariableHandler::setstatusmessagePGM(PGM_P const msg) { - DGUS_VP_Variable ramcopy; - if (populate_VPVar(VP_M117, &ramcopy)) { - ramcopy.memadr = (void*) msg; - DGUSLCD_SendStringToDisplayPGM(ramcopy); - } -} - -// Send an 8 bit or 16 bit value to the display. -void DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay(DGUS_VP_Variable &var) { - if (var.memadr) { - //DEBUG_ECHOPAIR(" DGUS_LCD_SendWordValueToDisplay ", var.VP); - //DEBUG_ECHOLNPAIR(" data ", *(uint16_t *)var.memadr); - uint8_t *tmp = (uint8_t *) var.memadr; - uint16_t data_to_send = (tmp[0] << 8); - if (var.size >= 1) data_to_send |= tmp[1]; - dgusdisplay.WriteVariable(var.VP, data_to_send); - } -} - -// Send an uint8_t between 0 and 255 to the display, but scale to a percentage (0..100) -void DGUSScreenVariableHandler::DGUSLCD_SendPercentageToDisplay(DGUS_VP_Variable &var) { - if (var.memadr) { - //DEBUG_ECHOPAIR(" DGUS_LCD_SendWordValueToDisplay ", var.VP); - //DEBUG_ECHOLNPAIR(" data ", *(uint16_t *)var.memadr); - uint16_t tmp = *(uint8_t *) var.memadr +1 ; // +1 -> avoid rounding issues for the display. - tmp = map(tmp, 0, 255, 0, 100); - uint16_t data_to_send = swap16(tmp); - dgusdisplay.WriteVariable(var.VP, data_to_send); - } -} - -// Send the current print progress to the display. -void DGUSScreenVariableHandler::DGUSLCD_SendPrintProgressToDisplay(DGUS_VP_Variable &var) { - //DEBUG_ECHOPAIR(" DGUSLCD_SendPrintProgressToDisplay ", var.VP); - uint16_t tmp = ExtUI::getProgress_percent(); - //DEBUG_ECHOLNPAIR(" data ", tmp); - uint16_t data_to_send = swap16(tmp); - dgusdisplay.WriteVariable(var.VP, data_to_send); -} - -// Send the current print time to the display. -// It is using a hex display for that: It expects BSD coded data in the format xxyyzz -void DGUSScreenVariableHandler::DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var) { - duration_t elapsed = print_job_timer.duration(); - char buf[32]; - elapsed.toString(buf); - dgusdisplay.WriteVariable(VP_PrintTime, buf, var.size, true); -} - -// Send an uint8_t between 0 and 100 to a variable scale to 0..255 -void DGUSScreenVariableHandler::DGUSLCD_PercentageToUint8(DGUS_VP_Variable &var, void *val_ptr) { - if (var.memadr) { - uint16_t value = swap16(*(uint16_t*)val_ptr); - *(uint8_t*)var.memadr = map(constrain(value, 0, 100), 0, 100, 0, 255); - } -} - -// Sends a (RAM located) string to the DGUS Display -// (Note: The DGUS Display does not clear after the \0, you have to -// overwrite the remainings with spaces.// var.size has the display buffer size! -void DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplay(DGUS_VP_Variable &var) { - char *tmp = (char*) var.memadr; - dgusdisplay.WriteVariable(var.VP, tmp, var.size, true); -} - -// Sends a (flash located) string to the DGUS Display -// (Note: The DGUS Display does not clear after the \0, you have to -// overwrite the remainings with spaces.// var.size has the display buffer size! -void DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var) { - char *tmp = (char*) var.memadr; - dgusdisplay.WriteVariablePGM(var.VP, tmp, var.size, true); -} - -#if HAS_PID_HEATING - void DGUSScreenVariableHandler::DGUSLCD_SendTemperaturePID(DGUS_VP_Variable &var) { - float value = *(float *)var.memadr; - float valuesend = 0; - switch (var.VP) { - default: return; - #if HOTENDS >= 1 - case VP_E0_PID_P: valuesend = value; break; - case VP_E0_PID_I: valuesend = unscalePID_i(value); break; - case VP_E0_PID_D: valuesend = unscalePID_d(value); break; - #endif - #if HOTENDS >= 2 - case VP_E1_PID_P: valuesend = value; break; - case VP_E1_PID_I: valuesend = unscalePID_i(value); break; - case VP_E1_PID_D: valuesend = unscalePID_d(value); break; - #endif - #if HAS_HEATED_BED - case VP_BED_PID_P: valuesend = value; break; - case VP_BED_PID_I: valuesend = unscalePID_i(value); break; - case VP_BED_PID_D: valuesend = unscalePID_d(value); break; - #endif - } - - valuesend *= cpow(10, 1); - union { int16_t i; char lb[2]; } endian; - - char tmp[2]; - endian.i = valuesend; - tmp[0] = endian.lb[1]; - tmp[1] = endian.lb[0]; - dgusdisplay.WriteVariable(var.VP, tmp, 2); - } -#endif - -#if ENABLED(PRINTCOUNTER) - - // Send the accumulate print time to the display. - // It is using a hex display for that: It expects BSD coded data in the format xxyyzz - void DGUSScreenVariableHandler::DGUSLCD_SendPrintAccTimeToDisplay(DGUS_VP_Variable &var) { - printStatistics state = print_job_timer.getStats(); - char buf[21]; - duration_t elapsed = state.printTime; - elapsed.toString(buf); - dgusdisplay.WriteVariable(VP_PrintAccTime, buf, var.size, true); - } - - void DGUSScreenVariableHandler::DGUSLCD_SendPrintsTotalToDisplay(DGUS_VP_Variable &var) { - printStatistics state = print_job_timer.getStats(); - char buf[21]; - sprintf_P(buf, PSTR("%u"), state.totalPrints); - dgusdisplay.WriteVariable(VP_PrintsTotal, buf, var.size, true); - } - -#endif - -// Send fan status value to the display. -#if HAS_FAN - void DGUSScreenVariableHandler::DGUSLCD_SendFanStatusToDisplay(DGUS_VP_Variable &var) { - if (var.memadr) { - DEBUG_ECHOPAIR(" DGUSLCD_SendFanStatusToDisplay ", var.VP); - DEBUG_ECHOLNPAIR(" data ", *(uint8_t *)var.memadr); - uint16_t data_to_send = 0; - if (*(uint8_t *) var.memadr) data_to_send = 1; - data_to_send = swap16(data_to_send); - dgusdisplay.WriteVariable(var.VP, data_to_send); - } - } -#endif - -// Send heater status value to the display. -void DGUSScreenVariableHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var) { - if (var.memadr) { - DEBUG_ECHOPAIR(" DGUSLCD_SendHeaterStatusToDisplay ", var.VP); - DEBUG_ECHOLNPAIR(" data ", *(int16_t *)var.memadr); - uint16_t data_to_send = 0; - if (*(int16_t *) var.memadr) data_to_send = 1; - data_to_send = swap16(data_to_send); - dgusdisplay.WriteVariable(var.VP, data_to_send); - } -} - -#if ENABLED(DGUS_UI_WAITING) - void DGUSScreenVariableHandler::DGUSLCD_SendWaitingStatusToDisplay(DGUS_VP_Variable &var) { - // In FYSETC UI design there are 10 statuses to loop - static uint16_t period = 0; - static uint16_t index = 0; - //DEBUG_ECHOPAIR(" DGUSLCD_SendWaitingStatusToDisplay ", var.VP); - //DEBUG_ECHOLNPAIR(" data ", swap16(index)); - if (period++ > DGUS_UI_WAITING_STATUS_PERIOD) { - dgusdisplay.WriteVariable(var.VP, swap16(index)); - //DEBUG_ECHOLNPAIR(" data ", swap16(index)); - if (++index >= DGUS_UI_WAITING_STATUS) index = 0; - period = 0; - } - } -#endif - -#if ENABLED(SDSUPPORT) - - void DGUSScreenVariableHandler::ScreenChangeHookIfSD(DGUS_VP_Variable &var, void *val_ptr) { - // default action executed when there is a SD card, but not printing - if (ExtUI::isMediaInserted() && !ExtUI::isPrintingFromMedia()) { - ScreenChangeHook(var, val_ptr); - dgusdisplay.RequestScreen(current_screen); - return; - } - - // if we are printing, we jump to two screens after the requested one. - // This should host e.g a print pause / print abort / print resume dialog. - // This concept allows to recycle this hook for other file - if (ExtUI::isPrintingFromMedia() && !card.flag.abort_sd_printing) { - GotoScreen(DGUSLCD_SCREEN_SDPRINTMANIPULATION); - return; - } - - // Don't let the user in the dark why there is no reaction. - if (!ExtUI::isMediaInserted()) { - setstatusmessagePGM(GET_TEXT(MSG_NO_MEDIA)); - return; - } - if (card.flag.abort_sd_printing) { - setstatusmessagePGM(GET_TEXT(MSG_MEDIA_ABORTING)); - return; - } - } - - void DGUSScreenVariableHandler::DGUSLCD_SD_ScrollFilelist(DGUS_VP_Variable& var, void *val_ptr) { - auto old_top = top_file; - const int16_t scroll = (int16_t)swap16(*(uint16_t*)val_ptr); - if (scroll) { - top_file += scroll; - DEBUG_ECHOPAIR("new topfile calculated:", top_file); - if (top_file < 0) { - top_file = 0; - DEBUG_ECHOLNPGM("Top of filelist reached"); - } - else { - int16_t max_top = filelist.count() - DGUS_SD_FILESPERSCREEN; - NOLESS(max_top, 0); - NOMORE(top_file, max_top); - } - DEBUG_ECHOPAIR("new topfile adjusted:", top_file); - } - else if (!filelist.isAtRootDir()) { - filelist.upDir(); - top_file = 0; - ForceCompleteUpdate(); - } - - if (old_top != top_file) ForceCompleteUpdate(); - } - - void DGUSScreenVariableHandler::DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr) { - uint16_t touched_nr = (int16_t)swap16(*(uint16_t*)val_ptr) + top_file; - if (touched_nr > filelist.count()) return; - if (!filelist.seek(touched_nr)) return; - if (filelist.isDir()) { - filelist.changeDir(filelist.filename()); - top_file = 0; - ForceCompleteUpdate(); - return; - } - - #if ENABLED(DGUS_PRINT_FILENAME) - // Send print filename - dgusdisplay.WriteVariable(VP_SD_Print_Filename, filelist.filename(), VP_SD_FileName_LEN, true); - #endif - - // Setup Confirmation screen - file_to_print = touched_nr; - HandleUserConfirmationPopUp(VP_SD_FileSelectConfirm, nullptr, PSTR("Print file"), filelist.filename(), PSTR("from SD Card?"), true, true, false, true); - } - - void DGUSScreenVariableHandler::DGUSLCD_SD_StartPrint(DGUS_VP_Variable &var, void *val_ptr) { - if (!filelist.seek(file_to_print)) return; - ExtUI::printFile(filelist.shortFilename()); - ScreenHandler.GotoScreen( - #if ENABLED(DGUS_LCD_UI_ORIGIN) - DGUSLCD_SCREEN_STATUS - #else - DGUSLCD_SCREEN_SDPRINTMANIPULATION - #endif - ); - } - - void DGUSScreenVariableHandler::DGUSLCD_SD_ResumePauseAbort(DGUS_VP_Variable &var, void *val_ptr) { - if (!ExtUI::isPrintingFromMedia()) return; // avoid race condition when user stays in this menu and printer finishes. - switch (swap16(*(uint16_t*)val_ptr)) { - case 0: // Resume - if (ExtUI::isPrintingFromMediaPaused()) ExtUI::resumePrint(); - break; - case 1: // Pause - if (!ExtUI::isPrintingFromMediaPaused()) ExtUI::pausePrint(); - break; - case 2: // Abort - ScreenHandler.HandleUserConfirmationPopUp(VP_SD_AbortPrintConfirmed, nullptr, PSTR("Abort printing"), filelist.filename(), PSTR("?"), true, true, false, true); - break; - } - } - - void DGUSScreenVariableHandler::DGUSLCD_SD_ReallyAbort(DGUS_VP_Variable &var, void *val_ptr) { - ExtUI::stopPrint(); - GotoScreen(DGUSLCD_SCREEN_MAIN); - } - - void DGUSScreenVariableHandler::DGUSLCD_SD_PrintTune(DGUS_VP_Variable &var, void *val_ptr) { - if (!ExtUI::isPrintingFromMedia()) return; // avoid race condition when user stays in this menu and printer finishes. - GotoScreen(DGUSLCD_SCREEN_SDPRINTTUNE); - } - - void DGUSScreenVariableHandler::DGUSLCD_SD_SendFilename(DGUS_VP_Variable& var) { - uint16_t target_line = (var.VP - VP_SD_FileName0) / VP_SD_FileName_LEN; - if (target_line > DGUS_SD_FILESPERSCREEN) return; - char tmpfilename[VP_SD_FileName_LEN + 1] = ""; - var.memadr = (void*)tmpfilename; - if (filelist.seek(top_file + target_line)) - snprintf_P(tmpfilename, VP_SD_FileName_LEN, PSTR("%s%c"), filelist.filename(), filelist.isDir() ? '/' : 0); - DGUSLCD_SendStringToDisplay(var); - } - - void DGUSScreenVariableHandler::SDCardInserted() { - top_file = 0; - filelist.refresh(); - auto cs = ScreenHandler.getCurrentScreen(); - if (cs == DGUSLCD_SCREEN_MAIN || cs == DGUSLCD_SCREEN_STATUS) - ScreenHandler.GotoScreen(DGUSLCD_SCREEN_SDFILELIST); - } - - void DGUSScreenVariableHandler::SDCardRemoved() { - if (current_screen == DGUSLCD_SCREEN_SDFILELIST - || (current_screen == DGUSLCD_SCREEN_CONFIRM && (ConfirmVP == VP_SD_AbortPrintConfirmed || ConfirmVP == VP_SD_FileSelectConfirm)) - || current_screen == DGUSLCD_SCREEN_SDPRINTMANIPULATION - ) ScreenHandler.GotoScreen(DGUSLCD_SCREEN_MAIN); - } - - void DGUSScreenVariableHandler::SDCardError() { - DGUSScreenVariableHandler::SDCardRemoved(); - ScreenHandler.sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("SD card error"), nullptr, true, true, true, true); - ScreenHandler.SetupConfirmAction(nullptr); - ScreenHandler.GotoScreen(DGUSLCD_SCREEN_POPUP); - } - -#endif // SDSUPPORT - -void DGUSScreenVariableHandler::ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr) { - DGUS_VP_Variable ramcopy; - if (!populate_VPVar(ConfirmVP, &ramcopy)) return; - if (ramcopy.set_by_display_handler) ramcopy.set_by_display_handler(ramcopy, val_ptr); -} - -const uint16_t* DGUSLCD_FindScreenVPMapList(uint8_t screen) { - const uint16_t *ret; - const struct VPMapping *map = VPMap; - while (ret = (uint16_t*) pgm_read_ptr(&(map->VPList))) { - if (pgm_read_byte(&(map->screen)) == screen) return ret; - map++; - } - return nullptr; -} - -const DGUS_VP_Variable* DGUSLCD_FindVPVar(const uint16_t vp) { - const DGUS_VP_Variable *ret = ListOfVP; - do { - const uint16_t vpcheck = pgm_read_word(&(ret->VP)); - if (vpcheck == 0) break; - if (vpcheck == vp) return ret; - ++ret; - } while (1); - - DEBUG_ECHOLNPAIR("FindVPVar NOT FOUND ", vp); - return nullptr; -} - -void DGUSScreenVariableHandler::ScreenChangeHookIfIdle(DGUS_VP_Variable &var, void *val_ptr) { - if (!ExtUI::isPrinting()) { - ScreenChangeHook(var, val_ptr); - dgusdisplay.RequestScreen(current_screen); - } -} - -void DGUSScreenVariableHandler::ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr) { - uint8_t *tmp = (uint8_t*)val_ptr; - - // The keycode in target is coded as , so 0x0100A means - // from screen 1 (main) to 10 (temperature). DGUSLCD_SCREEN_POPUP is special, - // meaning "return to previous screen" - DGUSLCD_Screens target = (DGUSLCD_Screens)tmp[1]; - - if (target == DGUSLCD_SCREEN_POPUP) { - // special handling for popup is to return to previous menu - if (current_screen == DGUSLCD_SCREEN_POPUP && confirm_action_cb) confirm_action_cb(); - PopToOldScreen(); - return; - } - - UpdateNewScreen(target); - - #ifdef DEBUG_DGUSLCD - if (!DGUSLCD_FindScreenVPMapList(target)) DEBUG_ECHOLNPAIR("WARNING: No screen Mapping found for ", target); - #endif -} - -void DGUSScreenVariableHandler::HandleAllHeatersOff(DGUS_VP_Variable &var, void *val_ptr) { - thermalManager.disable_all_heaters(); - ScreenHandler.ForceCompleteUpdate(); // hint to send all data. -} - -void DGUSScreenVariableHandler::HandleTemperatureChanged(DGUS_VP_Variable &var, void *val_ptr) { - uint16_t newvalue = swap16(*(uint16_t*)val_ptr); - uint16_t acceptedvalue; - - switch (var.VP) { - default: return; - #if HOTENDS >= 1 - case VP_T_E0_Set: - thermalManager.setTargetHotend(newvalue, 0); - acceptedvalue = thermalManager.temp_hotend[0].target; - break; - #endif - #if HOTENDS >= 2 - case VP_T_E1_Set: - thermalManager.setTargetHotend(newvalue, 1); - acceptedvalue = thermalManager.temp_hotend[1].target; - break; - #endif - #if HAS_HEATED_BED - case VP_T_Bed_Set: - thermalManager.setTargetBed(newvalue); - acceptedvalue = thermalManager.temp_bed.target; - break; - #endif - } - - // reply to display the new value to update the view if the new value was rejected by the Thermal Manager. - if (newvalue != acceptedvalue && var.send_to_display_handler) var.send_to_display_handler(var); - ScreenHandler.skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel -} - -void DGUSScreenVariableHandler::HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_ptr) { - #if EXTRUDERS - uint16_t newvalue = swap16(*(uint16_t*)val_ptr); - uint8_t target_extruder; - switch (var.VP) { - default: return; - #if HOTENDS >= 1 - case VP_Flowrate_E0: target_extruder = 0; break; - #endif - #if HOTENDS >= 2 - case VP_Flowrate_E1: target_extruder = 1; break; - #endif - } - - planner.set_flow(target_extruder, newvalue); - ScreenHandler.skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel - #else - UNUSED(var); UNUSED(val_ptr); - #endif -} - -void DGUSScreenVariableHandler::HandleManualExtrude(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleManualExtrude"); - - int16_t movevalue = swap16(*(uint16_t*)val_ptr); - float target = movevalue * 0.01f; - ExtUI::extruder_t target_extruder; - - switch (var.VP) { - #if HOTENDS >= 1 - case VP_MOVE_E0: target_extruder = ExtUI::extruder_t::E0; break; - #endif - #if HOTENDS >= 2 - case VP_MOVE_E1: target_extruder = ExtUI::extruder_t::E1; break; - #endif - default: return; - } - - target += ExtUI::getAxisPosition_mm(target_extruder); - ExtUI::setAxisPosition_mm(target, target_extruder); - skipVP = var.VP; -} - -#if ENABLED(DGUS_UI_MOVE_DIS_OPTION) - void DGUSScreenVariableHandler::HandleManualMoveOption(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleManualMoveOption"); - *(uint16_t*)var.memadr = swap16(*(uint16_t*)val_ptr); - } -#endif - -void DGUSScreenVariableHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleManualMove"); - - int16_t movevalue = swap16(*(uint16_t*)val_ptr); - #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) - if (movevalue) { - const uint16_t choice = *(uint16_t*)var.memadr; - movevalue = movevalue < 0 ? -choice : choice; - } - #endif - char axiscode; - unsigned int speed = 1500; //FIXME: get default feedrate for manual moves, dont hardcode. - - switch (var.VP) { - default: return; - - case VP_MOVE_X: - axiscode = 'X'; - if (!ExtUI::canMove(ExtUI::axis_t::X)) goto cannotmove; - break; - - case VP_MOVE_Y: - axiscode = 'Y'; - if (!ExtUI::canMove(ExtUI::axis_t::Y)) goto cannotmove; - break; - - case VP_MOVE_Z: - axiscode = 'Z'; - speed = 300; // default to 5mm/s - if (!ExtUI::canMove(ExtUI::axis_t::Z)) goto cannotmove; - break; - - case VP_HOME_ALL: // only used for homing - axiscode = '\0'; - movevalue = 0; // ignore value sent from display, this VP is _ONLY_ for homing. - break; - } - - if (!movevalue) { - // homing - DEBUG_ECHOPAIR(" homing ", axiscode); - char buf[6] = "G28 X"; - buf[4] = axiscode; - //DEBUG_ECHOPAIR(" ", buf); - queue.enqueue_one_now(buf); - //DEBUG_ECHOLNPGM(" ✓"); - ScreenHandler.ForceCompleteUpdate(); - return; - } - else { - //movement - DEBUG_ECHOPAIR(" move ", axiscode); - bool old_relative_mode = relative_mode; - if (!relative_mode) { - //DEBUG_ECHOPGM(" G91"); - queue.enqueue_now_P(PSTR("G91")); - //DEBUG_ECHOPGM(" ✓ "); - } - char buf[32]; // G1 X9999.99 F12345 - unsigned int backup_speed = MMS_TO_MMM(feedrate_mm_s); - char sign[]="\0"; - int16_t value = movevalue / 100; - if (movevalue < 0) { value = -value; sign[0] = '-'; } - int16_t fraction = ABS(movevalue) % 100; - snprintf_P(buf, 32, PSTR("G0 %c%s%d.%02d F%d"), axiscode, sign, value, fraction, speed); - //DEBUG_ECHOPAIR(" ", buf); - queue.enqueue_one_now(buf); - //DEBUG_ECHOLNPGM(" ✓ "); - if (backup_speed != speed) { - snprintf_P(buf, 32, PSTR("G0 F%d"), backup_speed); - queue.enqueue_one_now(buf); - //DEBUG_ECHOPAIR(" ", buf); - } - //while (!enqueue_and_echo_command(buf)) idle(); - //DEBUG_ECHOLNPGM(" ✓ "); - if (!old_relative_mode) { - //DEBUG_ECHOPGM("G90"); - queue.enqueue_now_P(PSTR("G90")); - //DEBUG_ECHOPGM(" ✓ "); - } - } - - ScreenHandler.ForceCompleteUpdate(); - DEBUG_ECHOLNPGM("manmv done."); - return; - - cannotmove: - DEBUG_ECHOLNPAIR(" cannot move ", axiscode); - return; -} - -void DGUSScreenVariableHandler::HandleMotorLockUnlock(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleMotorLockUnlock"); - - char buf[4]; - const int16_t lock = swap16(*(uint16_t*)val_ptr); - strcpy_P(buf, lock ? PSTR("M18") : PSTR("M17")); - - //DEBUG_ECHOPAIR(" ", buf); - queue.enqueue_one_now(buf); -} - -#if ENABLED(POWER_LOSS_RECOVERY) - - void DGUSScreenVariableHandler::HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr) { - uint16_t value = swap16(*(uint16_t*)val_ptr); - if (value) { - queue.inject_P(PSTR("M1000")); - ScreenHandler.GotoScreen(DGUSLCD_SCREEN_SDPRINTMANIPULATION); - } - else { - recovery.cancel(); - ScreenHandler.GotoScreen(DGUSLCD_SCREEN_STATUS); - } - } - -#endif - -void DGUSScreenVariableHandler::HandleSettings(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleSettings"); - uint16_t value = swap16(*(uint16_t*)val_ptr); - switch (value) { - default: break; - case 1: - TERN_(PRINTCOUNTER, print_job_timer.initStats()); - queue.inject_P(PSTR("M502\nM500")); - break; - case 2: queue.inject_P(PSTR("M501")); break; - case 3: queue.inject_P(PSTR("M500")); break; - } -} - -void DGUSScreenVariableHandler::HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleStepPerMMChanged"); - - uint16_t value_raw = swap16(*(uint16_t*)val_ptr); - DEBUG_ECHOLNPAIR("value_raw:", value_raw); - float value = (float)value_raw/10; - ExtUI::axis_t axis; - switch (var.VP) { - case VP_X_STEP_PER_MM: axis = ExtUI::axis_t::X; break; - case VP_Y_STEP_PER_MM: axis = ExtUI::axis_t::Y; break; - case VP_Z_STEP_PER_MM: axis = ExtUI::axis_t::Z; break; - default: return; - } - DEBUG_ECHOLNPAIR_F("value:", value); - ExtUI::setAxisSteps_per_mm(value, axis); - DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisSteps_per_mm(axis)); - ScreenHandler.skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel - return; -} - -void DGUSScreenVariableHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleStepPerMMExtruderChanged"); - - uint16_t value_raw = swap16(*(uint16_t*)val_ptr); - DEBUG_ECHOLNPAIR("value_raw:", value_raw); - float value = (float)value_raw/10; - ExtUI::extruder_t extruder; - switch (var.VP) { - default: return; - #if HOTENDS >= 1 - case VP_E0_STEP_PER_MM: extruder = ExtUI::extruder_t::E0; break; - #endif - #if HOTENDS >= 2 - case VP_E1_STEP_PER_MM: extruder = ExtUI::extruder_t::E1; break; - #endif - } - DEBUG_ECHOLNPAIR_F("value:", value); - ExtUI::setAxisSteps_per_mm(value,extruder); - DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisSteps_per_mm(extruder)); - ScreenHandler.skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel - return; -} - -#if HAS_PID_HEATING - void DGUSScreenVariableHandler::HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr) { - uint16_t rawvalue = swap16(*(uint16_t*)val_ptr); - DEBUG_ECHOLNPAIR("V1:", rawvalue); - float value = (float)rawvalue / 10; - DEBUG_ECHOLNPAIR("V2:", value); - float newvalue = 0; - - switch (var.VP) { - default: return; - #if HOTENDS >= 1 - case VP_E0_PID_P: newvalue = value; break; - case VP_E0_PID_I: newvalue = scalePID_i(value); break; - case VP_E0_PID_D: newvalue = scalePID_d(value); break; - #endif - #if HOTENDS >= 2 - case VP_E1_PID_P: newvalue = value; break; - case VP_E1_PID_I: newvalue = scalePID_i(value); break; - case VP_E1_PID_D: newvalue = scalePID_d(value); break; - #endif - #if HAS_HEATED_BED - case VP_BED_PID_P: newvalue = value; break; - case VP_BED_PID_I: newvalue = scalePID_i(value); break; - case VP_BED_PID_D: newvalue = scalePID_d(value); break; - #endif - } - - DEBUG_ECHOLNPAIR_F("V3:", newvalue); - *(float *)var.memadr = newvalue; - ScreenHandler.skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel - } - - void DGUSScreenVariableHandler::HandlePIDAutotune(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandlePIDAutotune"); - - char buf[32] = {0}; - - switch (var.VP) { - default: break; - #if ENABLED(PIDTEMP) - #if HOTENDS >= 1 - case VP_PID_AUTOTUNE_E0: // Autotune Extruder 0 - sprintf(buf, "M303 E%d C5 S210 U1", ExtUI::extruder_t::E0); - break; - #endif - #if HOTENDS >= 2 - case VP_PID_AUTOTUNE_E1: - sprintf(buf, "M303 E%d C5 S210 U1", ExtUI::extruder_t::E1); - break; - #endif - #endif - #if ENABLED(PIDTEMPBED) - case VP_PID_AUTOTUNE_BED: - sprintf(buf, "M303 E-1 C5 S70 U1"); - break; - #endif - } - - if (buf[0]) queue.enqueue_one_now(buf); - - #if ENABLED(DGUS_UI_WAITING) - sendinfoscreen(PSTR("PID is autotuning"), PSTR("please wait"), NUL_STR, NUL_STR, true, true, true, true); - GotoScreen(DGUSLCD_SCREEN_WAITING); - #endif - } -#endif - -#if HAS_BED_PROBE - void DGUSScreenVariableHandler::HandleProbeOffsetZChanged(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleProbeOffsetZChanged"); - - const float offset = float(int16_t(swap16(*(uint16_t*)val_ptr))) / 100.0f; - ExtUI::setZOffset_mm(offset); - ScreenHandler.skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel - return; - } -#endif - -#if ENABLED(BABYSTEPPING) - void DGUSScreenVariableHandler::HandleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleLiveAdjustZ"); - - int16_t flag = swap16(*(uint16_t*)val_ptr); - int16_t steps = flag ? -20 : 20; - ExtUI::smartAdjustAxis_steps(steps, ExtUI::axis_t::Z, true); - ScreenHandler.ForceCompleteUpdate(); - return; - } -#endif - -#if HAS_FAN - void DGUSScreenVariableHandler::HandleFanControl(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleFanControl"); - *(uint8_t*)var.memadr = *(uint8_t*)var.memadr > 0 ? 0 : 255; - } -#endif - -void DGUSScreenVariableHandler::HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleHeaterControl"); - - uint8_t preheat_temp = 0; - switch (var.VP) { - #if HOTENDS >= 1 - case VP_E0_CONTROL: - #endif - #if HOTENDS >= 2 - case VP_E1_CONTROL: - #endif - #if HOTENDS >= 3 - case VP_E2_CONTROL: - #endif - preheat_temp = PREHEAT_1_TEMP_HOTEND; - break; - - case VP_BED_CONTROL: - preheat_temp = PREHEAT_1_TEMP_BED; - break; - } - - *(int16_t*)var.memadr = *(int16_t*)var.memadr > 0 ? 0 : preheat_temp; -} - -#if ENABLED(DGUS_PREHEAT_UI) - - void DGUSScreenVariableHandler::HandlePreheat(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandlePreheat"); - - uint8_t e_temp = 0; - TERN_(HAS_HEATED_BED, uint8_t bed_temp = 0); - const uint16_t preheat_option = swap16(*(uint16_t*)val_ptr); - switch (preheat_option) { - default: - case 0: // Preheat PLA - #if defined(PREHEAT_1_TEMP_HOTEND) && defined(PREHEAT_1_TEMP_BED) - e_temp = PREHEAT_1_TEMP_HOTEND; - TERN_(HAS_HEATED_BED, bed_temp = PREHEAT_1_TEMP_BED); - #endif - break; - case 1: // Preheat ABS - #if defined(PREHEAT_2_TEMP_HOTEND) && defined(PREHEAT_2_TEMP_BED) - e_temp = PREHEAT_2_TEMP_HOTEND; - TERN_(HAS_HEATED_BED, bed_temp = PREHEAT_2_TEMP_BED); - #endif - break; - case 2: // Preheat PET - #if defined(PREHEAT_3_TEMP_HOTEND) && defined(PREHEAT_3_TEMP_BED) - e_temp = PREHEAT_3_TEMP_HOTEND; - TERN_(HAS_HEATED_BED, bed_temp = PREHEAT_3_TEMP_BED); - #endif - break; - case 3: // Preheat FLEX - #if defined(PREHEAT_4_TEMP_HOTEND) && defined(PREHEAT_4_TEMP_BED) - e_temp = PREHEAT_4_TEMP_HOTEND; - TERN_(HAS_HEATED_BED, bed_temp = PREHEAT_4_TEMP_BED); - #endif - break; - case 7: break; // Custom preheat - case 9: break; // Cool down - } - - switch (var.VP) { - default: return; - #if HOTENDS >= 1 - case VP_E0_BED_PREHEAT: - thermalManager.setTargetHotend(e_temp, 0); - TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(bed_temp)); - break; - #endif - #if HOTENDS >= 2 - case VP_E1_BED_PREHEAT: - thermalManager.setTargetHotend(e_temp, 1); - TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(bed_temp)); - break; - #endif - } - - // Go to the preheat screen to show the heating progress - GotoScreen(DGUSLCD_SCREEN_PREHEAT); - } - -#endif - -#if ENABLED(DGUS_FILAMENT_LOADUNLOAD) - void DGUSScreenVariableHandler::HandleFilamentOption(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleFilamentOption"); - - uint8_t e_temp = 0; - filament_data.heated = false; - uint16_t preheat_option = swap16(*(uint16_t*)val_ptr); - if (preheat_option <= 8) // Load filament type - filament_data.action = 1; - else if (preheat_option >= 10) { // Unload filament type - preheat_option -= 10; - filament_data.action = 2; - filament_data.purge_length = DGUS_FILAMENT_PURGE_LENGTH; - } - else // Cancel filament operation - filament_data.action = 0; - - switch (preheat_option) { - case 0: // Load PLA - #ifdef PREHEAT_1_TEMP_HOTEND - e_temp = PREHEAT_1_TEMP_HOTEND; - #endif - break; - case 1: // Load ABS - TERN_(PREHEAT_2_TEMP_HOTEND, e_temp = PREHEAT_2_TEMP_HOTEND); - break; - case 2: // Load PET - #ifdef PREHEAT_3_TEMP_HOTEND - e_temp = PREHEAT_3_TEMP_HOTEND; - #endif - break; - case 3: // Load FLEX - #ifdef PREHEAT_4_TEMP_HOTEND - e_temp = PREHEAT_4_TEMP_HOTEND; - #endif - break; - case 9: // Cool down - default: - e_temp = 0; - break; - } - - if (filament_data.action == 0) { // Go back to utility screen - #if HOTENDS >= 1 - thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E0); - #endif - #if HOTENDS >= 2 - thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E1); - #endif - GotoScreen(DGUSLCD_SCREEN_UTILITY); - } - else { // Go to the preheat screen to show the heating progress - switch (var.VP) { - default: return; - #if HOTENDS >= 1 - case VP_E0_FILAMENT_LOAD_UNLOAD: - filament_data.extruder = ExtUI::extruder_t::E0; - thermalManager.setTargetHotend(e_temp, filament_data.extruder); - break; - #endif - #if HOTENDS >= 2 - case VP_E1_FILAMENT_LOAD_UNLOAD: - filament_data.extruder = ExtUI::extruder_t::E1; - thermalManager.setTargetHotend(e_temp, filament_data.extruder); - break; - #endif - } - GotoScreen(DGUSLCD_SCREEN_FILAMENT_HEATING); - } - } - - void DGUSScreenVariableHandler::HandleFilamentLoadUnload(DGUS_VP_Variable &var) { - DEBUG_ECHOLNPGM("HandleFilamentLoadUnload"); - if (filament_data.action <= 0) return; - - // If we close to the target temperature, we can start load or unload the filament - if (thermalManager.hotEnoughToExtrude(filament_data.extruder) && \ - thermalManager.targetHotEnoughToExtrude(filament_data.extruder)) { - float movevalue = DGUS_FILAMENT_LOAD_LENGTH_PER_TIME; - - if (filament_data.action == 1) { // load filament - if (!filament_data.heated) { - GotoScreen(DGUSLCD_SCREEN_FILAMENT_LOADING); - filament_data.heated = true; - } - movevalue = ExtUI::getAxisPosition_mm(filament_data.extruder)+movevalue; - } - else { // unload filament - if (!filament_data.heated) { - GotoScreen(DGUSLCD_SCREEN_FILAMENT_UNLOADING); - filament_data.heated = true; - } - // Before unloading extrude to prevent jamming - if (filament_data.purge_length >= 0) { - movevalue = ExtUI::getAxisPosition_mm(filament_data.extruder) + movevalue; - filament_data.purge_length -= movevalue; - } - else - movevalue = ExtUI::getAxisPosition_mm(filament_data.extruder) - movevalue; - } - ExtUI::setAxisPosition_mm(movevalue, filament_data.extruder); - } - } -#endif - -void DGUSScreenVariableHandler::UpdateNewScreen(DGUSLCD_Screens newscreen, bool popup) { - DEBUG_ECHOLNPAIR("SetNewScreen: ", newscreen); - - if (!popup) { - memmove(&past_screens[1], &past_screens[0], sizeof(past_screens) - 1); - past_screens[0] = current_screen; - } - - current_screen = newscreen; - skipVP = 0; - ForceCompleteUpdate(); -} - -void DGUSScreenVariableHandler::PopToOldScreen() { - DEBUG_ECHOLNPAIR("PopToOldScreen s=", past_screens[0]); - GotoScreen(past_screens[0], true); - memmove(&past_screens[0], &past_screens[1], sizeof(past_screens) - 1); - past_screens[sizeof(past_screens) - 1] = DGUSLCD_SCREEN_MAIN; -} - -void DGUSScreenVariableHandler::UpdateScreenVPData() { - DEBUG_ECHOPAIR(" UpdateScreenVPData Screen: ", current_screen); - - const uint16_t *VPList = DGUSLCD_FindScreenVPMapList(current_screen); - if (!VPList) { - DEBUG_ECHOLNPAIR(" NO SCREEN FOR: ", current_screen); - ScreenComplete = true; - return; // nothing to do, likely a bug or boring screen. - } - - // Round-robin updating of all VPs. - VPList += update_ptr; - - bool sent_one = false; - do { - uint16_t VP = pgm_read_word(VPList); - DEBUG_ECHOPAIR(" VP: ", VP); - if (!VP) { - update_ptr = 0; - DEBUG_ECHOLNPGM(" UpdateScreenVPData done"); - ScreenComplete = true; - return; // Screen completed. - } - - if (VP == skipVP) { skipVP = 0; continue; } - - DGUS_VP_Variable rcpy; - if (populate_VPVar(VP, &rcpy)) { - uint8_t expected_tx = 6 + rcpy.size; // expected overhead is 6 bytes + payload. - // Send the VP to the display, but try to avoid overrunning the Tx Buffer. - // But send at least one VP, to avoid getting stalled. - if (rcpy.send_to_display_handler && (!sent_one || expected_tx <= dgusdisplay.GetFreeTxBuffer())) { - //DEBUG_ECHOPAIR(" calling handler for ", rcpy.VP); - sent_one = true; - rcpy.send_to_display_handler(rcpy); - } - else { - //auto x=dgusdisplay.GetFreeTxBuffer(); - //DEBUG_ECHOLNPAIR(" tx almost full: ", x); - //DEBUG_ECHOPAIR(" update_ptr ", update_ptr); - ScreenComplete = false; - return; // please call again! - } - } - - } while (++update_ptr, ++VPList, true); -} - -void DGUSDisplay::loop() { - // protect against recursion… ProcessRx() may indirectly call idle() when injecting gcode commands. - if (!no_reentrance) { - no_reentrance = true; - ProcessRx(); - no_reentrance = false; - } -} - void DGUSDisplay::InitDisplay() { dgusserial.begin(DGUS_BAUDRATE); @@ -1199,40 +122,6 @@ void DGUSDisplay::WriteVariablePGM(uint16_t adr, const void* values, uint8_t val } } -void DGUSScreenVariableHandler::GotoScreen(DGUSLCD_Screens screen, bool ispopup) { - dgusdisplay.RequestScreen(screen); - UpdateNewScreen(screen, ispopup); -} - -bool DGUSScreenVariableHandler::loop() { - dgusdisplay.loop(); - - const millis_t ms = millis(); - static millis_t next_event_ms = 0; - - if (!IsScreenComplete() || ELAPSED(ms, next_event_ms)) { - next_event_ms = ms + DGUS_UPDATE_INTERVAL_MS; - UpdateScreenVPData(); - } - - #if ENABLED(SHOW_BOOTSCREEN) - static bool booted = false; - if (!booted && TERN0(POWER_LOSS_RECOVERY, recovery.valid())) - booted = true; - if (!booted && ELAPSED(ms, BOOTSCREEN_TIMEOUT)) { - booted = true; - GotoScreen(DGUSLCD_SCREEN_MAIN); - } - #endif - return IsScreenComplete(); -} - -void DGUSDisplay::RequestScreen(DGUSLCD_Screens screen) { - DEBUG_ECHOLNPAIR("GotoScreen ", screen); - const unsigned char gotoscreen[] = { 0x5A, 0x01, (unsigned char) (screen >> 8U), (unsigned char) (screen & 0xFFU) }; - WriteVariable(0x84, gotoscreen, sizeof(gotoscreen)); -} - void DGUSDisplay::ProcessRx() { #if ENABLED(DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS) @@ -1340,7 +229,30 @@ void DGUSDisplay::WritePGM(const char str[], uint8_t len) { while (len--) dgusserial.write(pgm_read_byte(str++)); } +void DGUSDisplay::loop() { + // protect against recursion… ProcessRx() may indirectly call idle() when injecting gcode commands. + if (!no_reentrance) { + no_reentrance = true; + ProcessRx(); + no_reentrance = false; + } +} + +rx_datagram_state_t DGUSDisplay::rx_datagram_state = DGUS_IDLE; +uint8_t DGUSDisplay::rx_datagram_len = 0; +bool DGUSDisplay::Initialized = false; +bool DGUSDisplay::no_reentrance = false; + // A SW memory barrier, to ensure GCC does not overoptimize loops #define sw_barrier() asm volatile("": : :"memory"); +bool populate_VPVar(const uint16_t VP, DGUS_VP_Variable * const ramcopy) { + // DEBUG_ECHOPAIR("populate_VPVar ", VP); + const DGUS_VP_Variable *pvp = DGUSLCD_FindVPVar(VP); + // DEBUG_ECHOLNPAIR(" pvp ", (uint16_t )pvp); + if (!pvp) return false; + memcpy_P(ramcopy, pvp, sizeof(DGUS_VP_Variable)); + return true; +} + #endif // HAS_DGUS_LCD diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h index fea33c73d4fb..fd83451228dd 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h @@ -90,223 +90,6 @@ extern DGUSDisplay dgusdisplay; // compile-time x^y constexpr float cpow(const float x, const int y) { return y == 0 ? 1.0 : x * cpow(x, y - 1); } -class DGUSScreenVariableHandler { -public: - DGUSScreenVariableHandler() = default; - - static bool loop(); - - /// Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen - /// The bools specifing whether the strings are in RAM or FLASH. - static void sendinfoscreen(const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); - - static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); - - /// "M117" Message -- msg is a RAM ptr. - static void setstatusmessage(const char* msg); - /// The same for messages from Flash - static void setstatusmessagePGM(PGM_P const msg); - // Callback for VP "Display wants to change screen on idle printer" - static void ScreenChangeHookIfIdle(DGUS_VP_Variable &var, void *val_ptr); - // Callback for VP "Screen has been changed" - static void ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr); - // Callback for VP "All Heaters Off" - static void HandleAllHeatersOff(DGUS_VP_Variable &var, void *val_ptr); - // Hook for "Change this temperature" - static void HandleTemperatureChanged(DGUS_VP_Variable &var, void *val_ptr); - // Hook for "Change Flowrate" - static void HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_ptr); - #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) - // Hook for manual move option - static void HandleManualMoveOption(DGUS_VP_Variable &var, void *val_ptr); - #endif - // Hook for manual move. - static void HandleManualMove(DGUS_VP_Variable &var, void *val_ptr); - // Hook for manual extrude. - static void HandleManualExtrude(DGUS_VP_Variable &var, void *val_ptr); - // Hook for motor lock and unlook - static void HandleMotorLockUnlock(DGUS_VP_Variable &var, void *val_ptr); - #if ENABLED(POWER_LOSS_RECOVERY) - // Hook for power loss recovery. - static void HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr); - #endif - // Hook for settings - static void HandleSettings(DGUS_VP_Variable &var, void *val_ptr); - static void HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr); - static void HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr); - #if HAS_PID_HEATING - // Hook for "Change this temperature PID para" - static void HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr); - // Hook for PID autotune - static void HandlePIDAutotune(DGUS_VP_Variable &var, void *val_ptr); - #endif - #if HAS_BED_PROBE - // Hook for "Change probe offset z" - static void HandleProbeOffsetZChanged(DGUS_VP_Variable &var, void *val_ptr); - #endif - #if ENABLED(BABYSTEPPING) - // Hook for live z adjust action - static void HandleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr); - #endif - #if HAS_FAN - // Hook for fan control - static void HandleFanControl(DGUS_VP_Variable &var, void *val_ptr); - #endif - // Hook for heater control - static void HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr); - #if ENABLED(DGUS_PREHEAT_UI) - // Hook for preheat - static void HandlePreheat(DGUS_VP_Variable &var, void *val_ptr); - #endif - #if ENABLED(DGUS_FILAMENT_LOADUNLOAD) - // Hook for filament load and unload filament option - static void HandleFilamentOption(DGUS_VP_Variable &var, void *val_ptr); - // Hook for filament load and unload - static void HandleFilamentLoadUnload(DGUS_VP_Variable &var); - #endif - - #if ENABLED(SDSUPPORT) - // Callback for VP "Display wants to change screen when there is a SD card" - static void ScreenChangeHookIfSD(DGUS_VP_Variable &var, void *val_ptr); - /// Scroll buttons on the file listing screen. - static void DGUSLCD_SD_ScrollFilelist(DGUS_VP_Variable &var, void *val_ptr); - /// File touched. - static void DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr); - /// start print after confirmation received. - static void DGUSLCD_SD_StartPrint(DGUS_VP_Variable &var, void *val_ptr); - /// User hit the pause, resume or abort button. - static void DGUSLCD_SD_ResumePauseAbort(DGUS_VP_Variable &var, void *val_ptr); - /// User confirmed the abort action - static void DGUSLCD_SD_ReallyAbort(DGUS_VP_Variable &var, void *val_ptr); - /// User hit the tune button - static void DGUSLCD_SD_PrintTune(DGUS_VP_Variable &var, void *val_ptr); - /// Send a single filename to the display. - static void DGUSLCD_SD_SendFilename(DGUS_VP_Variable &var); - /// Marlin informed us that a new SD has been inserted. - static void SDCardInserted(); - /// Marlin informed us that the SD Card has been removed(). - static void SDCardRemoved(); - /// Marlin informed us about a bad SD Card. - static void SDCardError(); - #endif - - // OK Button the Confirm screen. - static void ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr); - - // Update data after went to new screen (by display or by GotoScreen) - // remember: store the last-displayed screen, so it can get returned to. - // (e.g for pop up messages) - static void UpdateNewScreen(DGUSLCD_Screens newscreen, bool popup=false); - - // Recall the remembered screen. - static void PopToOldScreen(); - - // Make the display show the screen and update all VPs in it. - static void GotoScreen(DGUSLCD_Screens screen, bool ispopup = false); - - static void UpdateScreenVPData(); - - // Helpers to convert and transfer data to the display. - static void DGUSLCD_SendWordValueToDisplay(DGUS_VP_Variable &var); - static void DGUSLCD_SendStringToDisplay(DGUS_VP_Variable &var); - static void DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var); - static void DGUSLCD_SendTemperaturePID(DGUS_VP_Variable &var); - static void DGUSLCD_SendPercentageToDisplay(DGUS_VP_Variable &var); - static void DGUSLCD_SendPrintProgressToDisplay(DGUS_VP_Variable &var); - static void DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var); - #if ENABLED(PRINTCOUNTER) - static void DGUSLCD_SendPrintAccTimeToDisplay(DGUS_VP_Variable &var); - static void DGUSLCD_SendPrintsTotalToDisplay(DGUS_VP_Variable &var); - #endif - #if HAS_FAN - static void DGUSLCD_SendFanStatusToDisplay(DGUS_VP_Variable &var); - #endif - static void DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var); - #if ENABLED(DGUS_UI_WAITING) - static void DGUSLCD_SendWaitingStatusToDisplay(DGUS_VP_Variable &var); - #endif - - /// Send a value from 0..100 to a variable with a range from 0..255 - static void DGUSLCD_PercentageToUint8(DGUS_VP_Variable &var, void *val_ptr); - - template - static void DGUSLCD_SetValueDirectly(DGUS_VP_Variable &var, void *val_ptr) { - if (!var.memadr) return; - union { unsigned char tmp[sizeof(T)]; T t; } x; - unsigned char *ptr = (unsigned char*)val_ptr; - LOOP_L_N(i, sizeof(T)) x.tmp[i] = ptr[sizeof(T) - i - 1]; - *(T*)var.memadr = x.t; - } - - /// Send a float value to the display. - /// Display will get a 4-byte integer scaled to the number of digits: - /// Tell the display the number of digits and it cheats by displaying a dot between... - template - static void DGUSLCD_SendFloatAsLongValueToDisplay(DGUS_VP_Variable &var) { - if (var.memadr) { - float f = *(float *)var.memadr; - f *= cpow(10, decimals); - union { long l; char lb[4]; } endian; - - char tmp[4]; - endian.l = f; - tmp[0] = endian.lb[3]; - tmp[1] = endian.lb[2]; - tmp[2] = endian.lb[1]; - tmp[3] = endian.lb[0]; - dgusdisplay.WriteVariable(var.VP, tmp, 4); - } - } - - /// Send a float value to the display. - /// Display will get a 2-byte integer scaled to the number of digits: - /// Tell the display the number of digits and it cheats by displaying a dot between... - template - static void DGUSLCD_SendFloatAsIntValueToDisplay(DGUS_VP_Variable &var) { - if (var.memadr) { - float f = *(float *)var.memadr; - DEBUG_ECHOLNPAIR_F(" >> ", f, 6); - f *= cpow(10, decimals); - union { int16_t i; char lb[2]; } endian; - - char tmp[2]; - endian.i = f; - tmp[0] = endian.lb[1]; - tmp[1] = endian.lb[0]; - dgusdisplay.WriteVariable(var.VP, tmp, 2); - } - } - - /// Force an update of all VP on the current screen. - static inline void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; } - /// Has all VPs sent to the screen - static inline bool IsScreenComplete() { return ScreenComplete; } - - static inline DGUSLCD_Screens getCurrentScreen() { return current_screen; } - - static inline void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; } - -private: - static DGUSLCD_Screens current_screen; ///< currently on screen - static constexpr uint8_t NUM_PAST_SCREENS = 4; - static DGUSLCD_Screens past_screens[NUM_PAST_SCREENS]; ///< LIFO with past screens for the "back" button. - - static uint8_t update_ptr; ///< Last sent entry in the VPList for the actual screen. - static uint16_t skipVP; ///< When updating the screen data, skip this one, because the user is interacting with it. - static bool ScreenComplete; ///< All VPs sent to screen? - - static uint16_t ConfirmVP; ///< context for confirm screen (VP that will be emulated-sent on "OK"). - - #if ENABLED(SDSUPPORT) - static int16_t top_file; ///< file on top of file chooser - static int16_t file_to_print; ///< touched file to be confirmed - #endif - - static void (*confirm_action_cb)(); -}; - -extern DGUSScreenVariableHandler ScreenHandler; - /// Find the flash address of a DGUS_VP_Variable for the VP. extern const DGUS_VP_Variable* DGUSLCD_FindVPVar(const uint16_t vp); diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.cpp new file mode 100644 index 000000000000..338032aba494 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.cpp @@ -0,0 +1,1110 @@ +#include "../../ui_api.h" + +#include "../../../../MarlinCore.h" +#include "../../../../module/temperature.h" +#include "../../../../module/motion.h" +#include "../../../../gcode/queue.h" +#include "../../../../module/planner.h" +#include "../../../../sd/cardreader.h" +#include "../../../../libs/duration_t.h" +#include "../../../../module/printcounter.h" +#if ENABLED(POWER_LOSS_RECOVERY) + #include "../../../../feature/powerloss.h" +#endif + +#include "DGUSDisplay.h" +#include "DGUSVPVariable.h" +#include "DGUSDisplayDef.h" +#include "DGUSScreenVariableHandler.h" + +uint16_t DGUSScreenVariableHandler::ConfirmVP; + +#if ENABLED(SDSUPPORT) + int16_t DGUSScreenVariableHandler::top_file = 0; + int16_t DGUSScreenVariableHandler::file_to_print = 0; + static ExtUI::FileList filelist; +#endif + +void (*DGUSScreenVariableHandler::confirm_action_cb)() = nullptr; + +//DGUSScreenVariableHandler ScreenHandler; + +DGUSLCD_Screens DGUSScreenVariableHandler::current_screen; +DGUSLCD_Screens DGUSScreenVariableHandler::past_screens[NUM_PAST_SCREENS]; +uint8_t DGUSScreenVariableHandler::update_ptr; +uint16_t DGUSScreenVariableHandler::skipVP; +bool DGUSScreenVariableHandler::ScreenComplete; + +//DGUSDisplay dgusdisplay; + + + +// endianness swap +uint16_t swap16(const uint16_t value) { return (value & 0xffU) << 8U | (value >> 8U); } + +void DGUSScreenVariableHandler::sendinfoscreen(const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool l4inflash) { + DGUS_VP_Variable ramcopy; + if (populate_VPVar(VP_MSGSTR1, &ramcopy)) { + ramcopy.memadr = (void*) line1; + l1inflash ? DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplay(ramcopy); + } + if (populate_VPVar(VP_MSGSTR2, &ramcopy)) { + ramcopy.memadr = (void*) line2; + l2inflash ? DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplay(ramcopy); + } + if (populate_VPVar(VP_MSGSTR3, &ramcopy)) { + ramcopy.memadr = (void*) line3; + l3inflash ? DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplay(ramcopy); + } + if (populate_VPVar(VP_MSGSTR4, &ramcopy)) { + ramcopy.memadr = (void*) line4; + l4inflash ? DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplay(ramcopy); + } +} + +void DGUSScreenVariableHandler::HandleUserConfirmationPopUp(uint16_t VP, const char* line1, const char* line2, const char* line3, const char* line4, bool l1, bool l2, bool l3, bool l4) { + if (current_screen == DGUSLCD_SCREEN_CONFIRM) { + // Already showing a pop up, so we need to cancel that first. + PopToOldScreen(); + } + + ConfirmVP = VP; + sendinfoscreen(line1, line2, line3, line4, l1, l2, l3, l4); + ScreenHandler.GotoScreen(DGUSLCD_SCREEN_CONFIRM); +} + +void DGUSScreenVariableHandler::setstatusmessage(const char *msg) { + DGUS_VP_Variable ramcopy; + if (populate_VPVar(VP_M117, &ramcopy)) { + ramcopy.memadr = (void*) msg; + DGUSLCD_SendStringToDisplay(ramcopy); + } +} + +void DGUSScreenVariableHandler::setstatusmessagePGM(PGM_P const msg) { + DGUS_VP_Variable ramcopy; + if (populate_VPVar(VP_M117, &ramcopy)) { + ramcopy.memadr = (void*) msg; + DGUSLCD_SendStringToDisplayPGM(ramcopy); + } +} + +// Send an 8 bit or 16 bit value to the display. +void DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay(DGUS_VP_Variable &var) { + if (var.memadr) { + //DEBUG_ECHOPAIR(" DGUS_LCD_SendWordValueToDisplay ", var.VP); + //DEBUG_ECHOLNPAIR(" data ", *(uint16_t *)var.memadr); + uint8_t *tmp = (uint8_t *) var.memadr; + uint16_t data_to_send = (tmp[0] << 8); + if (var.size >= 1) data_to_send |= tmp[1]; + dgusdisplay.WriteVariable(var.VP, data_to_send); + } +} + +// Send an uint8_t between 0 and 255 to the display, but scale to a percentage (0..100) +void DGUSScreenVariableHandler::DGUSLCD_SendPercentageToDisplay(DGUS_VP_Variable &var) { + if (var.memadr) { + //DEBUG_ECHOPAIR(" DGUS_LCD_SendWordValueToDisplay ", var.VP); + //DEBUG_ECHOLNPAIR(" data ", *(uint16_t *)var.memadr); + uint16_t tmp = *(uint8_t *) var.memadr +1 ; // +1 -> avoid rounding issues for the display. + tmp = map(tmp, 0, 255, 0, 100); + uint16_t data_to_send = swap16(tmp); + dgusdisplay.WriteVariable(var.VP, data_to_send); + } +} + +// Send the current print progress to the display. +void DGUSScreenVariableHandler::DGUSLCD_SendPrintProgressToDisplay(DGUS_VP_Variable &var) { + //DEBUG_ECHOPAIR(" DGUSLCD_SendPrintProgressToDisplay ", var.VP); + uint16_t tmp = ExtUI::getProgress_percent(); + //DEBUG_ECHOLNPAIR(" data ", tmp); + uint16_t data_to_send = swap16(tmp); + dgusdisplay.WriteVariable(var.VP, data_to_send); +} + +// Send the current print time to the display. +// It is using a hex display for that: It expects BSD coded data in the format xxyyzz +void DGUSScreenVariableHandler::DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var) { + duration_t elapsed = print_job_timer.duration(); + char buf[32]; + elapsed.toString(buf); + dgusdisplay.WriteVariable(VP_PrintTime, buf, var.size, true); +} + +// Send an uint8_t between 0 and 100 to a variable scale to 0..255 +void DGUSScreenVariableHandler::DGUSLCD_PercentageToUint8(DGUS_VP_Variable &var, void *val_ptr) { + if (var.memadr) { + uint16_t value = swap16(*(uint16_t*)val_ptr); + *(uint8_t*)var.memadr = map(constrain(value, 0, 100), 0, 100, 0, 255); + } +} + +// Sends a (RAM located) string to the DGUS Display +// (Note: The DGUS Display does not clear after the \0, you have to +// overwrite the remainings with spaces.// var.size has the display buffer size! +void DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplay(DGUS_VP_Variable &var) { + char *tmp = (char*) var.memadr; + dgusdisplay.WriteVariable(var.VP, tmp, var.size, true); +} + +// Sends a (flash located) string to the DGUS Display +// (Note: The DGUS Display does not clear after the \0, you have to +// overwrite the remainings with spaces.// var.size has the display buffer size! +void DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var) { + char *tmp = (char*) var.memadr; + dgusdisplay.WriteVariablePGM(var.VP, tmp, var.size, true); +} + +#if HAS_PID_HEATING + void DGUSScreenVariableHandler::DGUSLCD_SendTemperaturePID(DGUS_VP_Variable &var) { + float value = *(float *)var.memadr; + float valuesend = 0; + switch (var.VP) { + default: return; + #if HOTENDS >= 1 + case VP_E0_PID_P: valuesend = value; break; + case VP_E0_PID_I: valuesend = unscalePID_i(value); break; + case VP_E0_PID_D: valuesend = unscalePID_d(value); break; + #endif + #if HOTENDS >= 2 + case VP_E1_PID_P: valuesend = value; break; + case VP_E1_PID_I: valuesend = unscalePID_i(value); break; + case VP_E1_PID_D: valuesend = unscalePID_d(value); break; + #endif + #if HAS_HEATED_BED + case VP_BED_PID_P: valuesend = value; break; + case VP_BED_PID_I: valuesend = unscalePID_i(value); break; + case VP_BED_PID_D: valuesend = unscalePID_d(value); break; + #endif + } + + valuesend *= cpow(10, 1); + union { int16_t i; char lb[2]; } endian; + + char tmp[2]; + endian.i = valuesend; + tmp[0] = endian.lb[1]; + tmp[1] = endian.lb[0]; + dgusdisplay.WriteVariable(var.VP, tmp, 2); + } +#endif + +#if ENABLED(PRINTCOUNTER) + + // Send the accumulate print time to the display. + // It is using a hex display for that: It expects BSD coded data in the format xxyyzz + void DGUSScreenVariableHandler::DGUSLCD_SendPrintAccTimeToDisplay(DGUS_VP_Variable &var) { + printStatistics state = print_job_timer.getStats(); + char buf[21]; + duration_t elapsed = state.printTime; + elapsed.toString(buf); + dgusdisplay.WriteVariable(VP_PrintAccTime, buf, var.size, true); + } + + void DGUSScreenVariableHandler::DGUSLCD_SendPrintsTotalToDisplay(DGUS_VP_Variable &var) { + printStatistics state = print_job_timer.getStats(); + char buf[21]; + sprintf_P(buf, PSTR("%u"), state.totalPrints); + dgusdisplay.WriteVariable(VP_PrintsTotal, buf, var.size, true); + } + +#endif + +// Send fan status value to the display. +#if HAS_FAN + void DGUSScreenVariableHandler::DGUSLCD_SendFanStatusToDisplay(DGUS_VP_Variable &var) { + if (var.memadr) { + DEBUG_ECHOPAIR(" DGUSLCD_SendFanStatusToDisplay ", var.VP); + DEBUG_ECHOLNPAIR(" data ", *(uint8_t *)var.memadr); + uint16_t data_to_send = 0; + if (*(uint8_t *) var.memadr) data_to_send = 1; + data_to_send = swap16(data_to_send); + dgusdisplay.WriteVariable(var.VP, data_to_send); + } + } +#endif + +// Send heater status value to the display. +void DGUSScreenVariableHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var) { + if (var.memadr) { + DEBUG_ECHOPAIR(" DGUSLCD_SendHeaterStatusToDisplay ", var.VP); + DEBUG_ECHOLNPAIR(" data ", *(int16_t *)var.memadr); + uint16_t data_to_send = 0; + if (*(int16_t *) var.memadr) data_to_send = 1; + data_to_send = swap16(data_to_send); + dgusdisplay.WriteVariable(var.VP, data_to_send); + } +} + +#if ENABLED(DGUS_UI_WAITING) + void DGUSScreenVariableHandler::DGUSLCD_SendWaitingStatusToDisplay(DGUS_VP_Variable &var) { + // In FYSETC UI design there are 10 statuses to loop + static uint16_t period = 0; + static uint16_t index = 0; + //DEBUG_ECHOPAIR(" DGUSLCD_SendWaitingStatusToDisplay ", var.VP); + //DEBUG_ECHOLNPAIR(" data ", swap16(index)); + if (period++ > DGUS_UI_WAITING_STATUS_PERIOD) { + dgusdisplay.WriteVariable(var.VP, swap16(index)); + //DEBUG_ECHOLNPAIR(" data ", swap16(index)); + if (++index >= DGUS_UI_WAITING_STATUS) index = 0; + period = 0; + } + } +#endif + +#if ENABLED(SDSUPPORT) + + void DGUSScreenVariableHandler::ScreenChangeHookIfSD(DGUS_VP_Variable &var, void *val_ptr) { + // default action executed when there is a SD card, but not printing + if (ExtUI::isMediaInserted() && !ExtUI::isPrintingFromMedia()) { + ScreenChangeHook(var, val_ptr); + dgusdisplay.RequestScreen(current_screen); + return; + } + + // if we are printing, we jump to two screens after the requested one. + // This should host e.g a print pause / print abort / print resume dialog. + // This concept allows to recycle this hook for other file + if (ExtUI::isPrintingFromMedia() && !card.flag.abort_sd_printing) { + GotoScreen(DGUSLCD_SCREEN_SDPRINTMANIPULATION); + return; + } + + // Don't let the user in the dark why there is no reaction. + if (!ExtUI::isMediaInserted()) { + setstatusmessagePGM(GET_TEXT(MSG_NO_MEDIA)); + return; + } + if (card.flag.abort_sd_printing) { + setstatusmessagePGM(GET_TEXT(MSG_MEDIA_ABORTING)); + return; + } + } + + void DGUSScreenVariableHandler::DGUSLCD_SD_ScrollFilelist(DGUS_VP_Variable& var, void *val_ptr) { + auto old_top = top_file; + const int16_t scroll = (int16_t)swap16(*(uint16_t*)val_ptr); + if (scroll) { + top_file += scroll; + DEBUG_ECHOPAIR("new topfile calculated:", top_file); + if (top_file < 0) { + top_file = 0; + DEBUG_ECHOLNPGM("Top of filelist reached"); + } + else { + int16_t max_top = filelist.count() - DGUS_SD_FILESPERSCREEN; + NOLESS(max_top, 0); + NOMORE(top_file, max_top); + } + DEBUG_ECHOPAIR("new topfile adjusted:", top_file); + } + else if (!filelist.isAtRootDir()) { + filelist.upDir(); + top_file = 0; + ForceCompleteUpdate(); + } + + if (old_top != top_file) ForceCompleteUpdate(); + } + + void DGUSScreenVariableHandler::DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr) { + uint16_t touched_nr = (int16_t)swap16(*(uint16_t*)val_ptr) + top_file; + if (touched_nr > filelist.count()) return; + if (!filelist.seek(touched_nr)) return; + if (filelist.isDir()) { + filelist.changeDir(filelist.filename()); + top_file = 0; + ForceCompleteUpdate(); + return; + } + + #if ENABLED(DGUS_PRINT_FILENAME) + // Send print filename + dgusdisplay.WriteVariable(VP_SD_Print_Filename, filelist.filename(), VP_SD_FileName_LEN, true); + #endif + + // Setup Confirmation screen + file_to_print = touched_nr; + HandleUserConfirmationPopUp(VP_SD_FileSelectConfirm, nullptr, PSTR("Print file"), filelist.filename(), PSTR("from SD Card?"), true, true, false, true); + } + + void DGUSScreenVariableHandler::DGUSLCD_SD_StartPrint(DGUS_VP_Variable &var, void *val_ptr) { + if (!filelist.seek(file_to_print)) return; + ExtUI::printFile(filelist.shortFilename()); + ScreenHandler.GotoScreen( + #if ENABLED(DGUS_LCD_UI_ORIGIN) + DGUSLCD_SCREEN_STATUS + #else + DGUSLCD_SCREEN_SDPRINTMANIPULATION + #endif + ); + } + + void DGUSScreenVariableHandler::DGUSLCD_SD_ResumePauseAbort(DGUS_VP_Variable &var, void *val_ptr) { + if (!ExtUI::isPrintingFromMedia()) return; // avoid race condition when user stays in this menu and printer finishes. + switch (swap16(*(uint16_t*)val_ptr)) { + case 0: // Resume + if (ExtUI::isPrintingFromMediaPaused()) ExtUI::resumePrint(); + break; + case 1: // Pause + if (!ExtUI::isPrintingFromMediaPaused()) ExtUI::pausePrint(); + break; + case 2: // Abort + ScreenHandler.HandleUserConfirmationPopUp(VP_SD_AbortPrintConfirmed, nullptr, PSTR("Abort printing"), filelist.filename(), PSTR("?"), true, true, false, true); + break; + } + } + + void DGUSScreenVariableHandler::DGUSLCD_SD_ReallyAbort(DGUS_VP_Variable &var, void *val_ptr) { + ExtUI::stopPrint(); + GotoScreen(DGUSLCD_SCREEN_MAIN); + } + + void DGUSScreenVariableHandler::DGUSLCD_SD_PrintTune(DGUS_VP_Variable &var, void *val_ptr) { + if (!ExtUI::isPrintingFromMedia()) return; // avoid race condition when user stays in this menu and printer finishes. + GotoScreen(DGUSLCD_SCREEN_SDPRINTTUNE); + } + + void DGUSScreenVariableHandler::DGUSLCD_SD_SendFilename(DGUS_VP_Variable& var) { + uint16_t target_line = (var.VP - VP_SD_FileName0) / VP_SD_FileName_LEN; + if (target_line > DGUS_SD_FILESPERSCREEN) return; + char tmpfilename[VP_SD_FileName_LEN + 1] = ""; + var.memadr = (void*)tmpfilename; + if (filelist.seek(top_file + target_line)) + snprintf_P(tmpfilename, VP_SD_FileName_LEN, PSTR("%s%c"), filelist.filename(), filelist.isDir() ? '/' : 0); + DGUSLCD_SendStringToDisplay(var); + } + + void DGUSScreenVariableHandler::SDCardInserted() { + top_file = 0; + filelist.refresh(); + auto cs = ScreenHandler.getCurrentScreen(); + if (cs == DGUSLCD_SCREEN_MAIN || cs == DGUSLCD_SCREEN_STATUS) + ScreenHandler.GotoScreen(DGUSLCD_SCREEN_SDFILELIST); + } + + void DGUSScreenVariableHandler::SDCardRemoved() { + if (current_screen == DGUSLCD_SCREEN_SDFILELIST + || (current_screen == DGUSLCD_SCREEN_CONFIRM && (ConfirmVP == VP_SD_AbortPrintConfirmed || ConfirmVP == VP_SD_FileSelectConfirm)) + || current_screen == DGUSLCD_SCREEN_SDPRINTMANIPULATION + ) ScreenHandler.GotoScreen(DGUSLCD_SCREEN_MAIN); + } + + void DGUSScreenVariableHandler::SDCardError() { + DGUSScreenVariableHandler::SDCardRemoved(); + ScreenHandler.sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("SD card error"), nullptr, true, true, true, true); + ScreenHandler.SetupConfirmAction(nullptr); + ScreenHandler.GotoScreen(DGUSLCD_SCREEN_POPUP); + } + +#endif // SDSUPPORT + +void DGUSScreenVariableHandler::ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr) { + DGUS_VP_Variable ramcopy; + if (!populate_VPVar(ConfirmVP, &ramcopy)) return; + if (ramcopy.set_by_display_handler) ramcopy.set_by_display_handler(ramcopy, val_ptr); +} + +const uint16_t* DGUSLCD_FindScreenVPMapList(uint8_t screen) { + const uint16_t *ret; + const struct VPMapping *map = VPMap; + while (ret = (uint16_t*) pgm_read_ptr(&(map->VPList))) { + if (pgm_read_byte(&(map->screen)) == screen) return ret; + map++; + } + return nullptr; +} + +const DGUS_VP_Variable* DGUSLCD_FindVPVar(const uint16_t vp) { + const DGUS_VP_Variable *ret = ListOfVP; + do { + const uint16_t vpcheck = pgm_read_word(&(ret->VP)); + if (vpcheck == 0) break; + if (vpcheck == vp) return ret; + ++ret; + } while (1); + + DEBUG_ECHOLNPAIR("FindVPVar NOT FOUND ", vp); + return nullptr; +} + +void DGUSScreenVariableHandler::ScreenChangeHookIfIdle(DGUS_VP_Variable &var, void *val_ptr) { + if (!ExtUI::isPrinting()) { + ScreenChangeHook(var, val_ptr); + dgusdisplay.RequestScreen(current_screen); + } +} + +void DGUSScreenVariableHandler::ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr) { + uint8_t *tmp = (uint8_t*)val_ptr; + + // The keycode in target is coded as , so 0x0100A means + // from screen 1 (main) to 10 (temperature). DGUSLCD_SCREEN_POPUP is special, + // meaning "return to previous screen" + DGUSLCD_Screens target = (DGUSLCD_Screens)tmp[1]; + + if (target == DGUSLCD_SCREEN_POPUP) { + // special handling for popup is to return to previous menu + if (current_screen == DGUSLCD_SCREEN_POPUP && confirm_action_cb) confirm_action_cb(); + PopToOldScreen(); + return; + } + + UpdateNewScreen(target); + + #ifdef DEBUG_DGUSLCD + if (!DGUSLCD_FindScreenVPMapList(target)) DEBUG_ECHOLNPAIR("WARNING: No screen Mapping found for ", target); + #endif +} + +void DGUSScreenVariableHandler::HandleAllHeatersOff(DGUS_VP_Variable &var, void *val_ptr) { + thermalManager.disable_all_heaters(); + ScreenHandler.ForceCompleteUpdate(); // hint to send all data. +} + +void DGUSScreenVariableHandler::HandleTemperatureChanged(DGUS_VP_Variable &var, void *val_ptr) { + uint16_t newvalue = swap16(*(uint16_t*)val_ptr); + uint16_t acceptedvalue; + + switch (var.VP) { + default: return; + #if HOTENDS >= 1 + case VP_T_E0_Set: + thermalManager.setTargetHotend(newvalue, 0); + acceptedvalue = thermalManager.temp_hotend[0].target; + break; + #endif + #if HOTENDS >= 2 + case VP_T_E1_Set: + thermalManager.setTargetHotend(newvalue, 1); + acceptedvalue = thermalManager.temp_hotend[1].target; + break; + #endif + #if HAS_HEATED_BED + case VP_T_Bed_Set: + thermalManager.setTargetBed(newvalue); + acceptedvalue = thermalManager.temp_bed.target; + break; + #endif + } + + // reply to display the new value to update the view if the new value was rejected by the Thermal Manager. + if (newvalue != acceptedvalue && var.send_to_display_handler) var.send_to_display_handler(var); + ScreenHandler.skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel +} + +void DGUSScreenVariableHandler::HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_ptr) { + #if EXTRUDERS + uint16_t newvalue = swap16(*(uint16_t*)val_ptr); + uint8_t target_extruder; + switch (var.VP) { + default: return; + #if HOTENDS >= 1 + case VP_Flowrate_E0: target_extruder = 0; break; + #endif + #if HOTENDS >= 2 + case VP_Flowrate_E1: target_extruder = 1; break; + #endif + } + + planner.set_flow(target_extruder, newvalue); + ScreenHandler.skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel + #else + UNUSED(var); UNUSED(val_ptr); + #endif +} + +void DGUSScreenVariableHandler::HandleManualExtrude(DGUS_VP_Variable &var, void *val_ptr) { + DEBUG_ECHOLNPGM("HandleManualExtrude"); + + int16_t movevalue = swap16(*(uint16_t*)val_ptr); + float target = movevalue * 0.01f; + ExtUI::extruder_t target_extruder; + + switch (var.VP) { + #if HOTENDS >= 1 + case VP_MOVE_E0: target_extruder = ExtUI::extruder_t::E0; break; + #endif + #if HOTENDS >= 2 + case VP_MOVE_E1: target_extruder = ExtUI::extruder_t::E1; break; + #endif + default: return; + } + + target += ExtUI::getAxisPosition_mm(target_extruder); + ExtUI::setAxisPosition_mm(target, target_extruder); + skipVP = var.VP; +} + +#if ENABLED(DGUS_UI_MOVE_DIS_OPTION) + void DGUSScreenVariableHandler::HandleManualMoveOption(DGUS_VP_Variable &var, void *val_ptr) { + DEBUG_ECHOLNPGM("HandleManualMoveOption"); + *(uint16_t*)var.memadr = swap16(*(uint16_t*)val_ptr); + } +#endif + +void DGUSScreenVariableHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { + DEBUG_ECHOLNPGM("HandleManualMove"); + + int16_t movevalue = swap16(*(uint16_t*)val_ptr); + #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) + if (movevalue) { + const uint16_t choice = *(uint16_t*)var.memadr; + movevalue = movevalue < 0 ? -choice : choice; + } + #endif + char axiscode; + unsigned int speed = 1500; //FIXME: get default feedrate for manual moves, dont hardcode. + + switch (var.VP) { + default: return; + + case VP_MOVE_X: + axiscode = 'X'; + if (!ExtUI::canMove(ExtUI::axis_t::X)) goto cannotmove; + break; + + case VP_MOVE_Y: + axiscode = 'Y'; + if (!ExtUI::canMove(ExtUI::axis_t::Y)) goto cannotmove; + break; + + case VP_MOVE_Z: + axiscode = 'Z'; + speed = 300; // default to 5mm/s + if (!ExtUI::canMove(ExtUI::axis_t::Z)) goto cannotmove; + break; + + case VP_HOME_ALL: // only used for homing + axiscode = '\0'; + movevalue = 0; // ignore value sent from display, this VP is _ONLY_ for homing. + break; + } + + if (!movevalue) { + // homing + DEBUG_ECHOPAIR(" homing ", axiscode); + char buf[6] = "G28 X"; + buf[4] = axiscode; + //DEBUG_ECHOPAIR(" ", buf); + queue.enqueue_one_now(buf); + //DEBUG_ECHOLNPGM(" ✓"); + ScreenHandler.ForceCompleteUpdate(); + return; + } + else { + //movement + DEBUG_ECHOPAIR(" move ", axiscode); + bool old_relative_mode = relative_mode; + if (!relative_mode) { + //DEBUG_ECHOPGM(" G91"); + queue.enqueue_now_P(PSTR("G91")); + //DEBUG_ECHOPGM(" ✓ "); + } + char buf[32]; // G1 X9999.99 F12345 + unsigned int backup_speed = MMS_TO_MMM(feedrate_mm_s); + char sign[]="\0"; + int16_t value = movevalue / 100; + if (movevalue < 0) { value = -value; sign[0] = '-'; } + int16_t fraction = ABS(movevalue) % 100; + snprintf_P(buf, 32, PSTR("G0 %c%s%d.%02d F%d"), axiscode, sign, value, fraction, speed); + //DEBUG_ECHOPAIR(" ", buf); + queue.enqueue_one_now(buf); + //DEBUG_ECHOLNPGM(" ✓ "); + if (backup_speed != speed) { + snprintf_P(buf, 32, PSTR("G0 F%d"), backup_speed); + queue.enqueue_one_now(buf); + //DEBUG_ECHOPAIR(" ", buf); + } + //while (!enqueue_and_echo_command(buf)) idle(); + //DEBUG_ECHOLNPGM(" ✓ "); + if (!old_relative_mode) { + //DEBUG_ECHOPGM("G90"); + queue.enqueue_now_P(PSTR("G90")); + //DEBUG_ECHOPGM(" ✓ "); + } + } + + ScreenHandler.ForceCompleteUpdate(); + DEBUG_ECHOLNPGM("manmv done."); + return; + + cannotmove: + DEBUG_ECHOLNPAIR(" cannot move ", axiscode); + return; +} + +void DGUSScreenVariableHandler::HandleMotorLockUnlock(DGUS_VP_Variable &var, void *val_ptr) { + DEBUG_ECHOLNPGM("HandleMotorLockUnlock"); + + char buf[4]; + const int16_t lock = swap16(*(uint16_t*)val_ptr); + strcpy_P(buf, lock ? PSTR("M18") : PSTR("M17")); + + //DEBUG_ECHOPAIR(" ", buf); + queue.enqueue_one_now(buf); +} + +#if ENABLED(POWER_LOSS_RECOVERY) + + void DGUSScreenVariableHandler::HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr) { + uint16_t value = swap16(*(uint16_t*)val_ptr); + if (value) { + queue.inject_P(PSTR("M1000")); + ScreenHandler.GotoScreen(DGUSLCD_SCREEN_SDPRINTMANIPULATION); + } + else { + recovery.cancel(); + ScreenHandler.GotoScreen(DGUSLCD_SCREEN_STATUS); + } + } + +#endif + +void DGUSScreenVariableHandler::HandleSettings(DGUS_VP_Variable &var, void *val_ptr) { + DEBUG_ECHOLNPGM("HandleSettings"); + uint16_t value = swap16(*(uint16_t*)val_ptr); + switch (value) { + default: break; + case 1: + TERN_(PRINTCOUNTER, print_job_timer.initStats()); + queue.inject_P(PSTR("M502\nM500")); + break; + case 2: queue.inject_P(PSTR("M501")); break; + case 3: queue.inject_P(PSTR("M500")); break; + } +} + +void DGUSScreenVariableHandler::HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr) { + DEBUG_ECHOLNPGM("HandleStepPerMMChanged"); + + uint16_t value_raw = swap16(*(uint16_t*)val_ptr); + DEBUG_ECHOLNPAIR("value_raw:", value_raw); + float value = (float)value_raw/10; + ExtUI::axis_t axis; + switch (var.VP) { + case VP_X_STEP_PER_MM: axis = ExtUI::axis_t::X; break; + case VP_Y_STEP_PER_MM: axis = ExtUI::axis_t::Y; break; + case VP_Z_STEP_PER_MM: axis = ExtUI::axis_t::Z; break; + default: return; + } + DEBUG_ECHOLNPAIR_F("value:", value); + ExtUI::setAxisSteps_per_mm(value, axis); + DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisSteps_per_mm(axis)); + ScreenHandler.skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel + return; +} + +void DGUSScreenVariableHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr) { + DEBUG_ECHOLNPGM("HandleStepPerMMExtruderChanged"); + + uint16_t value_raw = swap16(*(uint16_t*)val_ptr); + DEBUG_ECHOLNPAIR("value_raw:", value_raw); + float value = (float)value_raw/10; + ExtUI::extruder_t extruder; + switch (var.VP) { + default: return; + #if HOTENDS >= 1 + case VP_E0_STEP_PER_MM: extruder = ExtUI::extruder_t::E0; break; + #endif + #if HOTENDS >= 2 + case VP_E1_STEP_PER_MM: extruder = ExtUI::extruder_t::E1; break; + #endif + } + DEBUG_ECHOLNPAIR_F("value:", value); + ExtUI::setAxisSteps_per_mm(value,extruder); + DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisSteps_per_mm(extruder)); + ScreenHandler.skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel + return; +} + +#if HAS_PID_HEATING + void DGUSScreenVariableHandler::HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr) { + uint16_t rawvalue = swap16(*(uint16_t*)val_ptr); + DEBUG_ECHOLNPAIR("V1:", rawvalue); + float value = (float)rawvalue / 10; + DEBUG_ECHOLNPAIR("V2:", value); + float newvalue = 0; + + switch (var.VP) { + default: return; + #if HOTENDS >= 1 + case VP_E0_PID_P: newvalue = value; break; + case VP_E0_PID_I: newvalue = scalePID_i(value); break; + case VP_E0_PID_D: newvalue = scalePID_d(value); break; + #endif + #if HOTENDS >= 2 + case VP_E1_PID_P: newvalue = value; break; + case VP_E1_PID_I: newvalue = scalePID_i(value); break; + case VP_E1_PID_D: newvalue = scalePID_d(value); break; + #endif + #if HAS_HEATED_BED + case VP_BED_PID_P: newvalue = value; break; + case VP_BED_PID_I: newvalue = scalePID_i(value); break; + case VP_BED_PID_D: newvalue = scalePID_d(value); break; + #endif + } + + DEBUG_ECHOLNPAIR_F("V3:", newvalue); + *(float *)var.memadr = newvalue; + ScreenHandler.skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel + } + + void DGUSScreenVariableHandler::HandlePIDAutotune(DGUS_VP_Variable &var, void *val_ptr) { + DEBUG_ECHOLNPGM("HandlePIDAutotune"); + + char buf[32] = {0}; + + switch (var.VP) { + default: break; + #if ENABLED(PIDTEMP) + #if HOTENDS >= 1 + case VP_PID_AUTOTUNE_E0: // Autotune Extruder 0 + sprintf(buf, "M303 E%d C5 S210 U1", ExtUI::extruder_t::E0); + break; + #endif + #if HOTENDS >= 2 + case VP_PID_AUTOTUNE_E1: + sprintf(buf, "M303 E%d C5 S210 U1", ExtUI::extruder_t::E1); + break; + #endif + #endif + #if ENABLED(PIDTEMPBED) + case VP_PID_AUTOTUNE_BED: + sprintf(buf, "M303 E-1 C5 S70 U1"); + break; + #endif + } + + if (buf[0]) queue.enqueue_one_now(buf); + + #if ENABLED(DGUS_UI_WAITING) + sendinfoscreen(PSTR("PID is autotuning"), PSTR("please wait"), NUL_STR, NUL_STR, true, true, true, true); + GotoScreen(DGUSLCD_SCREEN_WAITING); + #endif + } +#endif + +#if HAS_BED_PROBE + void DGUSScreenVariableHandler::HandleProbeOffsetZChanged(DGUS_VP_Variable &var, void *val_ptr) { + DEBUG_ECHOLNPGM("HandleProbeOffsetZChanged"); + + const float offset = float(int16_t(swap16(*(uint16_t*)val_ptr))) / 100.0f; + ExtUI::setZOffset_mm(offset); + ScreenHandler.skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel + return; + } +#endif + +#if ENABLED(BABYSTEPPING) + void DGUSScreenVariableHandler::HandleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr) { + DEBUG_ECHOLNPGM("HandleLiveAdjustZ"); + + int16_t flag = swap16(*(uint16_t*)val_ptr); + int16_t steps = flag ? -20 : 20; + ExtUI::smartAdjustAxis_steps(steps, ExtUI::axis_t::Z, true); + ScreenHandler.ForceCompleteUpdate(); + return; + } +#endif + +#if HAS_FAN + void DGUSScreenVariableHandler::HandleFanControl(DGUS_VP_Variable &var, void *val_ptr) { + DEBUG_ECHOLNPGM("HandleFanControl"); + *(uint8_t*)var.memadr = *(uint8_t*)var.memadr > 0 ? 0 : 255; + } +#endif + +void DGUSScreenVariableHandler::HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr) { + DEBUG_ECHOLNPGM("HandleHeaterControl"); + + uint8_t preheat_temp = 0; + switch (var.VP) { + #if HOTENDS >= 1 + case VP_E0_CONTROL: + #endif + #if HOTENDS >= 2 + case VP_E1_CONTROL: + #endif + #if HOTENDS >= 3 + case VP_E2_CONTROL: + #endif + preheat_temp = PREHEAT_1_TEMP_HOTEND; + break; + + case VP_BED_CONTROL: + preheat_temp = PREHEAT_1_TEMP_BED; + break; + } + + *(int16_t*)var.memadr = *(int16_t*)var.memadr > 0 ? 0 : preheat_temp; +} + +#if ENABLED(DGUS_PREHEAT_UI) + + void DGUSScreenVariableHandler::HandlePreheat(DGUS_VP_Variable &var, void *val_ptr) { + DEBUG_ECHOLNPGM("HandlePreheat"); + + uint8_t e_temp = 0; + TERN_(HAS_HEATED_BED, uint8_t bed_temp = 0); + const uint16_t preheat_option = swap16(*(uint16_t*)val_ptr); + switch (preheat_option) { + default: + case 0: // Preheat PLA + #if defined(PREHEAT_1_TEMP_HOTEND) && defined(PREHEAT_1_TEMP_BED) + e_temp = PREHEAT_1_TEMP_HOTEND; + TERN_(HAS_HEATED_BED, bed_temp = PREHEAT_1_TEMP_BED); + #endif + break; + case 1: // Preheat ABS + #if defined(PREHEAT_2_TEMP_HOTEND) && defined(PREHEAT_2_TEMP_BED) + e_temp = PREHEAT_2_TEMP_HOTEND; + TERN_(HAS_HEATED_BED, bed_temp = PREHEAT_2_TEMP_BED); + #endif + break; + case 2: // Preheat PET + #if defined(PREHEAT_3_TEMP_HOTEND) && defined(PREHEAT_3_TEMP_BED) + e_temp = PREHEAT_3_TEMP_HOTEND; + TERN_(HAS_HEATED_BED, bed_temp = PREHEAT_3_TEMP_BED); + #endif + break; + case 3: // Preheat FLEX + #if defined(PREHEAT_4_TEMP_HOTEND) && defined(PREHEAT_4_TEMP_BED) + e_temp = PREHEAT_4_TEMP_HOTEND; + TERN_(HAS_HEATED_BED, bed_temp = PREHEAT_4_TEMP_BED); + #endif + break; + case 7: break; // Custom preheat + case 9: break; // Cool down + } + + switch (var.VP) { + default: return; + #if HOTENDS >= 1 + case VP_E0_BED_PREHEAT: + thermalManager.setTargetHotend(e_temp, 0); + TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(bed_temp)); + break; + #endif + #if HOTENDS >= 2 + case VP_E1_BED_PREHEAT: + thermalManager.setTargetHotend(e_temp, 1); + TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(bed_temp)); + break; + #endif + } + + // Go to the preheat screen to show the heating progress + GotoScreen(DGUSLCD_SCREEN_PREHEAT); + } + +#endif + +#if ENABLED(DGUS_FILAMENT_LOADUNLOAD) + void DGUSScreenVariableHandler::HandleFilamentOption(DGUS_VP_Variable &var, void *val_ptr) { + DEBUG_ECHOLNPGM("HandleFilamentOption"); + + uint8_t e_temp = 0; + filament_data.heated = false; + uint16_t preheat_option = swap16(*(uint16_t*)val_ptr); + if (preheat_option <= 8) // Load filament type + filament_data.action = 1; + else if (preheat_option >= 10) { // Unload filament type + preheat_option -= 10; + filament_data.action = 2; + filament_data.purge_length = DGUS_FILAMENT_PURGE_LENGTH; + } + else // Cancel filament operation + filament_data.action = 0; + + switch (preheat_option) { + case 0: // Load PLA + #ifdef PREHEAT_1_TEMP_HOTEND + e_temp = PREHEAT_1_TEMP_HOTEND; + #endif + break; + case 1: // Load ABS + TERN_(PREHEAT_2_TEMP_HOTEND, e_temp = PREHEAT_2_TEMP_HOTEND); + break; + case 2: // Load PET + #ifdef PREHEAT_3_TEMP_HOTEND + e_temp = PREHEAT_3_TEMP_HOTEND; + #endif + break; + case 3: // Load FLEX + #ifdef PREHEAT_4_TEMP_HOTEND + e_temp = PREHEAT_4_TEMP_HOTEND; + #endif + break; + case 9: // Cool down + default: + e_temp = 0; + break; + } + + if (filament_data.action == 0) { // Go back to utility screen + #if HOTENDS >= 1 + thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E0); + #endif + #if HOTENDS >= 2 + thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E1); + #endif + GotoScreen(DGUSLCD_SCREEN_UTILITY); + } + else { // Go to the preheat screen to show the heating progress + switch (var.VP) { + default: return; + #if HOTENDS >= 1 + case VP_E0_FILAMENT_LOAD_UNLOAD: + filament_data.extruder = ExtUI::extruder_t::E0; + thermalManager.setTargetHotend(e_temp, filament_data.extruder); + break; + #endif + #if HOTENDS >= 2 + case VP_E1_FILAMENT_LOAD_UNLOAD: + filament_data.extruder = ExtUI::extruder_t::E1; + thermalManager.setTargetHotend(e_temp, filament_data.extruder); + break; + #endif + } + GotoScreen(DGUSLCD_SCREEN_FILAMENT_HEATING); + } + } + + void DGUSScreenVariableHandler::HandleFilamentLoadUnload(DGUS_VP_Variable &var) { + DEBUG_ECHOLNPGM("HandleFilamentLoadUnload"); + if (filament_data.action <= 0) return; + + // If we close to the target temperature, we can start load or unload the filament + if (thermalManager.hotEnoughToExtrude(filament_data.extruder) && \ + thermalManager.targetHotEnoughToExtrude(filament_data.extruder)) { + float movevalue = DGUS_FILAMENT_LOAD_LENGTH_PER_TIME; + + if (filament_data.action == 1) { // load filament + if (!filament_data.heated) { + GotoScreen(DGUSLCD_SCREEN_FILAMENT_LOADING); + filament_data.heated = true; + } + movevalue = ExtUI::getAxisPosition_mm(filament_data.extruder)+movevalue; + } + else { // unload filament + if (!filament_data.heated) { + GotoScreen(DGUSLCD_SCREEN_FILAMENT_UNLOADING); + filament_data.heated = true; + } + // Before unloading extrude to prevent jamming + if (filament_data.purge_length >= 0) { + movevalue = ExtUI::getAxisPosition_mm(filament_data.extruder) + movevalue; + filament_data.purge_length -= movevalue; + } + else + movevalue = ExtUI::getAxisPosition_mm(filament_data.extruder) - movevalue; + } + ExtUI::setAxisPosition_mm(movevalue, filament_data.extruder); + } + } +#endif + +void DGUSScreenVariableHandler::UpdateNewScreen(DGUSLCD_Screens newscreen, bool popup) { + DEBUG_ECHOLNPAIR("SetNewScreen: ", newscreen); + + if (!popup) { + memmove(&past_screens[1], &past_screens[0], sizeof(past_screens) - 1); + past_screens[0] = current_screen; + } + + current_screen = newscreen; + skipVP = 0; + ForceCompleteUpdate(); +} + +void DGUSScreenVariableHandler::PopToOldScreen() { + DEBUG_ECHOLNPAIR("PopToOldScreen s=", past_screens[0]); + GotoScreen(past_screens[0], true); + memmove(&past_screens[0], &past_screens[1], sizeof(past_screens) - 1); + past_screens[sizeof(past_screens) - 1] = DGUSLCD_SCREEN_MAIN; +} + +void DGUSScreenVariableHandler::UpdateScreenVPData() { + DEBUG_ECHOPAIR(" UpdateScreenVPData Screen: ", current_screen); + + const uint16_t *VPList = DGUSLCD_FindScreenVPMapList(current_screen); + if (!VPList) { + DEBUG_ECHOLNPAIR(" NO SCREEN FOR: ", current_screen); + ScreenComplete = true; + return; // nothing to do, likely a bug or boring screen. + } + + // Round-robin updating of all VPs. + VPList += update_ptr; + + bool sent_one = false; + do { + uint16_t VP = pgm_read_word(VPList); + DEBUG_ECHOPAIR(" VP: ", VP); + if (!VP) { + update_ptr = 0; + DEBUG_ECHOLNPGM(" UpdateScreenVPData done"); + ScreenComplete = true; + return; // Screen completed. + } + + if (VP == skipVP) { skipVP = 0; continue; } + + DGUS_VP_Variable rcpy; + if (populate_VPVar(VP, &rcpy)) { + uint8_t expected_tx = 6 + rcpy.size; // expected overhead is 6 bytes + payload. + // Send the VP to the display, but try to avoid overrunning the Tx Buffer. + // But send at least one VP, to avoid getting stalled. + if (rcpy.send_to_display_handler && (!sent_one || expected_tx <= dgusdisplay.GetFreeTxBuffer())) { + //DEBUG_ECHOPAIR(" calling handler for ", rcpy.VP); + sent_one = true; + rcpy.send_to_display_handler(rcpy); + } + else { + //auto x=dgusdisplay.GetFreeTxBuffer(); + //DEBUG_ECHOLNPAIR(" tx almost full: ", x); + //DEBUG_ECHOPAIR(" update_ptr ", update_ptr); + ScreenComplete = false; + return; // please call again! + } + } + + } while (++update_ptr, ++VPList, true); +} + + + +void DGUSScreenVariableHandler::GotoScreen(DGUSLCD_Screens screen, bool ispopup) { + dgusdisplay.RequestScreen(screen); + UpdateNewScreen(screen, ispopup); +} + +bool DGUSScreenVariableHandler::loop() { + dgusdisplay.loop(); + + const millis_t ms = millis(); + static millis_t next_event_ms = 0; + + if (!IsScreenComplete() || ELAPSED(ms, next_event_ms)) { + next_event_ms = ms + DGUS_UPDATE_INTERVAL_MS; + UpdateScreenVPData(); + } + + #if ENABLED(SHOW_BOOTSCREEN) + static bool booted = false; + if (!booted && TERN0(POWER_LOSS_RECOVERY, recovery.valid())) + booted = true; + if (!booted && ELAPSED(ms, BOOTSCREEN_TIMEOUT)) { + booted = true; + GotoScreen(DGUSLCD_SCREEN_MAIN); + } + #endif + return IsScreenComplete(); +} + +void DGUSDisplay::RequestScreen(DGUSLCD_Screens screen) { + DEBUG_ECHOLNPAIR("GotoScreen ", screen); + const unsigned char gotoscreen[] = { 0x5A, 0x01, (unsigned char) (screen >> 8U), (unsigned char) (screen & 0xFFU) }; + WriteVariable(0x84, gotoscreen, sizeof(gotoscreen)); +} \ No newline at end of file diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.h b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.h new file mode 100644 index 000000000000..62b730eeac00 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.h @@ -0,0 +1,224 @@ +#include "../../../../inc/MarlinConfigPre.h" + +#include "../../../../MarlinCore.h" +#if HAS_BED_PROBE + #include "../../../../module/probe.h" +#endif +#include "DGUSVPVariable.h" + +class DGUSScreenVariableHandler { +public: + DGUSScreenVariableHandler() = default; + + static bool loop(); + + /// Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen + /// The bools specifing whether the strings are in RAM or FLASH. + static void sendinfoscreen(const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + + static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + + /// "M117" Message -- msg is a RAM ptr. + static void setstatusmessage(const char* msg); + /// The same for messages from Flash + static void setstatusmessagePGM(PGM_P const msg); + // Callback for VP "Display wants to change screen on idle printer" + static void ScreenChangeHookIfIdle(DGUS_VP_Variable &var, void *val_ptr); + // Callback for VP "Screen has been changed" + static void ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr); + // Callback for VP "All Heaters Off" + static void HandleAllHeatersOff(DGUS_VP_Variable &var, void *val_ptr); + // Hook for "Change this temperature" + static void HandleTemperatureChanged(DGUS_VP_Variable &var, void *val_ptr); + // Hook for "Change Flowrate" + static void HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_ptr); + #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) + // Hook for manual move option + static void HandleManualMoveOption(DGUS_VP_Variable &var, void *val_ptr); + #endif + // Hook for manual move. + static void HandleManualMove(DGUS_VP_Variable &var, void *val_ptr); + // Hook for manual extrude. + static void HandleManualExtrude(DGUS_VP_Variable &var, void *val_ptr); + // Hook for motor lock and unlook + static void HandleMotorLockUnlock(DGUS_VP_Variable &var, void *val_ptr); + #if ENABLED(POWER_LOSS_RECOVERY) + // Hook for power loss recovery. + static void HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr); + #endif + // Hook for settings + static void HandleSettings(DGUS_VP_Variable &var, void *val_ptr); + static void HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr); + static void HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr); + #if HAS_PID_HEATING + // Hook for "Change this temperature PID para" + static void HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr); + // Hook for PID autotune + static void HandlePIDAutotune(DGUS_VP_Variable &var, void *val_ptr); + #endif + #if HAS_BED_PROBE + // Hook for "Change probe offset z" + static void HandleProbeOffsetZChanged(DGUS_VP_Variable &var, void *val_ptr); + #endif + #if ENABLED(BABYSTEPPING) + // Hook for live z adjust action + static void HandleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr); + #endif + #if HAS_FAN + // Hook for fan control + static void HandleFanControl(DGUS_VP_Variable &var, void *val_ptr); + #endif + // Hook for heater control + static void HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr); + #if ENABLED(DGUS_PREHEAT_UI) + // Hook for preheat + static void HandlePreheat(DGUS_VP_Variable &var, void *val_ptr); + #endif + #if ENABLED(DGUS_FILAMENT_LOADUNLOAD) + // Hook for filament load and unload filament option + static void HandleFilamentOption(DGUS_VP_Variable &var, void *val_ptr); + // Hook for filament load and unload + static void HandleFilamentLoadUnload(DGUS_VP_Variable &var); + #endif + + #if ENABLED(SDSUPPORT) + // Callback for VP "Display wants to change screen when there is a SD card" + static void ScreenChangeHookIfSD(DGUS_VP_Variable &var, void *val_ptr); + /// Scroll buttons on the file listing screen. + static void DGUSLCD_SD_ScrollFilelist(DGUS_VP_Variable &var, void *val_ptr); + /// File touched. + static void DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr); + /// start print after confirmation received. + static void DGUSLCD_SD_StartPrint(DGUS_VP_Variable &var, void *val_ptr); + /// User hit the pause, resume or abort button. + static void DGUSLCD_SD_ResumePauseAbort(DGUS_VP_Variable &var, void *val_ptr); + /// User confirmed the abort action + static void DGUSLCD_SD_ReallyAbort(DGUS_VP_Variable &var, void *val_ptr); + /// User hit the tune button + static void DGUSLCD_SD_PrintTune(DGUS_VP_Variable &var, void *val_ptr); + /// Send a single filename to the display. + static void DGUSLCD_SD_SendFilename(DGUS_VP_Variable &var); + /// Marlin informed us that a new SD has been inserted. + static void SDCardInserted(); + /// Marlin informed us that the SD Card has been removed(). + static void SDCardRemoved(); + /// Marlin informed us about a bad SD Card. + static void SDCardError(); + #endif + + // OK Button the Confirm screen. + static void ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr); + + // Update data after went to new screen (by display or by GotoScreen) + // remember: store the last-displayed screen, so it can get returned to. + // (e.g for pop up messages) + static void UpdateNewScreen(DGUSLCD_Screens newscreen, bool popup=false); + + // Recall the remembered screen. + static void PopToOldScreen(); + + // Make the display show the screen and update all VPs in it. + static void GotoScreen(DGUSLCD_Screens screen, bool ispopup = false); + + static void UpdateScreenVPData(); + + // Helpers to convert and transfer data to the display. + static void DGUSLCD_SendWordValueToDisplay(DGUS_VP_Variable &var); + static void DGUSLCD_SendStringToDisplay(DGUS_VP_Variable &var); + static void DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var); + static void DGUSLCD_SendTemperaturePID(DGUS_VP_Variable &var); + static void DGUSLCD_SendPercentageToDisplay(DGUS_VP_Variable &var); + static void DGUSLCD_SendPrintProgressToDisplay(DGUS_VP_Variable &var); + static void DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var); + #if ENABLED(PRINTCOUNTER) + static void DGUSLCD_SendPrintAccTimeToDisplay(DGUS_VP_Variable &var); + static void DGUSLCD_SendPrintsTotalToDisplay(DGUS_VP_Variable &var); + #endif + #if HAS_FAN + static void DGUSLCD_SendFanStatusToDisplay(DGUS_VP_Variable &var); + #endif + static void DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var); + #if ENABLED(DGUS_UI_WAITING) + static void DGUSLCD_SendWaitingStatusToDisplay(DGUS_VP_Variable &var); + #endif + + /// Send a value from 0..100 to a variable with a range from 0..255 + static void DGUSLCD_PercentageToUint8(DGUS_VP_Variable &var, void *val_ptr); + + template + static void DGUSLCD_SetValueDirectly(DGUS_VP_Variable &var, void *val_ptr) { + if (!var.memadr) return; + union { unsigned char tmp[sizeof(T)]; T t; } x; + unsigned char *ptr = (unsigned char*)val_ptr; + LOOP_L_N(i, sizeof(T)) x.tmp[i] = ptr[sizeof(T) - i - 1]; + *(T*)var.memadr = x.t; + } + + /// Send a float value to the display. + /// Display will get a 4-byte integer scaled to the number of digits: + /// Tell the display the number of digits and it cheats by displaying a dot between... + template + static void DGUSLCD_SendFloatAsLongValueToDisplay(DGUS_VP_Variable &var) { + if (var.memadr) { + float f = *(float *)var.memadr; + f *= cpow(10, decimals); + union { long l; char lb[4]; } endian; + + char tmp[4]; + endian.l = f; + tmp[0] = endian.lb[3]; + tmp[1] = endian.lb[2]; + tmp[2] = endian.lb[1]; + tmp[3] = endian.lb[0]; + dgusdisplay.WriteVariable(var.VP, tmp, 4); + } + } + + /// Send a float value to the display. + /// Display will get a 2-byte integer scaled to the number of digits: + /// Tell the display the number of digits and it cheats by displaying a dot between... + template + static void DGUSLCD_SendFloatAsIntValueToDisplay(DGUS_VP_Variable &var) { + if (var.memadr) { + float f = *(float *)var.memadr; + DEBUG_ECHOLNPAIR_F(" >> ", f, 6); + f *= cpow(10, decimals); + union { int16_t i; char lb[2]; } endian; + + char tmp[2]; + endian.i = f; + tmp[0] = endian.lb[1]; + tmp[1] = endian.lb[0]; + dgusdisplay.WriteVariable(var.VP, tmp, 2); + } + } + + /// Force an update of all VP on the current screen. + static inline void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; } + /// Has all VPs sent to the screen + static inline bool IsScreenComplete() { return ScreenComplete; } + + static inline DGUSLCD_Screens getCurrentScreen() { return current_screen; } + + static inline void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; } + +private: + static DGUSLCD_Screens current_screen; ///< currently on screen + static constexpr uint8_t NUM_PAST_SCREENS = 4; + static DGUSLCD_Screens past_screens[NUM_PAST_SCREENS]; ///< LIFO with past screens for the "back" button. + + static uint8_t update_ptr; ///< Last sent entry in the VPList for the actual screen. + static uint16_t skipVP; ///< When updating the screen data, skip this one, because the user is interacting with it. + static bool ScreenComplete; ///< All VPs sent to screen? + + static uint16_t ConfirmVP; ///< context for confirm screen (VP that will be emulated-sent on "OK"). + + #if ENABLED(SDSUPPORT) + static int16_t top_file; ///< file on top of file chooser + static int16_t file_to_print; ///< touched file to be confirmed + #endif + + static void (*confirm_action_cb)(); +}; + +extern DGUSScreenVariableHandler ScreenHandler; \ No newline at end of file diff --git a/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp index 71ae60434408..d3a2a408e697 100644 --- a/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp @@ -28,6 +28,7 @@ #include "../DGUSDisplayDef.h" #include "../DGUSDisplay.h" +#include "../DGUSScreenVariableHandler.h" #include "../../../../../module/temperature.h" #include "../../../../../module/motion.h" diff --git a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp index 62cd67d2cb54..31864fecd0f6 100644 --- a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp @@ -28,6 +28,7 @@ #include "../DGUSDisplayDef.h" #include "../DGUSDisplay.h" +#include "../DGUSScreenVariableHandler.h" #include "../../../../../module/temperature.h" #include "../../../../../module/motion.h" diff --git a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp index b6a7fca903b2..458f0805badd 100644 --- a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp @@ -28,6 +28,7 @@ #include "../DGUSDisplayDef.h" #include "../DGUSDisplay.h" +#include "../DGUSScreenVariableHandler.h" #include "../../../../../module/temperature.h" #include "../../../../../module/motion.h" diff --git a/Marlin/src/lcd/extui_dgus_lcd.cpp b/Marlin/src/lcd/extui_dgus_lcd.cpp index 56308f08d6d3..6f68a62fdab1 100644 --- a/Marlin/src/lcd/extui_dgus_lcd.cpp +++ b/Marlin/src/lcd/extui_dgus_lcd.cpp @@ -33,6 +33,7 @@ #include "extui/ui_api.h" #include "extui/lib/dgus/DGUSDisplay.h" #include "extui/lib/dgus/DGUSDisplayDef.h" +#include "extui/lib/dgus/DGUSScreenVariableHandler.h" extern const char NUL_STR[]; From b9ae189e1be7965cf526db2c998903e8e90827b4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 18 Jul 2020 19:23:53 -0500 Subject: [PATCH 03/11] Add header, formatting --- .../lib/dgus/DGUSScreenVariableHandler.cpp | 39 +++++++++++++------ .../lib/dgus/DGUSScreenVariableHandler.h | 31 ++++++++++++--- 2 files changed, 53 insertions(+), 17 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.cpp index 338032aba494..924d1a2d6960 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.cpp @@ -1,5 +1,31 @@ -#include "../../ui_api.h" +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#include "DGUSScreenVariableHandler.h" +#include "DGUSDisplay.h" +#include "DGUSVPVariable.h" +#include "DGUSDisplayDef.h" + +#include "../../ui_api.h" #include "../../../../MarlinCore.h" #include "../../../../module/temperature.h" #include "../../../../module/motion.h" @@ -12,11 +38,6 @@ #include "../../../../feature/powerloss.h" #endif -#include "DGUSDisplay.h" -#include "DGUSVPVariable.h" -#include "DGUSDisplayDef.h" -#include "DGUSScreenVariableHandler.h" - uint16_t DGUSScreenVariableHandler::ConfirmVP; #if ENABLED(SDSUPPORT) @@ -37,8 +58,6 @@ bool DGUSScreenVariableHandler::ScreenComplete; //DGUSDisplay dgusdisplay; - - // endianness swap uint16_t swap16(const uint16_t value) { return (value & 0xffU) << 8U | (value >> 8U); } @@ -1073,8 +1092,6 @@ void DGUSScreenVariableHandler::UpdateScreenVPData() { } while (++update_ptr, ++VPList, true); } - - void DGUSScreenVariableHandler::GotoScreen(DGUSLCD_Screens screen, bool ispopup) { dgusdisplay.RequestScreen(screen); UpdateNewScreen(screen, ispopup); @@ -1107,4 +1124,4 @@ void DGUSDisplay::RequestScreen(DGUSLCD_Screens screen) { DEBUG_ECHOLNPAIR("GotoScreen ", screen); const unsigned char gotoscreen[] = { 0x5A, 0x01, (unsigned char) (screen >> 8U), (unsigned char) (screen & 0xFFU) }; WriteVariable(0x84, gotoscreen, sizeof(gotoscreen)); -} \ No newline at end of file +} diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.h b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.h index 62b730eeac00..7d965ee3cc09 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.h +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.h @@ -1,11 +1,30 @@ -#include "../../../../inc/MarlinConfigPre.h" +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once -#include "../../../../MarlinCore.h" -#if HAS_BED_PROBE - #include "../../../../module/probe.h" -#endif #include "DGUSVPVariable.h" +#include "../../../../inc/MarlinConfigPre.h" + class DGUSScreenVariableHandler { public: DGUSScreenVariableHandler() = default; @@ -221,4 +240,4 @@ class DGUSScreenVariableHandler { static void (*confirm_action_cb)(); }; -extern DGUSScreenVariableHandler ScreenHandler; \ No newline at end of file +extern DGUSScreenVariableHandler ScreenHandler; From e1e4b8d6cc3778e681735fc5770b15f96e5618ce Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 18 Jul 2020 19:32:03 -0500 Subject: [PATCH 04/11] Shorten name, use dot notation with instance --- .../lib/dgus/DGUSScreenVariableHandler.cpp | 142 +++++++-------- .../lib/dgus/DGUSScreenVariableHandler.h | 6 +- .../extui/lib/dgus/fysetc/DGUSDisplayDef.cpp | 168 +++++++++--------- .../extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp | 162 ++++++++--------- .../extui/lib/dgus/origin/DGUSDisplayDef.cpp | 158 ++++++++-------- 5 files changed, 318 insertions(+), 318 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.cpp index 924d1a2d6960..7d09799387cd 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.cpp @@ -38,50 +38,50 @@ #include "../../../../feature/powerloss.h" #endif -uint16_t DGUSScreenVariableHandler::ConfirmVP; +uint16_t DGUSScreenHandler::ConfirmVP; #if ENABLED(SDSUPPORT) - int16_t DGUSScreenVariableHandler::top_file = 0; - int16_t DGUSScreenVariableHandler::file_to_print = 0; + int16_t DGUSScreenHandler::top_file = 0; + int16_t DGUSScreenHandler::file_to_print = 0; static ExtUI::FileList filelist; #endif -void (*DGUSScreenVariableHandler::confirm_action_cb)() = nullptr; +void (*DGUSScreenHandler::confirm_action_cb)() = nullptr; -//DGUSScreenVariableHandler ScreenHandler; +//DGUSScreenHandler ScreenHandler; -DGUSLCD_Screens DGUSScreenVariableHandler::current_screen; -DGUSLCD_Screens DGUSScreenVariableHandler::past_screens[NUM_PAST_SCREENS]; -uint8_t DGUSScreenVariableHandler::update_ptr; -uint16_t DGUSScreenVariableHandler::skipVP; -bool DGUSScreenVariableHandler::ScreenComplete; +DGUSLCD_Screens DGUSScreenHandler::current_screen; +DGUSLCD_Screens DGUSScreenHandler::past_screens[NUM_PAST_SCREENS]; +uint8_t DGUSScreenHandler::update_ptr; +uint16_t DGUSScreenHandler::skipVP; +bool DGUSScreenHandler::ScreenComplete; //DGUSDisplay dgusdisplay; // endianness swap uint16_t swap16(const uint16_t value) { return (value & 0xffU) << 8U | (value >> 8U); } -void DGUSScreenVariableHandler::sendinfoscreen(const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool l4inflash) { +void DGUSScreenHandler::sendinfoscreen(const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool l4inflash) { DGUS_VP_Variable ramcopy; if (populate_VPVar(VP_MSGSTR1, &ramcopy)) { ramcopy.memadr = (void*) line1; - l1inflash ? DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplay(ramcopy); + l1inflash ? DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenHandler::DGUSLCD_SendStringToDisplay(ramcopy); } if (populate_VPVar(VP_MSGSTR2, &ramcopy)) { ramcopy.memadr = (void*) line2; - l2inflash ? DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplay(ramcopy); + l2inflash ? DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenHandler::DGUSLCD_SendStringToDisplay(ramcopy); } if (populate_VPVar(VP_MSGSTR3, &ramcopy)) { ramcopy.memadr = (void*) line3; - l3inflash ? DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplay(ramcopy); + l3inflash ? DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenHandler::DGUSLCD_SendStringToDisplay(ramcopy); } if (populate_VPVar(VP_MSGSTR4, &ramcopy)) { ramcopy.memadr = (void*) line4; - l4inflash ? DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplay(ramcopy); + l4inflash ? DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenHandler::DGUSLCD_SendStringToDisplay(ramcopy); } } -void DGUSScreenVariableHandler::HandleUserConfirmationPopUp(uint16_t VP, const char* line1, const char* line2, const char* line3, const char* line4, bool l1, bool l2, bool l3, bool l4) { +void DGUSScreenHandler::HandleUserConfirmationPopUp(uint16_t VP, const char* line1, const char* line2, const char* line3, const char* line4, bool l1, bool l2, bool l3, bool l4) { if (current_screen == DGUSLCD_SCREEN_CONFIRM) { // Already showing a pop up, so we need to cancel that first. PopToOldScreen(); @@ -92,7 +92,7 @@ void DGUSScreenVariableHandler::HandleUserConfirmationPopUp(uint16_t VP, const c ScreenHandler.GotoScreen(DGUSLCD_SCREEN_CONFIRM); } -void DGUSScreenVariableHandler::setstatusmessage(const char *msg) { +void DGUSScreenHandler::setstatusmessage(const char *msg) { DGUS_VP_Variable ramcopy; if (populate_VPVar(VP_M117, &ramcopy)) { ramcopy.memadr = (void*) msg; @@ -100,7 +100,7 @@ void DGUSScreenVariableHandler::setstatusmessage(const char *msg) { } } -void DGUSScreenVariableHandler::setstatusmessagePGM(PGM_P const msg) { +void DGUSScreenHandler::setstatusmessagePGM(PGM_P const msg) { DGUS_VP_Variable ramcopy; if (populate_VPVar(VP_M117, &ramcopy)) { ramcopy.memadr = (void*) msg; @@ -109,7 +109,7 @@ void DGUSScreenVariableHandler::setstatusmessagePGM(PGM_P const msg) { } // Send an 8 bit or 16 bit value to the display. -void DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay(DGUS_VP_Variable &var) { +void DGUSScreenHandler::DGUSLCD_SendWordValueToDisplay(DGUS_VP_Variable &var) { if (var.memadr) { //DEBUG_ECHOPAIR(" DGUS_LCD_SendWordValueToDisplay ", var.VP); //DEBUG_ECHOLNPAIR(" data ", *(uint16_t *)var.memadr); @@ -121,7 +121,7 @@ void DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay(DGUS_VP_Variable } // Send an uint8_t between 0 and 255 to the display, but scale to a percentage (0..100) -void DGUSScreenVariableHandler::DGUSLCD_SendPercentageToDisplay(DGUS_VP_Variable &var) { +void DGUSScreenHandler::DGUSLCD_SendPercentageToDisplay(DGUS_VP_Variable &var) { if (var.memadr) { //DEBUG_ECHOPAIR(" DGUS_LCD_SendWordValueToDisplay ", var.VP); //DEBUG_ECHOLNPAIR(" data ", *(uint16_t *)var.memadr); @@ -133,7 +133,7 @@ void DGUSScreenVariableHandler::DGUSLCD_SendPercentageToDisplay(DGUS_VP_Variable } // Send the current print progress to the display. -void DGUSScreenVariableHandler::DGUSLCD_SendPrintProgressToDisplay(DGUS_VP_Variable &var) { +void DGUSScreenHandler::DGUSLCD_SendPrintProgressToDisplay(DGUS_VP_Variable &var) { //DEBUG_ECHOPAIR(" DGUSLCD_SendPrintProgressToDisplay ", var.VP); uint16_t tmp = ExtUI::getProgress_percent(); //DEBUG_ECHOLNPAIR(" data ", tmp); @@ -143,7 +143,7 @@ void DGUSScreenVariableHandler::DGUSLCD_SendPrintProgressToDisplay(DGUS_VP_Varia // Send the current print time to the display. // It is using a hex display for that: It expects BSD coded data in the format xxyyzz -void DGUSScreenVariableHandler::DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var) { +void DGUSScreenHandler::DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var) { duration_t elapsed = print_job_timer.duration(); char buf[32]; elapsed.toString(buf); @@ -151,7 +151,7 @@ void DGUSScreenVariableHandler::DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable } // Send an uint8_t between 0 and 100 to a variable scale to 0..255 -void DGUSScreenVariableHandler::DGUSLCD_PercentageToUint8(DGUS_VP_Variable &var, void *val_ptr) { +void DGUSScreenHandler::DGUSLCD_PercentageToUint8(DGUS_VP_Variable &var, void *val_ptr) { if (var.memadr) { uint16_t value = swap16(*(uint16_t*)val_ptr); *(uint8_t*)var.memadr = map(constrain(value, 0, 100), 0, 100, 0, 255); @@ -161,7 +161,7 @@ void DGUSScreenVariableHandler::DGUSLCD_PercentageToUint8(DGUS_VP_Variable &var, // Sends a (RAM located) string to the DGUS Display // (Note: The DGUS Display does not clear after the \0, you have to // overwrite the remainings with spaces.// var.size has the display buffer size! -void DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplay(DGUS_VP_Variable &var) { +void DGUSScreenHandler::DGUSLCD_SendStringToDisplay(DGUS_VP_Variable &var) { char *tmp = (char*) var.memadr; dgusdisplay.WriteVariable(var.VP, tmp, var.size, true); } @@ -169,13 +169,13 @@ void DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplay(DGUS_VP_Variable &va // Sends a (flash located) string to the DGUS Display // (Note: The DGUS Display does not clear after the \0, you have to // overwrite the remainings with spaces.// var.size has the display buffer size! -void DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var) { +void DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var) { char *tmp = (char*) var.memadr; dgusdisplay.WriteVariablePGM(var.VP, tmp, var.size, true); } #if HAS_PID_HEATING - void DGUSScreenVariableHandler::DGUSLCD_SendTemperaturePID(DGUS_VP_Variable &var) { + void DGUSScreenHandler::DGUSLCD_SendTemperaturePID(DGUS_VP_Variable &var) { float value = *(float *)var.memadr; float valuesend = 0; switch (var.VP) { @@ -212,7 +212,7 @@ void DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable // Send the accumulate print time to the display. // It is using a hex display for that: It expects BSD coded data in the format xxyyzz - void DGUSScreenVariableHandler::DGUSLCD_SendPrintAccTimeToDisplay(DGUS_VP_Variable &var) { + void DGUSScreenHandler::DGUSLCD_SendPrintAccTimeToDisplay(DGUS_VP_Variable &var) { printStatistics state = print_job_timer.getStats(); char buf[21]; duration_t elapsed = state.printTime; @@ -220,7 +220,7 @@ void DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable dgusdisplay.WriteVariable(VP_PrintAccTime, buf, var.size, true); } - void DGUSScreenVariableHandler::DGUSLCD_SendPrintsTotalToDisplay(DGUS_VP_Variable &var) { + void DGUSScreenHandler::DGUSLCD_SendPrintsTotalToDisplay(DGUS_VP_Variable &var) { printStatistics state = print_job_timer.getStats(); char buf[21]; sprintf_P(buf, PSTR("%u"), state.totalPrints); @@ -231,7 +231,7 @@ void DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable // Send fan status value to the display. #if HAS_FAN - void DGUSScreenVariableHandler::DGUSLCD_SendFanStatusToDisplay(DGUS_VP_Variable &var) { + void DGUSScreenHandler::DGUSLCD_SendFanStatusToDisplay(DGUS_VP_Variable &var) { if (var.memadr) { DEBUG_ECHOPAIR(" DGUSLCD_SendFanStatusToDisplay ", var.VP); DEBUG_ECHOLNPAIR(" data ", *(uint8_t *)var.memadr); @@ -244,7 +244,7 @@ void DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable #endif // Send heater status value to the display. -void DGUSScreenVariableHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var) { +void DGUSScreenHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var) { if (var.memadr) { DEBUG_ECHOPAIR(" DGUSLCD_SendHeaterStatusToDisplay ", var.VP); DEBUG_ECHOLNPAIR(" data ", *(int16_t *)var.memadr); @@ -256,7 +256,7 @@ void DGUSScreenVariableHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variab } #if ENABLED(DGUS_UI_WAITING) - void DGUSScreenVariableHandler::DGUSLCD_SendWaitingStatusToDisplay(DGUS_VP_Variable &var) { + void DGUSScreenHandler::DGUSLCD_SendWaitingStatusToDisplay(DGUS_VP_Variable &var) { // In FYSETC UI design there are 10 statuses to loop static uint16_t period = 0; static uint16_t index = 0; @@ -273,7 +273,7 @@ void DGUSScreenVariableHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variab #if ENABLED(SDSUPPORT) - void DGUSScreenVariableHandler::ScreenChangeHookIfSD(DGUS_VP_Variable &var, void *val_ptr) { + void DGUSScreenHandler::ScreenChangeHookIfSD(DGUS_VP_Variable &var, void *val_ptr) { // default action executed when there is a SD card, but not printing if (ExtUI::isMediaInserted() && !ExtUI::isPrintingFromMedia()) { ScreenChangeHook(var, val_ptr); @@ -300,7 +300,7 @@ void DGUSScreenVariableHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variab } } - void DGUSScreenVariableHandler::DGUSLCD_SD_ScrollFilelist(DGUS_VP_Variable& var, void *val_ptr) { + void DGUSScreenHandler::DGUSLCD_SD_ScrollFilelist(DGUS_VP_Variable& var, void *val_ptr) { auto old_top = top_file; const int16_t scroll = (int16_t)swap16(*(uint16_t*)val_ptr); if (scroll) { @@ -326,7 +326,7 @@ void DGUSScreenVariableHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variab if (old_top != top_file) ForceCompleteUpdate(); } - void DGUSScreenVariableHandler::DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr) { + void DGUSScreenHandler::DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr) { uint16_t touched_nr = (int16_t)swap16(*(uint16_t*)val_ptr) + top_file; if (touched_nr > filelist.count()) return; if (!filelist.seek(touched_nr)) return; @@ -347,7 +347,7 @@ void DGUSScreenVariableHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variab HandleUserConfirmationPopUp(VP_SD_FileSelectConfirm, nullptr, PSTR("Print file"), filelist.filename(), PSTR("from SD Card?"), true, true, false, true); } - void DGUSScreenVariableHandler::DGUSLCD_SD_StartPrint(DGUS_VP_Variable &var, void *val_ptr) { + void DGUSScreenHandler::DGUSLCD_SD_StartPrint(DGUS_VP_Variable &var, void *val_ptr) { if (!filelist.seek(file_to_print)) return; ExtUI::printFile(filelist.shortFilename()); ScreenHandler.GotoScreen( @@ -359,7 +359,7 @@ void DGUSScreenVariableHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variab ); } - void DGUSScreenVariableHandler::DGUSLCD_SD_ResumePauseAbort(DGUS_VP_Variable &var, void *val_ptr) { + void DGUSScreenHandler::DGUSLCD_SD_ResumePauseAbort(DGUS_VP_Variable &var, void *val_ptr) { if (!ExtUI::isPrintingFromMedia()) return; // avoid race condition when user stays in this menu and printer finishes. switch (swap16(*(uint16_t*)val_ptr)) { case 0: // Resume @@ -374,17 +374,17 @@ void DGUSScreenVariableHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variab } } - void DGUSScreenVariableHandler::DGUSLCD_SD_ReallyAbort(DGUS_VP_Variable &var, void *val_ptr) { + void DGUSScreenHandler::DGUSLCD_SD_ReallyAbort(DGUS_VP_Variable &var, void *val_ptr) { ExtUI::stopPrint(); GotoScreen(DGUSLCD_SCREEN_MAIN); } - void DGUSScreenVariableHandler::DGUSLCD_SD_PrintTune(DGUS_VP_Variable &var, void *val_ptr) { + void DGUSScreenHandler::DGUSLCD_SD_PrintTune(DGUS_VP_Variable &var, void *val_ptr) { if (!ExtUI::isPrintingFromMedia()) return; // avoid race condition when user stays in this menu and printer finishes. GotoScreen(DGUSLCD_SCREEN_SDPRINTTUNE); } - void DGUSScreenVariableHandler::DGUSLCD_SD_SendFilename(DGUS_VP_Variable& var) { + void DGUSScreenHandler::DGUSLCD_SD_SendFilename(DGUS_VP_Variable& var) { uint16_t target_line = (var.VP - VP_SD_FileName0) / VP_SD_FileName_LEN; if (target_line > DGUS_SD_FILESPERSCREEN) return; char tmpfilename[VP_SD_FileName_LEN + 1] = ""; @@ -394,7 +394,7 @@ void DGUSScreenVariableHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variab DGUSLCD_SendStringToDisplay(var); } - void DGUSScreenVariableHandler::SDCardInserted() { + void DGUSScreenHandler::SDCardInserted() { top_file = 0; filelist.refresh(); auto cs = ScreenHandler.getCurrentScreen(); @@ -402,15 +402,15 @@ void DGUSScreenVariableHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variab ScreenHandler.GotoScreen(DGUSLCD_SCREEN_SDFILELIST); } - void DGUSScreenVariableHandler::SDCardRemoved() { + void DGUSScreenHandler::SDCardRemoved() { if (current_screen == DGUSLCD_SCREEN_SDFILELIST || (current_screen == DGUSLCD_SCREEN_CONFIRM && (ConfirmVP == VP_SD_AbortPrintConfirmed || ConfirmVP == VP_SD_FileSelectConfirm)) || current_screen == DGUSLCD_SCREEN_SDPRINTMANIPULATION ) ScreenHandler.GotoScreen(DGUSLCD_SCREEN_MAIN); } - void DGUSScreenVariableHandler::SDCardError() { - DGUSScreenVariableHandler::SDCardRemoved(); + void DGUSScreenHandler::SDCardError() { + DGUSScreenHandler::SDCardRemoved(); ScreenHandler.sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("SD card error"), nullptr, true, true, true, true); ScreenHandler.SetupConfirmAction(nullptr); ScreenHandler.GotoScreen(DGUSLCD_SCREEN_POPUP); @@ -418,7 +418,7 @@ void DGUSScreenVariableHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variab #endif // SDSUPPORT -void DGUSScreenVariableHandler::ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr) { +void DGUSScreenHandler::ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr) { DGUS_VP_Variable ramcopy; if (!populate_VPVar(ConfirmVP, &ramcopy)) return; if (ramcopy.set_by_display_handler) ramcopy.set_by_display_handler(ramcopy, val_ptr); @@ -447,14 +447,14 @@ const DGUS_VP_Variable* DGUSLCD_FindVPVar(const uint16_t vp) { return nullptr; } -void DGUSScreenVariableHandler::ScreenChangeHookIfIdle(DGUS_VP_Variable &var, void *val_ptr) { +void DGUSScreenHandler::ScreenChangeHookIfIdle(DGUS_VP_Variable &var, void *val_ptr) { if (!ExtUI::isPrinting()) { ScreenChangeHook(var, val_ptr); dgusdisplay.RequestScreen(current_screen); } } -void DGUSScreenVariableHandler::ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr) { +void DGUSScreenHandler::ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr) { uint8_t *tmp = (uint8_t*)val_ptr; // The keycode in target is coded as , so 0x0100A means @@ -476,12 +476,12 @@ void DGUSScreenVariableHandler::ScreenChangeHook(DGUS_VP_Variable &var, void *va #endif } -void DGUSScreenVariableHandler::HandleAllHeatersOff(DGUS_VP_Variable &var, void *val_ptr) { +void DGUSScreenHandler::HandleAllHeatersOff(DGUS_VP_Variable &var, void *val_ptr) { thermalManager.disable_all_heaters(); ScreenHandler.ForceCompleteUpdate(); // hint to send all data. } -void DGUSScreenVariableHandler::HandleTemperatureChanged(DGUS_VP_Variable &var, void *val_ptr) { +void DGUSScreenHandler::HandleTemperatureChanged(DGUS_VP_Variable &var, void *val_ptr) { uint16_t newvalue = swap16(*(uint16_t*)val_ptr); uint16_t acceptedvalue; @@ -512,7 +512,7 @@ void DGUSScreenVariableHandler::HandleTemperatureChanged(DGUS_VP_Variable &var, ScreenHandler.skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } -void DGUSScreenVariableHandler::HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_ptr) { +void DGUSScreenHandler::HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_ptr) { #if EXTRUDERS uint16_t newvalue = swap16(*(uint16_t*)val_ptr); uint8_t target_extruder; @@ -533,7 +533,7 @@ void DGUSScreenVariableHandler::HandleFlowRateChanged(DGUS_VP_Variable &var, voi #endif } -void DGUSScreenVariableHandler::HandleManualExtrude(DGUS_VP_Variable &var, void *val_ptr) { +void DGUSScreenHandler::HandleManualExtrude(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleManualExtrude"); int16_t movevalue = swap16(*(uint16_t*)val_ptr); @@ -556,13 +556,13 @@ void DGUSScreenVariableHandler::HandleManualExtrude(DGUS_VP_Variable &var, void } #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) - void DGUSScreenVariableHandler::HandleManualMoveOption(DGUS_VP_Variable &var, void *val_ptr) { + void DGUSScreenHandler::HandleManualMoveOption(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleManualMoveOption"); *(uint16_t*)var.memadr = swap16(*(uint16_t*)val_ptr); } #endif -void DGUSScreenVariableHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { +void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleManualMove"); int16_t movevalue = swap16(*(uint16_t*)val_ptr); @@ -653,7 +653,7 @@ void DGUSScreenVariableHandler::HandleManualMove(DGUS_VP_Variable &var, void *va return; } -void DGUSScreenVariableHandler::HandleMotorLockUnlock(DGUS_VP_Variable &var, void *val_ptr) { +void DGUSScreenHandler::HandleMotorLockUnlock(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleMotorLockUnlock"); char buf[4]; @@ -666,7 +666,7 @@ void DGUSScreenVariableHandler::HandleMotorLockUnlock(DGUS_VP_Variable &var, voi #if ENABLED(POWER_LOSS_RECOVERY) - void DGUSScreenVariableHandler::HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr) { + void DGUSScreenHandler::HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr) { uint16_t value = swap16(*(uint16_t*)val_ptr); if (value) { queue.inject_P(PSTR("M1000")); @@ -680,7 +680,7 @@ void DGUSScreenVariableHandler::HandleMotorLockUnlock(DGUS_VP_Variable &var, voi #endif -void DGUSScreenVariableHandler::HandleSettings(DGUS_VP_Variable &var, void *val_ptr) { +void DGUSScreenHandler::HandleSettings(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleSettings"); uint16_t value = swap16(*(uint16_t*)val_ptr); switch (value) { @@ -694,7 +694,7 @@ void DGUSScreenVariableHandler::HandleSettings(DGUS_VP_Variable &var, void *val_ } } -void DGUSScreenVariableHandler::HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr) { +void DGUSScreenHandler::HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleStepPerMMChanged"); uint16_t value_raw = swap16(*(uint16_t*)val_ptr); @@ -714,7 +714,7 @@ void DGUSScreenVariableHandler::HandleStepPerMMChanged(DGUS_VP_Variable &var, vo return; } -void DGUSScreenVariableHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr) { +void DGUSScreenHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleStepPerMMExtruderChanged"); uint16_t value_raw = swap16(*(uint16_t*)val_ptr); @@ -738,7 +738,7 @@ void DGUSScreenVariableHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable } #if HAS_PID_HEATING - void DGUSScreenVariableHandler::HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr) { + void DGUSScreenHandler::HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr) { uint16_t rawvalue = swap16(*(uint16_t*)val_ptr); DEBUG_ECHOLNPAIR("V1:", rawvalue); float value = (float)rawvalue / 10; @@ -769,7 +769,7 @@ void DGUSScreenVariableHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable ScreenHandler.skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } - void DGUSScreenVariableHandler::HandlePIDAutotune(DGUS_VP_Variable &var, void *val_ptr) { + void DGUSScreenHandler::HandlePIDAutotune(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandlePIDAutotune"); char buf[32] = {0}; @@ -805,7 +805,7 @@ void DGUSScreenVariableHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable #endif #if HAS_BED_PROBE - void DGUSScreenVariableHandler::HandleProbeOffsetZChanged(DGUS_VP_Variable &var, void *val_ptr) { + void DGUSScreenHandler::HandleProbeOffsetZChanged(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleProbeOffsetZChanged"); const float offset = float(int16_t(swap16(*(uint16_t*)val_ptr))) / 100.0f; @@ -816,7 +816,7 @@ void DGUSScreenVariableHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable #endif #if ENABLED(BABYSTEPPING) - void DGUSScreenVariableHandler::HandleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr) { + void DGUSScreenHandler::HandleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleLiveAdjustZ"); int16_t flag = swap16(*(uint16_t*)val_ptr); @@ -828,13 +828,13 @@ void DGUSScreenVariableHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable #endif #if HAS_FAN - void DGUSScreenVariableHandler::HandleFanControl(DGUS_VP_Variable &var, void *val_ptr) { + void DGUSScreenHandler::HandleFanControl(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleFanControl"); *(uint8_t*)var.memadr = *(uint8_t*)var.memadr > 0 ? 0 : 255; } #endif -void DGUSScreenVariableHandler::HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr) { +void DGUSScreenHandler::HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleHeaterControl"); uint8_t preheat_temp = 0; @@ -861,7 +861,7 @@ void DGUSScreenVariableHandler::HandleHeaterControl(DGUS_VP_Variable &var, void #if ENABLED(DGUS_PREHEAT_UI) - void DGUSScreenVariableHandler::HandlePreheat(DGUS_VP_Variable &var, void *val_ptr) { + void DGUSScreenHandler::HandlePreheat(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandlePreheat"); uint8_t e_temp = 0; @@ -920,7 +920,7 @@ void DGUSScreenVariableHandler::HandleHeaterControl(DGUS_VP_Variable &var, void #endif #if ENABLED(DGUS_FILAMENT_LOADUNLOAD) - void DGUSScreenVariableHandler::HandleFilamentOption(DGUS_VP_Variable &var, void *val_ptr) { + void DGUSScreenHandler::HandleFilamentOption(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleFilamentOption"); uint8_t e_temp = 0; @@ -990,7 +990,7 @@ void DGUSScreenVariableHandler::HandleHeaterControl(DGUS_VP_Variable &var, void } } - void DGUSScreenVariableHandler::HandleFilamentLoadUnload(DGUS_VP_Variable &var) { + void DGUSScreenHandler::HandleFilamentLoadUnload(DGUS_VP_Variable &var) { DEBUG_ECHOLNPGM("HandleFilamentLoadUnload"); if (filament_data.action <= 0) return; @@ -1024,7 +1024,7 @@ void DGUSScreenVariableHandler::HandleHeaterControl(DGUS_VP_Variable &var, void } #endif -void DGUSScreenVariableHandler::UpdateNewScreen(DGUSLCD_Screens newscreen, bool popup) { +void DGUSScreenHandler::UpdateNewScreen(DGUSLCD_Screens newscreen, bool popup) { DEBUG_ECHOLNPAIR("SetNewScreen: ", newscreen); if (!popup) { @@ -1037,14 +1037,14 @@ void DGUSScreenVariableHandler::UpdateNewScreen(DGUSLCD_Screens newscreen, bool ForceCompleteUpdate(); } -void DGUSScreenVariableHandler::PopToOldScreen() { +void DGUSScreenHandler::PopToOldScreen() { DEBUG_ECHOLNPAIR("PopToOldScreen s=", past_screens[0]); GotoScreen(past_screens[0], true); memmove(&past_screens[0], &past_screens[1], sizeof(past_screens) - 1); past_screens[sizeof(past_screens) - 1] = DGUSLCD_SCREEN_MAIN; } -void DGUSScreenVariableHandler::UpdateScreenVPData() { +void DGUSScreenHandler::UpdateScreenVPData() { DEBUG_ECHOPAIR(" UpdateScreenVPData Screen: ", current_screen); const uint16_t *VPList = DGUSLCD_FindScreenVPMapList(current_screen); @@ -1092,12 +1092,12 @@ void DGUSScreenVariableHandler::UpdateScreenVPData() { } while (++update_ptr, ++VPList, true); } -void DGUSScreenVariableHandler::GotoScreen(DGUSLCD_Screens screen, bool ispopup) { +void DGUSScreenHandler::GotoScreen(DGUSLCD_Screens screen, bool ispopup) { dgusdisplay.RequestScreen(screen); UpdateNewScreen(screen, ispopup); } -bool DGUSScreenVariableHandler::loop() { +bool DGUSScreenHandler::loop() { dgusdisplay.loop(); const millis_t ms = millis(); diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.h b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.h index 7d965ee3cc09..6f21517ddf4b 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.h +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.h @@ -25,9 +25,9 @@ #include "../../../../inc/MarlinConfigPre.h" -class DGUSScreenVariableHandler { +class DGUSScreenHandler { public: - DGUSScreenVariableHandler() = default; + DGUSScreenHandler() = default; static bool loop(); @@ -240,4 +240,4 @@ class DGUSScreenVariableHandler { static void (*confirm_action_cb)(); }; -extern DGUSScreenVariableHandler ScreenHandler; +extern DGUSScreenHandler ScreenHandler; diff --git a/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp index d3a2a408e697..359a30b79525 100644 --- a/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp @@ -326,159 +326,159 @@ const char MarlinVersion[] PROGMEM = SHORT_BUILD_VERSION; const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { // Helper to detect touch events - VPHELPER(VP_SCREENCHANGE, nullptr, DGUSScreenVariableHandler::ScreenChangeHook, nullptr), - VPHELPER(VP_SCREENCHANGE_ASK, nullptr, DGUSScreenVariableHandler::ScreenChangeHookIfIdle, nullptr), + VPHELPER(VP_SCREENCHANGE, nullptr, ScreenHandler.ScreenChangeHook, nullptr), + VPHELPER(VP_SCREENCHANGE_ASK, nullptr, ScreenHandler.ScreenChangeHookIfIdle, nullptr), #if ENABLED(SDSUPPORT) - VPHELPER(VP_SCREENCHANGE_WHENSD, nullptr, DGUSScreenVariableHandler::ScreenChangeHookIfSD, nullptr), + VPHELPER(VP_SCREENCHANGE_WHENSD, nullptr, ScreenHandler.ScreenChangeHookIfSD, nullptr), #endif - VPHELPER(VP_CONFIRMED, nullptr, DGUSScreenVariableHandler::ScreenConfirmedOK, nullptr), + VPHELPER(VP_CONFIRMED, nullptr, ScreenHandler.ScreenConfirmedOK, nullptr), - VPHELPER(VP_TEMP_ALL_OFF, nullptr, &DGUSScreenVariableHandler::HandleAllHeatersOff, nullptr), + VPHELPER(VP_TEMP_ALL_OFF, nullptr, &ScreenHandler.HandleAllHeatersOff, nullptr), #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) - VPHELPER(VP_MOVE_OPTION, &distanceToMove, &DGUSScreenVariableHandler::HandleManualMoveOption, nullptr), + VPHELPER(VP_MOVE_OPTION, &distanceToMove, &ScreenHandler.HandleManualMoveOption, nullptr), #endif #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) - VPHELPER(VP_MOVE_X, &distanceToMove, &DGUSScreenVariableHandler::HandleManualMove, nullptr), - VPHELPER(VP_MOVE_Y, &distanceToMove, &DGUSScreenVariableHandler::HandleManualMove, nullptr), - VPHELPER(VP_MOVE_Z, &distanceToMove, &DGUSScreenVariableHandler::HandleManualMove, nullptr), - VPHELPER(VP_HOME_ALL, &distanceToMove, &DGUSScreenVariableHandler::HandleManualMove, nullptr), + VPHELPER(VP_MOVE_X, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_Y, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_Z, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_HOME_ALL, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr), #else - VPHELPER(VP_MOVE_X, nullptr, &DGUSScreenVariableHandler::HandleManualMove, nullptr), - VPHELPER(VP_MOVE_Y, nullptr, &DGUSScreenVariableHandler::HandleManualMove, nullptr), - VPHELPER(VP_MOVE_Z, nullptr, &DGUSScreenVariableHandler::HandleManualMove, nullptr), - VPHELPER(VP_HOME_ALL, nullptr, &DGUSScreenVariableHandler::HandleManualMove, nullptr), + VPHELPER(VP_MOVE_X, nullptr, &ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_Y, nullptr, &ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_Z, nullptr, &ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_HOME_ALL, nullptr, &ScreenHandler.HandleManualMove, nullptr), #endif - VPHELPER(VP_MOTOR_LOCK_UNLOK, nullptr, &DGUSScreenVariableHandler::HandleMotorLockUnlock, nullptr), + VPHELPER(VP_MOTOR_LOCK_UNLOK, nullptr, &ScreenHandler.HandleMotorLockUnlock, nullptr), #if ENABLED(POWER_LOSS_RECOVERY) - VPHELPER(VP_POWER_LOSS_RECOVERY, nullptr, &DGUSScreenVariableHandler::HandlePowerLossRecovery, nullptr), + VPHELPER(VP_POWER_LOSS_RECOVERY, nullptr, &ScreenHandler.HandlePowerLossRecovery, nullptr), #endif - VPHELPER(VP_SETTINGS, nullptr, &DGUSScreenVariableHandler::HandleSettings, nullptr), + VPHELPER(VP_SETTINGS, nullptr, &ScreenHandler.HandleSettings, nullptr), #if ENABLED(SINGLE_Z_CALIBRATION) - VPHELPER(VP_Z_CALIBRATE, nullptr, &DGUSScreenVariableHandler::HandleZCalibration, nullptr), + VPHELPER(VP_Z_CALIBRATE, nullptr, &ScreenHandler.HandleZCalibration, nullptr), #endif #if ENABLED(FIRST_LAYER_CAL) - VPHELPER(VP_Z_FIRST_LAYER_CAL, nullptr, &DGUSScreenVariableHandler::HandleFirstLayerCal, nullptr), + VPHELPER(VP_Z_FIRST_LAYER_CAL, nullptr, &ScreenHandler.HandleFirstLayerCal, nullptr), #endif - { .VP = VP_MARLIN_VERSION, .memadr = (void*)MarlinVersion, .size = VP_MARLIN_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MARLIN_VERSION, .memadr = (void*)MarlinVersion, .size = VP_MARLIN_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, // M117 LCD String (We don't need the string in memory but "just" push it to the display on demand, hence the nullptr - { .VP = VP_M117, .memadr = nullptr, .size = VP_M117_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplay }, + { .VP = VP_M117, .memadr = nullptr, .size = VP_M117_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&ScreenHandler.DGUSLCD_SendStringToDisplay }, // Temperature Data #if HOTENDS >= 1 - VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<0>), - VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, DGUSScreenVariableHandler::HandleTemperatureChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Flowrate_E0, &planner.flow_percentage[ExtUI::extruder_t::E0], DGUSScreenVariableHandler::HandleFlowRateChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_EPos, &destination.e, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<2>), - VPHELPER(VP_MOVE_E0, nullptr, &DGUSScreenVariableHandler::HandleManualExtrude, nullptr), - VPHELPER(VP_E0_CONTROL, &thermalManager.temp_hotend[0].target, &DGUSScreenVariableHandler::HandleHeaterControl, nullptr), - VPHELPER(VP_E0_STATUS, &thermalManager.temp_hotend[0].target, nullptr, &DGUSScreenVariableHandler::DGUSLCD_SendHeaterStatusToDisplay), + VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Flowrate_E0, &planner.flow_percentage[ExtUI::extruder_t::E0], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_EPos, &destination.e, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), + VPHELPER(VP_MOVE_E0, nullptr, &ScreenHandler.HandleManualExtrude, nullptr), + VPHELPER(VP_E0_CONTROL, &thermalManager.temp_hotend[0].target, &ScreenHandler.HandleHeaterControl, nullptr), + VPHELPER(VP_E0_STATUS, &thermalManager.temp_hotend[0].target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), #if ENABLED(DGUS_PREHEAT_UI) - VPHELPER(VP_E0_BED_PREHEAT, nullptr, &DGUSScreenVariableHandler::HandlePreheat, nullptr), + VPHELPER(VP_E0_BED_PREHEAT, nullptr, &ScreenHandler.HandlePreheat, nullptr), #endif #if ENABLED(PIDTEMP) - VPHELPER(VP_E0_PID_P, &thermalManager.temp_hotend[0].pid.Kp, DGUSScreenVariableHandler::HandleTemperaturePIDChanged, DGUSScreenVariableHandler::DGUSLCD_SendTemperaturePID), - VPHELPER(VP_E0_PID_I, &thermalManager.temp_hotend[0].pid.Ki, DGUSScreenVariableHandler::HandleTemperaturePIDChanged, DGUSScreenVariableHandler::DGUSLCD_SendTemperaturePID), - VPHELPER(VP_E0_PID_D, &thermalManager.temp_hotend[0].pid.Kd, DGUSScreenVariableHandler::HandleTemperaturePIDChanged, DGUSScreenVariableHandler::DGUSLCD_SendTemperaturePID), - VPHELPER(VP_PID_AUTOTUNE_E0, nullptr, &DGUSScreenVariableHandler::HandlePIDAutotune, nullptr), + VPHELPER(VP_E0_PID_P, &thermalManager.temp_hotend[0].pid.Kp, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), + VPHELPER(VP_E0_PID_I, &thermalManager.temp_hotend[0].pid.Ki, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), + VPHELPER(VP_E0_PID_D, &thermalManager.temp_hotend[0].pid.Kd, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), + VPHELPER(VP_PID_AUTOTUNE_E0, nullptr, &ScreenHandler.HandlePIDAutotune, nullptr), #endif #if ENABLED(DGUS_FILAMENT_LOADUNLOAD) - VPHELPER(VP_E0_FILAMENT_LOAD_UNLOAD, nullptr, &DGUSScreenVariableHandler::HandleFilamentOption, &DGUSScreenVariableHandler::HandleFilamentLoadUnload), + VPHELPER(VP_E0_FILAMENT_LOAD_UNLOAD, nullptr, &ScreenHandler.HandleFilamentOption, &ScreenHandler.HandleFilamentLoadUnload), #endif #endif #if HOTENDS >= 2 - VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<0>), - VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, DGUSScreenVariableHandler::HandleTemperatureChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Flowrate_E1, &planner.flow_percentage[ExtUI::extruder_t::E1], DGUSScreenVariableHandler::HandleFlowRateChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_MOVE_E1, nullptr, &DGUSScreenVariableHandler::HandleManualExtrude, nullptr), - VPHELPER(VP_E1_CONTROL, &thermalManager.temp_hotend[1].target, &DGUSScreenVariableHandler::HandleHeaterControl, nullptr), - VPHELPER(VP_E1_STATUS, &thermalManager.temp_hotend[1].target, nullptr, &DGUSScreenVariableHandler::DGUSLCD_SendHeaterStatusToDisplay), + VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Flowrate_E1, &planner.flow_percentage[ExtUI::extruder_t::E1], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_MOVE_E1, nullptr, &ScreenHandler.HandleManualExtrude, nullptr), + VPHELPER(VP_E1_CONTROL, &thermalManager.temp_hotend[1].target, &ScreenHandler.HandleHeaterControl, nullptr), + VPHELPER(VP_E1_STATUS, &thermalManager.temp_hotend[1].target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), #if ENABLED(PIDTEMP) - VPHELPER(VP_PID_AUTOTUNE_E1, nullptr, &DGUSScreenVariableHandler::HandlePIDAutotune, nullptr), + VPHELPER(VP_PID_AUTOTUNE_E1, nullptr, &ScreenHandler.HandlePIDAutotune, nullptr), #endif - VPHELPER(VP_E1_FILAMENT_LOAD_UNLOAD, nullptr, &DGUSScreenVariableHandler::HandleFilamentOption, &DGUSScreenVariableHandler::HandleFilamentLoadUnload), + VPHELPER(VP_E1_FILAMENT_LOAD_UNLOAD, nullptr, &ScreenHandler.HandleFilamentOption, &ScreenHandler.HandleFilamentLoadUnload), #endif #if HAS_HEATED_BED - VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<0>), - VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, DGUSScreenVariableHandler::HandleTemperatureChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &DGUSScreenVariableHandler::HandleHeaterControl, nullptr), - VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &DGUSScreenVariableHandler::DGUSLCD_SendHeaterStatusToDisplay), + VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &ScreenHandler.HandleHeaterControl, nullptr), + VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), #if ENABLED(PIDTEMPBED) - VPHELPER(VP_BED_PID_P, &thermalManager.temp_bed.pid.Kp, DGUSScreenVariableHandler::HandleTemperaturePIDChanged, DGUSScreenVariableHandler::DGUSLCD_SendTemperaturePID), - VPHELPER(VP_BED_PID_I, &thermalManager.temp_bed.pid.Ki, DGUSScreenVariableHandler::HandleTemperaturePIDChanged, DGUSScreenVariableHandler::DGUSLCD_SendTemperaturePID), - VPHELPER(VP_BED_PID_D, &thermalManager.temp_bed.pid.Kd, DGUSScreenVariableHandler::HandleTemperaturePIDChanged, DGUSScreenVariableHandler::DGUSLCD_SendTemperaturePID), - VPHELPER(VP_PID_AUTOTUNE_BED, nullptr, &DGUSScreenVariableHandler::HandlePIDAutotune, nullptr), + VPHELPER(VP_BED_PID_P, &thermalManager.temp_bed.pid.Kp, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), + VPHELPER(VP_BED_PID_I, &thermalManager.temp_bed.pid.Ki, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), + VPHELPER(VP_BED_PID_D, &thermalManager.temp_bed.pid.Kd, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), + VPHELPER(VP_PID_AUTOTUNE_BED, nullptr, &ScreenHandler.HandlePIDAutotune, nullptr), #endif #endif // Fan Data #if HAS_FAN #define FAN_VPHELPER(N) \ - VPHELPER(VP_Fan##N##_Percentage, &thermalManager.fan_speed[N], DGUSScreenVariableHandler::DGUSLCD_PercentageToUint8, &DGUSScreenVariableHandler::DGUSLCD_SendPercentageToDisplay), \ - VPHELPER(VP_FAN##N##_CONTROL, &thermalManager.fan_speed[N], &DGUSScreenVariableHandler::HandleFanControl, nullptr), \ - VPHELPER(VP_FAN##N##_STATUS, &thermalManager.fan_speed[N], nullptr, &DGUSScreenVariableHandler::DGUSLCD_SendFanStatusToDisplay), + VPHELPER(VP_Fan##N##_Percentage, &thermalManager.fan_speed[N], ScreenHandler.DGUSLCD_PercentageToUint8, &ScreenHandler.DGUSLCD_SendPercentageToDisplay), \ + VPHELPER(VP_FAN##N##_CONTROL, &thermalManager.fan_speed[N], &ScreenHandler.HandleFanControl, nullptr), \ + VPHELPER(VP_FAN##N##_STATUS, &thermalManager.fan_speed[N], nullptr, &ScreenHandler.DGUSLCD_SendFanStatusToDisplay), REPEAT(FAN_COUNT, FAN_VPHELPER) #endif // Feedrate - VPHELPER(VP_Feedrate_Percentage, &feedrate_percentage, DGUSScreenVariableHandler::DGUSLCD_SetValueDirectly, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay ), + VPHELPER(VP_Feedrate_Percentage, &feedrate_percentage, ScreenHandler.DGUSLCD_SetValueDirectly, &ScreenHandler.DGUSLCD_SendWordValueToDisplay ), // Position Data - VPHELPER(VP_XPos, ¤t_position.x, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<2>), - VPHELPER(VP_YPos, ¤t_position.y, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<2>), - VPHELPER(VP_ZPos, ¤t_position.z, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<2>), + VPHELPER(VP_XPos, ¤t_position.x, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), + VPHELPER(VP_YPos, ¤t_position.y, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), + VPHELPER(VP_ZPos, ¤t_position.z, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), // Print Progress - VPHELPER(VP_PrintProgress_Percentage, nullptr, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendPrintProgressToDisplay ), + VPHELPER(VP_PrintProgress_Percentage, nullptr, nullptr, ScreenHandler.DGUSLCD_SendPrintProgressToDisplay ), // Print Time - VPHELPER_STR(VP_PrintTime, nullptr, VP_PrintTime_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendPrintTimeToDisplay), + VPHELPER_STR(VP_PrintTime, nullptr, VP_PrintTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintTimeToDisplay), #if ENABLED(PRINTCOUNTER) - VPHELPER_STR(VP_PrintAccTime, nullptr, VP_PrintAccTime_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendPrintAccTimeToDisplay), - VPHELPER_STR(VP_PrintsTotal, nullptr, VP_PrintsTotal_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendPrintsTotalToDisplay), + VPHELPER_STR(VP_PrintAccTime, nullptr, VP_PrintAccTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintAccTimeToDisplay), + VPHELPER_STR(VP_PrintsTotal, nullptr, VP_PrintsTotal_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintsTotalToDisplay), #endif - VPHELPER(VP_X_STEP_PER_MM, &planner.settings.axis_steps_per_mm[X_AXIS], DGUSScreenVariableHandler::HandleStepPerMMChanged, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<1>), - VPHELPER(VP_Y_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Y_AXIS], DGUSScreenVariableHandler::HandleStepPerMMChanged, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<1>), - VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], DGUSScreenVariableHandler::HandleStepPerMMChanged, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<1>), + VPHELPER(VP_X_STEP_PER_MM, &planner.settings.axis_steps_per_mm[X_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), + VPHELPER(VP_Y_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Y_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), + VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), #if HOTENDS >= 1 - VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], DGUSScreenVariableHandler::HandleStepPerMMExtruderChanged, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<1>), + VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), #endif #if HOTENDS >= 2 - VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], DGUSScreenVariableHandler::HandleStepPerMMExtruderChanged, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<1>), + VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), #endif // SDCard File listing. #if ENABLED(SDSUPPORT) - VPHELPER(VP_SD_ScrollEvent, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ScrollFilelist, nullptr), - VPHELPER(VP_SD_FileSelected, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_FileSelected, nullptr), - VPHELPER(VP_SD_FileSelectConfirm, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_StartPrint, nullptr), - VPHELPER_STR(VP_SD_FileName0, nullptr, VP_SD_FileName_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_SendFilename), - VPHELPER_STR(VP_SD_FileName1, nullptr, VP_SD_FileName_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_SendFilename), - VPHELPER_STR(VP_SD_FileName2, nullptr, VP_SD_FileName_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_SendFilename), - VPHELPER_STR(VP_SD_FileName3, nullptr, VP_SD_FileName_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_SendFilename), - VPHELPER_STR(VP_SD_FileName4, nullptr, VP_SD_FileName_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_SendFilename), - VPHELPER(VP_SD_ResumePauseAbort, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ResumePauseAbort, nullptr), - VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ReallyAbort, nullptr), - VPHELPER(VP_SD_Print_Setting, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_PrintTune, nullptr), + VPHELPER(VP_SD_ScrollEvent, nullptr, ScreenHandler.DGUSLCD_SD_ScrollFilelist, nullptr), + VPHELPER(VP_SD_FileSelected, nullptr, ScreenHandler.DGUSLCD_SD_FileSelected, nullptr), + VPHELPER(VP_SD_FileSelectConfirm, nullptr, ScreenHandler.DGUSLCD_SD_StartPrint, nullptr), + VPHELPER_STR(VP_SD_FileName0, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename), + VPHELPER_STR(VP_SD_FileName1, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename), + VPHELPER_STR(VP_SD_FileName2, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename), + VPHELPER_STR(VP_SD_FileName3, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename), + VPHELPER_STR(VP_SD_FileName4, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename), + VPHELPER(VP_SD_ResumePauseAbort, nullptr, ScreenHandler.DGUSLCD_SD_ResumePauseAbort, nullptr), + VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, ScreenHandler.DGUSLCD_SD_ReallyAbort, nullptr), + VPHELPER(VP_SD_Print_Setting, nullptr, ScreenHandler.DGUSLCD_SD_PrintTune, nullptr), #if HAS_BED_PROBE - VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe.offset.z, DGUSScreenVariableHandler::HandleProbeOffsetZChanged, &DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<2>), + VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe.offset.z, ScreenHandler.HandleProbeOffsetZChanged, &ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>), #if ENABLED(BABYSTEPPING) - VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, DGUSScreenVariableHandler::HandleLiveAdjustZ, nullptr), + VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, ScreenHandler.HandleLiveAdjustZ, nullptr), #endif #endif #endif #if ENABLED(DGUS_UI_WAITING) - VPHELPER(VP_WAITING_STATUS, nullptr, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendWaitingStatusToDisplay), + VPHELPER(VP_WAITING_STATUS, nullptr, nullptr, ScreenHandler.DGUSLCD_SendWaitingStatusToDisplay), #endif // Messages for the User, shared by the popup and the kill screen. They cant be autouploaded as we do not buffer content. - { .VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM }, - { .VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM }, - { .VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM }, - { .VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, VPHELPER(0, 0, 0, 0) // must be last entry. }; diff --git a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp index 31864fecd0f6..84917e688f58 100644 --- a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp @@ -329,155 +329,155 @@ const char MarlinVersion[] PROGMEM = SHORT_BUILD_VERSION; const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { // Helper to detect touch events - VPHELPER(VP_SCREENCHANGE, nullptr, DGUSScreenVariableHandler::ScreenChangeHook, nullptr), - VPHELPER(VP_SCREENCHANGE_ASK, nullptr, DGUSScreenVariableHandler::ScreenChangeHookIfIdle, nullptr), + VPHELPER(VP_SCREENCHANGE, nullptr, ScreenHandler.ScreenChangeHook, nullptr), + VPHELPER(VP_SCREENCHANGE_ASK, nullptr, ScreenHandler.ScreenChangeHookIfIdle, nullptr), #if ENABLED(SDSUPPORT) - VPHELPER(VP_SCREENCHANGE_WHENSD, nullptr, DGUSScreenVariableHandler::ScreenChangeHookIfSD, nullptr), + VPHELPER(VP_SCREENCHANGE_WHENSD, nullptr, ScreenHandler.ScreenChangeHookIfSD, nullptr), #endif - VPHELPER(VP_CONFIRMED, nullptr, DGUSScreenVariableHandler::ScreenConfirmedOK, nullptr), + VPHELPER(VP_CONFIRMED, nullptr, ScreenHandler.ScreenConfirmedOK, nullptr), - VPHELPER(VP_TEMP_ALL_OFF, nullptr, &DGUSScreenVariableHandler::HandleAllHeatersOff, nullptr), + VPHELPER(VP_TEMP_ALL_OFF, nullptr, &ScreenHandler.HandleAllHeatersOff, nullptr), #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) - VPHELPER(VP_MOVE_OPTION, &distanceToMove, &DGUSScreenVariableHandler::HandleManualMoveOption, nullptr), + VPHELPER(VP_MOVE_OPTION, &distanceToMove, &ScreenHandler.HandleManualMoveOption, nullptr), #endif #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) - VPHELPER(VP_MOVE_X, &distanceToMove, &DGUSScreenVariableHandler::HandleManualMove, nullptr), - VPHELPER(VP_MOVE_Y, &distanceToMove, &DGUSScreenVariableHandler::HandleManualMove, nullptr), - VPHELPER(VP_MOVE_Z, &distanceToMove, &DGUSScreenVariableHandler::HandleManualMove, nullptr), - VPHELPER(VP_HOME_ALL, &distanceToMove, &DGUSScreenVariableHandler::HandleManualMove, nullptr), + VPHELPER(VP_MOVE_X, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_Y, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_Z, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_HOME_ALL, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr), #else - VPHELPER(VP_MOVE_X, nullptr, &DGUSScreenVariableHandler::HandleManualMove, nullptr), - VPHELPER(VP_MOVE_Y, nullptr, &DGUSScreenVariableHandler::HandleManualMove, nullptr), - VPHELPER(VP_MOVE_Z, nullptr, &DGUSScreenVariableHandler::HandleManualMove, nullptr), - VPHELPER(VP_HOME_ALL, nullptr, &DGUSScreenVariableHandler::HandleManualMove, nullptr), + VPHELPER(VP_MOVE_X, nullptr, &ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_Y, nullptr, &ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_Z, nullptr, &ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_HOME_ALL, nullptr, &ScreenHandler.HandleManualMove, nullptr), #endif - VPHELPER(VP_MOTOR_LOCK_UNLOK, nullptr, &DGUSScreenVariableHandler::HandleMotorLockUnlock, nullptr), + VPHELPER(VP_MOTOR_LOCK_UNLOK, nullptr, &ScreenHandler.HandleMotorLockUnlock, nullptr), #if ENABLED(POWER_LOSS_RECOVERY) - VPHELPER(VP_POWER_LOSS_RECOVERY, nullptr, &DGUSScreenVariableHandler::HandlePowerLossRecovery, nullptr), + VPHELPER(VP_POWER_LOSS_RECOVERY, nullptr, &ScreenHandler.HandlePowerLossRecovery, nullptr), #endif - VPHELPER(VP_SETTINGS, nullptr, &DGUSScreenVariableHandler::HandleSettings, nullptr), + VPHELPER(VP_SETTINGS, nullptr, &ScreenHandler.HandleSettings, nullptr), #if ENABLED(SINGLE_Z_CALIBRATION) - VPHELPER(VP_Z_CALIBRATE, nullptr, &DGUSScreenVariableHandler::HandleZCalibration, nullptr), + VPHELPER(VP_Z_CALIBRATE, nullptr, &ScreenHandler.HandleZCalibration, nullptr), #endif #if ENABLED(FIRST_LAYER_CAL) - VPHELPER(VP_Z_FIRST_LAYER_CAL, nullptr, &DGUSScreenVariableHandler::HandleFirstLayerCal, nullptr), + VPHELPER(VP_Z_FIRST_LAYER_CAL, nullptr, &ScreenHandler.HandleFirstLayerCal, nullptr), #endif - { .VP = VP_MARLIN_VERSION, .memadr = (void*)MarlinVersion, .size = VP_MARLIN_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MARLIN_VERSION, .memadr = (void*)MarlinVersion, .size = VP_MARLIN_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, // M117 LCD String (We don't need the string in memory but "just" push it to the display on demand, hence the nullptr - { .VP = VP_M117, .memadr = nullptr, .size = VP_M117_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplay }, + { .VP = VP_M117, .memadr = nullptr, .size = VP_M117_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&ScreenHandler.DGUSLCD_SendStringToDisplay }, // Temperature Data #if HOTENDS >= 1 - VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<0>), - VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, DGUSScreenVariableHandler::HandleTemperatureChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Flowrate_E0, &planner.flow_percentage[ExtUI::extruder_t::E0], DGUSScreenVariableHandler::HandleFlowRateChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_EPos, &destination.e, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<2>), - VPHELPER(VP_MOVE_E0, nullptr, &DGUSScreenVariableHandler::HandleManualExtrude, nullptr), - VPHELPER(VP_E0_CONTROL, &thermalManager.temp_hotend[0].target, &DGUSScreenVariableHandler::HandleHeaterControl, nullptr), - VPHELPER(VP_E0_STATUS, &thermalManager.temp_hotend[0].target, nullptr, &DGUSScreenVariableHandler::DGUSLCD_SendHeaterStatusToDisplay), + VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Flowrate_E0, &planner.flow_percentage[ExtUI::extruder_t::E0], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_EPos, &destination.e, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), + VPHELPER(VP_MOVE_E0, nullptr, &ScreenHandler.HandleManualExtrude, nullptr), + VPHELPER(VP_E0_CONTROL, &thermalManager.temp_hotend[0].target, &ScreenHandler.HandleHeaterControl, nullptr), + VPHELPER(VP_E0_STATUS, &thermalManager.temp_hotend[0].target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), #if ENABLED(DGUS_PREHEAT_UI) - VPHELPER(VP_E0_BED_PREHEAT, nullptr, &DGUSScreenVariableHandler::HandlePreheat, nullptr), + VPHELPER(VP_E0_BED_PREHEAT, nullptr, &ScreenHandler.HandlePreheat, nullptr), #endif #if ENABLED(DGUS_FILAMENT_LOADUNLOAD) - VPHELPER(VP_E0_FILAMENT_LOAD_UNLOAD, nullptr, &DGUSScreenVariableHandler::HandleFilamentOption, &DGUSScreenVariableHandler::HandleFilamentLoadUnload), + VPHELPER(VP_E0_FILAMENT_LOAD_UNLOAD, nullptr, &ScreenHandler.HandleFilamentOption, &ScreenHandler.HandleFilamentLoadUnload), #endif #if ENABLED(PIDTEMP) - VPHELPER(VP_E0_PID_P, &thermalManager.temp_hotend[0].pid.Kp, DGUSScreenVariableHandler::HandleTemperaturePIDChanged, DGUSScreenVariableHandler::DGUSLCD_SendTemperaturePID), - VPHELPER(VP_E0_PID_I, &thermalManager.temp_hotend[0].pid.Ki, DGUSScreenVariableHandler::HandleTemperaturePIDChanged, DGUSScreenVariableHandler::DGUSLCD_SendTemperaturePID), - VPHELPER(VP_E0_PID_D, &thermalManager.temp_hotend[0].pid.Kd, DGUSScreenVariableHandler::HandleTemperaturePIDChanged, DGUSScreenVariableHandler::DGUSLCD_SendTemperaturePID), - VPHELPER(VP_PID_AUTOTUNE_E0, nullptr, &DGUSScreenVariableHandler::HandlePIDAutotune, nullptr), + VPHELPER(VP_E0_PID_P, &thermalManager.temp_hotend[0].pid.Kp, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), + VPHELPER(VP_E0_PID_I, &thermalManager.temp_hotend[0].pid.Ki, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), + VPHELPER(VP_E0_PID_D, &thermalManager.temp_hotend[0].pid.Kd, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), + VPHELPER(VP_PID_AUTOTUNE_E0, nullptr, &ScreenHandler.HandlePIDAutotune, nullptr), #endif #endif #if HOTENDS >= 2 VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, DGUSLCD_SendFloatAsLongValueToDisplay<0>), - VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, DGUSScreenVariableHandler::HandleTemperatureChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Flowrate_E1, nullptr, DGUSScreenVariableHandler::HandleFlowRateChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_MOVE_E1, nullptr, &DGUSScreenVariableHandler::HandleManualExtrude, nullptr), - VPHELPER(VP_E1_CONTROL, &thermalManager.temp_hotend[1].target, &DGUSScreenVariableHandler::HandleHeaterControl, nullptr), - VPHELPER(VP_E1_STATUS, &thermalManager.temp_hotend[1].target, nullptr, &DGUSScreenVariableHandler::DGUSLCD_SendHeaterStatusToDisplay), + VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Flowrate_E1, nullptr, ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_MOVE_E1, nullptr, &ScreenHandler.HandleManualExtrude, nullptr), + VPHELPER(VP_E1_CONTROL, &thermalManager.temp_hotend[1].target, &ScreenHandler.HandleHeaterControl, nullptr), + VPHELPER(VP_E1_STATUS, &thermalManager.temp_hotend[1].target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), #endif #if HAS_HEATED_BED - VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<0>), - VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, DGUSScreenVariableHandler::HandleTemperatureChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &DGUSScreenVariableHandler::HandleHeaterControl, nullptr), - VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &DGUSScreenVariableHandler::DGUSLCD_SendHeaterStatusToDisplay), + VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &ScreenHandler.HandleHeaterControl, nullptr), + VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), #if ENABLED(PIDTEMP) - VPHELPER(VP_BED_PID_P, &thermalManager.temp_bed.pid.Kp, DGUSScreenVariableHandler::HandleTemperaturePIDChanged, DGUSScreenVariableHandler::DGUSLCD_SendTemperaturePID), - VPHELPER(VP_BED_PID_I, &thermalManager.temp_bed.pid.Ki, DGUSScreenVariableHandler::HandleTemperaturePIDChanged, DGUSScreenVariableHandler::DGUSLCD_SendTemperaturePID), - VPHELPER(VP_BED_PID_D, &thermalManager.temp_bed.pid.Kd, DGUSScreenVariableHandler::HandleTemperaturePIDChanged, DGUSScreenVariableHandler::DGUSLCD_SendTemperaturePID), - VPHELPER(VP_PID_AUTOTUNE_BED, nullptr, &DGUSScreenVariableHandler::HandlePIDAutotune, nullptr), + VPHELPER(VP_BED_PID_P, &thermalManager.temp_bed.pid.Kp, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), + VPHELPER(VP_BED_PID_I, &thermalManager.temp_bed.pid.Ki, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), + VPHELPER(VP_BED_PID_D, &thermalManager.temp_bed.pid.Kd, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), + VPHELPER(VP_PID_AUTOTUNE_BED, nullptr, &ScreenHandler.HandlePIDAutotune, nullptr), #endif #endif // Fan Data #if HAS_FAN #define FAN_VPHELPER(N) \ - VPHELPER(VP_Fan##N##_Percentage, &thermalManager.fan_speed[N], DGUSScreenVariableHandler::DGUSLCD_PercentageToUint8, &DGUSScreenVariableHandler::DGUSLCD_SendPercentageToDisplay), \ - VPHELPER(VP_FAN##N##_CONTROL, &thermalManager.fan_speed[N], &DGUSScreenVariableHandler::HandleFanControl, nullptr), \ - VPHELPER(VP_FAN##N##_STATUS, &thermalManager.fan_speed[N], nullptr, &DGUSScreenVariableHandler::DGUSLCD_SendFanStatusToDisplay), + VPHELPER(VP_Fan##N##_Percentage, &thermalManager.fan_speed[N], ScreenHandler.DGUSLCD_PercentageToUint8, &ScreenHandler.DGUSLCD_SendPercentageToDisplay), \ + VPHELPER(VP_FAN##N##_CONTROL, &thermalManager.fan_speed[N], &ScreenHandler.HandleFanControl, nullptr), \ + VPHELPER(VP_FAN##N##_STATUS, &thermalManager.fan_speed[N], nullptr, &ScreenHandler.DGUSLCD_SendFanStatusToDisplay), REPEAT(FAN_COUNT, FAN_VPHELPER) #endif // Feedrate - VPHELPER(VP_Feedrate_Percentage, &feedrate_percentage, DGUSScreenVariableHandler::DGUSLCD_SetValueDirectly, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay ), + VPHELPER(VP_Feedrate_Percentage, &feedrate_percentage, ScreenHandler.DGUSLCD_SetValueDirectly, &ScreenHandler.DGUSLCD_SendWordValueToDisplay ), // Position Data - VPHELPER(VP_XPos, ¤t_position.x, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<2>), - VPHELPER(VP_YPos, ¤t_position.y, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<2>), - VPHELPER(VP_ZPos, ¤t_position.z, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<2>), + VPHELPER(VP_XPos, ¤t_position.x, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), + VPHELPER(VP_YPos, ¤t_position.y, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), + VPHELPER(VP_ZPos, ¤t_position.z, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), // Print Progress - VPHELPER(VP_PrintProgress_Percentage, nullptr, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendPrintProgressToDisplay ), + VPHELPER(VP_PrintProgress_Percentage, nullptr, nullptr, ScreenHandler.DGUSLCD_SendPrintProgressToDisplay ), // Print Time - VPHELPER_STR(VP_PrintTime, nullptr, VP_PrintTime_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendPrintTimeToDisplay ), + VPHELPER_STR(VP_PrintTime, nullptr, VP_PrintTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintTimeToDisplay ), #if ENABLED(PRINTCOUNTER) - VPHELPER_STR(VP_PrintAccTime, nullptr, VP_PrintAccTime_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendPrintAccTimeToDisplay ), - VPHELPER_STR(VP_PrintsTotal, nullptr, VP_PrintsTotal_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendPrintsTotalToDisplay ), + VPHELPER_STR(VP_PrintAccTime, nullptr, VP_PrintAccTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintAccTimeToDisplay ), + VPHELPER_STR(VP_PrintsTotal, nullptr, VP_PrintsTotal_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintsTotalToDisplay ), #endif - VPHELPER(VP_X_STEP_PER_MM, &planner.settings.axis_steps_per_mm[X_AXIS], DGUSScreenVariableHandler::HandleStepPerMMChanged, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<1>), - VPHELPER(VP_Y_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Y_AXIS], DGUSScreenVariableHandler::HandleStepPerMMChanged, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<1>), - VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], DGUSScreenVariableHandler::HandleStepPerMMChanged, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<1>), + VPHELPER(VP_X_STEP_PER_MM, &planner.settings.axis_steps_per_mm[X_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), + VPHELPER(VP_Y_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Y_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), + VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), #if HOTENDS >= 1 - VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], DGUSScreenVariableHandler::HandleStepPerMMExtruderChanged, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<1>), + VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), #endif #if HOTENDS >= 2 - VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], DGUSScreenVariableHandler::HandleStepPerMMExtruderChanged, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<1>), + VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), #endif // SDCard File listing. #if ENABLED(SDSUPPORT) - VPHELPER(VP_SD_ScrollEvent, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ScrollFilelist, nullptr), - VPHELPER(VP_SD_FileSelected, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_FileSelected, nullptr), - VPHELPER(VP_SD_FileSelectConfirm, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_StartPrint, nullptr), - VPHELPER_STR(VP_SD_FileName0, nullptr, VP_SD_FileName_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_SendFilename ), - VPHELPER_STR(VP_SD_FileName1, nullptr, VP_SD_FileName_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_SendFilename ), - VPHELPER_STR(VP_SD_FileName2, nullptr, VP_SD_FileName_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_SendFilename ), - VPHELPER_STR(VP_SD_FileName3, nullptr, VP_SD_FileName_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_SendFilename ), - VPHELPER_STR(VP_SD_FileName4, nullptr, VP_SD_FileName_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_SendFilename ), - VPHELPER(VP_SD_ResumePauseAbort, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ResumePauseAbort, nullptr), - VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ReallyAbort, nullptr), - VPHELPER(VP_SD_Print_Setting, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_PrintTune, nullptr), + VPHELPER(VP_SD_ScrollEvent, nullptr, ScreenHandler.DGUSLCD_SD_ScrollFilelist, nullptr), + VPHELPER(VP_SD_FileSelected, nullptr, ScreenHandler.DGUSLCD_SD_FileSelected, nullptr), + VPHELPER(VP_SD_FileSelectConfirm, nullptr, ScreenHandler.DGUSLCD_SD_StartPrint, nullptr), + VPHELPER_STR(VP_SD_FileName0, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ), + VPHELPER_STR(VP_SD_FileName1, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ), + VPHELPER_STR(VP_SD_FileName2, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ), + VPHELPER_STR(VP_SD_FileName3, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ), + VPHELPER_STR(VP_SD_FileName4, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ), + VPHELPER(VP_SD_ResumePauseAbort, nullptr, ScreenHandler.DGUSLCD_SD_ResumePauseAbort, nullptr), + VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, ScreenHandler.DGUSLCD_SD_ReallyAbort, nullptr), + VPHELPER(VP_SD_Print_Setting, nullptr, ScreenHandler.DGUSLCD_SD_PrintTune, nullptr), #if HAS_BED_PROBE - VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe.offset.z, DGUSScreenVariableHandler::HandleProbeOffsetZChanged, &DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<2>), + VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe.offset.z, ScreenHandler.HandleProbeOffsetZChanged, &ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>), #if ENABLED(BABYSTEPPING) - VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, DGUSScreenVariableHandler::HandleLiveAdjustZ, nullptr), + VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, ScreenHandler.HandleLiveAdjustZ, nullptr), #endif #endif #endif #if ENABLED(DGUS_UI_WAITING) - VPHELPER(VP_WAITING_STATUS, nullptr, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendWaitingStatusToDisplay), + VPHELPER(VP_WAITING_STATUS, nullptr, nullptr, ScreenHandler.DGUSLCD_SendWaitingStatusToDisplay), #endif // Messages for the User, shared by the popup and the kill screen. They cant be autouploaded as we do not buffer content. - { .VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM }, - { .VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM }, - { .VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM }, - { .VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, VPHELPER(0, 0, 0, 0) // must be last entry. }; diff --git a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp index 458f0805badd..87414570ee71 100644 --- a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp @@ -154,152 +154,152 @@ const char MarlinVersion[] PROGMEM = SHORT_BUILD_VERSION; const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { // Helper to detect touch events - VPHELPER(VP_SCREENCHANGE, nullptr, DGUSScreenVariableHandler::ScreenChangeHook, nullptr), - VPHELPER(VP_SCREENCHANGE_ASK, nullptr, DGUSScreenVariableHandler::ScreenChangeHookIfIdle, nullptr), + VPHELPER(VP_SCREENCHANGE, nullptr, ScreenHandler.ScreenChangeHook, nullptr), + VPHELPER(VP_SCREENCHANGE_ASK, nullptr, ScreenHandler.ScreenChangeHookIfIdle, nullptr), #if ENABLED(SDSUPPORT) - VPHELPER(VP_SCREENCHANGE_WHENSD, nullptr, DGUSScreenVariableHandler::ScreenChangeHookIfSD, nullptr), + VPHELPER(VP_SCREENCHANGE_WHENSD, nullptr, ScreenHandler.ScreenChangeHookIfSD, nullptr), #endif - VPHELPER(VP_CONFIRMED, nullptr, DGUSScreenVariableHandler::ScreenConfirmedOK, nullptr), + VPHELPER(VP_CONFIRMED, nullptr, ScreenHandler.ScreenConfirmedOK, nullptr), - VPHELPER(VP_TEMP_ALL_OFF, nullptr, &DGUSScreenVariableHandler::HandleAllHeatersOff, nullptr), + VPHELPER(VP_TEMP_ALL_OFF, nullptr, &ScreenHandler.HandleAllHeatersOff, nullptr), #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) - VPHELPER(VP_MOVE_OPTION, &distanceToMove, &DGUSScreenVariableHandler::HandleManualMoveOption, nullptr), + VPHELPER(VP_MOVE_OPTION, &distanceToMove, &ScreenHandler.HandleManualMoveOption, nullptr), #endif #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) - VPHELPER(VP_MOVE_X, &distanceToMove, &DGUSScreenVariableHandler::HandleManualMove, nullptr), - VPHELPER(VP_MOVE_Y, &distanceToMove, &DGUSScreenVariableHandler::HandleManualMove, nullptr), - VPHELPER(VP_MOVE_Z, &distanceToMove, &DGUSScreenVariableHandler::HandleManualMove, nullptr), - VPHELPER(VP_HOME_ALL, &distanceToMove, &DGUSScreenVariableHandler::HandleManualMove, nullptr), + VPHELPER(VP_MOVE_X, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_Y, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_Z, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_HOME_ALL, &distanceToMove, &ScreenHandler.HandleManualMove, nullptr), #else - VPHELPER(VP_MOVE_X, nullptr, &DGUSScreenVariableHandler::HandleManualMove, nullptr), - VPHELPER(VP_MOVE_Y, nullptr, &DGUSScreenVariableHandler::HandleManualMove, nullptr), - VPHELPER(VP_MOVE_Z, nullptr, &DGUSScreenVariableHandler::HandleManualMove, nullptr), - VPHELPER(VP_HOME_ALL, nullptr, &DGUSScreenVariableHandler::HandleManualMove, nullptr), + VPHELPER(VP_MOVE_X, nullptr, &ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_Y, nullptr, &ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_MOVE_Z, nullptr, &ScreenHandler.HandleManualMove, nullptr), + VPHELPER(VP_HOME_ALL, nullptr, &ScreenHandler.HandleManualMove, nullptr), #endif - VPHELPER(VP_MOTOR_LOCK_UNLOK, nullptr, &DGUSScreenVariableHandler::HandleMotorLockUnlock, nullptr), + VPHELPER(VP_MOTOR_LOCK_UNLOK, nullptr, &ScreenHandler.HandleMotorLockUnlock, nullptr), #if ENABLED(POWER_LOSS_RECOVERY) - VPHELPER(VP_POWER_LOSS_RECOVERY, nullptr, &DGUSScreenVariableHandler::HandlePowerLossRecovery, nullptr), + VPHELPER(VP_POWER_LOSS_RECOVERY, nullptr, &ScreenHandler.HandlePowerLossRecovery, nullptr), #endif - VPHELPER(VP_SETTINGS, nullptr, &DGUSScreenVariableHandler::HandleSettings, nullptr), + VPHELPER(VP_SETTINGS, nullptr, &ScreenHandler.HandleSettings, nullptr), - { .VP = VP_MARLIN_VERSION, .memadr = (void*)MarlinVersion, .size = VP_MARLIN_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MARLIN_VERSION, .memadr = (void*)MarlinVersion, .size = VP_MARLIN_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, // M117 LCD String (We don't need the string in memory but "just" push it to the display on demand, hence the nullptr - { .VP = VP_M117, .memadr = nullptr, .size = VP_M117_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplay }, + { .VP = VP_M117, .memadr = nullptr, .size = VP_M117_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&ScreenHandler.DGUSLCD_SendStringToDisplay }, // Temperature Data #if HOTENDS >= 1 - VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<0>), - VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, DGUSScreenVariableHandler::HandleTemperatureChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Flowrate_E0, nullptr, DGUSScreenVariableHandler::HandleFlowRateChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_EPos, &destination.e, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<2>), - VPHELPER(VP_MOVE_E0, nullptr, &DGUSScreenVariableHandler::HandleManualExtrude, nullptr), - VPHELPER(VP_E0_CONTROL, &thermalManager.temp_hotend[0].target, &DGUSScreenVariableHandler::HandleHeaterControl, nullptr), - VPHELPER(VP_E0_STATUS, &thermalManager.temp_hotend[0].target, nullptr, &DGUSScreenVariableHandler::DGUSLCD_SendHeaterStatusToDisplay), + VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Flowrate_E0, nullptr, ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_EPos, &destination.e, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), + VPHELPER(VP_MOVE_E0, nullptr, &ScreenHandler.HandleManualExtrude, nullptr), + VPHELPER(VP_E0_CONTROL, &thermalManager.temp_hotend[0].target, &ScreenHandler.HandleHeaterControl, nullptr), + VPHELPER(VP_E0_STATUS, &thermalManager.temp_hotend[0].target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), #if ENABLED(DGUS_PREHEAT_UI) - VPHELPER(VP_E0_BED_PREHEAT, nullptr, &DGUSScreenVariableHandler::HandlePreheat, nullptr), + VPHELPER(VP_E0_BED_PREHEAT, nullptr, &ScreenHandler.HandlePreheat, nullptr), #endif #if ENABLED(PIDTEMP) - VPHELPER(VP_E0_PID_P, &thermalManager.temp_hotend[0].pid.Kp, DGUSScreenVariableHandler::HandleTemperaturePIDChanged, DGUSScreenVariableHandler::DGUSLCD_SendTemperaturePID), - VPHELPER(VP_E0_PID_I, &thermalManager.temp_hotend[0].pid.Ki, DGUSScreenVariableHandler::HandleTemperaturePIDChanged, DGUSScreenVariableHandler::DGUSLCD_SendTemperaturePID), - VPHELPER(VP_E0_PID_D, &thermalManager.temp_hotend[0].pid.Kd, DGUSScreenVariableHandler::HandleTemperaturePIDChanged, DGUSScreenVariableHandler::DGUSLCD_SendTemperaturePID), - VPHELPER(VP_PID_AUTOTUNE_E0, nullptr, &DGUSScreenVariableHandler::HandlePIDAutotune, nullptr), + VPHELPER(VP_E0_PID_P, &thermalManager.temp_hotend[0].pid.Kp, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), + VPHELPER(VP_E0_PID_I, &thermalManager.temp_hotend[0].pid.Ki, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), + VPHELPER(VP_E0_PID_D, &thermalManager.temp_hotend[0].pid.Kd, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), + VPHELPER(VP_PID_AUTOTUNE_E0, nullptr, &ScreenHandler.HandlePIDAutotune, nullptr), #endif #if ENABLED(DGUS_FILAMENT_LOADUNLOAD) - VPHELPER(VP_E0_FILAMENT_LOAD_UNLOAD, nullptr, &DGUSScreenVariableHandler::HandleFilamentOption, &DGUSScreenVariableHandler::HandleFilamentLoadUnload), + VPHELPER(VP_E0_FILAMENT_LOAD_UNLOAD, nullptr, &ScreenHandler.HandleFilamentOption, &ScreenHandler.HandleFilamentLoadUnload), #endif #endif #if HOTENDS >= 2 VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, DGUSLCD_SendFloatAsLongValueToDisplay<0>), - VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, DGUSScreenVariableHandler::HandleTemperatureChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Flowrate_E1, nullptr, DGUSScreenVariableHandler::HandleFlowRateChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_MOVE_E1, nullptr, &DGUSScreenVariableHandler::HandleManualExtrude, nullptr), - VPHELPER(VP_E1_CONTROL, &thermalManager.temp_hotend[1].target, &DGUSScreenVariableHandler::HandleHeaterControl, nullptr), - VPHELPER(VP_E1_STATUS, &thermalManager.temp_hotend[1].target, nullptr, &DGUSScreenVariableHandler::DGUSLCD_SendHeaterStatusToDisplay), + VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Flowrate_E1, nullptr, ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_MOVE_E1, nullptr, &ScreenHandler.HandleManualExtrude, nullptr), + VPHELPER(VP_E1_CONTROL, &thermalManager.temp_hotend[1].target, &ScreenHandler.HandleHeaterControl, nullptr), + VPHELPER(VP_E1_STATUS, &thermalManager.temp_hotend[1].target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), #if ENABLED(PIDTEMP) - VPHELPER(VP_PID_AUTOTUNE_E1, nullptr, &DGUSScreenVariableHandler::HandlePIDAutotune, nullptr), + VPHELPER(VP_PID_AUTOTUNE_E1, nullptr, &ScreenHandler.HandlePIDAutotune, nullptr), #endif #endif #if HAS_HEATED_BED - VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<0>), - VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, DGUSScreenVariableHandler::HandleTemperatureChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &DGUSScreenVariableHandler::HandleHeaterControl, nullptr), - VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &DGUSScreenVariableHandler::DGUSLCD_SendHeaterStatusToDisplay), + VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &ScreenHandler.HandleHeaterControl, nullptr), + VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), #if ENABLED(PIDTEMPBED) - VPHELPER(VP_BED_PID_P, &thermalManager.temp_bed.pid.Kp, DGUSScreenVariableHandler::HandleTemperaturePIDChanged, DGUSScreenVariableHandler::DGUSLCD_SendTemperaturePID), - VPHELPER(VP_BED_PID_I, &thermalManager.temp_bed.pid.Ki, DGUSScreenVariableHandler::HandleTemperaturePIDChanged, DGUSScreenVariableHandler::DGUSLCD_SendTemperaturePID), - VPHELPER(VP_BED_PID_D, &thermalManager.temp_bed.pid.Kd, DGUSScreenVariableHandler::HandleTemperaturePIDChanged, DGUSScreenVariableHandler::DGUSLCD_SendTemperaturePID), + VPHELPER(VP_BED_PID_P, &thermalManager.temp_bed.pid.Kp, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), + VPHELPER(VP_BED_PID_I, &thermalManager.temp_bed.pid.Ki, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), + VPHELPER(VP_BED_PID_D, &thermalManager.temp_bed.pid.Kd, ScreenHandler.HandleTemperaturePIDChanged, ScreenHandler.DGUSLCD_SendTemperaturePID), #endif #endif // Fan Data #if HAS_FAN #define FAN_VPHELPER(N) \ - VPHELPER(VP_Fan##N##_Percentage, &thermalManager.fan_speed[N], DGUSScreenVariableHandler::DGUSLCD_PercentageToUint8, &DGUSScreenVariableHandler::DGUSLCD_SendPercentageToDisplay), \ - VPHELPER(VP_FAN##N##_CONTROL, &thermalManager.fan_speed[N], &DGUSScreenVariableHandler::HandleFanControl, nullptr), \ - VPHELPER(VP_FAN##N##_STATUS, &thermalManager.fan_speed[N], nullptr, &DGUSScreenVariableHandler::DGUSLCD_SendFanStatusToDisplay), + VPHELPER(VP_Fan##N##_Percentage, &thermalManager.fan_speed[N], ScreenHandler.DGUSLCD_PercentageToUint8, &ScreenHandler.DGUSLCD_SendPercentageToDisplay), \ + VPHELPER(VP_FAN##N##_CONTROL, &thermalManager.fan_speed[N], &ScreenHandler.HandleFanControl, nullptr), \ + VPHELPER(VP_FAN##N##_STATUS, &thermalManager.fan_speed[N], nullptr, &ScreenHandler.DGUSLCD_SendFanStatusToDisplay), REPEAT(FAN_COUNT, FAN_VPHELPER) #endif // Feedrate - VPHELPER(VP_Feedrate_Percentage, &feedrate_percentage, DGUSScreenVariableHandler::DGUSLCD_SetValueDirectly, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay ), + VPHELPER(VP_Feedrate_Percentage, &feedrate_percentage, ScreenHandler.DGUSLCD_SetValueDirectly, &ScreenHandler.DGUSLCD_SendWordValueToDisplay ), // Position Data - VPHELPER(VP_XPos, ¤t_position.x, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<2>), - VPHELPER(VP_YPos, ¤t_position.y, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<2>), - VPHELPER(VP_ZPos, ¤t_position.z, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<2>), + VPHELPER(VP_XPos, ¤t_position.x, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), + VPHELPER(VP_YPos, ¤t_position.y, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), + VPHELPER(VP_ZPos, ¤t_position.z, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), // Print Progress - VPHELPER(VP_PrintProgress_Percentage, nullptr, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendPrintProgressToDisplay ), + VPHELPER(VP_PrintProgress_Percentage, nullptr, nullptr, ScreenHandler.DGUSLCD_SendPrintProgressToDisplay ), // Print Time - VPHELPER_STR(VP_PrintTime, nullptr, VP_PrintTime_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendPrintTimeToDisplay ), + VPHELPER_STR(VP_PrintTime, nullptr, VP_PrintTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintTimeToDisplay ), #if ENABLED(PRINTCOUNTER) - VPHELPER_STR(VP_PrintAccTime, nullptr, VP_PrintAccTime_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendPrintAccTimeToDisplay ), - VPHELPER_STR(VP_PrintsTotal, nullptr, VP_PrintsTotal_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendPrintsTotalToDisplay ), + VPHELPER_STR(VP_PrintAccTime, nullptr, VP_PrintAccTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintAccTimeToDisplay ), + VPHELPER_STR(VP_PrintsTotal, nullptr, VP_PrintsTotal_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintsTotalToDisplay ), #endif - VPHELPER(VP_X_STEP_PER_MM, &planner.settings.axis_steps_per_mm[X_AXIS], DGUSScreenVariableHandler::HandleStepPerMMChanged, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<1>), - VPHELPER(VP_Y_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Y_AXIS], DGUSScreenVariableHandler::HandleStepPerMMChanged, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<1>), - VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], DGUSScreenVariableHandler::HandleStepPerMMChanged, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<1>), + VPHELPER(VP_X_STEP_PER_MM, &planner.settings.axis_steps_per_mm[X_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), + VPHELPER(VP_Y_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Y_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), + VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), #if HOTENDS >= 1 - VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], DGUSScreenVariableHandler::HandleStepPerMMExtruderChanged, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<1>), + VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), #endif #if HOTENDS >= 2 - VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], DGUSScreenVariableHandler::HandleStepPerMMExtruderChanged, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<1>), + VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>), #endif // SDCard File listing. #if ENABLED(SDSUPPORT) - VPHELPER(VP_SD_ScrollEvent, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ScrollFilelist, nullptr), - VPHELPER(VP_SD_FileSelected, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_FileSelected, nullptr), - VPHELPER(VP_SD_FileSelectConfirm, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_StartPrint, nullptr), - VPHELPER_STR(VP_SD_FileName0, nullptr, VP_SD_FileName_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_SendFilename ), - VPHELPER_STR(VP_SD_FileName1, nullptr, VP_SD_FileName_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_SendFilename ), - VPHELPER_STR(VP_SD_FileName2, nullptr, VP_SD_FileName_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_SendFilename ), - VPHELPER_STR(VP_SD_FileName3, nullptr, VP_SD_FileName_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_SendFilename ), - VPHELPER_STR(VP_SD_FileName4, nullptr, VP_SD_FileName_LEN, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_SendFilename ), - VPHELPER(VP_SD_ResumePauseAbort, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ResumePauseAbort, nullptr), - VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ReallyAbort, nullptr), - VPHELPER(VP_SD_Print_Setting, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_PrintTune, nullptr), + VPHELPER(VP_SD_ScrollEvent, nullptr, ScreenHandler.DGUSLCD_SD_ScrollFilelist, nullptr), + VPHELPER(VP_SD_FileSelected, nullptr, ScreenHandler.DGUSLCD_SD_FileSelected, nullptr), + VPHELPER(VP_SD_FileSelectConfirm, nullptr, ScreenHandler.DGUSLCD_SD_StartPrint, nullptr), + VPHELPER_STR(VP_SD_FileName0, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ), + VPHELPER_STR(VP_SD_FileName1, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ), + VPHELPER_STR(VP_SD_FileName2, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ), + VPHELPER_STR(VP_SD_FileName3, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ), + VPHELPER_STR(VP_SD_FileName4, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename ), + VPHELPER(VP_SD_ResumePauseAbort, nullptr, ScreenHandler.DGUSLCD_SD_ResumePauseAbort, nullptr), + VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, ScreenHandler.DGUSLCD_SD_ReallyAbort, nullptr), + VPHELPER(VP_SD_Print_Setting, nullptr, ScreenHandler.DGUSLCD_SD_PrintTune, nullptr), #if HAS_BED_PROBE - VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe.offset.z, DGUSScreenVariableHandler::HandleProbeOffsetZChanged, &DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<2>), + VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe.offset.z, ScreenHandler.HandleProbeOffsetZChanged, &ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>), #if ENABLED(BABYSTEPPING) - VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, DGUSScreenVariableHandler::HandleLiveAdjustZ, nullptr), + VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, ScreenHandler.HandleLiveAdjustZ, nullptr), #endif #endif #endif #if ENABLED(DGUS_UI_WAITING) - VPHELPER(VP_WAITING_STATUS, nullptr, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendWaitingStatusToDisplay), + VPHELPER(VP_WAITING_STATUS, nullptr, nullptr, ScreenHandler.DGUSLCD_SendWaitingStatusToDisplay), #endif // Messages for the User, shared by the popup and the kill screen. They cant be autouploaded as we do not buffer content. - { .VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM }, - { .VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM }, - { .VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM }, - { .VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, VPHELPER(0, 0, 0, 0) // must be last entry. }; From d437ab99b9fc31bc946ca52f649c6ec15eef0c60 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 18 Jul 2020 19:34:18 -0500 Subject: [PATCH 05/11] Shorten filename also --- .../{DGUSScreenVariableHandler.cpp => DGUSScreenHandler.cpp} | 2 +- .../dgus/{DGUSScreenVariableHandler.h => DGUSScreenHandler.h} | 0 Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp | 2 +- Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp | 2 +- Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp | 2 +- Marlin/src/lcd/extui_dgus_lcd.cpp | 2 +- 6 files changed, 5 insertions(+), 5 deletions(-) rename Marlin/src/lcd/extui/lib/dgus/{DGUSScreenVariableHandler.cpp => DGUSScreenHandler.cpp} (99%) rename Marlin/src/lcd/extui/lib/dgus/{DGUSScreenVariableHandler.h => DGUSScreenHandler.h} (100%) diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp similarity index 99% rename from Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.cpp rename to Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp index 7d09799387cd..8be455e69dd8 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp @@ -20,7 +20,7 @@ * */ -#include "DGUSScreenVariableHandler.h" +#include "DGUSScreenHandler.h" #include "DGUSDisplay.h" #include "DGUSVPVariable.h" #include "DGUSDisplayDef.h" diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.h b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.h similarity index 100% rename from Marlin/src/lcd/extui/lib/dgus/DGUSScreenVariableHandler.h rename to Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.h diff --git a/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp index 359a30b79525..e5826a9180b7 100644 --- a/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp @@ -28,7 +28,7 @@ #include "../DGUSDisplayDef.h" #include "../DGUSDisplay.h" -#include "../DGUSScreenVariableHandler.h" +#include "../DGUSScreenHandler.h" #include "../../../../../module/temperature.h" #include "../../../../../module/motion.h" diff --git a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp index 84917e688f58..d5ac981e5b5d 100644 --- a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp @@ -28,7 +28,7 @@ #include "../DGUSDisplayDef.h" #include "../DGUSDisplay.h" -#include "../DGUSScreenVariableHandler.h" +#include "../DGUSScreenHandler.h" #include "../../../../../module/temperature.h" #include "../../../../../module/motion.h" diff --git a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp index 87414570ee71..73ee1a62d331 100644 --- a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp @@ -28,7 +28,7 @@ #include "../DGUSDisplayDef.h" #include "../DGUSDisplay.h" -#include "../DGUSScreenVariableHandler.h" +#include "../DGUSScreenHandler.h" #include "../../../../../module/temperature.h" #include "../../../../../module/motion.h" diff --git a/Marlin/src/lcd/extui_dgus_lcd.cpp b/Marlin/src/lcd/extui_dgus_lcd.cpp index 6f68a62fdab1..e2d307d5357b 100644 --- a/Marlin/src/lcd/extui_dgus_lcd.cpp +++ b/Marlin/src/lcd/extui_dgus_lcd.cpp @@ -33,7 +33,7 @@ #include "extui/ui_api.h" #include "extui/lib/dgus/DGUSDisplay.h" #include "extui/lib/dgus/DGUSDisplayDef.h" -#include "extui/lib/dgus/DGUSScreenVariableHandler.h" +#include "extui/lib/dgus/DGUSScreenHandler.h" extern const char NUL_STR[]; From 233657f43a1d3eb4f473de785f5bcecf15ab5761 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 18 Jul 2020 19:48:25 -0500 Subject: [PATCH 06/11] Fix DGUSVPVariable.h --- Marlin/src/lcd/extui/lib/dgus/DGUSVPVariable.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSVPVariable.h b/Marlin/src/lcd/extui/lib/dgus/DGUSVPVariable.h index 30555bbb9f3a..58621cfd571e 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSVPVariable.h +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSVPVariable.h @@ -21,6 +21,8 @@ */ #pragma once +#include + /** * DGUSVPVariable.h * From 510360fd8de760cb55ae7a87535b59ad038f8394 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 18 Jul 2020 20:08:31 -0500 Subject: [PATCH 07/11] Patch dependencies, apply HAS_DGUS_LCD --- Marlin/src/lcd/extui/lib/dgus/DGUSDisplayDef.h | 7 +++++++ Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp | 7 +++++++ Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.h | 5 ++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplayDef.h b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplayDef.h index 7af1ffefa7ba..f6f3b20cc0c4 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplayDef.h +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplayDef.h @@ -25,6 +25,8 @@ #include "DGUSVPVariable.h" +#include + // This file defines the interaction between Marlin and the display firmware. // information on which screen which VP is displayed @@ -41,10 +43,15 @@ extern const struct VPMapping VPMap[]; // List of VPs handled by Marlin / The Display. extern const struct DGUS_VP_Variable ListOfVP[]; +#include "../../../../inc/MarlinConfig.h" + #if ENABLED(DGUS_LCD_UI_ORIGIN) #include "origin/DGUSDisplayDef.h" + #error "origin/DGUSDisplayDef.h" #elif ENABLED(DGUS_LCD_UI_FYSETC) #include "fysetc/DGUSDisplayDef.h" + #error "fysetc/DGUSDisplayDef.h" #elif ENABLED(DGUS_LCD_UI_HIPRECY) #include "hiprecy/DGUSDisplayDef.h" + #error "hiprecy/DGUSDisplayDef.h" #endif diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp index 8be455e69dd8..d708fe813934 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp @@ -20,6 +20,10 @@ * */ +#include "../../../../inc/MarlinConfigPre.h" + +#if HAS_DGUS_LCD + #include "DGUSScreenHandler.h" #include "DGUSDisplay.h" #include "DGUSVPVariable.h" @@ -34,6 +38,7 @@ #include "../../../../sd/cardreader.h" #include "../../../../libs/duration_t.h" #include "../../../../module/printcounter.h" + #if ENABLED(POWER_LOSS_RECOVERY) #include "../../../../feature/powerloss.h" #endif @@ -1125,3 +1130,5 @@ void DGUSDisplay::RequestScreen(DGUSLCD_Screens screen) { const unsigned char gotoscreen[] = { 0x5A, 0x01, (unsigned char) (screen >> 8U), (unsigned char) (screen & 0xFFU) }; WriteVariable(0x84, gotoscreen, sizeof(gotoscreen)); } + +#endif // HAS_DGUS_LCD diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.h b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.h index 6f21517ddf4b..d5b1450e2f09 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.h @@ -21,9 +21,12 @@ */ #pragma once +#include "DGUSDisplay.h" #include "DGUSVPVariable.h" -#include "../../../../inc/MarlinConfigPre.h" +#include "../../../../inc/MarlinConfig.h" + +enum DGUSLCD_Screens : uint8_t; class DGUSScreenHandler { public: From aabb653a4c02d3efd105e747bd44c5622d88e586 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 18 Jul 2020 20:10:49 -0500 Subject: [PATCH 08/11] drop debug --- Marlin/src/lcd/extui/lib/dgus/DGUSDisplayDef.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplayDef.h b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplayDef.h index f6f3b20cc0c4..39ed3174f07e 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplayDef.h +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplayDef.h @@ -47,11 +47,8 @@ extern const struct DGUS_VP_Variable ListOfVP[]; #if ENABLED(DGUS_LCD_UI_ORIGIN) #include "origin/DGUSDisplayDef.h" - #error "origin/DGUSDisplayDef.h" #elif ENABLED(DGUS_LCD_UI_FYSETC) #include "fysetc/DGUSDisplayDef.h" - #error "fysetc/DGUSDisplayDef.h" #elif ENABLED(DGUS_LCD_UI_HIPRECY) #include "hiprecy/DGUSDisplayDef.h" - #error "hiprecy/DGUSDisplayDef.h" #endif From 46bb5027e92edc9d151cfe65994e5f0e3bf1f42b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 18 Jul 2020 20:12:48 -0500 Subject: [PATCH 09/11] Fix filament_data --- Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp | 10 ---------- Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp index 3cbee8d93e74..989a06623a7b 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp @@ -59,16 +59,6 @@ constexpr uint8_t DGUS_CMD_READVAR = 0x83; bool dguslcd_local_debug; // = false; #endif -#if ENABLED(DGUS_FILAMENT_LOADUNLOAD) - typedef struct { - ExtUI::extruder_t extruder; // which extruder to operate - uint8_t action; // load or unload - bool heated; // heating done ? - float purge_length; // the length to extrude before unload, prevent filament jam - } filament_data_t; - static filament_data_t filament_data; -#endif - #define dgusserial DGUS_SERIAL void DGUSDisplay::InitDisplay() { diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp index d708fe813934..6ff578832695 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp @@ -925,6 +925,16 @@ void DGUSScreenHandler::HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr #endif #if ENABLED(DGUS_FILAMENT_LOADUNLOAD) + + typedef struct { + ExtUI::extruder_t extruder; // which extruder to operate + uint8_t action; // load or unload + bool heated; // heating done ? + float purge_length; // the length to extrude before unload, prevent filament jam + } filament_data_t; + + static filament_data_t filament_data; + void DGUSScreenHandler::HandleFilamentOption(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleFilamentOption"); From 6e830361fd3888ac20fd538245411457ff430f90 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 18 Jul 2020 20:14:44 -0500 Subject: [PATCH 10/11] Add DGUS with FYSETC test --- buildroot/tests/FYSETC_F6_13-tests | 1 + 1 file changed, 1 insertion(+) diff --git a/buildroot/tests/FYSETC_F6_13-tests b/buildroot/tests/FYSETC_F6_13-tests index 5ddbac554e73..e86f31e6c291 100644 --- a/buildroot/tests/FYSETC_F6_13-tests +++ b/buildroot/tests/FYSETC_F6_13-tests @@ -11,6 +11,7 @@ set -e # restore_configs opt_set MOTHERBOARD BOARD_FYSETC_F6_13 +opt_enable DGUS_LCD_UI_FYSETC exec_test $1 $2 "Default Configuration" # clean up From a2856e2c97b82e8d2707d0c99e1061149abd1620 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 18 Jul 2020 20:15:54 -0500 Subject: [PATCH 11/11] ibid. --- buildroot/tests/FYSETC_F6_13-tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildroot/tests/FYSETC_F6_13-tests b/buildroot/tests/FYSETC_F6_13-tests index e86f31e6c291..631a11778502 100644 --- a/buildroot/tests/FYSETC_F6_13-tests +++ b/buildroot/tests/FYSETC_F6_13-tests @@ -12,7 +12,7 @@ set -e restore_configs opt_set MOTHERBOARD BOARD_FYSETC_F6_13 opt_enable DGUS_LCD_UI_FYSETC -exec_test $1 $2 "Default Configuration" +exec_test $1 $2 "FYSETC F6 1.3 with DGUS" # clean up restore_configs