Browse Source

♻️ Consolidate DGUSScreenHandler class (#24067)

FB4S_WIFI
Scott Lahteine 3 years ago
committed by Scott Lahteine
parent
commit
9ab1a57d72
  1. 6
      Marlin/src/lcd/extui/dgus/DGUSDisplay.cpp
  2. 5
      Marlin/src/lcd/extui/dgus/DGUSDisplay.h
  3. 2
      Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp
  4. 5
      Marlin/src/lcd/extui/dgus/DGUSScreenHandler.h
  5. 241
      Marlin/src/lcd/extui/dgus/DGUSScreenHandlerBase.h
  6. 16
      Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp
  7. 219
      Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.h
  8. 5
      Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp
  9. 219
      Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.h
  10. 86
      Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp
  11. 150
      Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp
  12. 265
      Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h
  13. 219
      Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.h
  14. 2
      Marlin/src/module/settings.cpp

6
Marlin/src/lcd/extui/dgus/DGUSDisplay.cpp

@ -109,12 +109,6 @@ void DGUSDisplay::WriteVariable(uint16_t adr, int8_t value) {
WriteVariable(adr, static_cast<const void*>(&value), sizeof(int8_t));
}
#if ENABLED(DGUS_LCD_UI_MKS)
void DGUSDisplay::MKS_WriteVariable(uint16_t adr, uint8_t value) {
WriteVariable(adr, static_cast<const void *>(&value), sizeof(uint8_t));
}
#endif
void DGUSDisplay::WriteVariable(uint16_t adr, long value) {
union { long l; char lb[4]; } endian;
char tmp[4];

5
Marlin/src/lcd/extui/dgus/DGUSDisplay.h

@ -50,6 +50,8 @@ typedef enum : uint8_t {
DGUS_WAIT_TELEGRAM, //< LEN received, Waiting for to receive all bytes.
} rx_datagram_state_t;
constexpr uint16_t swap16(const uint16_t value) { return (value & 0xFFU) << 8U | (value >> 8U); }
// Low-Level access to the display.
class DGUSDisplay {
public:
@ -66,8 +68,6 @@ public:
static void WriteVariable(uint16_t adr, uint8_t value);
static void WriteVariable(uint16_t adr, int8_t value);
static void WriteVariable(uint16_t adr, long value);
static void MKS_WriteVariable(uint16_t adr, uint8_t value);
// Utility functions for bridging ui_api and dbus
template<typename T, float(*Getter)(const T), T selector, typename WireType=uint16_t>
@ -105,7 +105,6 @@ private:
static void WritePGM(const char str[], uint8_t len);
static void ProcessRx();
static uint16_t swap16(const uint16_t value) { return (value & 0xFFU) << 8U | (value >> 8U); }
static rx_datagram_state_t rx_datagram_state;
static uint8_t rx_datagram_len;
static bool Initialized, no_reentrance;

2
Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp

@ -40,7 +40,7 @@
#include "../../../feature/powerloss.h"
#endif
DGUSScreenHandler ScreenHandler;
DGUSScreenHandlerClass ScreenHandler;
uint16_t DGUSScreenHandler::ConfirmVP;

5
Marlin/src/lcd/extui/dgus/DGUSScreenHandler.h

@ -42,9 +42,6 @@
#endif
// endianness swap
inline uint16_t swap16(const uint16_t value) { return (value & 0xFFU) << 8U | (value >> 8U); }
#if ENABLED(DGUS_LCD_UI_ORIGIN)
#include "origin/DGUSScreenHandler.h"
#elif ENABLED(DGUS_LCD_UI_MKS)
@ -55,7 +52,7 @@ inline uint16_t swap16(const uint16_t value) { return (value & 0xFFU) << 8U | (v
#include "hiprecy/DGUSScreenHandler.h"
#endif
extern DGUSScreenHandler ScreenHandler;
extern DGUSScreenHandlerClass ScreenHandler;
// Helper to define a DGUS_VP_Variable for common use-cases.
#define VPHELPER(VPADR, VPADRVAR, RXFPTR, TXFPTR) { \

241
Marlin/src/lcd/extui/dgus/DGUSScreenHandlerBase.h

@ -0,0 +1,241 @@
/**
* 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 <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "DGUSDisplay.h"
#include "DGUSVPVariable.h"
#include "DGUSDisplayDef.h"
#include "../../../inc/MarlinConfig.h"
enum DGUSLCD_Screens : uint8_t;
class DGUSScreenHandler {
public:
DGUSScreenHandler() = default;
static bool loop();
// Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen
// The bools specifying whether the strings are in RAM or FLASH.
static void sendinfoscreen(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash);
}
static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash);
}
static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const 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 on the Confirm screen.
static void ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr);
// Update data after going to a new screen (by display or by GotoScreen)
// remember to store the last-displayed screen so it can be restored.
// (e.g., for popup 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<typename T>
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<unsigned int decimals>
static void DGUSLCD_SendFloatAsLongValueToDisplay(DGUS_VP_Variable &var) {
if (var.memadr) {
float f = *(float *)var.memadr;
f *= cpow(10, decimals);
dgusdisplay.WriteVariable(var.VP, (long)f);
}
}
// 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<unsigned int decimals>
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);
dgusdisplay.WriteVariable(var.VP, (int16_t)f);
}
}
// Force an update of all VP on the current screen.
static void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; }
// Has all VPs sent to the screen
static bool IsScreenComplete() { return ScreenComplete; }
static DGUSLCD_Screens getCurrentScreen() { return current_screen; }
static void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; }
protected:
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)();
};

16
Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp

@ -333,9 +333,9 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
if (filament_data.action == 0) { // Go back to utility screen
#if HAS_HOTEND
thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E0);
#endif
#if HAS_MULTI_HOTEND
thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E1);
#if HAS_MULTI_HOTEND
thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E1);
#endif
#endif
GotoScreen(DGUSLCD_SCREEN_UTILITY);
}
@ -348,7 +348,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
thermalManager.setTargetHotend(e_temp, filament_data.extruder);
break;
#endif
#if HAS_MULTI_EXTRUDER
#if HAS_MULTI_HOTEND
case VP_E1_FILAMENT_LOAD_UNLOAD:
filament_data.extruder = ExtUI::extruder_t::E1;
thermalManager.setTargetHotend(e_temp, filament_data.extruder);
@ -413,14 +413,10 @@ bool DGUSScreenHandler::loop() {
if (!booted && ELAPSED(ms, BOOTSCREEN_TIMEOUT)) {
booted = true;
if (TERN0(POWER_LOSS_RECOVERY, recovery.valid()))
GotoScreen(DGUSLCD_SCREEN_POWER_LOSS);
else
GotoScreen(DGUSLCD_SCREEN_MAIN);
GotoScreen(TERN0(POWER_LOSS_RECOVERY, recovery.valid()) ? DGUSLCD_SCREEN_POWER_LOSS : DGUSLCD_SCREEN_MAIN);
}
#endif
return IsScreenComplete();
}

219
Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.h

@ -21,224 +21,9 @@
*/
#pragma once
#include "../DGUSDisplay.h"
#include "../DGUSVPVariable.h"
#include "../DGUSDisplayDef.h"
#include "../DGUSScreenHandlerBase.h"
#include "../../../../inc/MarlinConfig.h"
enum DGUSLCD_Screens : uint8_t;
class DGUSScreenHandler {
public:
DGUSScreenHandler() = default;
static bool loop();
// Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen
// The bools specifying whether the strings are in RAM or FLASH.
static void sendinfoscreen(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash);
}
static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash);
}
static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const 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<typename T>
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<unsigned int decimals>
static void DGUSLCD_SendFloatAsLongValueToDisplay(DGUS_VP_Variable &var) {
if (var.memadr) {
float f = *(float *)var.memadr;
f *= cpow(10, decimals);
dgusdisplay.WriteVariable(var.VP, (long)f);
}
}
// 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<unsigned int decimals>
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);
dgusdisplay.WriteVariable(var.VP, (int16_t)f);
}
}
// Force an update of all VP on the current screen.
static void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; }
// Has all VPs sent to the screen
static bool IsScreenComplete() { return ScreenComplete; }
static DGUSLCD_Screens getCurrentScreen() { return current_screen; }
static 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)();
};
typedef DGUSScreenHandler DGUSScreenHandlerClass;
#if ENABLED(POWER_LOSS_RECOVERY)
#define PLR_SCREEN_RECOVER DGUSLCD_SCREEN_SDPRINTMANIPULATION

5
Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp

@ -411,9 +411,12 @@ bool DGUSScreenHandler::loop() {
if (!booted && TERN0(POWER_LOSS_RECOVERY, recovery.valid()))
booted = true;
if (!booted && ELAPSED(ms, TERN(USE_MKS_GREEN_UI, 1000, BOOTSCREEN_TIMEOUT)))
if (!booted && ELAPSED(ms, BOOTSCREEN_TIMEOUT)) {
booted = true;
GotoScreen(TERN0(POWER_LOSS_RECOVERY, recovery.valid()) ? DGUSLCD_SCREEN_POWER_LOSS : DGUSLCD_SCREEN_MAIN);
}
#endif
return IsScreenComplete();
}

219
Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.h

@ -21,224 +21,9 @@
*/
#pragma once
#include "../DGUSDisplay.h"
#include "../DGUSVPVariable.h"
#include "../DGUSDisplayDef.h"
#include "../DGUSScreenHandlerBase.h"
#include "../../../../inc/MarlinConfig.h"
enum DGUSLCD_Screens : uint8_t;
class DGUSScreenHandler {
public:
DGUSScreenHandler() = default;
static bool loop();
// Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen
// The bools specifying whether the strings are in RAM or FLASH.
static void sendinfoscreen(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash);
}
static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash);
}
static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const 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<typename T>
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<unsigned int decimals>
static void DGUSLCD_SendFloatAsLongValueToDisplay(DGUS_VP_Variable &var) {
if (var.memadr) {
float f = *(float *)var.memadr;
f *= cpow(10, decimals);
dgusdisplay.WriteVariable(var.VP, (long)f);
}
}
// 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<unsigned int decimals>
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);
dgusdisplay.WriteVariable(var.VP, (int16_t)f);
}
}
// Force an update of all VP on the current screen.
static void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; }
// Has all VPs sent to the screen
static bool IsScreenComplete() { return ScreenComplete; }
static DGUSLCD_Screens getCurrentScreen() { return current_screen; }
static 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)();
};
typedef DGUSScreenHandler DGUSScreenHandlerClass;
#if ENABLED(POWER_LOSS_RECOVERY)
#define PLR_SCREEN_RECOVER DGUSLCD_SCREEN_SDPRINTMANIPULATION

86
Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp

@ -69,7 +69,7 @@ void MKS_reset_settings() {
{ 20, 20 }, { 20, 20 },
{ X_CENTER, Y_CENTER }
};
mks_language_index = 0;
mks_language_index = MKS_SimpleChinese;
COPY(mks_corner_offsets, init_dgus_level_offsets);
mks_park_pos.set(20, 20, 10);
mks_min_extrusion_temp = 0;
@ -560,8 +560,8 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
VPHELPER(VP_PID_AUTOTUNE_E0, nullptr, ScreenHandler.HandlePIDAutotune, nullptr),
#endif
#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_LOAD_Filament, nullptr, ScreenHandler.FilamentLoad, nullptr),
VPHELPER(VP_UNLOAD_Filament, nullptr, ScreenHandler.FilamentUnLoad, nullptr),
VPHELPER(VP_Filament_distance, &distanceFilament, ScreenHandler.GetManualFilament, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Filament_speed, &filamentSpeed_mm_s, ScreenHandler.GetManualFilamentSpeed, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#endif
@ -618,16 +618,16 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
VPHELPER(VP_ZPos, &current_position.z, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
// Level Point Set
VPHELPER(VP_Level_Point_One_X, &mks_corner_offsets[0].x, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_One_Y, &mks_corner_offsets[0].y, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Two_X, &mks_corner_offsets[1].x, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Two_Y, &mks_corner_offsets[1].y, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Three_X, &mks_corner_offsets[2].x, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Three_Y, &mks_corner_offsets[2].y, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Four_X, &mks_corner_offsets[3].x, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Four_Y, &mks_corner_offsets[3].y, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Five_X, &mks_corner_offsets[4].x, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Five_Y, &mks_corner_offsets[4].y, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_One_X, &mks_corner_offsets[0].x, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_One_Y, &mks_corner_offsets[0].y, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Two_X, &mks_corner_offsets[1].x, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Two_Y, &mks_corner_offsets[1].y, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Three_X, &mks_corner_offsets[2].x, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Three_Y, &mks_corner_offsets[2].y, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Four_X, &mks_corner_offsets[3].x, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Four_Y, &mks_corner_offsets[3].y, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Five_X, &mks_corner_offsets[4].x, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Five_Y, &mks_corner_offsets[4].y, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
// Print Progress
VPHELPER(VP_PrintProgress_Percentage, nullptr, nullptr, ScreenHandler.DGUSLCD_SendPrintProgressToDisplay),
@ -639,50 +639,50 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
VPHELPER(VP_SD_FileSelect_Back, nullptr, ScreenHandler.SD_FileBack, nullptr),
// Print Time
VPHELPER_STR(VP_PrintTime, nullptr, VP_PrintTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintTimeToDisplay_MKS),
VPHELPER_STR(VP_PrintTime, nullptr, VP_PrintTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintTimeToDisplay),
#if ENABLED(PRINTCOUNTER)
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], ScreenHandler.HandleStepPerMMChanged_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_Y_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Y_AXIS], ScreenHandler.HandleStepPerMMChanged_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], ScreenHandler.HandleStepPerMMChanged_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_X_STEP_PER_MM, &planner.settings.axis_steps_per_mm[X_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_Y_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Y_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_X_MAX_SPEED, &planner.settings.max_feedrate_mm_s[X_AXIS], ScreenHandler.HandleMaxSpeedChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_Y_MAX_SPEED, &planner.settings.max_feedrate_mm_s[Y_AXIS], ScreenHandler.HandleMaxSpeedChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_Z_MAX_SPEED, &planner.settings.max_feedrate_mm_s[Z_AXIS], ScreenHandler.HandleMaxSpeedChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_X_MAX_SPEED, &planner.settings.max_feedrate_mm_s[X_AXIS], ScreenHandler.HandleMaxSpeedChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_Y_MAX_SPEED, &planner.settings.max_feedrate_mm_s[Y_AXIS], ScreenHandler.HandleMaxSpeedChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_Z_MAX_SPEED, &planner.settings.max_feedrate_mm_s[Z_AXIS], ScreenHandler.HandleMaxSpeedChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
#if HAS_HOTEND
VPHELPER(VP_E0_MAX_SPEED, &planner.settings.max_feedrate_mm_s[E_AXIS_N(0)], ScreenHandler.HandleExtruderMaxSpeedChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_E0_MAX_SPEED, &planner.settings.max_feedrate_mm_s[E_AXIS_N(0)], ScreenHandler.HandleExtruderMaxSpeedChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
#if HAS_MULTI_HOTEND
VPHELPER(VP_E1_MAX_SPEED, &planner.settings.max_feedrate_mm_s[E_AXIS_N(1)], ScreenHandler.HandleExtruderMaxSpeedChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_E1_MAX_SPEED, &planner.settings.max_feedrate_mm_s[E_AXIS_N(1)], ScreenHandler.HandleExtruderMaxSpeedChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
#endif
#endif
VPHELPER(VP_X_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[X_AXIS], ScreenHandler.HandleMaxAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Y_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[Y_AXIS], ScreenHandler.HandleMaxAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Z_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[Z_AXIS], ScreenHandler.HandleMaxAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_X_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[X_AXIS], ScreenHandler.HandleMaxAccChange, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Y_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[Y_AXIS], ScreenHandler.HandleMaxAccChange, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Z_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[Z_AXIS], ScreenHandler.HandleMaxAccChange, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#if HAS_HOTEND
VPHELPER(VP_E0_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(0)], ScreenHandler.HandleExtruderAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_E0_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(0)], ScreenHandler.HandleExtruderAccChange, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#if HAS_MULTI_HOTEND
VPHELPER(VP_E1_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)], ScreenHandler.HandleExtruderAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_E1_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)], ScreenHandler.HandleExtruderAccChange, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#endif
#endif
VPHELPER(VP_TRAVEL_SPEED, (uint16_t *)&planner.settings.travel_acceleration, ScreenHandler.HandleTravelAccChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_FEEDRATE_MIN_SPEED, (uint16_t *)&planner.settings.min_feedrate_mm_s, ScreenHandler.HandleFeedRateMinChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_T_F_SPEED, (uint16_t *)&planner.settings.min_travel_feedrate_mm_s, ScreenHandler.HandleMin_T_F_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_ACC_SPEED, (uint16_t *)&planner.settings.acceleration, ScreenHandler.HandleAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_TRAVEL_SPEED, (uint16_t *)&planner.settings.travel_acceleration, ScreenHandler.HandleTravelAccChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_FEEDRATE_MIN_SPEED, (uint16_t *)&planner.settings.min_feedrate_mm_s, ScreenHandler.HandleFeedRateMinChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_T_F_SPEED, (uint16_t *)&planner.settings.min_travel_feedrate_mm_s, ScreenHandler.HandleMin_T_F, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_ACC_SPEED, (uint16_t *)&planner.settings.acceleration, ScreenHandler.HandleAccChange, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_X_PARK_POS, &mks_park_pos.x, ScreenHandler.GetParkPos_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Y_PARK_POS, &mks_park_pos.y, ScreenHandler.GetParkPos_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Z_PARK_POS, &mks_park_pos.z, ScreenHandler.GetParkPos_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_X_PARK_POS, &mks_park_pos.x, ScreenHandler.GetParkPos, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Y_PARK_POS, &mks_park_pos.y, ScreenHandler.GetParkPos, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Z_PARK_POS, &mks_park_pos.z, ScreenHandler.GetParkPos, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#if ENABLED(PREVENT_COLD_EXTRUSION)
VPHELPER(VP_MIN_EX_T, &thermalManager.extrude_min_temp, ScreenHandler.HandleGetExMinTemp_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_MIN_EX_T, &thermalManager.extrude_min_temp, ScreenHandler.HandleGetExMinTemp, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#endif
#if ENABLED(SENSORLESS_HOMING) // TMC SENSORLESS Setting
@ -725,8 +725,8 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
#endif
VPHELPER(VP_EEPROM_CTRL, nullptr, ScreenHandler.EEPROM_CTRL, nullptr),
VPHELPER(VP_LEVEL_BUTTON, nullptr, ScreenHandler.Level_Ctrl_MKS, nullptr),
VPHELPER(VP_LANGUAGE_CHANGE, nullptr, ScreenHandler.LanguageChange_MKS, nullptr),
VPHELPER(VP_LEVEL_BUTTON, nullptr, ScreenHandler.Level_Ctrl, nullptr),
VPHELPER(VP_LANGUAGE_CHANGE, nullptr, ScreenHandler.LanguageChange, nullptr),
//VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, ScreenHandler.HandleLiveAdjustZ, nullptr),
@ -743,9 +743,9 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
VPHELPER(VP_AutoTurnOffSw, nullptr, ScreenHandler.GetTurnOffCtrl, nullptr),
#if HAS_HOTEND
VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], ScreenHandler.HandleStepPerMMExtruderChanged_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
#if HAS_MULTI_HOTEND
VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], ScreenHandler.HandleStepPerMMExtruderChanged_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
#endif
#endif
@ -791,10 +791,10 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
//{.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},
{.VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay_Language_MKS},
{.VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay_Language_MKS},
{.VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay_Language_MKS},
{.VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay_Language_MKS},
{.VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay_Language},
{.VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay_Language},
{.VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay_Language},
{.VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay_Language},
VPHELPER(0, 0, 0, 0) // must be last entry.
};

150
Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp

@ -52,36 +52,36 @@
#endif
bool DGUSAutoTurnOff = false;
uint8_t mks_language_index; // Initialized by settings.load()
MKS_Language mks_language_index; // Initialized by settings.load()
// endianness swap
uint32_t swap32(const uint32_t value) { return (value & 0x000000FFU) << 24U | (value & 0x0000FF00U) << 8U | (value & 0x00FF0000U) >> 8U | (value & 0xFF000000U) >> 24U; }
#if 0
void DGUSScreenHandler::sendinfoscreen_ch_mks(const uint16_t *line1, const uint16_t *line2, const uint16_t *line3, const uint16_t *line4) {
void DGUSScreenHandlerMKS::sendinfoscreen_ch(const uint16_t *line1, const uint16_t *line2, const uint16_t *line3, const uint16_t *line4) {
dgusdisplay.WriteVariable(VP_MSGSTR1, line1, 32, true);
dgusdisplay.WriteVariable(VP_MSGSTR2, line2, 32, true);
dgusdisplay.WriteVariable(VP_MSGSTR3, line3, 32, true);
dgusdisplay.WriteVariable(VP_MSGSTR4, line4, 32, true);
}
void DGUSScreenHandler::sendinfoscreen_en_mks(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4) {
void DGUSScreenHandlerMKS::sendinfoscreen_en(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4) {
dgusdisplay.WriteVariable(VP_MSGSTR1, line1, 32, true);
dgusdisplay.WriteVariable(VP_MSGSTR2, line2, 32, true);
dgusdisplay.WriteVariable(VP_MSGSTR3, line3, 32, true);
dgusdisplay.WriteVariable(VP_MSGSTR4, line4, 32, true);
}
void DGUSScreenHandler::sendinfoscreen_mks(const void *line1, const void *line2, const void *line3, const void *line4, uint16_t language) {
void DGUSScreenHandlerMKS::sendinfoscreen(const void *line1, const void *line2, const void *line3, const void *line4, uint16_t language) {
if (language == MKS_English)
DGUSScreenHandler::sendinfoscreen_en_mks((char *)line1, (char *)line2, (char *)line3, (char *)line4);
DGUSScreenHandlerMKS::sendinfoscreen_en((char *)line1, (char *)line2, (char *)line3, (char *)line4);
else if (language == MKS_SimpleChinese)
DGUSScreenHandler::sendinfoscreen_ch_mks((uint16_t *)line1, (uint16_t *)line2, (uint16_t *)line3, (uint16_t *)line4);
DGUSScreenHandlerMKS::sendinfoscreen_ch((uint16_t *)line1, (uint16_t *)line2, (uint16_t *)line3, (uint16_t *)line4);
}
#endif
void DGUSScreenHandler::DGUSLCD_SendFanToDisplay(DGUS_VP_Variable &var) {
void DGUSScreenHandlerMKS::DGUSLCD_SendFanToDisplay(DGUS_VP_Variable &var) {
if (var.memadr) {
//DEBUG_ECHOPGM(" DGUS_LCD_SendWordValueToDisplay ", var.VP);
//DEBUG_ECHOLNPGM(" data ", *(uint16_t *)var.memadr);
@ -91,14 +91,14 @@ void DGUSScreenHandler::DGUSLCD_SendFanToDisplay(DGUS_VP_Variable &var) {
}
}
void DGUSScreenHandler::DGUSLCD_SendBabyStepToDisplay_MKS(DGUS_VP_Variable &var) {
void DGUSScreenHandlerMKS::DGUSLCD_SendBabyStepToDisplay(DGUS_VP_Variable &var) {
float value = current_position.z;
DEBUG_ECHOLNPAIR_F(" >> ", value, 6);
value *= cpow(10, 2);
dgusdisplay.WriteVariable(VP_SD_Print_Baby, (uint16_t)value);
}
void DGUSScreenHandler::DGUSLCD_SendPrintTimeToDisplay_MKS(DGUS_VP_Variable &var) {
void DGUSScreenHandlerMKS::DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var) {
duration_t elapsed = print_job_timer.duration();
uint32_t time = elapsed.value;
dgusdisplay.WriteVariable(VP_PrintTime_H, uint16_t(time / 3600));
@ -106,7 +106,7 @@ void DGUSScreenHandler::DGUSLCD_SendPrintTimeToDisplay_MKS(DGUS_VP_Variable &var
dgusdisplay.WriteVariable(VP_PrintTime_S, uint16_t((time % 3600) % 60));
}
void DGUSScreenHandler::DGUSLCD_SetUint8(DGUS_VP_Variable &var, void *val_ptr) {
void DGUSScreenHandlerMKS::DGUSLCD_SetUint8(DGUS_VP_Variable &var, void *val_ptr) {
if (var.memadr) {
const uint16_t value = swap16(*(uint16_t*)val_ptr);
DEBUG_ECHOLNPGM("FAN value get:", value);
@ -115,13 +115,13 @@ void DGUSScreenHandler::DGUSLCD_SetUint8(DGUS_VP_Variable &var, void *val_ptr) {
}
}
void DGUSScreenHandler::DGUSLCD_SendGbkToDisplay(DGUS_VP_Variable &var) {
void DGUSScreenHandlerMKS::DGUSLCD_SendGbkToDisplay(DGUS_VP_Variable &var) {
DEBUG_ECHOLNPGM(" data ", *(uint16_t *)var.memadr);
uint16_t *tmp = (uint16_t*) var.memadr;
dgusdisplay.WriteVariable(var.VP, tmp, var.size, true);
}
void DGUSScreenHandler::DGUSLCD_SendStringToDisplay_Language_MKS(DGUS_VP_Variable &var) {
void DGUSScreenHandlerMKS::DGUSLCD_SendStringToDisplay_Language(DGUS_VP_Variable &var) {
if (mks_language_index == MKS_English) {
char *tmp = (char*) var.memadr;
dgusdisplay.WriteVariable(var.VP, tmp, var.size, true);
@ -132,7 +132,7 @@ void DGUSScreenHandler::DGUSLCD_SendStringToDisplay_Language_MKS(DGUS_VP_Variabl
}
}
void DGUSScreenHandler::DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var) {
void DGUSScreenHandlerMKS::DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var) {
#if ENABLED(SENSORLESS_HOMING)
#if X_HAS_STEALTHCHOP
tmc_step.x = stepperX.homing_threshold();
@ -268,7 +268,7 @@ void DGUSScreenHandler::DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var) {
}
#else
void DGUSScreenHandler::PrintReturn(DGUS_VP_Variable& var, void *val_ptr) {
void DGUSScreenHandlerMKS::PrintReturn(DGUS_VP_Variable& var, void *val_ptr) {
uint16_t value = swap16(*(uint16_t*)val_ptr);
if (value == 0x0F) GotoScreen(DGUSLCD_SCREEN_MAIN);
}
@ -315,14 +315,14 @@ void DGUSScreenHandler::ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr) {
#endif
}
void DGUSScreenHandler::ScreenBackChange(DGUS_VP_Variable &var, void *val_ptr) {
void DGUSScreenHandlerMKS::ScreenBackChange(DGUS_VP_Variable &var, void *val_ptr) {
const uint16_t target = swap16(*(uint16_t *)val_ptr);
DEBUG_ECHOLNPGM(" back = 0x%x", target);
switch (target) {
}
}
void DGUSScreenHandler::ZoffsetConfirm(DGUS_VP_Variable &var, void *val_ptr) {
void DGUSScreenHandlerMKS::ZoffsetConfirm(DGUS_VP_Variable &var, void *val_ptr) {
settings.save();
if (printJobOngoing())
GotoScreen(MKSLCD_SCREEN_PRINT);
@ -330,7 +330,7 @@ void DGUSScreenHandler::ZoffsetConfirm(DGUS_VP_Variable &var, void *val_ptr) {
GotoScreen(MKSLCD_SCREEN_PAUSE);
}
void DGUSScreenHandler::GetTurnOffCtrl(DGUS_VP_Variable &var, void *val_ptr) {
void DGUSScreenHandlerMKS::GetTurnOffCtrl(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("GetTurnOffCtrl\n");
const uint16_t value = swap16(*(uint16_t *)val_ptr);
switch (value) {
@ -339,7 +339,7 @@ void DGUSScreenHandler::GetTurnOffCtrl(DGUS_VP_Variable &var, void *val_ptr) {
}
}
void DGUSScreenHandler::GetMinExtrudeTemp(DGUS_VP_Variable &var, void *val_ptr) {
void DGUSScreenHandlerMKS::GetMinExtrudeTemp(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("GetMinExtrudeTemp");
const uint16_t value = swap16(*(uint16_t *)val_ptr);
TERN_(PREVENT_COLD_EXTRUSION, thermalManager.extrude_min_temp = value);
@ -347,7 +347,7 @@ void DGUSScreenHandler::GetMinExtrudeTemp(DGUS_VP_Variable &var, void *val_ptr)
settings.save();
}
void DGUSScreenHandler::GetZoffsetDistance(DGUS_VP_Variable &var, void *val_ptr) {
void DGUSScreenHandlerMKS::GetZoffsetDistance(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("GetZoffsetDistance");
const uint16_t value = swap16(*(uint16_t *)val_ptr);
float val_distance = 0;
@ -361,12 +361,12 @@ void DGUSScreenHandler::GetZoffsetDistance(DGUS_VP_Variable &var, void *val_ptr)
ZOffset_distance = val_distance;
}
void DGUSScreenHandler::GetManualMovestep(DGUS_VP_Variable &var, void *val_ptr) {
void DGUSScreenHandlerMKS::GetManualMovestep(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("\nGetManualMovestep");
*(uint16_t *)var.memadr = swap16(*(uint16_t *)val_ptr);
}
void DGUSScreenHandler::EEPROM_CTRL(DGUS_VP_Variable &var, void *val_ptr) {
void DGUSScreenHandlerMKS::EEPROM_CTRL(DGUS_VP_Variable &var, void *val_ptr) {
const uint16_t eep_flag = swap16(*(uint16_t *)val_ptr);
switch (eep_flag) {
case 0:
@ -384,7 +384,7 @@ void DGUSScreenHandler::EEPROM_CTRL(DGUS_VP_Variable &var, void *val_ptr) {
}
}
void DGUSScreenHandler::Z_offset_select(DGUS_VP_Variable &var, void *val_ptr) {
void DGUSScreenHandlerMKS::Z_offset_select(DGUS_VP_Variable &var, void *val_ptr) {
const uint16_t z_value = swap16(*(uint16_t *)val_ptr);
switch (z_value) {
case 0: Z_distance = 0.01; break;
@ -394,7 +394,7 @@ void DGUSScreenHandler::Z_offset_select(DGUS_VP_Variable &var, void *val_ptr) {
}
}
void DGUSScreenHandler::GetOffsetValue(DGUS_VP_Variable &var, void *val_ptr) {
void DGUSScreenHandlerMKS::GetOffsetValue(DGUS_VP_Variable &var, void *val_ptr) {
#if HAS_BED_PROBE
int32_t value = swap32(*(int32_t *)val_ptr);
@ -411,21 +411,21 @@ void DGUSScreenHandler::GetOffsetValue(DGUS_VP_Variable &var, void *val_ptr) {
settings.save();
}
void DGUSScreenHandler::LanguageChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
void DGUSScreenHandlerMKS::LanguageChange(DGUS_VP_Variable &var, void *val_ptr) {
const uint16_t lag_flag = swap16(*(uint16_t *)val_ptr);
switch (lag_flag) {
case MKS_SimpleChinese:
DGUS_LanguageDisplay(MKS_SimpleChinese);
mks_language_index = MKS_SimpleChinese;
dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE1, MKS_Language_Choose);
dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE2, MKS_Language_NoChoose);
dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE1, MKS_Language_Choose);
dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE2, MKS_Language_NoChoose);
settings.save();
break;
case MKS_English:
DGUS_LanguageDisplay(MKS_English);
mks_language_index = MKS_English;
dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE1, MKS_Language_NoChoose);
dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE2, MKS_Language_Choose);
dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE1, MKS_Language_NoChoose);
dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE2, MKS_Language_Choose);
settings.save();
break;
default: break;
@ -436,7 +436,7 @@ void DGUSScreenHandler::LanguageChange_MKS(DGUS_VP_Variable &var, void *val_ptr)
uint8_t mesh_point_count = GRID_MAX_POINTS;
#endif
void DGUSScreenHandler::Level_Ctrl_MKS(DGUS_VP_Variable &var, void *val_ptr) {
void DGUSScreenHandlerMKS::Level_Ctrl(DGUS_VP_Variable &var, void *val_ptr) {
const uint16_t lev_but = swap16(*(uint16_t *)val_ptr);
#if ENABLED(MESH_BED_LEVELING)
auto cs = getCurrentScreen();
@ -483,7 +483,7 @@ void DGUSScreenHandler::Level_Ctrl_MKS(DGUS_VP_Variable &var, void *val_ptr) {
}
}
void DGUSScreenHandler::MeshLevelDistanceConfig(DGUS_VP_Variable &var, void *val_ptr) {
void DGUSScreenHandlerMKS::MeshLevelDistanceConfig(DGUS_VP_Variable &var, void *val_ptr) {
const uint16_t mesh_dist = swap16(*(uint16_t *)val_ptr);
switch (mesh_dist) {
case 0: mesh_adj_distance = 0.01; break;
@ -493,7 +493,7 @@ void DGUSScreenHandler::MeshLevelDistanceConfig(DGUS_VP_Variable &var, void *val
}
}
void DGUSScreenHandler::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) {
void DGUSScreenHandlerMKS::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) {
#if ENABLED(MESH_BED_LEVELING)
const uint16_t mesh_value = swap16(*(uint16_t *)val_ptr);
// static uint8_t a_first_level = 1;
@ -588,11 +588,11 @@ void DGUSScreenHandler::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) {
#endif // MESH_BED_LEVELING
}
void DGUSScreenHandler::SD_FileBack(DGUS_VP_Variable&, void*) {
void DGUSScreenHandlerMKS::SD_FileBack(DGUS_VP_Variable&, void*) {
GotoScreen(MKSLCD_SCREEN_HOME);
}
void DGUSScreenHandler::LCD_BLK_Adjust(DGUS_VP_Variable &var, void *val_ptr) {
void DGUSScreenHandlerMKS::LCD_BLK_Adjust(DGUS_VP_Variable &var, void *val_ptr) {
const uint16_t lcd_value = swap16(*(uint16_t *)val_ptr);
lcd_default_light = constrain(lcd_value, 10, 100);
@ -601,7 +601,7 @@ void DGUSScreenHandler::LCD_BLK_Adjust(DGUS_VP_Variable &var, void *val_ptr) {
dgusdisplay.WriteVariable(0x0082, &lcd_data, 5, true);
}
void DGUSScreenHandler::ManualAssistLeveling(DGUS_VP_Variable &var, void *val_ptr) {
void DGUSScreenHandlerMKS::ManualAssistLeveling(DGUS_VP_Variable &var, void *val_ptr) {
const int16_t point_value = swap16(*(uint16_t *)val_ptr);
// Insist on leveling first time at this screen
@ -654,7 +654,7 @@ void DGUSScreenHandler::ManualAssistLeveling(DGUS_VP_Variable &var, void *val_pt
#define mks_min(a, b) ((a) < (b)) ? (a) : (b)
#define mks_max(a, b) ((a) > (b)) ? (a) : (b)
void DGUSScreenHandler::TMC_ChangeConfig(DGUS_VP_Variable &var, void *val_ptr) {
void DGUSScreenHandlerMKS::TMC_ChangeConfig(DGUS_VP_Variable &var, void *val_ptr) {
#if EITHER(HAS_TRINAMIC_CONFIG, HAS_STEALTHCHOP)
const uint16_t tmc_value = swap16(*(uint16_t*)val_ptr);
#endif
@ -893,7 +893,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
return;
}
void DGUSScreenHandler::GetParkPos_MKS(DGUS_VP_Variable &var, void *val_ptr) {
void DGUSScreenHandlerMKS::GetParkPos(DGUS_VP_Variable &var, void *val_ptr) {
const int16_t value_pos = swap16(*(int16_t*)val_ptr);
switch (var.VP) {
@ -905,8 +905,8 @@ void DGUSScreenHandler::GetParkPos_MKS(DGUS_VP_Variable &var, void *val_ptr) {
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
}
void DGUSScreenHandler::HandleChangeLevelPoint_MKS(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("HandleChangeLevelPoint_MKS");
void DGUSScreenHandlerMKS::HandleChangeLevelPoint(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("HandleChangeLevelPoint");
const int16_t value_raw = swap16(*(int16_t*)val_ptr);
DEBUG_ECHOLNPGM("value_raw:", value_raw);
@ -917,8 +917,8 @@ void DGUSScreenHandler::HandleChangeLevelPoint_MKS(DGUS_VP_Variable &var, void *
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
}
void DGUSScreenHandler::HandleStepPerMMChanged_MKS(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("HandleStepPerMMChanged_MKS");
void DGUSScreenHandlerMKS::HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("HandleStepPerMMChanged");
const uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
const float value = (float)value_raw;
@ -939,8 +939,8 @@ void DGUSScreenHandler::HandleStepPerMMChanged_MKS(DGUS_VP_Variable &var, void *
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
}
void DGUSScreenHandler::HandleStepPerMMExtruderChanged_MKS(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("HandleStepPerMMExtruderChanged_MKS");
void DGUSScreenHandlerMKS::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("HandleStepPerMMExtruderChanged");
const uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
const float value = (float)value_raw;
@ -964,8 +964,8 @@ void DGUSScreenHandler::HandleStepPerMMExtruderChanged_MKS(DGUS_VP_Variable &var
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
}
void DGUSScreenHandler::HandleMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("HandleMaxSpeedChange_MKS");
void DGUSScreenHandlerMKS::HandleMaxSpeedChange(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("HandleMaxSpeedChange");
const uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
const float value = (float)value_raw;
@ -986,8 +986,8 @@ void DGUSScreenHandler::HandleMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *va
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
}
void DGUSScreenHandler::HandleExtruderMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("HandleExtruderMaxSpeedChange_MKS");
void DGUSScreenHandlerMKS::HandleExtruderMaxSpeedChange(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("HandleExtruderMaxSpeedChange");
const uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
const float value = (float)value_raw;
@ -1011,8 +1011,8 @@ void DGUSScreenHandler::HandleExtruderMaxSpeedChange_MKS(DGUS_VP_Variable &var,
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
}
void DGUSScreenHandler::HandleMaxAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("HandleMaxAccChange_MKS");
void DGUSScreenHandlerMKS::HandleMaxAccChange(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("HandleMaxAccChange");
const uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
const float value = (float)value_raw;
@ -1033,8 +1033,8 @@ void DGUSScreenHandler::HandleMaxAccChange_MKS(DGUS_VP_Variable &var, void *val_
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
}
void DGUSScreenHandler::HandleExtruderAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("HandleExtruderAccChange_MKS");
void DGUSScreenHandlerMKS::HandleExtruderAccChange(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("HandleExtruderAccChange");
uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
DEBUG_ECHOLNPGM("value_raw:", value_raw);
@ -1056,32 +1056,32 @@ void DGUSScreenHandler::HandleExtruderAccChange_MKS(DGUS_VP_Variable &var, void
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
}
void DGUSScreenHandler::HandleTravelAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
void DGUSScreenHandlerMKS::HandleTravelAccChange(DGUS_VP_Variable &var, void *val_ptr) {
uint16_t value_travel = swap16(*(uint16_t*)val_ptr);
planner.settings.travel_acceleration = (float)value_travel;
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
}
void DGUSScreenHandler::HandleFeedRateMinChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
void DGUSScreenHandlerMKS::HandleFeedRateMinChange(DGUS_VP_Variable &var, void *val_ptr) {
uint16_t value_t = swap16(*(uint16_t*)val_ptr);
planner.settings.min_feedrate_mm_s = (float)value_t;
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
}
void DGUSScreenHandler::HandleMin_T_F_MKS(DGUS_VP_Variable &var, void *val_ptr) {
void DGUSScreenHandlerMKS::HandleMin_T_F(DGUS_VP_Variable &var, void *val_ptr) {
uint16_t value_t_f = swap16(*(uint16_t*)val_ptr);
planner.settings.min_travel_feedrate_mm_s = (float)value_t_f;
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
}
void DGUSScreenHandler::HandleAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
void DGUSScreenHandlerMKS::HandleAccChange(DGUS_VP_Variable &var, void *val_ptr) {
uint16_t value_acc = swap16(*(uint16_t*)val_ptr);
planner.settings.acceleration = (float)value_acc;
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
}
#if ENABLED(PREVENT_COLD_EXTRUSION)
void DGUSScreenHandler::HandleGetExMinTemp_MKS(DGUS_VP_Variable &var, void *val_ptr) {
void DGUSScreenHandlerMKS::HandleGetExMinTemp(DGUS_VP_Variable &var, void *val_ptr) {
const uint16_t value_ex_min_temp = swap16(*(uint16_t*)val_ptr);
thermalManager.extrude_min_temp = value_ex_min_temp;
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
@ -1168,7 +1168,7 @@ void DGUSScreenHandler::HandleAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr
}
#endif // BABYSTEPPING
void DGUSScreenHandler::GetManualFilament(DGUS_VP_Variable &var, void *val_ptr) {
void DGUSScreenHandlerMKS::GetManualFilament(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("GetManualFilament");
uint16_t value_len = swap16(*(uint16_t*)val_ptr);
@ -1181,7 +1181,7 @@ void DGUSScreenHandler::GetManualFilament(DGUS_VP_Variable &var, void *val_ptr)
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
}
void DGUSScreenHandler::GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_ptr) {
void DGUSScreenHandlerMKS::GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("GetManualFilamentSpeed");
uint16_t value_len = swap16(*(uint16_t*)val_ptr);
@ -1193,7 +1193,7 @@ void DGUSScreenHandler::GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
}
void DGUSScreenHandler::MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ptr, const int filamentDir) {
void DGUSScreenHandlerMKS::FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ptr, const int filamentDir) {
#if EITHER(HAS_MULTI_HOTEND, SINGLENOZZLE)
uint8_t swap_tool = 0;
#else
@ -1254,7 +1254,7 @@ void DGUSScreenHandler::MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_
}
/**
* M1002: Do a tool-change and relative move for MKS_FilamentLoadUnload
* M1002: Do a tool-change and relative move for FilamentLoadUnload
* within the G-code execution window for best concurrency.
*/
void GcodeSuite::M1002() {
@ -1276,14 +1276,14 @@ void GcodeSuite::M1002() {
axis_relative = old_axis_relative;
}
void DGUSScreenHandler::MKS_FilamentLoad(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("MKS_FilamentLoad");
MKS_FilamentLoadUnload(var, val_ptr, 1);
void DGUSScreenHandlerMKS::FilamentLoad(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("FilamentLoad");
FilamentLoadUnload(var, val_ptr, 1);
}
void DGUSScreenHandler::MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("MKS_FilamentUnLoad");
MKS_FilamentLoadUnload(var, val_ptr, -1);
void DGUSScreenHandlerMKS::FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("FilamentUnLoad");
FilamentLoadUnload(var, val_ptr, -1);
}
#if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
@ -1392,7 +1392,7 @@ void DGUSScreenHandler::MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr)
#endif // DGUS_FILAMENT_LOADUNLOAD
bool DGUSScreenHandler::loop() {
bool DGUSScreenHandlerMKS::loop() {
dgusdisplay.loop();
const millis_t ms = millis();
@ -1444,22 +1444,22 @@ bool DGUSScreenHandler::loop() {
return IsScreenComplete();
}
void DGUSScreenHandler::LanguagePInit() {
void DGUSScreenHandlerMKS::LanguagePInit() {
switch (mks_language_index) {
case MKS_SimpleChinese:
dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE1, MKS_Language_Choose);
dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE2, MKS_Language_NoChoose);
dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE1, MKS_Language_Choose);
dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE2, MKS_Language_NoChoose);
break;
case MKS_English:
dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE1, MKS_Language_NoChoose);
dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE2, MKS_Language_Choose);
dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE1, MKS_Language_NoChoose);
dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE2, MKS_Language_Choose);
break;
default:
break;
}
}
void DGUSScreenHandler::DGUS_ExtrudeLoadInit() {
void DGUSScreenHandlerMKS::DGUS_ExtrudeLoadInit() {
ex_filament.ex_length = distanceFilament;
ex_filament.ex_load_unload_flag = 0;
ex_filament.ex_need_time = filamentSpeed_mm_s;
@ -1469,7 +1469,7 @@ void DGUSScreenHandler::DGUS_ExtrudeLoadInit() {
ex_filament.ex_tick_start = 0;
}
void DGUSScreenHandler::DGUS_RunoutInit() {
void DGUSScreenHandlerMKS::DGUS_RunoutInit() {
#if PIN_EXISTS(MT_DET_1)
SET_INPUT_PULLUP(MT_DET_1_PIN);
#endif
@ -1479,7 +1479,7 @@ void DGUSScreenHandler::DGUS_RunoutInit() {
runout_mks.runout_status = UNRUNOUT_STATUS;
}
void DGUSScreenHandler::DGUS_Runout_Idle() {
void DGUSScreenHandlerMKS::DGUS_Runout_Idle() {
#if ENABLED(DGUS_MKS_RUNOUT_SENSOR)
// scanf runout pin
switch (runout_mks.runout_status) {
@ -1514,7 +1514,7 @@ void DGUSScreenHandler::DGUS_Runout_Idle() {
#endif
}
void DGUSScreenHandler::DGUS_LanguageDisplay(uint8_t var) {
void DGUSScreenHandlerMKS::DGUS_LanguageDisplay(uint8_t var) {
if (var == MKS_English) {
const char home_buf_en[] = "Home";
dgusdisplay.WriteVariable(VP_HOME_Dis, home_buf_en, 32, true);

265
Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h

@ -21,64 +21,26 @@
*/
#pragma once
#include "../DGUSDisplay.h"
#include "../DGUSVPVariable.h"
#include "../DGUSDisplayDef.h"
#include "../../../../inc/MarlinConfig.h"
#include "../DGUSScreenHandlerBase.h"
enum DGUSLCD_Screens : uint8_t;
class DGUSScreenHandler {
class DGUSScreenHandlerMKS : public DGUSScreenHandler {
public:
DGUSScreenHandler() = default;
static bool loop();
// Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen
// The bools specifying whether the strings are in RAM or FLASH.
static void sendinfoscreen(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash);
}
static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash);
}
static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
DGUSScreenHandlerMKS() = default;
#if 0
static void sendinfoscreen_ch_mks(const uint16_t *line1, const uint16_t *line2, const uint16_t *line3, const uint16_t *line4);
static void sendinfoscreen_en_mks(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4);
static void sendinfoscreen_mks(const void *line1, const void *line2, const void *line3, const void *line4, uint16_t language);
static void sendinfoscreen_ch(const uint16_t *line1, const uint16_t *line2, const uint16_t *line3, const uint16_t *line4);
static void sendinfoscreen_en(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4);
static void sendinfoscreen(const void *line1, const void *line2, const void *line3, const void *line4, uint16_t language);
#endif
// "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);
static void ScreenBackChange(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
static void EEPROM_CTRL(DGUS_VP_Variable &var, void *val_ptr);
static void LanguageChange_MKS(DGUS_VP_Variable &var, void *val_ptr);
static void LanguageChange(DGUS_VP_Variable &var, void *val_ptr);
static void GetOffsetValue(DGUS_VP_Variable &var, void *val_ptr);
static void Level_Ctrl_MKS(DGUS_VP_Variable &var, void *val_ptr);
static void Level_Ctrl(DGUS_VP_Variable &var, void *val_ptr);
static void MeshLevel(DGUS_VP_Variable &var, void *val_ptr);
static void MeshLevelDistanceConfig(DGUS_VP_Variable &var, void *val_ptr);
static void ManualAssistLeveling(DGUS_VP_Variable &var, void *val_ptr);
@ -87,9 +49,9 @@ public:
static void GetManualMovestep(DGUS_VP_Variable &var, void *val_ptr);
static void GetZoffsetDistance(DGUS_VP_Variable &var, void *val_ptr);
static void GetMinExtrudeTemp(DGUS_VP_Variable &var, void *val_ptr);
static void GetParkPos_MKS(DGUS_VP_Variable &var, void *val_ptr);
static void GetParkPos(DGUS_VP_Variable &var, void *val_ptr);
#if ENABLED(PREVENT_COLD_EXTRUSION)
static void HandleGetExMinTemp_MKS(DGUS_VP_Variable &var, void *val_ptr);
static void HandleGetExMinTemp(DGUS_VP_Variable &var, void *val_ptr);
#endif
static void DGUS_LanguageDisplay(uint8_t var);
static void TMC_ChangeConfig(DGUS_VP_Variable &var, void *val_ptr);
@ -101,221 +63,54 @@ public:
static void LCD_BLK_Adjust(DGUS_VP_Variable &var, void *val_ptr);
static void SD_FileBack(DGUS_VP_Variable &var, void *val_ptr);
// 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);
static void HandleStepPerMMChanged_MKS(DGUS_VP_Variable &var, void *val_ptr);
static void HandleStepPerMMExtruderChanged_MKS(DGUS_VP_Variable &var, void *val_ptr);
static void HandleMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *val_ptr);
static void HandleExtruderMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *val_ptr);
static void HandleAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr);
static void HandleMaxAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr);
static void HandleExtruderAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr);
static void HandleChangeLevelPoint_MKS(DGUS_VP_Variable &var, void *val_ptr);
static void HandleTravelAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr);
static void HandleFeedRateMinChange_MKS(DGUS_VP_Variable &var, void *val_ptr);
static void HandleMin_T_F_MKS(DGUS_VP_Variable &var, void *val_ptr);
static void HandleMaxSpeedChange(DGUS_VP_Variable &var, void *val_ptr);
static void HandleExtruderMaxSpeedChange(DGUS_VP_Variable &var, void *val_ptr);
static void HandleAccChange(DGUS_VP_Variable &var, void *val_ptr);
static void HandleMaxAccChange(DGUS_VP_Variable &var, void *val_ptr);
static void HandleExtruderAccChange(DGUS_VP_Variable &var, void *val_ptr);
static void HandleChangeLevelPoint(DGUS_VP_Variable &var, void *val_ptr);
static void HandleTravelAccChange(DGUS_VP_Variable &var, void *val_ptr);
static void HandleFeedRateMinChange(DGUS_VP_Variable &var, void *val_ptr);
static void HandleMin_T_F(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);
static void MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ptr, const int filamentDir);
static void MKS_FilamentLoad(DGUS_VP_Variable &var, void *val_ptr);
static void MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr);
static void MKS_LOAD_UNLOAD_IDLE();
static void MKS_LOAD_Cancle(DGUS_VP_Variable &var, void *val_ptr);
static void FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ptr, const int filamentDir);
static void FilamentLoad(DGUS_VP_Variable &var, void *val_ptr);
static void FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr);
static void GetManualFilament(DGUS_VP_Variable &var, void *val_ptr);
static void GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_ptr);
#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();
// Marlin informed us about SD print completion.
static void SDPrintingFinished();
#else
static void PrintReturn(DGUS_VP_Variable &var, void *val_ptr);
#endif
// OK Button on the Confirm screen.
static void ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr);
// Update data after going to a new screen (by display or by GotoScreen)
// remember: store the last-displayed screen, so it can be returned to.
// (e.g for popup 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);
static void DGUSLCD_SendPrintTimeToDisplay_MKS(DGUS_VP_Variable &var);
static void DGUSLCD_SendBabyStepToDisplay_MKS(DGUS_VP_Variable &var);
static void DGUSLCD_SendBabyStepToDisplay(DGUS_VP_Variable &var);
static void DGUSLCD_SendFanToDisplay(DGUS_VP_Variable &var);
static void DGUSLCD_SendGbkToDisplay(DGUS_VP_Variable &var);
static void DGUSLCD_SendStringToDisplay_Language_MKS(DGUS_VP_Variable &var);
static void DGUSLCD_SendStringToDisplay_Language(DGUS_VP_Variable &var);
static void DGUSLCD_SendTMCStepValue(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);
static void DGUSLCD_SetUint8(DGUS_VP_Variable &var, void *val_ptr);
template<typename T>
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<unsigned int decimals>
static void DGUSLCD_SendFloatAsLongValueToDisplay(DGUS_VP_Variable &var) {
if (var.memadr) {
float f = *(float *)var.memadr;
f *= cpow(10, decimals);
dgusdisplay.WriteVariable(var.VP, (long)f);
}
}
// 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<unsigned int decimals>
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);
dgusdisplay.WriteVariable(var.VP, (int16_t)f);
}
}
// Force an update of all VP on the current screen.
static void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; }
// Has all VPs sent to the screen
static bool IsScreenComplete() { return ScreenComplete; }
static DGUSLCD_Screens getCurrentScreen() { return current_screen; }
static 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)();
static bool loop();
};
#define MKS_Language_Choose 0x00
#define MKS_Language_NoChoose 0x01
enum MKS_Choose : uint8_t { MKS_Language_Choose, MKS_Language_NoChoose };
enum MKS_Language : uint8_t { MKS_SimpleChinese, MKS_English };
#define MKS_SimpleChinese 0
#define MKS_English 1
extern uint8_t mks_language_index;
extern MKS_Language mks_language_index;
extern bool DGUSAutoTurnOff;
#if ENABLED(POWER_LOSS_RECOVERY)
#define PLR_SCREEN_RECOVER MKSLCD_SCREEN_PRINT
#define PLR_SCREEN_CANCEL MKSLCD_SCREEN_HOME
#endif
typedef DGUSScreenHandlerMKS DGUSScreenHandlerClass;

219
Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.h

@ -21,224 +21,9 @@
*/
#pragma once
#include "../DGUSDisplay.h"
#include "../DGUSVPVariable.h"
#include "../DGUSDisplayDef.h"
#include "../DGUSScreenHandlerBase.h"
#include "../../../../inc/MarlinConfig.h"
enum DGUSLCD_Screens : uint8_t;
class DGUSScreenHandler {
public:
DGUSScreenHandler() = default;
static bool loop();
// Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen
// The bools specifying whether the strings are in RAM or FLASH.
static void sendinfoscreen(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash);
}
static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash);
}
static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const 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<typename T>
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<unsigned int decimals>
static void DGUSLCD_SendFloatAsLongValueToDisplay(DGUS_VP_Variable &var) {
if (var.memadr) {
float f = *(float *)var.memadr;
f *= cpow(10, decimals);
dgusdisplay.WriteVariable(var.VP, (long)f);
}
}
// 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<unsigned int decimals>
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);
dgusdisplay.WriteVariable(var.VP, (int16_t)f);
}
}
// Force an update of all VP on the current screen.
static void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; }
// Has all VPs sent to the screen
static bool IsScreenComplete() { return ScreenComplete; }
static DGUSLCD_Screens getCurrentScreen() { return current_screen; }
static 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)();
};
typedef DGUSScreenHandler DGUSScreenHandlerClass;
#if ENABLED(POWER_LOSS_RECOVERY)
#define PLR_SCREEN_RECOVER DGUSLCD_SCREEN_SDPRINTMANIPULATION

2
Marlin/src/module/settings.cpp

@ -544,7 +544,7 @@ typedef struct SettingsDataStruct {
// MKS UI controller
//
#if ENABLED(DGUS_LCD_UI_MKS)
uint8_t mks_language_index; // Display Language
MKS_Language mks_language_index; // Display Language
xy_int_t mks_corner_offsets[5]; // Bed Tramming
xyz_int_t mks_park_pos; // Custom Parking (without NOZZLE_PARK)
celsius_t mks_min_extrusion_temp; // Min E Temp (shadow M302 value)

Loading…
Cancel
Save