From 6747d350a53ff78be2e7679cb3e9afec0d9aca52 Mon Sep 17 00:00:00 2001 From: Sola <42537573+solawc@users.noreply.github.com> Date: Fri, 2 Apr 2021 08:19:22 +0800 Subject: [PATCH] MKS H43 fix, cleanup (#21500) Followup to #21485 --- Marlin/Configuration.h | 2 +- Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp | 2 +- Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp | 9 ++++++--- Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.h | 4 ++-- Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp | 7 ++++++- Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h | 7 +++++-- 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 5f9b1782fc..0847892934 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2374,7 +2374,7 @@ //#define DGUS_LCD_UI_FYSETC //#define DGUS_LCD_UI_HIPRECY -// #define DGUS_LCD_UI_MKS +//#define DGUS_LCD_UI_MKS #if ENABLED(DGUS_LCD_UI_MKS) #define USE_MKS_GREEN_UI #endif diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp index b4e876ce4c..067ea482c7 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp @@ -176,6 +176,7 @@ void DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var) { #if HAS_PID_HEATING void DGUSScreenHandler::DGUSLCD_SendTemperaturePID(DGUS_VP_Variable &var) { float value = *(float *)var.memadr; + value /= 10; float valuesend = 0; switch (var.VP) { default: return; @@ -343,7 +344,6 @@ void DGUSScreenHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var) SetupConfirmAction(nullptr); GotoScreen(DGUSLCD_SCREEN_POPUP); } - #endif // SDSUPPORT void DGUSScreenHandler::ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr) { diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp index a2ccdada36..786d1821a6 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp @@ -44,7 +44,7 @@ #endif uint16_t manualMoveStep = 1; -float distanceFilament = 10; +uint16_t distanceFilament = 10; uint16_t FilamentSpeed = 25; float ZOffset_distance = 0.1; float mesh_adj_distance = 0.01; @@ -554,7 +554,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { #if ENABLED(DGUS_FILAMENT_LOADUNLOAD) VPHELPER(VP_LOAD_Filament, nullptr, &ScreenHandler.MKS_FilamentLoad, nullptr), VPHELPER(VP_UNLOAD_Filament, nullptr, &ScreenHandler.MKS_FilamentUnLoad, nullptr), - VPHELPER(VP_Filament_distance, &distanceFilament, &ScreenHandler.GetManualFilament, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_Filament_distance, &distanceFilament, &ScreenHandler.GetManualFilament, ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_Filament_speed, &FilamentSpeed, &ScreenHandler.GetManualFilamentSpeed, ScreenHandler.DGUSLCD_SendWordValueToDisplay), #endif #endif @@ -733,8 +733,9 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { // SDCard File listing - VPHELPER(VP_SD_FileSelected, nullptr, ScreenHandler.DGUSLCD_SD_FileSelected, nullptr), + #if ENABLED(SDSUPPORT) + VPHELPER(VP_SD_FileSelected, nullptr, ScreenHandler.DGUSLCD_SD_FileSelected, nullptr), VPHELPER(VP_SD_ScrollEvent, nullptr, ScreenHandler.DGUSLCD_SD_ScrollFilelist, 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), @@ -759,6 +760,8 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_OFFSET_Y, &probe.offset.y, ScreenHandler.GetOffsetValue,ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), VPHELPER(VP_OFFSET_Z, &probe.offset.z, ScreenHandler.GetOffsetValue,ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), #endif + #else + VPHELPER(VP_SD_FileSelected, nullptr, ScreenHandler.PrintReturn, nullptr), #endif #if ENABLED(DGUS_UI_WAITING) diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.h b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.h index 9a3690f356..ac0a482ede 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.h +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.h @@ -36,7 +36,7 @@ #define MKS_FINSH extern uint16_t manualMoveStep; -extern float distanceFilament; +extern uint16_t distanceFilament; extern uint16_t FilamentSpeed; extern float ZOffset_distance; extern float mesh_adj_distance; @@ -55,7 +55,7 @@ void MKS_resume_print_move(); extern float z_offset_add; -xyz_int_t tmc_step; +extern xyz_int_t tmc_step; extern uint16_t lcd_default_light; diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp index b6633d3a1f..54500011f8 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp @@ -270,6 +270,11 @@ void DGUSScreenHandler::DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var) { GotoScreen(MKSLCD_SCREEN_PrintDone); } +#else + void DGUSScreenHandler::PrintReturn(DGUS_VP_Variable& var, void *val_ptr) { + uint16_t value = swap16(*(uint16_t*)val_ptr); + if (value == 0x0F) GotoScreen(DGUSLCD_SCREEN_MAIN); + } #endif // SDSUPPORT void DGUSScreenHandler::ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr) { @@ -1215,7 +1220,7 @@ void DGUSScreenHandler::MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ } else { #if EITHER(HAS_MULTI_HOTEND, SINGLENOZZLE) - swap_tool = 2; + swap_tool = 1; #endif } #endif diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h index 2d0678ca5b..07c123d928 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h @@ -158,13 +158,14 @@ public: static void GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_ptr); #endif - // File touched. - static void DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr); + #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. @@ -183,6 +184,8 @@ public: static void SDCardError(); // Marlin informed us about SD print completion. static void SDPrintingFinished(); + #else + static void PrintReturn(DGUS_VP_Variable &var, void *val_ptr); #endif // OK Button the Confirm screen.