Skip to content

Commit

Permalink
Fixed [BUG] Crash and reboot after second time gcode preview.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Nazar78 committed Oct 30, 2023
1 parent e456224 commit 92696d8
Show file tree
Hide file tree
Showing 26 changed files with 101 additions and 199 deletions.
2 changes: 0 additions & 2 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/e3v2/proui/custom_gcodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down
75 changes: 22 additions & 53 deletions Marlin/src/lcd/e3v2/proui/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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); }

Expand All @@ -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())
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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)
Expand Down Expand Up @@ -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);
Expand All @@ -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)
Expand Down
Loading

0 comments on commit 92696d8

Please sign in to comment.