From 92696d8e86cbd2b33910859ef3286c78d1c04b7f Mon Sep 17 00:00:00 2001 From: Nazar78 Date: Tue, 31 Oct 2023 03:28:18 +0800 Subject: [PATCH] Fixed [BUG] Crash and reboot after second time gcode preview. modified: Marlin/Configuration.h modified: Marlin/src/lcd/e3v2/proui/custom_gcodes.cpp modified: Marlin/src/lcd/e3v2/proui/dwin.cpp renamed: Marlin/src/lcd/e3v2/proui/gcode_preview_nopro.cpp -> Marlin/src/lcd/e3v2/proui/gcode_preview.cpp modified: Marlin/src/lcd/e3v2/proui/gcode_preview.h deleted: Marlin/src/lcd/e3v2/proui/gcode_preview_nopro.h modified: configurations/Andrew427/Configuration.h modified: configurations/BTT-SKR_Mini_E3_V2/ConfigurationMM.h modified: configurations/BTT-SKR_Mini_E3_V2/ConfigurationUBL.h modified: configurations/BTT-SKR_Mini_E3_V3/ConfigurationMM.h modified: configurations/BTT-SKR_Mini_E3_V3/ConfigurationUBL.h modified: configurations/Creality Ender/BLT/Configuration.h modified: configurations/Creality Ender/Default-NP/Configuration.h modified: configurations/Creality Ender/MM/Configuration.h modified: configurations/Creality Ender/UBL/Configuration.h modified: configurations/Voxelab Aquila 427/BLT/Configuration.h modified: configurations/Voxelab Aquila 427/Default-NP/Configuration.h modified: configurations/Voxelab Aquila 427/MM/Configuration.h modified: configurations/Voxelab Aquila 427/UBL/Configuration.h modified: configurations/Voxelab Aquila/BLT/Configuration.h modified: configurations/Voxelab Aquila/BLT/ConfigurationPro.h modified: configurations/Voxelab Aquila/Default-NP/Configuration.h modified: configurations/Voxelab Aquila/MM/Configuration.h modified: configurations/Voxelab Aquila/UBL/Configuration.h modified: configurations/Voxelab Aquila/UBL/ConfigurationPro.h modified: configurations/Voxelab Aquila/X3/Configuration.h --- Marlin/Configuration.h | 2 - Marlin/src/lcd/e3v2/proui/custom_gcodes.cpp | 4 +- Marlin/src/lcd/e3v2/proui/dwin.cpp | 75 +++++--------- ...de_preview_nopro.cpp => gcode_preview.cpp} | 99 ++++++++++--------- Marlin/src/lcd/e3v2/proui/gcode_preview.h | 39 +++++--- .../src/lcd/e3v2/proui/gcode_preview_nopro.h | 41 -------- configurations/Andrew427/Configuration.h | 2 - .../BTT-SKR_Mini_E3_V2/ConfigurationMM.h | 2 - .../BTT-SKR_Mini_E3_V2/ConfigurationUBL.h | 2 - .../BTT-SKR_Mini_E3_V3/ConfigurationMM.h | 2 - .../BTT-SKR_Mini_E3_V3/ConfigurationUBL.h | 2 - .../Creality Ender/BLT/Configuration.h | 2 - .../Creality Ender/Default-NP/Configuration.h | 2 - .../Creality Ender/MM/Configuration.h | 2 - .../Creality Ender/UBL/Configuration.h | 2 - .../Voxelab Aquila 427/BLT/Configuration.h | 2 - .../Default-NP/Configuration.h | 2 - .../Voxelab Aquila 427/MM/Configuration.h | 2 - .../Voxelab Aquila 427/UBL/Configuration.h | 2 - .../Voxelab Aquila/BLT/Configuration.h | 2 - .../Voxelab Aquila/BLT/ConfigurationPro.h | 2 - .../Voxelab Aquila/Default-NP/Configuration.h | 2 - .../Voxelab Aquila/MM/Configuration.h | 2 - .../Voxelab Aquila/UBL/Configuration.h | 2 - .../Voxelab Aquila/UBL/ConfigurationPro.h | 2 - .../Voxelab Aquila/X3/Configuration.h | 2 - 26 files changed, 101 insertions(+), 199 deletions(-) rename Marlin/src/lcd/e3v2/proui/{gcode_preview_nopro.cpp => gcode_preview.cpp} (60%) delete mode 100644 Marlin/src/lcd/e3v2/proui/gcode_preview_nopro.h diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 1c5b6e9c30..68dcd123c9 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -3419,8 +3419,6 @@ #ifdef PROUI_EX #define HAS_GCODE_PREVIEW 1 #define HAS_TOOLBAR 1 - #else - #define HAS_GCODE_PREVIEW_NOPRO 1 #endif #define DISABLE_TUNING_GRAPH 0// Temp plot graph - PID/MPC Tuning (1624 bytes of flash) #define HAS_ESDIAG 1 // View End-stop switch continuity (560 bytes of flash) diff --git a/Marlin/src/lcd/e3v2/proui/custom_gcodes.cpp b/Marlin/src/lcd/e3v2/proui/custom_gcodes.cpp index 57a06f4138..8cf7c77cd0 100644 --- a/Marlin/src/lcd/e3v2/proui/custom_gcodes.cpp +++ b/Marlin/src/lcd/e3v2/proui/custom_gcodes.cpp @@ -84,7 +84,7 @@ void C108() { } // Enable or disable preview screen -#if HAS_GCODE_PREVIEW || HAS_GCODE_PREVIEW_NOPRO +#if HAS_GCODE_PREVIEW void C250() { if (parser.seenval('P')) { HMI_data.EnablePreview = !!parser.value_byte(); @@ -120,7 +120,7 @@ void custom_gcode(const int16_t codenum) { case 35: C35(); break; // Launch bed tramming wizard #endif case 108: C108(); break; // Cancel a Wait for User without an Emergecy Parser - #if HAS_GCODE_PREVIEW || HAS_GCODE_PREVIEW_NOPRO + #if HAS_GCODE_PREVIEW case 250: C250(); break; // Enable or disable preview screen #endif #if HAS_LOCKSCREEN diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index 04558a1e90..bdbdba0874 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -99,8 +99,6 @@ #if HAS_GCODE_PREVIEW #include "file_header.h" #include "gcode_preview.h" -#elif HAS_GCODE_PREVIEW_NOPRO - #include "gcode_preview_nopro.h" #endif #if HAS_TOOLBAR @@ -123,10 +121,6 @@ #include "lockscreen.h" #endif -#if HAS_SOUND - #include "../../../libs/buzzer.h" -#endif - //#define DEBUG_OUT ENABLED(DEBUG_DWIN) #include "../../../core/debug_out.h" @@ -630,12 +624,6 @@ void Draw_PrintDone() { DWINUI::ClearMainArea(); DWIN_Print_Header(nullptr); #if HAS_GCODE_PREVIEW - const bool haspreview = Preview_Valid(); - if (haspreview) { - Preview_Show(); - DWINUI::Draw_Button(BTN_Continue, 86, 295, true); - } - #elif HAS_GCODE_PREVIEW_NOPRO const bool haspreview = preview.valid(); if (haspreview) { preview.show(); @@ -768,7 +756,7 @@ void _draw_feedrate() { DWINUI::Draw_String(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 116 + 4 * STAT_CHR_W + 2, 384, F(" %")); } else { - _value = CEIL(MMS_SCALED(feedrate_mm_s)); + _value = CEIL(feedrate_mm_s * feedrate_percentage / 100); DWIN_Draw_Box(1, HMI_data.Background_Color, 116 + 4 * STAT_CHR_W + 2, 384, 30, 20); } DWINUI::Draw_Int(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 3, 116 + 2 * STAT_CHR_W, 384, _value); @@ -802,8 +790,8 @@ void _draw_xyz_position(const bool force) { } void update_variable() { - TERN_(DEBUG_DWIN, DWINUI::Draw_Int(Color_Yellow, Color_Bg_Black, 2, DWIN_WIDTH - 6 * DWINUI::fontWidth(), 6, checkkey);) - TERN_(DEBUG_DWIN, DWINUI::Draw_Int(Color_Yellow, Color_Bg_Black, 2, DWIN_WIDTH - 3 * DWINUI::fontWidth(), 6, last_checkkey);) + TERN_(DEBUG_DWIN, DWINUI::Draw_Int(Color_Yellow, Color_Bg_Black, 2, DWIN_WIDTH-6*DWINUI::fontWidth(), 6, checkkey);) + TERN_(DEBUG_DWIN, DWINUI::Draw_Int(Color_Yellow, Color_Bg_Black, 2, DWIN_WIDTH-3*DWINUI::fontWidth(), 6, last_checkkey);) _draw_xyz_position(false); @@ -1260,6 +1248,8 @@ void HMI_Printing() { DWIN_UpdateLCD(); } +#include "../../../libs/buzzer.h" + void Draw_Main_Area() { switch (checkkey) { case MainMenu: Draw_Main_Menu(); break; @@ -1582,7 +1572,7 @@ void DWIN_HomingStart() { HMI_flag.home_flag = true; HMI_SaveProcessID(Homing); Title.ShowCaption(GET_TEXT_F(MSG_HOMING)); - DWIN_Show_Popup(TERN(TJC_DISPLAY, ICON_BLTouch, ICON_Printer_0), GET_TEXT_F(MSG_HOMING), GET_TEXT_F(MSG_PLEASE_WAIT)); + DWIN_Show_Popup(ICON_Printer_0, GET_TEXT_F(MSG_HOMING), GET_TEXT_F(MSG_PLEASE_WAIT)); } void DWIN_HomingDone() { @@ -1843,18 +1833,13 @@ void DWIN_LevelingDone() { // Started a Print Job void DWIN_Print_Started() { DEBUG_ECHOLNPGM("DWIN_Print_Started: ", SD_Printing()); - TERN_(HAS_GCODE_PREVIEW, if (Host_Printing()) { Preview_Invalidate(); }) - TERN_(HAS_GCODE_PREVIEW_NOPRO, if (Host_Printing()) { preview.invalidate(); }) + TERN_(HAS_GCODE_PREVIEW, if (Host_Printing()) { preview.invalidate(); }) ui.progress_reset(); ui.reset_remaining_time(); HMI_flag.pause_flag = false; HMI_flag.abort_flag = false; select_print.reset(); - #if PROUI_EX - if (!fileprop.isConfig) { Goto_PrintProcess(); } - #else - Goto_PrintProcess(); - #endif + Goto_PrintProcess(); } // Pause a print job @@ -1876,12 +1861,7 @@ void DWIN_Print_Finished() { HMI_flag.abort_flag = false; HMI_flag.pause_flag = false; wait_for_heatup = false; - #if PROUI_EX - if (!fileprop.isConfig) { Goto_PrintDone(); } - else { fileprop.isConfig = false; } - #else - Goto_PrintDone(); - #endif + Goto_PrintDone(); } // Print was aborted @@ -1909,7 +1889,7 @@ void DWIN_Print_Aborted() { DWIN_Print_Finished(); } -#if (ALT_COLOR_MENU == 1) // 1 = Alternate Aquila +#if (ALT_COLOR_MENU == 1) void DWIN_SetColorDefaults() { HMI_data.Background_Color = Def_Background_Color; HMI_data.Cursor_Color = Def_Cursor_Color; @@ -1931,7 +1911,7 @@ void DWIN_Print_Aborted() { HMI_data.Coordinate_Color = Def_Coordinate_Color; HMI_data.Bottom_Color = Def_Bottom_Color; } -#elif (ALT_COLOR_MENU == 2) // 2 = Ender3V2 Default +#elif (ALT_COLOR_MENU == 2) void DWIN_SetColorDefaults() { #undef Def_Background_Color #undef Def_Text_Color @@ -1959,7 +1939,7 @@ void DWIN_Print_Aborted() { HMI_data.Coordinate_Color = Color_White; HMI_data.Bottom_Color = RGB( 0, 23, 16); } -#else // 0 = Voxelab Default +#else void DWIN_SetColorDefaults() { HMI_data.Background_Color = Def_Background_Color; HMI_data.Cursor_Color = Def_Text_Color; @@ -2039,7 +2019,7 @@ void DWIN_SetDataDefaults() { #endif #endif TERN_(ADAPTIVE_STEP_SMOOTHING, HMI_data.AdaptiveStepSmoothing = true;) - #if HAS_GCODE_PREVIEW || HAS_GCODE_PREVIEW_NOPRO + #if HAS_GCODE_PREVIEW HMI_data.EnablePreview = true; #endif #if PROUI_EX @@ -2164,7 +2144,7 @@ void MarlinUI::refresh() { /* Nothing to see here */ } #endif void MarlinUI::kill_screen(FSTR_P const lcd_error, FSTR_P const) { - DWIN_Draw_Popup(TERN(TJC_DISPLAY, ICON_BLTouch, ICON_Printer_0), GET_TEXT_F(MSG_PRINTER_KILLED), lcd_error); + DWIN_Draw_Popup(ICON_Printer_0, GET_TEXT_F(MSG_PRINTER_KILLED), lcd_error); DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 270, GET_TEXT_F(MSG_TURN_OFF)); DWIN_UpdateLCD(); } @@ -2279,7 +2259,7 @@ void DWIN_RedrawScreen() { #endif // HAS_LOCKSCREEN -#if HAS_GCODE_PREVIEW || HAS_GCODE_PREVIEW_NOPRO +#if HAS_GCODE_PREVIEW void SetPreview() { Toggle_Chkb_Line(HMI_data.EnablePreview); } @@ -2297,14 +2277,6 @@ void DWIN_RedrawScreen() { #endif void Goto_ConfirmToPrint() { - #if PROUI_EX - fileprop.clear(); - fileprop.setname(card.filename); - card.openFileRead(fileprop.name, 100); - getFileHeader(); - card.closefile(); - if (fileprop.isConfig) return card.openAndPrintFile(card.filename); - #endif #if ENABLED(CV_LASER_MODULE) if (fileprop.isLaser) { if (laser_device.is_laser_device()) @@ -2316,8 +2288,6 @@ void Goto_ConfirmToPrint() { LaserOn(false); // If it is not laser file turn off laser mode #endif #if HAS_GCODE_PREVIEW - if (HMI_data.EnablePreview) return Goto_Popup(Preview_DrawFromSD, onClick_ConfirmToPrint); - #elif HAS_GCODE_PREVIEW_NOPRO if (HMI_data.EnablePreview) return Goto_Popup(preview.drawFromSD, onClick_ConfirmToPrint); #endif card.openAndPrintFile(card.filename); // Direct print SD file @@ -2608,8 +2578,7 @@ void ApplyMove() { #endif #if LCD_BACKLIGHT_TIMEOUT_MINS - void ApplyTimer() { ui.backlight_timeout_minutes = MenuData.Value; } - void SetTimer() { SetIntOnClick(ui.backlight_timeout_min, ui.backlight_timeout_max, ui.backlight_timeout_minutes, ApplyTimer); } + void SetTimer() { SetPIntOnClick(ui.backlight_timeout_min, ui.backlight_timeout_max); } #endif #if PROUI_EX && ENABLED(NOZZLE_PARK_FEATURE) @@ -3104,7 +3073,7 @@ void onDrawGetColorItem(MenuItemClass* menuitem, int8_t line) { #if HAS_BED_PROBE && ENABLED(TRAMWIZ_MENU_ITEM) // Trammingwizard Popup - void PopUp_StartTramwiz() { DWIN_Popup_ConfirmCancel(TERN(TJC_DISPLAY, ICON_BLTouch, ICON_Printer_0), F("Start Tramming Wizard?")); } + void PopUp_StartTramwiz() { DWIN_Popup_ConfirmCancel(ICON_Printer_0, F("Start Tramming Wizard?")); } void onClick_StartTramwiz() { if (HMI_flag.select_flag) { if (HMI_data.FullManualTramming) { @@ -3490,7 +3459,7 @@ void Draw_Tune_Menu() { EDIT_ITEM(ICON_MaxAccelerated, MSG_ADVANCE_K, onDrawPFloat3Menu, SetLA_K, &planner.extruder_advance_K[0]); #endif #if LCD_BACKLIGHT_TIMEOUT_MINS - EDIT_ITEM(ICON_Box, MSG_SCREEN_TIMEOUT, onDrawPInt8Menu, SetTimer, &ui.backlight_timeout_minutes); + EDIT_ITEM(ICON_Box, MSG_SCREEN_TIMEOUT, onDrawPIntMenu, SetTimer, &ui.backlight_timeout_minutes); #endif #if HAS_LCD_BRIGHTNESS EDIT_ITEM(ICON_Brightness, MSG_BRIGHTNESS, onDrawPInt8Menu, SetBrightness, &ui.brightness); @@ -4505,7 +4474,7 @@ void Draw_AdvancedSettings_Menu() { EDIT_ITEM(ICON_Brightness, MSG_BRIGHTNESS, onDrawPInt8Menu, SetBrightness, &ui.brightness); #endif #if LCD_BACKLIGHT_TIMEOUT_MINS - EDIT_ITEM(ICON_Box, MSG_SCREEN_TIMEOUT, onDrawPInt8Menu, SetTimer, &ui.backlight_timeout_minutes); + EDIT_ITEM(ICON_Box, MSG_SCREEN_TIMEOUT, onDrawPIntMenu, SetTimer, &ui.backlight_timeout_minutes); #endif #if BED_SCREW_INSET EDIT_ITEM_F(ICON_ProbeMargin, "Bed Screw Inset", onDrawPFloatMenu, SetRetractSpeed, &ui.screw_pos); @@ -4520,7 +4489,7 @@ void Draw_AdvancedSettings_Menu() { EDIT_ITEM(ICON_Sound, MSG_TICK, onDrawChkbMenu, SetEnableTick, &ui.tick_on); EDIT_ITEM(ICON_Sound, MSG_SOUND, onDrawChkbMenu, SetEnableSound, &ui.sound_on); #endif - #if HAS_GCODE_PREVIEW || HAS_GCODE_PREVIEW_NOPRO + #if HAS_GCODE_PREVIEW EDIT_ITEM(ICON_File, MSG_HAS_PREVIEW, onDrawChkbMenu, SetPreview, &HMI_data.EnablePreview); #endif #if ENABLED(BAUD_RATE_GCODE) @@ -4560,7 +4529,7 @@ void Draw_Advanced_Menu() { // From Control_Menu (Control) || Default-NP Advance EDIT_ITEM(ICON_Brightness, MSG_BRIGHTNESS, onDrawPInt8Menu, SetBrightness, &ui.brightness); #endif #if LCD_BACKLIGHT_TIMEOUT_MINS - EDIT_ITEM(ICON_Box, MSG_SCREEN_TIMEOUT, onDrawPInt8Menu, SetTimer, &ui.backlight_timeout_minutes); + EDIT_ITEM(ICON_Box, MSG_SCREEN_TIMEOUT, onDrawPIntMenu, SetTimer, &ui.backlight_timeout_minutes); #endif #if BED_SCREW_INSET EDIT_ITEM_F(ICON_ProbeMargin, "Bed Screw Inset", onDrawPFloatMenu, SetRetractSpeed, &ui.screw_pos); @@ -4575,7 +4544,7 @@ void Draw_Advanced_Menu() { // From Control_Menu (Control) || Default-NP Advance EDIT_ITEM(ICON_Sound, MSG_TICK, onDrawChkbMenu, SetEnableTick, &ui.tick_on); EDIT_ITEM(ICON_Sound, MSG_SOUND, onDrawChkbMenu, SetEnableSound, &ui.sound_on); #endif - #if HAS_GCODE_PREVIEW || HAS_GCODE_PREVIEW_NOPRO + #if HAS_GCODE_PREVIEW EDIT_ITEM(ICON_File, MSG_HAS_PREVIEW, onDrawChkbMenu, SetPreview, &HMI_data.EnablePreview); #endif #if ENABLED(BAUD_RATE_GCODE) diff --git a/Marlin/src/lcd/e3v2/proui/gcode_preview_nopro.cpp b/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp similarity index 60% rename from Marlin/src/lcd/e3v2/proui/gcode_preview_nopro.cpp rename to Marlin/src/lcd/e3v2/proui/gcode_preview.cpp index 5e78053c79..4015d88bd7 100644 --- a/Marlin/src/lcd/e3v2/proui/gcode_preview_nopro.cpp +++ b/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp @@ -29,14 +29,13 @@ #include "../../../inc/MarlinConfigPre.h" -#if ALL(DWIN_LCD_PROUI, HAS_GCODE_PREVIEW_NOPRO) +#if ALL(DWIN_LCD_PROUI, HAS_GCODE_PREVIEW) -#include "gcode_preview_nopro.h" +#include "gcode_preview.h" #include "../../../core/types.h" #include "../../marlinui.h" #include "../../../sd/cardreader.h" -#include "../../../MarlinCore.h" // for wait_for_user #include "dwin.h" #include "dwin_popup.h" #include "base64.h" @@ -75,7 +74,7 @@ typedef struct { } fileprop_t; -fileprop_t fileprop; +fileprop_t fileprop_nopro; void getValue(const char * const buf, PGM_P const key, float &value) { if (value != 0.0f) return; @@ -102,34 +101,34 @@ bool Preview::hasPreview() { uint32_t indx = 0; float tmp = 0; - fileprop.clear(); - fileprop.setname(card.filename); + fileprop_nopro.clear(); + fileprop_nopro.setname(card.filename); - card.openFileRead(fileprop.name); + card.openFileRead(fileprop_nopro.name); char buf[256]; uint8_t nbyte = 1; - while (!fileprop.thumbstart && nbyte > 0 && indx < 4 * sizeof(buf)) { + while (!fileprop_nopro.thumbstart && nbyte > 0 && indx < 4 * sizeof(buf)) { nbyte = card.read(buf, sizeof(buf) - 1); if (nbyte > 0) { buf[nbyte] = '\0'; - getValue(buf, PSTR(";TIME:"), fileprop.time); - getValue(buf, PSTR(";Filament used:"), fileprop.filament); - getValue(buf, PSTR(";Layer height:"), fileprop.layer); + getValue(buf, PSTR(";TIME:"), fileprop_nopro.time); + getValue(buf, PSTR(";Filament used:"), fileprop_nopro.filament); + getValue(buf, PSTR(";Layer height:"), fileprop_nopro.layer); getValue(buf, PSTR(";MINX:"), tmp); - getValue(buf, PSTR(";MAXX:"), fileprop.width); - fileprop.width -= tmp; + getValue(buf, PSTR(";MAXX:"), fileprop_nopro.width); + fileprop_nopro.width -= tmp; tmp = 0; getValue(buf, PSTR(";MINY:"), tmp); - getValue(buf, PSTR(";MAXY:"), fileprop.length); - fileprop.length -= tmp; + getValue(buf, PSTR(";MAXY:"), fileprop_nopro.length); + fileprop_nopro.length -= tmp; tmp = 0; getValue(buf, PSTR(";MINZ:"), tmp); - getValue(buf, PSTR(";MAXZ:"), fileprop.height); - fileprop.height -= tmp; + getValue(buf, PSTR(";MAXZ:"), fileprop_nopro.height); + fileprop_nopro.height -= tmp; posptr = strstr_P(buf, tbstart); if (posptr != nullptr) { - fileprop.thumbstart = indx + (posptr - &buf[0]); + fileprop_nopro.thumbstart = indx + (posptr - &buf[0]); } else { indx += _MAX(10, nbyte - (signed)strlen_P(tbstart)); @@ -138,31 +137,31 @@ bool Preview::hasPreview() { } } - if (!fileprop.thumbstart) { + if (!fileprop_nopro.thumbstart) { card.closefile(); LCD_MESSAGE_F("Thumbnail not found"); return false; } // Get the size of the thumbnail - card.setIndex(fileprop.thumbstart + strlen_P(tbstart)); + card.setIndex(fileprop_nopro.thumbstart + strlen_P(tbstart)); for (uint8_t i = 0; i < 16; i++) { const char c = card.get(); if (ISEOL(c)) { buf[i] = '\0'; break; } buf[i] = c; } - fileprop.thumbsize = atoi(buf); + fileprop_nopro.thumbsize = atoi(buf); // Exit if there isn't a thumbnail - if (!fileprop.thumbsize) { + if (!fileprop_nopro.thumbsize) { card.closefile(); LCD_MESSAGE_F("Invalid Thumbnail Size"); return false; } - uint8_t buf64[fileprop.thumbsize + 1]; + uint8_t buf64[fileprop_nopro.thumbsize + 1]; uint16_t nread = 0; - while (nread < fileprop.thumbsize) { + while (nread < fileprop_nopro.thumbsize) { const uint8_t c = card.get(); if (!ISEOL(c) && c != ';' && c != ' ') buf64[nread++] = c; @@ -170,59 +169,63 @@ bool Preview::hasPreview() { card.closefile(); buf64[nread] = '\0'; - uint8_t thumbdata[3 + 3 * (fileprop.thumbsize / 4)]; // Reserve space for the JPEG thumbnail - fileprop.thumbsize = decode_base64(buf64, thumbdata); - DWINUI::WriteToSRAM(0x00, fileprop.thumbsize, thumbdata); + uint8_t thumbdata[3 + 3 * (fileprop_nopro.thumbsize / 4)]; // Reserve space for the JPEG thumbnail + fileprop_nopro.thumbsize = decode_base64(buf64, thumbdata); + DWINUI::WriteToSRAM(0x00, fileprop_nopro.thumbsize, thumbdata); - fileprop.thumbwidth = THUMBWIDTH; - fileprop.thumbheight = THUMBHEIGHT; + fileprop_nopro.thumbwidth = THUMBWIDTH; + fileprop_nopro.thumbheight = THUMBHEIGHT; return true; } void Preview::drawFromSD() { - if (!hasPreview()) { - HMI_flag.select_flag = 1; - wait_for_user = false; - return; - } + hasPreview(); MString<45> buf; DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, 0, DWIN_WIDTH, STATUS_Y - 1); - if (fileprop.time) { - buf.setf(F("Estimated time: %i:%02i"), (uint16_t)fileprop.time / 3600, ((uint16_t)fileprop.time % 3600) / 60); + if (fileprop_nopro.time) { + buf.setf(F("Estimated time: %i:%02i"), (uint16_t)fileprop_nopro.time / 3600, ((uint16_t)fileprop_nopro.time % 3600) / 60); DWINUI::Draw_String(20, 10, &buf); } - if (fileprop.filament) { - buf.set(F("Filament used: "), p_float_t(fileprop.filament, 2), F(" m")); + if (fileprop_nopro.filament) { + buf.set(F("Filament used: "), p_float_t(fileprop_nopro.filament, 2), F(" m")); DWINUI::Draw_String(20, 30, &buf); } - if (fileprop.layer) { - buf.set(F("Layer height: "), p_float_t(fileprop.layer, 2), F(" mm")); + if (fileprop_nopro.layer) { + buf.set(F("Layer height: "), p_float_t(fileprop_nopro.layer, 2), F(" mm")); DWINUI::Draw_String(20, 50, &buf); } - if (fileprop.width) { - buf.set(F("Volume: "), p_float_t(fileprop.width, 1), 'x', p_float_t(fileprop.length, 1), 'x', p_float_t(fileprop.height, 1), F(" mm")); + if (fileprop_nopro.width) { + buf.set(F("Volume: "), p_float_t(fileprop_nopro.width, 1), 'x', p_float_t(fileprop_nopro.length, 1), 'x', p_float_t(fileprop_nopro.height, 1), F(" mm")); DWINUI::Draw_String(20, 70, &buf); } + + if (!fileprop_nopro.thumbsize) { + const uint8_t xpos = ((DWIN_WIDTH) / 2) - 55, // 55 = iconW/2 + ypos = ((DWIN_HEIGHT) / 2) - 125; + DWINUI::Draw_Icon(ICON_Info_0, xpos, ypos); + buf.set(PSTR("No " STRINGIFY(THUMBWIDTH) "x" STRINGIFY(THUMBHEIGHT) " Thumbnail")); + DWINUI::Draw_CenteredString(false, (DWINUI::fontid*3), DWINUI::textcolor, DWINUI::backcolor, 0, DWIN_WIDTH, (DWIN_HEIGHT / 2), &buf); + } DWINUI::Draw_Button(BTN_Print, 26, 290); DWINUI::Draw_Button(BTN_Cancel, 146, 290); - show(); - Draw_Select_Highlight(true, 290); + if (fileprop_nopro.thumbsize) show(); + Draw_Select_Highlight(false, 290); DWIN_UpdateLCD(); } void Preview::invalidate() { - fileprop.thumbsize = 0; + fileprop_nopro.thumbsize = 0; } bool Preview::valid() { - return !!fileprop.thumbsize; + return !!fileprop_nopro.thumbsize; } void Preview::show() { - const uint8_t xpos = ((DWIN_WIDTH) - fileprop.thumbwidth) / 2, - ypos = (205 - fileprop.thumbheight) / 2 + 87; + const uint8_t xpos = ((DWIN_WIDTH) - fileprop_nopro.thumbwidth) / 2, + ypos = (205 - fileprop_nopro.thumbheight) / 2 + 87; DWIN_ICON_Show(xpos, ypos, 0x00); } diff --git a/Marlin/src/lcd/e3v2/proui/gcode_preview.h b/Marlin/src/lcd/e3v2/proui/gcode_preview.h index 5de4f953f6..9146642447 100644 --- a/Marlin/src/lcd/e3v2/proui/gcode_preview.h +++ b/Marlin/src/lcd/e3v2/proui/gcode_preview.h @@ -1,12 +1,13 @@ /** - * DWIN G-code thumbnail preview - * Author: Miguel A. Risco-Castillo - * version: 3.5.3 - * Date: 2023/04/25 + * Marlin 3D Printer Firmware + * Copyright (c) 2022 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 Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the License, or + * 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, @@ -14,15 +15,27 @@ * 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 Lesser General Public License + * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * For commercial applications additional licenses can be requested */ - #pragma once -void Preview_DrawFromSD(); -void Preview_Invalidate(); -bool Preview_Valid(); -void Preview_Show(); +/** + * DWIN G-code thumbnail preview + * Author: Miguel A. Risco-Castillo + * version: 3.1.2 + * Date: 2022/09/03 + */ + +class Preview { +public: + static void drawFromSD(); + static void invalidate(); + static bool valid(); + static void show(); +private: + static bool hasPreview(); +}; + +extern Preview preview; diff --git a/Marlin/src/lcd/e3v2/proui/gcode_preview_nopro.h b/Marlin/src/lcd/e3v2/proui/gcode_preview_nopro.h deleted file mode 100644 index 9146642447..0000000000 --- a/Marlin/src/lcd/e3v2/proui/gcode_preview_nopro.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2022 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 - -/** - * DWIN G-code thumbnail preview - * Author: Miguel A. Risco-Castillo - * version: 3.1.2 - * Date: 2022/09/03 - */ - -class Preview { -public: - static void drawFromSD(); - static void invalidate(); - static bool valid(); - static void show(); -private: - static bool hasPreview(); -}; - -extern Preview preview; diff --git a/configurations/Andrew427/Configuration.h b/configurations/Andrew427/Configuration.h index d85e24ceef..1402346caf 100644 --- a/configurations/Andrew427/Configuration.h +++ b/configurations/Andrew427/Configuration.h @@ -3419,8 +3419,6 @@ #ifdef PROUI_EX #define HAS_GCODE_PREVIEW 1 #define HAS_TOOLBAR 1 - #else - #define HAS_GCODE_PREVIEW_NOPRO 1 #endif #define DISABLE_TUNING_GRAPH 0// Temp plot graph - PID/MPC Tuning (1624 bytes of flash) #define HAS_ESDIAG 1 // View End-stop switch continuity (560 bytes of flash) diff --git a/configurations/BTT-SKR_Mini_E3_V2/ConfigurationMM.h b/configurations/BTT-SKR_Mini_E3_V2/ConfigurationMM.h index ecdb7b87ca..55265ea706 100644 --- a/configurations/BTT-SKR_Mini_E3_V2/ConfigurationMM.h +++ b/configurations/BTT-SKR_Mini_E3_V2/ConfigurationMM.h @@ -3418,8 +3418,6 @@ #ifdef PROUI_EX #define HAS_GCODE_PREVIEW 1 #define HAS_TOOLBAR 1 - #else - #define HAS_GCODE_PREVIEW_NOPRO 1 #endif #define DISABLE_TUNING_GRAPH 0// Temp plot graph - PID/MPC Tuning (1624 bytes of flash) #define HAS_ESDIAG 1 // View End-stop switch continuity (560 bytes of flash) diff --git a/configurations/BTT-SKR_Mini_E3_V2/ConfigurationUBL.h b/configurations/BTT-SKR_Mini_E3_V2/ConfigurationUBL.h index 749a43724f..0c8c80f49d 100644 --- a/configurations/BTT-SKR_Mini_E3_V2/ConfigurationUBL.h +++ b/configurations/BTT-SKR_Mini_E3_V2/ConfigurationUBL.h @@ -3418,8 +3418,6 @@ #ifdef PROUI_EX #define HAS_GCODE_PREVIEW 1 #define HAS_TOOLBAR 1 - #else - #define HAS_GCODE_PREVIEW_NOPRO 1 #endif #define DISABLE_TUNING_GRAPH 0// Temp plot graph - PID/MPC Tuning (1624 bytes of flash) #define HAS_ESDIAG 1 // View End-stop switch continuity (560 bytes of flash) diff --git a/configurations/BTT-SKR_Mini_E3_V3/ConfigurationMM.h b/configurations/BTT-SKR_Mini_E3_V3/ConfigurationMM.h index ce179a7ea6..164f4512ac 100644 --- a/configurations/BTT-SKR_Mini_E3_V3/ConfigurationMM.h +++ b/configurations/BTT-SKR_Mini_E3_V3/ConfigurationMM.h @@ -3418,8 +3418,6 @@ #ifdef PROUI_EX #define HAS_GCODE_PREVIEW 1 #define HAS_TOOLBAR 1 - #else - #define HAS_GCODE_PREVIEW_NOPRO 1 #endif #define DISABLE_TUNING_GRAPH 0// Temp plot graph - PID/MPC Tuning (1624 bytes of flash) #define HAS_ESDIAG 1 // View End-stop switch continuity (560 bytes of flash) diff --git a/configurations/BTT-SKR_Mini_E3_V3/ConfigurationUBL.h b/configurations/BTT-SKR_Mini_E3_V3/ConfigurationUBL.h index 1453608d27..cc04082be9 100644 --- a/configurations/BTT-SKR_Mini_E3_V3/ConfigurationUBL.h +++ b/configurations/BTT-SKR_Mini_E3_V3/ConfigurationUBL.h @@ -3418,8 +3418,6 @@ #ifdef PROUI_EX #define HAS_GCODE_PREVIEW 1 #define HAS_TOOLBAR 1 - #else - #define HAS_GCODE_PREVIEW_NOPRO 1 #endif #define DISABLE_TUNING_GRAPH 0// Temp plot graph - PID/MPC Tuning (1624 bytes of flash) #define HAS_ESDIAG 1 // View End-stop switch continuity (560 bytes of flash) diff --git a/configurations/Creality Ender/BLT/Configuration.h b/configurations/Creality Ender/BLT/Configuration.h index 40c2e889d9..45e900a075 100644 --- a/configurations/Creality Ender/BLT/Configuration.h +++ b/configurations/Creality Ender/BLT/Configuration.h @@ -3419,8 +3419,6 @@ #ifdef PROUI_EX #define HAS_GCODE_PREVIEW 1 #define HAS_TOOLBAR 1 - #else - #define HAS_GCODE_PREVIEW_NOPRO 1 #endif #define DISABLE_TUNING_GRAPH 0// Temp plot graph - PID/MPC Tuning (1624 bytes of flash) #define HAS_ESDIAG 1 // View End-stop switch continuity (560 bytes of flash) diff --git a/configurations/Creality Ender/Default-NP/Configuration.h b/configurations/Creality Ender/Default-NP/Configuration.h index 7257e1ac53..dd46fac988 100644 --- a/configurations/Creality Ender/Default-NP/Configuration.h +++ b/configurations/Creality Ender/Default-NP/Configuration.h @@ -3419,8 +3419,6 @@ #ifdef PROUI_EX #define HAS_GCODE_PREVIEW 1 #define HAS_TOOLBAR 1 - #else - #define HAS_GCODE_PREVIEW_NOPRO 1 #endif #define DISABLE_TUNING_GRAPH 0// Temp plot graph - PID/MPC Tuning (1624 bytes of flash) #define HAS_ESDIAG 1 // View End-stop switch continuity (560 bytes of flash) diff --git a/configurations/Creality Ender/MM/Configuration.h b/configurations/Creality Ender/MM/Configuration.h index 05574457b3..e9d1255f2b 100644 --- a/configurations/Creality Ender/MM/Configuration.h +++ b/configurations/Creality Ender/MM/Configuration.h @@ -3418,8 +3418,6 @@ #ifdef PROUI_EX #define HAS_GCODE_PREVIEW 1 #define HAS_TOOLBAR 1 - #else - #define HAS_GCODE_PREVIEW_NOPRO 1 #endif #define DISABLE_TUNING_GRAPH 0// Temp plot graph - PID/MPC Tuning (1624 bytes of flash) #define HAS_ESDIAG 1 // View End-stop switch continuity (560 bytes of flash) diff --git a/configurations/Creality Ender/UBL/Configuration.h b/configurations/Creality Ender/UBL/Configuration.h index 204d8fa8e6..e07b6be190 100644 --- a/configurations/Creality Ender/UBL/Configuration.h +++ b/configurations/Creality Ender/UBL/Configuration.h @@ -3419,8 +3419,6 @@ #ifdef PROUI_EX #define HAS_GCODE_PREVIEW 1 #define HAS_TOOLBAR 1 - #else - #define HAS_GCODE_PREVIEW_NOPRO 1 #endif #define DISABLE_TUNING_GRAPH 0// Temp plot graph - PID/MPC Tuning (1624 bytes of flash) #define HAS_ESDIAG 1 // View End-stop switch continuity (560 bytes of flash) diff --git a/configurations/Voxelab Aquila 427/BLT/Configuration.h b/configurations/Voxelab Aquila 427/BLT/Configuration.h index 7ad202ff7c..482cfa173c 100644 --- a/configurations/Voxelab Aquila 427/BLT/Configuration.h +++ b/configurations/Voxelab Aquila 427/BLT/Configuration.h @@ -3419,8 +3419,6 @@ #ifdef PROUI_EX #define HAS_GCODE_PREVIEW 1 #define HAS_TOOLBAR 1 - #else - #define HAS_GCODE_PREVIEW_NOPRO 1 #endif #define DISABLE_TUNING_GRAPH 0// Temp plot graph - PID/MPC Tuning (1624 bytes of flash) #define HAS_ESDIAG 1 // View End-stop switch continuity (560 bytes of flash) diff --git a/configurations/Voxelab Aquila 427/Default-NP/Configuration.h b/configurations/Voxelab Aquila 427/Default-NP/Configuration.h index d2ba1696f2..1703b2bc9a 100644 --- a/configurations/Voxelab Aquila 427/Default-NP/Configuration.h +++ b/configurations/Voxelab Aquila 427/Default-NP/Configuration.h @@ -3419,8 +3419,6 @@ #ifdef PROUI_EX #define HAS_GCODE_PREVIEW 1 #define HAS_TOOLBAR 1 - #else - #define HAS_GCODE_PREVIEW_NOPRO 1 #endif #define DISABLE_TUNING_GRAPH 0// Temp plot graph - PID/MPC Tuning (1624 bytes of flash) #define HAS_ESDIAG 1 // View End-stop switch continuity (560 bytes of flash) diff --git a/configurations/Voxelab Aquila 427/MM/Configuration.h b/configurations/Voxelab Aquila 427/MM/Configuration.h index 12d667de7a..cd3a2afd73 100644 --- a/configurations/Voxelab Aquila 427/MM/Configuration.h +++ b/configurations/Voxelab Aquila 427/MM/Configuration.h @@ -3418,8 +3418,6 @@ #ifdef PROUI_EX #define HAS_GCODE_PREVIEW 1 #define HAS_TOOLBAR 1 - #else - #define HAS_GCODE_PREVIEW_NOPRO 1 #endif #define DISABLE_TUNING_GRAPH 0// Temp plot graph - PID/MPC Tuning (1624 bytes of flash) #define HAS_ESDIAG 1 // View End-stop switch continuity (560 bytes of flash) diff --git a/configurations/Voxelab Aquila 427/UBL/Configuration.h b/configurations/Voxelab Aquila 427/UBL/Configuration.h index 3f43ef6d17..7923147524 100644 --- a/configurations/Voxelab Aquila 427/UBL/Configuration.h +++ b/configurations/Voxelab Aquila 427/UBL/Configuration.h @@ -3419,8 +3419,6 @@ #ifdef PROUI_EX #define HAS_GCODE_PREVIEW 1 #define HAS_TOOLBAR 1 - #else - #define HAS_GCODE_PREVIEW_NOPRO 1 #endif #define DISABLE_TUNING_GRAPH 0// Temp plot graph - PID/MPC Tuning (1624 bytes of flash) #define HAS_ESDIAG 1 // View End-stop switch continuity (560 bytes of flash) diff --git a/configurations/Voxelab Aquila/BLT/Configuration.h b/configurations/Voxelab Aquila/BLT/Configuration.h index 5d043c78ba..a37b9c2179 100644 --- a/configurations/Voxelab Aquila/BLT/Configuration.h +++ b/configurations/Voxelab Aquila/BLT/Configuration.h @@ -3419,8 +3419,6 @@ #ifdef PROUI_EX #define HAS_GCODE_PREVIEW 1 #define HAS_TOOLBAR 1 - #else - #define HAS_GCODE_PREVIEW_NOPRO 1 #endif #define DISABLE_TUNING_GRAPH 0// Temp plot graph - PID/MPC Tuning (1624 bytes of flash) #define HAS_ESDIAG 1 // View End-stop switch continuity (560 bytes of flash) diff --git a/configurations/Voxelab Aquila/BLT/ConfigurationPro.h b/configurations/Voxelab Aquila/BLT/ConfigurationPro.h index 1c5b6e9c30..68dcd123c9 100644 --- a/configurations/Voxelab Aquila/BLT/ConfigurationPro.h +++ b/configurations/Voxelab Aquila/BLT/ConfigurationPro.h @@ -3419,8 +3419,6 @@ #ifdef PROUI_EX #define HAS_GCODE_PREVIEW 1 #define HAS_TOOLBAR 1 - #else - #define HAS_GCODE_PREVIEW_NOPRO 1 #endif #define DISABLE_TUNING_GRAPH 0// Temp plot graph - PID/MPC Tuning (1624 bytes of flash) #define HAS_ESDIAG 1 // View End-stop switch continuity (560 bytes of flash) diff --git a/configurations/Voxelab Aquila/Default-NP/Configuration.h b/configurations/Voxelab Aquila/Default-NP/Configuration.h index 070c5fe551..04af06fcb1 100644 --- a/configurations/Voxelab Aquila/Default-NP/Configuration.h +++ b/configurations/Voxelab Aquila/Default-NP/Configuration.h @@ -3419,8 +3419,6 @@ #ifdef PROUI_EX #define HAS_GCODE_PREVIEW 1 #define HAS_TOOLBAR 1 - #else - #define HAS_GCODE_PREVIEW_NOPRO 1 #endif #define DISABLE_TUNING_GRAPH 0// Temp plot graph - PID/MPC Tuning (1624 bytes of flash) #define HAS_ESDIAG 1 // View End-stop switch continuity (560 bytes of flash) diff --git a/configurations/Voxelab Aquila/MM/Configuration.h b/configurations/Voxelab Aquila/MM/Configuration.h index e84690fdcd..dd12545907 100644 --- a/configurations/Voxelab Aquila/MM/Configuration.h +++ b/configurations/Voxelab Aquila/MM/Configuration.h @@ -3418,8 +3418,6 @@ #ifdef PROUI_EX #define HAS_GCODE_PREVIEW 1 #define HAS_TOOLBAR 1 - #else - #define HAS_GCODE_PREVIEW_NOPRO 1 #endif #define DISABLE_TUNING_GRAPH 0// Temp plot graph - PID/MPC Tuning (1624 bytes of flash) #define HAS_ESDIAG 1 // View End-stop switch continuity (560 bytes of flash) diff --git a/configurations/Voxelab Aquila/UBL/Configuration.h b/configurations/Voxelab Aquila/UBL/Configuration.h index def8a221d5..1921022260 100644 --- a/configurations/Voxelab Aquila/UBL/Configuration.h +++ b/configurations/Voxelab Aquila/UBL/Configuration.h @@ -3419,8 +3419,6 @@ #ifdef PROUI_EX #define HAS_GCODE_PREVIEW 1 #define HAS_TOOLBAR 1 - #else - #define HAS_GCODE_PREVIEW_NOPRO 1 #endif #define DISABLE_TUNING_GRAPH 0// Temp plot graph - PID/MPC Tuning (1624 bytes of flash) #define HAS_ESDIAG 1 // View End-stop switch continuity (560 bytes of flash) diff --git a/configurations/Voxelab Aquila/UBL/ConfigurationPro.h b/configurations/Voxelab Aquila/UBL/ConfigurationPro.h index f1994611b7..da25fcf328 100644 --- a/configurations/Voxelab Aquila/UBL/ConfigurationPro.h +++ b/configurations/Voxelab Aquila/UBL/ConfigurationPro.h @@ -3419,8 +3419,6 @@ #ifdef PROUI_EX #define HAS_GCODE_PREVIEW 1 #define HAS_TOOLBAR 1 - #else - #define HAS_GCODE_PREVIEW_NOPRO 1 #endif #define DISABLE_TUNING_GRAPH 0// Temp plot graph - PID/MPC Tuning (1624 bytes of flash) #define HAS_ESDIAG 1 // View End-stop switch continuity (560 bytes of flash) diff --git a/configurations/Voxelab Aquila/X3/Configuration.h b/configurations/Voxelab Aquila/X3/Configuration.h index c4ab277c42..4b8bd46d59 100644 --- a/configurations/Voxelab Aquila/X3/Configuration.h +++ b/configurations/Voxelab Aquila/X3/Configuration.h @@ -3421,8 +3421,6 @@ #ifdef PROUI_EX #define HAS_GCODE_PREVIEW 1 #define HAS_TOOLBAR 1 - #else - #define HAS_GCODE_PREVIEW_NOPRO 1 #endif #define DISABLE_TUNING_GRAPH 0// Temp plot graph - PID/MPC Tuning (1624 bytes of flash) #define HAS_ESDIAG 1 // View End-stop switch continuity (560 bytes of flash)