mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2025-02-16 22:37:35 +00:00
✨ CR-6 SE
This commit is contained in:
parent
aa44542f76
commit
4d7b670e94
21 changed files with 2073 additions and 60 deletions
|
@ -3199,13 +3199,16 @@
|
|||
* - Download https://github.com/CrealityOfficial/Ender-3S1/archive/3S1_Plus_Screen.zip
|
||||
* - Copy the downloaded DWIN_SET folder to the SD card.
|
||||
*
|
||||
* CREALITY_TOUCH
|
||||
* - CR-6 OEM touch screen. A DWIN display with touch.
|
||||
*
|
||||
* Flash display with DGUS Displays for Marlin:
|
||||
* - Format the SD card to FAT32 with an allocation size of 4kb.
|
||||
* - Download files as specified for your type of display.
|
||||
* - Plug the microSD card into the back of the display.
|
||||
* - Boot the display and wait for the update to complete.
|
||||
*
|
||||
* :[ 'ORIGIN', 'FYSETC', 'HYPRECY', 'MKS', 'RELOADED', 'IA_CREALITY', 'E3S1PRO' ]
|
||||
* :[ 'ORIGIN', 'FYSETC', 'HYPRECY', 'MKS', 'RELOADED', 'IA_CREALITY', 'E3S1PRO', 'CREALITY_TOUCH' ]
|
||||
*/
|
||||
//#define DGUS_LCD_UI ORIGIN
|
||||
#if DGUS_UI_IS(MKS)
|
||||
|
|
|
@ -752,13 +752,14 @@
|
|||
#define HAS_E_TEMP_SENSOR (0 REPEAT(EXTRUDERS, _HAS_E_TEMP))
|
||||
#define TEMP_SENSOR_IS_MAX_TC(T) (TEMP_SENSOR(T) == -5 || TEMP_SENSOR(T) == -3 || TEMP_SENSOR(T) == -2)
|
||||
|
||||
#define _UI_NONE 0
|
||||
#define _UI_ORIGIN 101
|
||||
#define _UI_FYSETC 102
|
||||
#define _UI_HIPRECY 103
|
||||
#define _UI_MKS 104
|
||||
#define _UI_RELOADED 105
|
||||
#define _UI_IA_CREALITY 106
|
||||
#define _UI_E3S1PRO 107
|
||||
#define _UI_NONE 0
|
||||
#define _UI_ORIGIN 101
|
||||
#define _UI_FYSETC 102
|
||||
#define _UI_HIPRECY 103
|
||||
#define _UI_MKS 104
|
||||
#define _UI_RELOADED 105
|
||||
#define _UI_IA_CREALITY 106
|
||||
#define _UI_E3S1PRO 107
|
||||
#define _UI_CREALITY_TOUCH 108
|
||||
#define _DGUS_UI_IS(N) || (CAT(_UI_, DGUS_LCD_UI) == CAT(_UI_, N))
|
||||
#define DGUS_UI_IS(V...) (0 MAP(_DGUS_UI_IS, V))
|
||||
|
|
|
@ -93,7 +93,7 @@ void event_filament_runout(const uint8_t extruder) {
|
|||
|
||||
//action:out_of_filament
|
||||
#if ENABLED(HOST_PROMPT_SUPPORT)
|
||||
hostui.prompt_do(PROMPT_FILAMENT_RUNOUT, F("FilamentRunout T"), tool); //action:out_of_filament
|
||||
hostui.prompt_do(PROMPT_FILAMENT_RUNOUT, F("filamentRunout T"), tool); //action:out_of_filament
|
||||
#endif
|
||||
|
||||
const bool run_runout_script = !runout.host_handling;
|
||||
|
|
|
@ -92,6 +92,8 @@
|
|||
#define DGUS_LCD_UI_IA_CREALITY 1
|
||||
#elif DGUS_UI_IS(E3S1PRO)
|
||||
#define DGUS_LCD_UI_E3S1PRO 1
|
||||
#elif DGUS_UI_IS(CREALITY_TOUCH)
|
||||
#define DGUS_LCD_UI_CREALITY_TOUCH 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -543,7 +545,7 @@
|
|||
// Aliases for LCD features
|
||||
#if !DGUS_UI_IS(NONE) || ENABLED(ANYCUBIC_LCD_VYPER)
|
||||
#define HAS_DGUS_LCD 1
|
||||
#if DGUS_UI_IS(ORIGIN, FYSETC, HIPRECY, MKS)
|
||||
#if DGUS_UI_IS(ORIGIN, FYSETC, HIPRECY, MKS, CREALITY_TOUCH)
|
||||
#define HAS_DGUS_LCD_CLASSIC 1
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -3463,7 +3463,7 @@
|
|||
#endif
|
||||
|
||||
// Number of VFAT entries used. Each entry has 13 UTF-16 characters
|
||||
#if ANY(SCROLL_LONG_FILENAMES, HAS_DWIN_E3V2, TFT_COLOR_UI)
|
||||
#if ANY(SCROLL_LONG_FILENAMES, HAS_DWIN_E3V2, TFT_COLOR_UI, DGUS_LCD_UI_CREALITY_TOUCH)
|
||||
#define VFAT_ENTRIES_LIMIT 5
|
||||
#else
|
||||
#define VFAT_ENTRIES_LIMIT 2
|
||||
|
|
|
@ -2734,7 +2734,7 @@ static_assert(NUM_SERVOS <= NUM_SERVO_PLUGS, "NUM_SERVOS (or some servo index) i
|
|||
+ (DISABLED(IS_LEGACY_TFT) && ENABLED(TFT_GENERIC)) \
|
||||
+ (ENABLED(IS_LEGACY_TFT) && COUNT_ENABLED(TFT_320x240, TFT_320x240_SPI, TFT_480x320, TFT_480x320_SPI)) \
|
||||
+ COUNT_ENABLED(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, ANYCUBIC_TFT35, ANYCUBIC_LCD_VYPER) \
|
||||
+ DGUS_UI_IS(ORIGIN) + DGUS_UI_IS(FYSETC) + DGUS_UI_IS(HIPRECY) + DGUS_UI_IS(MKS) + DGUS_UI_IS(RELOADED) + DGUS_UI_IS(IA_CREALITY) \
|
||||
+ DGUS_UI_IS(ORIGIN) + DGUS_UI_IS(FYSETC) + DGUS_UI_IS(HIPRECY) + DGUS_UI_IS(MKS) + DGUS_UI_IS(RELOADED) + DGUS_UI_IS(IA_CREALITY) + DGUS_UI_IS(CREALITY_TOUCH) \
|
||||
+ COUNT_ENABLED(ENDER2_STOCKDISPLAY, CR10_STOCKDISPLAY) \
|
||||
+ COUNT_ENABLED(DWIN_CREALITY_LCD, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_PORTRAIT, DWIN_MARLINUI_LANDSCAPE) \
|
||||
+ COUNT_ENABLED(FYSETC_MINI_12864_X_X, FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0, FYSETC_GENERIC_12864_1_1) \
|
||||
|
|
|
@ -76,6 +76,27 @@ void DGUSDisplay::initDisplay() {
|
|||
requestScreen(TERN(SHOW_BOOTSCREEN, DGUS_SCREEN_BOOT, DGUS_SCREEN_MAIN));
|
||||
}
|
||||
|
||||
#if DGUS_LCD_UI_CREALITY_TOUCH
|
||||
|
||||
DGUS_ScreenID DGUSDisplay::displayRequest = DGUS_SCREEN_BOOT;
|
||||
|
||||
void DGUSDisplay::readCurrentScreen() { readVariable(0x14 /*PIC_NOW*/); }
|
||||
|
||||
void DGUSDisplay::resetDisplay() {
|
||||
DEBUG_ECHOLNPGM("resetDisplay");
|
||||
const unsigned char resetCommand[] = { 0x55, 0xAA, 0x5A, 0xA5 };
|
||||
writeVariable(0x04, resetCommand, sizeof(resetCommand));
|
||||
}
|
||||
|
||||
void DGUSDisplay::readVariable(uint16_t adr) {
|
||||
writeHeader(adr, DGUS_CMD_READVAR, sizeof(uint8_t));
|
||||
|
||||
// Specify to read one byte
|
||||
LCD_SERIAL.write(static_cast<uint8_t>(1));
|
||||
}
|
||||
|
||||
#endif // DWIN_CREALITY_TOUCHLCD
|
||||
|
||||
void DGUSDisplay::writeVariable(uint16_t adr, const void *values, uint8_t valueslen, bool isstr) {
|
||||
const char* myvalues = static_cast<const char*>(values);
|
||||
bool strend = !myvalues;
|
||||
|
@ -204,11 +225,48 @@ void DGUSDisplay::processRx() {
|
|||
| Command DataLen (in Words) */
|
||||
if (command == DGUS_CMD_READVAR) {
|
||||
const uint16_t vp = tmp[0] << 8 | tmp[1];
|
||||
DGUS_VP_Variable ramcopy;
|
||||
if (populate_VPVar(vp, &ramcopy)) {
|
||||
if (ramcopy.set_by_display_handler)
|
||||
ramcopy.set_by_display_handler(ramcopy, &tmp[3]);
|
||||
}
|
||||
|
||||
#if DGUS_LCD_UI_CREALITY_TOUCH
|
||||
|
||||
if (vp == 0x14 /*PIC_Now*/) {
|
||||
const uint16_t screen_id = tmp[3] << 8 | tmp[4];
|
||||
// In the code below DGUS_SCREEN_BOOT acts as a sentinel
|
||||
if (screen_id == 255) {
|
||||
// DGUS OS sometimes randomly sends 255 back as an answer. Possible buffer overrun?
|
||||
readCurrentScreen(); // Request again
|
||||
}
|
||||
else if (displayRequest != DGUS_SCREEN_BOOT && screen_id != displayRequest) {
|
||||
// A display was requested. If the screen didn't yet switch to that display, we won't give that value back, otherwise the code gets confused.
|
||||
// The DWIN display mostly honours the PIC_SET requests from the firmware, so after a while we may want to nudge it to the correct screen
|
||||
DEBUG_ECHOPGM(" Got a response on the current screen: ", screen_id);
|
||||
DEBUG_ECHOLNPGM(" - however, we've requested screen ", displayRequest);
|
||||
}
|
||||
else {
|
||||
displayRequest = DGUS_SCREEN_BOOT;
|
||||
if (current_screen_update_callback)
|
||||
current_screen_update_callback(static_cast<DGUS_ScreenID>(screen_id));
|
||||
}
|
||||
}
|
||||
else {
|
||||
DGUS_VP_Variable ramcopy;
|
||||
if (populate_VPVar(vp, &ramcopy)) {
|
||||
if (ramcopy.set_by_display_handler)
|
||||
ramcopy.set_by_display_handler(ramcopy, &tmp[3]);
|
||||
}
|
||||
|
||||
// Always ask for a screen update so we can send a screen update earlier, this prevents a flash of unstyled screen
|
||||
readCurrentScreen();
|
||||
}
|
||||
|
||||
#else // !DWIN_CREALITY_TOUCHLCD
|
||||
|
||||
DGUS_VP_Variable ramcopy;
|
||||
if (populate_VPVar(vp, &ramcopy)) {
|
||||
if (ramcopy.set_by_display_handler)
|
||||
ramcopy.set_by_display_handler(ramcopy, &tmp[3]);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
rx_datagram_state = DGUS_IDLE;
|
||||
break;
|
||||
|
|
|
@ -51,6 +51,10 @@ typedef enum : uint8_t {
|
|||
|
||||
constexpr uint16_t swap16(const uint16_t value) { return (value & 0xFFU) << 8U | (value >> 8U); }
|
||||
|
||||
#if DGUS_LCD_UI_CREALITY_TOUCH
|
||||
typedef void (*screenUpdateCallback_t)(DGUS_ScreenID screen);
|
||||
#endif
|
||||
|
||||
// Low-Level access to the display.
|
||||
class DGUSDisplay {
|
||||
public:
|
||||
|
@ -58,6 +62,9 @@ public:
|
|||
DGUSDisplay() = default;
|
||||
|
||||
static void initDisplay();
|
||||
#if DGUS_LCD_UI_CREALITY_TOUCH
|
||||
static void resetDisplay();
|
||||
#endif
|
||||
|
||||
// Variable access.
|
||||
static void writeVariable(uint16_t adr, const void *values, uint8_t valueslen, bool isstr=false);
|
||||
|
@ -68,7 +75,13 @@ public:
|
|||
static void writeVariable(uint16_t adr, int8_t value);
|
||||
static void writeVariable(uint16_t adr, long value);
|
||||
|
||||
// Utility functions for bridging ui_api and dbus
|
||||
#if DGUS_LCD_UI_CREALITY_TOUCH
|
||||
// Until now I did not need to actively read from the display.
|
||||
// (I extensively use the auto upload of the display)
|
||||
static void readVariable(uint16_t adr);
|
||||
#endif
|
||||
|
||||
// Utility functions for bridging ui_api and dgus
|
||||
template<typename T, float(*Getter)(const T), T selector, typename WireType=uint16_t>
|
||||
static void setVariable(DGUS_VP_Variable &var) {
|
||||
writeVariable(var.VP, (WireType)Getter(selector));
|
||||
|
@ -80,14 +93,16 @@ public:
|
|||
Setter(newvalue, selector);
|
||||
}
|
||||
|
||||
// Until now I did not need to actively read from the display. That's why there is no ReadVariable
|
||||
// (I extensively use the auto upload of the display)
|
||||
|
||||
// Force display into another screen.
|
||||
// (And trigger update of containing VPs)
|
||||
// (to implement a pop up message, which may not be nested)
|
||||
static void requestScreen(const DGUS_ScreenID screenID);
|
||||
|
||||
#if DGUS_LCD_UI_CREALITY_TOUCH
|
||||
// Request the current displayed screen - will be passed to current_screen_update_callback
|
||||
static void readCurrentScreen();
|
||||
#endif
|
||||
|
||||
// Periodic tasks, eg. Rx-Queue handling.
|
||||
static void loop();
|
||||
|
||||
|
@ -99,6 +114,10 @@ public:
|
|||
// (both boils down that the display answered to our chatting)
|
||||
static bool isInitialized() { return initialized; }
|
||||
|
||||
#if DGUS_LCD_UI_CREALITY_TOUCH
|
||||
static screenUpdateCallback_t current_screen_update_callback;
|
||||
#endif
|
||||
|
||||
private:
|
||||
static void writeHeader(uint16_t adr, uint8_t cmd, uint8_t payloadlen);
|
||||
static void writePGM(const char str[], uint8_t len);
|
||||
|
@ -107,6 +126,10 @@ private:
|
|||
static rx_datagram_state_t rx_datagram_state;
|
||||
static uint8_t rx_datagram_len;
|
||||
static bool initialized, no_reentrance;
|
||||
|
||||
#if DGUS_LCD_UI_CREALITY_TOUCH
|
||||
static DGUS_ScreenID displayRequest;
|
||||
#endif
|
||||
};
|
||||
|
||||
extern DGUSDisplay dgus;
|
||||
|
|
|
@ -54,4 +54,6 @@ extern const struct DGUS_VP_Variable ListOfVP[];
|
|||
#include "fysetc/DGUSDisplayDef.h"
|
||||
#elif DGUS_LCD_UI_HIPRECY
|
||||
#include "hiprecy/DGUSDisplayDef.h"
|
||||
#elif DGUS_LCD_UI_CREALITY_TOUCH
|
||||
#include "creality/DGUSDisplayDef.h"
|
||||
#endif
|
||||
|
|
|
@ -54,6 +54,8 @@
|
|||
#include "fysetc/DGUSScreenHandler.h"
|
||||
#elif DGUS_LCD_UI_HIPRECY
|
||||
#include "hiprecy/DGUSScreenHandler.h"
|
||||
#elif DGUS_LCD_UI_CREALITY_TOUCH
|
||||
#include "creality/DGUSScreenHandler.h"
|
||||
#endif
|
||||
|
||||
extern DGUSScreenHandlerClass screen;
|
||||
|
|
493
Marlin/src/lcd/extui/dgus/creality/DGUSDisplayDef.cpp
Normal file
493
Marlin/src/lcd/extui/dgus/creality/DGUSDisplayDef.cpp
Normal file
|
@ -0,0 +1,493 @@
|
|||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if DGUS_LCD_UI_CREALITY_TOUCH
|
||||
|
||||
#include "DGUSDisplayDef.h"
|
||||
#include "../DGUSDisplay.h"
|
||||
#include "../DGUSScreenHandler.h"
|
||||
#include "PageHandlers.h"
|
||||
|
||||
#include "../../../../module/temperature.h"
|
||||
#include "../../../../module/motion.h"
|
||||
#include "../../../../module/planner.h"
|
||||
#include "../../../../feature/caselight.h"
|
||||
|
||||
#include "../../ui_api.h"
|
||||
#include "../../../marlinui.h" // For material presets
|
||||
|
||||
#if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
|
||||
uint16_t distanceToMove = 10;
|
||||
#endif
|
||||
using namespace ExtUI;
|
||||
|
||||
PGMSTR(MarlinVersion, SHORT_BUILD_VERSION);
|
||||
|
||||
// ----- Which variables to auto-update on which screens
|
||||
const uint16_t VPList_None[] PROGMEM = { 0x0000 };
|
||||
const uint16_t VPList_DialogStop[] PROGMEM = { 0x0000 };
|
||||
|
||||
const uint16_t VPList_Main[] PROGMEM = {
|
||||
/* VP_M117, for completeness, but it cannot be auto-uploaded. */
|
||||
#if HOTENDS >= 1
|
||||
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
|
||||
#endif
|
||||
/*VP_XPos, VP_YPos,*/ VP_ZPos,
|
||||
//VP_Fan0_Percentage,
|
||||
VP_Feedrate_Percentage,
|
||||
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
|
||||
VP_PrintProgress_Percentage,
|
||||
#endif
|
||||
0x0000
|
||||
};
|
||||
|
||||
const uint16_t VPList_SDFileList[] PROGMEM = {
|
||||
/* VP_M117, for completeness, but it cannot be auto-uploaded. */
|
||||
#if HOTENDS >= 1
|
||||
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
|
||||
#endif
|
||||
/*VP_XPos, VP_YPos,*/ VP_ZPos,
|
||||
//VP_Fan0_Percentage,
|
||||
VP_Feedrate_Percentage,
|
||||
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
|
||||
VP_PrintProgress_Percentage,
|
||||
#endif
|
||||
|
||||
VP_SD_FileName0,
|
||||
VP_SD_FileName1,
|
||||
VP_SD_FileName2,
|
||||
VP_SD_FileName3,
|
||||
VP_SD_FileName4,
|
||||
VP_SD_FileName5,
|
||||
|
||||
0x0000
|
||||
};
|
||||
|
||||
const uint16_t VPList_Control[] PROGMEM = {
|
||||
/* VP_M117, for completeness, but it cannot be auto-uploaded. */
|
||||
#if HOTENDS >= 1
|
||||
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
|
||||
#endif
|
||||
/*VP_XPos, VP_YPos,*/ VP_ZPos,
|
||||
//VP_Fan0_Percentage,
|
||||
VP_Feedrate_Percentage,
|
||||
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
|
||||
VP_PrintProgress_Percentage,
|
||||
#endif
|
||||
|
||||
VP_LED_TOGGLE,
|
||||
|
||||
0x0000
|
||||
};
|
||||
|
||||
const uint16_t VPList_Feed[] PROGMEM = {
|
||||
/* VP_M117, for completeness, but it cannot be auto-uploaded. */
|
||||
#if HOTENDS >= 1
|
||||
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
|
||||
#endif
|
||||
/*VP_XPos, VP_YPos,*/ VP_ZPos,
|
||||
//VP_Fan0_Percentage,
|
||||
VP_Feedrate_Percentage,
|
||||
|
||||
|
||||
0x0000
|
||||
};
|
||||
|
||||
const uint16_t VPList_Temp[] PROGMEM = {
|
||||
/* VP_M117, for completeness, but it cannot be auto-uploaded. */
|
||||
#if HOTENDS >= 1
|
||||
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
|
||||
#endif
|
||||
/*VP_XPos, VP_YPos,*/ VP_ZPos,
|
||||
//VP_Fan0_Percentage,
|
||||
VP_Feedrate_Percentage,
|
||||
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
|
||||
VP_PrintProgress_Percentage,
|
||||
#endif
|
||||
|
||||
VP_FAN_TOGGLE,
|
||||
|
||||
0x0000
|
||||
};
|
||||
|
||||
|
||||
const uint16_t VPList_PreheatPLASettings[] PROGMEM = {
|
||||
/* VP_M117, for completeness, but it cannot be auto-uploaded. */
|
||||
#if HOTENDS >= 1
|
||||
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
|
||||
#endif
|
||||
/*VP_XPos, VP_YPos,*/ VP_ZPos,
|
||||
//VP_Fan0_Percentage,
|
||||
VP_Feedrate_Percentage,
|
||||
|
||||
VP_PREHEAT_PLA_HOTEND_TEMP,
|
||||
VP_PREHEAT_PLA_BED_TEMP,
|
||||
|
||||
0x0000
|
||||
};
|
||||
|
||||
const uint16_t VPList_PreheatABSSettings[] PROGMEM = {
|
||||
/* VP_M117, for completeness, but it cannot be auto-uploaded. */
|
||||
#if HOTENDS >= 1
|
||||
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
|
||||
#endif
|
||||
/*VP_XPos, VP_YPos,*/ VP_ZPos,
|
||||
//VP_Fan0_Percentage,
|
||||
VP_Feedrate_Percentage,
|
||||
|
||||
VP_PREHEAT_ABS_HOTEND_TEMP,
|
||||
VP_PREHEAT_ABS_BED_TEMP,
|
||||
|
||||
0x0000
|
||||
};
|
||||
|
||||
|
||||
const uint16_t VPList_PrintPausingError[] PROGMEM = {
|
||||
/* VP_M117, for completeness, but it cannot be auto-uploaded. */
|
||||
#if HOTENDS >= 1
|
||||
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
|
||||
#endif
|
||||
/*VP_XPos, VP_YPos,*/ VP_ZPos,
|
||||
//VP_Fan0_Percentage,
|
||||
VP_Feedrate_Percentage,
|
||||
|
||||
VP_PrintProgress_Percentage,
|
||||
VP_PrintTimeProgressBar,
|
||||
VP_PrintTime,
|
||||
|
||||
0x0000
|
||||
};
|
||||
|
||||
const uint16_t VPList_PrintScreen[] PROGMEM = {
|
||||
/* VP_M117, for completeness, but it cannot be auto-uploaded. */
|
||||
VP_M117,
|
||||
|
||||
VP_PrintTime,
|
||||
|
||||
#if HOTENDS >= 1
|
||||
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
|
||||
#endif
|
||||
/*VP_XPos, VP_YPos,*/ VP_ZPos,
|
||||
//VP_Fan0_Percentage,
|
||||
VP_Feedrate_Percentage,
|
||||
|
||||
VP_PrintProgress_Percentage,
|
||||
VP_PrintTimeProgressBar,
|
||||
VP_PrintTime,
|
||||
|
||||
0x0000
|
||||
};
|
||||
|
||||
const uint16_t VPList_Leveling[] PROGMEM = {
|
||||
#if HOTENDS >= 1
|
||||
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
|
||||
#endif
|
||||
/*VP_XPos, VP_YPos,*/ VP_ZPos,
|
||||
//VP_Fan0_Percentage,
|
||||
VP_Feedrate_Percentage,
|
||||
|
||||
VP_MESH_LEVEL_TEMP,
|
||||
VP_MESH_LEVEL_STATUS,
|
||||
|
||||
0x0000
|
||||
};
|
||||
|
||||
const uint16_t VPList_ZOffsetLevel[] PROGMEM = {
|
||||
#if HOTENDS >= 1
|
||||
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
|
||||
#endif
|
||||
/*VP_XPos, VP_YPos,*/ VP_ZPos,
|
||||
//VP_Fan0_Percentage,
|
||||
VP_Feedrate_Percentage,
|
||||
|
||||
0x0000
|
||||
};
|
||||
|
||||
const uint16_t VPList_TuneScreen[] PROGMEM = {
|
||||
/* VP_M117, for completeness, but it cannot be auto-uploaded. */
|
||||
VP_M117,
|
||||
|
||||
VP_PrintTime,
|
||||
|
||||
#if HOTENDS >= 1
|
||||
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
|
||||
#endif
|
||||
/*VP_XPos, VP_YPos,*/ VP_ZPos,
|
||||
//VP_Fan0_Percentage,
|
||||
VP_Feedrate_Percentage,
|
||||
|
||||
VP_LED_TOGGLE,
|
||||
VP_FAN_TOGGLE,
|
||||
|
||||
|
||||
0x0000
|
||||
};
|
||||
|
||||
const uint16_t VPList_Prepare[] PROGMEM = {
|
||||
/* VP_M117, for completeness, but it cannot be auto-uploaded. */
|
||||
VP_M117,
|
||||
|
||||
VP_PrintTime,
|
||||
|
||||
#if HOTENDS >= 1
|
||||
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
|
||||
#endif
|
||||
/*VP_XPos, VP_YPos,*/ VP_ZPos,
|
||||
//VP_Fan0_Percentage,
|
||||
VP_Feedrate_Percentage,
|
||||
|
||||
VP_STEPPERS,
|
||||
|
||||
0x0000
|
||||
};
|
||||
|
||||
const uint16_t VPList_Info[] PROGMEM = {
|
||||
/* VP_M117, for completeness, but it cannot be auto-uploaded. */
|
||||
VP_M117,
|
||||
|
||||
VP_PrintTime,
|
||||
|
||||
#if HOTENDS >= 1
|
||||
VP_T_E0_Is, VP_T_E0_Set,// VP_E0_STATUS,
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
VP_T_Bed_Is, VP_T_Bed_Set,// VP_BED_STATUS,
|
||||
#endif
|
||||
/*VP_XPos, VP_YPos,*/ VP_ZPos,
|
||||
//VP_Fan0_Percentage,
|
||||
VP_Feedrate_Percentage,
|
||||
|
||||
VP_PRINTER_BEDSIZE,
|
||||
VP_MARLIN_VERSION,
|
||||
|
||||
0x0000
|
||||
};
|
||||
|
||||
// Toggle button handler
|
||||
void DGUSCrealityDisplay_HandleToggleButton(DGUS_VP_Variable &var, void *val_ptr) {
|
||||
switch (*(uint16_t*)var.memadr) {
|
||||
case ICON_TOGGLE_ON:
|
||||
*((bool*)var.memadr) = true;
|
||||
break;
|
||||
|
||||
case ICON_TOGGLE_OFF:
|
||||
*((bool*)var.memadr) = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void DGUSCrealityDisplay_SendToggleButton(DGUS_VP_Variable &var) {
|
||||
dgus.writeVariable(var.VP, *(bool*)var.memadr ? ICON_TOGGLE_ON : ICON_TOGGLE_OFF);
|
||||
}
|
||||
|
||||
// -- Mapping from screen to variable list
|
||||
const struct VPMapping VPMap[] PROGMEM = {
|
||||
{ DGUS_SCREEN_BOOT, VPList_None },
|
||||
{ DGUS_SCREEN_MAIN, VPList_Main },
|
||||
|
||||
{ DGUS_SCREEN_SDFILELIST, VPList_SDFileList },
|
||||
|
||||
{ DGUS_SCREEN_FILAMENTRUNOUT1, VPList_PrintPausingError },
|
||||
{ DGUS_SCREEN_FILAMENTRUNOUT2, VPList_PrintPausingError },
|
||||
|
||||
{ DGUS_SCREEN_PRINT_FINISH, VPList_PrintScreen },
|
||||
{ DGUS_SCREEN_PRINT_RUNNING, VPList_PrintScreen },
|
||||
{ DGUS_SCREEN_PRINT_PAUSED, VPList_PrintScreen },
|
||||
|
||||
{ DGUS_SCREEN_TUNING, VPList_TuneScreen },
|
||||
{ DGUS_SCREEN_PREPARE, VPList_Prepare },
|
||||
|
||||
{ DGUS_SCREEN_INFO, VPList_Info },
|
||||
|
||||
{ DGUS_SCREEN_MOVE1MM, VPList_PrintScreen },
|
||||
{ DGUS_SCREEN_MOVE10MM, VPList_PrintScreen },
|
||||
{ DGUS_SCREEN_MOVE01MM, VPList_PrintScreen },
|
||||
|
||||
{ DGUS_SCREEN_FEED, VPList_Feed },
|
||||
{ DGUS_SCREEN_CONTROL, VPList_Control },
|
||||
|
||||
{ DGUS_SCREEN_TEMP, VPList_Temp },
|
||||
{ DGUS_SCREEN_TEMP_PLA, VPList_PreheatPLASettings },
|
||||
{ DGUS_SCREEN_TEMP_ABS, VPList_PreheatABSSettings },
|
||||
|
||||
{ DGUS_SCREEN_INFO, VPList_PrintScreen },
|
||||
{ DGUS_SCREEN_ZOFFSET_LEVEL, VPList_ZOffsetLevel },
|
||||
{ DGUS_SCREEN_LEVELING, VPList_Leveling },
|
||||
|
||||
{ DGUS_SCREEN_POWER_LOSS, VPList_None },
|
||||
{ DGUS_SCREEN_THERMAL_RUNAWAY, VPList_None },
|
||||
{ DGUS_SCREEN_HEATING_FAILED, VPList_None },
|
||||
{ DGUS_SCREEN_THERMISTOR_ERROR, VPList_None },
|
||||
|
||||
{ DGUS_SCREEN_AUTOHOME, VPList_None },
|
||||
|
||||
{ DGUS_SCREEN_DIALOG_PAUSE, VPList_None },
|
||||
{ DGUS_SCREEN_DIALOG_STOP, VPList_DialogStop },
|
||||
|
||||
{ DGUS_SCREEN_CONFIRM, VPList_None },
|
||||
{ DGUS_SCREEN_POPUP, VPList_None },
|
||||
|
||||
|
||||
{ 0 , nullptr } // List is terminated with an nullptr as table entry.
|
||||
};
|
||||
|
||||
const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
|
||||
// TODO:
|
||||
|
||||
#if HOTENDS >= 1
|
||||
VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, screen.sendFloatAsIntValueToDisplay<0>),
|
||||
VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, screen.handleTemperatureChanged, &screen.sendWordValueToDisplay),
|
||||
#endif
|
||||
|
||||
#if HAS_HEATED_BED
|
||||
VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, screen.sendFloatAsIntValueToDisplay<0>),
|
||||
VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, screen.handleTemperatureChanged, &screen.sendWordValueToDisplay),
|
||||
#endif
|
||||
|
||||
VPHELPER(VP_MESH_LEVEL_TEMP, &thermalManager.temp_hotend[0].target, nullptr, &screen.sendWordValueToDisplay),
|
||||
VPHELPER(VP_MESH_LEVEL_STATUS, nullptr, nullptr, nullptr),
|
||||
|
||||
// Feedrate
|
||||
VPHELPER(VP_Feedrate_Percentage, &feedrate_percentage, screen.setValueDirectly<int16_t>, &screen.sendWordValueToDisplay ),
|
||||
|
||||
VPHELPER(VP_PrintProgress_Percentage, nullptr, nullptr, screen.sendPrintProgressToDisplay),
|
||||
VPHELPER(VP_PrintTimeProgressBar, nullptr, nullptr, screen.sendPrintProgressToDisplay),
|
||||
|
||||
// Preheat settings
|
||||
#if PREHEAT_COUNT
|
||||
#ifdef PREHEAT_1_LABEL
|
||||
VPHELPER(VP_PREHEAT_PLA_HOTEND_TEMP, &ui.material_preset[0].hotend_temp, screen.setValueDirectly<int16_t>, &screen.sendWordValueToDisplay ),
|
||||
VPHELPER(VP_PREHEAT_PLA_BED_TEMP, &ui.material_preset[0].bed_temp, screen.setValueDirectly<int16_t>, &screen.sendWordValueToDisplay ),
|
||||
#endif
|
||||
#ifdef PREHEAT_2_LABEL
|
||||
VPHELPER(VP_PREHEAT_ABS_HOTEND_TEMP, &ui.material_preset[1].hotend_temp, screen.setValueDirectly<int16_t>, &screen.sendWordValueToDisplay ),
|
||||
VPHELPER(VP_PREHEAT_ABS_BED_TEMP, &ui.material_preset[1].bed_temp, screen.setValueDirectly<int16_t>, &screen.sendWordValueToDisplay ),
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// About info
|
||||
VPHELPER(VP_MARLIN_VERSION, nullptr, nullptr, screen.sendAboutFirmwareVersion),
|
||||
VPHELPER(VP_PRINTER_BEDSIZE, nullptr, nullptr, screen.sendAboutPrintSize),
|
||||
|
||||
// Position Data
|
||||
//VPHELPER(VP_XPos, ¤t_position.x, nullptr, screen.sendFloatAsLongValueToDisplay<2>),
|
||||
//VPHELPER(VP_YPos, ¤t_position.y, nullptr, screen.sendFloatAsLongValueToDisplay<2>),
|
||||
//VPHELPER(VP_YPos, ¤t_position.y, nullptr, screen.sendFloatAsLongValueToDisplay<2>),
|
||||
|
||||
VPHELPER(VP_ZPos, &probe.offset.z, screen.handleProbeOffsetZChanged, screen.sendFloatAsIntValueToDisplay<2>),
|
||||
|
||||
VPHELPER(VP_FAN_TOGGLE, &thermalManager.fan_speed[0], screen.handleFanControl, screen.sendFanStatusToDisplay),
|
||||
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
VPHELPER(VP_POWER_LOSS_RECOVERY, nullptr, &screen.handlePowerLossRecovery, nullptr),
|
||||
#endif
|
||||
|
||||
VPHELPER_STR(VP_PrintTime, nullptr, VP_PrintTime_LEN, nullptr, screen.sendPrintTimeToDisplay ),
|
||||
VPHELPER(VP_SCREENCHANGE, nullptr, screen.screenChangeHook, nullptr),
|
||||
VPHELPER(VP_CONFIRMED, nullptr, screen.screenConfirmedOK, nullptr),
|
||||
|
||||
// Feed
|
||||
VPHELPER(VP_FEED_AMOUNT, &screen.feed_amount, screen.handleFeedAmountChanged, screen.sendFloatAsIntValueToDisplay<2>),
|
||||
|
||||
// Creality has the same button ID mapped all over the place, so let the generic handler figure it out
|
||||
VPHELPER(VP_BUTTON_MAINENTERKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
|
||||
VPHELPER(VP_BUTTON_ADJUSTENTERKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
|
||||
VPHELPER(VP_BUTTON_PREPAREENTERKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
|
||||
VPHELPER(VP_BUTTON_RESUMEPRINTKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
|
||||
VPHELPER(VP_BUTTON_SELECTFILEKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
|
||||
VPHELPER(VP_BUTTON_STARTPRINTKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
|
||||
VPHELPER(VP_BUTTON_STOPPRINTKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
|
||||
VPHELPER(VP_BUTTON_PAUSEPRINTKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
|
||||
VPHELPER(VP_BUTTON_COOLDOWN, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
|
||||
VPHELPER(VP_BUTTON_TEMPCONTROL, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
|
||||
VPHELPER(VP_BUTTON_BEDLEVELKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
|
||||
VPHELPER(VP_BUTTON_HEATLOADSTARTKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
|
||||
|
||||
// File listing
|
||||
VPHELPER(VP_SD_ScrollEvent, nullptr, screen.sdScrollFilelist, nullptr),
|
||||
VPHELPER(VP_SD_FileSelected, nullptr, screen.sdFileSelected, nullptr),
|
||||
VPHELPER(VP_SD_FileSelectConfirm, nullptr, screen.sdStartPrint, nullptr),
|
||||
VPHELPER_STR(VP_SD_FileName0, nullptr, VP_SD_FileName_LEN, nullptr, screen.sdSendFilename ),
|
||||
VPHELPER_STR(VP_SD_FileName1, nullptr, VP_SD_FileName_LEN, nullptr, screen.sdSendFilename ),
|
||||
VPHELPER_STR(VP_SD_FileName2, nullptr, VP_SD_FileName_LEN, nullptr, screen.sdSendFilename ),
|
||||
VPHELPER_STR(VP_SD_FileName3, nullptr, VP_SD_FileName_LEN, nullptr, screen.sdSendFilename ),
|
||||
VPHELPER_STR(VP_SD_FileName4, nullptr, VP_SD_FileName_LEN, nullptr, screen.sdSendFilename ),
|
||||
VPHELPER_STR(VP_SD_FileName5, nullptr, VP_SD_FileName_LEN, nullptr, screen.sdSendFilename ),
|
||||
|
||||
// Icons
|
||||
VPHELPER(VP_STEPPERS, &screen.are_steppers_enabled, nullptr, (screen.sendIconValue<ICON_TOGGLE_OFF, ICON_TOGGLE_ON>)),
|
||||
VPHELPER(VP_LED_TOGGLE, &caselight.on, nullptr, (screen.sendIconValue<ICON_TOGGLE_ON,ICON_TOGGLE_OFF>)),
|
||||
|
||||
// M117 LCD String (We don't need the string in memory but "just" push it to the display on demand, hence the nullptr
|
||||
{ .VP = VP_M117, .memadr = nullptr, .size = VP_M117_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&screen.sendStringToDisplay },
|
||||
|
||||
// Messages for the User, shared by the popup and the kill screen. They cant be autouploaded as we do not buffer content.
|
||||
{ .VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &screen.sendStringToDisplayPGM },
|
||||
{ .VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &screen.sendStringToDisplayPGM },
|
||||
{ .VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &screen.sendStringToDisplayPGM },
|
||||
//{ .VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &screen.sendStringToDisplayPGM },
|
||||
|
||||
VPHELPER(0, 0, 0, 0) // must be last entry.
|
||||
};
|
||||
|
||||
#endif // DGUS_LCD_UI_ORIGIN
|
357
Marlin/src/lcd/extui/dgus/creality/DGUSDisplayDef.h
Normal file
357
Marlin/src/lcd/extui/dgus/creality/DGUSDisplayDef.h
Normal file
|
@ -0,0 +1,357 @@
|
|||
/**
|
||||
* 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 "../DGUSDisplayDef.h"
|
||||
|
||||
enum DGUS_ScreenID : uint8_t {
|
||||
DGUS_SCREEN_BOOT = 0,
|
||||
|
||||
DGUS_SCREEN_MAIN = 28,
|
||||
|
||||
DGUS_SCREEN_CONFIRM = 66,
|
||||
DGUS_SCREEN_SDPRINTMANIPULATION = 37 ,
|
||||
DGUS_SCREEN_SDPRINTTUNE = 41,
|
||||
DGUS_SCREEN_SDFILELIST = 67,
|
||||
|
||||
DGUS_SCREEN_FILAMENTRUNOUT1 = 34, // DWINTouchPage::ERR_FILAMENTRUNOUT_HOTEND_COLD
|
||||
DGUS_SCREEN_FILAMENTRUNOUT2 = 35, // DWINTouchPage::ERR_FILAMENTRUNOUT_FILAMENT_LOADED
|
||||
|
||||
DGUS_SCREEN_PRINT_FINISH = 36, // DWINTouchPage::PRINT_FINISHED
|
||||
DGUS_SCREEN_PRINT_RUNNING = 37, // DWINTouchPage::PRINT_PROGRESS_RUNNING
|
||||
DGUS_SCREEN_PRINT_PAUSED = 39, // DWINTouchPage::PRINT_PROGRESS_PAUSED
|
||||
|
||||
DGUS_SCREEN_DIALOG_PAUSE = 38, // DWINTouchPage::DIALOG_PAUSE_PRINTING
|
||||
DGUS_SCREEN_DIALOG_STOP = 40, // DWINTouchPage::DIALOG_STOP_PRINTING
|
||||
|
||||
DGUS_SCREEN_TUNING = 41, // DWINTouchPage::MENU_TUNING
|
||||
DGUS_SCREEN_PREPARE = 42, // DWINTouchPage::MENU_PREPARE
|
||||
|
||||
DGUS_SCREEN_MOVE1MM = 43, // DWINTouchPage::MOVE_1MM
|
||||
DGUS_SCREEN_MOVE10MM = 44, // DWINTouchPage::MOVE_10MM
|
||||
DGUS_SCREEN_MOVE01MM = 45, // DWINTouchPage::MOVE_01MM
|
||||
|
||||
DGUS_SCREEN_FEED = 46, // DWINTouchPage::FEED
|
||||
DGUS_SCREEN_CONTROL = 47, // DWINTouchPage::MENU_CONTROL
|
||||
|
||||
DGUS_SCREEN_TEMP = 48, // DWINTouchPage::MENU_TEMP
|
||||
DGUS_SCREEN_TEMP_PLA = 49, // DWINTouchPage::MENU_PLA_TEMP
|
||||
DGUS_SCREEN_TEMP_ABS = 50, // DWINTouchPage::MENU_ABS_TEMP
|
||||
|
||||
DGUS_SCREEN_INFO = 51, // DWINTouchPage::MENU_ABOUT
|
||||
|
||||
DGUS_SCREEN_ZOFFSET_LEVEL = 52, // DWINTouchPage::MENU_ZOFFSET_LEVELING
|
||||
DGUS_SCREEN_LEVELING = 53, // DWINTouchPage::LEVELING
|
||||
|
||||
DGUS_SCREEN_POWER_LOSS = 54, // DWINTouchPage::DIALOG_POWER_FAILURE
|
||||
DGUS_SCREEN_THERMAL_RUNAWAY = 57, // DWINTouchPage::ERR_THERMAL_RUNAWAY
|
||||
DGUS_SCREEN_HEATING_FAILED = 58, // DWINTouchPage::ERR_HEATING_FAILED
|
||||
DGUS_SCREEN_THERMISTOR_ERROR = 59, // DWINTouchPage::ERR_THERMISTOR
|
||||
|
||||
DGUS_SCREEN_AUTOHOME = 61, // DWINTouchPage::AUTOHOME_IN_PROGRESS
|
||||
|
||||
DGUS_SCREEN_POPUP = 63, // NEW - does not exist in original display
|
||||
DGUS_SCREEN_KILL = 64, // NEW - does not exist in original display
|
||||
};
|
||||
|
||||
// Display Memory layout used (T5UID)
|
||||
// Except system variables this is arbitrary, just to organize stuff....
|
||||
|
||||
// 0x0000 .. 0x0FFF -- System variables and reserved by the display
|
||||
// 0x1000 .. 0x1FFF -- Variables to never change location, regardless of UI Version
|
||||
// 0x2000 .. 0x2FFF -- Controls (VPs that will trigger some action)
|
||||
// 0x3000 .. 0x4FFF -- Marlin Data to be displayed
|
||||
// 0x5000 .. -- SPs (if we want to modify display elements, e.g change color or like) -- currently unused
|
||||
|
||||
// As there is plenty of space (at least most displays have >8k RAM), we do not pack them too tight,
|
||||
// so that we can keep variables nicely together in the address space.
|
||||
|
||||
// UI Version always on 0x1000...0x1002 so that the firmware can check this and bail out.
|
||||
//constexpr uint16_t VP_UI_VERSION_MAJOR = 0x1000; // Major -- incremented when incompatible
|
||||
//constexpr uint16_t VP_UI_VERSION_MINOR = 0x1001; // Minor -- incremented on new features, but compatible
|
||||
//constexpr uint16_t VP_UI_VERSION_PATCH = 0x1002; // Patch -- fixed which do not change functionality.
|
||||
//constexpr uint16_t VP_UI_FLAVOUR = 0x1010; // lets reserve 16 bytes here to determine if UI is suitable for this Marlin. tbd.
|
||||
|
||||
#define VP_STARTPROGRESSBAR 0x1000
|
||||
|
||||
// // Storage space for the Killscreen messages. Reused for the popup.
|
||||
constexpr uint16_t VP_MSGSTR1 = 0x2010;
|
||||
constexpr uint8_t VP_MSGSTR1_LEN = 0x20; // might be more place for it...
|
||||
constexpr uint16_t VP_MSGSTR2 = 0x2030;
|
||||
constexpr uint8_t VP_MSGSTR2_LEN = 0x40;
|
||||
constexpr uint16_t VP_MSGSTR3 = 0x2070;
|
||||
constexpr uint8_t VP_MSGSTR3_LEN = 0x40;
|
||||
//constexpr uint16_t VP_MSGSTR4 = 0x11C0;
|
||||
//constexpr uint8_t VP_MSGSTR4_LEN = 0x20;
|
||||
|
||||
// // Screenchange request for screens that only make sense when printer is idle.
|
||||
// // e.g movement is only allowed if printer is not printing.
|
||||
// // Marlin must confirm by setting the screen manually.
|
||||
//constexpr uint16_t VP_SCREENCHANGE_ASK = 0x2000;
|
||||
constexpr uint16_t VP_SCREENCHANGE = 0x219f; // Key-Return button to new menu pressed. Data contains target screen in low byte and info in high byte.
|
||||
//constexpr uint16_t VP_TEMP_ALL_OFF = 0x2002; // Turn all heaters off. Value arbitrary ;)=
|
||||
//constexpr uint16_t VP_SCREENCHANGE_WHENSD = 0x2003; // "Print" Button touched -- go only there if there is an SD Card.
|
||||
|
||||
constexpr uint16_t VP_CONFIRMED = 0x219E; // OK on confirm screen.
|
||||
|
||||
// // Buttons on the SD-Card File listing.
|
||||
//constexpr uint16_t VP_SD_ScrollEvent = 0x2020; // Data: 0 for "up a directory", numbers are the amount to scroll, e.g -1 one up, 1 one down
|
||||
//constexpr uint16_t VP_SD_FileSelected = 0x2022; // Number of file field selected.
|
||||
constexpr uint16_t VP_SD_FileSelectConfirm = 0x2024; // (This is a virtual VP and emulated by the Confirm Screen when a file has been confirmed)
|
||||
|
||||
//constexpr uint16_t VP_SD_ResumePauseAbort = 0x2026; // Resume(Data=0), Pause(Data=1), Abort(Data=2) SD Card prints
|
||||
constexpr uint16_t VP_SD_AbortPrintConfirmed = 0x2028; // Abort print confirmation (virtual, will be injected by the confirm dialog)
|
||||
//constexpr uint16_t VP_SD_Print_Setting = 0x2040;
|
||||
//constexpr uint16_t VP_SD_Print_LiveAdjustZ = 0x2050; // Data: 0 down, 1 up
|
||||
|
||||
// // Controls for movement (we can't use the incremental / decremental feature of the display at this feature works only with 16 bit values
|
||||
// // (which would limit us to 655.35mm, which is likely not a problem for common setups, but i don't want to rule out hangprinters support)
|
||||
// // A word about the coding: The VP will be per axis and the return code will be an signed 16 bit value in 0.01 mm resolution, telling us
|
||||
// // the relative travel amount t he user wants to do. So eg. if the display sends us VP=2100 with value 100, the user wants us to move X by +1 mm.
|
||||
constexpr uint16_t VP_MOVE_X = 0x2100;
|
||||
constexpr uint16_t VP_MOVE_Y = 0x2102;
|
||||
constexpr uint16_t VP_MOVE_Z = 0x2104;
|
||||
constexpr uint16_t VP_MOVE_E0 = 0x2110;
|
||||
//constexpr uint16_t VP_MOVE_E1 = 0x2112;
|
||||
// //constexpr uint16_t VP_MOVE_E2 = 0x2114;
|
||||
// //constexpr uint16_t VP_MOVE_E3 = 0x2116;
|
||||
// //constexpr uint16_t VP_MOVE_E4 = 0x2118;
|
||||
// //constexpr uint16_t VP_MOVE_E5 = 0x211A;
|
||||
constexpr uint16_t VP_HOME_ALL = 0x2120;
|
||||
//constexpr uint16_t VP_MOTOR_LOCK_UNLOK = 0x2130;
|
||||
|
||||
// // Power loss recovery
|
||||
//constexpr uint16_t VP_POWER_LOSS_RECOVERY = 0x2180;
|
||||
|
||||
// // Fan Control Buttons , switch between "off" and "on"
|
||||
//constexpr uint16_t VP_FAN0_CONTROL = 0x2200;
|
||||
//constexpr uint16_t VP_FAN1_CONTROL = 0x2202;
|
||||
// //constexpr uint16_t VP_FAN2_CONTROL = 0x2204;
|
||||
// //constexpr uint16_t VP_FAN3_CONTROL = 0x2206;
|
||||
|
||||
// // Heater Control Buttons , triged between "cool down" and "heat PLA" state
|
||||
constexpr uint16_t VP_E0_CONTROL = 0x2210;
|
||||
//constexpr uint16_t VP_E1_CONTROL = 0x2212;
|
||||
// //constexpr uint16_t VP_E2_CONTROL = 0x2214;
|
||||
// //constexpr uint16_t VP_E3_CONTROL = 0x2216;
|
||||
// //constexpr uint16_t VP_E4_CONTROL = 0x2218;
|
||||
// //constexpr uint16_t VP_E5_CONTROL = 0x221A;
|
||||
constexpr uint16_t VP_BED_CONTROL = 0x221C;
|
||||
|
||||
// // Preheat
|
||||
//constexpr uint16_t VP_E0_BED_PREHEAT = 0x2220;
|
||||
//constexpr uint16_t VP_E1_BED_CONTROL = 0x2222;
|
||||
// //constexpr uint16_t VP_E2_BED_CONTROL = 0x2224;
|
||||
// //constexpr uint16_t VP_E3_BED_CONTROL = 0x2226;
|
||||
// //constexpr uint16_t VP_E4_BED_CONTROL = 0x2228;
|
||||
// //constexpr uint16_t VP_E5_BED_CONTROL = 0x222A;
|
||||
|
||||
// // Filament load and unload
|
||||
//constexpr uint16_t VP_E0_FILAMENT_LOAD_UNLOAD = 0x2300;
|
||||
//constexpr uint16_t VP_E1_FILAMENT_LOAD_UNLOAD = 0x2302;
|
||||
|
||||
// // Settings store , reset
|
||||
//constexpr uint16_t VP_SETTINGS = 0x2400;
|
||||
|
||||
// // PID autotune
|
||||
constexpr uint16_t VP_PID_AUTOTUNE_E0 = 0x2410;
|
||||
// //constexpr uint16_t VP_PID_AUTOTUNE_E1 = 0x2412;
|
||||
// //constexpr uint16_t VP_PID_AUTOTUNE_E2 = 0x2414;
|
||||
// //constexpr uint16_t VP_PID_AUTOTUNE_E3 = 0x2416;
|
||||
// //constexpr uint16_t VP_PID_AUTOTUNE_E4 = 0x2418;
|
||||
// //constexpr uint16_t VP_PID_AUTOTUNE_E5 = 0x241A;
|
||||
constexpr uint16_t VP_PID_AUTOTUNE_BED = 0x2420;
|
||||
|
||||
// // Firmware version on the boot screen.
|
||||
constexpr uint16_t VP_PRINTER_BEDSIZE = 0x1074;
|
||||
constexpr uint16_t VP_PRINTER_BEDSIZE_LEN = 12;
|
||||
constexpr uint16_t VP_MARLIN_VERSION = 0x2222;
|
||||
constexpr uint8_t VP_MARLIN_VERSION_LEN = 20; // there is more space on the display, if needed.
|
||||
|
||||
// Material preheat settings
|
||||
constexpr uint16_t VP_PREHEAT_PLA_HOTEND_TEMP = 0x1102;
|
||||
constexpr uint16_t VP_PREHEAT_PLA_BED_TEMP = 0x1104;
|
||||
|
||||
constexpr uint16_t VP_PREHEAT_ABS_HOTEND_TEMP = 0x1108;
|
||||
constexpr uint16_t VP_PREHEAT_ABS_BED_TEMP = 0x110a;
|
||||
|
||||
// // Place for status messages.
|
||||
constexpr uint16_t VP_M117 = 0x21B3;
|
||||
constexpr uint8_t VP_M117_LEN = 0x20;
|
||||
|
||||
// // Temperatures.
|
||||
constexpr uint16_t VP_T_E0_Is = 0x1036; // 4 Byte Integer - HEAD_CURRENT_TEMP_VP
|
||||
constexpr uint16_t VP_T_E0_Set = 0x1034; // 2 Byte Integer - HEAD_SET_TEMP_VP
|
||||
//constexpr uint16_t VP_T_E1_Is = 0x3064; // 4 Byte Integer
|
||||
|
||||
// // reserved to support up to 6 Extruders:
|
||||
// //constexpr uint16_t VP_T_E1_Set = 0x3066; // 2 Byte Integer
|
||||
// //constexpr uint16_t VP_T_E2_Is = 0x3068; // 4 Byte Integer
|
||||
// //constexpr uint16_t VP_T_E2_Set = 0x306A; // 2 Byte Integer
|
||||
// //constexpr uint16_t VP_T_E3_Is = 0x306C; // 4 Byte Integer
|
||||
// //constexpr uint16_t VP_T_E3_Set = 0x306E; // 2 Byte Integer
|
||||
// //constexpr uint16_t VP_T_E4_Is = 0x3070; // 4 Byte Integer
|
||||
// //constexpr uint16_t VP_T_E4_Set = 0x3072; // 2 Byte Integer
|
||||
// //constexpr uint16_t VP_T_E4_Is = 0x3074; // 4 Byte Integer
|
||||
// //constexpr uint16_t VP_T_E4_Set = 0x3076; // 2 Byte Integer
|
||||
// //constexpr uint16_t VP_T_E5_Is = 0x3078; // 4 Byte Integer
|
||||
// //constexpr uint16_t VP_T_E5_Set = 0x307A; // 2 Byte Integer
|
||||
|
||||
constexpr uint16_t VP_T_Bed_Is = 0x103c; // 4 Byte Integer - BED_SET_TEMP_VP
|
||||
constexpr uint16_t VP_T_Bed_Set = 0x103A; // 2 Byte Integer - BED_CURRENT_TEMP_VP
|
||||
|
||||
constexpr uint16_t VP_Flowrate_E0 = 0x3090; // 2 Byte Integer
|
||||
//constexpr uint16_t VP_Flowrate_E1 = 0x3092; // 2 Byte Integer
|
||||
|
||||
//constexpr uint16_t VP_Fan0_Percentage = 0x3100; // 2 Byte Integer (0..100)
|
||||
//constexpr uint16_t VP_Fan1_Percentage = 0x33A2; // 2 Byte Integer (0..100)
|
||||
// //constexpr uint16_t VP_Fan2_Percentage = 0x33A4; // 2 Byte Integer (0..100)
|
||||
// //constexpr uint16_t VP_Fan3_Percentage = 0x33A6; // 2 Byte Integer (0..100)
|
||||
|
||||
constexpr uint16_t VP_Feedrate_Percentage = 0x1006; // 2 Byte Integer (0..100) - PRINT_SPEED_RATE_VP
|
||||
constexpr uint16_t VP_PrintProgress_Percentage = 0x1016; // 2 Byte Integer (0..100)
|
||||
|
||||
constexpr uint16_t VP_PrintTimeProgressBar = 0x100E;
|
||||
|
||||
constexpr uint16_t VP_PrintTime = 0x21a0;
|
||||
constexpr uint16_t VP_PrintTime_LEN = 6;
|
||||
|
||||
//constexpr uint16_t VP_PrintAccTime = 0x3160;
|
||||
//constexpr uint16_t VP_PrintAccTime_LEN = 32;
|
||||
|
||||
//constexpr uint16_t VP_PrintsTotal = 0x3180;
|
||||
//constexpr uint16_t VP_PrintsTotal_LEN = 16;
|
||||
|
||||
// // Actual Position
|
||||
//constexpr uint16_t VP_XPos = 0x3110; // 4 Byte Fixed point number; format xxx.yy
|
||||
//constexpr uint16_t VP_YPos = 0x3112; // 4 Byte Fixed point number; format xxx.yy
|
||||
constexpr uint16_t VP_ZPos = 0x1026; // 4 Byte Fixed point number; format xxx.yy - AUTO_BED_LEVEL_ZOFFSET_VP [SD: this is actually Z-offset?]
|
||||
|
||||
//constexpr uint16_t VP_EPos = 0x3120; // 4 Byte Fixed point number; format xxx.yy
|
||||
|
||||
// // SDCard File Listing
|
||||
constexpr uint16_t VP_SD_ScrollEvent = 0x20D4; // Data: 0 for "up a directory", numbers are the amount to scroll, e.g -1 one up, 1 one down
|
||||
constexpr uint16_t VP_SD_FileSelected = 0x2200; // Number of file field selected.
|
||||
constexpr uint16_t VP_SD_FileName_LEN = 21; // LEN is shared for all entries.
|
||||
constexpr uint16_t VP_SD_FileName_CNT = 6; // LEN is shared for all entries.
|
||||
constexpr uint16_t DGUS_SD_FILESPERSCREEN = VP_SD_FileName_CNT; // FIXME move that info to the display and read it from there.
|
||||
constexpr uint16_t VP_SD_FileName0 = 0x20D5;
|
||||
constexpr uint16_t VP_SD_FileName1 = VP_SD_FileName0 + VP_SD_FileName_LEN;
|
||||
constexpr uint16_t VP_SD_FileName2 = VP_SD_FileName1 + VP_SD_FileName_LEN;
|
||||
constexpr uint16_t VP_SD_FileName3 = VP_SD_FileName2 + VP_SD_FileName_LEN;
|
||||
constexpr uint16_t VP_SD_FileName4 = VP_SD_FileName3 + VP_SD_FileName_LEN;
|
||||
constexpr uint16_t VP_SD_FileName5 = VP_SD_FileName4 + VP_SD_FileName_LEN;
|
||||
|
||||
constexpr uint16_t VP_SD_Print_ProbeOffsetZ = 0x32A0; //
|
||||
constexpr uint16_t VP_SD_Print_Filename = 0x2000; //
|
||||
|
||||
constexpr uint16_t VP_ICON_OVERLAY_CLEAR = 10;
|
||||
constexpr uint16_t VP_ICON_OVERLAY_SELECTED = 6;
|
||||
|
||||
// // Fan status
|
||||
//constexpr uint16_t VP_FAN0_STATUS = 0x3300;
|
||||
//constexpr uint16_t VP_FAN1_STATUS = 0x3302;
|
||||
// //constexpr uint16_t VP_FAN2_STATUS = 0x3304;
|
||||
// //constexpr uint16_t VP_FAN3_STATUS = 0x3306;
|
||||
|
||||
// // Heater status
|
||||
//constexpr uint16_t VP_E0_STATUS = 0x3310;
|
||||
// //constexpr uint16_t VP_E1_STATUS = 0x3312;
|
||||
// //constexpr uint16_t VP_E2_STATUS = 0x3314;
|
||||
// //constexpr uint16_t VP_E3_STATUS = 0x3316;
|
||||
// //constexpr uint16_t VP_E4_STATUS = 0x3318;
|
||||
// //constexpr uint16_t VP_E5_STATUS = 0x331A;
|
||||
//constexpr uint16_t VP_BED_STATUS = 0x331C;
|
||||
|
||||
//constexpr uint16_t VP_MOVE_OPTION = 0x3400;
|
||||
|
||||
// // Step per mm
|
||||
constexpr uint16_t VP_X_STEP_PER_MM = 0x3600; // at the moment , 2 byte unsigned int , 0~1638.4
|
||||
// //constexpr uint16_t VP_X2_STEP_PER_MM = 0x3602;
|
||||
constexpr uint16_t VP_Y_STEP_PER_MM = 0x3604;
|
||||
// //constexpr uint16_t VP_Y2_STEP_PER_MM = 0x3606;
|
||||
constexpr uint16_t VP_Z_STEP_PER_MM = 0x3608;
|
||||
// //constexpr uint16_t VP_Z2_STEP_PER_MM = 0x360A;
|
||||
constexpr uint16_t VP_E0_STEP_PER_MM = 0x3610;
|
||||
// //constexpr uint16_t VP_E1_STEP_PER_MM = 0x3612;
|
||||
// //constexpr uint16_t VP_E2_STEP_PER_MM = 0x3614;
|
||||
// //constexpr uint16_t VP_E3_STEP_PER_MM = 0x3616;
|
||||
// //constexpr uint16_t VP_E4_STEP_PER_MM = 0x3618;
|
||||
// //constexpr uint16_t VP_E5_STEP_PER_MM = 0x361A;
|
||||
|
||||
// // PIDs
|
||||
constexpr uint16_t VP_E0_PID_P = 0x3700; // at the moment , 2 byte unsigned int , 0~1638.4
|
||||
constexpr uint16_t VP_E0_PID_I = 0x3702;
|
||||
constexpr uint16_t VP_E0_PID_D = 0x3704;
|
||||
constexpr uint16_t VP_BED_PID_P = 0x3710;
|
||||
constexpr uint16_t VP_BED_PID_I = 0x3712;
|
||||
constexpr uint16_t VP_BED_PID_D = 0x3714;
|
||||
|
||||
// // Wating screen status
|
||||
//constexpr uint16_t VP_WAITING_STATUS = 0x3800;
|
||||
|
||||
// // SPs for certain variables...
|
||||
|
||||
// // located at 0x5000 and up
|
||||
// // Not used yet!
|
||||
// // This can be used e.g to make controls / data display invisible
|
||||
//constexpr uint16_t SP_T_E0_Is = 0x5000;
|
||||
//constexpr uint16_t SP_T_E0_Set = 0x5010;
|
||||
//constexpr uint16_t SP_T_E1_Is = 0x5020;
|
||||
//constexpr uint16_t SP_T_Bed_Is = 0x5030;
|
||||
//constexpr uint16_t SP_T_Bed_Set = 0x5040;
|
||||
|
||||
// Power loss recovery
|
||||
constexpr uint16_t VP_POWER_LOSS_RECOVERY = 0x105F;
|
||||
|
||||
// Buttons defined by Creality - Don't worry if you're confused by the naming, so am I
|
||||
constexpr uint16_t VP_BUTTON_MAINENTERKEY = 0x1002;
|
||||
constexpr uint16_t VP_BUTTON_ADJUSTENTERKEY = 0x1004;
|
||||
constexpr uint16_t VP_BUTTON_PAUSEPRINTKEY = 0x100A;
|
||||
constexpr uint16_t VP_BUTTON_TEMPCONTROL = 0x1030;
|
||||
constexpr uint16_t VP_BUTTON_COOLDOWN = 0x1032;
|
||||
constexpr uint16_t VP_BUTTON_PREPAREENTERKEY = 0x103E;
|
||||
|
||||
constexpr uint16_t VP_BUTTON_SELECTFILEKEY = 0x20D3;
|
||||
constexpr uint16_t VP_BUTTON_STARTPRINTKEY = 0x20D2;
|
||||
constexpr uint16_t VP_BUTTON_STOPPRINTKEY = 0x1008;
|
||||
constexpr uint16_t VP_BUTTON_RESUMEPRINTKEY = 0x100C;
|
||||
constexpr uint16_t VP_BUTTON_BEDLEVELKEY = 0x1044;
|
||||
|
||||
constexpr uint16_t VP_BUTTON_HEATLOADSTARTKEY = 0x1056;
|
||||
|
||||
// Additional stuff defined by Creality
|
||||
constexpr uint16_t VP_FAN_TOGGLE = 0x101E;
|
||||
constexpr uint16_t VP_LED_TOGGLE = 0x101F;
|
||||
constexpr uint16_t VP_STEPPERS = 0x1200;
|
||||
constexpr uint16_t VP_MESH_LEVEL_TEMP = 0x108A;
|
||||
constexpr uint16_t VP_MESH_LEVEL_STATUS = 0x108D;
|
||||
constexpr uint16_t VP_FEED_AMOUNT = 0x1054;
|
||||
constexpr uint16_t VP_FEED_PROGRESS = 0x108e;
|
||||
|
||||
// Icons
|
||||
constexpr uint16_t ICON_TOGGLE_ON = 1;
|
||||
constexpr uint16_t ICON_TOGGLE_OFF = 2;
|
||||
|
||||
|
||||
// Additional variables to migrate later
|
||||
extern bool LEDStatus;
|
519
Marlin/src/lcd/extui/dgus/creality/DGUSScreenHandler.cpp
Normal file
519
Marlin/src/lcd/extui/dgus/creality/DGUSScreenHandler.cpp
Normal file
|
@ -0,0 +1,519 @@
|
|||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
#include "../../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if DGUS_LCD_UI_CREALITY_TOUCH
|
||||
|
||||
#include "../DGUSScreenHandler.h"
|
||||
|
||||
#include "../../../../MarlinCore.h"
|
||||
#include "../../../../module/temperature.h"
|
||||
#include "../../../../module/motion.h"
|
||||
#include "../../../../module/settings.h"
|
||||
#include "../../../../gcode/queue.h"
|
||||
#include "../../../../module/planner.h"
|
||||
#include "../../../../sd/cardreader.h"
|
||||
#include "../../../../libs/duration_t.h"
|
||||
#include "../../../../module/printcounter.h"
|
||||
#include "../../../../feature/caselight.h"
|
||||
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
#include "../../../../feature/powerloss.h"
|
||||
#endif
|
||||
|
||||
uint8_t DGUSScreenHandlerCreality::meshLevelIndex = -1;
|
||||
bool DGUSScreenHandlerCreality::are_steppers_enabled = true;
|
||||
float DGUSScreenHandlerCreality::feed_amount = true;
|
||||
|
||||
screenUpdateCallback_t DGUSDisplay::current_screen_update_callback = &DGUSScreenHandlerCreality::updateCurrentScreen;
|
||||
|
||||
void DGUSScreenHandlerCreality::sendAboutFirmwareVersion(DGUS_VP_Variable &var) {
|
||||
PGM_P const fwVersion = PSTR(SHORT_BUILD_VERSION);
|
||||
dgus.writeVariablePGM(var.VP, fwVersion, strlen(fwVersion), true);
|
||||
}
|
||||
|
||||
void DGUSScreenHandlerCreality::sendAboutPrintSize(DGUS_VP_Variable &var) {
|
||||
char PRINTSIZE[VP_PRINTER_BEDSIZE_LEN] = {0};
|
||||
sprintf_P(PRINTSIZE, PSTR("%dx%dx%d"), X_BED_SIZE, Y_BED_SIZE, Z_MAX_POS);
|
||||
dgus.writeVariablePGM(var.VP, &PRINTSIZE, sizeof(PRINTSIZE), true);
|
||||
}
|
||||
|
||||
#if HAS_MEDIA
|
||||
|
||||
extern ExtUI::FileList filelist;
|
||||
|
||||
void DGUSScreenHandler::sdFileSelected(DGUS_VP_Variable &var, void *val_ptr) {
|
||||
uint16_t touched_nr = (int16_t)swap16(*(uint16_t*)val_ptr) + top_file;
|
||||
|
||||
if (touched_nr > filelist.count()) return;
|
||||
if (!filelist.seek(touched_nr)) return;
|
||||
if (filelist.isDir()) {
|
||||
filelist.changeDir(filelist.shortFilename());
|
||||
top_file = 0;
|
||||
forceCompleteUpdate();
|
||||
return;
|
||||
}
|
||||
|
||||
// Send print filename
|
||||
dgus.writeVariable(VP_SD_Print_Filename, filelist.filename(), VP_SD_FileName_LEN, true);
|
||||
|
||||
// Setup Confirmation screen
|
||||
file_to_print = touched_nr;
|
||||
handleUserConfirmationPopUp(VP_SD_FileSelectConfirm, PSTR("Print file"), filelist.filename(), PSTR("from SD Card?"), nullptr, true, false, true, true);
|
||||
}
|
||||
|
||||
void DGUSScreenHandler::sdStartPrint(DGUS_VP_Variable &var, void *val_ptr) {
|
||||
if (!filelist.seek(file_to_print)) return;
|
||||
ExtUI::printFile(filelist.shortFilename());
|
||||
screen.gotoScreen(DGUS_SCREEN_SDPRINTMANIPULATION);
|
||||
}
|
||||
|
||||
void DGUSScreenHandler::sdResumePauseAbort(DGUS_VP_Variable &var, void *val_ptr) {
|
||||
if (!ExtUI::isPrintingFromMedia()) return; // avoid race condition when user stays in this menu and printer finishes.
|
||||
switch (swap16(*(uint16_t*)val_ptr)) {
|
||||
case 0: // Resume
|
||||
if (ExtUI::isPrintingFromMediaPaused()) ExtUI::resumePrint();
|
||||
break;
|
||||
case 1: // Pause
|
||||
if (!ExtUI::isPrintingFromMediaPaused()) ExtUI::pausePrint();
|
||||
break;
|
||||
case 2: // Abort
|
||||
screen.handleUserConfirmationPopUp(VP_SD_AbortPrintConfirmed, nullptr, PSTR("Abort printing"), filelist.filename(), PSTR("?"), true, true, false, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void DGUSScreenHandler::sdSendFilename(DGUS_VP_Variable& var) {
|
||||
uint16_t target_line = (var.VP - VP_SD_FileName0) / VP_SD_FileName_LEN;
|
||||
if (target_line > DGUS_SD_FILESPERSCREEN) return;
|
||||
char tmpfilename[VP_SD_FileName_LEN + 1] = "";
|
||||
var.memadr = (void*)tmpfilename;
|
||||
if (filelist.seek(top_file + target_line))
|
||||
snprintf_P(tmpfilename, VP_SD_FileName_LEN, PSTR("%s%c"), filelist.filename(), filelist.isDir() ? '/' : 0);
|
||||
sendStringToDisplay(var);
|
||||
}
|
||||
|
||||
void DGUSScreenHandler::sdCardInserted() {
|
||||
top_file = 0;
|
||||
filelist.refresh();
|
||||
auto cs = screen.getCurrentScreen();
|
||||
if (cs == DGUS_SCREEN_MAIN || cs == DGUS_SCREEN_CONTROL)
|
||||
screen.gotoScreen(DGUS_SCREEN_SDFILELIST);
|
||||
}
|
||||
|
||||
void DGUSScreenHandler::sdCardRemoved() {
|
||||
if (current_screenID == DGUS_SCREEN_SDFILELIST
|
||||
|| (current_screenID == DGUS_SCREEN_CONFIRM && (confirmVP == VP_SD_AbortPrintConfirmed || confirmVP == VP_SD_FileSelectConfirm))
|
||||
|| current_screenID == DGUS_SCREEN_SDPRINTMANIPULATION
|
||||
) screen.gotoScreen(DGUS_SCREEN_MAIN);
|
||||
}
|
||||
|
||||
#endif // SDSUPPORT
|
||||
|
||||
void DGUSScreenHandlerCreality::filamentRunout() {
|
||||
screen.gotoScreen(DGUS_SCREEN_FILAMENTRUNOUT1);
|
||||
}
|
||||
|
||||
void DGUSScreenHandlerCreality::onFactoryReset() {
|
||||
screen.gotoScreen(DGUS_SCREEN_MAIN);
|
||||
}
|
||||
|
||||
#if HAS_BUZZER
|
||||
void DGUSScreenHandlerCreality::buzzer(const uint16_t frequency, const uint16_t duration/*=0*/) {
|
||||
// Frequency is fixed - duration is not but in 8 ms steps
|
||||
const uint8_t durationUnits = static_cast<uint8_t>(duration / 8);
|
||||
|
||||
const unsigned char buzzerCommand[] = { 0x00, durationUnits, 0x40 /*Volume*/, 0x02 };
|
||||
|
||||
// WAE_Music_Play_Set
|
||||
dgus.writeVariable(0xA0, buzzerCommand, sizeof(buzzerCommand));
|
||||
}
|
||||
#endif
|
||||
|
||||
void DGUSScreenHandlerCreality::onHomingStart() {
|
||||
screen.gotoScreen(DGUS_SCREEN_AUTOHOME);
|
||||
}
|
||||
|
||||
void DGUSScreenHandlerCreality::onHomingDone() {
|
||||
screen.popToOldScreen();
|
||||
}
|
||||
|
||||
void DGUSScreenHandlerCreality::onPrintDone() {
|
||||
screen.gotoScreen(DGUS_SCREEN_PRINT_FINISH);
|
||||
}
|
||||
|
||||
void DGUSScreenHandlerCreality::onLevelingStart() {
|
||||
gotoScreen(DGUS_SCREEN_LEVELING);
|
||||
|
||||
meshLevelIndex = 0;
|
||||
|
||||
dgus.writeVariable(VP_MESH_LEVEL_STATUS, static_cast<uint16_t>(1));
|
||||
forceCompleteUpdate();
|
||||
}
|
||||
|
||||
void DGUSScreenHandlerCreality::onLevelingUpdate(const int8_t xpos, const int8_t ypos) {
|
||||
meshLevelIndex++;
|
||||
|
||||
// Update icon
|
||||
dgus.writeVariable(VP_MESH_LEVEL_STATUS, static_cast<uint16_t>(meshLevelIndex + 1));
|
||||
forceCompleteUpdate();
|
||||
|
||||
if (meshLevelIndex == GRID_MAX_POINTS - 1) {
|
||||
// Done
|
||||
thermalManager.disable_all_heaters();
|
||||
|
||||
settings.save();
|
||||
|
||||
delay(1000);
|
||||
|
||||
gotoScreen(DGUS_SCREEN_ZOFFSET_LEVEL);
|
||||
}
|
||||
else {
|
||||
// We've already updated the icon, so nothing left
|
||||
}
|
||||
}
|
||||
|
||||
void DGUSScreenHandler::screenChangeHook(DGUS_VP_Variable &var, void *val_ptr) {
|
||||
uint8_t *tmp = (uint8_t*)val_ptr;
|
||||
|
||||
// The keycode in target is coded as <from-frame><to-frame>, so 0x0100A means
|
||||
// from screen 1 (main) to 10 (temperature). DGUS_SCREEN_POPUP is special,
|
||||
// meaning "return to previous screen"
|
||||
DGUS_ScreenID target = (DGUS_ScreenID)tmp[1];
|
||||
|
||||
if (confirm_action_cb && current_screenID == DGUS_SCREEN_POPUP) {
|
||||
confirm_action_cb();
|
||||
popToOldScreen();
|
||||
return;
|
||||
}
|
||||
|
||||
if (target == DGUS_SCREEN_POPUP || target == DGUS_SCREEN_CONFIRM || target == 0 || target == 255 /*Buggy DWIN screen sometimes just returns 255*/) {
|
||||
popToOldScreen();
|
||||
return;
|
||||
}
|
||||
|
||||
updateNewScreen(target);
|
||||
|
||||
#ifdef DEBUG_DGUSLCD
|
||||
if (!DGUS_FindScreenVPMapList(target)) DEBUG_ECHOLNPGM("WARNING: No screen Mapping found for ", target);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
|
||||
void DGUSScreenHandler::handleManualMoveOption(DGUS_VP_Variable &var, void *val_ptr) {
|
||||
*(uint16_t*)var.memadr = swap16(*(uint16_t*)val_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
void DGUSScreenHandler::handleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
|
||||
int16_t movevalue = swap16(*(uint16_t*)val_ptr);
|
||||
#if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
|
||||
if (movevalue) {
|
||||
const uint16_t choice = *(uint16_t*)var.memadr;
|
||||
movevalue = movevalue < 0 ? -choice : choice;
|
||||
}
|
||||
#endif
|
||||
char axiscode;
|
||||
uint16_t speed = manual_feedrate_mm_m[X_AXIS]; // Default feedrate for manual moves
|
||||
|
||||
switch (var.VP) {
|
||||
default: return;
|
||||
|
||||
case VP_MOVE_X:
|
||||
axiscode = 'X';
|
||||
if (!ExtUI::canMove(ExtUI::axis_t::X)) goto cannotmove;
|
||||
break;
|
||||
|
||||
case VP_MOVE_Y:
|
||||
axiscode = 'Y';
|
||||
speed = manual_feedrate_mm_m[Y_AXIS];
|
||||
if (!ExtUI::canMove(ExtUI::axis_t::Y)) goto cannotmove;
|
||||
break;
|
||||
|
||||
case VP_MOVE_Z:
|
||||
axiscode = 'Z';
|
||||
speed = manual_feedrate_mm_m[Z_AXIS];
|
||||
if (!ExtUI::canMove(ExtUI::axis_t::Z)) goto cannotmove;
|
||||
break;
|
||||
|
||||
case VP_HOME_ALL: // only used for homing
|
||||
axiscode = '\0';
|
||||
movevalue = 0; // ignore value sent from display, this VP is _ONLY_ for homing.
|
||||
break;
|
||||
}
|
||||
|
||||
if (!movevalue) {
|
||||
// homing
|
||||
char buf[6] = "G28 X";
|
||||
buf[4] = axiscode;
|
||||
queue.enqueue_one_now(buf);
|
||||
screen.forceCompleteUpdate();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
// movement
|
||||
bool old_relative_mode = relative_mode;
|
||||
if (!relative_mode) queue.enqueue_now_P(PSTR("G91"));
|
||||
char buf[32]; // G1 X9999.99 F12345
|
||||
unsigned int backup_speed = MMS_TO_MMM(feedrate_mm_s);
|
||||
char sign[]="\0";
|
||||
int16_t value = movevalue / 100;
|
||||
if (movevalue < 0) { value = -value; sign[0] = '-'; }
|
||||
int16_t fraction = ABS(movevalue) % 100;
|
||||
snprintf_P(buf, 32, PSTR("G0 %c%s%d.%02d F%d"), axiscode, sign, value, fraction, speed);
|
||||
queue.enqueue_one_now(buf);
|
||||
if (backup_speed != speed) {
|
||||
snprintf_P(buf, 32, PSTR("G0 F%d"), backup_speed);
|
||||
queue.enqueue_one_now(buf);
|
||||
}
|
||||
//while (!enqueue_and_echo_command(buf)) idle();
|
||||
if (!old_relative_mode) queue.enqueue_now_P(PSTR("G90"));
|
||||
}
|
||||
|
||||
screen.forceCompleteUpdate();
|
||||
|
||||
cannotmove:
|
||||
return;
|
||||
}
|
||||
|
||||
#if HAS_PID_HEATING
|
||||
void DGUSScreenHandler::handleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr) {
|
||||
uint16_t rawvalue = swap16(*(uint16_t*)val_ptr);
|
||||
float value = (float)rawvalue / 10;
|
||||
float newvalue = 0;
|
||||
|
||||
switch (var.VP) {
|
||||
default: return;
|
||||
#if HOTENDS >= 1
|
||||
case VP_E0_PID_P: newvalue = value; break;
|
||||
case VP_E0_PID_I: newvalue = scalePID_i(value); break;
|
||||
case VP_E0_PID_D: newvalue = scalePID_d(value); break;
|
||||
#endif
|
||||
#if HOTENDS >= 2
|
||||
case VP_E1_PID_P: newvalue = value; break;
|
||||
case VP_E1_PID_I: newvalue = scalePID_i(value); break;
|
||||
case VP_E1_PID_D: newvalue = scalePID_d(value); break;
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
case VP_BED_PID_P: newvalue = value; break;
|
||||
case VP_BED_PID_I: newvalue = scalePID_i(value); break;
|
||||
case VP_BED_PID_D: newvalue = scalePID_d(value); break;
|
||||
#endif
|
||||
}
|
||||
|
||||
*(float *)var.memadr = newvalue;
|
||||
screen.skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
|
||||
}
|
||||
#endif
|
||||
|
||||
void DGUSScreenHandlerCreality::handleFeedAmountChanged(DGUS_VP_Variable &var, void *val_ptr) {
|
||||
int16_t movevalue = swap16(*(uint16_t*)val_ptr);
|
||||
float target = movevalue * 0.01f;
|
||||
|
||||
*(float *)var.memadr = target;
|
||||
|
||||
screen.skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
|
||||
}
|
||||
|
||||
#if ENABLED(BABYSTEPPING)
|
||||
void DGUSScreenHandler::handleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr) {
|
||||
const float absoluteAmount = float(swap16(*(uint16_t*)val_ptr)) / 100.0f,
|
||||
existingAmount = ExtUI::getZOffset_mm(),
|
||||
difference = absoluteAmount - existingAmount;
|
||||
|
||||
const int16_t steps = ExtUI::mmToWholeSteps(difference, ExtUI::axis_t::Z);
|
||||
|
||||
ExtUI::smartAdjustAxis_steps(steps, ExtUI::axis_t::Z, true);
|
||||
|
||||
screen.forceCompleteUpdate();
|
||||
screen.skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
|
||||
|
||||
void DGUSScreenHandler::handleFilamentOption(DGUS_VP_Variable &var, void *val_ptr) {
|
||||
uint8_t e_temp = 0;
|
||||
filament_data.heated = false;
|
||||
uint16_t preheat_option = swap16(*(uint16_t*)val_ptr);
|
||||
if (preheat_option <= 8) // Load filament type
|
||||
filament_data.action = 1;
|
||||
else if (preheat_option >= 10) { // Unload filament type
|
||||
preheat_option -= 10;
|
||||
filament_data.action = 2;
|
||||
filament_data.purge_length = DGUS_FILAMENT_PURGE_LENGTH;
|
||||
}
|
||||
else // Cancel filament operation
|
||||
filament_data.action = 0;
|
||||
|
||||
switch (preheat_option) {
|
||||
case 0: // Load PLA
|
||||
#ifdef PREHEAT_1_TEMP_HOTEND
|
||||
e_temp = PREHEAT_1_TEMP_HOTEND;
|
||||
#endif
|
||||
break;
|
||||
case 1: // Load ABS
|
||||
TERN_(PREHEAT_2_TEMP_HOTEND, e_temp = PREHEAT_2_TEMP_HOTEND);
|
||||
break;
|
||||
case 2: // Load PET
|
||||
#ifdef PREHEAT_3_TEMP_HOTEND
|
||||
e_temp = PREHEAT_3_TEMP_HOTEND;
|
||||
#endif
|
||||
break;
|
||||
case 3: // Load FLEX
|
||||
#ifdef PREHEAT_4_TEMP_HOTEND
|
||||
e_temp = PREHEAT_4_TEMP_HOTEND;
|
||||
#endif
|
||||
break;
|
||||
case 9: // Cool down
|
||||
default:
|
||||
e_temp = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (filament_data.action == 0) { // Go back to utility screen
|
||||
#if HOTENDS >= 1
|
||||
thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E0);
|
||||
#endif
|
||||
#if HOTENDS >= 2
|
||||
thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E1);
|
||||
#endif
|
||||
gotoScreen(DGUS_SCREEN_UTILITY);
|
||||
}
|
||||
else { // Go to the preheat screen to show the heating progress
|
||||
switch (var.VP) {
|
||||
default: return;
|
||||
#if HOTENDS >= 1
|
||||
case VP_E0_FILAMENT_LOAD_UNLOAD:
|
||||
filament_data.extruder = ExtUI::extruder_t::E0;
|
||||
thermalManager.setTargetHotend(e_temp, filament_data.extruder);
|
||||
break;
|
||||
#endif
|
||||
#if HOTENDS >= 2
|
||||
case VP_E1_FILAMENT_LOAD_UNLOAD:
|
||||
filament_data.extruder = ExtUI::extruder_t::E1;
|
||||
thermalManager.setTargetHotend(e_temp, filament_data.extruder);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
gotoScreen(DGUS_SCREEN_FILAMENT_HEATING);
|
||||
}
|
||||
}
|
||||
|
||||
void DGUSScreenHandler::handleFilamentLoadUnload(DGUS_VP_Variable &var) {
|
||||
if (filament_data.action <= 0) return;
|
||||
|
||||
// If we close to the target temperature, we can start load or unload the filament
|
||||
if (thermalManager.hotEnoughToExtrude(filament_data.extruder) && \
|
||||
thermalManager.targetHotEnoughToExtrude(filament_data.extruder)) {
|
||||
float movevalue = DGUS_FILAMENT_LOAD_LENGTH_PER_TIME;
|
||||
|
||||
if (filament_data.action == 1) { // load filament
|
||||
if (!filament_data.heated) {
|
||||
gotoScreen(DGUS_SCREEN_FILAMENT_LOADING);
|
||||
filament_data.heated = true;
|
||||
}
|
||||
movevalue = ExtUI::getAxisPosition_mm(filament_data.extruder)+movevalue;
|
||||
}
|
||||
else { // unload filament
|
||||
if (!filament_data.heated) {
|
||||
gotoScreen(DGUS_SCREEN_FILAMENT_UNLOADING);
|
||||
filament_data.heated = true;
|
||||
}
|
||||
// Before unloading extrude to prevent jamming
|
||||
if (filament_data.purge_length >= 0) {
|
||||
movevalue = ExtUI::getAxisPosition_mm(filament_data.extruder) + movevalue;
|
||||
filament_data.purge_length -= movevalue;
|
||||
}
|
||||
else
|
||||
movevalue = ExtUI::getAxisPosition_mm(filament_data.extruder) - movevalue;
|
||||
}
|
||||
ExtUI::setAxisPosition_mm(movevalue, filament_data.extruder);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void DGUSScreenHandlerCreality::handleStepperState(const bool is_enabled) {
|
||||
if (are_steppers_enabled != is_enabled) {
|
||||
are_steppers_enabled = is_enabled;
|
||||
forceCompleteUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
void DGUSScreenHandlerCreality::handleLEDToggle() {
|
||||
const bool newState = !caselight.on;
|
||||
caselight.on = newState;
|
||||
caselight.update(newState);
|
||||
forceCompleteUpdate();
|
||||
}
|
||||
|
||||
void DGUSScreenHandlerCreality::updateCurrentScreen(const DGUS_ScreenID currentID) {
|
||||
if (current_screenID != currentID)
|
||||
updateNewScreen(currentID, currentID == DGUS_SCREEN_POPUP || currentID == DGUS_SCREEN_CONFIRM);
|
||||
}
|
||||
|
||||
#ifndef BOOTSCREEN_TIMEOUT
|
||||
#define BOOTSCREEN_TIMEOUT 3000
|
||||
#endif
|
||||
|
||||
bool DGUSScreenHandler::loop() {
|
||||
dgus.loop();
|
||||
|
||||
const millis_t ms = millis();
|
||||
static millis_t next_event_ms = 0;
|
||||
|
||||
if (wait_for_user && current_screenID != DGUS_SCREEN_POPUP) {
|
||||
// In some occassions the display needs more time to handle a screen change, for instance,
|
||||
// with ADVANCED_PAUSE_FEATURE, the calls to ExtUI::onUserConfirmRequired are quite fast
|
||||
gotoScreen(current_screenID, true);
|
||||
}
|
||||
|
||||
if (!isScreenComplete() || ELAPSED(ms, next_event_ms)) {
|
||||
next_event_ms = ms + DGUS_UPDATE_INTERVAL_MS;
|
||||
updateScreenVPData();
|
||||
|
||||
// Read which screen is currently triggered - navigation at display side may occur
|
||||
if (dgus.isInitialized()) dgus.readCurrentScreen();
|
||||
}
|
||||
|
||||
if (dgus.isInitialized()) {
|
||||
static bool booted = false;
|
||||
if (!booted) {
|
||||
int16_t percentage = static_cast<int16_t>(((float) ms / (float)BOOTSCREEN_TIMEOUT) * 100);
|
||||
if (percentage > 100) percentage = 100;
|
||||
|
||||
dgus.writeVariable(VP_STARTPROGRESSBAR, percentage);
|
||||
}
|
||||
|
||||
if (!booted && TERN0(POWER_LOSS_RECOVERY, recovery.valid()))
|
||||
booted = true;
|
||||
|
||||
if (!booted && ELAPSED(ms, BOOTSCREEN_TIMEOUT)) {
|
||||
booted = true;
|
||||
gotoScreen(DGUS_SCREEN_MAIN);
|
||||
}
|
||||
}
|
||||
|
||||
return isScreenComplete();
|
||||
}
|
||||
|
||||
#endif // HAS_DGUS_LCD
|
85
Marlin/src/lcd/extui/dgus/creality/DGUSScreenHandler.h
Normal file
85
Marlin/src/lcd/extui/dgus/creality/DGUSScreenHandler.h
Normal file
|
@ -0,0 +1,85 @@
|
|||
/**
|
||||
* 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 "../DGUSScreenHandlerBase.h"
|
||||
|
||||
//#define DEBUG_DGUS_SCREEN_HANDLER
|
||||
#define DEBUG_OUT ENABLED(DEBUG_DGUS_SCREEN_HANDLER)
|
||||
#include "../../../../core/debug_out.h"
|
||||
|
||||
enum DGUS_ScreenID : uint8_t;
|
||||
|
||||
class DGUSScreenHandlerCreality : public DGUSScreenHandler {
|
||||
public:
|
||||
DGUSScreenHandlerCreality() = default;
|
||||
|
||||
static void handleFeedAmountChanged(DGUS_VP_Variable &var, void *val_ptr);
|
||||
|
||||
#if HAS_BED_PROBE
|
||||
static void onLevelingStart();
|
||||
static void onLevelingUpdate(const int8_t xpos, const int8_t ypos);
|
||||
#endif
|
||||
|
||||
static void handleLEDToggle();
|
||||
static void handleStepperState(bool is_enabled);
|
||||
static void filamentRunout();
|
||||
static void onFactoryReset();
|
||||
|
||||
#if HAS_BUZZER
|
||||
static void buzzer(const uint16_t frequency, const uint16_t duration=0);
|
||||
#else
|
||||
static void buzzer(const uint16_t, const uint16_t=0) {}
|
||||
#endif
|
||||
|
||||
static void onHomingStart();
|
||||
static void onHomingDone();
|
||||
static void onPrintDone();
|
||||
|
||||
static void sendAboutFirmwareVersion(DGUS_VP_Variable &var);
|
||||
static void sendAboutPrintSize(DGUS_VP_Variable &var);
|
||||
|
||||
// Send an icon to the display, depending on whether it is true or false
|
||||
template<unsigned int value_if_true, unsigned int value_if_false>
|
||||
static void sendIconValue(DGUS_VP_Variable &var) {
|
||||
if (var.memadr) {
|
||||
bool value = *(bool *)var.memadr;
|
||||
uint16_t valueToSend = value ? value_if_true : value_if_false;
|
||||
dgus.writeVariable(var.VP, valueToSend);
|
||||
}
|
||||
}
|
||||
|
||||
static void updateCurrentScreen(const DGUS_ScreenID current);
|
||||
|
||||
static float feed_amount;
|
||||
static bool are_steppers_enabled;
|
||||
|
||||
private:
|
||||
static uint8_t meshLevelIndex;
|
||||
};
|
||||
|
||||
typedef DGUSScreenHandlerCreality DGUSScreenHandlerClass;
|
||||
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
#define PLR_SCREEN_RECOVER DGUS_SCREEN_SDPRINTMANIPULATION
|
||||
#define PLR_SCREEN_CANCEL DGUS_SCREEN_MAIN
|
||||
#endif
|
342
Marlin/src/lcd/extui/dgus/creality/PageHandlers.cpp
Normal file
342
Marlin/src/lcd/extui/dgus/creality/PageHandlers.cpp
Normal file
|
@ -0,0 +1,342 @@
|
|||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
#include "../../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if DGUS_LCD_UI_CREALITY_TOUCH
|
||||
|
||||
#include "DGUSDisplayDef.h"
|
||||
#include "../DGUSDisplay.h"
|
||||
#include "../DGUSScreenHandler.h"
|
||||
#include "PageHandlers.h"
|
||||
|
||||
#include "../../../../module/temperature.h"
|
||||
#include "../../../../module/motion.h"
|
||||
#include "../../../../module/planner.h"
|
||||
#include "../../../../feature/pause.h"
|
||||
#include "../../../../feature/runout.h"
|
||||
#include "../../../../module/settings.h"
|
||||
|
||||
#include "../../../marlinui.h" // for material presets
|
||||
#include "../../ui_api.h"
|
||||
|
||||
// Definitions of page handlers
|
||||
|
||||
void MainMenuHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
|
||||
// Nothing
|
||||
}
|
||||
|
||||
void ControlMenuHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
|
||||
switch (var.VP) {
|
||||
case VP_BUTTON_PREPAREENTERKEY:
|
||||
switch (buttonValue) {
|
||||
case 5: // About
|
||||
// Automatically handled
|
||||
break;
|
||||
|
||||
case 7: // Reset to factory settings
|
||||
settings.reset();
|
||||
settings.save();
|
||||
break;
|
||||
|
||||
case 9: // Back button
|
||||
// TODO: should navigate automatically
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case VP_BUTTON_ADJUSTENTERKEY:
|
||||
screen.handleLEDToggle();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void LevelingModeHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
|
||||
switch (var.VP) {
|
||||
case VP_BUTTON_BEDLEVELKEY:
|
||||
switch (buttonValue) {
|
||||
case 1: {
|
||||
const bool xy_known = ExtUI::isAxisPositionKnown(ExtUI::axis_t::X) && ExtUI::isAxisPositionKnown(ExtUI::axis_t::Y);
|
||||
ExtUI::injectCommands_P(xy_known ? PSTR("G28 Z") : PSTR("G28"));
|
||||
} break;
|
||||
|
||||
case 2 ... 3: {
|
||||
// Increase / Decrease Z-offset
|
||||
const int16_t steps = ExtUI::mmToWholeSteps(0.01, ExtUI::axis_t::Z);
|
||||
ExtUI::smartAdjustAxis_steps(buttonValue == 2 ? steps : -steps, ExtUI::axis_t::Z, true);
|
||||
screen.forceCompleteUpdate();
|
||||
} break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case VP_BUTTON_MAINENTERKEY:
|
||||
// Go to leveling screen
|
||||
ExtUI::injectCommands_P(PSTR("G28\nG29"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void LevelingHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
|
||||
switch (var.VP) {
|
||||
case VP_BUTTON_BEDLEVELKEY:
|
||||
screen.gotoScreen(DGUS_SCREEN_ZOFFSET_LEVEL);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void TempMenuHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
|
||||
switch (var.VP) {
|
||||
case VP_BUTTON_ADJUSTENTERKEY:
|
||||
switch (buttonValue) {
|
||||
case 3:
|
||||
DGUSScreenHandler::handleFanControl(var, &buttonValue);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PrepareMenuHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
|
||||
switch (var.VP) {
|
||||
case VP_BUTTON_PREPAREENTERKEY:
|
||||
// Disable steppers
|
||||
screen.handleMotorLockUnlock(var, &buttonValue);
|
||||
break;
|
||||
|
||||
case VP_BUTTON_COOLDOWN:
|
||||
screen.handleAllHeatersOff(var, &buttonValue);
|
||||
break;
|
||||
|
||||
case VP_BUTTON_TEMPCONTROL:
|
||||
#if PREHEAT_COUNT
|
||||
switch (buttonValue) {
|
||||
case 5:
|
||||
thermalManager.setTargetHotend(ui.material_preset[0].hotend_temp, 0);
|
||||
thermalManager.setTargetBed(ui.material_preset[0].bed_temp);
|
||||
break;
|
||||
case 6:
|
||||
thermalManager.setTargetHotend(ui.material_preset[1].hotend_temp, 0);
|
||||
thermalManager.setTargetBed(ui.material_preset[1].bed_temp);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
screen.forceCompleteUpdate();
|
||||
}
|
||||
|
||||
void TuneMenuHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
|
||||
switch (var.VP) {
|
||||
case VP_BUTTON_ADJUSTENTERKEY:
|
||||
switch (buttonValue) {
|
||||
case 2:
|
||||
screen.gotoScreen(ExtUI::isPrintingFromMediaPaused() ? DGUS_SCREEN_PRINT_PAUSED : DGUS_SCREEN_PRINT_RUNNING);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
DGUSScreenHandler::handleFanControl(var, &buttonValue);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
screen.handleLEDToggle();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PrintRunningMenuHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
|
||||
// There are actually no buttons to handle here: all buttons navigate to other screens (like confirmation screens)
|
||||
}
|
||||
|
||||
void PrintPausedMenuHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
|
||||
switch (var.VP) {
|
||||
case VP_BUTTON_RESUMEPRINTKEY:
|
||||
runout.reset();
|
||||
ExtUI::resumePrint();
|
||||
screen.gotoScreen(DGUS_SCREEN_PRINT_RUNNING);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PrintPauseDialogHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
|
||||
switch (var.VP) {
|
||||
case VP_BUTTON_PAUSEPRINTKEY:
|
||||
switch (buttonValue) {
|
||||
case 2:
|
||||
ExtUI::pausePrint();
|
||||
screen.gotoScreen(DGUS_SCREEN_PRINT_PAUSED);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
screen.gotoScreen(DGUS_SCREEN_PRINT_RUNNING);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void FilamentRunoutHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
|
||||
switch (var.VP) {
|
||||
case VP_BUTTON_RESUMEPRINTKEY:
|
||||
ExtUI::resumePrint();
|
||||
screen.gotoScreen(DGUS_SCREEN_PRINT_RUNNING);
|
||||
break;
|
||||
|
||||
case VP_BUTTON_STOPPRINTKEY:
|
||||
ExtUI::stopPrint();
|
||||
screen.gotoScreen(DGUS_SCREEN_MAIN);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void StopConfirmScreenHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
|
||||
switch (var.VP) {
|
||||
case VP_BUTTON_STOPPRINTKEY:
|
||||
switch (buttonValue) {
|
||||
case 2:
|
||||
ExtUI::stopPrint();
|
||||
screen.gotoScreen(DGUS_SCREEN_MAIN);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
screen.gotoScreen(ExtUI::isPrintingFromMediaPaused() ? DGUS_SCREEN_PRINT_PAUSED : DGUS_SCREEN_PRINT_RUNNING);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PreheatSettingsScreenHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
|
||||
switch (var.VP) {
|
||||
case VP_BUTTON_PREPAREENTERKEY:
|
||||
// Save button, save settings and go back
|
||||
settings.save();
|
||||
screen.gotoScreen(DGUS_SCREEN_TEMP);
|
||||
break;
|
||||
|
||||
case VP_BUTTON_COOLDOWN:
|
||||
// Back button, discard settings
|
||||
settings.load();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void FeedHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
|
||||
if (var.VP != VP_BUTTON_HEATLOADSTARTKEY) return;
|
||||
|
||||
switch (buttonValue) {
|
||||
case 1:
|
||||
if (ExtUI::getActualTemp_celsius(ExtUI::H0) < PREHEAT_1_TEMP_HOTEND) {
|
||||
ExtUI::setTargetTemp_celsius(PREHEAT_1_TEMP_HOTEND, ExtUI::H0);
|
||||
thermalManager.wait_for_hotend(0);
|
||||
}
|
||||
|
||||
dgus.writeVariable(VP_FEED_PROGRESS, static_cast<int16_t>(10));
|
||||
|
||||
load_filament(
|
||||
FILAMENT_CHANGE_SLOW_LOAD_LENGTH,
|
||||
FILAMENT_CHANGE_FAST_LOAD_LENGTH,
|
||||
screen.feed_amount,
|
||||
FILAMENT_CHANGE_ALERT_BEEPS,
|
||||
false,
|
||||
thermalManager.still_heating(0),
|
||||
PAUSE_MODE_LOAD_FILAMENT
|
||||
);
|
||||
|
||||
dgus.writeVariable(VP_FEED_PROGRESS, static_cast<int16_t>(0));
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (ExtUI::getActualTemp_celsius(ExtUI::H0) < PREHEAT_1_TEMP_HOTEND) {
|
||||
ExtUI::setTargetTemp_celsius(PREHEAT_1_TEMP_HOTEND, ExtUI::H0);
|
||||
thermalManager.wait_for_hotend(0);
|
||||
}
|
||||
|
||||
dgus.writeVariable(VP_FEED_PROGRESS, static_cast<int16_t>(10));
|
||||
|
||||
unload_filament(screen.feed_amount, false, PAUSE_MODE_UNLOAD_FILAMENT);
|
||||
|
||||
dgus.writeVariable(VP_FEED_PROGRESS, static_cast<int16_t>(0));
|
||||
break;
|
||||
}
|
||||
|
||||
screen.forceCompleteUpdate();
|
||||
}
|
||||
|
||||
// Register the page handlers
|
||||
#define PAGE_HANDLER(SCRID, HDLRPTR) { .ScreenID = SCRID, .Handler = HDLRPTR },
|
||||
|
||||
const struct PageHandler PageHandlers[] PROGMEM = {
|
||||
PAGE_HANDLER(DGUS_ScreenID::DGUS_SCREEN_MAIN, MainMenuHandler)
|
||||
|
||||
PAGE_HANDLER(DGUS_ScreenID::DGUS_SCREEN_CONTROL, ControlMenuHandler)
|
||||
|
||||
PAGE_HANDLER(DGUS_ScreenID::DGUS_SCREEN_ZOFFSET_LEVEL, LevelingModeHandler)
|
||||
PAGE_HANDLER(DGUS_ScreenID::DGUS_SCREEN_LEVELING, LevelingHandler)
|
||||
|
||||
PAGE_HANDLER(DGUS_ScreenID::DGUS_SCREEN_TEMP, TempMenuHandler)
|
||||
PAGE_HANDLER(DGUS_ScreenID::DGUS_SCREEN_TEMP_PLA, PreheatSettingsScreenHandler)
|
||||
PAGE_HANDLER(DGUS_ScreenID::DGUS_SCREEN_TEMP_ABS, PreheatSettingsScreenHandler)
|
||||
|
||||
PAGE_HANDLER(DGUS_ScreenID::DGUS_SCREEN_TUNING, TuneMenuHandler)
|
||||
PAGE_HANDLER(DGUS_ScreenID::DGUS_SCREEN_FEED, FeedHandler)
|
||||
|
||||
PAGE_HANDLER(DGUS_ScreenID::DGUS_SCREEN_FILAMENTRUNOUT1, FilamentRunoutHandler)
|
||||
|
||||
PAGE_HANDLER(DGUS_ScreenID::DGUS_SCREEN_DIALOG_STOP, StopConfirmScreenHandler)
|
||||
|
||||
PAGE_HANDLER(DGUS_ScreenID::DGUS_SCREEN_PRINT_RUNNING, PrintRunningMenuHandler)
|
||||
PAGE_HANDLER(DGUS_ScreenID::DGUS_SCREEN_PRINT_PAUSED, PrintPausedMenuHandler)
|
||||
|
||||
PAGE_HANDLER(DGUS_ScreenID::DGUS_SCREEN_DIALOG_PAUSE, PrintPauseDialogHandler)
|
||||
|
||||
PAGE_HANDLER(DGUS_ScreenID::DGUS_SCREEN_PREPARE, PrepareMenuHandler)
|
||||
|
||||
// Terminating
|
||||
PAGE_HANDLER(static_cast<DGUS_ScreenID>(0), 0)
|
||||
};
|
||||
|
||||
void DGUSCrealityDisplay_HandleReturnKeyEvent(DGUS_VP_Variable &var, void *val_ptr) {
|
||||
const struct PageHandler *map = PageHandlers;
|
||||
const uint16_t *ret;
|
||||
const DGUS_ScreenID current_screenID = DGUSScreenHandler::getCurrentScreen();
|
||||
|
||||
while ((ret = (uint16_t*) pgm_read_ptr(&(map->Handler)))) {
|
||||
if (map->ScreenID == current_screenID) {
|
||||
unsigned short button_value = *static_cast<unsigned short*>(val_ptr);
|
||||
button_value = (button_value & 0xffU) << 8U | (button_value >> 8U);
|
||||
|
||||
SERIAL_ECHOPGM("Invoking handler for screen ", current_screenID);
|
||||
SERIAL_ECHOLNPGM("with VP=", var.VP, " value=", button_value);
|
||||
|
||||
map->Handler(var, button_value);
|
||||
return;
|
||||
}
|
||||
|
||||
map++;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // DGUS_LCD_UI_CREALITY_TOUCH
|
32
Marlin/src/lcd/extui/dgus/creality/PageHandlers.h
Normal file
32
Marlin/src/lcd/extui/dgus/creality/PageHandlers.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
* 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
|
||||
|
||||
// Mapping of handlers per page. This construction is necessary because the CR-6 touch screen re-uses the same button IDs all over the place.
|
||||
typedef void (*DGUS_CREALITY_SCREEN_BUTTON_HANDLER)(DGUS_VP_Variable &var, unsigned short buttonValue);
|
||||
|
||||
struct PageHandler {
|
||||
DGUS_ScreenID ScreenID;
|
||||
DGUS_CREALITY_SCREEN_BUTTON_HANDLER Handler;
|
||||
};
|
||||
|
||||
void DGUSCrealityDisplay_HandleReturnKeyEvent(DGUS_VP_Variable &var, void *val_ptr);
|
|
@ -33,6 +33,8 @@
|
|||
#include "DGUSDisplayDef.h"
|
||||
#include "DGUSScreenHandler.h"
|
||||
|
||||
extern const char NUL_STR[];
|
||||
|
||||
namespace ExtUI {
|
||||
|
||||
void onStartup() {
|
||||
|
@ -43,8 +45,20 @@ namespace ExtUI {
|
|||
void onIdle() { screen.loop(); }
|
||||
|
||||
void onPrinterKilled(FSTR_P const error, FSTR_P const) {
|
||||
screen.sendInfoScreen(GET_TEXT_F(MSG_HALTED), error, FPSTR(NUL_STR), GET_TEXT_F(MSG_PLEASE_RESET), true, true, true, true);
|
||||
screen.gotoScreen(DGUS_SCREEN_KILL);
|
||||
DGUS_ScreenID screenID = DGUS_SCREEN_KILL;
|
||||
#if DGUS_LCD_UI_CREALITY_TOUCH
|
||||
if (strcmp_P(FTOP(error), GET_TEXT(MSG_ERR_MAXTEMP)) == 0 || strcmp_P(FTOP(error), GET_TEXT(MSG_ERR_THERMAL_RUNAWAY)) == 0)
|
||||
screenID = DGUS_SCREEN_THERMAL_RUNAWAY;
|
||||
else if (strcmp_P(FTOP(error), GET_TEXT(MSG_ERR_HEATING_FAILED)) == 0)
|
||||
screenID = DGUS_SCREEN_HEATING_FAILED;
|
||||
else if (strcmp_P(FTOP(error), GET_TEXT(MSG_ERR_MINTEMP)) == 0)
|
||||
screenID = DGUS_SCREEN_THERMISTOR_ERROR;
|
||||
screen.sendInfoScreen(GET_TEXT_F(MSG_HALTED), error, GET_TEXT_F(MSG_PLEASE_RESET), FPSTR(NUL_STR), true, true, true, true);
|
||||
#else
|
||||
screen.sendInfoScreen(GET_TEXT_F(MSG_HALTED), error, FPSTR(NUL_STR), GET_TEXT_F(MSG_PLEASE_RESET), true, true, true, true);
|
||||
#endif
|
||||
|
||||
screen.gotoScreen(screenID);
|
||||
while (!screen.loop()); // Wait while anything is left to be sent
|
||||
}
|
||||
|
||||
|
@ -56,20 +70,54 @@ namespace ExtUI {
|
|||
void onMinTempError(const heater_id_t header_id) {}
|
||||
void onMaxTempError(const heater_id_t header_id) {}
|
||||
|
||||
void onPlayTone(const uint16_t frequency, const uint16_t duration/*=0*/) {}
|
||||
void onPlayTone(const uint16_t frequency, const uint16_t duration/*=0*/) {
|
||||
TERN_(DGUS_LCD_UI_CREALITY_TOUCH, screen.buzzer(frequency, duration));
|
||||
}
|
||||
void onPrintTimerStarted() {}
|
||||
void onPrintTimerPaused() {}
|
||||
|
||||
void onPrintTimerPaused() {
|
||||
#if DGUS_LCD_UI_CREALITY_TOUCH
|
||||
// Handle M28 Pause SD print - But only if we're not waiting on a user
|
||||
if (isPrintingFromMediaPaused() && screen.getCurrentScreen() == DGUS_SCREEN_PRINT_RUNNING)
|
||||
screen.gotoScreen(DGUS_SCREEN_PRINT_PAUSED);
|
||||
#endif
|
||||
}
|
||||
|
||||
void onPrintTimerStopped() {}
|
||||
void onFilamentRunout(const extruder_t extruder) {}
|
||||
|
||||
void onFilamentRunout(const extruder_t extruder) { TERN_(DGUS_LCD_UI_CREALITY_TOUCH, screen.filamentRunout()); }
|
||||
|
||||
inline void onUserConfirmed() {
|
||||
screen.setupConfirmAction(nullptr);
|
||||
#if DGUS_LCD_UI_CREALITY_TOUCH
|
||||
//SERIAL_ECHOLNPGM("User confirmation invoked");
|
||||
setUserConfirmed();
|
||||
#else
|
||||
screen.popToOldScreen();
|
||||
#endif
|
||||
}
|
||||
|
||||
void onUserConfirmRequired(const char * const msg) {
|
||||
if (msg) {
|
||||
screen.sendInfoScreen(F("Please confirm."), nullptr, msg, nullptr, true, true, false, true);
|
||||
screen.setupConfirmAction(setUserConfirmed);
|
||||
#if DGUS_LCD_UI_CREALITY_TOUCH
|
||||
//SERIAL_ECHOLNPGM("User confirmation requested: ", msg);
|
||||
screen.setstatusmessagePGM(msg);
|
||||
screen.setupConfirmAction(onUserConfirmed);
|
||||
screen.sendInfoScreen(F("Confirmation required"), FPSTR(msg), FPSTR(NUL_STR), FPSTR(NUL_STR), true, true, false, true);
|
||||
#else
|
||||
screen.sendInfoScreen(F("Please confirm."), nullptr, FPSTR(msg), nullptr, true, true, false, true);
|
||||
screen.setupConfirmAction(setUserConfirmed);
|
||||
#endif
|
||||
screen.gotoScreen(DGUS_SCREEN_POPUP);
|
||||
}
|
||||
else if (screen.getCurrentScreen() == DGUS_SCREEN_POPUP) {
|
||||
screen.setupConfirmAction(nullptr);
|
||||
else if (screen.getCurrentScreen() == DGUS_SCREEN_POPUP ) {
|
||||
#if DGUS_LCD_UI_CREALITY_TOUCH
|
||||
//SERIAL_ECHOLNPGM("User confirmation canceled");
|
||||
//screen.setupConfirmAction(nullptr);
|
||||
screen.setstatusmessagePGM(nullptr);
|
||||
#else
|
||||
screen.setupConfirmAction(nullptr);
|
||||
#endif
|
||||
screen.popToOldScreen();
|
||||
}
|
||||
}
|
||||
|
@ -96,12 +144,12 @@ namespace ExtUI {
|
|||
|
||||
void onStatusChanged(const char * const msg) { screen.setStatusMessage(msg); }
|
||||
|
||||
void onHomingStart() {}
|
||||
void onHomingDone() {}
|
||||
void onHomingStart() { TERN_(DGUS_LCD_UI_CREALITY_TOUCH, screen.onHomingStart()); }
|
||||
void onHomingDone() { TERN_(DGUS_LCD_UI_CREALITY_TOUCH, screen.onHomingDone()); }
|
||||
|
||||
void onPrintDone() {}
|
||||
void onPrintDone() { TERN_(DGUS_LCD_UI_CREALITY_TOUCH, screen.onPrintDone()); }
|
||||
|
||||
void onFactoryReset() {}
|
||||
void onFactoryReset() { TERN_(DGUS_LCD_UI_CREALITY_TOUCH, screen.onFactoryReset()); }
|
||||
|
||||
void onStoreSettings(char *buff) {
|
||||
// Called when saving to EEPROM (i.e. M500). If the ExtUI needs
|
||||
|
@ -138,7 +186,7 @@ namespace ExtUI {
|
|||
}
|
||||
|
||||
#if HAS_LEVELING
|
||||
void onLevelingStart() {}
|
||||
void onLevelingStart() { TERN_(DGUS_LCD_UI_CREALITY_TOUCH, screen.onLevelingStart()); }
|
||||
void onLevelingDone() {}
|
||||
#if ENABLED(PREHEAT_BEFORE_LEVELING)
|
||||
celsius_t getLevelingBedTemp() { return LEVELING_BED_TEMP; }
|
||||
|
@ -148,10 +196,16 @@ namespace ExtUI {
|
|||
#if HAS_MESH
|
||||
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) {
|
||||
// Called when any mesh points are updated
|
||||
TERN_(DGUS_LCD_UI_CREALITY_TOUCH, screen.onLevelingUpdate(xpos, ypos));
|
||||
}
|
||||
|
||||
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const probe_state_t state) {
|
||||
// Called to indicate a special condition
|
||||
#if DGUS_LCD_UI_CREALITY_TOUCH
|
||||
// Only called for UBL
|
||||
if (state == G29_START) screen.onLevelingStart();
|
||||
screen.onLevelingUpdate(xpos, ypos);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -174,27 +228,31 @@ namespace ExtUI {
|
|||
|
||||
#if HAS_PID_HEATING
|
||||
void onPIDTuning(const pidresult_t rst) {
|
||||
// Called for temperature PID tuning result
|
||||
switch (rst) {
|
||||
case PID_STARTED:
|
||||
case PID_BED_STARTED:
|
||||
case PID_CHAMBER_STARTED:
|
||||
screen.setStatusMessage(GET_TEXT_F(MSG_PID_AUTOTUNE));
|
||||
break;
|
||||
case PID_BAD_HEATER_ID:
|
||||
screen.setStatusMessage(GET_TEXT_F(MSG_PID_BAD_HEATER_ID));
|
||||
break;
|
||||
case PID_TEMP_TOO_HIGH:
|
||||
screen.setStatusMessage(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH));
|
||||
break;
|
||||
case PID_TUNING_TIMEOUT:
|
||||
screen.setStatusMessage(GET_TEXT_F(MSG_PID_TIMEOUT));
|
||||
break;
|
||||
case PID_DONE:
|
||||
screen.setStatusMessage(GET_TEXT_F(MSG_PID_AUTOTUNE_DONE));
|
||||
break;
|
||||
}
|
||||
screen.gotoScreen(DGUS_SCREEN_MAIN);
|
||||
#if DISABLED(DGUS_LCD_UI_CREALITY_TOUCH)
|
||||
// Called for temperature PID tuning result
|
||||
switch (rst) {
|
||||
case PID_STARTED:
|
||||
case PID_BED_STARTED:
|
||||
case PID_CHAMBER_STARTED:
|
||||
screen.setStatusMessage(GET_TEXT_F(MSG_PID_AUTOTUNE));
|
||||
break;
|
||||
case PID_BAD_HEATER_ID:
|
||||
screen.setStatusMessage(GET_TEXT_F(MSG_PID_BAD_HEATER_ID));
|
||||
break;
|
||||
case PID_TEMP_TOO_HIGH:
|
||||
screen.setStatusMessage(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH));
|
||||
break;
|
||||
case PID_TUNING_TIMEOUT:
|
||||
screen.setStatusMessage(GET_TEXT_F(MSG_PID_TIMEOUT));
|
||||
break;
|
||||
case PID_DONE:
|
||||
screen.setStatusMessage(GET_TEXT_F(MSG_PID_AUTOTUNE_DONE));
|
||||
break;
|
||||
}
|
||||
screen.gotoScreen(DGUS_SCREEN_MAIN);
|
||||
#else
|
||||
UNUSED(rst);
|
||||
#endif
|
||||
}
|
||||
void onStartM303(const int count, const heater_id_t hid, const celsius_t temp) {
|
||||
// Called by M303 to update the UI
|
||||
|
@ -226,8 +284,8 @@ namespace ExtUI {
|
|||
void onFirmwareFlash() {}
|
||||
#endif
|
||||
|
||||
void onSteppersDisabled() {}
|
||||
void onSteppersEnabled() {}
|
||||
void onSteppersDisabled() { TERN_(DGUS_LCD_UI_CREALITY_TOUCH, screen.handleStepperState(false)); }
|
||||
void onSteppersEnabled() { TERN_(DGUS_LCD_UI_CREALITY_TOUCH, screen.handleStepperState(true)); }
|
||||
void onAxisDisabled(const axis_t) {}
|
||||
void onAxisEnabled(const axis_t) {}
|
||||
}
|
||||
|
|
|
@ -119,6 +119,12 @@
|
|||
// Buzz directly via the BEEPER pin tone queue
|
||||
#define BUZZ(V...) buzzer.tone(V)
|
||||
|
||||
#elif DGUS_LCD_UI_CREALITY_TOUCH
|
||||
|
||||
// Let extensible UI handle it
|
||||
namespace ExtUI { void onPlayTone(const uint16_t, const uint16_t); }
|
||||
#define BUZZ(V...) ExtUI::onPlayTone(V)
|
||||
|
||||
#elif USE_MARLINUI_BUZZER
|
||||
|
||||
// Use MarlinUI for a buzzer on the LCD
|
||||
|
@ -132,5 +138,5 @@
|
|||
#endif
|
||||
|
||||
#define ERR_BUZZ() BUZZ(400, 40)
|
||||
#define OKAY_BUZZ() do{ BUZZ(100, 659); BUZZ(10); BUZZ(100, 698); }while(0)
|
||||
#define OKAY_BUZZ() do{ BUZZ(100, 659); BUZZ(10, 0); BUZZ(100, 698); }while(0)
|
||||
#define DONE_BUZZ(ok) do{ if (ok) OKAY_BUZZ(); else ERR_BUZZ(); }while(0)
|
||||
|
|
|
@ -36,6 +36,10 @@
|
|||
|
||||
#define BOARD_NO_NATIVE_USB
|
||||
|
||||
#ifndef TEMP_TIMER_CHAN
|
||||
#define TEMP_TIMER_CHAN 4 // Timer Channel for compare, interrupts. Defined by PIO env.
|
||||
#endif
|
||||
|
||||
//
|
||||
// EEPROM
|
||||
//
|
||||
|
@ -112,3 +116,25 @@
|
|||
// Misc. Functions
|
||||
//
|
||||
#define CASE_LIGHT_PIN PA6
|
||||
|
||||
#if HAS_TMC220x
|
||||
|
||||
//
|
||||
// TMC2208 mode
|
||||
//
|
||||
//#define TMC2208_STANDALONE
|
||||
|
||||
#define X_HARDWARE_SERIAL MSerial2
|
||||
#define Y_HARDWARE_SERIAL MSerial2
|
||||
#define Z_HARDWARE_SERIAL MSerial2
|
||||
#define E0_HARDWARE_SERIAL MSerial2
|
||||
|
||||
//
|
||||
// TMC2208 Software serial
|
||||
//
|
||||
//#define HAVE_SW_SERIAL
|
||||
|
||||
// Reduce baud rate to improve software serial reliability
|
||||
//#define TMC_BAUD_RATE 19200
|
||||
|
||||
#endif
|
||||
|
|
|
@ -33,6 +33,9 @@ opt_enable DWIN_LCD_PROUI INDIVIDUAL_AXIS_HOMING_SUBMENU SET_PROGRESS_MANUALLY S
|
|||
opt_set PREHEAT_3_LABEL '"CUSTOM"' PREHEAT_3_TEMP_HOTEND 240 PREHEAT_3_TEMP_BED 60 PREHEAT_3_FAN_SPEED 128 BOOTSCREEN_TIMEOUT 1100 CASE_LIGHT_PIN 4
|
||||
exec_test $1 $2 "Ender-3 S1 - ProUI (PIDTEMP)" "$3"
|
||||
|
||||
use_example_configs "Creality/CR-6 SE"
|
||||
exec_test $1 $2 "Creality CR-6 SE"
|
||||
|
||||
restore_configs
|
||||
opt_set MOTHERBOARD BOARD_CREALITY_V452 SERIAL_PORT 1
|
||||
opt_disable NOZZLE_TO_PROBE_OFFSET
|
||||
|
|
|
@ -201,6 +201,7 @@ DGUS_LCD_UI_HIPRECY = build_src_filter=+<src/lcd/extui/dgus/h
|
|||
DGUS_LCD_UI_MKS = build_src_filter=+<src/lcd/extui/dgus/mks>
|
||||
DGUS_LCD_UI_ORIGIN = build_src_filter=+<src/lcd/extui/dgus/origin>
|
||||
DGUS_LCD_UI_IA_CREALITY = build_src_filter=+<src/lcd/extui/ia_creality>
|
||||
DGUS_LCD_UI_CREALITY_TOUCH = build_src_filter=+<src/lcd/extui/dgus/creality>
|
||||
EXTUI_EXAMPLE = build_src_filter=+<src/lcd/extui/example>
|
||||
TOUCH_UI_FTDI_EVE = build_src_filter=+<src/lcd/extui/ftdi_eve_touch_ui>
|
||||
MALYAN_LCD = build_src_filter=+<src/lcd/extui/malyan>
|
||||
|
|
Loading…
Reference in a new issue