From 509dfe92d0c2227ddece025fb97875582ca47aed Mon Sep 17 00:00:00 2001 From: Meilleur Gars <98503100+LCh-77@users.noreply.github.com> Date: Wed, 6 Jul 2022 13:46:11 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20JyersUI=20updates=20(#24451)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/bedlevel/abl/G29.cpp | 2 + Marlin/src/gcode/config/M575.cpp | 9 +- Marlin/src/gcode/control/M997.cpp | 3 + Marlin/src/gcode/lcd/M0_M1.cpp | 4 + Marlin/src/gcode/probe/G30.cpp | 10 +- Marlin/src/gcode/stats/M75-M78.cpp | 16 +- Marlin/src/gcode/temp/M303.cpp | 3 + Marlin/src/inc/Conditionals_LCD.h | 9 +- Marlin/src/inc/Conditionals_post.h | 2 +- Marlin/src/inc/SanityCheck.h | 2 +- Marlin/src/lcd/e3v2/common/dwin_api.cpp | 10 +- Marlin/src/lcd/e3v2/jyersui/base64.hpp | 208 ++ Marlin/src/lcd/e3v2/jyersui/dwin.cpp | 3090 ++++++++++++----- Marlin/src/lcd/e3v2/jyersui/dwin.h | 230 +- Marlin/src/lcd/e3v2/jyersui/dwin_defines.h | 131 + Marlin/src/lcd/e3v2/jyersui/dwin_lcd.cpp | 33 +- Marlin/src/lcd/e3v2/jyersui/dwin_lcd.h | 8 + Marlin/src/lcd/e3v2/jyersui/dwinui.cpp | 340 ++ Marlin/src/lcd/e3v2/jyersui/dwinui.h | 527 +++ Marlin/src/lcd/e3v2/jyersui/endstop_diag.cpp | 111 + Marlin/src/lcd/e3v2/jyersui/endstop_diag.h | 39 + Marlin/src/lcd/e3v2/jyersui/gcode_preview.cpp | 244 ++ Marlin/src/lcd/e3v2/jyersui/gcode_preview.h | 34 + Marlin/src/lcd/e3v2/jyersui/lockscreen.cpp | 83 + Marlin/src/lcd/e3v2/jyersui/lockscreen.h | 49 + Marlin/src/lcd/e3v2/jyersui/plot.cpp | 86 + Marlin/src/lcd/e3v2/jyersui/plot.h | 41 + Marlin/src/lcd/e3v2/proui/base64.hpp | 6 +- Marlin/src/lcd/e3v2/proui/gcode_preview.cpp | 6 +- Marlin/src/lcd/e3v2/proui/gcode_preview.h | 2 +- Marlin/src/module/settings.cpp | 6 +- Marlin/src/module/temperature.cpp | 8 + 32 files changed, 4352 insertions(+), 1000 deletions(-) create mode 100644 Marlin/src/lcd/e3v2/jyersui/base64.hpp create mode 100644 Marlin/src/lcd/e3v2/jyersui/dwin_defines.h create mode 100644 Marlin/src/lcd/e3v2/jyersui/dwinui.cpp create mode 100644 Marlin/src/lcd/e3v2/jyersui/dwinui.h create mode 100644 Marlin/src/lcd/e3v2/jyersui/endstop_diag.cpp create mode 100644 Marlin/src/lcd/e3v2/jyersui/endstop_diag.h create mode 100644 Marlin/src/lcd/e3v2/jyersui/gcode_preview.cpp create mode 100644 Marlin/src/lcd/e3v2/jyersui/gcode_preview.h create mode 100644 Marlin/src/lcd/e3v2/jyersui/lockscreen.cpp create mode 100644 Marlin/src/lcd/e3v2/jyersui/lockscreen.h create mode 100644 Marlin/src/lcd/e3v2/jyersui/plot.cpp create mode 100644 Marlin/src/lcd/e3v2/jyersui/plot.h diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index a2c53b5ab253..e8c9c4a1857c 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -51,6 +51,8 @@ #include "../../../lcd/e3v2/creality/dwin.h" #elif ENABLED(DWIN_LCD_PROUI) #include "../../../lcd/e3v2/proui/dwin.h" +#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) + #include "../../../lcd/e3v2/jyersui/dwin.h" #endif #if HAS_MULTI_HOTEND diff --git a/Marlin/src/gcode/config/M575.cpp b/Marlin/src/gcode/config/M575.cpp index 2c12428d982a..f96bca8a3ee3 100644 --- a/Marlin/src/gcode/config/M575.cpp +++ b/Marlin/src/gcode/config/M575.cpp @@ -26,6 +26,10 @@ #include "../gcode.h" +#if ENABLED(DWIN_CREALITY_LCD_JYERSUI) + #include "../../lcd/e3v2/jyersui/dwin.h" +#endif + /** * M575 - Change serial baud rate * @@ -65,7 +69,10 @@ void GcodeSuite::M575() { SERIAL_FLUSH(); - if (set1) { MYSERIAL1.end(); MYSERIAL1.begin(baud); } + if (set1) { + MYSERIAL1.end(); MYSERIAL1.begin(baud); + TERN_(DWIN_CREALITY_LCD_JYERSUI, eeprom_settings.Baud115k = (baud == 115200)); + } #if HAS_MULTI_SERIAL if (set2) { MYSERIAL2.end(); MYSERIAL2.begin(baud); } #ifdef SERIAL_PORT_3 diff --git a/Marlin/src/gcode/control/M997.cpp b/Marlin/src/gcode/control/M997.cpp index 74ed8b0d073e..66a0256c44ef 100644 --- a/Marlin/src/gcode/control/M997.cpp +++ b/Marlin/src/gcode/control/M997.cpp @@ -26,6 +26,8 @@ #if ENABLED(DWIN_LCD_PROUI) #include "../../lcd/e3v2/proui/dwin.h" +#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) + #include "../../lcd/e3v2/jyersui/dwin.h" #endif /** @@ -34,6 +36,7 @@ void GcodeSuite::M997() { TERN_(DWIN_LCD_PROUI, DWIN_RebootScreen()); + TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWIN.DWIN_RebootScreen()); flashFirmware(parser.intval('S')); diff --git a/Marlin/src/gcode/lcd/M0_M1.cpp b/Marlin/src/gcode/lcd/M0_M1.cpp index af03fcb0b1a1..b6d2131555c6 100644 --- a/Marlin/src/gcode/lcd/M0_M1.cpp +++ b/Marlin/src/gcode/lcd/M0_M1.cpp @@ -38,6 +38,8 @@ #elif ENABLED(DWIN_LCD_PROUI) #include "../../lcd/e3v2/proui/dwin_popup.h" #include "../../lcd/e3v2/proui/dwin.h" +#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) + #include "../../lcd/e3v2/jyersui/dwin.h" #endif #if ENABLED(HOST_PROMPT_SUPPORT) @@ -76,6 +78,8 @@ void GcodeSuite::M0_M1() { DWIN_Popup_Confirm(ICON_BLTouch, parser.string_arg, GET_TEXT_F(MSG_USERWAIT)); else DWIN_Popup_Confirm(ICON_BLTouch, GET_TEXT_F(MSG_STOPPED), GET_TEXT_F(MSG_USERWAIT)); + #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) + CrealityDWIN.Confirm_Handler(UserInput, parser.string_arg == nullptr); #else if (parser.string_arg) { diff --git a/Marlin/src/gcode/probe/G30.cpp b/Marlin/src/gcode/probe/G30.cpp index a16853bdf894..b22ec6eb7f7f 100644 --- a/Marlin/src/gcode/probe/G30.cpp +++ b/Marlin/src/gcode/probe/G30.cpp @@ -33,7 +33,7 @@ #include "../../feature/probe_temp_comp.h" #endif -#if ENABLED(DWIN_LCD_PROUI) +#if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) #include "../../lcd/marlinui.h" #endif @@ -53,7 +53,7 @@ void GcodeSuite::G30() { parser.linearval('Y', current_position.y + probe.offset_xy.y) }; if (!probe.can_reach(pos)) { - #if ENABLED(DWIN_LCD_PROUI) + #if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) SERIAL_ECHOLNF(GET_EN_TEXT_F(MSG_ZPROBE_OUT)); LCD_MESSAGE(MSG_ZPROBE_OUT); #endif @@ -65,7 +65,9 @@ void GcodeSuite::G30() { remember_feedrate_scaling_off(); - TERN_(DWIN_LCD_PROUI, process_subcommands_now(F("G28O"))); + #if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) + process_subcommands_now(F("G28O")); + #endif const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE; @@ -74,7 +76,7 @@ void GcodeSuite::G30() { TERN_(HAS_PTC, ptc.set_enabled(true)); if (!isnan(measured_z)) { SERIAL_ECHOLNPGM("Bed X: ", pos.x, " Y: ", pos.y, " Z: ", measured_z); - #if ENABLED(DWIN_LCD_PROUI) + #if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) char msg[31], str_1[6], str_2[6], str_3[6]; sprintf_P(msg, PSTR("X:%s, Y:%s, Z:%s"), dtostrf(pos.x, 1, 1, str_1), diff --git a/Marlin/src/gcode/stats/M75-M78.cpp b/Marlin/src/gcode/stats/M75-M78.cpp index 0ed1e6693013..13a593bc30f1 100644 --- a/Marlin/src/gcode/stats/M75-M78.cpp +++ b/Marlin/src/gcode/stats/M75-M78.cpp @@ -33,15 +33,23 @@ #include "../../lcd/e3v2/proui/dwin.h" #endif +#if ENABLED(DWIN_CREALITY_LCD_JYERSUI) + #include "../../lcd/e3v2/jyersui/dwin.h" +#endif + /** * M75: Start print timer */ void GcodeSuite::M75() { startOrResumeJob(); - #if ENABLED(DWIN_LCD_PROUI) - DWIN_Print_Started(false); - if (!IS_SD_PRINTING()) DWIN_Print_Header(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT)); - #endif + TERN_(DWIN_LCD_PROUI, DWIN_Print_Started(false)); + if (!IS_SD_PRINTING()) { + #if ENABLED(DWIN_LCD_PROUI) + DWIN_Print_Header(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT)); + #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) + CrealityDWIN.Update_Print_Filename(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT)); + #endif + } } /** diff --git a/Marlin/src/gcode/temp/M303.cpp b/Marlin/src/gcode/temp/M303.cpp index ce362984a6ca..2bd05f75373c 100644 --- a/Marlin/src/gcode/temp/M303.cpp +++ b/Marlin/src/gcode/temp/M303.cpp @@ -32,6 +32,8 @@ #include "../../lcd/extui/ui_api.h" #elif ENABLED(DWIN_LCD_PROUI) #include "../../lcd/e3v2/proui/dwin.h" +#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) + #include "../../lcd/e3v2/jyersui/dwin.h" #endif /** @@ -75,6 +77,7 @@ void GcodeSuite::M303() { SERIAL_ECHOLNPGM(STR_PID_BAD_HEATER_ID); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_BAD_EXTRUDER_NUM)); TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_BAD_EXTRUDER_NUM)); + TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_BAD_EXTRUDER_NUM)); return; } diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 8d29b177dd56..bf8d5e122a5e 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -1256,6 +1256,8 @@ #endif #if ANY(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_3POINT) #define HAS_ABL_NOT_UBL 1 +#else + #undef PROBE_MANUALLY #endif #if ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL, MESH_BED_LEVELING) #define HAS_MESH 1 @@ -1274,14 +1276,11 @@ #if DISABLED(AUTO_BED_LEVELING_UBL) #define PLANNER_LEVELING 1 #endif -#endif -#if !HAS_LEVELING +#else #undef RESTORE_LEVELING_AFTER_G28 #undef ENABLE_LEVELING_AFTER_G28 #undef G29_RETRY_AND_RECOVER -#endif -#if !HAS_LEVELING || EITHER(MESH_BED_LEVELING, AUTO_BED_LEVELING_UBL) - #undef PROBE_MANUALLY + #undef PREHEAT_BEFORE_LEVELING #endif #if ANY(HAS_BED_PROBE, PROBE_MANUALLY, MESH_BED_LEVELING) #define PROBE_SELECTED 1 diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 9edcd6f1aa9a..0f4cf1381a7f 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -3541,7 +3541,7 @@ #ifndef MESH_MAX_Y #define MESH_MAX_Y _MESH_MAX_Y #endif -#else +#elif DISABLED(DWIN_CREALITY_LCD_JYERSUI) #undef MESH_MIN_X #undef MESH_MIN_Y #undef MESH_MAX_X diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index a967f0109457..8ef8a3d2d64a 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -3671,7 +3671,7 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #error "A very large BLOCK_BUFFER_SIZE is not needed and takes longer to drain the buffer on pause / cancel." #endif -#if ENABLED(LED_CONTROL_MENU) && NONE(HAS_MARLINUI_MENU, DWIN_LCD_PROUI) +#if ENABLED(LED_CONTROL_MENU) && NONE(HAS_MARLINUI_MENU, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) #error "LED_CONTROL_MENU requires an LCD controller that implements the menu." #endif diff --git a/Marlin/src/lcd/e3v2/common/dwin_api.cpp b/Marlin/src/lcd/e3v2/common/dwin_api.cpp index 3f699465a9c8..79998219a95e 100644 --- a/Marlin/src/lcd/e3v2/common/dwin_api.cpp +++ b/Marlin/src/lcd/e3v2/common/dwin_api.cpp @@ -234,7 +234,7 @@ void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis, // *string: The string // rlimit: To limit the drawn string length void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * const string, uint16_t rlimit/*=0xFFFF*/) { - #if DISABLED(DWIN_LCD_PROUI) + #if NONE(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) DWIN_Draw_Rectangle(1, bColor, x, y, x + (fontWidth(size) * strlen_P(string)), y + fontHeight(size)); #endif constexpr uint8_t widthAdjust = 0; @@ -266,7 +266,9 @@ void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint32_t value) { size_t i = 0; - DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * iNum + 1, y + fontHeight(size)); + #if DISABLED(DWIN_CREALITY_LCD_JYERSUI) + DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * iNum + 1, y + fontHeight(size)); + #endif DWIN_Byte(i, 0x14); // Bit 7: bshow // Bit 6: 1 = signed; 0 = unsigned number; @@ -314,7 +316,9 @@ void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_ uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, int32_t value) { //uint8_t *fvalue = (uint8_t*)&value; size_t i = 0; - DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * (iNum+fNum+1), y + fontHeight(size)); + #if DISABLED(DWIN_CREALITY_LCD_JYERSUI) + DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * (iNum+fNum+1), y + fontHeight(size)); + #endif DWIN_Byte(i, 0x14); DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size); DWIN_Word(i, color); diff --git a/Marlin/src/lcd/e3v2/jyersui/base64.hpp b/Marlin/src/lcd/e3v2/jyersui/base64.hpp new file mode 100644 index 000000000000..7a933df321b8 --- /dev/null +++ b/Marlin/src/lcd/e3v2/jyersui/base64.hpp @@ -0,0 +1,208 @@ +/** + * Base64 encoder/decoder for arduino repo + * Uses common web conventions - '+' for 62, '/' for 63, '=' for padding. + * Note that invalid base64 characters are interpreted as padding. + * Author: Densaugeo + * Maintainer: Densaugeo + * Version: 1.2.1.1 + * Changed unsigned int to uint16_t for use in the professional Ender 3V2/S1 firmware + * Url: https://www.arduino.cc/reference/en/libraries/base64/ + */ + +#ifndef BASE64_H_INCLUDED +#define BASE64_H_INCLUDED + +/* binary_to_base64: + * Description: + * Converts a single byte from a binary value to the corresponding base64 character + * Parameters: + * v - Byte to convert + * Returns: + * ascii code of base64 character. If byte is >= 64, then there is not corresponding base64 character + * and 255 is returned + */ +unsigned char binary_to_base64(unsigned char v); + +/* base64_to_binary: + * Description: + * Converts a single byte from a base64 character to the corresponding binary value + * Parameters: + * c - Base64 character (as ascii code) + * Returns: + * 6-bit binary value + */ +unsigned char base64_to_binary(unsigned char c); + +/* encode_base64_length: + * Description: + * Calculates length of base64 string needed for a given number of binary bytes + * Parameters: + * input_length - Amount of binary data in bytes + * Returns: + * Number of base64 characters needed to encode input_length bytes of binary data + */ +uint16_t encode_base64_length(uint16_t input_length); + +/* decode_base64_length: + * Description: + * Calculates number of bytes of binary data in a base64 string + * Variant that does not use input_length no longer used within library, retained for API compatibility + * Parameters: + * input - Base64-encoded null-terminated string + * input_length (optional) - Number of bytes to read from input pointer + * Returns: + * Number of bytes of binary data in input + */ +uint16_t decode_base64_length(unsigned char input[]); +uint16_t decode_base64_length(unsigned char input[], uint16_t input_length); + +/* encode_base64: + * Description: + * Converts an array of bytes to a base64 null-terminated string + * Parameters: + * input - Pointer to input data + * input_length - Number of bytes to read from input pointer + * output - Pointer to output string. Null terminator will be added automatically + * Returns: + * Length of encoded string in bytes (not including null terminator) + */ +uint16_t encode_base64(unsigned char input[], uint16_t input_length, unsigned char output[]); + +/* decode_base64: + * Description: + * Converts a base64 null-terminated string to an array of bytes + * Parameters: + * input - Pointer to input string + * input_length (optional) - Number of bytes to read from input pointer + * output - Pointer to output array + * Returns: + * Number of bytes in the decoded binary + */ +uint16_t decode_base64(unsigned char input[], unsigned char output[]); +uint16_t decode_base64(unsigned char input[], uint16_t input_length, unsigned char output[]); + +unsigned char binary_to_base64(unsigned char v) { + // Capital letters - 'A' is ascii 65 and base64 0 + if (v < 26) return v + 'A'; + + // Lowercase letters - 'a' is ascii 97 and base64 26 + if (v < 52) return v + 71; + + // Digits - '0' is ascii 48 and base64 52 + if (v < 62) return v - 4; + + // '+' is ascii 43 and base64 62 + if (v == 62) return '+'; + + // '/' is ascii 47 and base64 63 + if (v == 63) return '/'; + + return 64; +} + +unsigned char base64_to_binary(unsigned char c) { + // Capital letters - 'A' is ascii 65 and base64 0 + if ('A' <= c && c <= 'Z') return c - 'A'; + + // Lowercase letters - 'a' is ascii 97 and base64 26 + if ('a' <= c && c <= 'z') return c - 71; + + // Digits - '0' is ascii 48 and base64 52 + if ('0' <= c && c <= '9') return c + 4; + + // '+' is ascii 43 and base64 62 + if (c == '+') return 62; + + // '/' is ascii 47 and base64 63 + if (c == '/') return 63; + + return 255; +} + +uint16_t encode_base64_length(uint16_t input_length) { + return (input_length + 2)/3*4; +} + +uint16_t decode_base64_length(unsigned char input[]) { + return decode_base64_length(input, -1); +} + +uint16_t decode_base64_length(unsigned char input[], uint16_t input_length) { + unsigned char *start = input; + + while (base64_to_binary(input[0]) < 64 && (unsigned char)(input - start) < input_length) { + ++input; + } + + input_length = input - start; + return input_length/4*3 + (input_length % 4 ? input_length % 4 - 1 : 0); +} + +uint16_t encode_base64(unsigned char input[], uint16_t input_length, unsigned char output[]) { + uint16_t full_sets = input_length/3; + + // While there are still full sets of 24 bits... + for (uint16_t i = 0; i < full_sets; ++i) { + output[0] = binary_to_base64( input[0] >> 2); + output[1] = binary_to_base64((input[0] & 0x03) << 4 | input[1] >> 4); + output[2] = binary_to_base64((input[1] & 0x0F) << 2 | input[2] >> 6); + output[3] = binary_to_base64( input[2] & 0x3F); + + input += 3; + output += 4; + } + + switch (input_length % 3) { + case 0: + output[0] = '\0'; + break; + case 1: + output[0] = binary_to_base64( input[0] >> 2); + output[1] = binary_to_base64((input[0] & 0x03) << 4); + output[2] = '='; + output[3] = '='; + output[4] = '\0'; + break; + case 2: + output[0] = binary_to_base64( input[0] >> 2); + output[1] = binary_to_base64((input[0] & 0x03) << 4 | input[1] >> 4); + output[2] = binary_to_base64((input[1] & 0x0F) << 2); + output[3] = '='; + output[4] = '\0'; + break; + } + + return encode_base64_length(input_length); +} + +uint16_t decode_base64(unsigned char input[], unsigned char output[]) { + return decode_base64(input, -1, output); +} + +uint16_t decode_base64(unsigned char input[], uint16_t input_length, unsigned char output[]) { + uint16_t output_length = decode_base64_length(input, input_length); + + // While there are still full sets of 24 bits... + for (uint16_t i = 2; i < output_length; i += 3) { + output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4; + output[1] = base64_to_binary(input[1]) << 4 | base64_to_binary(input[2]) >> 2; + output[2] = base64_to_binary(input[2]) << 6 | base64_to_binary(input[3]); + + input += 4; + output += 3; + } + + switch (output_length % 3) { + case 1: + output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4; + break; + case 2: + output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4; + output[1] = base64_to_binary(input[1]) << 4 | base64_to_binary(input[2]) >> 2; + break; + } + + return output_length; +} + +#endif // BASE64_H_INCLUDED diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index 285013d7504e..e62bb04a43a2 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -22,23 +22,30 @@ /** * lcd/e3v2/jyersui/dwin.cpp + * JYERSUI Author: Jacob Myers + * + * JYERSUI Enhanced by LCH-77 + * Version: 1.9 + * Date: Jun 16, 2022 */ #include "../../../inc/MarlinConfigPre.h" #if ENABLED(DWIN_CREALITY_LCD_JYERSUI) +#include "dwin_defines.h" #include "dwin.h" +#include "dwinui.h" #include "../../marlinui.h" #include "../../../MarlinCore.h" - #include "../../../gcode/gcode.h" #include "../../../module/temperature.h" #include "../../../module/planner.h" #include "../../../module/settings.h" #include "../../../libs/buzzer.h" #include "../../../inc/Conditionals_post.h" +#include "../common/encoder.h" //#define DEBUG_OUT 1 #include "../../../core/debug_out.h" @@ -67,6 +74,10 @@ #include "../../../feature/bedlevel/bedlevel.h" #endif +#ifdef BLTOUCH_HS_MODE + #include "../../../feature/bltouch.h" +#endif + #if ENABLED(AUTO_BED_LEVELING_UBL) #include "../../../libs/least_squares_fit.h" #include "../../../libs/vector_3.h" @@ -80,21 +91,40 @@ #include "../../../feature/powerloss.h" #endif -#define MACHINE_SIZE STRINGIFY(X_BED_SIZE) "x" STRINGIFY(Y_BED_SIZE) "x" STRINGIFY(Z_MAX_POS) +#if HAS_ESDIAG + #include "endstop_diag.h" +#endif + +#if HAS_LOCKSCREEN + #include "lockscreen.h" +#endif -#define DWIN_FONT_MENU font8x16 -#define DWIN_FONT_STAT font10x20 -#define DWIN_FONT_HEAD font10x20 +#if ENABLED(CASE_LIGHT_MENU) + #include "../../../feature/caselight.h" +#endif + +#if ENABLED(LED_CONTROL_MENU) + #include "../../../feature/leds/leds.h" +#endif + +#if HAS_PIDPLOT + #include "plot.h" +#endif +#if HAS_GCODE_PREVIEW + #include "gcode_preview.h" +#endif + +#define MACHINE_SIZE STRINGIFY(X_BED_SIZE) "x" STRINGIFY(Y_BED_SIZE) "x" STRINGIFY(Z_MAX_POS) -#define MENU_CHAR_LIMIT 24 -#define STATUS_Y 352 +#define MENU_CHAR_LIMIT 24 +#define STATUS_CHAR_LIMIT 30 -#define MAX_PRINT_SPEED 500 -#define MIN_PRINT_SPEED 10 +#define MAX_PRINT_SPEED 500 +#define MIN_PRINT_SPEED 10 #if HAS_FAN - #define MAX_FAN_SPEED 255 - #define MIN_FAN_SPEED 0 + #define MAX_FAN_SPEED 255 + #define MIN_FAN_SPEED 0 #endif #define MAX_XY_OFFSET 100 @@ -109,16 +139,21 @@ #endif #if HAS_HOTEND - #define MAX_FLOW_RATE 200 - #define MIN_FLOW_RATE 10 + #define MAX_FLOW_RATE 200 + #define MIN_FLOW_RATE 10 - #define MAX_E_TEMP (HEATER_0_MAXTEMP - HOTEND_OVERSHOOT) - #define MIN_E_TEMP 0 + #define MAX_E_TEMP (HEATER_0_MAXTEMP - HOTEND_OVERSHOOT) + #define MIN_E_TEMP 0 #endif #if HAS_HEATED_BED - #define MAX_BED_TEMP BED_MAXTEMP - #define MIN_BED_TEMP 0 + #define MAX_BED_TEMP BED_MAXTEMP + #define MIN_BED_TEMP 0 +#endif + +#if HAS_JUNCTION_DEVIATION + #define MIN_JD_MM 0.01 + #define MAX_JD_MM 0.3 #endif /** @@ -141,19 +176,11 @@ #endif #endif -constexpr uint16_t TROWS = 6, MROWS = TROWS - 1, - TITLE_HEIGHT = 30, - MLINE = 53, - LBLX = 60, - MENU_CHR_W = 8, MENU_CHR_H = 16, STAT_CHR_W = 10; - -#define MBASE(L) (49 + MLINE * (L)) - -constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE; -constexpr float default_max_acceleration[] = DEFAULT_MAX_ACCELERATION; -constexpr float default_steps[] = DEFAULT_AXIS_STEPS_PER_UNIT; +constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE; +constexpr float default_max_acceleration[] = DEFAULT_MAX_ACCELERATION; +constexpr float default_steps[] = DEFAULT_AXIS_STEPS_PER_UNIT; #if HAS_CLASSIC_JERK - constexpr float default_max_jerk[] = { DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK, DEFAULT_EJERK }; + constexpr float default_max_jerk[] = { DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK, DEFAULT_EJERK }; #endif enum SelectItem : uint8_t { @@ -169,8 +196,10 @@ enum SelectItem : uint8_t { PRINT_COUNT }; +eeprom_settings_t eeprom_settings = {0}; +temp_val_t temp_val = {0}; uint8_t active_menu = MainMenu, last_menu = MainMenu; -uint8_t selection = 0, last_selection = 0; +uint8_t selection = 0, last_selection = 0, last_pos_selection = 0; uint8_t scrollpos = 0; uint8_t process = Main, last_process = Main; PopupID popup, last_popup; @@ -183,24 +212,22 @@ float valuemax; uint8_t valueunit; uint8_t valuetype; -char cmd[MAX_CMD_SIZE+16], str_1[16], str_2[16], str_3[16]; +char cmd[MAX_CMD_SIZE + 16], str_1[16], str_2[16], str_3[16]; char statusmsg[64]; char filename[LONG_FILENAME_LENGTH]; -bool printing = false; -bool paused = false; -bool sdprint = false; -int16_t pausetemp, pausebed, pausefan; - -bool livemove = false; -bool liveadjust = false; -uint8_t preheatmode = 0; -float zoffsetvalue = 0; -uint8_t gridpoint; -float corner_avg; -float corner_pos; - -bool probe_deployed = false; +#if HAS_HOSTACTION_MENUS + #define KEY_WIDTH 26 + #define KEY_HEIGHT 30 + #define KEY_INSET 5 + #define KEY_PADDING 3 + #define KEY_Y_START DWIN_HEIGHT - (4 * (KEY_HEIGHT) + 2 * (KEY_INSET + 1)) + + bool keyboard_restrict, reset_keyboard, numeric_keyboard = false; + uint8_t maxstringlen; + char *stringpointer = nullptr; + char action1[9], action2[9], action3[9]; +#endif CrealityDWINClass CrealityDWIN; @@ -215,6 +242,7 @@ CrealityDWINClass CrealityDWIN; uint8_t mesh_y = 0; #if ENABLED(AUTO_BED_LEVELING_UBL) + uint8_t tilt_grid = 1; void manual_value_update(bool undefined=false) { @@ -330,13 +358,13 @@ CrealityDWINClass CrealityDWIN; const float v_max = abs(get_max_value()), v_min = abs(get_min_value()), range = _MAX(v_min, v_max); // Clear background from previous selection and select new square - DWIN_Draw_Rectangle(1, Color_Bg_Black, _MAX(0, padding_x - gridline_width), _MAX(0, padding_y_top - gridline_width), padding_x + total_width_px, padding_y_top + total_width_px); + DWIN_Draw_Rectangle(1, Def_Background_Color, _MAX(0, padding_x - gridline_width), _MAX(0, padding_y_top - gridline_width), padding_x + total_width_px, padding_y_top + total_width_px); if (selected >= 0) { const auto selected_y = selected / (GRID_MAX_POINTS_X); const auto selected_x = selected - (GRID_MAX_POINTS_X) * selected_y; const auto start_y_px = padding_y_top + selected_y * cell_height_px; const auto start_x_px = padding_x + selected_x * cell_width_px; - DWIN_Draw_Rectangle(1, Color_White, _MAX(0, start_x_px - gridline_width), _MAX(0, start_y_px - gridline_width), start_x_px + cell_width_px, start_y_px + cell_height_px); + DWIN_Draw_Rectangle(1, Def_Highlight_Color, _MAX(0, start_x_px - gridline_width), _MAX(0, start_y_px - gridline_width), start_x_px + cell_width_px, start_y_px + cell_height_px); } // Draw value square grid @@ -362,7 +390,7 @@ CrealityDWINClass CrealityDWIN; if (viewer_print_value) { int8_t offset_x, offset_y = cell_height_px / 2 - 6; if (isnan(bedlevel.z_values[x][y])) { // undefined - DWIN_Draw_String(false, font6x12, Color_White, Color_Bg_Blue, start_x_px + cell_width_px / 2 - 5, start_y_px + offset_y, F("X")); + DWINUI::Draw_String(font6x12, Def_Text_Color, Color_Bg_Blue, start_x_px + cell_width_px / 2 - 5, start_y_px + offset_y, F("X")); } else { // has value if (GRID_MAX_POINTS_X < 10) @@ -371,8 +399,8 @@ CrealityDWINClass CrealityDWIN; sprintf_P(buf, PSTR("%02i"), (uint16_t)(abs(bedlevel.z_values[x][y] - (int16_t)bedlevel.z_values[x][y]) * 100)); offset_x = cell_width_px / 2 - 3 * (strlen(buf)) - 2; if (!(GRID_MAX_POINTS_X < 10)) - DWIN_Draw_String(false, font6x12, Color_White, Color_Bg_Blue, start_x_px - 2 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, F(".")); - DWIN_Draw_String(false, font6x12, Color_White, Color_Bg_Blue, start_x_px + 1 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, buf); + DWINUI::Draw_String(font6x12, Def_Text_Color, Color_Bg_Blue, start_x_px - 2 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, F(".")); + DWINUI::Draw_String(font6x12, Def_Text_Color, Color_Bg_Blue, start_x_px + 1 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, buf); } safe_delay(10); LCD_SERIAL.flushTX(); @@ -405,10 +433,12 @@ CrealityDWINClass CrealityDWIN; #endif // HAS_MESH /* General Display Functions */ - -struct CrealityDWINClass::EEPROM_Settings CrealityDWINClass::eeprom_settings{0}; constexpr const char * const CrealityDWINClass::color_names[11]; constexpr const char * const CrealityDWINClass::preheat_modes[3]; +constexpr const char * const CrealityDWINClass::zoffset_modes[3]; +#if ENABLED(PREHEAT_BEFORE_LEVELING) + constexpr const char * const CrealityDWINClass::preheat_levmodes[4]; +#endif // Clear a part of the screen // 4=Entire screen @@ -416,98 +446,119 @@ constexpr const char * const CrealityDWINClass::preheat_modes[3]; // 2=Menu area // 1=Title bar void CrealityDWINClass::Clear_Screen(uint8_t e/*=3*/) { - if (e == 1 || e == 3 || e == 4) DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.menu_top_bg, Color_Bg_Blue, false), 0, 0, DWIN_WIDTH, TITLE_HEIGHT); // Clear Title Bar - if (e == 2 || e == 3) DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, 31, DWIN_WIDTH, STATUS_Y); // Clear Menu Area - if (e == 4) DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, 31, DWIN_WIDTH, DWIN_HEIGHT); // Clear Popup Area + if (e == 1 || e == 3 || e == 4) DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.menu_top_bg, Def_TitleBg_color, false), 0, 0, DWIN_WIDTH, TITLE_HEIGHT); // Clear Title Bar + if (e == 2 || e == 3) DWIN_Draw_Rectangle(1, Def_Background_Color, 0, 31, DWIN_WIDTH, STATUS_Y); // Clear Menu Area + if (e == 4) DWIN_Draw_Rectangle(1, Def_Background_Color, 0, 31, DWIN_WIDTH, DWIN_HEIGHT); // Clear Popup Area } void CrealityDWINClass::Draw_Float(float value, uint8_t row, bool selected/*=false*/, uint8_t minunit/*=10*/) { const uint8_t digits = (uint8_t)floor(log10(abs(value))) + log10(minunit) + (minunit > 1); - const uint16_t bColor = (selected) ? Select_Color : Color_Bg_Black; + const uint16_t bColor = (selected) ? Def_Selected_Color : Def_Background_Color; const uint16_t xpos = 240 - (digits * 8); - DWIN_Draw_Rectangle(1, Color_Bg_Black, 194, MBASE(row), 234 - (digits * 8), MBASE(row) + 16); + DWIN_Draw_Rectangle(1, Def_Background_Color, 194, MBASE(row), 234 - (digits * 8), MBASE(row) + 16); if (isnan(value)) - DWIN_Draw_String(true, DWIN_FONT_MENU, Color_White, bColor, xpos - 8, MBASE(row), F(" NaN")); + DWINUI::Draw_String(Def_Text_Color, bColor, xpos - 8, MBASE(row), F(" NaN")); else { - DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, Color_White, bColor, digits - log10(minunit) + 1, log10(minunit), xpos, MBASE(row), (value < 0 ? -value : value)); - DWIN_Draw_String(true, DWIN_FONT_MENU, Color_White, bColor, xpos - 8, MBASE(row), value < 0 ? F("-") : F(" ")); + DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, Def_Text_Color, bColor, digits - log10(minunit) + 1, log10(minunit), xpos, MBASE(row), (value < 0 ? -value : value)); + DWINUI::Draw_String(Def_Text_Color, bColor, xpos - 8, MBASE(row), value < 0 ? F("-") : F(" ")); } } void CrealityDWINClass::Draw_Option(uint8_t value, const char * const * options, uint8_t row, bool selected/*=false*/, bool color/*=false*/) { - uint16_t bColor = (selected) ? Select_Color : Color_Bg_Black, - tColor = (color) ? GetColor(value, Color_White, false) : Color_White; + uint16_t bColor = (selected) ? Def_Selected_Color : Def_Background_Color, + tColor = (color) ? GetColor(value, Def_Text_Color, false) : Def_Text_Color; DWIN_Draw_Rectangle(1, bColor, 202, MBASE(row) + 14, 258, MBASE(row) - 2); - DWIN_Draw_String(false, DWIN_FONT_MENU, tColor, bColor, 202, MBASE(row) - 1, options[value]); + DWINUI::Draw_String(tColor, bColor, 202, MBASE(row) - 1, options[value]); } +#if HAS_HOSTACTION_MENUS + + void CrealityDWINClass::Draw_String(char * string, uint8_t row, bool selected/*=false*/, bool below/*=false*/) { + if (!string) string[0] = '\0'; + const uint8_t offset_x = DWIN_WIDTH - strlen(string) * 8 - 20; + const uint8_t offset_y = (below) ? MENU_CHR_H * 3 / 5 : 0; + DWIN_Draw_Rectangle(1, Def_Background_Color, offset_x - 10, MBASE(row) + offset_y - 1, offset_x, MBASE(row) + 16 + offset_y); + DWINUI::Draw_String(Def_Text_Color, (selected) ? Def_Selected_Color : Def_Background_Color, offset_x, MBASE(row) - 1 + offset_y, string); + } + + const uint64_t CrealityDWINClass::Encode_String(const char * string) { + const char table[65] = "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"; + uint64_t output = 0; + LOOP_L_N(i, strlen(string)) { + uint8_t upper_bound = 63, lower_bound = 0; + uint8_t midpoint; + LOOP_L_N(x, 6) { + midpoint = (uint8_t)(0.5 * (upper_bound + lower_bound)); + if (string[i] == table[midpoint]) break; + if (string[i] > table[midpoint]) + lower_bound = midpoint; + else + upper_bound = midpoint; + } + output += midpoint * pow(64, i); + } + return output; + } + + void CrealityDWINClass::Decode_String(uint64_t num, char * string) { + const char table[65] = "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"; + LOOP_L_N(i, 30) { + string[i] = table[num % 64]; + num /= 64; + if (num == 0) { + string[i + 1] = '\0'; + break; + } + } + } + +#endif // HAS_HOSTACTION_MENUS + uint16_t CrealityDWINClass::GetColor(uint8_t color, uint16_t original, bool light/*=false*/) { switch (color) { - case Default: - return original; - break; - case White: - return (light) ? Color_Light_White : Color_White; - break; - case Green: - return (light) ? Color_Light_Green : Color_Green; - break; - case Cyan: - return (light) ? Color_Light_Cyan : Color_Cyan; - break; - case Blue: - return (light) ? Color_Light_Blue : Color_Blue; - break; - case Magenta: - return (light) ? Color_Light_Magenta : Color_Magenta; - break; - case Red: - return (light) ? Color_Light_Red : Color_Red; - break; - case Orange: - return (light) ? Color_Light_Orange : Color_Orange; - break; - case Yellow: - return (light) ? Color_Light_Yellow : Color_Yellow; - break; - case Brown: - return (light) ? Color_Light_Brown : Color_Brown; - break; - case Black: - return Color_Black; - break; + case Default: return original; + case White: return (light) ? Color_Light_White : Color_White; + case Green: return (light) ? Color_Light_Green : Color_Green; + case Cyan: return (light) ? Color_Light_Cyan : Color_Cyan; + case Blue: return (light) ? Color_Light_Blue : Color_Blue; + case Magenta: return (light) ? Color_Light_Magenta : Color_Magenta; + case Red: return (light) ? Color_Light_Red : Color_Red; + case Orange: return (light) ? Color_Light_Orange : Color_Orange; + case Yellow: return (light) ? Color_Light_Yellow : Color_Yellow; + case Brown: return (light) ? Color_Light_Brown : Color_Brown; + case Black: return Color_Black; } return Color_White; } void CrealityDWINClass::Draw_Title(const char * ctitle) { - DWIN_Draw_String(false, DWIN_FONT_HEAD, GetColor(eeprom_settings.menu_top_txt, Color_White, false), Color_Bg_Blue, (DWIN_WIDTH - strlen(ctitle) * STAT_CHR_W) / 2, 5, ctitle); + DWINUI::Draw_CenteredString((uint8_t)DWIN_FONT_HEAD, GetColor(eeprom_settings.menu_top_txt, Def_TitleTxt_color, false), 5, ctitle); } void CrealityDWINClass::Draw_Title(FSTR_P const ftitle) { - DWIN_Draw_String(false, DWIN_FONT_HEAD, GetColor(eeprom_settings.menu_top_txt, Color_White, false), Color_Bg_Blue, (DWIN_WIDTH - strlen_P(FTOP(ftitle)) * STAT_CHR_W) / 2, 5, ftitle); + DWINUI::Draw_CenteredString((uint8_t)DWIN_FONT_HEAD, GetColor(eeprom_settings.menu_top_txt, Def_TitleTxt_color, false), 5, ftitle); } void _Decorate_Menu_Item(uint8_t row, uint8_t icon, bool more) { if (icon) DWIN_ICON_Show(ICON, icon, 26, MBASE(row) - 3); //Draw Menu Icon if (more) DWIN_ICON_Show(ICON, ICON_More, 226, MBASE(row) - 3); // Draw More Arrow - DWIN_Draw_Line(CrealityDWIN.GetColor(CrealityDWIN.eeprom_settings.menu_split_line, Line_Color, true), 16, MBASE(row) + 33, 256, MBASE(row) + 33); // Draw Menu Line + DWIN_Draw_HLine(CrealityDWIN.GetColor(eeprom_settings.menu_split_line, Def_SplitLine_Color, true), 16, MBASE(row) + 33, 240); // Draw Menu Line } void CrealityDWINClass::Draw_Menu_Item(uint8_t row, uint8_t icon/*=0*/, const char * label1, const char * label2, bool more/*=false*/, bool centered/*=false*/) { - const uint8_t label_offset_y = (label1 || label2) ? MENU_CHR_H * 3 / 5 : 0, - label1_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1U/5, (DWIN_WIDTH - LBLX - (label1 ? strlen(label1) : 0) * MENU_CHR_W) / 2), - label2_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1U/5, (DWIN_WIDTH - LBLX - (label2 ? strlen(label2) : 0) * MENU_CHR_W) / 2); - if (label1) DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, label1_offset_x, MBASE(row) - 1 - label_offset_y, label1); // Draw Label - if (label2) DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, label2_offset_x, MBASE(row) - 1 + label_offset_y, label2); // Draw Label + const uint8_t label_offset_y = (label1 && label2) ? MENU_CHR_H * 3 / 5 : 0, + label1_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1/5U, (DWIN_WIDTH - LBLX - (label1 ? strlen(label1) : 0) * MENU_CHR_W) / 2), + label2_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1/5U, (DWIN_WIDTH - LBLX - (label2 ? strlen(label2) : 0) * MENU_CHR_W) / 2); + if (label1) DWINUI::Draw_String(label1_offset_x, MBASE(row) - 1 - label_offset_y, label1); // Draw Label + if (label2) DWINUI::Draw_String(label2_offset_x, MBASE(row) - 1 + label_offset_y, label2); // Draw Label _Decorate_Menu_Item(row, icon, more); } void CrealityDWINClass::Draw_Menu_Item(uint8_t row, uint8_t icon/*=0*/, FSTR_P const flabel1, FSTR_P const flabel2, bool more/*=false*/, bool centered/*=false*/) { - const uint8_t label_offset_y = (flabel1 || flabel2) ? MENU_CHR_H * 3 / 5 : 0, - label1_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1U/5, (DWIN_WIDTH - LBLX - (flabel1 ? strlen_P(FTOP(flabel1)) : 0) * MENU_CHR_W) / 2), - label2_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1U/5, (DWIN_WIDTH - LBLX - (flabel2 ? strlen_P(FTOP(flabel2)) : 0) * MENU_CHR_W) / 2); - if (flabel1) DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, label1_offset_x, MBASE(row) - 1 - label_offset_y, flabel1); // Draw Label - if (flabel2) DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, label2_offset_x, MBASE(row) - 1 + label_offset_y, flabel2); // Draw Label + const uint8_t label_offset_y = (flabel1 && flabel2) ? MENU_CHR_H * 3 / 5 : 0, + label1_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1/5U, (DWIN_WIDTH - LBLX - (flabel1 ? strlen_P(FTOP(flabel1)) : 0) * MENU_CHR_W) / 2), + label2_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1/5U, (DWIN_WIDTH - LBLX - (flabel2 ? strlen_P(FTOP(flabel2)) : 0) * MENU_CHR_W) / 2); + if (flabel1) DWINUI::Draw_String(label1_offset_x, MBASE(row) - 1 - label_offset_y, flabel1); // Draw Label + if (flabel2) DWINUI::Draw_String(label2_offset_x, MBASE(row) - 1 + label_offset_y, flabel2); // Draw Label _Decorate_Menu_Item(row, icon, more); } @@ -515,8 +566,8 @@ void CrealityDWINClass::Draw_Checkbox(uint8_t row, bool value) { #if ENABLED(DWIN_CREALITY_LCD_CUSTOM_ICONS) // Draw appropriate checkbox icon DWIN_ICON_Show(ICON, (value ? ICON_Checkbox_T : ICON_Checkbox_F), 226, MBASE(row) - 3); #else // Draw a basic checkbox using rectangles and lines - DWIN_Draw_Rectangle(1, Color_Bg_Black, 226, MBASE(row) - 3, 226 + 20, MBASE(row) - 3 + 20); - DWIN_Draw_Rectangle(0, Color_White, 226, MBASE(row) - 3, 226 + 20, MBASE(row) - 3 + 20); + DWIN_Draw_Rectangle(1, Def_Background_Color, 226, MBASE(row) - 3, 226 + 20, MBASE(row) - 3 + 20); + DWIN_Draw_Rectangle(0, Def_Text_Color, 226, MBASE(row) - 3, 226 + 20, MBASE(row) - 3 + 20); if (value) { DWIN_Draw_Line(Check_Color, 227, MBASE(row) - 3 + 11, 226 + 8, MBASE(row) - 3 + 17); DWIN_Draw_Line(Check_Color, 227 + 8, MBASE(row) - 3 + 17, 226 + 19, MBASE(row) - 3 + 1); @@ -542,7 +593,7 @@ void CrealityDWINClass::Draw_Menu(uint8_t menu, uint8_t select/*=0*/, uint8_t sc Clear_Screen(); Draw_Title(Get_Menu_Title(menu)); LOOP_L_N(i, TROWS) Menu_Item_Handler(menu, i + scrollpos); - DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Rectangle_Color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); + DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Def_Cursor_color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); } void CrealityDWINClass::Redraw_Menu(bool lastprocess/*=true*/, bool lastselection/*=false*/, bool lastmenu/*=false*/) { @@ -558,7 +609,8 @@ void CrealityDWINClass::Redraw_Menu(bool lastprocess/*=true*/, bool lastselectio } void CrealityDWINClass::Redraw_Screen() { - Redraw_Menu(false); + if (printingIsActive()) Draw_Print_Screen(); + else Redraw_Menu(false); Draw_Status_Area(true); Update_Status_Bar(true); } @@ -566,53 +618,56 @@ void CrealityDWINClass::Redraw_Screen() { /* Primary Menus and Screen Elements */ void CrealityDWINClass::Main_Menu_Icons() { + if (selection == 0) { - DWIN_ICON_Show(ICON, ICON_Print_1, 17, 130); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 17, 130, 126, 229); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 52, 200, F("Print")); - } - else { - DWIN_ICON_Show(ICON, ICON_Print_0, 17, 130); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 52, 200, F("Print")); + DWINUI::DRAW_IconWB(ICON, ICON_Print_1, 17, 110); + DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 17, 110, 126, 209); } + else + DWINUI::DRAW_IconWB(ICON, ICON_Print_0, 17, 110); + + DWINUI::Draw_String(52, 180, GET_TEXT_F(MSG_BUTTON_PRINT)); + if (selection == 1) { - DWIN_ICON_Show(ICON, ICON_Prepare_1, 145, 130); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 145, 130, 254, 229); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 170, 200, F("Prepare")); - } - else { - DWIN_ICON_Show(ICON, ICON_Prepare_0, 145, 130); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 170, 200, F("Prepare")); + DWINUI::DRAW_IconWB(ICON, ICON_Prepare_1, 145, 110); + DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 145, 110, 254, 209); } + else + DWINUI::DRAW_IconWB(ICON, ICON_Prepare_0, 145, 110); + + DWINUI::Draw_String(170, 180, GET_TEXT_F(MSG_PREPARE)); + if (selection == 2) { - DWIN_ICON_Show(ICON, ICON_Control_1, 17, 246); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 17, 246, 126, 345); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 43, 317, F("Control")); - } - else { - DWIN_ICON_Show(ICON, ICON_Control_0, 17, 246); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 43, 317, F("Control")); + DWINUI::DRAW_IconWB(ICON, ICON_Control_1, 17, 226); + DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 17, 226, 126, 325); } + else + DWINUI::DRAW_IconWB(ICON, ICON_Control_0, 17, 226); + + DWINUI::Draw_String(43, 297, GET_TEXT_F(MSG_CONTROL)); + #if HAS_ABL_OR_UBL + if (selection == 3) { - DWIN_ICON_Show(ICON, ICON_Leveling_1, 145, 246); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 145, 246, 254, 345); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 179, 317, F("Level")); - } - else { - DWIN_ICON_Show(ICON, ICON_Leveling_0, 145, 246); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 179, 317, F("Level")); + DWINUI::DRAW_IconWB(ICON, ICON_Leveling_1, 145, 226); + DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 145, 226, 254, 325); } + else + DWINUI::DRAW_IconWB(ICON, ICON_Leveling_0, 145, 226); + + DWINUI::Draw_String(179, 297, GET_TEXT_F(MSG_BUTTON_LEVEL)); + #else + if (selection == 3) { - DWIN_ICON_Show(ICON, ICON_Info_1, 145, 246); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 145, 246, 254, 345); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 181, 317, F("Info")); - } - else { - DWIN_ICON_Show(ICON, ICON_Info_0, 145, 246); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 181, 317, F("Info")); + DWINUI::DRAW_IconWB(ICON, ICON_Info_1, 145, 226); + DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 145, 226, 254, 325); } + else + DWINUI::DRAW_IconWB(ICON, ICON_Info_0, 145, 226); + + DWINUI::Draw_String(181, 297, GET_TEXT_F(MSG_BUTTON_INFO)); + #endif } @@ -623,50 +678,48 @@ void CrealityDWINClass::Draw_Main_Menu(uint8_t select/*=0*/) { Clear_Screen(); Draw_Title(Get_Menu_Title(MainMenu)); SERIAL_ECHOPGM("\nDWIN handshake "); - DWIN_ICON_Show(ICON, ICON_LOGO, 71, 72); + DWIN_ICON_Show(ICON, ICON_LOGO, 71, 62); Main_Menu_Icons(); } void CrealityDWINClass::Print_Screen_Icons() { if (selection == 0) { - DWIN_ICON_Show(ICON, ICON_Setup_1, 8, 252); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 8, 252, 87, 351); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 30, 322, F("Tune")); - } - else { - DWIN_ICON_Show(ICON, ICON_Setup_0, 8, 252); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 30, 322, F("Tune")); + DWINUI::DRAW_IconWB(ICON, ICON_Setup_1, 8, 252); + DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 8, 252, 87, 351); } + else + DWINUI::DRAW_IconWB(ICON, ICON_Setup_0, 8, 252); + + DWINUI::Draw_String(30, 322, GET_TEXT_F(MSG_TUNE)); + if (selection == 2) { - DWIN_ICON_Show(ICON, ICON_Stop_1, 184, 252); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 184, 252, 263, 351); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 205, 322, F("Stop")); + DWINUI::DRAW_IconWB(ICON, ICON_Stop_1, 184, 252); + DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 184, 252, 263, 351); } - else { - DWIN_ICON_Show(ICON, ICON_Stop_0, 184, 252); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 205, 322, F("Stop")); - } - if (paused) { + else + DWINUI::DRAW_IconWB(ICON, ICON_Stop_0, 184, 252); + + DWINUI::Draw_String(205, 322, GET_TEXT_F(MSG_BUTTON_STOP)); + + if (temp_val.paused) { if (selection == 1) { - DWIN_ICON_Show(ICON, ICON_Continue_1, 96, 252); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 96, 252, 175, 351); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Print")); - } - else { - DWIN_ICON_Show(ICON, ICON_Continue_0, 96, 252); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Print")); + DWINUI::DRAW_IconWB(ICON, ICON_Continue_1, 96, 252); + DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 96, 252, 175, 351); } + else + DWINUI::DRAW_IconWB(ICON, ICON_Continue_0, 96, 252); + + DWINUI::Draw_String(114, 322, GET_TEXT_F(MSG_BUTTON_RESUME)); } else { if (selection == 1) { - DWIN_ICON_Show(ICON, ICON_Pause_1, 96, 252); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 96, 252, 175, 351); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Pause")); - } - else { - DWIN_ICON_Show(ICON, ICON_Pause_0, 96, 252); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Pause")); + DWINUI::DRAW_IconWB(ICON, ICON_Pause_1, 96, 252); + DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 96, 252, 175, 351); } + else + DWINUI::DRAW_IconWB(ICON, ICON_Pause_0, 96, 252); + + DWINUI::Draw_String(114, 322, GET_TEXT_F(MSG_BUTTON_PAUSE)); } } @@ -674,13 +727,13 @@ void CrealityDWINClass::Draw_Print_Screen() { process = Print; selection = 0; Clear_Screen(); - DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 352, DWIN_WIDTH - 8, 376); - Draw_Title("Printing..."); + DWIN_Draw_Rectangle(1, Def_Background_Color, 8, 352, DWIN_WIDTH - 8, 376); + Draw_Title(GET_TEXT(MSG_PRINTING)); Print_Screen_Icons(); DWIN_ICON_Show(ICON, ICON_PrintTime, 14, 171); DWIN_ICON_Show(ICON, ICON_RemainTime, 147, 169); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, 41, 163, F("Elapsed")); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, 176, 163, F("Remaining")); + DWINUI::Draw_String(Def_PercentTxt_Color, 41, 163, GET_TEXT_F(MSG_INFO_PRINT_TIME)); + DWINUI::Draw_String(Def_PercentTxt_Color, 176, 163, GET_TEXT_F(MSG_REMAINING_TIME)); Update_Status_Bar(true); Draw_Print_ProgressBar(); Draw_Print_ProgressElapsed(); @@ -692,83 +745,91 @@ void CrealityDWINClass::Draw_Print_Filename(const bool reset/*=false*/) { static uint8_t namescrl = 0; if (reset) namescrl = 0; if (process == Print) { - constexpr int8_t maxlen = 30; - char *outstr = filename; - size_t slen = strlen(filename); - int8_t outlen = slen; - if (slen > maxlen) { - char dispname[maxlen + 1]; - int8_t pos = slen - namescrl, len = maxlen; + size_t len = strlen(filename); + int8_t pos = len; + if (pos > STATUS_CHAR_LIMIT) { + pos -= namescrl; + len = _MIN((size_t)pos, (size_t)STATUS_CHAR_LIMIT); + char dispname[len + 1]; if (pos >= 0) { - NOMORE(len, pos); LOOP_L_N(i, len) dispname[i] = filename[i + namescrl]; } else { - const int8_t mp = maxlen + pos; - LOOP_L_N(i, mp) dispname[i] = ' '; - LOOP_S_L_N(i, mp, maxlen) dispname[i] = filename[i - mp]; - if (mp <= 0) namescrl = 0; + LOOP_L_N(i, STATUS_CHAR_LIMIT + pos) dispname[i] = ' '; + LOOP_S_L_N(i, STATUS_CHAR_LIMIT + pos, STATUS_CHAR_LIMIT) dispname[i] = filename[i - (STATUS_CHAR_LIMIT + pos)]; } dispname[len] = '\0'; - outstr = dispname; - outlen = maxlen; + DWIN_Draw_Rectangle(1, Def_Background_Color, 8, 50, DWIN_WIDTH - 8, 80); + const int8_t npos = (DWIN_WIDTH - STATUS_CHAR_LIMIT * MENU_CHR_W) / 2; + DWINUI::Draw_String(npos, 60, dispname); + if (-pos >= STATUS_CHAR_LIMIT) namescrl = 0; namescrl++; } - DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 50, DWIN_WIDTH - 8, 80); - const int8_t npos = (DWIN_WIDTH - outlen * MENU_CHR_W) / 2; - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, npos, 60, outstr); + else { + DWIN_Draw_Rectangle(1, Def_Background_Color, 8, 50, DWIN_WIDTH - 8, 80); + const int8_t npos = (DWIN_WIDTH - strlen(filename) * MENU_CHR_W) / 2; + DWINUI::Draw_String(npos, 60, filename); + } } } void CrealityDWINClass::Draw_Print_ProgressBar() { - uint8_t printpercent = sdprint ? card.percentDone() : (ui._get_progress() / 100); - DWIN_ICON_Show(ICON, ICON_Bar, 15, 93); - DWIN_Draw_Rectangle(1, BarFill_Color, 16 + printpercent * 240 / 100, 93, 256, 113); - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_percent, Percent_Color), Color_Bg_Black, 3, 109, 133, printpercent); - DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_percent, Percent_Color), Color_Bg_Black, 133, 133, F("%")); + uint8_t printpercent = temp_val.sdprint ? card.percentDone() : (ui._get_progress() / 100); + DWINUI::DRAW_IconWB(ICON, ICON_Bar, 15, 93); + DWIN_Draw_Rectangle(1, Def_Barfill_Color, 16 + printpercent * 240 / 100, 93, 256, 113); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_percent, Def_PercentTxt_Color), Def_Background_Color, 3, 109, 133, printpercent); + DWINUI::Draw_String(GetColor(eeprom_settings.progress_percent, Def_PercentTxt_Color), Def_Background_Color, 134, 133, F("%")); } #if ENABLED(USE_M73_REMAINING_TIME) void CrealityDWINClass::Draw_Print_ProgressRemain() { uint16_t remainingtime = ui.get_remaining_time(); - DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 176, 187, remainingtime / 3600); - DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 200, 187, (remainingtime % 3600) / 60); + DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 2, 176, 187, remainingtime / 3600); + DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 2, 201, 187, (remainingtime % 3600) / 60); if (eeprom_settings.time_format_textual) { - DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 192, 187, F("h")); - DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 216, 187, F("m")); + DWINUI::Draw_String(GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 193, 187, F("h")); + DWINUI::Draw_String(GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 217, 187, F("m")); } else - DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 192, 187, F(":")); + DWINUI::Draw_String(GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 193, 187, F(":")); } #endif void CrealityDWINClass::Draw_Print_ProgressElapsed() { duration_t elapsed = print_job_timer.duration(); - DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 42, 187, elapsed.value / 3600); - DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 66, 187, (elapsed.value % 3600) / 60); + DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 2, 42, 187, elapsed.value / 3600); + DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 2, 67, 187, (elapsed.value % 3600) / 60); if (eeprom_settings.time_format_textual) { - DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 58, 187, F("h")); - DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 82, 187, F("m")); + DWINUI::Draw_String(GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 59, 187, F("h")); + DWINUI::Draw_String(GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 83, 187, F("m")); } else - DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 58, 187, F(":")); + DWINUI::Draw_String(GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 59, 187, F(":")); } -void CrealityDWINClass::Draw_Print_confirm() { - Draw_Print_Screen(); +void CrealityDWINClass::Draw_PrintDone_confirm() { process = Confirm; popup = Complete; - DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 252, 263, 351); - DWIN_ICON_Show(ICON, ICON_Confirm_E, 87, 283); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 86, 282, 187, 321); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 85, 281, 188, 322); + if (TERN0(HAS_GCODE_PREVIEW, Preview_Valid())) { + Clear_Screen(); + Draw_Title(GET_TEXT(MSG_PRINT_DONE)); + DWIN_ICON_Show(0, 0, 1, 21, 100, 0x00); + DWINUI::Draw_Button(BTN_Continue, 87, 300); + } + else { + Draw_Print_Screen(); + DWIN_Draw_Rectangle(1, Def_Background_Color, 8, 252, 263, 351); + DWINUI::Draw_Button(BTN_Continue, 87, 283); + DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 86, 282, 187, 321); + DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 85, 281, 188, 322); + } } void CrealityDWINClass::Draw_SD_Item(uint8_t item, uint8_t row) { if (item == 0) - Draw_Menu_Item(0, ICON_Back, card.flag.workDirIsRoot ? F("Back") : F("..")); + Draw_Menu_Item(0, ICON_Back, card.flag.workDirIsRoot ? GET_TEXT_F(MSG_BACK) : F("..")); else { card.getfilename_sorted(SD_ORDER(item - 1, card.get_num_Files())); char * const filename = card.longest_filename(); @@ -777,11 +838,10 @@ void CrealityDWINClass::Draw_SD_Item(uint8_t item, uint8_t row) { if (!card.flag.filenameIsDir) while (pos && filename[pos] != '.') pos--; len = pos; - if (len > max) len = max; + NOMORE(len, max); char name[len + 1]; - LOOP_L_N(i, len) name[i] = filename[i]; - if (pos > max) - LOOP_S_L_N(i, len - 3, len) name[i] = '.'; + memcpy(name, filename, len); + if (pos > max) LOOP_S_L_N(i, len - 3, len) name[i] = '.'; name[len] = '\0'; Draw_Menu_Item(row, card.flag.filenameIsDir ? ICON_More : ICON_File, name); } @@ -798,16 +858,16 @@ void CrealityDWINClass::Draw_SD_List(bool removed/*=false*/) { Draw_SD_Item(i, i); } else { - Draw_Menu_Item(0, ICON_Back, F("Back")); - DWIN_Draw_Rectangle(1, Color_Bg_Red, 10, MBASE(3) - 10, DWIN_WIDTH - 10, MBASE(4)); - DWIN_Draw_String(false, font16x32, Color_Yellow, Color_Bg_Red, ((DWIN_WIDTH) - 8 * 16) / 2, MBASE(3), F("No Media")); + Draw_Menu_Item(0, ICON_Back, GET_TEXT_F(MSG_BACK)); + DWIN_Draw_Rectangle(1, Def_AlertBg_Color, 10, MBASE(3) - 10, DWIN_WIDTH - 10, MBASE(4)); + DWINUI::Draw_String(font16x32, Def_AlertTxt_Color, Def_AlertBg_Color, ((DWIN_WIDTH) - 8 * 16) / 2, MBASE(3), GET_TEXT_F(MSG_NO_MEDIA)); } - DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Rectangle_Color), 0, MBASE(0) - 18, 14, MBASE(0) + 33); + DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Def_Cursor_color), 0, MBASE(0) - 18, 14, MBASE(0) + 33); } void CrealityDWINClass::Draw_Status_Area(bool icons/*=false*/) { - if (icons) DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, STATUS_Y, DWIN_WIDTH, DWIN_HEIGHT - 1); + if (icons) DWIN_Draw_Rectangle(1, Def_Background_Color, 0, STATUS_Y, DWIN_WIDTH, DWIN_HEIGHT - 1); #if HAS_HOTEND static float hotend = -1; @@ -816,26 +876,26 @@ void CrealityDWINClass::Draw_Status_Area(bool icons/*=false*/) { hotend = -1; hotendtarget = -1; DWIN_ICON_Show(ICON, ICON_HotendTemp, 10, 383); - DWIN_Draw_String(false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 384, F("/")); + DWINUI::Draw_String(DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 25 + 3 * STAT_CHR_W + 5, 384, F("/")); } if (thermalManager.temp_hotend[0].celsius != hotend) { hotend = thermalManager.temp_hotend[0].celsius; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 3, 28, 384, thermalManager.temp_hotend[0].celsius); - DWIN_Draw_DegreeSymbol(GetColor(eeprom_settings.status_area_text, Color_White), 25 + 3 * STAT_CHR_W + 5, 386); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 3, 28, 384, thermalManager.temp_hotend[0].celsius); + DWIN_Draw_DegreeSymbol(GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), 25 + 3 * STAT_CHR_W + 5, 386); } if (thermalManager.temp_hotend[0].target != hotendtarget) { hotendtarget = thermalManager.temp_hotend[0].target; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 384, thermalManager.temp_hotend[0].target); - DWIN_Draw_DegreeSymbol(GetColor(eeprom_settings.status_area_text, Color_White), 25 + 4 * STAT_CHR_W + 39, 386); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 3, 25 + 4 * STAT_CHR_W + 6, 384, thermalManager.temp_hotend[0].target); + DWIN_Draw_DegreeSymbol(GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), 25 + 4 * STAT_CHR_W + 39, 386); } if (icons) { flow = -1; DWIN_ICON_Show(ICON, ICON_StepE, 112, 417); - DWIN_Draw_String(false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 116 + 5 * STAT_CHR_W + 2, 417, F("%")); + DWINUI::Draw_String(DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 116 + 5 * STAT_CHR_W + 2, 417, F("%")); } if (planner.flow_percentage[0] != flow) { flow = planner.flow_percentage[0]; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 3, 116 + 2 * STAT_CHR_W, 417, planner.flow_percentage[0]); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 3, 116 + 2 * STAT_CHR_W, 417, planner.flow_percentage[0]); } #endif @@ -846,17 +906,17 @@ void CrealityDWINClass::Draw_Status_Area(bool icons/*=false*/) { bed = -1; bedtarget = -1; DWIN_ICON_Show(ICON, ICON_BedTemp, 10, 416); - DWIN_Draw_String(false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 417, F("/")); + DWINUI::Draw_String(DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 25 + 3 * STAT_CHR_W + 5, 417, F("/")); } if (thermalManager.temp_bed.celsius != bed) { bed = thermalManager.temp_bed.celsius; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 3, 28, 417, thermalManager.temp_bed.celsius); - DWIN_Draw_DegreeSymbol(GetColor(eeprom_settings.status_area_text, Color_White), 25 + 3 * STAT_CHR_W + 5, 419); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 3, 28, 417, thermalManager.temp_bed.celsius); + DWIN_Draw_DegreeSymbol(GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), 25 + 3 * STAT_CHR_W + 5, 419); } if (thermalManager.temp_bed.target != bedtarget) { bedtarget = thermalManager.temp_bed.target; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 417, thermalManager.temp_bed.target); - DWIN_Draw_DegreeSymbol(GetColor(eeprom_settings.status_area_text, Color_White), 25 + 4 * STAT_CHR_W + 39, 419); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 3, 25 + 4 * STAT_CHR_W + 6, 417, thermalManager.temp_bed.target); + DWIN_Draw_DegreeSymbol(GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), 25 + 4 * STAT_CHR_W + 39, 419); } #endif @@ -868,21 +928,37 @@ void CrealityDWINClass::Draw_Status_Area(bool icons/*=false*/) { } if (thermalManager.fan_speed[0] != fan) { fan = thermalManager.fan_speed[0]; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 3, 195 + 2 * STAT_CHR_W, 384, thermalManager.fan_speed[0]); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 3, 195 + 2 * STAT_CHR_W, 384, thermalManager.fan_speed[0]); } #endif #if HAS_ZOFFSET_ITEM static float offset = -1; - if (icons) { - offset = -1; + #if HAS_MESH + static bool _leveling_active = false, + _printing_leveling_active = false; + if (printingIsActive()) { + _printing_leveling_active = ((planner.leveling_active && planner.leveling_active_at_z(current_position.z)) || _printing_leveling_active ); + if ((_printing_leveling_active = (planner.leveling_active && planner.leveling_active_at_z(current_position.z)) && ui.get_blink())) + DWIN_Draw_Rectangle(1, Def_SplitLine_Color, 186, 415, 205, 436); + else + DWIN_Draw_Rectangle(1, Def_Background_Color, 186, 415, 205, 436); + } + else { + _leveling_active = (planner.leveling_active || _leveling_active); + if ((_leveling_active = planner.leveling_active && ui.get_blink())) + DWIN_Draw_Rectangle(1, Def_SplitLine_Color, 186, 415, 205, 436); + else + DWIN_Draw_Rectangle(1, Def_Background_Color, 186, 415, 205, 436); + } DWIN_ICON_Show(ICON, ICON_Zoffset, 187, 416); - } - if (zoffsetvalue != offset) { - offset = zoffsetvalue; - DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 2, 2, 207, 417, (zoffsetvalue < 0 ? -zoffsetvalue : zoffsetvalue)); - DWIN_Draw_String(true, DWIN_FONT_MENU, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 205, 419, zoffsetvalue < 0 ? F("-") : F(" ")); + #else + if (icons) DWIN_ICON_Show(ICON, ICON_Zoffset, 187, 416); + #endif + if (temp_val.zoffsetvalue != offset || icons) { + offset = temp_val.zoffsetvalue; + DWINUI::Draw_Signed_Float(DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color),Def_Background_Color, 1, 2, 202, 417, temp_val.zoffsetvalue); } #endif @@ -890,11 +966,11 @@ void CrealityDWINClass::Draw_Status_Area(bool icons/*=false*/) { if (icons) { feedrate = -1; DWIN_ICON_Show(ICON, ICON_Speed, 113, 383); - DWIN_Draw_String(false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 116 + 5 * STAT_CHR_W + 2, 384, F("%")); + DWINUI::Draw_String(DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 116 + 5 * STAT_CHR_W + 2, 384, F("%")); } if (feedrate_percentage != feedrate) { feedrate = feedrate_percentage; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 3, 116 + 2 * STAT_CHR_W, 384, feedrate_percentage); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 3, 116 + 2 * STAT_CHR_W, 384, feedrate_percentage); } static float x = -1, y = -1, z = -1; @@ -904,7 +980,7 @@ void CrealityDWINClass::Draw_Status_Area(bool icons/*=false*/) { update_z = (current_position.z != z || axis_should_home(Z_AXIS) || update_z); if (icons) { x = y = z = -1; - DWIN_Draw_Line(GetColor(eeprom_settings.coordinates_split_line, Line_Color, true), 16, 450, 256, 450); + DWIN_Draw_Line(GetColor(eeprom_settings.coordinates_split_line, Def_SplitLine_Color, true), 16, 450, 256, 450); DWIN_ICON_Show(ICON, ICON_MaxSpeedX, 10, 456); DWIN_ICON_Show(ICON, ICON_MaxSpeedY, 95, 456); DWIN_ICON_Show(ICON, ICON_MaxSpeedZ, 180, 456); @@ -912,60 +988,59 @@ void CrealityDWINClass::Draw_Status_Area(bool icons/*=false*/) { if (update_x) { x = current_position.x; if ((update_x = axis_should_home(X_AXIS) && ui.get_blink())) - DWIN_Draw_String(true, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 35, 459, F(" -?- ")); + DWINUI::Draw_String(GetColor(eeprom_settings.coordinates_text, Def_Coordinate_Color), Def_Background_Color, 39, 459, F(" -?- ")); else - DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 3, 1, 35, 459, current_position.x); + DWINUI::Draw_Signed_Float(DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Def_Coordinate_Color), Def_Background_Color, 3, 1, 31, 459, current_position.x); } if (update_y) { y = current_position.y; if ((update_y = axis_should_home(Y_AXIS) && ui.get_blink())) - DWIN_Draw_String(true, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 120, 459, F(" -?- ")); + DWINUI::Draw_String(GetColor(eeprom_settings.coordinates_text, Def_Coordinate_Color), Def_Background_Color, 124, 459, F(" -?- ")); else - DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 3, 1, 120, 459, current_position.y); + DWINUI::Draw_Signed_Float(DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Def_Coordinate_Color), Def_Background_Color, 3, 1, 116, 459, current_position.y); } if (update_z) { z = current_position.z; if ((update_z = axis_should_home(Z_AXIS) && ui.get_blink())) - DWIN_Draw_String(true, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 205, 459, F(" -?- ")); + DWINUI::Draw_String(GetColor(eeprom_settings.coordinates_text, Def_Coordinate_Color), Def_Background_Color, 205, 459, F(" -?- ")); else - DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 3, 2, 205, 459, (current_position.z>=0) ? current_position.z : 0); + DWINUI::Draw_Signed_Float(DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Def_Coordinate_Color), Def_Background_Color, 3, 2, 197, 459, current_position.z); } DWIN_UpdateLCD(); } void CrealityDWINClass::Draw_Popup(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, uint8_t mode, uint8_t icon/*=0*/) { - if (process != Confirm && process != Popup && process != Wait) last_process = process; + if (process != Confirm && process != Popup && process != Wait && process != Cancel) last_process = process; if ((process == Menu || process == Wait) && mode == Popup) last_selection = selection; process = mode; - Clear_Screen(); - DWIN_Draw_Rectangle(0, Color_White, 13, 59, 259, 351); - DWIN_Draw_Rectangle(1, Color_Bg_Window, 14, 60, 258, 350); - const uint8_t ypos = (mode == Popup || mode == Confirm) ? 150 : 230; + if (popup != PrintConfirm) { + Clear_Screen(); + DWIN_Draw_Rectangle(0, Def_Highlight_Color, 13, 59, 259, 346); + DWIN_Draw_Rectangle(1, Def_PopupBg_color, 14, 60, 258, 345); + } + else DWIN_Draw_Rectangle(1, Def_Background_Color, 0, 0, DWIN_WIDTH, STATUS_Y - 1); + const uint8_t ypos = (mode == Popup || mode == Confirm) ? 150 : (mode == Cancel) ? 200 : 230; if (icon > 0) DWIN_ICON_Show(ICON, icon, 101, 105); - DWIN_Draw_String(true, DWIN_FONT_MENU, Popup_Text_Color, Color_Bg_Window, (272 - 8 * strlen_P(FTOP(line1))) / 2, ypos, line1); - DWIN_Draw_String(true, DWIN_FONT_MENU, Popup_Text_Color, Color_Bg_Window, (272 - 8 * strlen_P(FTOP(line2))) / 2, ypos + 30, line2); - DWIN_Draw_String(true, DWIN_FONT_MENU, Popup_Text_Color, Color_Bg_Window, (272 - 8 * strlen_P(FTOP(line3))) / 2, ypos + 60, line3); + if (line1) DWINUI::Draw_String(Def_PopupTxt_Color, (272 - 8 * strlen_P(FTOP(line1))) / 2, ypos, line1); + if (line2) DWINUI::Draw_String(Def_PopupTxt_Color, (272 - 8 * strlen_P(FTOP(line2))) / 2, ypos + 30, line2); + if (line3) DWINUI::Draw_String(Def_PopupTxt_Color, (272 - 8 * strlen_P(FTOP(line3))) / 2, ypos + 60, line3); if (mode == Popup) { selection = 0; - DWIN_Draw_Rectangle(1, Confirm_Color, 26, 280, 125, 317); - DWIN_Draw_Rectangle(1, Cancel_Color, 146, 280, 245, 317); - DWIN_Draw_String(false, DWIN_FONT_STAT, Color_White, Color_Bg_Window, 39, 290, F("Confirm")); - DWIN_Draw_String(false, DWIN_FONT_STAT, Color_White, Color_Bg_Window, 165, 290, F("Cancel")); + DWINUI::Draw_Button(BTN_Confirm, 26, 280); + DWINUI::Draw_Button(BTN_Cancel, 146, 280); Popup_Select(); } - else if (mode == Confirm) { - DWIN_Draw_Rectangle(1, Confirm_Color, 87, 280, 186, 317); - DWIN_Draw_String(false, DWIN_FONT_STAT, Color_White, Color_Bg_Window, 96, 290, F("Continue")); - } + else if (mode == Confirm) DWINUI::Draw_Button(BTN_Continue, 87, 280); + else if (mode == Cancel) DWINUI::Draw_Button(BTN_Cancel, 87, 280); } void MarlinUI::kill_screen(FSTR_P const error, FSTR_P const) { - CrealityDWIN.Draw_Popup(F("Printer Kill Reason:"), error, F("Restart Required"), Wait, ICON_BLTouch); + CrealityDWIN.Draw_Popup(GET_TEXT_F(MSG_KILLED), error, GET_TEXT_F(MSG_SWITCH_PS_OFF), Wait, ICON_BLTouch); } void CrealityDWINClass::Popup_Select() { - const uint16_t c1 = (selection == 0) ? GetColor(eeprom_settings.highlight_box, Color_White) : Color_Bg_Window, - c2 = (selection == 0) ? Color_Bg_Window : GetColor(eeprom_settings.highlight_box, Color_White); + const uint16_t c1 = (selection == 0) ? GetColor(eeprom_settings.highlight_box, Def_Highlight_Color) : Def_Background_Color, + c2 = (selection == 0) ? Def_Background_Color : GetColor(eeprom_settings.highlight_box, Def_Highlight_Color); DWIN_Draw_Rectangle(0, c1, 25, 279, 126, 318); DWIN_Draw_Rectangle(0, c1, 24, 278, 127, 319); DWIN_Draw_Rectangle(0, c2, 145, 279, 246, 318); @@ -975,7 +1050,7 @@ void CrealityDWINClass::Popup_Select() { void CrealityDWINClass::Update_Status_Bar(bool refresh/*=false*/) { static bool new_msg; static uint8_t msgscrl = 0; - static char lastmsg[64]; + static char lastmsg[128]; if (strcmp(lastmsg, statusmsg) != 0 || refresh) { strcpy(lastmsg, statusmsg); msgscrl = 0; @@ -983,50 +1058,162 @@ void CrealityDWINClass::Update_Status_Bar(bool refresh/*=false*/) { } size_t len = strlen(statusmsg); int8_t pos = len; - if (pos > 30) { + if (pos > STATUS_CHAR_LIMIT) { pos -= msgscrl; - len = pos; - if (len > 30) - len = 30; + len = _MIN((size_t)pos, (size_t)STATUS_CHAR_LIMIT); char dispmsg[len + 1]; if (pos >= 0) { LOOP_L_N(i, len) dispmsg[i] = statusmsg[i + msgscrl]; } else { - LOOP_L_N(i, 30 + pos) dispmsg[i] = ' '; - LOOP_S_L_N(i, 30 + pos, 30) dispmsg[i] = statusmsg[i - (30 + pos)]; + LOOP_L_N(i, STATUS_CHAR_LIMIT + pos) dispmsg[i] = ' '; + LOOP_S_L_N(i, STATUS_CHAR_LIMIT + pos, STATUS_CHAR_LIMIT) dispmsg[i] = statusmsg[i - (STATUS_CHAR_LIMIT + pos)]; } dispmsg[len] = '\0'; if (process == Print) { - DWIN_Draw_Rectangle(1, Color_Grey, 8, 214, DWIN_WIDTH - 8, 238); - const int8_t npos = (DWIN_WIDTH - 30 * MENU_CHR_W) / 2; - DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 219, dispmsg); + DWIN_Draw_Rectangle(1, Def_StatusBg_Color, 8, 214, DWIN_WIDTH - 8, 238); + const int8_t npos = (DWIN_WIDTH - STATUS_CHAR_LIMIT * MENU_CHR_W) / 2; + DWINUI::Draw_String(GetColor(eeprom_settings.status_bar_text, Def_StatusTxt_Color), Def_StatusBg_Color, npos, 219, dispmsg); } else { - DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 352, DWIN_WIDTH - 8, 376); - const int8_t npos = (DWIN_WIDTH - 30 * MENU_CHR_W) / 2; - DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 357, dispmsg); + DWIN_Draw_Rectangle(1, Def_StatusBg_Color, 8, 352, DWIN_WIDTH - 8, 376); + const int8_t npos = (DWIN_WIDTH - STATUS_CHAR_LIMIT * MENU_CHR_W) / 2; + DWINUI::Draw_String(GetColor(eeprom_settings.status_bar_text, Def_StatusTxt_Color), Def_StatusBg_Color, npos, 357, dispmsg); } - if (-pos >= 30) msgscrl = 0; + if (-pos >= STATUS_CHAR_LIMIT) msgscrl = 0; msgscrl++; } else { if (new_msg) { new_msg = false; if (process == Print) { - DWIN_Draw_Rectangle(1, Color_Grey, 8, 214, DWIN_WIDTH - 8, 238); + DWIN_Draw_Rectangle(1, Def_StatusBg_Color, 8, 214, DWIN_WIDTH - 8, 238); const int8_t npos = (DWIN_WIDTH - strlen(statusmsg) * MENU_CHR_W) / 2; - DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 219, statusmsg); + DWINUI::Draw_String(GetColor(eeprom_settings.status_bar_text, Def_StatusTxt_Color), Def_StatusBg_Color, npos, 219, statusmsg); } else { - DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 352, DWIN_WIDTH - 8, 376); + DWIN_Draw_Rectangle(1, Def_StatusBg_Color, 8, 352, DWIN_WIDTH - 8, 376); const int8_t npos = (DWIN_WIDTH - strlen(statusmsg) * MENU_CHR_W) / 2; - DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 357, statusmsg); + DWINUI::Draw_String(GetColor(eeprom_settings.status_bar_text, Def_StatusTxt_Color), Def_StatusBg_Color, npos, 357, statusmsg); } } } } +#if HAS_HOSTACTION_MENUS + + void CrealityDWINClass::Draw_Keyboard(bool restrict, bool numeric, uint8_t selected, bool uppercase/*=false*/, bool lock/*=false*/) { + process = Keyboard; + keyboard_restrict = restrict; + numeric_keyboard = numeric; + DWIN_Draw_Rectangle(0, Def_SplitLine_Color, 0, KEY_Y_START, DWIN_WIDTH-2, DWIN_HEIGHT-2); + DWIN_Draw_Rectangle(1, Def_Background_Color, 1, KEY_Y_START+1, DWIN_WIDTH-3, DWIN_HEIGHT-3); + LOOP_L_N(i, 36) Draw_Keys(i, (i == selected), uppercase, lock); + } + + void CrealityDWINClass::Draw_Keys(uint8_t index, bool selected, bool uppercase/*=false*/, bool lock/*=false*/) { + const char *keys; + if (numeric_keyboard) keys = "1234567890&<>() {}[]*\"\':;!?"; + else keys = (uppercase) ? "QWERTYUIOPASDFGHJKLZXCVBNM" : "qwertyuiopasdfghjklzxcvbnm"; + #define KEY_X1(x) x*KEY_WIDTH+KEY_INSET+KEY_PADDING + #define KEY_X2(x) (x+1) * KEY_WIDTH+KEY_INSET-KEY_PADDING + #define KEY_Y1(y) KEY_Y_START+KEY_INSET+KEY_PADDING+y*KEY_HEIGHT + #define KEY_Y2(y) KEY_Y_START+KEY_INSET-KEY_PADDING+(y+1) * KEY_HEIGHT + + const uint8_t rowCount[3] = { 10, 9, 7 }; + const float xOffset[3] = { 0, 0.5f * KEY_WIDTH, 1.5f * KEY_WIDTH }; + + if (index < 28) { + if (index == 19) { + DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(0), KEY_Y1(2), KEY_X2(0) + xOffset[1], KEY_Y2(2)); + DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(0) + 1, KEY_Y1(2) + 1, KEY_X2(0) + xOffset[1] - 1, KEY_Y2(2) - 1); + if (!numeric_keyboard) { + if (lock) { + DWIN_Draw_Line(Def_Selected_Color, KEY_X1(0) + 17, KEY_Y1(2) + 16, KEY_X1(0) + 25, KEY_Y1(2) + 8); + DWIN_Draw_Line(Def_Selected_Color, KEY_X1(0) + 17, KEY_Y1(2) + 16, KEY_X1(0) + 9, KEY_Y1(2) + 8); + } + else { + DWIN_Draw_Line((uppercase) ? Def_Selected_Color : Def_Text_Color, KEY_X1(0) + 17, KEY_Y1(2) + 8, KEY_X1(0) + 25, KEY_Y1(2) + 16); + DWIN_Draw_Line((uppercase) ? Def_Selected_Color : Def_Text_Color, KEY_X1(0) + 17, KEY_Y1(2) + 8, KEY_X1(0) + 9, KEY_Y1(2) + 16); + } + } + } + else if (index == 27) { + DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(7) + xOffset[2], KEY_Y1(2), KEY_X2(9), KEY_Y2(2)); + DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(7) + xOffset[2] + 1, KEY_Y1(2) + 1, KEY_X2(9) - 1, KEY_Y2(2) - 1); + DWINUI::Draw_String(Color_Red, KEY_X1(7) + xOffset[2] + 3, KEY_Y1(2) + 5, F("<--")); + } + else { + if (index > 19) index--; + if (index > 27) index--; + uint8_t y, x; + if (index < rowCount[0]) y = 0, x = index; + else if (index < (rowCount[0] + rowCount[1])) y = 1, x = index-rowCount[0]; + else y = 2, x = index-(rowCount[0] + rowCount[1]); + const char keyStr[2] = {keys[(y > 0) * rowCount[0] + (y > 1) * rowCount[1] + x], '\0'}; + DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(x) + xOffset[y], KEY_Y1(y), KEY_X2(x) + xOffset[y], KEY_Y2(y)); + DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(x) + xOffset[y] + 1, KEY_Y1(y) + 1, KEY_X2(x) + xOffset[y] - 1, KEY_Y2(y) - 1); + DWINUI::Draw_String(KEY_X1(x) + xOffset[y] + 5, KEY_Y1(y) + 5, keyStr); + if (keyboard_restrict && numeric_keyboard && index > 9) { + DWIN_Draw_Line(Color_Light_Red, KEY_X1(x) + xOffset[y] + 1, KEY_Y1(y) + 1, KEY_X2(x) + xOffset[y] - 1, KEY_Y2(y) - 1); + DWIN_Draw_Line(Color_Light_Red, KEY_X1(x) + xOffset[y] + 1, KEY_Y2(y) - 1, KEY_X2(x) + xOffset[y] - 1, KEY_Y1(y) + 1); + } + } + } + else { + switch (index) { + case 28: + DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(0), KEY_Y1(3), KEY_X2(0) + xOffset[1], KEY_Y2(3)); + DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(0) + 1, KEY_Y1(3) + 1, KEY_X2(0) + xOffset[1] - 1, KEY_Y2(3) - 1); + DWINUI::Draw_String(KEY_X1(0) - 1, KEY_Y1(3) + 5, F("?123")); + break; + case 29: + DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(1) + xOffset[1], KEY_Y1(3), KEY_X2(1) + xOffset[1], KEY_Y2(3)); + DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(1) + xOffset[1] + 1, KEY_Y1(3) + 1, KEY_X2(1) + xOffset[1] - 1, KEY_Y2(3) - 1); + DWINUI::Draw_String(KEY_X1(1) + xOffset[1] + 5, KEY_Y1(3) + 5, F("-")); + break; + case 30: + DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(2) + xOffset[1], KEY_Y1(3), KEY_X2(2) + xOffset[1], KEY_Y2(3)); + DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(2) + xOffset[1] + 1, KEY_Y1(3) + 1, KEY_X2(2) + xOffset[1] - 1, KEY_Y2(3) - 1); + DWINUI::Draw_String(KEY_X1(2) + xOffset[1] + 5, KEY_Y1(3) + 5, F("_")); + break; + case 31: + DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(3) + xOffset[1], KEY_Y1(3), KEY_X2(5) + xOffset[1], KEY_Y2(3)); + DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(3) + xOffset[1] + 1, KEY_Y1(3) + 1, KEY_X2(5) + xOffset[1] - 1, KEY_Y2(3) - 1); + DWINUI::Draw_String(KEY_X1(3) + xOffset[1] + 14, KEY_Y1(3) + 5, F("Space")); + if (keyboard_restrict) { + DWIN_Draw_Line(Color_Light_Red, KEY_X1(3) + xOffset[1] + 1, KEY_Y1(3) + 1, KEY_X2(5) + xOffset[1] - 1, KEY_Y2(3) - 1); + DWIN_Draw_Line(Color_Light_Red, KEY_X1(3) + xOffset[1] + 1, KEY_Y2(3) - 1, KEY_X2(5) + xOffset[1] - 1, KEY_Y1(3) + 1); + } + break; + case 32: + DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(6) + xOffset[1], KEY_Y1(3), KEY_X2(6) + xOffset[1], KEY_Y2(3)); + DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(6) + xOffset[1] + 1, KEY_Y1(3) + 1, KEY_X2(6) + xOffset[1] - 1, KEY_Y2(3) - 1); + DWINUI::Draw_String(KEY_X1(6) + xOffset[1] + 7, KEY_Y1(3) + 5, F(".")); + if (keyboard_restrict) { + DWIN_Draw_Line(Color_Light_Red, KEY_X1(6) + xOffset[1] + 1, KEY_Y1(3) + 1, KEY_X2(6) + xOffset[1] - 1, KEY_Y2(3) - 1); + DWIN_Draw_Line(Color_Light_Red, KEY_X1(6) + xOffset[1] + 1, KEY_Y2(3) - 1, KEY_X2(6) + xOffset[1] - 1, KEY_Y1(3) + 1); + } + break; + case 33: + DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(7) + xOffset[1], KEY_Y1(3), KEY_X2(7) + xOffset[1], KEY_Y2(3)); + DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(7) + xOffset[1] + 1, KEY_Y1(3) + 1, KEY_X2(7) + xOffset[1] - 1, KEY_Y2(3) - 1); + DWINUI::Draw_String(KEY_X1(7) + xOffset[1] + 4, KEY_Y1(3) + 5, F("/")); + if (keyboard_restrict) { + DWIN_Draw_Line(Color_Light_Red, KEY_X1(7) + xOffset[1] + 1, KEY_Y1(3) + 1, KEY_X2(7) + xOffset[1] - 1, KEY_Y2(3) - 1); + DWIN_Draw_Line(Color_Light_Red, KEY_X1(7) + xOffset[1] + 1, KEY_Y2(3) - 1, KEY_X2(7) + xOffset[1] - 1, KEY_Y1(3) + 1); + } + break; + case 34: + DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(7) + xOffset[2], KEY_Y1(3), KEY_X2(9), KEY_Y2(3)); + DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(7) + xOffset[2] + 1, KEY_Y1(3) + 1, KEY_X2(9) - 1, KEY_Y2(3) - 1); + DWINUI::Draw_String(Color_Cyan, KEY_X1(7) + xOffset[2] + 3, KEY_Y1(3) + 5, F("-->")); + break; + } + } + } +#endif // HAS_HOSTACTION_MENUS + /* Menu Item Config */ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/*=true*/) { @@ -1047,7 +1234,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case PREHEAT_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(TempMenu, sel); break; @@ -1074,7 +1261,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_FAN case PREHEAT_SUBMENU_FAN: if (draw) { - Draw_Menu_Item(row, ICON_FanSpeed, F("Fan")); + Draw_Menu_Item(row, ICON_FanSpeed, GET_TEXT_F(MSG_FAN_SPEED)); Draw_Float(ui.material_preset[index].fan_speed, row, false, 1); } else @@ -1098,37 +1285,38 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #define PREPARE_PREHEAT (PREPARE_ZOFFSET + ENABLED(HAS_PREHEAT)) #define PREPARE_COOLDOWN (PREPARE_PREHEAT + EITHER(HAS_HOTEND, HAS_HEATED_BED)) #define PREPARE_CHANGEFIL (PREPARE_COOLDOWN + ENABLED(ADVANCED_PAUSE_FEATURE)) - #define PREPARE_CUSTOM_MENU (PREPARE_CHANGEFIL + ENABLED(HAS_CUSTOM_MENU)) - #define PREPARE_TOTAL PREPARE_CUSTOM_MENU + #define PREPARE_ACTIONCOMMANDS (PREPARE_CHANGEFIL + ENABLED(HAS_HOSTACTION_MENUS)) + #define PREPARE_CUSTOM_MENU (PREPARE_ACTIONCOMMANDS + ENABLED(HAS_CUSTOM_MENU)) + #define PREPARE_TOTAL PREPARE_ACTIONCOMMANDS switch (item) { case PREPARE_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Main_Menu(1); break; case PREPARE_MOVE: if (draw) - Draw_Menu_Item(row, ICON_Axis, F("Move"), nullptr, true); + Draw_Menu_Item(row, ICON_Axis, GET_TEXT_F(MSG_MOVE_AXIS), nullptr, true); else Draw_Menu(Move); break; case PREPARE_DISABLE: if (draw) - Draw_Menu_Item(row, ICON_CloseMotor, F("Disable Stepper")); + Draw_Menu_Item(row, ICON_CloseMotor, GET_TEXT_F(MSG_DISABLE_STEPPERS)); else queue.inject(F("M84")); break; case PREPARE_HOME: if (draw) - Draw_Menu_Item(row, ICON_SetHome, F("Homing"), nullptr, true); + Draw_Menu_Item(row, ICON_SetHome, GET_TEXT_F(MSG_HOMING), nullptr, true); else Draw_Menu(HomeMenu); break; case PREPARE_MANUALLEVEL: if (draw) - Draw_Menu_Item(row, ICON_PrintSize, F("Manual Leveling"), nullptr, true); + Draw_Menu_Item(row, ICON_PrintSize, GET_TEXT_F(MSG_BED_TRAMMING_MANUAL), nullptr, true); else { if (axes_should_home()) { Popup_Handler(Home); @@ -1168,12 +1356,23 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_HOTEND || HAS_HEATED_BED case PREPARE_COOLDOWN: if (draw) - Draw_Menu_Item(row, ICON_Cool, F("Cooldown")); - else + Draw_Menu_Item(row, ICON_Cool, GET_TEXT_F(MSG_COOLDOWN)); + else { thermalManager.cooldown(); + Update_Status(GET_TEXT(MSG_COOLDOWN)); + } break; #endif + #if HAS_HOSTACTION_MENUS + case PREPARE_ACTIONCOMMANDS: + if (draw) + Draw_Menu_Item(row, ICON_SetHome, F("Host Actions"), nullptr, true); + else + Draw_Menu(HostActions); + break; + #endif + #if HAS_CUSTOM_MENU case PREPARE_CUSTOM_MENU: #ifndef CUSTOM_MENU_CONFIG_TITLE @@ -1189,7 +1388,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if ENABLED(ADVANCED_PAUSE_FEATURE) case PREPARE_CHANGEFIL: if (draw) { - Draw_Menu_Item(row, ICON_ResumeEEPROM, F("Change Filament") + Draw_Menu_Item(row, ICON_ResumeEEPROM, GET_TEXT_F(MSG_FILAMENTCHANGE) #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) , nullptr, true #endif @@ -1230,13 +1429,13 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case HOME_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Prepare, PREPARE_HOME); break; case HOME_ALL: if (draw) - Draw_Menu_Item(row, ICON_Homing, F("Home All")); + Draw_Menu_Item(row, ICON_Homing, GET_TEXT_F(MSG_AUTO_HOME)); else { Popup_Handler(Home); gcode.home_all_axes(true); @@ -1245,7 +1444,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case HOME_X: if (draw) - Draw_Menu_Item(row, ICON_MoveX, F("Home X")); + Draw_Menu_Item(row, ICON_MoveX, GET_TEXT_F(MSG_AUTO_HOME_X)); else { Popup_Handler(Home); gcode.process_subcommands_now(F("G28 X")); @@ -1255,7 +1454,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case HOME_Y: if (draw) - Draw_Menu_Item(row, ICON_MoveY, F("Home Y")); + Draw_Menu_Item(row, ICON_MoveY, GET_TEXT_F(MSG_AUTO_HOME_Y)); else { Popup_Handler(Home); gcode.process_subcommands_now(F("G28 Y")); @@ -1265,7 +1464,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case HOME_Z: if (draw) - Draw_Menu_Item(row, ICON_MoveZ, F("Home Z")); + Draw_Menu_Item(row, ICON_MoveZ, GET_TEXT_F(MSG_AUTO_HOME_Z)); else { Popup_Handler(Home); gcode.process_subcommands_now(F("G28 Z")); @@ -1275,7 +1474,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case HOME_SET: if (draw) - Draw_Menu_Item(row, ICON_SetHome, F("Set Home Position")); + Draw_Menu_Item(row, ICON_SetHome, GET_TEXT_F(MSG_SET_HOME_OFFSETS)); else { gcode.process_subcommands_now(F("G92X0Y0Z0")); AudioFeedback(); @@ -1298,18 +1497,18 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case MOVE_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else { #if HAS_BED_PROBE - probe_deployed = false; - probe.set_deployed(probe_deployed); + temp_val.probe_deployed = false; + probe.set_deployed(temp_val.probe_deployed); #endif Draw_Menu(Prepare, PREPARE_MOVE); } break; case MOVE_X: if (draw) { - Draw_Menu_Item(row, ICON_MoveX, F("Move X")); + Draw_Menu_Item(row, ICON_MoveX, GET_TEXT_F(MSG_MOVE_X)); Draw_Float(current_position.x, row, false); } else @@ -1317,7 +1516,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case MOVE_Y: if (draw) { - Draw_Menu_Item(row, ICON_MoveY, F("Move Y")); + Draw_Menu_Item(row, ICON_MoveY, GET_TEXT_F(MSG_MOVE_Y)); Draw_Float(current_position.y, row); } else @@ -1325,7 +1524,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case MOVE_Z: if (draw) { - Draw_Menu_Item(row, ICON_MoveZ, F("Move Z")); + Draw_Menu_Item(row, ICON_MoveZ, GET_TEXT_F(MSG_MOVE_Z)); Draw_Float(current_position.z, row); } else @@ -1335,15 +1534,14 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_HOTEND case MOVE_E: if (draw) { - Draw_Menu_Item(row, ICON_Extruder, F("Extruder")); + Draw_Menu_Item(row, ICON_Extruder, GET_TEXT_F(MSG_MOVE_E)); current_position.e = 0; sync_plan_position(); Draw_Float(current_position.e, row); } else { - if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) { + if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) Popup_Handler(ETemp); - } else { if (thermalManager.temp_hotend[0].is_below_target(-2)) { Popup_Handler(Heating); @@ -1361,13 +1559,13 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_BED_PROBE case MOVE_P: if (draw) { - Draw_Menu_Item(row, ICON_StockConfiguration, F("Probe")); - Draw_Checkbox(row, probe_deployed); + Draw_Menu_Item(row, ICON_ProbeDeploy, GET_TEXT_F(MSG_MANUAL_DEPLOY)); + Draw_Checkbox(row, temp_val.probe_deployed); } else { - probe_deployed = !probe_deployed; - probe.set_deployed(probe_deployed); - Draw_Checkbox(row, probe_deployed); + temp_val.probe_deployed = !temp_val.probe_deployed; + probe.set_deployed(temp_val.probe_deployed); + Draw_Checkbox(row, temp_val.probe_deployed); } break; #endif @@ -1375,11 +1573,11 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case MOVE_LIVE: if (draw) { Draw_Menu_Item(row, ICON_Axis, F("Live Movement")); - Draw_Checkbox(row, livemove); + Draw_Checkbox(row, temp_val.livemove); } else { - livemove = !livemove; - Draw_Checkbox(row, livemove); + temp_val.livemove = !temp_val.livemove; + Draw_Checkbox(row, temp_val.livemove); } break; } @@ -1388,11 +1586,11 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #define MLEVEL_BACK 0 #define MLEVEL_PROBE (MLEVEL_BACK + ENABLED(HAS_BED_PROBE)) - #define MLEVEL_BL (MLEVEL_PROBE + 1) - #define MLEVEL_TL (MLEVEL_BL + 1) - #define MLEVEL_TR (MLEVEL_TL + 1) - #define MLEVEL_BR (MLEVEL_TR + 1) - #define MLEVEL_C (MLEVEL_BR + 1) + #define MLEVEL_FL (MLEVEL_PROBE + 1) + #define MLEVEL_BL (MLEVEL_FL + 1) + #define MLEVEL_BR (MLEVEL_BL + 1) + #define MLEVEL_FR (MLEVEL_BR + 1) + #define MLEVEL_C (MLEVEL_FR + 1) #define MLEVEL_ZPOS (MLEVEL_C + 1) #define MLEVEL_TOTAL MLEVEL_ZPOS @@ -1402,7 +1600,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case MLEVEL_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else { TERN_(HAS_LEVELING, set_bed_leveling_enabled(level_state)); Draw_Menu(Prepare, PREPARE_MANUALLEVEL); @@ -1419,24 +1617,46 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Draw_Checkbox(row, use_probe); if (use_probe) { Popup_Handler(Level); - corner_avg = 0; - #define PROBE_X_MIN _MAX(0 + corner_pos, X_MIN_POS + probe.offset.x, X_MIN_POS + PROBING_MARGIN) - probe.offset.x - #define PROBE_X_MAX _MIN((X_BED_SIZE + X_MIN_POS) - corner_pos, X_MAX_POS + probe.offset.x, X_MAX_POS - PROBING_MARGIN) - probe.offset.x - #define PROBE_Y_MIN _MAX(0 + corner_pos, Y_MIN_POS + probe.offset.y, Y_MIN_POS + PROBING_MARGIN) - probe.offset.y - #define PROBE_Y_MAX _MIN((Y_BED_SIZE + Y_MIN_POS) - corner_pos, Y_MAX_POS + probe.offset.y, Y_MAX_POS - PROBING_MARGIN) - probe.offset.y - corner_avg += probe.probe_at_point(PROBE_X_MIN, PROBE_Y_MIN, PROBE_PT_RAISE, 0, false); - corner_avg += probe.probe_at_point(PROBE_X_MIN, PROBE_Y_MAX, PROBE_PT_RAISE, 0, false); - corner_avg += probe.probe_at_point(PROBE_X_MAX, PROBE_Y_MAX, PROBE_PT_RAISE, 0, false); - corner_avg += probe.probe_at_point(PROBE_X_MAX, PROBE_Y_MIN, PROBE_PT_STOW, 0, false); - corner_avg /= 4; + do_z_clearance(Z_HOMING_HEIGHT); + temp_val.corner_avg = 0; + #define PROBE_X_MIN _MAX(temp_val.corner_pos, PROBING_MARGIN, MESH_MIN_X) - probe.offset.x + #define PROBE_X_MAX _MIN(X_BED_SIZE - temp_val.corner_pos, X_BED_SIZE - PROBING_MARGIN, MESH_MAX_X) - probe.offset.x + #define PROBE_Y_MIN _MAX(temp_val.corner_pos, PROBING_MARGIN, MESH_MIN_Y) - probe.offset.y + #define PROBE_Y_MAX _MIN(Y_BED_SIZE - temp_val.corner_pos, Y_BED_SIZE - PROBING_MARGIN, MESH_MAX_Y) - probe.offset.y + temp_val.zval = probe.probe_at_point(PROBE_X_MIN, PROBE_Y_MIN, PROBE_PT_RAISE, 0, false); + const char * MSG_UNREACHABLE = "Position unreachable. Check Probe Offsets and Bed Screw Inset."; + if (isnan(temp_val.zval)) { + Update_Status(MSG_UNREACHABLE); + Redraw_Menu(); + } + temp_val.corner_avg += temp_val.zval; + temp_val.zval = probe.probe_at_point(PROBE_X_MIN, PROBE_Y_MAX, PROBE_PT_RAISE, 0, false); + if (isnan(temp_val.zval)) { + Update_Status(MSG_UNREACHABLE); + Redraw_Menu(); + } + temp_val.corner_avg += temp_val.zval; + temp_val.zval = probe.probe_at_point(PROBE_X_MAX, PROBE_Y_MAX, PROBE_PT_RAISE, 0, false); + if (isnan(temp_val.zval)) { + Update_Status(MSG_UNREACHABLE); + Redraw_Menu(); + } + temp_val.corner_avg += temp_val.zval; + temp_val.zval = probe.probe_at_point(PROBE_X_MAX, PROBE_Y_MIN, PROBE_PT_STOW, 0, false); + if (isnan(temp_val.zval)) { + Update_Status(MSG_UNREACHABLE); + Redraw_Menu(); + } + temp_val.corner_avg += temp_val.zval; + temp_val.corner_avg /= 4; Redraw_Menu(); } } break; #endif - case MLEVEL_BL: + case MLEVEL_FL: if (draw) - Draw_Menu_Item(row, ICON_AxisBL, F("Bottom Left")); + Draw_Menu_Item(row, ICON_AxisBL, GET_TEXT_F(MSG_LEVBED_FL)); else { Popup_Handler(MoveWait); if (use_probe) { @@ -1448,16 +1668,16 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #endif } else { - sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf(corner_pos, 1, 3, str_1), dtostrf(corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); + sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf(temp_val.corner_pos, 1, 3, str_1), dtostrf(temp_val.corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); gcode.process_subcommands_now(cmd); planner.synchronize(); Redraw_Menu(); } } break; - case MLEVEL_TL: + case MLEVEL_BL: if (draw) - Draw_Menu_Item(row, ICON_AxisTL, F("Top Left")); + Draw_Menu_Item(row, ICON_AxisTL, GET_TEXT_F(MSG_LEVBED_BL)); else { Popup_Handler(MoveWait); if (use_probe) { @@ -1469,16 +1689,16 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #endif } else { - sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf(corner_pos, 1, 3, str_1), dtostrf((Y_BED_SIZE + Y_MIN_POS) - corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); + sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf(temp_val.corner_pos, 1, 3, str_1), dtostrf(Y_BED_SIZE - temp_val.corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); gcode.process_subcommands_now(cmd); planner.synchronize(); Redraw_Menu(); } } break; - case MLEVEL_TR: + case MLEVEL_BR: if (draw) - Draw_Menu_Item(row, ICON_AxisTR, F("Top Right")); + Draw_Menu_Item(row, ICON_AxisTR, GET_TEXT_F(MSG_LEVBED_BR)); else { Popup_Handler(MoveWait); if (use_probe) { @@ -1490,16 +1710,16 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #endif } else { - sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf((X_BED_SIZE + X_MIN_POS) - corner_pos, 1, 3, str_1), dtostrf((Y_BED_SIZE + Y_MIN_POS) - corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); + sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf(X_BED_SIZE - temp_val.corner_pos, 1, 3, str_1), dtostrf(Y_BED_SIZE - temp_val.corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); gcode.process_subcommands_now(cmd); planner.synchronize(); Redraw_Menu(); } } break; - case MLEVEL_BR: + case MLEVEL_FR: if (draw) - Draw_Menu_Item(row, ICON_AxisBR, F("Bottom Right")); + Draw_Menu_Item(row, ICON_AxisBR, GET_TEXT_F(MSG_LEVBED_FR)); else { Popup_Handler(MoveWait); if (use_probe) { @@ -1511,7 +1731,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #endif } else { - sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf((X_BED_SIZE + X_MIN_POS) - corner_pos, 1, 3, str_1), dtostrf(corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); + sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf(X_BED_SIZE - temp_val.corner_pos, 1, 3, str_1), dtostrf(temp_val.corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); gcode.process_subcommands_now(cmd); planner.synchronize(); Redraw_Menu(); @@ -1520,19 +1740,19 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case MLEVEL_C: if (draw) - Draw_Menu_Item(row, ICON_AxisC, F("Center")); + Draw_Menu_Item(row, ICON_AxisC, GET_TEXT_F(MSG_LEVBED_C)); else { Popup_Handler(MoveWait); if (use_probe) { #if HAS_BED_PROBE - sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s"), dtostrf(X_MAX_POS / 2.0f - probe.offset.x, 1, 3, str_1), dtostrf(Y_MAX_POS / 2.0f - probe.offset.y, 1, 3, str_2)); + sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s"), dtostrf((PROBE_X_MIN + PROBE_X_MAX) / 2.0f, 1, 3, str_1), dtostrf((PROBE_Y_MIN + PROBE_Y_MAX) / 2.0f, 1, 3, str_2)); gcode.process_subcommands_now(cmd); planner.synchronize(); Popup_Handler(ManualProbing); #endif } else { - sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf((X_BED_SIZE + X_MIN_POS) / 2.0f, 1, 3, str_1), dtostrf((Y_BED_SIZE + Y_MIN_POS) / 2.0f, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); + sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf(X_BED_SIZE / 2.0f, 1, 3, str_1), dtostrf(Y_BED_SIZE / 2.0f, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); gcode.process_subcommands_now(cmd); planner.synchronize(); Redraw_Menu(); @@ -1541,7 +1761,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case MLEVEL_ZPOS: if (draw) { - Draw_Menu_Item(row, ICON_SetZOffset, F("Z Position")); + Draw_Menu_Item(row, ICON_SetZOffset, GET_TEXT_F(MSG_MOVE_Z)); Draw_Float(mlev_z_pos, row, false, 100); } else @@ -1564,16 +1784,19 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case ZOFFSET_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else { - liveadjust = false; + temp_val.zoffsetmode = 0; + #if !HAS_BED_PROBE + gcode.process_subcommands_now(F("M211 S1")); // Soft end-stops + #endif TERN_(HAS_LEVELING, set_bed_leveling_enabled(level_state)); Draw_Menu(Prepare, PREPARE_ZOFFSET); } break; case ZOFFSET_HOME: if (draw) - Draw_Menu_Item(row, ICON_Homing, F("Home Z Axis")); + Draw_Menu_Item(row, ICON_Homing, GET_TEXT_F(MSG_AUTO_HOME_Z)); else { Popup_Handler(Home); gcode.process_subcommands_now(F("G28 Z")); @@ -1583,7 +1806,8 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ sprintf_P(cmd, PSTR("G0 F4000 X%s Y%s"), dtostrf(Z_SAFE_HOMING_X_POINT, 1, 3, str_1), dtostrf(Z_SAFE_HOMING_Y_POINT, 1, 3, str_2)); gcode.process_subcommands_now(cmd); #else - gcode.process_subcommands_now(F("G0 F4000 X117.5 Y117.5")); + sprintf_P(cmd, PSTR("G0 F4000 X%s Y%s"), dtostrf((X_BED_SIZE + X_MIN_POS) / 2.0f, 1, 3, str_1), dtostrf((Y_BED_SIZE + Y_MIN_POS) / 2.0f, 1, 3, str_2)); + gcode.process_subcommands_now(cmd); #endif gcode.process_subcommands_now(F("G0 F300 Z0")); planner.synchronize(); @@ -1593,49 +1817,30 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case ZOFFSET_MODE: if (draw) { Draw_Menu_Item(row, ICON_Zoffset, F("Live Adjustment")); - Draw_Checkbox(row, liveadjust); - } - else { - if (!liveadjust) { - if (axes_should_home()) { - Popup_Handler(Home); - gcode.home_all_axes(true); - } - Popup_Handler(MoveWait); - #if ENABLED(Z_SAFE_HOMING) - planner.synchronize(); - sprintf_P(cmd, PSTR("G0 F4000 X%s Y%s"), dtostrf(Z_SAFE_HOMING_X_POINT, 1, 3, str_1), dtostrf(Z_SAFE_HOMING_Y_POINT, 1, 3, str_2)); - gcode.process_subcommands_now(cmd); - #else - gcode.process_subcommands_now(F("G0 F4000 X117.5 Y117.5")); - #endif - gcode.process_subcommands_now(F("G0 F300 Z0")); - planner.synchronize(); - Redraw_Menu(); - } - liveadjust = !liveadjust; - Draw_Checkbox(row, liveadjust); + Draw_Option(temp_val.zoffsetmode, zoffset_modes, row); } + else + Modify_Option(temp_val.zoffsetmode, zoffset_modes, 2); break; case ZOFFSET_OFFSET: if (draw) { Draw_Menu_Item(row, ICON_SetZOffset, F("Z Offset")); - Draw_Float(zoffsetvalue, row, false, 100); + Draw_Float(temp_val.zoffsetvalue, row, false, 100); } else - Modify_Value(zoffsetvalue, MIN_Z_OFFSET, MAX_Z_OFFSET, 100); + Modify_Value(temp_val.zoffsetvalue, MIN_Z_OFFSET, MAX_Z_OFFSET, 100); break; case ZOFFSET_UP: if (draw) Draw_Menu_Item(row, ICON_Axis, F("Microstep Up")); else { - if (zoffsetvalue < MAX_Z_OFFSET) { - if (liveadjust) { + if (temp_val.zoffsetvalue < MAX_Z_OFFSET) { + if (temp_val.zoffsetmode != 0) { gcode.process_subcommands_now(F("M290 Z0.01")); planner.synchronize(); } - zoffsetvalue += 0.01; - Draw_Float(zoffsetvalue, row - 1, false, 100); + temp_val.zoffsetvalue += 0.01; + Draw_Float(temp_val.zoffsetvalue, row - 1, false, 100); } } break; @@ -1643,20 +1848,20 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (draw) Draw_Menu_Item(row, ICON_AxisD, F("Microstep Down")); else { - if (zoffsetvalue > MIN_Z_OFFSET) { - if (liveadjust) { + if (temp_val.zoffsetvalue > MIN_Z_OFFSET) { + if (temp_val.zoffsetmode != 0) { gcode.process_subcommands_now(F("M290 Z-0.01")); planner.synchronize(); } - zoffsetvalue -= 0.01; - Draw_Float(zoffsetvalue, row - 2, false, 100); + temp_val.zoffsetvalue -= 0.01; + Draw_Float(temp_val.zoffsetvalue, row - 2, false, 100); } } break; #if ENABLED(EEPROM_SETTINGS) case ZOFFSET_SAVE: if (draw) - Draw_Menu_Item(row, ICON_WriteEEPROM, F("Save")); + Draw_Menu_Item(row, ICON_WriteEEPROM, GET_TEXT_F(MSG_BUTTON_SAVE)); else AudioFeedback(settings.save()); break; @@ -1677,25 +1882,25 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ auto do_preheat = [](const uint8_t m) { thermalManager.cooldown(); - if (preheatmode == 0 || preheatmode == 1) { ui.preheat_hotend_and_fan(m); } - if (preheatmode == 0 || preheatmode == 2) ui.preheat_bed(m); + if (temp_val.preheatmode == 0 || temp_val.preheatmode == 1) { ui.preheat_hotend_and_fan(m); } + if (temp_val.preheatmode == 0 || temp_val.preheatmode == 2) ui.preheat_bed(m); }; switch (item) { case PREHEAT_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Prepare, PREPARE_PREHEAT); break; case PREHEAT_MODE: if (draw) { - Draw_Menu_Item(row, ICON_Homing, F("Preheat Mode")); - Draw_Option(preheatmode, preheat_modes, row); + Draw_Menu_Item(row, ICON_Homing, GET_TEXT_F(MSG_CONFIGURATION)); + Draw_Option(temp_val.preheatmode, preheat_modes, row); } else - Modify_Option(preheatmode, preheat_modes, 2); + Modify_Option(temp_val.preheatmode, preheat_modes, 2); break; #define _PREHEAT_CASE(N) \ @@ -1713,7 +1918,8 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case ChangeFilament: #define CHANGEFIL_BACK 0 - #define CHANGEFIL_LOAD (CHANGEFIL_BACK + 1) + #define CHANGEFIL_PARKHEAD (CHANGEFIL_BACK + 1) + #define CHANGEFIL_LOAD (CHANGEFIL_PARKHEAD + 1) #define CHANGEFIL_UNLOAD (CHANGEFIL_LOAD + 1) #define CHANGEFIL_CHANGE (CHANGEFIL_UNLOAD + 1) #define CHANGEFIL_TOTAL CHANGEFIL_CHANGE @@ -1721,13 +1927,25 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case CHANGEFIL_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Prepare, PREPARE_CHANGEFIL); break; + case CHANGEFIL_PARKHEAD: + if (draw) + Draw_Menu_Item(row, ICON_Park, GET_TEXT_F(MSG_FILAMENT_PARK_ENABLED)); + else { + #if ENABLED(NOZZLE_PARK_FEATURE) + queue.inject(F("G28O\nG27 P2")); + #else + sprintf_P(cmd, PSTR("G28O\nG0 F4000 X%i Y%i\nG0 F3000 Z%i"), 0 , 0, 20); + queue.inject(cmd); + #endif + } + break; case CHANGEFIL_LOAD: if (draw) - Draw_Menu_Item(row, ICON_WriteEEPROM, F("Load Filament")); + Draw_Menu_Item(row, ICON_WriteEEPROM, GET_TEXT_F(MSG_FILAMENTLOAD)); else { if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) Popup_Handler(ETemp); @@ -1745,7 +1963,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case CHANGEFIL_UNLOAD: if (draw) - Draw_Menu_Item(row, ICON_ReadEEPROM, F("Unload Filament")); + Draw_Menu_Item(row, ICON_ReadEEPROM, GET_TEXT_F(MSG_FILAMENTUNLOAD)); else { if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) { Popup_Handler(ETemp); @@ -1764,7 +1982,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case CHANGEFIL_CHANGE: if (draw) - Draw_Menu_Item(row, ICON_ResumeEEPROM, F("Change Filament")); + Draw_Menu_Item(row, ICON_ResumeEEPROM, GET_TEXT_F(MSG_FILAMENTCHANGE)); else { if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) Popup_Handler(ETemp); @@ -1783,6 +2001,44 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; #endif // FILAMENT_LOAD_UNLOAD_GCODES + #if HAS_HOSTACTION_MENUS + case HostActions: + + #define HOSTACTIONS_BACK 0 + #define HOSTACTIONS_1 (HOSTACTIONS_BACK + 1) + #define HOSTACTIONS_2 (HOSTACTIONS_1 + 1) + #define HOSTACTIONS_3 (HOSTACTIONS_2 + 1) + #define HOSTACTIONS_TOTAL HOSTACTIONS_3 + + switch (item) { + case HOSTACTIONS_BACK: + if (draw) + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); + else { + if (temp_val.flag_tune) { + temp_val.flag_tune = false; + Redraw_Menu(false, true, true); + } + else + Draw_Menu(Prepare, PREPARE_ACTIONCOMMANDS); + } + break; + case HOSTACTIONS_1: + if (draw) Draw_Menu_Item(row, ICON_File, action1); + else if (!strcmp(action1, "-") == 0) hostui.action(F(action1)); + break; + case HOSTACTIONS_2: + if (draw) Draw_Menu_Item(row, ICON_File, action2); + else if (!strcmp(action2, "-") == 0) hostui.action(F(action2)); + break; + case HOSTACTIONS_3: + if (draw) Draw_Menu_Item(row, ICON_File, action3); + else if (!strcmp(action3, "-") == 0) hostui.action(F(action3)); + break; + } + break; + #endif + #if HAS_CUSTOM_MENU case MenuCustom: @@ -1908,70 +2164,104 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #define CONTROL_BACK 0 #define CONTROL_TEMP (CONTROL_BACK + 1) #define CONTROL_MOTION (CONTROL_TEMP + 1) - #define CONTROL_VISUAL (CONTROL_MOTION + 1) - #define CONTROL_ADVANCED (CONTROL_VISUAL + 1) + #define CONTROL_FWRETRACT (CONTROL_MOTION + ENABLED(FWRETRACT)) + #define CONTROL_LEDS (CONTROL_FWRETRACT + ANY(CASE_LIGHT_MENU, LED_CONTROL_MENU)) + #define CONTROL_VISUAL (CONTROL_LEDS + 1) + #define CONTROL_HOSTSETTINGS (CONTROL_VISUAL + ENABLED(HAS_HOSTACTION_MENUS)) + #define CONTROL_ADVANCED (CONTROL_HOSTSETTINGS + 1) #define CONTROL_SAVE (CONTROL_ADVANCED + ENABLED(EEPROM_SETTINGS)) #define CONTROL_RESTORE (CONTROL_SAVE + ENABLED(EEPROM_SETTINGS)) #define CONTROL_RESET (CONTROL_RESTORE + ENABLED(EEPROM_SETTINGS)) - #define CONTROL_INFO (CONTROL_RESET + 1) + #define CONTROL_REBOOT (CONTROL_RESET + 1) + #define CONTROL_INFO (CONTROL_REBOOT + 1) #define CONTROL_TOTAL CONTROL_INFO switch (item) { case CONTROL_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Main_Menu(2); break; case CONTROL_TEMP: if (draw) - Draw_Menu_Item(row, ICON_Temperature, F("Temperature"), nullptr, true); + Draw_Menu_Item(row, ICON_Temperature, GET_TEXT_F(MSG_TEMPERATURE), nullptr, true); else Draw_Menu(TempMenu); break; case CONTROL_MOTION: if (draw) - Draw_Menu_Item(row, ICON_Motion, F("Motion"), nullptr, true); + Draw_Menu_Item(row, ICON_Motion, GET_TEXT_F(MSG_MOTION), nullptr, true); else Draw_Menu(Motion); break; + #if ENABLED(FWRETRACT) + case CONTROL_FWRETRACT: + if (draw) + Draw_Menu_Item(row, ICON_StepE, GET_TEXT_F(MSG_AUTORETRACT), nullptr, true); + else + Draw_Menu(FwRetraction); + break; + #endif + #if ANY(CASE_LIGHT_MENU, LED_CONTROL_MENU) + case CONTROL_LEDS: + if (draw) + Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_LEDS), nullptr, true); + else + Draw_Menu(Ledsmenu); + break; + #endif case CONTROL_VISUAL: if (draw) Draw_Menu_Item(row, ICON_PrintSize, F("Visual"), nullptr, true); else Draw_Menu(Visual); break; + #if HAS_HOSTACTION_MENUS + case CONTROL_HOSTSETTINGS: + if (draw) + Draw_Menu_Item(row, ICON_Contact, F("Host Settings"), nullptr, true); + else + Draw_Menu(HostSettings); + break; + #endif case CONTROL_ADVANCED: if (draw) - Draw_Menu_Item(row, ICON_Version, F("Advanced"), nullptr, true); + Draw_Menu_Item(row, ICON_Version, GET_TEXT_F(MSG_ADVANCED_SETTINGS), nullptr, true); else Draw_Menu(Advanced); break; #if ENABLED(EEPROM_SETTINGS) case CONTROL_SAVE: if (draw) - Draw_Menu_Item(row, ICON_WriteEEPROM, F("Store Settings")); + Draw_Menu_Item(row, ICON_WriteEEPROM, GET_TEXT_F(MSG_STORE_EEPROM)); else AudioFeedback(settings.save()); break; case CONTROL_RESTORE: if (draw) - Draw_Menu_Item(row, ICON_ReadEEPROM, F("Restore Settings")); + Draw_Menu_Item(row, ICON_ReadEEPROM, GET_TEXT_F(MSG_LOAD_EEPROM)); else AudioFeedback(settings.load()); break; case CONTROL_RESET: if (draw) - Draw_Menu_Item(row, ICON_Temperature, F("Reset to Defaults")); + Draw_Menu_Item(row, ICON_Temperature, GET_TEXT_F(MSG_RESTORE_DEFAULTS)); else { settings.reset(); AudioFeedback(); } break; #endif + case CONTROL_REBOOT: + if (draw) + Draw_Menu_Item(row, ICON_Reboot, GET_TEXT_F(MSG_RESET_PRINTER)); + else + RebootPrinter(); + break; case CONTROL_INFO: if (draw) - Draw_Menu_Item(row, ICON_Info, F("Info")); + Draw_Menu_Item(row, ICON_Info, GET_TEXT_F(MSG_INFO_SCREEN)); else Draw_Menu(Info); break; @@ -1995,7 +2285,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case TEMP_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Control, CONTROL_TEMP); break; @@ -2022,7 +2312,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_FAN case TEMP_FAN: if (draw) { - Draw_Menu_Item(row, ICON_FanSpeed, F("Fan")); + Draw_Menu_Item(row, ICON_FanSpeed, GET_TEXT_F(MSG_FAN_SPEED)); Draw_Float(thermalManager.fan_speed[0], row, false, 1); } else @@ -2062,14 +2352,14 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case PID_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(TempMenu, TEMP_PID); break; #if HAS_HOTEND case PID_HOTEND: if (draw) - Draw_Menu_Item(row, ICON_HotendTemp, F("Hotend"), nullptr, true); + Draw_Menu_Item(row, ICON_HotendTemp, F(STR_HOTEND_PID), nullptr, true); else Draw_Menu(HotendPID); break; @@ -2077,14 +2367,14 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_HEATED_BED case PID_BED: if (draw) - Draw_Menu_Item(row, ICON_BedTemp, F("Bed"), nullptr, true); + Draw_Menu_Item(row, ICON_BedTemp, F(STR_BED_PID), nullptr, true); else Draw_Menu(BedPID); break; #endif case PID_CYCLES: if (draw) { - Draw_Menu_Item(row, ICON_FanSpeed, F("Cycles")); + Draw_Menu_Item(row, ICON_FanSpeed, GET_TEXT_F(MSG_PID_CYCLE)); Draw_Float(PID_cycles, row, false, 1); } else @@ -2105,21 +2395,19 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #define HOTENDPID_KD (HOTENDPID_KI + 1) #define HOTENDPID_TOTAL HOTENDPID_KD - static uint16_t PID_e_temp = 180; - switch (item) { case HOTENDPID_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(PID, PID_HOTEND); break; case HOTENDPID_TUNE: if (draw) - Draw_Menu_Item(row, ICON_HotendTemp, F("Autotune")); + Draw_Menu_Item(row, ICON_HotendTemp, GET_TEXT_F(MSG_PID_AUTOTUNE)); else { Popup_Handler(PIDWait); - sprintf_P(cmd, PSTR("M303 E0 C%i S%i U1"), PID_cycles, PID_e_temp); + sprintf_P(cmd, PSTR("M303 E0 C%i S%i U1"), PID_cycles, temp_val.PID_e_temp); gcode.process_subcommands_now(cmd); planner.synchronize(); Redraw_Menu(); @@ -2127,11 +2415,11 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case HOTENDPID_TEMP: if (draw) { - Draw_Menu_Item(row, ICON_Temperature, F("Temperature")); - Draw_Float(PID_e_temp, row, false, 1); + Draw_Menu_Item(row, ICON_Temperature, GET_TEXT_F(MSG_TEMPERATURE)); + Draw_Float(temp_val.PID_e_temp, row, false, 1); } else - Modify_Value(PID_e_temp, MIN_E_TEMP, MAX_E_TEMP, 1); + Modify_Value(temp_val.PID_e_temp, MIN_E_TEMP, MAX_E_TEMP, 1); break; case HOTENDPID_KP: if (draw) { @@ -2172,21 +2460,19 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #define BEDPID_KD (BEDPID_KI + 1) #define BEDPID_TOTAL BEDPID_KD - static uint16_t PID_bed_temp = 60; - switch (item) { case BEDPID_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(PID, PID_BED); break; case BEDPID_TUNE: if (draw) - Draw_Menu_Item(row, ICON_HotendTemp, F("Autotune")); + Draw_Menu_Item(row, ICON_HotendTemp, GET_TEXT_F(MSG_PID_AUTOTUNE)); else { Popup_Handler(PIDWait); - sprintf_P(cmd, PSTR("M303 E-1 C%i S%i U1"), PID_cycles, PID_bed_temp); + sprintf_P(cmd, PSTR("M303 E-1 C%i S%i U1"), PID_cycles, temp_val.PID_bed_temp); gcode.process_subcommands_now(cmd); planner.synchronize(); Redraw_Menu(); @@ -2194,20 +2480,19 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case BEDPID_TEMP: if (draw) { - Draw_Menu_Item(row, ICON_Temperature, F("Temperature")); - Draw_Float(PID_bed_temp, row, false, 1); + Draw_Menu_Item(row, ICON_Temperature, GET_TEXT_F(MSG_TEMPERATURE)); + Draw_Float(temp_val.PID_bed_temp, row, false, 1); } else - Modify_Value(PID_bed_temp, MIN_BED_TEMP, MAX_BED_TEMP, 1); + Modify_Value(temp_val.PID_bed_temp, MIN_BED_TEMP, MAX_BED_TEMP, 1); break; case BEDPID_KP: if (draw) { Draw_Menu_Item(row, ICON_Version, F("Kp Value")); Draw_Float(thermalManager.temp_bed.pid.Kp, row, false, 100); } - else { + else Modify_Value(thermalManager.temp_bed.pid.Kp, 0, 5000, 100, thermalManager.updatePID); - } break; case BEDPID_KI: if (draw) { @@ -2241,53 +2526,62 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #define MOTION_SPEED (MOTION_HOMEOFFSETS + 1) #define MOTION_ACCEL (MOTION_SPEED + 1) #define MOTION_JERK (MOTION_ACCEL + ENABLED(HAS_CLASSIC_JERK)) - #define MOTION_STEPS (MOTION_JERK + 1) + #define MOTION_JD (MOTION_JERK + ENABLED(HAS_JUNCTION_DEVIATION)) + #define MOTION_STEPS (MOTION_JD + 1) #define MOTION_FLOW (MOTION_STEPS + ENABLED(HAS_HOTEND)) #define MOTION_TOTAL MOTION_FLOW switch (item) { case MOTION_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Control, CONTROL_MOTION); break; case MOTION_HOMEOFFSETS: if (draw) - Draw_Menu_Item(row, ICON_SetHome, F("Home Offsets"), nullptr, true); + Draw_Menu_Item(row, ICON_SetHome, GET_TEXT_F(MSG_SET_HOME_OFFSETS), nullptr, true); else Draw_Menu(HomeOffsets); break; case MOTION_SPEED: if (draw) - Draw_Menu_Item(row, ICON_MaxSpeed, F("Max Speed"), nullptr, true); + Draw_Menu_Item(row, ICON_MaxSpeed, GET_TEXT_F(MSG_MAX_SPEED), nullptr, true); else Draw_Menu(MaxSpeed); break; case MOTION_ACCEL: if (draw) - Draw_Menu_Item(row, ICON_MaxAccelerated, F("Max Acceleration"), nullptr, true); + Draw_Menu_Item(row, ICON_MaxAccelerated, GET_TEXT_F(MSG_AMAX_EN), nullptr, true); else Draw_Menu(MaxAcceleration); break; #if HAS_CLASSIC_JERK case MOTION_JERK: if (draw) - Draw_Menu_Item(row, ICON_MaxJerk, F("Max Jerk"), nullptr, true); + Draw_Menu_Item(row, ICON_MaxJerk, GET_TEXT_F(MSG_JERK), nullptr, true); else Draw_Menu(MaxJerk); break; #endif + #if HAS_JUNCTION_DEVIATION + case MOTION_JD: + if (draw) + Draw_Menu_Item(row, ICON_MaxJerk, GET_TEXT_F(MSG_JUNCTION_DEVIATION), nullptr, true); + else + Draw_Menu(JDmenu); + break; + #endif case MOTION_STEPS: if (draw) - Draw_Menu_Item(row, ICON_Step, F("Steps/mm"), nullptr, true); + Draw_Menu_Item(row, ICON_Step, GET_TEXT_F(MSG_STEPS_PER_MM), nullptr, true); else Draw_Menu(Steps); break; #if HAS_HOTEND case MOTION_FLOW: if (draw) { - Draw_Menu_Item(row, ICON_Speed, F("Flow Rate")); + Draw_Menu_Item(row, ICON_Speed, GET_TEXT_F(MSG_FLOW)); Draw_Float(planner.flow_percentage[0], row, false, 1); } else @@ -2297,31 +2591,124 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ } break; - case HomeOffsets: + #if ENABLED(FWRETRACT) + case FwRetraction: - #define HOMEOFFSETS_BACK 0 - #define HOMEOFFSETS_XOFFSET (HOMEOFFSETS_BACK + 1) - #define HOMEOFFSETS_YOFFSET (HOMEOFFSETS_XOFFSET + 1) - #define HOMEOFFSETS_TOTAL HOMEOFFSETS_YOFFSET + #define FWR_BACK 0 + #define FWR_RET_AUTO (FWR_BACK + 1) + #define FWR_RET_LENGTH (FWR_RET_AUTO + 1) + #define FWR_RET_SPEED (FWR_RET_LENGTH + 1) + #define FWR_ZLIFT (FWR_RET_SPEED + 1) + #define FWR_REC_EXT_LENGTH (FWR_ZLIFT + 1) + #define FWR_REC_SPEED (FWR_REC_EXT_LENGTH + 1) + #define FWR_RESET (FWR_REC_SPEED + 1) + #define FWR_TOTAL FWR_RESET - switch (item) { - case HOMEOFFSETS_BACK: + switch (item) { + + case FWR_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); - else - Draw_Menu(Motion, MOTION_HOMEOFFSETS); - break; - case HOMEOFFSETS_XOFFSET: - if (draw) { - Draw_Menu_Item(row, ICON_StepX, F("X Offset")); - Draw_Float(home_offset.x, row, false, 100); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); + else { + if (temp_val.flag_tune) { + temp_val.flag_tune = false; + Redraw_Menu(false, true, true); + } + else + Draw_Menu(Control, CONTROL_FWRETRACT); } - else - Modify_Value(home_offset.x, -MAX_XY_OFFSET, MAX_XY_OFFSET, 100); + break; + case FWR_RET_AUTO: + if (draw) { + temp_val.auto_fw_retract = fwretract.autoretract_enabled; + Draw_Menu_Item(row, ICON_StepE, GET_TEXT_F(MSG_AUTORETRACT)); + Draw_Checkbox(row, temp_val.auto_fw_retract); + } + else { + if (MIN_AUTORETRACT <= MAX_AUTORETRACT) { + temp_val.auto_fw_retract = !temp_val.auto_fw_retract; + fwretract.enable_autoretract(temp_val.auto_fw_retract); + Draw_Checkbox(row, temp_val.auto_fw_retract); + } + } + break; + case FWR_RET_LENGTH: + if (draw) { + Draw_Menu_Item(row, ICON_FWRetLength, GET_TEXT_F(MSG_CONTROL_RETRACT)); + Draw_Float(fwretract.settings.retract_length, row, false, 10); + } + else + Modify_Value(fwretract.settings.retract_length, 0, 10, 10); + break; + case FWR_RET_SPEED: + if (draw) { + Draw_Menu_Item(row, ICON_FWRetSpeed, GET_TEXT_F(MSG_SINGLENOZZLE_RETRACT_SPEED)); + Draw_Float(fwretract.settings.retract_feedrate_mm_s, row, false, 10); + } + else + Modify_Value(fwretract.settings.retract_feedrate_mm_s, 1, 90, 10); + break; + case FWR_ZLIFT: + if (draw) { + Draw_Menu_Item(row, ICON_FWRetZRaise, GET_TEXT_F(MSG_CONTROL_RETRACT_ZHOP)); + Draw_Float(fwretract.settings.retract_zraise, row, false, 100); + } + else + Modify_Value(fwretract.settings.retract_zraise, 0, 10, 100); + break; + case FWR_REC_EXT_LENGTH: + if (draw) { + Draw_Menu_Item(row, ICON_FWRecExtLength, GET_TEXT_F(MSG_CONTROL_RETRACT_RECOVER)); + Draw_Float(fwretract.settings.retract_recover_extra, row, false, 10); + } + else + Modify_Value(fwretract.settings.retract_recover_extra, -10, 10, 10); + break; + case FWR_REC_SPEED: + if (draw) { + Draw_Menu_Item(row, ICON_FWRecSpeed, GET_TEXT_F(MSG_SINGLENOZZLE_UNRETRACT_SPEED)); + Draw_Float(fwretract.settings.retract_recover_feedrate_mm_s, row, false, 10); + } + else + Modify_Value(fwretract.settings.retract_recover_feedrate_mm_s, 1, 90, 10); + break; + case FWR_RESET: + if (draw) + Draw_Menu_Item(row, ICON_StepE, GET_TEXT_F(MSG_BUTTON_RESET)); + else { + fwretract.reset(); + Draw_Menu(FwRetraction); + } + break; + } + break; + #endif + + case HomeOffsets: + + #define HOMEOFFSETS_BACK 0 + #define HOMEOFFSETS_XOFFSET (HOMEOFFSETS_BACK + 1) + #define HOMEOFFSETS_YOFFSET (HOMEOFFSETS_XOFFSET + 1) + #define HOMEOFFSETS_TOTAL HOMEOFFSETS_YOFFSET + + switch (item) { + case HOMEOFFSETS_BACK: + if (draw) + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); + else + Draw_Menu(Motion, MOTION_HOMEOFFSETS); + break; + case HOMEOFFSETS_XOFFSET: + if (draw) { + Draw_Menu_Item(row, ICON_StepX, GET_TEXT_F(MSG_HOME_OFFSET_X)); + Draw_Float(home_offset.x, row, false, 100); + } + else + Modify_Value(home_offset.x, -MAX_XY_OFFSET, MAX_XY_OFFSET, 100); break; case HOMEOFFSETS_YOFFSET: if (draw) { - Draw_Menu_Item(row, ICON_StepY, F("Y Offset")); + Draw_Menu_Item(row, ICON_StepY, GET_TEXT_F(MSG_HOME_OFFSET_Y)); Draw_Float(home_offset.y, row, false, 100); } else @@ -2341,13 +2728,13 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case SPEED_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Motion, MOTION_SPEED); break; case SPEED_X: if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeedX, F("X Axis")); + Draw_Menu_Item(row, ICON_MaxSpeedX, GET_TEXT_F(MSG_VMAX_A)); Draw_Float(planner.settings.max_feedrate_mm_s[X_AXIS], row, false, 1); } else @@ -2357,7 +2744,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_Y_AXIS case SPEED_Y: if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeedY, F("Y Axis")); + Draw_Menu_Item(row, ICON_MaxSpeedY, GET_TEXT_F(MSG_VMAX_B)); Draw_Float(planner.settings.max_feedrate_mm_s[Y_AXIS], row, false, 1); } else @@ -2368,7 +2755,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_Z_AXIS case SPEED_Z: if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeedZ, F("Z Axis")); + Draw_Menu_Item(row, ICON_MaxSpeedZ, GET_TEXT_F(MSG_VMAX_C)); Draw_Float(planner.settings.max_feedrate_mm_s[Z_AXIS], row, false, 1); } else @@ -2379,7 +2766,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_HOTEND case SPEED_E: if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeedE, F("Extruder")); + Draw_Menu_Item(row, ICON_MaxSpeedE, GET_TEXT_F(MSG_VMAX_E)); Draw_Float(planner.settings.max_feedrate_mm_s[E_AXIS], row, false, 1); } else @@ -2401,13 +2788,13 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case ACCEL_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Motion, MOTION_ACCEL); break; case ACCEL_X: if (draw) { - Draw_Menu_Item(row, ICON_MaxAccX, F("X Axis")); + Draw_Menu_Item(row, ICON_MaxAccX, GET_TEXT_F(MSG_AMAX_A)); Draw_Float(planner.settings.max_acceleration_mm_per_s2[X_AXIS], row, false, 1); } else @@ -2415,7 +2802,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case ACCEL_Y: if (draw) { - Draw_Menu_Item(row, ICON_MaxAccY, F("Y Axis")); + Draw_Menu_Item(row, ICON_MaxAccY, GET_TEXT_F(MSG_AMAX_B)); Draw_Float(planner.settings.max_acceleration_mm_per_s2[Y_AXIS], row, false, 1); } else @@ -2423,7 +2810,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case ACCEL_Z: if (draw) { - Draw_Menu_Item(row, ICON_MaxAccZ, F("Z Axis")); + Draw_Menu_Item(row, ICON_MaxAccZ, GET_TEXT_F(MSG_AMAX_C)); Draw_Float(planner.settings.max_acceleration_mm_per_s2[Z_AXIS], row, false, 1); } else @@ -2432,7 +2819,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_HOTEND case ACCEL_E: if (draw) { - Draw_Menu_Item(row, ICON_MaxAccE, F("Extruder")); + Draw_Menu_Item(row, ICON_MaxAccE, GET_TEXT_F(MSG_AMAX_E)); Draw_Float(planner.settings.max_acceleration_mm_per_s2[E_AXIS], row, false, 1); } else @@ -2454,13 +2841,13 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case JERK_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Motion, MOTION_JERK); break; case JERK_X: if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeedJerkX, F("X Axis")); + Draw_Menu_Item(row, ICON_MaxSpeedJerkX, GET_TEXT_F(MSG_VA_JERK)); Draw_Float(planner.max_jerk[X_AXIS], row, false, 10); } else @@ -2468,7 +2855,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case JERK_Y: if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeedJerkY, F("Y Axis")); + Draw_Menu_Item(row, ICON_MaxSpeedJerkY, GET_TEXT_F(MSG_VB_JERK)); Draw_Float(planner.max_jerk[Y_AXIS], row, false, 10); } else @@ -2476,7 +2863,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case JERK_Z: if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeedJerkZ, F("Z Axis")); + Draw_Menu_Item(row, ICON_MaxSpeedJerkZ, GET_TEXT_F(MSG_VC_JERK)); Draw_Float(planner.max_jerk[Z_AXIS], row, false, 10); } else @@ -2485,7 +2872,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_HOTEND case JERK_E: if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeedJerkE, F("Extruder")); + Draw_Menu_Item(row, ICON_MaxSpeedJerkE, GET_TEXT_F(MSG_VE_JERK)); Draw_Float(planner.max_jerk[E_AXIS], row, false, 10); } else @@ -2495,6 +2882,33 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ } break; #endif + #if HAS_JUNCTION_DEVIATION + case JDmenu: + + #define JD_BACK 0 + #define JD_SETTING_JD_MM (JD_BACK + ENABLED(HAS_HOTEND)) + #define JD_TOTAL JD_SETTING_JD_MM + + switch (item) { + case JD_BACK: + if (draw) + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); + else + Draw_Menu(Motion, MOTION_JD); + break; + #if HAS_HOTEND + case JD_SETTING_JD_MM: + if (draw) { + Draw_Menu_Item(row, ICON_MaxJerk, GET_TEXT_F(MSG_JUNCTION_DEVIATION)); + Draw_Float(planner.junction_deviation_mm, row, false, 100); + } + else + Modify_Value(planner.junction_deviation_mm, MIN_JD_MM, MAX_JD_MM, 100); + break; + #endif + } + break; + #endif case Steps: #define STEPS_BACK 0 @@ -2507,13 +2921,13 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case STEPS_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Motion, MOTION_STEPS); break; case STEPS_X: if (draw) { - Draw_Menu_Item(row, ICON_StepX, F("X Axis")); + Draw_Menu_Item(row, ICON_StepX, GET_TEXT_F(MSG_A_STEPS)); Draw_Float(planner.settings.axis_steps_per_mm[X_AXIS], row, false, 10); } else @@ -2521,7 +2935,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case STEPS_Y: if (draw) { - Draw_Menu_Item(row, ICON_StepY, F("Y Axis")); + Draw_Menu_Item(row, ICON_StepY, GET_TEXT_F(MSG_B_STEPS)); Draw_Float(planner.settings.axis_steps_per_mm[Y_AXIS], row, false, 10); } else @@ -2529,7 +2943,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case STEPS_Z: if (draw) { - Draw_Menu_Item(row, ICON_StepZ, F("Z Axis")); + Draw_Menu_Item(row, ICON_StepZ, GET_TEXT_F(MSG_C_STEPS)); Draw_Float(planner.settings.axis_steps_per_mm[Z_AXIS], row, false, 10); } else @@ -2538,7 +2952,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_HOTEND case STEPS_E: if (draw) { - Draw_Menu_Item(row, ICON_StepE, F("Extruder")); + Draw_Menu_Item(row, ICON_StepE, GET_TEXT_F(MSG_E_STEPS)); Draw_Float(planner.settings.axis_steps_per_mm[E_AXIS], row, false, 10); } else @@ -2548,6 +2962,235 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ } break; + #if ANY(CASE_LIGHT_MENU, LED_CONTROL_MENU) + case Ledsmenu: + + #define LEDS_BACK 0 + #define LEDS_CASELIGHT (LEDS_BACK + ENABLED(CASE_LIGHT_MENU)) + #define LEDS_LED_CONTROL_MENU (LEDS_CASELIGHT + ENABLED(LED_CONTROL_MENU)) + #define LEDS_TOTAL LEDS_LED_CONTROL_MENU + + switch (item) { + + case LEDS_BACK: + if (draw) + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); + else + Draw_Menu(Control, CONTROL_LEDS); + break; + #if ENABLED(CASE_LIGHT_MENU) + case LEDS_CASELIGHT: + if (draw) { + #if ENABLED(CASELIGHT_USES_BRIGHTNESS) + Draw_Menu_Item(row, ICON_CaseLight, GET_TEXT_F(MSG_CASE_LIGHT), nullptr, true); + #else + Draw_Menu_Item(row, ICON_CaseLight, GET_TEXT_F(MSG_CASE_LIGHT)); + Draw_Checkbox(row, caselight.on); + #endif + } + else { + #if ENABLED(CASELIGHT_USES_BRIGHTNESS) + Draw_Menu(CaseLightmenu); + #else + caselight.on = !caselight.on; + caselight.update_enabled(); + Draw_Checkbox(row, caselight.on); + DWIN_UpdateLCD(); + #endif + } + break; + #endif + #if ENABLED(LED_CONTROL_MENU) + case LEDS_LED_CONTROL_MENU: + if (draw) + Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_LED_CONTROL), nullptr, true); + else + Draw_Menu(LedControlmenu); + break; + #endif + } + break; + #endif + + #if ENABLED(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) + case CaseLightmenu: + + #define CASE_LIGHT_BACK 0 + #define CASE_LIGHT_ON (CASE_LIGHT_BACK + 1) + #define CASE_LIGHT_USES_BRIGHT (CASE_LIGHT_ON + 1) + #define CASE_LIGHT_TOTAL CASE_LIGHT_USES_BRIGHT + + switch (item) { + + case CASE_LIGHT_BACK: + if (draw) + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); + else + Draw_Menu(Ledsmenu, LEDS_CASELIGHT); + break; + case CASE_LIGHT_ON: + if (draw) { + Draw_Menu_Item(row, ICON_CaseLight, GET_TEXT_F(MSG_CASE_LIGHT)); + Draw_Checkbox(row, caselight.on); + } + else { + caselight.on = !caselight.on; + caselight.update_enabled(); + Draw_Checkbox(row, caselight.on); + DWIN_UpdateLCD(); + } + break; + case CASE_LIGHT_USES_BRIGHT: + if (draw) { + Draw_Menu_Item(row, ICON_Brightness, GET_TEXT_F(MSG_CASE_LIGHT_BRIGHTNESS)); + Draw_Float(caselight.brightness, row); + } + else + Modify_Value(caselight.brightness, 0, 255, 1); + break; + } + break; + #endif + + #if ENABLED(LED_CONTROL_MENU) + case LedControlmenu: + + #define LEDCONTROL_BACK 0 + #define LEDCONTROL_LIGHTON (LEDCONTROL_BACK + !BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL)) + #define LEDCONTROL_PRESETS_MENU (LEDCONTROL_LIGHTON + BOTH(HAS_COLOR_LEDS, LED_COLOR_PRESETS)) + #define LEDCONTROL_CUSTOM_MENU (LEDCONTROL_PRESETS_MENU + ENABLED(HAS_COLOR_LEDS) - DISABLED(LED_COLOR_PRESETS)) + #define LEDCONTROL_TOTAL LEDCONTROL_CUSTOM_MENU + + switch (item) { + case LEDCONTROL_BACK: + if (draw) + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); + else + Draw_Menu(Ledsmenu, LEDS_LED_CONTROL_MENU); + break; + #if !BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL) + case LEDCONTROL_LIGHTON: + if (draw) { + Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_LEDS)); + Draw_Checkbox(row, leds.lights_on); + } + else { + leds.toggle(); + Draw_Checkbox(row, leds.lights_on); + DWIN_UpdateLCD(); + } + break; + #endif + #if HAS_COLOR_LEDS + #if ENABLED(LED_COLOR_PRESETS) + case LEDCONTROL_PRESETS_MENU: + if (draw) + Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_LED_PRESETS)); + else + Draw_Menu(LedControlpresets); + break; + #else + case LEDCONTROL_CUSTOM_MENU: + if (draw) + Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_CUSTOM_LEDS)); + else + Draw_Menu(LedControlcustom); + break; + #endif + #endif + } + break; + + #if HAS_COLOR_LEDS + #if ENABLED(LED_COLOR_PRESETS) + case LedControlpresets: + + #define LEDCONTROL_PRESETS_BACK 0 + #define LEDCONTROL_PRESETS_WHITE (LEDCONTROL_PRESETS_BACK + 1) + #define LEDCONTROL_PRESETS_RED (LEDCONTROL_PRESETS_WHITE + 1) + #define LEDCONTROL_PRESETS_ORANGE (LEDCONTROL_PRESETS_RED + 1) + #define LEDCONTROL_PRESETS_YELLOW (LEDCONTROL_PRESETS_ORANGE + 1) + #define LEDCONTROL_PRESETS_GREEN (LEDCONTROL_PRESETS_YELLOW + 1) + #define LEDCONTROL_PRESETS_BLUE (LEDCONTROL_PRESETS_GREEN + 1) + #define LEDCONTROL_PRESETS_INDIGO (LEDCONTROL_PRESETS_BLUE + 1) + #define LEDCONTROL_PRESETS_VIOLET (LEDCONTROL_PRESETS_INDIGO + 1) + #define LEDCONTROL_PRESETS_TOTAL LEDCONTROL_PRESETS_VIOLET + + #define LEDCOLORITEM(MSG,FUNC) if (draw) Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG)); else FUNC; break; + + switch (item) { + case LEDCONTROL_PRESETS_BACK: + if (draw) + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); + else + Draw_Menu(LedControlmenu, LEDCONTROL_PRESETS_MENU); + break; + case LEDCONTROL_PRESETS_WHITE: LEDCOLORITEM(MSG_SET_LEDS_WHITE, leds.set_white()); + case LEDCONTROL_PRESETS_RED: LEDCOLORITEM(MSG_SET_LEDS_RED, leds.set_red()); + case LEDCONTROL_PRESETS_ORANGE: LEDCOLORITEM(MSG_SET_LEDS_ORANGE, leds.set_orange()); + case LEDCONTROL_PRESETS_YELLOW: LEDCOLORITEM(MSG_SET_LEDS_YELLOW, leds.set_yellow()); + case LEDCONTROL_PRESETS_GREEN: LEDCOLORITEM(MSG_SET_LEDS_GREEN, leds.set_green()); + case LEDCONTROL_PRESETS_BLUE: LEDCOLORITEM(MSG_SET_LEDS_BLUE, leds.set_blue()); + case LEDCONTROL_PRESETS_INDIGO: LEDCOLORITEM(MSG_SET_LEDS_INDIGO, leds.set_indigo()); + case LEDCONTROL_PRESETS_VIOLET: LEDCOLORITEM(MSG_SET_LEDS_VIOLET, leds.set_violet()); + } + break; + #else + case LedControlcustom: + + #define LEDCONTROL_CUSTOM_BACK 0 + #define LEDCONTROL_CUSTOM_RED (LEDCONTROL_CUSTOM_BACK + 1) + #define LEDCONTROL_CUSTOM_GREEN (LEDCONTROL_CUSTOM_RED + 1) + #define LEDCONTROL_CUSTOM_BLUE (LEDCONTROL_CUSTOM_GREEN + 1) + #define LEDCONTROL_CUSTOM_WHITE (LEDCONTROL_CUSTOM_BLUE + ENABLED(HAS_WHITE_LED)) + #define LEDCONTROL_CUSTOM_TOTAL LEDCONTROL_CUSTOM_WHITE + + switch (item) { + case LEDCONTROL_PRESETS_BACK: + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); + else + Draw_Menu(LedControlmenu, LEDCONTROL_CUSTOM_MENU); + break; + case LEDCONTROL_CUSTOM_RED: + if (draw) { + Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_INTENSITY_R)); + Draw_Float(leds.color.r, row); + } + else + Modify_Value(leds.color.r, 0, 255, 1); + break; + case LEDCONTROL_CUSTOM_GREEN: + if (draw) { + Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_INTENSITY_G)); + Draw_Float(leds.color.g, row); + } + else + Modify_Value(leds.color.g, 0, 255, 1); + break; + case LEDCONTROL_CUSTOM_BLUE: + if (draw) { + Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_INTENSITY_B)); + Draw_Float(leds.color.b, row); + } + else + Modify_Value(leds.color.b, 0, 255, 1); + break; + #if HAS_WHITE_LED + case case LEDCONTROL_CUSTOM_WHITE: + if (draw) { + Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_INTENSITY_W)); + Draw_Float(leds.color.w, row); + } + else + Modify_Value(leds.color.w, 0, 255, 1); + break; + #endif + } + break; + #endif + #endif + #endif + case Visual: #define VISUAL_BACK 0 @@ -2560,19 +3203,19 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case VISUAL_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Control, CONTROL_VISUAL); break; case VISUAL_BACKLIGHT: if (draw) - Draw_Menu_Item(row, ICON_Brightness, F("Display Off")); + Draw_Menu_Item(row, ICON_Brightness, GET_TEXT_F(MSG_BRIGHTNESS_OFF)); else ui.set_brightness(0); break; case VISUAL_BRIGHTNESS: if (draw) { - Draw_Menu_Item(row, ICON_Brightness, F("LCD Brightness")); + Draw_Menu_Item(row, ICON_Brightness, GET_TEXT_F(MSG_BRIGHTNESS)); Draw_Float(ui.brightness, row, false, 1); } else @@ -2590,7 +3233,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case VISUAL_COLOR_THEMES: if (draw) - Draw_Menu_Item(row, ICON_MaxSpeed, F("UI Color Settings"), nullptr, true); + Draw_Menu_Item(row, ICON_MaxSpeed, GET_TEXT_F(MSG_COLORS_SELECT), nullptr, true); else Draw_Menu(ColorSettings); break; @@ -2616,7 +3259,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case COLORSETTINGS_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Visual, VISUAL_COLOR_THEMES); break; @@ -2711,6 +3354,70 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ } // switch (item) break; + #if HAS_HOSTACTION_MENUS + case HostSettings: + + #define HOSTSETTINGS_BACK 0 + #define HOSTSETTINGS_ACTIONCOMMANDS (HOSTSETTINGS_BACK + 1) + #define HOSTSETTINGS_TOTAL HOSTSETTINGS_ACTIONCOMMANDS + + switch (item) { + case HOSTSETTINGS_BACK: + if (draw) + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); + else + Draw_Menu(Control, CONTROL_HOSTSETTINGS); + break; + case HOSTSETTINGS_ACTIONCOMMANDS: + if (draw) Draw_Menu_Item(row, ICON_File, F("Host Actions")); + else Draw_Menu(ActionCommands); + break; + } + break; + + case ActionCommands: + + #define ACTIONCOMMANDS_BACK 0 + #define ACTIONCOMMANDS_1 (ACTIONCOMMANDS_BACK + 1) + #define ACTIONCOMMANDS_2 (ACTIONCOMMANDS_1 + 1) + #define ACTIONCOMMANDS_3 (ACTIONCOMMANDS_2 + 1) + #define ACTIONCOMMANDS_TOTAL ACTIONCOMMANDS_3 + + switch (item) { + case ACTIONCOMMANDS_BACK: + if (draw) + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); + else + Draw_Menu(HostSettings, HOSTSETTINGS_ACTIONCOMMANDS); + break; + case ACTIONCOMMANDS_1: + if (draw) { + Draw_Menu_Item(row, ICON_File, F("Action #1")); + Draw_String(action1, row); + } + else + Modify_String(action1, 8, true); + break; + case ACTIONCOMMANDS_2: + if (draw) { + Draw_Menu_Item(row, ICON_File, F("Action #2")); + Draw_String(action2, row); + } + else + Modify_String(action2, 8, true); + break; + case ACTIONCOMMANDS_3: + if (draw) { + Draw_Menu_Item(row, ICON_File, F("Action #3")); + Draw_String(action3, row); + } + else + Modify_String(action3, 8, true); + break; + } + break; + #endif + case Advanced: #define ADVANCED_BACK 0 @@ -2724,12 +3431,15 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #define ADVANCED_FILSENSORENABLED (ADVANCED_COLD_EXTRUDE + ENABLED(FILAMENT_RUNOUT_SENSOR)) #define ADVANCED_FILSENSORDISTANCE (ADVANCED_FILSENSORENABLED + ENABLED(HAS_FILAMENT_RUNOUT_DISTANCE)) #define ADVANCED_POWER_LOSS (ADVANCED_FILSENSORDISTANCE + ENABLED(POWER_LOSS_RECOVERY)) - #define ADVANCED_TOTAL ADVANCED_POWER_LOSS + #define ADVANCED_BAUDRATE_MODE (ADVANCED_POWER_LOSS + ENABLED(BAUD_RATE_GCODE)) + #define ADVANCED_ESDIAG (ADVANCED_BAUDRATE_MODE + ENABLED(HAS_ESDIAG)) + #define ADVANCED_LOCKSCREEN (ADVANCED_ESDIAG + ENABLED(HAS_LOCKSCREEN)) + #define ADVANCED_TOTAL ADVANCED_LOCKSCREEN switch (item) { case ADVANCED_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Control, CONTROL_ADVANCED); break; @@ -2737,7 +3447,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if ENABLED(SOUND_MENU_ITEM) case ADVANCED_BEEPER: if (draw) { - Draw_Menu_Item(row, ICON_Version, F("LCD Beeper")); + Draw_Menu_Item(row, ICON_Sound, GET_TEXT_F(MSG_SOUND_ENABLE)); Draw_Checkbox(row, ui.sound_on); } else { @@ -2750,7 +3460,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_BED_PROBE case ADVANCED_PROBE: if (draw) - Draw_Menu_Item(row, ICON_StepX, F("Probe"), nullptr, true); + Draw_Menu_Item(row, ICON_ProbeSet, GET_TEXT_F(MSG_ZPROBE_SETTINGS), nullptr, true); else Draw_Menu(ProbeMenu); break; @@ -2759,16 +3469,16 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case ADVANCED_CORNER: if (draw) { Draw_Menu_Item(row, ICON_MaxAccelerated, F("Bed Screw Inset")); - Draw_Float(corner_pos, row, false, 10); + Draw_Float(temp_val.corner_pos, row, false, 10); } else - Modify_Value(corner_pos, 1, 100, 10); + Modify_Value(temp_val.corner_pos, 1, 100, 10); break; #if ENABLED(LIN_ADVANCE) case ADVANCED_LA: if (draw) { - Draw_Menu_Item(row, ICON_MaxAccelerated, F("Lin Advance Kp")); + Draw_Menu_Item(row, ICON_MaxAccelerated, GET_TEXT_F(MSG_ADVANCE_K_E)); Draw_Float(planner.extruder_advance_K[0], row, false, 100); } else @@ -2779,7 +3489,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if ENABLED(ADVANCED_PAUSE_FEATURE) case ADVANCED_LOAD: if (draw) { - Draw_Menu_Item(row, ICON_WriteEEPROM, F("Load Length")); + Draw_Menu_Item(row, ICON_WriteEEPROM, GET_TEXT_F(MSG_FILAMENT_LOAD)); Draw_Float(fc_settings[0].load_length, row, false, 1); } else @@ -2787,7 +3497,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case ADVANCED_UNLOAD: if (draw) { - Draw_Menu_Item(row, ICON_ReadEEPROM, F("Unload Length")); + Draw_Menu_Item(row, ICON_ReadEEPROM, GET_TEXT_F(MSG_FILAMENT_UNLOAD)); Draw_Float(fc_settings[0].unload_length, row, false, 1); } else @@ -2811,7 +3521,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if ENABLED(FILAMENT_RUNOUT_SENSOR) case ADVANCED_FILSENSORENABLED: if (draw) { - Draw_Menu_Item(row, ICON_Extruder, F("Filament Sensor")); + Draw_Menu_Item(row, ICON_Extruder, GET_TEXT_F(MSG_RUNOUT_ENABLE)); Draw_Checkbox(row, runout.enabled); } else { @@ -2823,7 +3533,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if ENABLED(HAS_FILAMENT_RUNOUT_DISTANCE) case ADVANCED_FILSENSORDISTANCE: if (draw) { - Draw_Menu_Item(row, ICON_MaxAccE, F("Runout Distance")); + Draw_Menu_Item(row, ICON_MaxAccE, GET_TEXT_F(MSG_RUNOUT_DISTANCE_MM)); Draw_Float(runout.runout_distance(), row, false, 10); } else @@ -2835,7 +3545,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if ENABLED(POWER_LOSS_RECOVERY) case ADVANCED_POWER_LOSS: if (draw) { - Draw_Menu_Item(row, ICON_Motion, F("Power-loss recovery")); + Draw_Menu_Item(row, ICON_Motion, GET_TEXT_F(MSG_OUTAGE_RECOVERY)); Draw_Checkbox(row, recovery.enabled); } else { @@ -2844,6 +3554,34 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ } break; #endif + #if ENABLED(BAUD_RATE_GCODE) + case ADVANCED_BAUDRATE_MODE: + if (draw) { + Draw_Menu_Item(row, ICON_Setspeed, F("115k Baud")); + Draw_Checkbox(row, eeprom_settings.Baud115k); + } + else { + eeprom_settings.Baud115k = !eeprom_settings.Baud115k; + queue.inject(eeprom_settings.Baud115k ? F("M575 P0 B115200") : F("M575 P0 B250000")); + } + break; + #endif + #if HAS_ESDIAG + case ADVANCED_ESDIAG: + if (draw) + Draw_Menu_Item(row, ICON_ESDiag, F("End-stops diagnostic")); + else + DWIN_EndstopsDiag(); + break; + #endif + #if HAS_LOCKSCREEN + case ADVANCED_LOCKSCREEN: + if (draw) + Draw_Menu_Item(row, ICON_Lock, GET_TEXT_F(MSG_LOCKSCREEN)); + else + DWIN_LockScreen(); + break; + #endif } break; @@ -2853,7 +3591,12 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #define PROBE_BACK 0 #define PROBE_XOFFSET (PROBE_BACK + 1) #define PROBE_YOFFSET (PROBE_XOFFSET + 1) - #define PROBE_TEST (PROBE_YOFFSET + 1) + #define PROBE_ZOFFSET (PROBE_YOFFSET + 1) + #define PROBE_HSMODE (PROBE_ZOFFSET + ENABLED(BLTOUCH)) + #define PROBE_ALARMR (PROBE_HSMODE + ENABLED(BLTOUCH)) + #define PROBE_SELFTEST (PROBE_ALARMR + ENABLED(BLTOUCH)) + #define PROBE_MOVEP (PROBE_SELFTEST + ENABLED(BLTOUCH)) + #define PROBE_TEST (PROBE_MOVEP + 1) #define PROBE_TEST_COUNT (PROBE_TEST + 1) #define PROBE_TOTAL PROBE_TEST_COUNT @@ -2862,43 +3605,91 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case PROBE_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Advanced, ADVANCED_PROBE); break; - - case PROBE_XOFFSET: + case PROBE_XOFFSET: + if (draw) { + Draw_Menu_Item(row, ICON_StepX, GET_TEXT_F(MSG_ZPROBE_XOFFSET)); + Draw_Float(probe.offset.x, row, false, 10); + } + else + Modify_Value(probe.offset.x, -MAX_XY_OFFSET, MAX_XY_OFFSET, 10); + break; + case PROBE_YOFFSET: + if (draw) { + Draw_Menu_Item(row, ICON_StepY, GET_TEXT_F(MSG_ZPROBE_YOFFSET)); + Draw_Float(probe.offset.y, row, false, 10); + } + else + Modify_Value(probe.offset.y, -MAX_XY_OFFSET, MAX_XY_OFFSET, 10); + break; + case PROBE_ZOFFSET: + if (draw) { + Draw_Menu_Item(row, ICON_StepZ, GET_TEXT_F(MSG_ZPROBE_ZOFFSET)); + Draw_Float(probe.offset.z, row, false, 100); + } + else + Modify_Value(probe.offset.z, MIN_Z_OFFSET, MAX_Z_OFFSET, 100); + break; + #if ENABLED(BLTOUCH) + case PROBE_HSMODE: if (draw) { - Draw_Menu_Item(row, ICON_StepX, F("Probe X Offset")); - Draw_Float(probe.offset.x, row, false, 10); + Draw_Menu_Item(row, ICON_HSMode, GET_TEXT(MSG_BLTOUCH_SPEED_MODE)); + Draw_Checkbox(row, bltouch.high_speed_mode); + } + else { + bltouch.high_speed_mode = !bltouch.high_speed_mode; + Draw_Checkbox(row, bltouch.high_speed_mode); } - else - Modify_Value(probe.offset.x, -MAX_XY_OFFSET, MAX_XY_OFFSET, 10); break; - case PROBE_YOFFSET: - if (draw) { - Draw_Menu_Item(row, ICON_StepY, F("Probe Y Offset")); - Draw_Float(probe.offset.y, row, false, 10); + case PROBE_ALARMR: + if (draw) + Draw_Menu_Item(row, ICON_ProbeAlarm, GET_TEXT_F(MSG_BLTOUCH_RESET)); + else { + gcode.process_subcommands_now(F("M280 P0 S160")); + AudioFeedback(); } - else - Modify_Value(probe.offset.y, -MAX_XY_OFFSET, MAX_XY_OFFSET, 10); break; - case PROBE_TEST: + case PROBE_SELFTEST: if (draw) - Draw_Menu_Item(row, ICON_StepY, F("M48 Probe Test")); + Draw_Menu_Item(row, ICON_ProbeSelfTest, GET_TEXT_F(MSG_BLTOUCH_SELFTEST)); else { - sprintf_P(cmd, PSTR("G28O\nM48 X%s Y%s P%i"), dtostrf((X_BED_SIZE + X_MIN_POS) / 2.0f, 1, 3, str_1), dtostrf((Y_BED_SIZE + Y_MIN_POS) / 2.0f, 1, 3, str_2), testcount); - gcode.process_subcommands_now(cmd); + gcode.process_subcommands_now(F("M280 P0 S120\nG4 P1000\nM280 P0 S160")); + planner.synchronize(); + AudioFeedback(); } break; - case PROBE_TEST_COUNT: + case PROBE_MOVEP: if (draw) { - Draw_Menu_Item(row, ICON_StepY, F("Probe Test Count")); - Draw_Float(testcount, row, false, 1); + Draw_Menu_Item(row, ICON_ProbeDeploy, GET_TEXT_F(MSG_BLTOUCH_DEPLOY)); + Draw_Checkbox(row, temp_val.probe_deployed); + } + else { + temp_val.probe_deployed = !temp_val.probe_deployed; + if (temp_val.probe_deployed == true) gcode.process_subcommands_now(F("M280 P0 S10")); + else gcode.process_subcommands_now(F("M280 P0 S90")); + Draw_Checkbox(row, temp_val.probe_deployed); } - else - Modify_Value(testcount, 4, 50, 1); break; + #endif + case PROBE_TEST: + if (draw) + Draw_Menu_Item(row, ICON_ProbeTest, GET_TEXT_F(MSG_M48_TEST)); + else { + sprintf_P(cmd, PSTR("G28O\nM48 X%s Y%s P%i"), dtostrf((X_BED_SIZE + X_MIN_POS) / 2.0f, 1, 3, str_1), dtostrf((Y_BED_SIZE + Y_MIN_POS) / 2.0f, 1, 3, str_2), testcount); + gcode.process_subcommands_now(cmd); + } + break; + case PROBE_TEST_COUNT: + if (draw) { + Draw_Menu_Item(row, ICON_ProbeTestCount, F("Probe Test Count")); + Draw_Float(testcount, row, false, 1); + } + else + Modify_Value(testcount, 4, 50, 1); + break; } break; #endif @@ -2917,7 +3708,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case INFO_BACK: if (draw) { - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); #if ENABLED(PRINTCOUNTER) char row1[50], row2[50], buf[32]; @@ -2966,22 +3757,19 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case LEVELING_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Main_Menu(3); break; case LEVELING_ACTIVE: if (draw) { - Draw_Menu_Item(row, ICON_StockConfiguration, F("Leveling Active")); + Draw_Menu_Item(row, ICON_MeshActive, GET_TEXT_F(MSG_MESH_LEVELING)); Draw_Checkbox(row, planner.leveling_active); } else { if (!planner.leveling_active) { set_bed_leveling_enabled(!planner.leveling_active); - if (!planner.leveling_active) { - Confirm_Handler(LevelError); - break; - } + if (!planner.leveling_active) { Confirm_Handler(LevelError); break; } } else set_bed_leveling_enabled(!planner.leveling_active); @@ -2993,10 +3781,8 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (draw) Draw_Menu_Item(row, ICON_Tilt, F("Autotilt Current Mesh")); else { - if (bedlevel.storage_slot < 0) { - Popup_Handler(MeshSlot); - break; - } + if (bedlevel.storage_slot < 0) { Popup_Handler(MeshSlot); break; } + PreheatBefore(); Popup_Handler(Home); gcode.home_all_axes(true); Popup_Handler(Level); @@ -3013,21 +3799,21 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #endif case LEVELING_GET_MESH: if (draw) - Draw_Menu_Item(row, ICON_Mesh, F("Create New Mesh")); + Draw_Menu_Item(row, ICON_Mesh, GET_TEXT_F(MSG_UBL_BUILD_MESH_MENU)); else { + #if ENABLED(AUTO_BED_LEVELING_UBL) + if (bedlevel.storage_slot < 0) { Popup_Handler(MeshSlot, true); break; } + #endif + PreheatBefore(); Popup_Handler(Home); gcode.home_all_axes(true); #if ENABLED(AUTO_BED_LEVELING_UBL) - #if ENABLED(PREHEAT_BEFORE_LEVELING) - Popup_Handler(Heating); - probe.preheat_for_probing(LEVELING_NOZZLE_TEMP, LEVELING_BED_TEMP); - #endif #if HAS_BED_PROBE Popup_Handler(Level); - gcode.process_subcommands_now(F("G29 P0\nG29 P1")); + gcode.process_subcommands_now(F("G29 P1")); gcode.process_subcommands_now(F("G29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nM420 S1")); planner.synchronize(); - Update_Status("Probed all reachable points"); + Update_Status(GET_TEXT_F(MSG_MESH_DONE)); Popup_Handler(SaveLevel); #else level_state = planner.leveling_active; @@ -3042,13 +3828,14 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Popup_Handler(Level); gcode.process_subcommands_now(F("G29")); planner.synchronize(); + Update_Status(GET_TEXT_F(MSG_MESH_DONE)); Popup_Handler(SaveLevel); #else level_state = planner.leveling_active; set_bed_leveling_enabled(false); - gridpoint = 1; + temp_val.gridpoint = 1; Popup_Handler(MoveWait); - gcode.process_subcommands_now(F("G29")); + gcode.process_subcommands_now(F("M211 S0\nG29")); planner.synchronize(); Draw_Menu(ManualMesh); #endif @@ -3056,42 +3843,22 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case LEVELING_MANUAL: if (draw) - Draw_Menu_Item(row, ICON_Mesh, F("Manual Tuning"), nullptr, true); + Draw_Menu_Item(row, ICON_Mesh, GET_TEXT_F(MSG_UBL_MESH_EDIT), nullptr, true); else { #if ENABLED(AUTO_BED_LEVELING_BILINEAR) - if (!leveling_is_valid()) { - Confirm_Handler(InvalidMesh); - break; - } + if (!leveling_is_valid()) { Confirm_Handler(InvalidMesh); break; } #endif #if ENABLED(AUTO_BED_LEVELING_UBL) - if (bedlevel.storage_slot < 0) { - Popup_Handler(MeshSlot); - break; - } + if (bedlevel.storage_slot < 0) { Popup_Handler(MeshSlot); break; } #endif - if (axes_should_home()) { - Popup_Handler(Home); - gcode.home_all_axes(true); - } + PreheatBefore(); + if (axes_should_home()) { Popup_Handler(Home); gcode.home_all_axes(true); } level_state = planner.leveling_active; set_bed_leveling_enabled(false); mesh_conf.goto_mesh_value = false; - #if ENABLED(PREHEAT_BEFORE_LEVELING) - Popup_Handler(Heating); - #if HAS_HOTEND - if (thermalManager.degTargetHotend(0) < LEVELING_NOZZLE_TEMP) - thermalManager.setTargetHotend(LEVELING_NOZZLE_TEMP, 0); - #endif - #if HAS_HEATED_BED - if (thermalManager.degTargetBed() < LEVELING_BED_TEMP) - thermalManager.setTargetBed(LEVELING_BED_TEMP); - #endif - TERN_(HAS_HOTEND, thermalManager.wait_for_hotend(0)); - TERN_(HAS_HEATED_BED, thermalManager.wait_for_bed_heating()); - #endif Popup_Handler(MoveWait); mesh_conf.manual_mesh_move(); + gcode.process_subcommands_now(F("M211 S0")); Draw_Menu(LevelManual); } break; @@ -3100,24 +3867,21 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Draw_Menu_Item(row, ICON_Mesh, GET_TEXT_F(MSG_MESH_VIEW), nullptr, true); else { #if ENABLED(AUTO_BED_LEVELING_UBL) - if (bedlevel.storage_slot < 0) { - Popup_Handler(MeshSlot); - break; - } + if (bedlevel.storage_slot < 0) { Popup_Handler(MeshSlot); break; } #endif Draw_Menu(LevelView); } break; case LEVELING_SETTINGS: if (draw) - Draw_Menu_Item(row, ICON_Step, F("Leveling Settings"), nullptr, true); + Draw_Menu_Item(row, ICON_Step, GET_TEXT_F(MSG_ADVANCED_SETTINGS), nullptr, true); else Draw_Menu(LevelSettings); break; #if ENABLED(AUTO_BED_LEVELING_UBL) case LEVELING_SLOT: if (draw) { - Draw_Menu_Item(row, ICON_PrintSize, F("Mesh Slot")); + Draw_Menu_Item(row, ICON_PrintSize, GET_TEXT_F(MSG_UBL_STORAGE_SLOT)); Draw_Float(bedlevel.storage_slot, row, false, 1); } else @@ -3125,12 +3889,9 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case LEVELING_LOAD: if (draw) - Draw_Menu_Item(row, ICON_ReadEEPROM, F("Load Mesh")); + Draw_Menu_Item(row, ICON_ReadEEPROM, GET_TEXT_F(MSG_UBL_LOAD_MESH)); else { - if (bedlevel.storage_slot < 0) { - Popup_Handler(MeshSlot); - break; - } + if (bedlevel.storage_slot < 0) { Popup_Handler(MeshSlot); break; } gcode.process_subcommands_now(F("G29 L")); planner.synchronize(); AudioFeedback(true); @@ -3138,12 +3899,9 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case LEVELING_SAVE: if (draw) - Draw_Menu_Item(row, ICON_WriteEEPROM, F("Save Mesh")); + Draw_Menu_Item(row, ICON_WriteEEPROM, GET_TEXT_F(MSG_UBL_SAVE_MESH)); else { - if (bedlevel.storage_slot < 0) { - Popup_Handler(MeshSlot); - break; - } + if (bedlevel.storage_slot < 0) { Popup_Handler(MeshSlot); break; } gcode.process_subcommands_now(F("G29 S")); planner.synchronize(); AudioFeedback(true); @@ -3164,7 +3922,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case LEVELING_VIEW_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Leveling, LEVELING_VIEW); break; @@ -3200,7 +3958,10 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case LevelSettings: #define LEVELING_SETTINGS_BACK 0 - #define LEVELING_SETTINGS_FADE (LEVELING_SETTINGS_BACK + 1) + #define LEVELING_SETTINGS_LEVELTEMP_MODE (LEVELING_SETTINGS_BACK + ENABLED(PREHEAT_BEFORE_LEVELING)) + #define LEVELING_SETTINGS_HOTENDTEMP (LEVELING_SETTINGS_LEVELTEMP_MODE + ENABLED(PREHEAT_BEFORE_LEVELING)) + #define LEVELING_SETTINGS_BEDTEMP (LEVELING_SETTINGS_HOTENDTEMP + ENABLED(PREHEAT_BEFORE_LEVELING)) + #define LEVELING_SETTINGS_FADE (LEVELING_SETTINGS_BEDTEMP + 1) #define LEVELING_SETTINGS_TILT (LEVELING_SETTINGS_FADE + ENABLED(AUTO_BED_LEVELING_UBL)) #define LEVELING_SETTINGS_PLANE (LEVELING_SETTINGS_TILT + ENABLED(AUTO_BED_LEVELING_UBL)) #define LEVELING_SETTINGS_ZERO (LEVELING_SETTINGS_PLANE + ENABLED(AUTO_BED_LEVELING_UBL)) @@ -3210,31 +3971,59 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case LEVELING_SETTINGS_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Leveling, LEVELING_SETTINGS); break; - case LEVELING_SETTINGS_FADE: + #if ENABLED(PREHEAT_BEFORE_LEVELING) + case LEVELING_SETTINGS_LEVELTEMP_MODE: + if (draw) { + Draw_Menu_Item(row, ICON_Homing, F("Preheat Mode")); + Draw_Option(temp_val.LevelingTempmode, preheat_levmodes, row); + } + else + Modify_Option(temp_val.LevelingTempmode, preheat_levmodes, 3); + break; + case LEVELING_SETTINGS_HOTENDTEMP: if (draw) { - Draw_Menu_Item(row, ICON_Fade, F("Fade Mesh within")); - Draw_Float(planner.z_fade_height, row, false, 1); - } - else { - Modify_Value(planner.z_fade_height, 0, Z_MAX_POS, 1); - planner.z_fade_height = -1; - set_z_fade_height(planner.z_fade_height); + Draw_Menu_Item(row, ICON_SetEndTemp, F("Preheat Hotend")); + Draw_Float(eeprom_settings.hotend_levtemp, row, false, 1); } + else + Modify_Value(eeprom_settings.hotend_levtemp, MIN_E_TEMP, MAX_E_TEMP, 1); break; + case LEVELING_SETTINGS_BEDTEMP: + if (draw) { + Draw_Menu_Item(row, ICON_SetBedTemp, F("Preheat Bed")); + Draw_Float(eeprom_settings.bed_levtemp, row, false, 1); + } + else + Modify_Value(eeprom_settings.bed_levtemp, MIN_BED_TEMP, MAX_BED_TEMP, 1); + break; + #endif + case LEVELING_SETTINGS_FADE: + if (draw) { + Draw_Menu_Item(row, ICON_Fade, GET_TEXT_F(MSG_Z_FADE_HEIGHT)); + Draw_Float(planner.z_fade_height, row, false, 1); + } + else { + Modify_Value(planner.z_fade_height, 0, Z_MAX_POS, 1); + planner.z_fade_height = -1; + set_z_fade_height(planner.z_fade_height); + } + break; #if ENABLED(AUTO_BED_LEVELING_UBL) + case LEVELING_SETTINGS_TILT: if (draw) { - Draw_Menu_Item(row, ICON_Tilt, F("Tilting Grid Size")); + Draw_Menu_Item(row, ICON_Tilt, F("Tilting Grid")); Draw_Float(mesh_conf.tilt_grid, row, false, 1); } else Modify_Value(mesh_conf.tilt_grid, 1, 8, 1); break; + case LEVELING_SETTINGS_PLANE: if (draw) Draw_Menu_Item(row, ICON_ResumeEEPROM, F("Convert Mesh to Plane")); @@ -3245,18 +4034,21 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ AudioFeedback(true); } break; + case LEVELING_SETTINGS_ZERO: if (draw) Draw_Menu_Item(row, ICON_Mesh, F("Zero Current Mesh")); else ZERO(bedlevel.z_values); break; + case LEVELING_SETTINGS_UNDEF: if (draw) Draw_Menu_Item(row, ICON_Mesh, F("Clear Current Mesh")); else bedlevel.invalidate(); break; + #endif // AUTO_BED_LEVELING_UBL } break; @@ -3267,7 +4059,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (item == MESHVIEW_BACK) { if (draw) { - Draw_Menu_Item(0, ICON_Back, F("Back")); + Draw_Menu_Item(0, ICON_Back, GET_TEXT_F(MSG_BACK)); mesh_conf.Draw_Bed_Mesh(); mesh_conf.Set_Mesh_Viewer_Status(); } @@ -3294,7 +4086,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case LEVELING_M_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else { set_bed_leveling_enabled(level_state); TERN_(AUTO_BED_LEVELING_BILINEAR, bedlevel.refresh_bed_level()); @@ -3303,7 +4095,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case LEVELING_M_X: if (draw) { - Draw_Menu_Item(row, ICON_MoveX, F("Mesh Point X")); + Draw_Menu_Item(row, ICON_MoveX, GET_TEXT_F(MSG_MESH_X)); Draw_Float(mesh_conf.mesh_x, row, 0, 1); } else @@ -3311,7 +4103,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case LEVELING_M_Y: if (draw) { - Draw_Menu_Item(row, ICON_MoveY, F("Mesh Point Y")); + Draw_Menu_Item(row, ICON_MoveY, GET_TEXT_F(MSG_MESH_Y)); Draw_Float(mesh_conf.mesh_y, row, 0, 1); } else @@ -3319,15 +4111,15 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case LEVELING_M_NEXT: if (draw) - Draw_Menu_Item(row, ICON_More, F("Next Point")); + Draw_Menu_Item(row, ICON_More, GET_TEXT_F(MSG_LEVEL_BED_NEXT_POINT)); else { if (mesh_conf.mesh_x != (GRID_MAX_POINTS_X - 1) || mesh_conf.mesh_y != (GRID_MAX_POINTS_Y - 1)) { - if ((mesh_conf.mesh_x == (GRID_MAX_POINTS_X - 1) && mesh_conf.mesh_y % 2 == 0) || (mesh_conf.mesh_x == 0 && mesh_conf.mesh_y % 2 == 1)) + if ((mesh_conf.mesh_x == (GRID_MAX_POINTS_X - 1) && !(mesh_conf.mesh_y & 1)) || (!mesh_conf.mesh_x && (mesh_conf.mesh_y & 1))) mesh_conf.mesh_y++; - else if (mesh_conf.mesh_y % 2 == 0) - mesh_conf.mesh_x++; - else + else if (mesh_conf.mesh_y & 1) mesh_conf.mesh_x--; + else + mesh_conf.mesh_x++; mesh_conf.manual_mesh_move(); } } @@ -3407,7 +4199,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case UBL_M_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else { set_bed_leveling_enabled(level_state); Draw_Menu(Leveling, LEVELING_GET_MESH); @@ -3416,18 +4208,18 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case UBL_M_NEXT: if (draw) { if (mesh_conf.mesh_x != (GRID_MAX_POINTS_X - 1) || mesh_conf.mesh_y != (GRID_MAX_POINTS_Y - 1)) - Draw_Menu_Item(row, ICON_More, F("Next Point")); + Draw_Menu_Item(row, ICON_More, GET_TEXT_F(MSG_LEVEL_BED_NEXT_POINT)); else - Draw_Menu_Item(row, ICON_More, F("Save Mesh")); + Draw_Menu_Item(row, ICON_More, GET_TEXT_F(MSG_UBL_SAVE_MESH)); } else { if (mesh_conf.mesh_x != (GRID_MAX_POINTS_X - 1) || mesh_conf.mesh_y != (GRID_MAX_POINTS_Y - 1)) { - if ((mesh_conf.mesh_x == (GRID_MAX_POINTS_X - 1) && mesh_conf.mesh_y % 2 == 0) || (mesh_conf.mesh_x == 0 && mesh_conf.mesh_y % 2 == 1)) + if ((mesh_conf.mesh_x == (GRID_MAX_POINTS_X - 1) && !(mesh_conf.mesh_y & 1)) || (!mesh_conf.mesh_x && (mesh_conf.mesh_y & 1))) mesh_conf.mesh_y++; - else if (mesh_conf.mesh_y % 2 == 0) - mesh_conf.mesh_x++; - else + else if (mesh_conf.mesh_y & 1) mesh_conf.mesh_x--; + else + mesh_conf.mesh_x++; mesh_conf.manual_mesh_move(); } else { @@ -3443,12 +4235,12 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Draw_Menu_Item(row, ICON_More, F("Previous Point")); else { if (mesh_conf.mesh_x != 0 || mesh_conf.mesh_y != 0) { - if ((mesh_conf.mesh_x == (GRID_MAX_POINTS_X - 1) && mesh_conf.mesh_y % 2 == 1) || (mesh_conf.mesh_x == 0 && mesh_conf.mesh_y % 2 == 0)) + if ((mesh_conf.mesh_x == (GRID_MAX_POINTS_X - 1) && (mesh_conf.mesh_y & 1)) || (!mesh_conf.mesh_x && !(mesh_conf.mesh_y & 1))) mesh_conf.mesh_y--; - else if (mesh_conf.mesh_y % 2 == 0) - mesh_conf.mesh_x--; - else + else if (mesh_conf.mesh_y & 1) mesh_conf.mesh_x++; + else + mesh_conf.mesh_x--; mesh_conf.manual_mesh_move(); } } @@ -3506,7 +4298,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case MMESH_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Cancel")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BUTTON_CANCEL)); else { gcode.process_subcommands_now(F("G29 A")); planner.synchronize(); @@ -3516,16 +4308,16 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case MMESH_NEXT: if (draw) { - if (gridpoint < GRID_MAX_POINTS) - Draw_Menu_Item(row, ICON_More, F("Next Point")); + if (temp_val.gridpoint < GRID_MAX_POINTS) + Draw_Menu_Item(row, ICON_More, GET_TEXT_F(MSG_LEVEL_BED_NEXT_POINT)); else - Draw_Menu_Item(row, ICON_More, F("Save Mesh")); + Draw_Menu_Item(row, ICON_More, GET_TEXT_F(MSG_UBL_SAVE_MESH)); } - else if (gridpoint < GRID_MAX_POINTS) { + else if (temp_val.gridpoint < GRID_MAX_POINTS) { Popup_Handler(MoveWait); gcode.process_subcommands_now(F("G29")); planner.synchronize(); - gridpoint++; + temp_val.gridpoint++; Redraw_Menu(); } else { @@ -3569,16 +4361,16 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case MMESH_OLD: uint8_t mesh_x, mesh_y; // 0,0 -> 1,0 -> 2,0 -> 2,1 -> 1,1 -> 0,1 -> 0,2 -> 1,2 -> 2,2 - mesh_y = (gridpoint - 1) / (GRID_MAX_POINTS_Y); - mesh_x = (gridpoint - 1) % (GRID_MAX_POINTS_X); + mesh_y = (temp_val.gridpoint - 1) / (GRID_MAX_POINTS_Y); + mesh_x = (temp_val.gridpoint - 1) % (GRID_MAX_POINTS_X); - if (mesh_y % 2 == 1) + if (mesh_y & 1) mesh_x = (GRID_MAX_POINTS_X) - mesh_x - 1; const float currval = bedlevel.z_values[mesh_x][mesh_y]; if (draw) { - Draw_Menu_Item(row, ICON_Zoffset, F("Goto Mesh Value")); + Draw_Menu_Item(row, ICON_Zoffset, GET_TEXT_F(MSG_MESH_EDIT_Z)); Draw_Float(currval, row, false, 100); } else if (!isnan(currval)) { @@ -3604,22 +4396,25 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #define TUNE_ZOFFSET (TUNE_FAN + ENABLED(HAS_ZOFFSET_ITEM)) #define TUNE_ZUP (TUNE_ZOFFSET + ENABLED(HAS_ZOFFSET_ITEM)) #define TUNE_ZDOWN (TUNE_ZUP + ENABLED(HAS_ZOFFSET_ITEM)) - #define TUNE_CHANGEFIL (TUNE_ZDOWN + ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)) + #define TUNE_FWRETRACT (TUNE_ZDOWN + ENABLED(FWRETRACT)) + #define TUNE_HOSTACTIONS (TUNE_FWRETRACT + ENABLED(HAS_HOSTACTION_MENUS)) + #define TUNE_CHANGEFIL (TUNE_HOSTACTIONS + ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)) #define TUNE_FILSENSORENABLED (TUNE_CHANGEFIL + ENABLED(FILAMENT_RUNOUT_SENSOR)) #define TUNE_BACKLIGHT_OFF (TUNE_FILSENSORENABLED + 1) #define TUNE_BACKLIGHT (TUNE_BACKLIGHT_OFF + 1) - #define TUNE_TOTAL TUNE_BACKLIGHT + #define TUNE_CASELIGHT (TUNE_BACKLIGHT + ENABLED(CASE_LIGHT_MENU)) + #define TUNE_LEDCONTROL (TUNE_CASELIGHT + (ENABLED(LED_CONTROL_MENU) && DISABLED(CASE_LIGHT_USE_NEOPIXEL))) + #define TUNE_LOCKSCREEN (TUNE_LEDCONTROL + ENABLED(HAS_LOCKSCREEN)) + #define TUNE_TOTAL TUNE_LOCKSCREEN switch (item) { case TUNE_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); - else - Draw_Print_Screen(); + if (draw) Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); + else Draw_Print_Screen(); break; case TUNE_SPEED: if (draw) { - Draw_Menu_Item(row, ICON_Speed, F("Print Speed")); + Draw_Menu_Item(row, ICON_Speed, GET_TEXT_F(MSG_SPEED)); Draw_Float(feedrate_percentage, row, false, 1); } else @@ -3629,7 +4424,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_HOTEND case TUNE_FLOW: if (draw) { - Draw_Menu_Item(row, ICON_Speed, F("Flow Rate")); + Draw_Menu_Item(row, ICON_Speed, GET_TEXT_F(MSG_FLOW)); Draw_Float(planner.flow_percentage[0], row, false, 1); } else @@ -3659,7 +4454,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_FAN case TUNE_FAN: if (draw) { - Draw_Menu_Item(row, ICON_FanSpeed, F("Fan")); + Draw_Menu_Item(row, ICON_FanSpeed, GET_TEXT_F(MSG_FAN_SPEED)); Draw_Float(thermalManager.fan_speed[0], row, false, 1); } else @@ -3671,44 +4466,66 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case TUNE_ZOFFSET: if (draw) { Draw_Menu_Item(row, ICON_FanSpeed, F("Z-Offset")); - Draw_Float(zoffsetvalue, row, false, 100); + Draw_Float(temp_val.zoffsetvalue, row, false, 100); } else - Modify_Value(zoffsetvalue, MIN_Z_OFFSET, MAX_Z_OFFSET, 100); + Modify_Value(temp_val.zoffsetvalue, MIN_Z_OFFSET, MAX_Z_OFFSET, 100); break; case TUNE_ZUP: if (draw) - Draw_Menu_Item(row, ICON_Axis, F("Z-Offset Up")); - else if (zoffsetvalue < MAX_Z_OFFSET) { - gcode.process_subcommands_now(F("M290 Z0.01")); - zoffsetvalue += 0.01; - Draw_Float(zoffsetvalue, row - 1, false, 100); + Draw_Menu_Item(row, ICON_Axis, F("Z-Offset Up")); + else if (temp_val.zoffsetvalue < MAX_Z_OFFSET) { + gcode.process_subcommands_now(F("M290 Z0.01")); + temp_val.zoffsetvalue += 0.01; + Draw_Float(temp_val.zoffsetvalue, row - 1, false, 100); + } + break; + case TUNE_ZDOWN: + if (draw) + Draw_Menu_Item(row, ICON_AxisD, F("Z-Offset Down")); + else if (temp_val.zoffsetvalue > MIN_Z_OFFSET) { + gcode.process_subcommands_now(F("M290 Z-0.01")); + temp_val.zoffsetvalue -= 0.01; + Draw_Float(temp_val.zoffsetvalue, row - 2, false, 100); + } + break; + #endif + + #if ENABLED(FWRETRACT) + case TUNE_FWRETRACT: + if (draw) + Draw_Menu_Item(row, ICON_StepE, GET_TEXT_F(MSG_AUTORETRACT), nullptr, true); + else { + temp_val.flag_tune = true; + last_pos_selection = selection; + Draw_Menu(FwRetraction); } break; - case TUNE_ZDOWN: + #endif + + #if HAS_HOSTACTION_MENUS + case TUNE_HOSTACTIONS: if (draw) - Draw_Menu_Item(row, ICON_AxisD, F("Z-Offset Down")); - else if (zoffsetvalue > MIN_Z_OFFSET) { - gcode.process_subcommands_now(F("M290 Z-0.01")); - zoffsetvalue -= 0.01; - Draw_Float(zoffsetvalue, row - 2, false, 100); + Draw_Menu_Item(row, ICON_SetHome, F("Host Actions"), nullptr, true); + else { + temp_val.flag_tune = true; + last_pos_selection = selection; + Draw_Menu(HostActions); } break; #endif #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) case TUNE_CHANGEFIL: - if (draw) - Draw_Menu_Item(row, ICON_ResumeEEPROM, F("Change Filament")); - else - Popup_Handler(ConfFilChange); + if (draw) Draw_Menu_Item(row, ICON_ResumeEEPROM, GET_TEXT_F(MSG_FILAMENTCHANGE)); + else Popup_Handler(ConfFilChange); break; #endif #if ENABLED(FILAMENT_RUNOUT_SENSOR) case TUNE_FILSENSORENABLED: if (draw) { - Draw_Menu_Item(row, ICON_Extruder, F("Filament Sensor")); + Draw_Menu_Item(row, ICON_Extruder, GET_TEXT_F(MSG_RUNOUT_SENSOR)); Draw_Checkbox(row, runout.enabled); } else { @@ -3719,106 +4536,138 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #endif case TUNE_BACKLIGHT_OFF: - if (draw) - Draw_Menu_Item(row, ICON_Brightness, F("Display Off")); - else - ui.set_brightness(0); + if (draw) Draw_Menu_Item(row, ICON_Brightness, GET_TEXT_F(MSG_BRIGHTNESS_OFF)); + else ui.set_brightness(0); break; case TUNE_BACKLIGHT: if (draw) { - Draw_Menu_Item(row, ICON_Brightness, F("LCD Brightness")); + Draw_Menu_Item(row, ICON_Brightness, GET_TEXT_F(MSG_BRIGHTNESS)); Draw_Float(ui.brightness, row, false, 1); } else Modify_Value(ui.brightness, LCD_BRIGHTNESS_MIN, LCD_BRIGHTNESS_MAX, 1, ui.refresh_brightness); break; - } - break; - - #if HAS_PREHEAT && HAS_HOTEND - - case PreheatHotend: - - #define PREHEATHOTEND_BACK 0 - #define PREHEATHOTEND_CONTINUE (PREHEATHOTEND_BACK + 1) - #define PREHEATHOTEND_1 (PREHEATHOTEND_CONTINUE + (PREHEAT_COUNT >= 1)) - #define PREHEATHOTEND_2 (PREHEATHOTEND_1 + (PREHEAT_COUNT >= 2)) - #define PREHEATHOTEND_3 (PREHEATHOTEND_2 + (PREHEAT_COUNT >= 3)) - #define PREHEATHOTEND_4 (PREHEATHOTEND_3 + (PREHEAT_COUNT >= 4)) - #define PREHEATHOTEND_5 (PREHEATHOTEND_4 + (PREHEAT_COUNT >= 5)) - #define PREHEATHOTEND_CUSTOM (PREHEATHOTEND_5 + 1) - #define PREHEATHOTEND_TOTAL PREHEATHOTEND_CUSTOM - - switch (item) { - case PREHEATHOTEND_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, F("Cancel")); + #if ENABLED(CASE_LIGHT_MENU) + case TUNE_CASELIGHT: + if (draw) { + Draw_Menu_Item(row, ICON_CaseLight, GET_TEXT_F(MSG_CASE_LIGHT)); + Draw_Checkbox(row, caselight.on); + } else { - thermalManager.setTargetHotend(0, 0); - thermalManager.set_fan_speed(0, 0); - Redraw_Menu(false, true, true); + caselight.on = !caselight.on; + caselight.update_enabled(); + Draw_Checkbox(row, caselight.on); } break; - case PREHEATHOTEND_CONTINUE: - if (draw) - Draw_Menu_Item(row, ICON_SetEndTemp, F("Continue")); + #endif + #if ENABLED(LED_CONTROL_MENU) && DISABLED(CASE_LIGHT_USE_NEOPIXEL) + case TUNE_LEDCONTROL: + if (draw) { + Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_LEDS)); + Draw_Checkbox(row, leds.lights_on); + } else { - Popup_Handler(Heating); - thermalManager.wait_for_hotend(0); - switch (last_menu) { - case Prepare: - Popup_Handler(FilChange); - sprintf_P(cmd, PSTR("M600 B1 R%i"), thermalManager.temp_hotend[0].target); - gcode.process_subcommands_now(cmd); - break; - #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) - case ChangeFilament: - switch (last_selection) { - case CHANGEFIL_LOAD: - Popup_Handler(FilLoad); - gcode.process_subcommands_now(F("M701")); - planner.synchronize(); - Redraw_Menu(true, true, true); - break; - case CHANGEFIL_UNLOAD: - Popup_Handler(FilLoad, true); - gcode.process_subcommands_now(F("M702")); - planner.synchronize(); - Redraw_Menu(true, true, true); - break; - case CHANGEFIL_CHANGE: - Popup_Handler(FilChange); - sprintf_P(cmd, PSTR("M600 B1 R%i"), thermalManager.temp_hotend[0].target); - gcode.process_subcommands_now(cmd); - break; - } - break; - #endif - default: - Redraw_Menu(true, true, true); - break; - } + leds.toggle(); + Draw_Checkbox(row, leds.lights_on); } break; + #endif + #if HAS_LOCKSCREEN + case TUNE_LOCKSCREEN: + if (draw) Draw_Menu_Item(row, ICON_Lock, GET_TEXT_F(MSG_LOCKSCREEN)); + else DWIN_LockScreen(); + break; + #endif + } + break; + #if HAS_PREHEAT && HAS_HOTEND + case PreheatHotend: - #define _PREHEAT_HOTEND_CASE(N) \ - case PREHEATHOTEND_##N: \ - if (draw) Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_## N ##_LABEL)); \ - else ui.preheat_hotend_and_fan((N) - 1); \ + #define PREHEATHOTEND_BACK 0 + #define PREHEATHOTEND_CONTINUE (PREHEATHOTEND_BACK + 1) + #define PREHEATHOTEND_1 (PREHEATHOTEND_CONTINUE + (PREHEAT_COUNT >= 1)) + #define PREHEATHOTEND_2 (PREHEATHOTEND_1 + (PREHEAT_COUNT >= 2)) + #define PREHEATHOTEND_3 (PREHEATHOTEND_2 + (PREHEAT_COUNT >= 3)) + #define PREHEATHOTEND_4 (PREHEATHOTEND_3 + (PREHEAT_COUNT >= 4)) + #define PREHEATHOTEND_5 (PREHEATHOTEND_4 + (PREHEAT_COUNT >= 5)) + #define PREHEATHOTEND_CUSTOM (PREHEATHOTEND_5 + 1) + #define PREHEATHOTEND_TOTAL PREHEATHOTEND_CUSTOM + + switch (item) { + case PREHEATHOTEND_BACK: + if (draw) + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BUTTON_CANCEL)); + else { + thermalManager.setTargetHotend(0, 0); + thermalManager.set_fan_speed(0, 0); + Redraw_Menu(false, true, true); + } + break; + case PREHEATHOTEND_CONTINUE: + if (draw) + Draw_Menu_Item(row, ICON_SetEndTemp, GET_TEXT_F(MSG_BUTTON_CONTINUE)); + else { + Popup_Handler(Heating); + thermalManager.wait_for_hotend(0); + switch (last_menu) { + case Prepare: + Popup_Handler(FilChange); + sprintf_P(cmd, PSTR("M600 B1 R%i"), thermalManager.temp_hotend[0].target); + gcode.process_subcommands_now(cmd); + Draw_Menu(Prepare, PREPARE_CHANGEFIL); + break; + #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) + case ChangeFilament: + switch (last_selection) { + case CHANGEFIL_LOAD: + Popup_Handler(FilLoad); + Update_Status(GET_TEXT(MSG_FILAMENTLOAD)); + gcode.process_subcommands_now(F("M701")); + planner.synchronize(); + Draw_Menu(ChangeFilament, CHANGEFIL_LOAD); + break; + case CHANGEFIL_UNLOAD: + Popup_Handler(FilLoad, true); + Update_Status(GET_TEXT(MSG_FILAMENTUNLOAD)); + gcode.process_subcommands_now(F("M702")); + planner.synchronize(); + Draw_Menu(ChangeFilament, CHANGEFIL_UNLOAD); + break; + case CHANGEFIL_CHANGE: + Popup_Handler(FilChange); + Update_Status(GET_TEXT(MSG_FILAMENTCHANGE)); + sprintf_P(cmd, PSTR("M600 B1 R%i"), thermalManager.temp_hotend[0].target); + gcode.process_subcommands_now(cmd); + Draw_Menu(ChangeFilament, CHANGEFIL_CHANGE); + break; + } + break; + #endif + default: + Redraw_Menu(true, true, true); + break; + } + } break; - REPEAT_1(PREHEAT_COUNT, _PREHEAT_HOTEND_CASE) + #define _PREHEAT_HOTEND_CASE(N) \ + case PREHEATHOTEND_##N: \ + if (draw) Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_## N ##_LABEL)); \ + else ui.preheat_hotend_and_fan((N) - 1); \ + break; - case PREHEATHOTEND_CUSTOM: - if (draw) { - Draw_Menu_Item(row, ICON_Temperature, F("Custom")); - Draw_Float(thermalManager.temp_hotend[0].target, row, false, 1); - } - else - Modify_Value(thermalManager.temp_hotend[0].target, EXTRUDE_MINTEMP, MAX_E_TEMP, 1); - break; - } + REPEAT_1(PREHEAT_COUNT, _PREHEAT_HOTEND_CASE) + + case PREHEATHOTEND_CUSTOM: + if (draw) { + Draw_Menu_Item(row, ICON_Temperature, GET_TEXT_F(MSG_PREHEAT_CUSTOM)); + Draw_Float(thermalManager.temp_hotend[0].target, row, false, 1); + } + else + Modify_Value(thermalManager.temp_hotend[0].target, EXTRUDE_MINTEMP, MAX_E_TEMP, 1); + break; + } break; #endif // HAS_PREHEAT && HAS_HOTEND @@ -3827,11 +4676,11 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ FSTR_P CrealityDWINClass::Get_Menu_Title(uint8_t menu) { switch (menu) { - case MainMenu: return F("Main Menu"); - case Prepare: return F("Prepare"); - case HomeMenu: return F("Homing Menu"); - case Move: return F("Move"); - case ManualLevel: return F("Manual Leveling"); + case MainMenu: return GET_TEXT_F(MSG_MAIN); + case Prepare: return GET_TEXT_F(MSG_PREPARE); + case HomeMenu: return GET_TEXT_F(MSG_HOMING); + case Move: return GET_TEXT_F(MSG_MOVE_AXIS); + case ManualLevel: return GET_TEXT_F(MSG_BED_TRAMMING_MANUAL); #if HAS_ZOFFSET_ITEM case ZOffset: return F("Z Offset"); #endif @@ -3839,7 +4688,10 @@ FSTR_P CrealityDWINClass::Get_Menu_Title(uint8_t menu) { case Preheat: return F("Preheat"); #endif #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) - case ChangeFilament: return F("Change Filament"); + case ChangeFilament: return GET_TEXT_F(MSG_FILAMENTCHANGE); + #endif + #if HAS_HOSTACTION_MENUS + case HostActions: return F("Host Actions"); #endif #if HAS_CUSTOM_MENU case MenuCustom: @@ -3849,8 +4701,8 @@ FSTR_P CrealityDWINClass::Get_Menu_Title(uint8_t menu) { return F("Custom Commands"); #endif #endif - case Control: return F("Control"); - case TempMenu: return F("Temperature"); + case Control: return GET_TEXT_F(MSG_CONTROL); + case TempMenu: return GET_TEXT_F(MSG_TEMPERATURE); #if HAS_HOTEND || HAS_HEATED_BED case PID: return F("PID Menu"); #endif @@ -3865,36 +4717,62 @@ FSTR_P CrealityDWINClass::Get_Menu_Title(uint8_t menu) { REPEAT_1(PREHEAT_COUNT, _PREHEAT_TITLE_CASE) #endif case Motion: return F("Motion Settings"); - case HomeOffsets: return F("Home Offsets"); - case MaxSpeed: return F("Max Speed"); - case MaxAcceleration: return F("Max Acceleration"); + #if ENABLED(FWRETRACT) + case FwRetraction: return F("Firmware Retract"); + #endif + case HomeOffsets: return GET_TEXT_F(MSG_SET_HOME_OFFSETS); + case MaxSpeed: return GET_TEXT_F(MSG_SPEED); + case MaxAcceleration: return GET_TEXT_F(MSG_ACCELERATION); #if HAS_CLASSIC_JERK - case MaxJerk: return F("Max Jerk"); + case MaxJerk: return GET_TEXT_F(MSG_JERK); + #endif + #if HAS_JUNCTION_DEVIATION + case JDmenu: return GET_TEXT_F(MSG_JUNCTION_DEVIATION); #endif - case Steps: return F("Steps/mm"); + case Steps: return GET_TEXT_F(MSG_STEPS_PER_MM); case Visual: return F("Visual Settings"); - case Advanced: return F("Advanced Settings"); + #if HAS_HOSTACTION_MENUS + case HostSettings: return F("Host Settings"); + case ActionCommands: return F("Host Actions"); + #endif + case Advanced: return GET_TEXT_F(MSG_ADVANCED_SETTINGS); #if HAS_BED_PROBE - case ProbeMenu: return F("Probe Menu"); + case ProbeMenu: return GET_TEXT_F(MSG_ZPROBE_SETTINGS); #endif case ColorSettings: return F("UI Color Settings"); - case Info: return F("Info"); - case InfoMain: return F("Info"); + case Info: + case InfoMain: return GET_TEXT_F(MSG_INFO_SCREEN); #if HAS_MESH - case Leveling: return F("Leveling"); + case Leveling: return GET_TEXT_F(MSG_BED_LEVELING); case LevelView: return GET_TEXT_F(MSG_MESH_VIEW); case LevelSettings: return F("Leveling Settings"); case MeshViewer: return GET_TEXT_F(MSG_MESH_VIEW); - case LevelManual: return F("Manual Tuning"); + case LevelManual: return GET_TEXT_F(MSG_UBL_FINE_TUNE_MESH); #endif #if ENABLED(AUTO_BED_LEVELING_UBL) && !HAS_BED_PROBE - case UBLMesh: return F("UBL Bed Leveling"); + case UBLMesh: return GET_TEXT_F(MSG_UBL_LEVEL_BED); #endif #if ENABLED(PROBE_MANUALLY) - case ManualMesh: return F("Mesh Bed Leveling"); + case ManualMesh: return GET_TEXT_F(MSG_MESH_LEVELING); #endif - case Tune: return F("Tune"); + case Tune: return GET_TEXT_F(MSG_TUNE); case PreheatHotend: return F("Preheat Hotend"); + #if ANY(CASE_LIGHT_MENU, LED_CONTROL_MENU) + case Ledsmenu: return F("Light Settings"); + #if ENABLED(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) + case CaseLightmenu: return GET_TEXT_F(MSG_CASE_LIGHT); + #endif + #if ENABLED(LED_CONTROL_MENU) + case LedControlmenu: return GET_TEXT_F(MSG_LED_CONTROL); + #if HAS_COLOR_LEDS + #if ENABLED(LED_COLOR_PRESETS) + case LedControlpresets: return GET_TEXT_F(MSG_LED_PRESETS); + #else + case LedControlcustom: return GET_TEXT_F(MSG_CUSTOM_LEDS); + #endif + #endif + #endif + #endif } return F(""); } @@ -3914,6 +4792,9 @@ uint8_t CrealityDWINClass::Get_Menu_Size(uint8_t menu) { #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) case ChangeFilament: return CHANGEFIL_TOTAL; #endif + #if HAS_HOSTACTION_MENUS + case HostActions: return HOSTACTIONS_TOTAL; + #endif #if HAS_CUSTOM_MENU case MenuCustom: return CUSTOM_MENU_TOTAL; #endif @@ -3933,14 +4814,24 @@ uint8_t CrealityDWINClass::Get_Menu_Size(uint8_t menu) { return PREHEAT_SUBMENU_TOTAL; #endif case Motion: return MOTION_TOTAL; + #if ENABLED(FWRETRACT) + case FwRetraction: return FWR_TOTAL; + #endif case HomeOffsets: return HOMEOFFSETS_TOTAL; case MaxSpeed: return SPEED_TOTAL; case MaxAcceleration: return ACCEL_TOTAL; #if HAS_CLASSIC_JERK case MaxJerk: return JERK_TOTAL; #endif + #if HAS_JUNCTION_DEVIATION + case JDmenu: return JD_TOTAL; + #endif case Steps: return STEPS_TOTAL; case Visual: return VISUAL_TOTAL; + #if HAS_HOSTACTION_MENUS + case HostSettings: return HOSTSETTINGS_TOTAL; + case ActionCommands: return ACTIONCOMMANDS_TOTAL; + #endif case Advanced: return ADVANCED_TOTAL; #if HAS_BED_PROBE case ProbeMenu: return PROBE_TOTAL; @@ -3967,6 +4858,22 @@ uint8_t CrealityDWINClass::Get_Menu_Size(uint8_t menu) { #endif case ColorSettings: return COLORSETTINGS_TOTAL; + #if ANY(CASE_LIGHT_MENU, LED_CONTROL_MENU) + case Ledsmenu: return LEDS_TOTAL; + #if ENABLED(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) + case CaseLightmenu: return CASE_LIGHT_TOTAL; + #endif + #if ENABLED(LED_CONTROL_MENU) + case LedControlmenu: return LEDCONTROL_TOTAL; + #if HAS_COLOR_LEDS + #if ENABLED(LED_COLOR_PRESETS) + case LedControlpresets: return LEDCONTROL_PRESETS_TOTAL; + #else + case LedControlcustom: return LEDCONTROL_CUSTOM_TOTAL; + #endif + #endif + #endif + #endif } return 0; } @@ -3976,36 +4883,42 @@ uint8_t CrealityDWINClass::Get_Menu_Size(uint8_t menu) { void CrealityDWINClass::Popup_Handler(PopupID popupid, bool option/*=false*/) { popup = last_popup = popupid; switch (popupid) { - case Pause: Draw_Popup(F("Pause Print"), F(""), F(""), Popup); break; - case Stop: Draw_Popup(F("Stop Print"), F(""), F(""), Popup); break; - case Resume: Draw_Popup(F("Resume Print?"), F("Looks Like the last"), F("print was interrupted."), Popup); break; + case Pause: Draw_Popup(GET_TEXT_F(MSG_PAUSE_PRINT), F(""), F(""), Popup); break; + case Stop: Draw_Popup(GET_TEXT_F(MSG_STOP_PRINT), F(""), F(""), Popup); break; + case Resume: Draw_Popup(GET_TEXT_F(MSG_RESUME_PRINT), F("Looks Like the last"), F("print was interrupted."), Popup); break; case ConfFilChange: Draw_Popup(F("Confirm Filament Change"), F(""), F(""), Popup); break; case PurgeMore: Draw_Popup(F("Purge more filament?"), F("(Cancel to finish process)"), F(""), Popup); break; case SaveLevel: Draw_Popup(F("Leveling Complete"), F("Save to EEPROM?"), F(""), Popup); break; case MeshSlot: Draw_Popup(F("Mesh slot not selected"), F("(Confirm to select slot 0)"), F(""), Popup); break; - case ETemp: Draw_Popup(F("Nozzle is too cold"), F("Open Preheat Menu?"), F(""), Popup); break; + case ETemp: Draw_Popup(GET_TEXT_F(MSG_HOTEND_TOO_COLD), GET_TEXT_F(MSG_PLEASE_PREHEAT), F(""), Popup); break; case ManualProbing: Draw_Popup(F("Manual Probing"), F("(Confirm to probe)"), F("(cancel to exit)"), Popup); break; - case Level: Draw_Popup(F("Auto Bed Leveling"), F("Please wait until done."), F(""), Wait, ICON_AutoLeveling); break; - case Home: Draw_Popup(option ? F("Parking") : F("Homing"), F("Please wait until done."), F(""), Wait, ICON_BLTouch); break; - case MoveWait: Draw_Popup(F("Moving to Point"), F("Please wait until done."), F(""), Wait, ICON_BLTouch); break; - case Heating: Draw_Popup(F("Heating"), F("Please wait until done."), F(""), Wait, ICON_BLTouch); break; - case FilLoad: Draw_Popup(option ? F("Unloading Filament") : F("Loading Filament"), F("Please wait until done."), F(""), Wait, ICON_BLTouch); break; + case Level: Draw_Popup(F("Auto Bed Leveling"), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Wait, ICON_AutoLeveling); break; + case Home: Draw_Popup(option ? GET_TEXT_F(MSG_PAUSE_PRINT_PARKING) : GET_TEXT_F(MSG_HOMING), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Wait, ICON_BLTouch); break; + case MoveWait: Draw_Popup(GET_TEXT_F(MSG_MOVING), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Wait, ICON_BLTouch); break; + case Heating: Draw_Popup(GET_TEXT_F(MSG_HEATING), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Wait, ICON_BLTouch); break; + case FilLoad: Draw_Popup(option ? F("Unloading Filament") : F("Loading Filament"), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Wait, ICON_BLTouch); break; case FilChange: Draw_Popup(F("Filament Change"), F("Please wait for prompt."), F(""), Wait, ICON_BLTouch); break; - case TempWarn: Draw_Popup(option ? F("Nozzle temp too low!") : F("Nozzle temp too high!"), F(""), F(""), Wait, option ? ICON_TempTooLow : ICON_TempTooHigh); break; + case TempWarn: Draw_Popup(option ? GET_TEXT_F(MSG_HOTEND_TOO_COLD) : F("Nozzle temp too high!"), F(""), F(""), Wait, option ? ICON_TempTooLow : ICON_TempTooHigh); break; case Runout: Draw_Popup(F("Filament Runout"), F(""), F(""), Wait, ICON_BLTouch); break; - case PIDWait: Draw_Popup(F("PID Autotune"), F("in process"), F("Please wait until done."), Wait, ICON_BLTouch); break; - case Resuming: Draw_Popup(F("Resuming Print"), F("Please wait until done."), F(""), Wait, ICON_BLTouch); break; - case Custom: Draw_Popup(F("Running Custom GCode"), F("Please wait until done."), F(""), Wait, ICON_BLTouch); break; + #if !HAS_PIDPLOT + case PIDWait: Draw_Popup(F("PID Autotune"), F("in process"), GET_TEXT_F(MSG_PLEASE_WAIT), Wait, ICON_BLTouch); break; + #endif + case Resuming: Draw_Popup(F("Resuming Print"), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Wait, ICON_BLTouch); break; + #if HAS_CUSTOM_MENU + case Custom: Draw_Popup(F("Running Custom GCode"), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Wait, ICON_BLTouch); break; + #endif + case PrintConfirm: Draw_Popup(option ? F("") : F("Print file?"), F(""), F(""), Popup); break; default: break; } } -void CrealityDWINClass::Confirm_Handler(PopupID popupid) { +void CrealityDWINClass::Confirm_Handler(PopupID popupid, bool option/*=false*/) { popup = popupid; switch (popupid) { case FilInsert: Draw_Popup(F("Insert Filament"), F("Press to Continue"), F(""), Confirm); break; - case HeaterTime: Draw_Popup(F("Heater Timed Out"), F("Press to Reheat"), F(""), Confirm); break; - case UserInput: Draw_Popup(F("Waiting for Input"), F("Press to Continue"), F(""), Confirm); break; + case HeaterTime: Draw_Popup(GET_TEXT_F(MSG_HEATER_TIMEOUT), GET_TEXT_F(MSG_FILAMENT_CHANGE_HEAT), F(""), Confirm); break; + case UserInput: Draw_Popup(option ? GET_TEXT_F(MSG_STOPPED) : F("Waiting for Input"), GET_TEXT_F(MSG_ADVANCED_PAUSE_WAITING), F(""), Confirm); break; + case Level: Draw_Popup(F("Bed Leveling"), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Cancel, ICON_AutoLeveling); break; case LevelError: Draw_Popup(F("Couldn't enable Leveling"), F("(Valid mesh must exist)"), F(""), Confirm); break; case InvalidMesh: Draw_Popup(F("Valid mesh must exist"), F("before tuning can be"), F("performed"), Confirm); break; default: break; @@ -4039,24 +4952,24 @@ void CrealityDWINClass::Menu_Control() { EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState == ENCODER_DIFF_NO) return; if (encoder_diffState == ENCODER_DIFF_CW && selection < Get_Menu_Size(active_menu)) { - DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); + DWIN_Draw_Rectangle(1, Def_Background_Color, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); selection++; // Select Down if (selection > scrollpos+MROWS) { scrollpos++; - DWIN_Frame_AreaMove(1, 2, MLINE, Color_Bg_Black, 0, 31, DWIN_WIDTH, 349); + DWIN_Frame_AreaMove(1, 2, MLINE, Def_Background_Color, 0, 31, DWIN_WIDTH, 349); Menu_Item_Handler(active_menu, selection); } - DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Rectangle_Color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); + DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Def_Cursor_color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); } else if (encoder_diffState == ENCODER_DIFF_CCW && selection > 0) { - DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); + DWIN_Draw_Rectangle(1, Def_Background_Color, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); selection--; // Select Up if (selection < scrollpos) { scrollpos--; - DWIN_Frame_AreaMove(1, 3, MLINE, Color_Bg_Black, 0, 31, DWIN_WIDTH, 349); + DWIN_Frame_AreaMove(1, 3, MLINE, Def_Background_Color, 0, 31, DWIN_WIDTH, 349); Menu_Item_Handler(active_menu, selection); } - DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Rectangle_Color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); + DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Def_Cursor_color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); } else if (encoder_diffState == ENCODER_DIFF_ENTER) Menu_Item_Handler(active_menu, selection, false); @@ -4065,25 +4978,32 @@ void CrealityDWINClass::Menu_Control() { void CrealityDWINClass::Value_Control() { EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); + float difvalue = 0; if (encoder_diffState == ENCODER_DIFF_NO) return; - if (encoder_diffState == ENCODER_DIFF_CW) + if (encoder_diffState == ENCODER_DIFF_CW) { tempvalue += EncoderRate.encoderMoveValue; - else if (encoder_diffState == ENCODER_DIFF_CCW) + difvalue = EncoderRate.encoderMoveValue; + } + else if (encoder_diffState == ENCODER_DIFF_CCW) { tempvalue -= EncoderRate.encoderMoveValue; + difvalue = - EncoderRate.encoderMoveValue; + } else if (encoder_diffState == ENCODER_DIFF_ENTER) { process = Menu; EncoderRate.enabled = false; Draw_Float(tempvalue / valueunit, selection - scrollpos, false, valueunit); DWIN_UpdateLCD(); - if (active_menu == ZOffset && liveadjust) { + if (active_menu == ZOffset && temp_val.zoffsetmode != 0) { planner.synchronize(); - current_position.z += (tempvalue / valueunit - zoffsetvalue); - planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder); + if (temp_val.zoffsetmode == 1) { + current_position.z += (tempvalue / valueunit - temp_val.zoffsetvalue); + planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder); + } current_position.z = 0; sync_plan_position(); } else if (active_menu == Tune && selection == TUNE_ZOFFSET) { - sprintf_P(cmd, PSTR("M290 Z%s"), dtostrf((tempvalue / valueunit - zoffsetvalue), 1, 3, str_1)); + sprintf_P(cmd, PSTR("M290 Z%s"), dtostrf((tempvalue / valueunit - temp_val.zoffsetvalue), 1, 3, str_1)); gcode.process_subcommands_now(cmd); } if (TERN0(HAS_HOTEND, valuepointer == &thermalManager.temp_hotend[0].pid.Ki) || TERN0(HAS_HEATED_BED, valuepointer == &thermalManager.temp_bed.pid.Ki)) @@ -4104,17 +5024,33 @@ void CrealityDWINClass::Value_Control() { planner.buffer_line(current_position, manual_feedrate_mm_s[selection - 1], active_extruder); break; #if HAS_MESH - case ManualMesh: - planner.synchronize(); - planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder); - planner.synchronize(); - break; - case UBLMesh: mesh_conf.manual_mesh_move(true); break; + #if ENABLED(PROBE_MANUALLY) + case ManualMesh: + planner.synchronize(); + planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder); + planner.synchronize(); + break; + #endif + #if ENABLED(AUTO_BED_LEVELING_UBL) && !HAS_BED_PROBE + case UBLMesh: mesh_conf.manual_mesh_move(true); break; + #endif case LevelManual: mesh_conf.manual_mesh_move(selection == LEVELING_M_OFFSET); break; #endif } if (valuepointer == &planner.flow_percentage[0]) planner.refresh_e_factor(0); + #if ENABLED(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) + if (valuepointer == &caselight.brightness) + caselight.update_brightness(); + #endif + #if HAS_COLOR_LEDS + if ((valuepointer == &leds.color.r) || (valuepointer == &leds.color.g) || (valuepointer == &leds.color.b)) + ApplyLEDColor(); + #if HAS_WHITE_LED + if (valuepointer == &leds.color.w) ApplyLEDColor(); + #endif + #endif + if (funcpointer) funcpointer(); return; } @@ -4122,9 +5058,48 @@ void CrealityDWINClass::Value_Control() { NOMORE(tempvalue, (valuemax * valueunit)); Draw_Float(tempvalue / valueunit, selection - scrollpos, true, valueunit); DWIN_UpdateLCD(); - if (active_menu == Move && livemove) { - *(float*)valuepointer = tempvalue / valueunit; - planner.buffer_line(current_position, manual_feedrate_mm_s[selection - 1], active_extruder); + + if (valuepointer == &ui.brightness) { + *(uint8_t*)valuepointer = tempvalue / valueunit; + ui.refresh_brightness(); + } + + switch (active_menu) { + case Move: + if (temp_val.livemove) { + *(float*)valuepointer = tempvalue / valueunit; + planner.buffer_line(current_position, manual_feedrate_mm_s[selection - 1], active_extruder); + } + break; + case ZOffset: + if (temp_val.zoffsetmode == 2) { + planner.synchronize(); + sprintf_P(cmd, PSTR("M290 Z%s"), dtostrf((difvalue / valueunit), 1, 3, str_1)); + gcode.process_subcommands_now(cmd); + planner.synchronize(); + } + break; + case Tune: + if (selection == TUNE_ZOFFSET) { + planner.synchronize(); + sprintf_P(cmd, PSTR("M290 Z%s"), dtostrf((difvalue / valueunit), 1, 3, str_1)); + gcode.process_subcommands_now(cmd); + planner.synchronize(); + } + break; + #if ENABLED(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) + case CaseLightmenu: + *(uint8_t*)valuepointer = tempvalue / valueunit; + caselight.update_brightness(); + break; + #endif + #if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS) + case LedControlmenu: + *(uint8_t*)valuepointer = tempvalue / valueunit; + leds.update(); + break; + #endif + default : break; } } @@ -4155,7 +5130,37 @@ void CrealityDWINClass::Option_Control() { Redraw_Screen(); } else if (valuepointer == &preheat_modes) - preheatmode = tempvalue; + temp_val.preheatmode = tempvalue; + #if ENABLED(PREHEAT_BEFORE_LEVELING) + else if (valuepointer == &preheat_levmodes) { + temp_val.LevelingTempmode = tempvalue; + eeprom_settings.ena_hotend_levtemp = false; + eeprom_settings.ena_bed_levtemp = false; + if (temp_val.LevelingTempmode == 0 || temp_val.LevelingTempmode == 1) eeprom_settings.ena_hotend_levtemp = true; + if (temp_val.LevelingTempmode == 0 || temp_val.LevelingTempmode == 2) eeprom_settings.ena_bed_levtemp = true; + } + #endif + else if (valuepointer == &zoffset_modes) { + temp_val.zoffsetmode = tempvalue; + if (temp_val.zoffsetmode == 1 || temp_val.zoffsetmode == 2) { + if (axes_should_home()) { + Popup_Handler(Home); + gcode.home_all_axes(true); + } + Popup_Handler(MoveWait); + #if ENABLED(Z_SAFE_HOMING) + planner.synchronize(); + sprintf_P(cmd, PSTR("G0 F4000 X%s Y%s"), dtostrf(Z_SAFE_HOMING_X_POINT, 1, 3, str_1), dtostrf(Z_SAFE_HOMING_Y_POINT, 1, 3, str_2)); + gcode.process_subcommands_now(cmd); + #else + sprintf_P(cmd, PSTR("G0 F4000 X%s Y%s"), dtostrf((X_BED_SIZE + X_MIN_POS) / 2.0f, 1, 3, str_1), dtostrf((Y_BED_SIZE + Y_MIN_POS) / 2.0f, 1, 3, str_2)); + gcode.process_subcommands_now(cmd); + #endif + gcode.process_subcommands_now(F("G0 F300 Z0")); + planner.synchronize(); + Redraw_Menu(); + } + } Draw_Option(tempvalue, static_cast(valuepointer), selection - scrollpos, false, (valuepointer == &color_names)); DWIN_UpdateLCD(); @@ -4193,7 +5198,7 @@ void CrealityDWINClass::File_Control() { LOOP_S_L_N(i, MENU_CHAR_LIMIT + pos, MENU_CHAR_LIMIT) name[i] = filename[i - (MENU_CHAR_LIMIT + pos)]; } name[len] = '\0'; - DWIN_Draw_Rectangle(1, Color_Bg_Black, LBLX, MBASE(selection - scrollpos) - 14, 271, MBASE(selection - scrollpos) + 28); + DWIN_Draw_Rectangle(1, Def_Background_Color, LBLX, MBASE(selection - scrollpos) - 14, 271, MBASE(selection - scrollpos) + 28); Draw_Menu_Item(selection - scrollpos, card.flag.filenameIsDir ? ICON_More : ICON_File, name); if (-pos >= MENU_CHAR_LIMIT) filescrl = 0; filescrl++; @@ -4203,32 +5208,32 @@ void CrealityDWINClass::File_Control() { return; } if (encoder_diffState == ENCODER_DIFF_CW && selection < card.get_num_Files()) { - DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); + DWIN_Draw_Rectangle(1, Def_Background_Color, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); if (selection > 0) { - DWIN_Draw_Rectangle(1, Color_Bg_Black, LBLX, MBASE(selection - scrollpos) - 14, 271, MBASE(selection - scrollpos) + 28); + DWIN_Draw_Rectangle(1, Def_Background_Color, LBLX, MBASE(selection - scrollpos) - 14, 271, MBASE(selection - scrollpos) + 28); Draw_SD_Item(selection, selection - scrollpos); } filescrl = 0; selection++; // Select Down if (selection > scrollpos + MROWS) { scrollpos++; - DWIN_Frame_AreaMove(1, 2, MLINE, Color_Bg_Black, 0, 31, DWIN_WIDTH, 349); + DWIN_Frame_AreaMove(1, 2, MLINE, Def_Background_Color, 0, 31, DWIN_WIDTH, 349); Draw_SD_Item(selection, selection - scrollpos); } - DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Rectangle_Color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); + DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Def_Cursor_color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); } else if (encoder_diffState == ENCODER_DIFF_CCW && selection > 0) { - DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); - DWIN_Draw_Rectangle(1, Color_Bg_Black, LBLX, MBASE(selection - scrollpos) - 14, 271, MBASE(selection - scrollpos) + 28); + DWIN_Draw_Rectangle(1, Def_Background_Color, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); + DWIN_Draw_Rectangle(1, Def_Background_Color, LBLX, MBASE(selection - scrollpos) - 14, 271, MBASE(selection - scrollpos) + 28); Draw_SD_Item(selection, selection - scrollpos); filescrl = 0; selection--; // Select Up if (selection < scrollpos) { scrollpos--; - DWIN_Frame_AreaMove(1, 3, MLINE, Color_Bg_Black, 0, 31, DWIN_WIDTH, 349); + DWIN_Frame_AreaMove(1, 3, MLINE, Def_Background_Color, 0, 31, DWIN_WIDTH, 349); Draw_SD_Item(selection, selection - scrollpos); } - DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Rectangle_Color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); + DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Def_Cursor_color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); } else if (encoder_diffState == ENCODER_DIFF_ENTER) { if (selection == 0) { @@ -4248,7 +5253,11 @@ void CrealityDWINClass::File_Control() { Draw_SD_List(); } else { - card.openAndPrintFile(card.filename); + #if HAS_GCODE_PREVIEW + Preview_DrawFromSD(); + #else + card.openAndPrintFile(card.filename); + #endif } } } @@ -4273,8 +5282,8 @@ void CrealityDWINClass::Print_Screen_Control() { Update_Status_Bar(true); break; case PRINT_PAUSE_RESUME: - if (paused) { - if (sdprint) { + if (temp_val.paused) { + if (temp_val.sdprint) { wait_for_user = false; #if ENABLED(PARK_HEAD_ON_PAUSE) card.startOrResumeFilePrinting(); @@ -4282,14 +5291,14 @@ void CrealityDWINClass::Print_Screen_Control() { #else char cmd[20]; #if HAS_HEATED_BED - sprintf_P(cmd, PSTR("M140 S%i"), pausebed); + sprintf_P(cmd, PSTR("M140 S%i"), temp_val.pausebed); gcode.process_subcommands_now(cmd); #endif #if HAS_EXTRUDERS - sprintf_P(cmd, PSTR("M109 S%i"), pausetemp); + sprintf_P(cmd, PSTR("M109 S%i"), temp_val.pausetemp); gcode.process_subcommands_now(cmd); #endif - TERN_(HAS_FAN, thermalManager.fan_speed[0] = pausefan); + TERN_(HAS_FAN, thermalManager.fan_speed[0] = temp_val.pausefan); planner.synchronize(); TERN_(SDSUPPORT, queue.inject(F("M24"))); #endif @@ -4323,7 +5332,7 @@ void CrealityDWINClass::Popup_Control() { switch (popup) { case Pause: if (selection == 0) { - if (sdprint) { + if (temp_val.sdprint) { #if ENABLED(POWER_LOSS_RECOVERY) if (recovery.enabled) recovery.save(true); #endif @@ -4337,9 +5346,9 @@ void CrealityDWINClass::Popup_Control() { planner.synchronize(); #else queue.inject(F("M25")); - TERN_(HAS_HOTEND, pausetemp = thermalManager.temp_hotend[0].target); - TERN_(HAS_HEATED_BED, pausebed = thermalManager.temp_bed.target); - TERN_(HAS_FAN, pausefan = thermalManager.fan_speed[0]); + TERN_(HAS_HOTEND, temp_val.pausetemp = thermalManager.temp_hotend[0].target); + TERN_(HAS_HEATED_BED, temp_val.pausebed = thermalManager.temp_bed.target); + TERN_(HAS_FAN, temp_val.pausefan = thermalManager.fan_speed[0]); thermalManager.cooldown(); #endif } @@ -4351,7 +5360,7 @@ void CrealityDWINClass::Popup_Control() { break; case Stop: if (selection == 0) { - if (sdprint) { + if (temp_val.sdprint) { ui.abort_print(); thermalManager.cooldown(); } @@ -4387,7 +5396,7 @@ void CrealityDWINClass::Popup_Control() { case ManualProbing: if (selection == 0) { char buf[80]; - const float dif = probe.probe_at_point(current_position.x, current_position.y, PROBE_PT_STOW, 0, false) - corner_avg; + const float dif = probe.probe_at_point(current_position.x, current_position.y, PROBE_PT_STOW, 0, false) - temp_val.corner_avg; sprintf_P(buf, dif > 0 ? PSTR("Corner is %smm high") : PSTR("Corner is %smm low"), dtostrf(abs(dif), 1, 3, str_1)); Update_Status(buf); } @@ -4423,12 +5432,20 @@ void CrealityDWINClass::Popup_Control() { } else { pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT; - if (printing) Popup_Handler(Resuming); + if (temp_val.printing) Popup_Handler(Resuming); else Redraw_Menu(true, true, (active_menu==PreheatHotend)); } break; #endif // ADVANCED_PAUSE_FEATURE + case PrintConfirm: + if (selection==0) { + card.openAndPrintFile(card.filename);} + else{ + Redraw_Menu(true, true, true); + gcode.process_subcommands_now(F("M117"));} + break; + #if HAS_MESH case SaveLevel: if (selection == 0) { @@ -4470,8 +5487,15 @@ void CrealityDWINClass::Confirm_Control() { break; case HeaterTime: Popup_Handler(Heating); + Update_Status(GET_TEXT_F(MSG_HEATING)); wait_for_user = false; break; + #if HAS_ESDIAG + case ESDiagPopup: + wait_for_user = false; + Redraw_Menu(true, true, false); + break; + #endif default: Redraw_Menu(true, true, false); wait_for_user = false; @@ -4481,6 +5505,126 @@ void CrealityDWINClass::Confirm_Control() { DWIN_UpdateLCD(); } +#if HAS_HOSTACTION_MENUS + + void CrealityDWINClass::Keyboard_Control() { + const uint8_t keyboard_size = 34; + static uint8_t key_selection = 0, cursor = 0; + static char string[31]; + static bool uppercase = false, locked = false; + if (reset_keyboard) { + if (strcmp(stringpointer, "-") == 0) stringpointer[0] = '\0'; + key_selection = 0, cursor = strlen(stringpointer); + uppercase = false, locked = false; + reset_keyboard = false; + strcpy(string, stringpointer); + } + EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + if (encoder_diffState == ENCODER_DIFF_CW && key_selection < keyboard_size) { + Draw_Keys(key_selection, false, uppercase, locked); + key_selection++; + Draw_Keys(key_selection, true, uppercase, locked); + } + else if (encoder_diffState == ENCODER_DIFF_CCW && key_selection > 0) { + Draw_Keys(key_selection, false, uppercase, locked); + key_selection--; + Draw_Keys(key_selection, true, uppercase, locked); + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + if (key_selection < 28) { + if (key_selection == 19) { + if (!numeric_keyboard) { + if (locked) { + uppercase = false, locked = false; + Draw_Keyboard(keyboard_restrict, false, key_selection, uppercase, locked); + } else if (uppercase) { + locked = true; + Draw_Keyboard(keyboard_restrict, false, key_selection, uppercase, locked); + } + else { + uppercase = true; + Draw_Keyboard(keyboard_restrict, false, key_selection, uppercase, locked); + } + } + } + else if (key_selection == 27) { + cursor--; + string[cursor] = '\0'; + } + else { + uint8_t index = key_selection; + if (index > 19) index--; + if (index > 27) index--; + const char *keys; + if (numeric_keyboard) keys = "1234567890&<>() {}[]*\"\':;!?"; + else keys = (uppercase) ? "QWERTYUIOPASDFGHJKLZXCVBNM" : "qwertyuiopasdfghjklzxcvbnm"; + if (!(keyboard_restrict && numeric_keyboard && index > 9)) { + string[cursor] = keys[index]; + cursor++; + string[cursor] = '\0'; + } + if (!locked && uppercase) { + uppercase = false; + Draw_Keyboard(keyboard_restrict, false, key_selection, uppercase, locked); + } + } + } + else { + switch (key_selection) { + case 28: + if (!numeric_keyboard) uppercase = false, locked = false; + Draw_Keyboard(keyboard_restrict, !numeric_keyboard, key_selection, uppercase, locked); + break; + case 29: + string[cursor] = '-'; + cursor++; + string[cursor] = '\0'; + break; + case 30: + string[cursor] = '_'; + cursor++; + string[cursor] = '\0'; + break; + case 31: + if (!keyboard_restrict) { + string[cursor] = ' '; + cursor++; + string[cursor] = '\0'; + } + break; + case 32: + if (!keyboard_restrict) { + string[cursor] = '.'; + cursor++; + string[cursor] = '\0'; + } + break; + case 33: + if (!keyboard_restrict) { + string[cursor] = '/'; + cursor++; + string[cursor] = '\0'; + } + break; + case 34: + if (string[0] == '\0') strcpy(string, "-"); + strcpy(stringpointer, string); + process = Menu; + DWIN_Draw_Rectangle(1, Def_Background_Color, 0, KEY_Y_START, DWIN_WIDTH-2, DWIN_HEIGHT-2); + Draw_Status_Area(true); + Update_Status_Bar(true); + break; + } + } + if (strlen(string) > maxstringlen) string[maxstringlen] = '\0', cursor = maxstringlen; + Draw_String(string, selection, (process==Keyboard), (maxstringlen > 10)); + } + DWIN_UpdateLCD(); + } + +#endif // HAS_HOSTACTION_MENUS + /* In-Menu Value Modification */ void CrealityDWINClass::Setup_Value(float value, float min, float max, float unit, uint8_t type) { @@ -4540,24 +5684,37 @@ void CrealityDWINClass::Modify_Option(uint8_t value, const char * const * option Draw_Option(value, options, selection - scrollpos, true); } +#if HAS_HOSTACTION_MENUS + void CrealityDWINClass::Modify_String(char * string, uint8_t maxlength, bool restrict) { + stringpointer = string; + maxstringlen = maxlength; + reset_keyboard = true; + Draw_Keyboard(restrict, false); + Draw_String(string, selection, true, (maxstringlen > 10)); + } +#endif + /* Main Functions */ +void CrealityDWINClass::Update_Print_Filename(const char * const text) { + LOOP_L_N(i, _MIN((size_t)LONG_FILENAME_LENGTH, strlen(text))) filename[i] = text[i]; + filename[_MIN((size_t)LONG_FILENAME_LENGTH - 1, strlen(text))] = '\0'; + Draw_Print_Filename(true); +} + void CrealityDWINClass::Update_Status(const char * const text) { - if (strncmp_P(text, PSTR(""), 3) == 0) { - LOOP_L_N(i, _MIN((size_t)LONG_FILENAME_LENGTH, strlen(text))) filename[i] = text[i + 3]; - filename[_MIN((size_t)LONG_FILENAME_LENGTH - 1, strlen(text))] = '\0'; - Draw_Print_Filename(true); - } - else { - LOOP_L_N(i, _MIN((size_t)64, strlen(text))) statusmsg[i] = text[i]; - statusmsg[_MIN((size_t)64, strlen(text))] = '\0'; - } + LOOP_L_N(i, _MIN((size_t)64, strlen(text))) statusmsg[i] = text[i]; + statusmsg[_MIN((size_t)64, strlen(text))] = '\0'; +} + +void CrealityDWINClass::Update_Status(FSTR_P text) { + Update_Status(FTOP(text)); } void CrealityDWINClass::Start_Print(bool sd) { - sdprint = sd; - if (!printing) { - printing = true; + temp_val.sdprint = sd; + if (!temp_val.printing) { + temp_val.printing = true; statusmsg[0] = '\0'; if (sd) { #if ENABLED(POWER_LOSS_RECOVERY) @@ -4569,8 +5726,6 @@ void CrealityDWINClass::Start_Print(bool sd) { #endif strcpy(filename, card.longest_filename()); } - else - strcpy_P(filename, PSTR("Host Print")); TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress(0)); TERN_(USE_M73_REMAINING_TIME, ui.set_remaining_time(0)); Draw_Print_Screen(); @@ -4578,12 +5733,13 @@ void CrealityDWINClass::Start_Print(bool sd) { } void CrealityDWINClass::Stop_Print() { - printing = false; - sdprint = false; + temp_val.printing = false; + temp_val.sdprint = false; thermalManager.cooldown(); TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress(100 * (PROGRESS_SCALE))); TERN_(USE_M73_REMAINING_TIME, ui.set_remaining_time(0)); - Draw_Print_confirm(); + Draw_PrintDone_confirm(); + filename[0] = '\0'; } void CrealityDWINClass::Update() { @@ -4598,6 +5754,13 @@ void CrealityDWINClass::Update() { case Print: Print_Screen_Control(); break; case Popup: Popup_Control(); break; case Confirm: Confirm_Control(); break; + #if HAS_HOSTACTION_MENUS + case Keyboard: Keyboard_Control(); break; + #endif + case Cancel: Confirm_Control(); break; + #if HAS_LOCKSCREEN + case Locked: HMI_LockScreen(); break; + #endif } } @@ -4608,14 +5771,14 @@ void MarlinUI::update() { CrealityDWIN.Update(); } #endif void CrealityDWINClass::State_Update() { - if ((print_job_timer.isRunning() || print_job_timer.isPaused()) != printing) { - if (!printing) Start_Print(card.isFileOpen() || TERN0(POWER_LOSS_RECOVERY, recovery.valid())); + if ((print_job_timer.isRunning() || print_job_timer.isPaused()) != temp_val.printing) { + if (!temp_val.printing) Start_Print(card.isFileOpen() || TERN0(POWER_LOSS_RECOVERY, recovery.valid())); else Stop_Print(); } - if (print_job_timer.isPaused() != paused) { - paused = print_job_timer.isPaused(); + if (print_job_timer.isPaused() != temp_val.paused) { + temp_val.paused = print_job_timer.isPaused(); if (process == Print) Print_Screen_Icons(); - if (process == Wait && !paused) Redraw_Menu(true, true); + if (process == Wait && !temp_val.paused) Redraw_Menu(true, true); } if (wait_for_user && !(process == Confirm) && !print_job_timer.isPaused()) Confirm_Handler(UserInput); @@ -4624,7 +5787,7 @@ void CrealityDWINClass::State_Update() { if (pause_menu_response == PAUSE_RESPONSE_EXTRUDE_MORE) Popup_Handler(FilChange); else if (pause_menu_response == PAUSE_RESPONSE_RESUME_PRINT) { - if (printing) Popup_Handler(Resuming); + if (temp_val.printing) Popup_Handler(Resuming); else Redraw_Menu(true, true, (active_menu==PreheatHotend)); } } @@ -4643,14 +5806,20 @@ void CrealityDWINClass::Screen_Update() { static millis_t scrltime = 0; if (ELAPSED(ms, scrltime)) { scrltime = ms + 200; - Update_Status_Bar(); + if (process != Keyboard) Update_Status_Bar(); if (process == Print) Draw_Print_Filename(); } static millis_t statustime = 0; - if (ELAPSED(ms, statustime)) { + if (ELAPSED(ms, statustime) && process != Keyboard) { statustime = ms + 500; Draw_Status_Area(); + #if HAS_ESDIAG + if (process == Confirm && popup == ESDiagPopup) ESDiag.Update(); + #endif + #if HAS_PIDPLOT + if (process == Wait && (popup == PIDWaitH || popup == PIDWaitB)) Plot.Update((popup == PIDWaitH) ? thermalManager.wholeDegHotend(0) : thermalManager.wholeDegBed()); + #endif } static millis_t printtime = 0; @@ -4681,22 +5850,22 @@ void CrealityDWINClass::Screen_Update() { #endif #if HAS_ZOFFSET_ITEM - static float lastzoffset = zoffsetvalue; - if (zoffsetvalue != lastzoffset) { - lastzoffset = zoffsetvalue; + static float lastzoffset = temp_val.zoffsetvalue; + if (temp_val.zoffsetvalue != lastzoffset) { + lastzoffset = temp_val.zoffsetvalue; #if HAS_BED_PROBE - probe.offset.z = zoffsetvalue; + probe.offset.z = temp_val.zoffsetvalue; #else - set_home_offset(Z_AXIS, -zoffsetvalue); + set_home_offset(Z_AXIS, -temp_val.zoffsetvalue); #endif } #if HAS_BED_PROBE if (probe.offset.z != lastzoffset) - zoffsetvalue = lastzoffset = probe.offset.z; + temp_val.zoffsetvalue = lastzoffset = probe.offset.z; #else if (-home_offset.z != lastzoffset) - zoffsetvalue = lastzoffset = -home_offset.z; + temp_val.zoffsetvalue = lastzoffset = -home_offset.z; #endif #endif // HAS_ZOFFSET_ITEM @@ -4772,8 +5941,15 @@ void CrealityDWINClass::AudioFeedback(const bool success/*=true*/) { } void CrealityDWINClass::Save_Settings(char *buff) { + TERN_(DEBUG_DWIN, SERIAL_ECHOLNPGM("Save_Settings")); TERN_(AUTO_BED_LEVELING_UBL, eeprom_settings.tilt_grid_size = mesh_conf.tilt_grid - 1); - eeprom_settings.corner_pos = corner_pos * 10; + eeprom_settings.corner_pos = temp_val.corner_pos * 10; + #if HAS_HOSTACTION_MENUS + eeprom_settings.host_action_label_1 = Encode_String(action1); + eeprom_settings.host_action_label_2 = Encode_String(action2); + eeprom_settings.host_action_label_3 = Encode_String(action3); + #endif + TERN_(DEBUG_DWIN, SERIAL_ECHOLNPGM("eeprom_settings size: ", sizeof(eeprom_settings_t))); memcpy(buff, &eeprom_settings, _MIN(sizeof(eeprom_settings), eeprom_data_size)); } @@ -4781,7 +5957,29 @@ void CrealityDWINClass::Load_Settings(const char *buff) { memcpy(&eeprom_settings, buff, _MIN(sizeof(eeprom_settings), eeprom_data_size)); TERN_(AUTO_BED_LEVELING_UBL, mesh_conf.tilt_grid = eeprom_settings.tilt_grid_size + 1); if (eeprom_settings.corner_pos == 0) eeprom_settings.corner_pos = 325; - corner_pos = eeprom_settings.corner_pos / 10.0f; + temp_val.corner_pos = eeprom_settings.corner_pos / 10.0f; + #if ENABLED(BAUD_RATE_GCODE) + if (eeprom_settings.Baud115k) queue.inject(F("M575 P0 B115200")); + #endif + #if ENABLED(FWRETRACT) + temp_val.auto_fw_retract = fwretract.autoretract_enabled; + #endif + #if ENABLED(PREHEAT_BEFORE_LEVELING) + temp_val.LevelingTempmode = 2 * !eeprom_settings.ena_hotend_levtemp + !eeprom_settings.ena_bed_levtemp; + #endif + #if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS) + leds.set_color( + (temp_val.LED_Color >> 16) & 0xFF, + (temp_val.LED_Color >> 8) & 0xFF, + (temp_val.LED_Color >> 0) & 0xFF + OPTARG(HAS_WHITE_LED, (temp_val.LED_Color >> 24) & 0xFF) + ); + #endif + #if HAS_HOSTACTION_MENUS + Decode_String(eeprom_settings.host_action_label_1, action1); + Decode_String(eeprom_settings.host_action_label_2, action2); + Decode_String(eeprom_settings.host_action_label_3, action3); + #endif Redraw_Screen(); #if ENABLED(POWER_LOSS_RECOVERY) static bool init = true; @@ -4808,26 +6006,69 @@ void CrealityDWINClass::Reset_Settings() { eeprom_settings.coordinates_text = 0; eeprom_settings.coordinates_split_line = 0; TERN_(AUTO_BED_LEVELING_UBL, mesh_conf.tilt_grid = eeprom_settings.tilt_grid_size + 1); - corner_pos = eeprom_settings.corner_pos / 10.0f; + temp_val.corner_pos = eeprom_settings.corner_pos / 10.0f; TERN_(SOUND_MENU_ITEM, ui.sound_on = ENABLED(SOUND_ON_DEFAULT)); + TERN_(BAUD_RATE_GCODE, eeprom_settings.Baud115k = false); + TERN_(FWRETRACT, temp_val.auto_fw_retract = fwretract.autoretract_enabled); + #if ENABLED(PREHEAT_BEFORE_LEVELING) + eeprom_settings.ena_hotend_levtemp = true; + eeprom_settings.ena_bed_levtemp = true; + eeprom_settings.hotend_levtemp = LEVELING_NOZZLE_TEMP; + eeprom_settings.bed_levtemp = LEVELING_BED_TEMP; + #endif + #if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS) + leds.setup(); + #if ENABLED(LED_COLOR_PRESETS) + leds.set_default(); + #endif + temp_val.LED_Color = Def_Leds_Color; + leds.set_color( + (temp_val.LED_Color >> 16) & 0xFF, + (temp_val.LED_Color >> 8) & 0xFF, + (temp_val.LED_Color >> 0) & 0xFF + OPTARG(HAS_WHITE_LED, (temp_val.LED_Color >> 24) & 0xFF) + ); + #endif + #if HAS_HOSTACTION_MENUS + eeprom_settings.host_action_label_1 = 0; + eeprom_settings.host_action_label_2 = 0; + eeprom_settings.host_action_label_3 = 0; + action1[0] = action2[0] = action3[0] = '-'; + #endif Redraw_Screen(); } +void CrealityDWINClass::PreheatBefore() { + #if ENABLED(PREHEAT_BEFORE_LEVELING) + Popup_Handler(Heating); + #if HAS_BED_PROBE + probe.preheat_for_probing(eeprom_settings.ena_hotend_levtemp, eeprom_settings.ena_bed_levtemp); + #else + #if HAS_HOTEND + if (thermalManager.degTargetHotend(0) < eeprom_settings.hotend_levtemp && (eeprom_settings.ena_hotend_levtemp)) + thermalManager.setTargetHotend(eeprom_settings.hotend_levtemp, 0); + #endif + #if HAS_HEATED_BED + if (thermalManager.degTargetBed() < eeprom_settings.bed_levtemp && (eeprom_settings.ena_bed_levtemp)) + thermalManager.setTargetBed(eeprom_settings.bed_levtemp); + #endif + TERN_(HAS_HOTEND, if (eeprom_settings.ena_hotend_levtemp) thermalManager.wait_for_hotend(0)); + TERN_(HAS_HEATED_BED, if (eeprom_settings.ena_bed_levtemp) thermalManager.wait_for_bed_heating()); + #endif + Update_Status(""); + #endif +} + void MarlinUI::init_lcd() { - delay(800); - SERIAL_ECHOPGM("\nDWIN handshake "); - if (DWIN_Handshake()) SERIAL_ECHOLNPGM("ok."); else SERIAL_ECHOLNPGM("error."); - DWIN_Frame_SetDir(1); // Orientation 90° - DWIN_UpdateLCD(); // Show bootscreen (first image) + DWINUI::init(); Encoder_Configuration(); + DWIN_JPG_ShowAndCache(0); for (uint16_t t = 0; t <= 100; t += 2) { - DWIN_ICON_Show(ICON, ICON_Bar, 15, 260); - DWIN_Draw_Rectangle(1, Color_Bg_Black, 15 + t * 242 / 100, 260, 257, 280); + DWINUI::DRAW_IconWB(ICON, ICON_Bar, 15, 260); + DWIN_Draw_Rectangle(1, Def_Background_Color, 15 + t * 242 / 100, 260, 257, 280); DWIN_UpdateLCD(); delay(20); } - - DWIN_JPG_ShowAndCache(3); DWIN_JPG_CacheTo1(Language_English); CrealityDWIN.Redraw_Screen(); } @@ -4836,8 +6077,8 @@ void MarlinUI::init_lcd() { void MarlinUI::pause_show_message(const PauseMessage message, const PauseMode mode/*=PAUSE_MODE_SAME*/, const uint8_t extruder/*=active_extruder*/) { switch (message) { case PAUSE_MESSAGE_INSERT: CrealityDWIN.Confirm_Handler(FilInsert); break; - case PAUSE_MESSAGE_PURGE: - case PAUSE_MESSAGE_OPTION: CrealityDWIN.Popup_Handler(PurgeMore); break; + case PAUSE_MESSAGE_PURGE: break; + case PAUSE_MESSAGE_OPTION: pause_menu_response = PAUSE_RESPONSE_WAIT_FOR; CrealityDWIN.Popup_Handler(PurgeMore); break; case PAUSE_MESSAGE_HEAT: CrealityDWIN.Confirm_Handler(HeaterTime); break; case PAUSE_MESSAGE_WAITING: CrealityDWIN.Draw_Print_Screen(); break; default: break; @@ -4845,4 +6086,109 @@ void MarlinUI::init_lcd() { } #endif +// End-stops diagnostic from DWIN PROUI +#if HAS_ESDIAG + void CrealityDWINClass::DWIN_EndstopsDiag() { + last_process = process; + last_selection = selection; + process = Confirm; + popup = ESDiagPopup; + ESDiag.Draw(); + } +#endif + +// Lock screen from DWIN PROUI +#if HAS_LOCKSCREEN + void CrealityDWINClass::DWIN_LockScreen() { + if (process != Locked) { + lockScreen.rprocess = process; + process = Locked; + lockScreen.init(); + } + } + + void CrealityDWINClass::DWIN_UnLockScreen() { + if (process == Locked) { + process = lockScreen.rprocess; + if (!temp_val.printing) Draw_Main_Menu(); else Draw_Print_Screen(); + } + } + + void CrealityDWINClass::HMI_LockScreen() { + EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + lockScreen.onEncoder(encoder_diffState); + if (lockScreen.isUnlocked()) DWIN_UnLockScreen(); + } +#endif + +// Reboot screen from DWIN PROUI +void CrealityDWINClass::DWIN_RebootScreen() { + DWIN_Frame_Clear(Def_Background_Color); + DWIN_JPG_ShowAndCache(0); + DWINUI::Draw_CenteredString(Def_Text_Color, 220, GET_TEXT_F(MSG_PLEASE_WAIT_REBOOT)); + DWIN_UpdateLCD(); + delay(500); +} + +// Reboot Printer from DWIN PROUI +void CrealityDWINClass::RebootPrinter() { + wait_for_heatup = wait_for_user = false; // Stop waiting for heating/user + thermalManager.disable_all_heaters(); + planner.finish_and_disable(); + DWIN_RebootScreen(); + hal.reboot(); +} + +#if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS) + void CrealityDWINClass::ApplyLEDColor() { + temp_val.LED_Color = TERN0(HAS_WHITE_LED,(leds.color.w << 24)) | (leds.color.r << 16) | (leds.color.g << 8) | (leds.color.b); + } +#endif + +#if HAS_PIDPLOT + void CrealityDWINClass::DWIN_Draw_PIDPopup(const pidresult_t pidresult) { + frame_rect_t gfrm = {40, 160, DWIN_WIDTH - 80, 150}; + DWINUI::ClearMainArea(); + DWIN_Draw_Rectangle(1, Def_PopupBg_color, 14, 60, 258, 330); + DWIN_Draw_Rectangle(0, Def_Highlight_Color, 14, 60, 258, 330); + DWINUI::Draw_CenteredString(Def_PopupTxt_Color, 80, GET_TEXT_F(MSG_PID_AUTOTUNE)); + DWINUI::Draw_String(Def_PopupTxt_Color, gfrm.x, gfrm.y - DWINUI::fontHeight() - 4, F("PID target: Celsius")); + switch (pidresult) { + case PID_EXTR_START: + DWINUI::Draw_CenteredString(Def_PopupTxt_Color, 100, F("for Nozzle is running.")); + Plot.Draw(gfrm, thermalManager.hotend_maxtemp[0], temp_val.PID_e_temp); + DWINUI::Draw_Int(Def_PopupTxt_Color, 3, gfrm.x + 90, gfrm.y - DWINUI::fontHeight() - 4, temp_val.PID_e_temp); + break; + case PID_BED_START: + DWINUI::Draw_CenteredString(Def_PopupTxt_Color, 100, F("for BED is running.")); + Plot.Draw(gfrm, BED_MAXTEMP, temp_val.PID_bed_temp); + DWINUI::Draw_Int(Def_PopupTxt_Color, 3, gfrm.x + 90, gfrm.y - DWINUI::fontHeight() - 4, temp_val.PID_bed_temp); + break; + default: + break; + } + } +#endif + +#if HAS_PID_HEATING + void CrealityDWINClass::DWIN_PidTuning(const pidresult_t pidresult) { + switch (pidresult) { + case PID_STARTED: break; + #if HAS_PIDPLOT + case PID_EXTR_START: last_process = process; last_selection = selection; process = Wait; popup = PIDWaitH; DWIN_Draw_PIDPopup(pidresult); break; + case PID_BED_START: last_process = process; last_selection = selection; process = Wait; popup = PIDWaitB; DWIN_Draw_PIDPopup(pidresult); break; + #else + case PID_EXTR_START: Popup_Handler(PIDWait); break; + case PID_BED_START: Popup_Handler(PIDWait, true); break; + #endif + case PID_BAD_EXTRUDER_NUM: Confirm_Handler(BadextruderNumber); break; + case PID_TEMP_TOO_HIGH: Confirm_Handler(TempTooHigh); break; + case PID_TUNING_TIMEOUT: Confirm_Handler(PIDTimeout); break; + case PID_DONE: Confirm_Handler(PIDDone); break; + default: break; + } + } +#endif + #endif // DWIN_CREALITY_LCD_JYERSUI diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.h b/Marlin/src/lcd/e3v2/jyersui/dwin.h index 8985647cd131..c42c0677dce1 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.h +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.h @@ -23,27 +23,26 @@ /** * lcd/e3v2/jyersui/dwin.h + * JYERSUI Author: Jacob Myers + * + * JYERSUI Enhanced by LCH-77 + * Version: 1.9 + * Date: Jun 16, 2022 */ -#include "dwin_lcd.h" -#include "../common/dwin_set.h" -#include "../common/dwin_font.h" -#include "../common/dwin_color.h" -#include "../common/encoder.h" -#include "../../../libs/BL24CXX.h" - -#include "../../../inc/MarlinConfigPre.h" +#include "dwin_defines.h" -//#define DWIN_CREALITY_LCD_CUSTOM_ICONS +#include "../../../inc/MarlinConfig.h" enum processID : uint8_t { - Main, Print, Menu, Value, Option, File, Popup, Confirm, Wait + Main, Print, Menu, Value, Option, File, Popup, Confirm, Wait, Locked, Cancel, Keyboard }; enum PopupID : uint8_t { Pause, Stop, Resume, SaveLevel, ETemp, ConfFilChange, PurgeMore, MeshSlot, - Level, Home, MoveWait, Heating, FilLoad, FilChange, TempWarn, Runout, PIDWait, Resuming, ManualProbing, - FilInsert, HeaterTime, UserInput, LevelError, InvalidMesh, UI, Complete, Custom + Level, Home, MoveWait, Heating, FilLoad, FilChange, TempWarn, Runout, Resuming, ManualProbing, + FilInsert, HeaterTime, UserInput, LevelError, InvalidMesh, UI, Complete, Custom, ESDiagPopup, PrintConfirm, + PIDWait, PIDWaitH, PIDWaitB, BadextruderNumber, TempTooHigh, PIDTimeout, PIDDone }; enum menuID : uint8_t { @@ -55,6 +54,7 @@ enum menuID : uint8_t { ZOffset, Preheat, ChangeFilament, + HostActions, MenuCustom, Control, TempMenu, @@ -69,105 +69,108 @@ enum menuID : uint8_t { HomeOffsets, MaxSpeed, MaxAcceleration, - MaxJerk, + #if HAS_CLASSIC_JERK + MaxJerk, + #endif + #if HAS_JUNCTION_DEVIATION + JDmenu, + #endif Steps, + #if ENABLED(FWRETRACT) + FwRetraction, + #endif Visual, ColorSettings, + HostSettings, + ActionCommands, Advanced, - ProbeMenu, + #if HAS_BED_PROBE + ProbeMenu, + #endif Info, - Leveling, - LevelManual, - LevelView, - MeshViewer, - LevelSettings, - ManualMesh, - UBLMesh, + #if HAS_MESH + Leveling, + LevelManual, + LevelView, + MeshViewer, + LevelSettings, + #if ENABLED(PROBE_MANUALLY) + ManualMesh, + #endif + #if ENABLED(AUTO_BED_LEVELING_UBL) && !HAS_BED_PROBE + UBLMesh, + #endif + #endif InfoMain, Tune, - PreheatHotend + PreheatHotend, + #if ANY(CASE_LIGHT_MENU, LED_CONTROL_MENU) + Ledsmenu, + #if BOTH(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) + CaseLightmenu, + #endif + #if ENABLED(LED_CONTROL_MENU) + LedControlmenu, + #if HAS_COLOR_LEDS + #if ENABLED(LED_COLOR_PRESETS) + LedControlpresets, + #else + LedControlcustom, + #endif + #endif + #endif + #endif }; -// Custom icons -#if ENABLED(DWIN_CREALITY_LCD_CUSTOM_ICONS) - // index of every custom icon should be >= CUSTOM_ICON_START - #define CUSTOM_ICON_START ICON_Checkbox_F - #define ICON_Checkbox_F 200 - #define ICON_Checkbox_T 201 - #define ICON_Fade 202 - #define ICON_Mesh 203 - #define ICON_Tilt 204 - #define ICON_Brightness 205 - #define ICON_AxisD 249 - #define ICON_AxisBR 250 - #define ICON_AxisTR 251 - #define ICON_AxisBL 252 - #define ICON_AxisTL 253 - #define ICON_AxisC 254 -#else - #define ICON_Fade ICON_Version - #define ICON_Mesh ICON_Version - #define ICON_Tilt ICON_Version - #define ICON_Brightness ICON_Version - #define ICON_AxisD ICON_Axis - #define ICON_AxisBR ICON_Axis - #define ICON_AxisTR ICON_Axis - #define ICON_AxisBL ICON_Axis - #define ICON_AxisTL ICON_Axis - #define ICON_AxisC ICON_Axis -#endif +typedef struct { + // Flags + bool flag_tune = false; + bool auto_fw_retract = false; + bool printing = false; + bool paused = false; + bool sdprint = false; + bool livemove = false; + bool liveadjust = false; + bool probe_deployed = false; + // Auxiliary values + AxisEnum axis = X_AXIS; // Axis Select + int16_t pausetemp = 0; + int16_t pausebed = 0; + int16_t pausefan = 0; + uint8_t preheatmode = 0; + uint8_t zoffsetmode = 0; + float zoffsetvalue = 0; + uint8_t gridpoint; + float corner_avg; + float corner_pos; + float zval; + #if ENABLED(PREHEAT_BEFORE_LEVELING) + uint8_t LevelingTempmode = 0; + #endif + #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) + uint32_t LED_Color = Def_Leds_Color; + #endif + #if HAS_PID_HEATING + uint16_t PID_e_temp = 180; + uint16_t PID_bed_temp = 60; + #endif +} temp_val_t; +extern temp_val_t temp_val; +#define Custom_Colors 10 enum colorID : uint8_t { Default, White, Green, Cyan, Blue, Magenta, Red, Orange, Yellow, Brown, Black }; - -#define Custom_Colors 10 -#define Color_Aqua RGB(0x00,0x3F,0x1F) -#define Color_Light_White 0xBDD7 -#define Color_Green RGB(0x00,0x3F,0x00) -#define Color_Light_Green 0x3460 -#define Color_Cyan 0x07FF -#define Color_Light_Cyan 0x04F3 -#define Color_Blue 0x015F -#define Color_Light_Blue 0x3A6A -#define Color_Magenta 0xF81F -#define Color_Light_Magenta 0x9813 -#define Color_Light_Red 0x8800 -#define Color_Orange 0xFA20 -#define Color_Light_Orange 0xFBC0 -#define Color_Light_Yellow 0x8BE0 -#define Color_Brown 0xCC27 -#define Color_Light_Brown 0x6204 -#define Color_Black 0x0000 -#define Color_Grey 0x18E3 -#define Check_Color 0x4E5C // Check-box check color -#define Confirm_Color 0x34B9 -#define Cancel_Color 0x3186 +enum pidresult_t : uint8_t { PID_STARTED, PID_EXTR_START, PID_BED_START, PID_BAD_EXTRUDER_NUM, PID_TEMP_TOO_HIGH, PID_TUNING_TIMEOUT, PID_DONE }; class CrealityDWINClass { public: - static constexpr size_t eeprom_data_size = 48; - static struct EEPROM_Settings { // use bit fields to save space, max 48 bytes - bool time_format_textual : 1; - #if ENABLED(AUTO_BED_LEVELING_UBL) - uint8_t tilt_grid_size : 3; - #endif - uint16_t corner_pos : 10; - uint8_t cursor_color : 4; - uint8_t menu_split_line : 4; - uint8_t menu_top_bg : 4; - uint8_t menu_top_txt : 4; - uint8_t highlight_box : 4; - uint8_t progress_percent : 4; - uint8_t progress_time : 4; - uint8_t status_bar_text : 4; - uint8_t status_area_text : 4; - uint8_t coordinates_text : 4; - uint8_t coordinates_split_line : 4; - } eeprom_settings; - static constexpr const char * const color_names[11] = { "Default", "White", "Green", "Cyan", "Blue", "Magenta", "Red", "Orange", "Yellow", "Brown", "Black" }; static constexpr const char * const preheat_modes[3] = { "Both", "Hotend", "Bed" }; + static constexpr const char * const zoffset_modes[3] = { "No Live" , "OnClick", " Live" }; + #if ENABLED(PREHEAT_BEFORE_LEVELING) + static constexpr const char * const preheat_levmodes[4] = { " Both", " Hotend", " Bed", " None" }; + #endif static void Clear_Screen(uint8_t e=3); static void Draw_Float(float value, uint8_t row, bool selected=false, uint8_t minunit=10); @@ -192,7 +195,7 @@ class CrealityDWINClass { static void Draw_Print_ProgressRemain(); #endif static void Draw_Print_ProgressElapsed(); - static void Draw_Print_confirm(); + static void Draw_PrintDone_confirm(); static void Draw_SD_Item(uint8_t item, uint8_t row); static void Draw_SD_List(bool removed=false); static void Draw_Status_Area(bool icons=false); @@ -209,8 +212,8 @@ class CrealityDWINClass { static uint8_t Get_Menu_Size(uint8_t menu); static void Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw=true); - static void Popup_Handler(PopupID popupid, bool option = false); - static void Confirm_Handler(PopupID popupid); + static void Popup_Handler(PopupID popupid, bool option=false); + static void Confirm_Handler(PopupID popupid, bool option=false); static void Main_Menu_Control(); static void Menu_Control(); @@ -231,6 +234,7 @@ class CrealityDWINClass { static void Modify_Option(uint8_t value, const char * const * options, uint8_t max); static void Update_Status(const char * const text); + static void Update_Status(FSTR_P text); static void Start_Print(bool sd); static void Stop_Print(); static void Update(); @@ -240,6 +244,40 @@ class CrealityDWINClass { static void Save_Settings(char *buff); static void Load_Settings(const char *buff); static void Reset_Settings(); + static void PreheatBefore(); + + #if HAS_ESDIAG + static void DWIN_EndstopsDiag(); + #endif + #if HAS_LOCKSCREEN + static void DWIN_LockScreen(); + static void DWIN_UnLockScreen(); + static void HMI_LockScreen(); + #endif + static void DWIN_RebootScreen(); + static void RebootPrinter(); + static void Update_Print_Filename(const char * const text); + #if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS) + static void ApplyLEDColor(); + #endif + + #if HAS_HOSTACTION_MENUS + static void Draw_String(char * string, uint8_t row, bool selected=false, bool below=false); + static const uint64_t Encode_String(const char * string); + static void Decode_String(uint64_t num, char * string); + static void Draw_Keyboard(bool restrict, bool numeric, uint8_t selected=0, bool uppercase=false, bool lock=false); + static void Draw_Keys(uint8_t index, bool selected, bool uppercase=false, bool lock=false); + static void Modify_String(char * string, uint8_t maxlength, bool restrict); + static void Keyboard_Control(); + #endif + + #if HAS_PIDPLOT + static void DWIN_Draw_PIDPopup(const pidresult_t pidresult); + #endif + + #if HAS_PID_HEATING + static void DWIN_PidTuning(const pidresult_t pidresult); + #endif }; extern CrealityDWINClass CrealityDWIN; diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin_defines.h b/Marlin/src/lcd/e3v2/jyersui/dwin_defines.h new file mode 100644 index 000000000000..72d428448899 --- /dev/null +++ b/Marlin/src/lcd/e3v2/jyersui/dwin_defines.h @@ -0,0 +1,131 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * DWIN general defines and data structs for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.11.2 + * Date: 2022/02/28 + * + * Modded for JYERSUI by LCH-77 + * Version: 1.9 + * Date: Jun 16, 2022 + */ + +#include "../../../inc/MarlinConfigPre.h" + +#define HAS_ESDIAG 1 +#define HAS_LOCKSCREEN 1 +#define HAS_PIDPLOT 1 +#define HAS_GCODE_PREVIEW 1 +//#define DEBUG_DWIN 1 +//#define NEED_HEX_PRINT 1 + +#if ENABLED(HOST_ACTION_COMMANDS) + #define HAS_HOSTACTION_MENUS 1 +#endif + +#include "../../../core/types.h" +#include "../common/dwin_color.h" + +// Default UI Colors +#define Def_Background_Color RGB(4,4,0) +#define Def_Cursor_color RGB(24,24,0) +#define Def_TitleBg_color RGB(12,12,0) +#define Def_TitleTxt_color Color_White +#define Def_Text_Color Color_White +#define Def_Selected_Color RGB(24,24,0) +#define Def_SplitLine_Color RGB(24,24,0) +#define Def_Highlight_Color RGB(31,40,0) +#define Def_StatusBg_Color RGB(12,12,0) +#define Def_StatusTxt_Color Color_White +#define Def_PopupBg_color Color_Bg_Window +#define Def_PopupTxt_Color Popup_Text_Color +#define Def_AlertBg_Color Color_Bg_Red +#define Def_AlertTxt_Color Color_Yellow +#define Def_PercentTxt_Color RGB(31,48,8) +#define Def_Barfill_Color RGB(12,12,0) +#define Def_Indicator_Color RGB(31,48,8) +#define Def_Coordinate_Color Color_White +#define Def_Button_Color RGB(12,12,0) + +#if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS) + #define Def_Leds_Color 0xFFFFFFFF +#endif +#if ENABLED(CASELIGHT_USES_BRIGHTNESS) + #define Def_CaseLight_Brightness 255 +#endif + +#if HAS_MESH + #ifndef MESH_INSET + #define MESH_INSET 25 + #endif + #ifndef MESH_MIN_X + #define MESH_MIN_X MESH_INSET + #endif + #ifndef MESH_MIN_Y + #define MESH_MIN_Y MESH_INSET + #endif + #ifndef MESH_MAX_X + #define MESH_MAX_X X_BED_SIZE - (MESH_INSET) + #endif + #ifndef MESH_MAX_Y + #define MESH_MAX_Y X_BED_SIZE - (MESH_INSET) + #endif +#endif + +typedef struct { + bool time_format_textual : 1; + #if ENABLED(AUTO_BED_LEVELING_UBL) + uint8_t tilt_grid_size : 3; + #endif + uint16_t corner_pos : 10; + uint8_t cursor_color : 4; + uint8_t menu_split_line : 4; + uint8_t menu_top_bg : 4; + uint8_t menu_top_txt : 4; + uint8_t highlight_box : 4; + uint8_t progress_percent : 4; + uint8_t progress_time : 4; + uint8_t status_bar_text : 4; + uint8_t status_area_text : 4; + uint8_t coordinates_text : 4; + uint8_t coordinates_split_line : 4; + #if ENABLED(BAUD_RATE_GCODE) + bool Baud115k : 1; + #endif + #if ENABLED(PREHEAT_BEFORE_LEVELING) + bool ena_hotend_levtemp : 1; + bool ena_bed_levtemp : 1; + celsius_t hotend_levtemp = LEVELING_NOZZLE_TEMP; + celsius_t bed_levtemp = LEVELING_BED_TEMP; + #endif + #if HAS_HOSTACTION_MENUS + uint64_t host_action_label_1 : 48; + uint64_t host_action_label_2 : 48; + uint64_t host_action_label_3 : 48; + #endif +} eeprom_settings_t; + +static constexpr size_t eeprom_data_size = 48; +extern eeprom_settings_t eeprom_settings; diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin_lcd.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin_lcd.cpp index 04889e92b038..24d55272a3e9 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin_lcd.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin_lcd.cpp @@ -53,12 +53,41 @@ void DWIN_Draw_DegreeSymbol(uint16_t Color, uint16_t x, uint16_t y) { /*---------------------------------------- Picture related functions ----------------------------------------*/ -// Draw an Icon +// Draw an Icon with transparent background // libID: Icon library ID // picID: Icon ID // x/y: Upper-left point void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) { - DWIN_ICON_Show(true, false, false, libID, picID, x, y); + DWIN_ICON_Show(false, false, true, libID, picID, x, y); +} + +// From DWIN Enhanced implementation for PRO UI v3.10.1 +// Write buffer data to the SRAM or Flash +// mem: 0x5A=32KB SRAM, 0xA5=16KB Flash +// addr: start address +// length: Bytes to write +// data: address of the buffer with data +void DWIN_WriteToMem(uint8_t mem, uint16_t addr, uint16_t length, uint8_t *data) { + const uint8_t max_size = 128; + uint16_t pending = length; + uint16_t to_send; + uint16_t indx; + uint8_t block = 0; + + while (pending > 0) { + indx = block * max_size; + to_send = _MIN(pending, max_size); + size_t i = 0; + DWIN_Byte(i, 0x31); + DWIN_Byte(i, mem); + DWIN_Word(i, addr + indx); // start address of the data block + ++i; + LOOP_L_N(j, i) { LCD_SERIAL.write(DWIN_SendBuf[j]); delayMicroseconds(1); } // Buf header + for (uint16_t j = indx; j <= indx + to_send - 1; j++) LCD_SERIAL.write(*(data + j)); delayMicroseconds(1); // write block of data + LOOP_L_N(j, 4) { LCD_SERIAL.write(DWIN_BufTail[j]); delayMicroseconds(1); } + block++; + pending -= to_send; + } } #endif // DWIN_CREALITY_LCD_JYERSUI diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin_lcd.h b/Marlin/src/lcd/e3v2/jyersui/dwin_lcd.h index f76cfb5d3e5f..b1aeadbbc51b 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin_lcd.h +++ b/Marlin/src/lcd/e3v2/jyersui/dwin_lcd.h @@ -32,3 +32,11 @@ // Color: color // x/y: Upper-left coordinate of the first pixel void DWIN_Draw_DegreeSymbol(uint16_t Color, uint16_t x, uint16_t y); + +// From DWIN Enhanced implementation for PRO UI v3.10.1 +// Write buffer data to the SRAM or Flash +// mem: 0x5A=32KB SRAM, 0xA5=16KB Flash +// addr: start address +// length: Bytes to write +// data: address of the buffer with data +void DWIN_WriteToMem(uint8_t mem, uint16_t addr, uint16_t length, uint8_t *data); diff --git a/Marlin/src/lcd/e3v2/jyersui/dwinui.cpp b/Marlin/src/lcd/e3v2/jyersui/dwinui.cpp new file mode 100644 index 000000000000..1573bff552d9 --- /dev/null +++ b/Marlin/src/lcd/e3v2/jyersui/dwinui.cpp @@ -0,0 +1,340 @@ +/** + * 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 . + * + */ + +/** + * DWIN Enhanced implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.17.1 + * Date: 2022/04/12 + * + * Modded for JYERSUI by LCH-77 + * Version: 1.9 + * Date: Jun 16, 2022 + */ + +#include "../../../inc/MarlinConfigPre.h" + +#if ENABLED(DWIN_CREALITY_LCD_JYERSUI) + +#include "../../../inc/MarlinConfig.h" +#include "dwin_lcd.h" +#include "dwinui.h" +#include "dwin_defines.h" + +//#define DEBUG_OUT 1 +#include "../../../core/debug_out.h" + +xy_int_t DWINUI::cursor = { 0 }; +uint16_t DWINUI::pencolor = Color_White; +uint16_t DWINUI::textcolor = Def_Text_Color; +uint16_t DWINUI::backcolor = Def_Background_Color; +uint16_t DWINUI::buttoncolor = Def_Button_Color; +uint8_t DWINUI::font = font8x16; +FSTR_P const DWINUI::Author = F(STRING_CONFIG_H_AUTHOR); + +void DWINUI::init() { + delay(750); // Delay for wait to wakeup screen + const bool hs = DWIN_Handshake(); UNUSED(hs); + #if ENABLED(DEBUG_DWIN) + SERIAL_ECHOPGM("DWIN_Handshake "); + SERIAL_ECHOLNF(hs ? F("ok.") : F("error.")); + #endif + DWIN_Frame_SetDir(1); + cursor.reset(); + pencolor = Color_White; + textcolor = Def_Text_Color; + backcolor = Def_Background_Color; + buttoncolor = Def_Button_Color; + font = font8x16; +} + +// Set text/number font +void DWINUI::setFont(uint8_t cfont) { + font = cfont; +} + +// Get font character width +uint8_t DWINUI::fontWidth(uint8_t cfont) { + switch (cfont) { + case font6x12 : return 6; + case font8x16 : return 8; + case font10x20: return 10; + case font12x24: return 12; + case font14x28: return 14; + case font16x32: return 16; + case font20x40: return 20; + case font24x48: return 24; + case font28x56: return 28; + case font32x64: return 32; + default: return 0; + } +} + +// Get font character height +uint8_t DWINUI::fontHeight(uint8_t cfont) { + switch (cfont) { + case font6x12 : return 12; + case font8x16 : return 16; + case font10x20: return 20; + case font12x24: return 24; + case font14x28: return 28; + case font16x32: return 32; + case font20x40: return 40; + case font24x48: return 48; + case font28x56: return 56; + case font32x64: return 64; + default: return 0; + } +} + +// Get screen x coordinates from text column +uint16_t DWINUI::ColToX(uint8_t col) { + return col * fontWidth(font); +} + +// Get screen y coordinates from text row +uint16_t DWINUI::RowToY(uint8_t row) { + return row * fontHeight(font); +} + +// Set text/number color +void DWINUI::SetColors(uint16_t fgcolor, uint16_t bgcolor, uint16_t alcolor) { + textcolor = fgcolor; + backcolor = bgcolor; + buttoncolor = alcolor; +} +void DWINUI::SetTextColor(uint16_t fgcolor) { + textcolor = fgcolor; +} +void DWINUI::SetBackgroundColor(uint16_t bgcolor) { + backcolor = bgcolor; +} + +// Moves cursor to point +// x: abscissa of the display +// y: ordinate of the display +// point: xy coordinate +void DWINUI::MoveTo(int16_t x, int16_t y) { + cursor.x = x; + cursor.y = y; +} +void DWINUI::MoveTo(xy_int_t point) { + cursor = point; +} + +// Moves cursor relative to the actual position +// x: abscissa of the display +// y: ordinate of the display +// point: xy coordinate +void DWINUI::MoveBy(int16_t x, int16_t y) { + cursor.x += x; + cursor.y += y; +} +void DWINUI::MoveBy(xy_int_t point) { + cursor += point; +} + +// Draw a Centered string using arbitrary x1 and x2 margins +void DWINUI::Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string) { + const uint16_t x = _MAX(0U, x2 + x1 - strlen_P(string) * fontWidth(size)) / 2 - 1; + DWIN_Draw_String(bShow, size, color, bColor, x, y, string); +} + +// Draw a char +// color: Character color +// x: abscissa of the display +// y: ordinate of the display +// c: ASCII code of char +void DWINUI::Draw_Char(uint16_t color, uint16_t x, uint16_t y, const char c) { + const char string[2] = { c, 0}; + DWIN_Draw_String(false, font, color, backcolor, x, y, string, 1); +} + +// Draw a char at cursor position and increment cursor +void DWINUI::Draw_Char(uint16_t color, const char c) { + Draw_Char(color, cursor.x, cursor.y, c); + MoveBy(fontWidth(font), 0); +} + +// Draw a string at cursor position +// color: Character color +// *string: The string +// rlimit: For draw less chars than string length use rlimit +void DWINUI::Draw_String(const char * const string, uint16_t rlimit) { + DWIN_Draw_String(false, font, textcolor, backcolor, cursor.x, cursor.y, string, rlimit); + MoveBy(strlen(string) * fontWidth(font), 0); +} +void DWINUI::Draw_String(uint16_t color, const char * const string, uint16_t rlimit) { + DWIN_Draw_String(false, font, color, backcolor, cursor.x, cursor.y, string, rlimit); + MoveBy(strlen(string) * fontWidth(font), 0); +} + +// Draw a numeric integer value +// bShow: true=display background color; false=don't display background color +// signedMode: 1=signed; 0=unsigned +// size: Font size +// color: Character color +// bColor: Background color +// iNum: Number of digits +// x/y: Upper-left coordinate +// value: Integer value +void DWINUI::Draw_Int(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value) { + char nstr[10]; + sprintf_P(nstr, PSTR("%*li"), (signedMode ? iNum + 1 : iNum), value); + DWIN_Draw_String(bShow, size, color, bColor, x, y, nstr); +} + +// Draw a numeric float value +// bShow: true=display background color; false=don't display background color +// signedMode: 1=signed; 0=unsigned +// size: Font size +// color: Character color +// bColor: Background color +// iNum: Number of digits +// fNum: Number of decimal digits +// x/y: Upper-left coordinate +// value: float value +void DWINUI::Draw_Float(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + char nstr[10]; + DWIN_Draw_String(bShow, size, color, bColor, x, y, dtostrf(value, iNum + (signedMode ? 2:1) + fNum, fNum, nstr)); +} + +// ------------------------- Buttons ------------------------------// + +void DWINUI::Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char * const caption) { + DWIN_Draw_Rectangle(1, bcolor, x1, y1, x2, y2); + Draw_CenteredString(0, font, color, bcolor, x1, x2, (y2 + y1 - fontHeight())/2, caption); +} + +void DWINUI::Draw_Button(uint8_t id, uint16_t x, uint16_t y) { + switch (id) { + case BTN_Cancel : Draw_Button(GET_TEXT_F(MSG_BUTTON_CANCEL), x, y); break; + case BTN_Confirm : Draw_Button(GET_TEXT_F(MSG_BUTTON_CONFIRM), x, y); break; + case BTN_Continue: Draw_Button(GET_TEXT_F(MSG_BUTTON_CONTINUE), x, y); break; + case BTN_Print : Draw_Button(GET_TEXT_F(MSG_BUTTON_PRINT), x, y); break; + case BTN_Save : Draw_Button(GET_TEXT_F(MSG_BUTTON_SAVE), x, y); break; + case BTN_Purge : Draw_Button(GET_TEXT_F(MSG_BUTTON_PURGE), x, y); break; + default: break; + } +} + +// -------------------------- Extra -------------------------------// + +// Draw a circle +// color: circle color +// x: the abscissa of the center of the circle +// y: ordinate of the center of the circle +// r: circle radius +void DWINUI::Draw_Circle(uint16_t color, uint16_t x, uint16_t y, uint8_t r) { + int a = 0, b = 0; + while (a <= b) { + b = SQRT(sq(r) - sq(a)); + if (a == 0) b--; + DWIN_Draw_Point(color, 1, 1, x + a, y + b); // Draw some sector 1 + DWIN_Draw_Point(color, 1, 1, x + b, y + a); // Draw some sector 2 + DWIN_Draw_Point(color, 1, 1, x + b, y - a); // Draw some sector 3 + DWIN_Draw_Point(color, 1, 1, x + a, y - b); // Draw some sector 4 + DWIN_Draw_Point(color, 1, 1, x - a, y - b); // Draw some sector 5 + DWIN_Draw_Point(color, 1, 1, x - b, y - a); // Draw some sector 6 + DWIN_Draw_Point(color, 1, 1, x - b, y + a); // Draw some sector 7 + DWIN_Draw_Point(color, 1, 1, x - a, y + b); // Draw some sector 8 + a++; + } +} + +// Draw a circle filled with color +// bcolor: fill color +// x: the abscissa of the center of the circle +// y: ordinate of the center of the circle +// r: circle radius +void DWINUI::Draw_FillCircle(uint16_t bcolor, uint16_t x,uint16_t y,uint8_t r) { + int a = 0, b = 0; + while (a <= b) { + b = SQRT(sq(r) - sq(a)); // b=sqrt(r*r-a*a); + if (a == 0) b--; + DWIN_Draw_Line(bcolor, x-b,y-a,x+b,y-a); + DWIN_Draw_Line(bcolor, x-a,y-b,x+a,y-b); + DWIN_Draw_Line(bcolor, x-b,y+a,x+b,y+a); + DWIN_Draw_Line(bcolor, x-a,y+b,x+a,y+b); + a++; + } +} + +// Color Interpolator +// val : Interpolator minv..maxv +// minv : Minimum value +// maxv : Maximum value +// color1 : Start color +// color2 : End color +uint16_t DWINUI::ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2) { + uint8_t B, G, R; + const float n = (float)(val - minv) / (maxv - minv); + R = (1 - n) * GetRColor(color1) + n * GetRColor(color2); + G = (1 - n) * GetGColor(color1) + n * GetGColor(color2); + B = (1 - n) * GetBColor(color1) + n * GetBColor(color2); + return RGB(R, G, B); +} + +// Color Interpolator through Red->Yellow->Green->Blue (Pro UI) +// val : Interpolator minv..maxv +// minv : Minimum value +// maxv : Maximum value +uint16_t DWINUI::RainbowInt(int16_t val, int16_t minv, int16_t maxv) { + uint8_t B, G, R; + const uint8_t maxB = 28, maxR = 28, maxG = 38; + const int16_t limv = _MAX(abs(minv), abs(maxv)); + float n = minv >= 0 ? (float)(val - minv) / (maxv - minv) : (float)val / limv; + LIMIT(n, -1, 1); + if (n < 0) { + R = 0; + G = (1 + n) * maxG; + B = (-n) * maxB; + } + else if (n < 0.5) { + R = maxR * n * 2; + G = maxG; + B = 0; + } + else { + R = maxR; + G = maxG * (1 - n); + B = 0; + } + return RGB(R, G, B); +} + +// Draw a checkbox +// Color: frame color +// bColor: Background color +// x/y: Upper-left point +// mode : 0 : unchecked, 1 : checked +void DWINUI::Draw_Checkbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t y, bool checked=false) { + DWIN_Draw_String(true, font8x16, color, bcolor, x + 4, y, checked ? F("x") : F(" ")); + DWIN_Draw_Rectangle(0, color, x + 2, y + 2, x + 17, y + 17); +} + +// Clear Menu by filling the menu area with background color +void DWINUI::ClearMainArea() { + DWIN_Draw_Rectangle(1, backcolor, 0, TITLE_HEIGHT, DWIN_WIDTH - 1, STATUS_Y - 1); +} + +#endif // DWIN_CREALITY_LCD_JYERSUI diff --git a/Marlin/src/lcd/e3v2/jyersui/dwinui.h b/Marlin/src/lcd/e3v2/jyersui/dwinui.h new file mode 100644 index 000000000000..779e6270a128 --- /dev/null +++ b/Marlin/src/lcd/e3v2/jyersui/dwinui.h @@ -0,0 +1,527 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * DWIN Enhanced implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.17.1 + * Date: 2022/04/12 + * + * Modded for JYERSUI by LCH-77 + * Version: 1.9 + * Date: Jun 16, 2022 + */ + +#include "dwin_lcd.h" +#include "../common/dwin_set.h" +#include "../common/dwin_font.h" +#include "../common/dwin_color.h" +#include "../common/dwin_api.h" + +// Custom icons +//#define DWIN_CREALITY_LCD_CUSTOM_ICONS +#if ENABLED(DWIN_CREALITY_LCD_CUSTOM_ICONS) + // index of every custom icon should be >= CUSTOM_ICON_START + #define CUSTOM_ICON_START ICON_Checkbox_F + #define ICON_Checkbox_F 200 + #define ICON_Checkbox_T 201 + #define ICON_Fade 202 + #define ICON_Mesh 203 + #define ICON_Tilt 204 + #define ICON_Brightness 205 + #define ICON_AxisD 249 + #define ICON_AxisBR 250 + #define ICON_AxisTR 251 + #define ICON_AxisBL 252 + #define ICON_AxisTL 253 + #define ICON_AxisC 254 +#else + #define ICON_Fade ICON_Version + #define ICON_Mesh ICON_Version + #define ICON_Tilt ICON_Version + #define ICON_Brightness ICON_Version + #define ICON_AxisD ICON_Axis + #define ICON_AxisBR ICON_Axis + #define ICON_AxisTR ICON_Axis + #define ICON_AxisBL ICON_Axis + #define ICON_AxisTL ICON_Axis + #define ICON_AxisC ICON_Axis + #define ICON_ESDiag ICON_Info + #define ICON_Lock ICON_Cool + #define ICON_Reboot ICON_ResumeEEPROM + #define ICON_ProbeAlarm ICON_SetEndTemp + #define ICON_ProbeMargin ICON_PrintSize + #define ICON_ProbeSelfTest ICON_SetEndTemp + #define ICON_ProbeSet ICON_SetEndTemp + #define ICON_ProbeDeploy ICON_SetEndTemp + #define ICON_ProbeTest ICON_SetEndTemp + #define ICON_ProbeTestCount ICON_SetEndTemp + #define ICON_ProbeZSpeed ICON_MaxSpeedZ + #define ICON_FWRetLength ICON_StepE + #define ICON_FWRetSpeed ICON_Setspeed + #define ICON_FWRetZRaise ICON_MoveZ + #define ICON_FWRecExtLength ICON_StepE + #define ICON_FWRecSpeed ICON_Setspeed + #define ICON_HSMode ICON_StockConfiguration + #define ICON_Sound ICON_Cool + #define ICON_CaseLight ICON_Motion + #define ICON_LedControl ICON_Motion + #define ICON_MeshActive ICON_HotendTemp + #define ICON_Park ICON_Motion +#endif + +// Buttons +#define BTN_Continue 85 +#define BTN_Cancel 87 +#define BTN_Confirm 89 +#define BTN_Print 90 +#define BTN_Save 91 +#define BTN_Purge 92 + +// Extended UI Colors +#define Color_Aqua RGB(0,63,31) +#define Color_Light_White 0xBDD7 +#define Color_Green RGB(0,63,0) +#define Color_Light_Green 0x3460 +#define Color_Cyan 0x07FF +#define Color_Light_Cyan 0x04F3 +#define Color_Blue RGB(0,0,31) +#define Color_Light_Blue 0x3A6A +#define Color_Magenta 0xF81F +#define Color_Light_Magenta 0x9813 +#define Color_Light_Red 0x8800 +#define Color_Orange 0xFA20 +#define Color_Light_Orange 0xFBC0 +#define Color_Light_Yellow 0x8BE0 +#define Color_Brown 0xCC27 +#define Color_Light_Brown 0x6204 +#define Color_Black 0x0000 +#define Color_Grey 0x18E3 +#define Check_Color 0x4E5C +#define Confirm_Color 0x34B9 +#define Cancel_Color 0x3186 + +// UI element defines and constants +#define DWIN_FONT_MENU font8x16 +#define DWIN_FONT_STAT font10x20 +#define DWIN_FONT_HEAD font10x20 +#define DWIN_FONT_ALERT font10x20 +#define STATUS_Y 354 +#define LCD_WIDTH (DWIN_WIDTH / 8) // only if the default font is font8x16 + +// Minimum unit (0.1) : multiple (10) +#define UNITFDIGITS 1 +#define MINUNITMULT POW(10, UNITFDIGITS) + +constexpr uint8_t TITLE_HEIGHT = 30, // Title bar height + MLINE = 53, // Menu line height + TROWS = (STATUS_Y - TITLE_HEIGHT) / MLINE, // Total rows + MROWS = TROWS - 1, // Other-than-Back + ICOX = 26, // Menu item icon X position + LBLX = 60, // Menu item label X position + VALX = 210, // Menu item value X position + MENU_CHR_W = 8, MENU_CHR_H = 16, // Menu font 8x16 + STAT_CHR_W = 10; + +// Menuitem Y position +#define MYPOS(L) (TITLE_HEIGHT + MLINE * (L)) + +// Menuitem caption Offset +#define CAPOFF ((MLINE - MENU_CHR_H) / 2) + +// Menuitem caption Y position +#define MBASE(L) (MYPOS(L) + CAPOFF) + +typedef struct { uint16_t left, top, right, bottom; } rect_t; +typedef struct { uint16_t x, y, w, h; } frame_rect_t; + +namespace DWINUI { + extern xy_int_t cursor; + extern uint16_t pencolor; + extern uint16_t textcolor; + extern uint16_t backcolor; + extern uint16_t buttoncolor; + extern uint8_t font; + extern FSTR_P const Author; + + // DWIN LCD Initialization + void init(); + + // Set text/number font + void setFont(uint8_t cfont); + + // Get font character width + uint8_t fontWidth(uint8_t cfont); + inline uint8_t fontWidth() { return fontWidth(font); }; + + // Get font character height + uint8_t fontHeight(uint8_t cfont); + inline uint8_t fontHeight() { return fontHeight(font); }; + + // Get screen x coordinates from text column + uint16_t ColToX(uint8_t col); + + // Get screen y coordinates from text row + uint16_t RowToY(uint8_t row); + + // Set text/number color + void SetColors(uint16_t fgcolor, uint16_t bgcolor, uint16_t alcolor); + void SetTextColor(uint16_t fgcolor); + void SetBackgroundColor(uint16_t bgcolor); + + // Moves cursor to point + // x: abscissa of the display + // y: ordinate of the display + // point: xy coordinate + void MoveTo(int16_t x, int16_t y); + void MoveTo(xy_int_t point); + + // Moves cursor relative to the actual position + // x: abscissa of the display + // y: ordinate of the display + // point: xy coordinate + void MoveBy(int16_t x, int16_t y); + void MoveBy(xy_int_t point); + + // Draw a line from the cursor to xy position + // color: Line segment color + // x/y: End point + inline void LineTo(uint16_t color, uint16_t x, uint16_t y) { + DWIN_Draw_Line(color, cursor.x, cursor.y, x, y); + } + inline void LineTo(uint16_t x, uint16_t y) { + DWIN_Draw_Line(pencolor, cursor.x, cursor.y, x, y); + } + + // Extend a frame box + // v: value to extend + inline frame_rect_t ExtendFrame(frame_rect_t frame, uint8_t v) { + frame_rect_t t; + t.x = frame.x - v; + t.y = frame.y - v; + t.w = frame.w + 2 * v; + t.h = frame.h + 2 * v; + return t; + } + + // Draw an Icon with transparent background from the library ICON + // icon: Icon ID + // x/y: Upper-left point + inline void Draw_Icon(uint8_t icon, uint16_t x, uint16_t y) { + DWIN_ICON_Show(ICON, icon, x, y); + } + + // Draw an Icon from the library ICON with its background + // icon: Icon ID + // x/y: Upper-left point + inline void Draw_IconWB(uint8_t icon, uint16_t x, uint16_t y) { + DWIN_ICON_Show(true, false, false, ICON, icon, x, y); + } + inline void DRAW_IconWB(uint8_t libID, uint8_t icon, uint16_t x, uint16_t y) { + DWIN_ICON_Show(true, false, false, libID, icon, x, y); + } + + // Draw a numeric integer value + // bShow: true=display background color; false=don't display background color + // signedMode: 1=signed; 0=unsigned + // size: Font size + // color: Character color + // bColor: Background color + // iNum: Number of digits + // x/y: Upper-left coordinate + // value: Integer value + void Draw_Int(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value); + + // Draw a positive integer + inline void Draw_Int(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(bShow, 0, size, color, bColor, iNum, x, y, value); + } + inline void Draw_Int(uint8_t iNum, long value) { + Draw_Int(false, 0, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value); + MoveBy(iNum * fontWidth(font), 0); + } + inline void Draw_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(false, 0, font, textcolor, backcolor, iNum, x, y, value); + } + inline void Draw_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(false, 0, font, color, backcolor, iNum, x, y, value); + } + inline void Draw_Int(uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(true, 0, font, color, bColor, iNum, x, y, value); + } + inline void Draw_Int(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(true, 0, size, color, bColor, iNum, x, y, value); + } + + // Draw a signed integer + inline void Draw_Signed_Int(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(bShow, 1, size, color, bColor, iNum, x, y, value); + } + inline void Draw_Signed_Int(uint8_t iNum, long value) { + Draw_Int(false, 1, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value); + MoveBy(iNum * fontWidth(font), 0); + } + inline void Draw_Signed_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(false, 1, font, textcolor, backcolor, iNum, x, y, value); + } + inline void Draw_Signed_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(false, 1, font, color, backcolor, iNum, x, y, value); + } + inline void Draw_Signed_Int(uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(true, 1, font, color, bColor, iNum, x, y, value); + } + inline void Draw_Signed_Int(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(true, 1, size, color, bColor, iNum, x, y, value); + } + + // Draw a numeric float value + // bShow: true=display background color; false=don't display background color + // signedMode: 1=signed; 0=unsigned + // size: Font size + // color: Character color + // bColor: Background color + // iNum: Number of digits + // fNum: Number of decimal digits + // x/y: Upper-left coordinate + // value: float value + void Draw_Float(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value); + + // Draw a positive floating point number + inline void Draw_Float(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(bShow, 0, size, color, bColor, iNum, fNum, x, y, value); + } + inline void Draw_Float(uint8_t iNum, uint8_t fNum, float value) { + Draw_Float(false, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); + MoveBy((iNum + fNum + 1) * fontWidth(font), 0); + } + inline void Draw_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(false, 0, font, textcolor, backcolor, iNum, fNum, x, y, value); + } + inline void Draw_Float(uint8_t size, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(false, 0, size, textcolor, backcolor, iNum, fNum, x, y, value); + } + inline void Draw_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(true, 0, font, color, bColor, iNum, fNum, x, y, value); + } + inline void Draw_Float(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(true, 0, size, color, bColor, iNum, fNum, x, y, value); + } + + // Draw a signed floating point number + inline void Draw_Signed_Float(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(bShow, 1, size, color, bColor, iNum, fNum, x, y, value); + } + inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, float value) { + Draw_Float(false, 1, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); + MoveBy((iNum + fNum + 1) * fontWidth(font), 0); + } + inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(false, 1, font, textcolor, backcolor, iNum, fNum, x, y, value); + } + inline void Draw_Signed_Float(uint8_t size, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(false, 1, size, textcolor, backcolor, iNum, fNum, x, y, value); + } + inline void Draw_Signed_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(true, 1, font, color, bColor, iNum, fNum, x, y, value); + } + inline void Draw_Signed_Float(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(true, 1, size, color, bColor, iNum, fNum, x, y, value); + } + + // Draw a char + // color: Character color + // x: abscissa of the display + // y: ordinate of the display + // c: ASCII code of char + void Draw_Char(uint16_t color, uint16_t x, uint16_t y, const char c); + inline void Draw_Char(uint16_t x, uint16_t y, const char c) { Draw_Char(textcolor, x, y, c); }; + // Draw a char at cursor position and increment cursor + void Draw_Char(uint16_t color, const char c); + inline void Draw_Char(const char c) { Draw_Char(textcolor, c); } + + // Draw a string at cursor position + // color: Character color + // *string: The string + // rlimit: For draw less chars than string length use rlimit + void Draw_String(const char * const string, uint16_t rlimit = 0xFFFF); + void Draw_String(uint16_t color, const char * const string, uint16_t rlimit = 0xFFFF); + inline void Draw_String(FSTR_P string, uint16_t rlimit = 0xFFFF) { + Draw_String(FTOP(string), rlimit); + } + inline void Draw_String(uint16_t color, FSTR_P string, uint16_t rlimit = 0xFFFF) { + Draw_String(color, FTOP(string), rlimit); + } + + // Draw a string + // size: Font size + // color: Character color + // bColor: Background color + // x/y: Upper-left coordinate of the string + // *string: The string + inline void Draw_String(uint16_t x, uint16_t y, const char * const string) { + DWIN_Draw_String(false, font, textcolor, backcolor, x, y, string); + } + inline void Draw_String(uint16_t x, uint16_t y, FSTR_P title) { + DWIN_Draw_String(false, font, textcolor, backcolor, x, y, FTOP(title)); + } + inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, const char * const string) { + DWIN_Draw_String(false, font, color, backcolor, x, y, string); + } + inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, FSTR_P title) { + DWIN_Draw_String(false, font, color, backcolor, x, y, title); + } + inline void Draw_String(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) { + DWIN_Draw_String(true, font, color, bgcolor, x, y, string); + } + inline void Draw_String(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) { + DWIN_Draw_String(true, font, color, bgcolor, x, y, title); + } + inline void Draw_String(uint8_t size, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) { + DWIN_Draw_String(true, size, color, bgcolor, x, y, string); + } + inline void Draw_String(uint8_t size, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) { + DWIN_Draw_String(true, size, color, bgcolor, x, y, title); + } + + // Draw a centered string using DWIN_WIDTH + // bShow: true=display background color; false=don't display background color + // size: Font size + // color: Character color + // bColor: Background color + // y: Upper coordinate of the string + // *string: The string + void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string); + inline void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const char * const string) { + Draw_CenteredString(bShow, size, color, bColor, 0, DWIN_WIDTH, y, string); + } + inline void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, FSTR_P string) { + Draw_CenteredString(bShow, size, color, bColor, y, FTOP(string)); + } + inline void Draw_CenteredString(uint16_t color, uint16_t bcolor, uint16_t y, const char * const string) { + Draw_CenteredString(true, font, color, bcolor, y, string); + } + inline void Draw_CenteredString(uint8_t size, uint16_t color, uint16_t y, const char * const string) { + Draw_CenteredString(false, size, color, backcolor, y, string); + } + inline void Draw_CenteredString(uint8_t size, uint16_t color, uint16_t y, FSTR_P title) { + Draw_CenteredString(false, size, color, backcolor, y, title); + } + inline void Draw_CenteredString(uint16_t color, uint16_t y, const char * const string) { + Draw_CenteredString(false, font, color, backcolor, y, string); + } + inline void Draw_CenteredString(uint16_t color, uint16_t y, FSTR_P title) { + Draw_CenteredString(false, font, color, backcolor, y, title); + } + inline void Draw_CenteredString(uint16_t y, const char * const string) { + Draw_CenteredString(false, font, textcolor, backcolor, y, string); + } + inline void Draw_CenteredString(uint16_t y, FSTR_P title) { + Draw_CenteredString(false, font, textcolor, backcolor, y, title); + } + + // Draw a box + // mode: 0=frame, 1=fill, 2=XOR fill + // color: Rectangle color + // frame: Box coordinates and size + inline void Draw_Box(uint8_t mode, uint16_t color, frame_rect_t frame) { + DWIN_Draw_Box(mode, color, frame.x, frame.y, frame.w, frame.h); + } + + // Draw a circle + // Color: circle color + // x: abscissa of the center of the circle + // y: ordinate of the center of the circle + // r: circle radius + void Draw_Circle(uint16_t color, uint16_t x,uint16_t y,uint8_t r); + inline void Draw_Circle(uint16_t color, uint8_t r) { + Draw_Circle(color, cursor.x, cursor.y, r); + } + + // Draw a checkbox + // Color: frame color + // bColor: Background color + // x/y: Upper-left point + // checked : 0 : unchecked, 1 : checked + void Draw_Checkbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t y, bool checked); + inline void Draw_Checkbox(uint16_t x, uint16_t y, bool checked=false) { + Draw_Checkbox(textcolor, backcolor, x, y, checked); + } + + // Color Interpolator + // val : Interpolator minv..maxv + // minv : Minimum value + // maxv : Maximum value + // color1 : Start color + // color2 : End color + uint16_t ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2); + + // ------------------------- Buttons ------------------------------// + + void Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char * const caption); + inline void Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, FSTR_P caption) { + Draw_Button(color, bcolor, x1, y1, x2, y2, FTOP(caption)); + } + inline void Draw_Button(FSTR_P caption, uint16_t x, uint16_t y) { + Draw_Button(textcolor, buttoncolor, x, y, x + 99, y + 37, caption); + } + void Draw_Button(uint8_t id, uint16_t x, uint16_t y); + + // -------------------------- Extra -------------------------------// + + // Draw a circle filled with color + // bcolor: fill color + // x: abscissa of the center of the circle + // y: ordinate of the center of the circle + // r: circle radius + void Draw_FillCircle(uint16_t bcolor, uint16_t x,uint16_t y,uint8_t r); + inline void Draw_FillCircle(uint16_t bcolor, uint8_t r) { + Draw_FillCircle(bcolor, cursor.x, cursor.y, r); + } + + // Color Interpolator through Red->Yellow->Green->Blue + // val : Interpolator minv..maxv + // minv : Minimum value + // maxv : Maximum value + uint16_t RainbowInt(int16_t val, int16_t minv, int16_t maxv); + + // Write buffer data to the SRAM + // addr: SRAM start address 0x0000-0x7FFF + // length: Bytes to write + // data: address of the buffer with data + inline void WriteToSRAM(uint16_t addr, uint16_t length, uint8_t *data) { + DWIN_WriteToMem(0x5A, addr, length, data); + } + + // Write buffer data to the Flash + // addr: Flash start address 0x0000-0x3FFF + // length: Bytes to write + // data: address of the buffer with data + inline void WriteToFlash(uint16_t addr, uint16_t length, uint8_t *data) { + DWIN_WriteToMem(0xA5, addr, length, data); + } + + // Clear by filling the area with background color + // Area (0, TITLE_HEIGHT, DWIN_WIDTH, STATUS_Y - 1) + void ClearMainArea(); + +}; diff --git a/Marlin/src/lcd/e3v2/jyersui/endstop_diag.cpp b/Marlin/src/lcd/e3v2/jyersui/endstop_diag.cpp new file mode 100644 index 000000000000..5c4549619fb1 --- /dev/null +++ b/Marlin/src/lcd/e3v2/jyersui/endstop_diag.cpp @@ -0,0 +1,111 @@ +/** + * 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 . + * + */ + +/** + * DWIN End Stops diagnostic page + * Author: Miguel A. Risco-Castillo + * Version: 1.0 + * Date: 2021/11/06 + * + * Modded for JYERSUI by LCH-77 + */ + +#include "../../../inc/MarlinConfigPre.h" + +#if ENABLED(DWIN_CREALITY_LCD_JYERSUI) + +#include "dwin_defines.h" + +#if HAS_ESDIAG + +#include "endstop_diag.h" +#include "dwinui.h" +#include "dwin.h" + +#if HAS_FILAMENT_SENSOR + #include "../../../feature/runout.h" +#endif + +#if HAS_BED_PROBE + #include "../../../module/probe.h" +#endif + +ESDiagClass ESDiag; + +void draw_es_label(FSTR_P const flabel=nullptr) { + DWINUI::cursor.x = 40; + if (flabel) DWINUI::Draw_String(F(flabel)); + DWINUI::Draw_String(F(": ")); + DWINUI::MoveBy(0, 25); +} + +void draw_es_state(const bool is_hit) { + const uint8_t LM = 130; + DWINUI::cursor.x = LM; + DWIN_Draw_Rectangle(1, Color_Bg_Window, LM, DWINUI::cursor.y, LM + 100, DWINUI::cursor.y + 20); + is_hit ? DWINUI::Draw_String(RGB(31,31,16), F(STR_ENDSTOP_HIT)) : DWINUI::Draw_String(RGB(16,63,16), F(STR_ENDSTOP_OPEN)); + DWINUI::MoveBy(0, 25); +} + +void ESDiagClass::Draw() { + CrealityDWINClass::Clear_Screen(1); + CrealityDWINClass::Draw_Title(F("End-stops Diagnostic")); + DWINUI::ClearMainArea(); + DWIN_Draw_Rectangle(0, Color_White, 14, 60, 258, 330); + DWINUI::Draw_Button(BTN_Continue, 86, 250); + DWINUI::cursor.y = 80; + #define ES_LABEL(S) draw_es_label(F(STR_##S)) + #if HAS_X_MIN + ES_LABEL(X_MIN); + #endif + #if HAS_Y_MIN + ES_LABEL(Y_MIN); + #endif + #if HAS_Z_MIN + ES_LABEL(Z_MIN); + #endif + #if HAS_FILAMENT_SENSOR + draw_es_label(F(STR_FILAMENT)); + #endif + Update(); +} + +void ESDiagClass::Update() { + DWINUI::cursor.y = 80; + #define ES_REPORT(S) draw_es_state(READ(S##_PIN) != S##_ENDSTOP_INVERTING) + #if HAS_X_MIN + ES_REPORT(X_MIN); + #endif + #if HAS_Y_MIN + ES_REPORT(Y_MIN); + #endif + #if HAS_Z_MIN + ES_REPORT(Z_MIN); + #endif + #if HAS_FILAMENT_SENSOR + draw_es_state(READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE); + #endif + DWIN_UpdateLCD(); +} + +#endif // HAS_ES_DIAG +#endif // DWIN_CREALITY_LCD_JYERSUI diff --git a/Marlin/src/lcd/e3v2/jyersui/endstop_diag.h b/Marlin/src/lcd/e3v2/jyersui/endstop_diag.h new file mode 100644 index 000000000000..59509739d047 --- /dev/null +++ b/Marlin/src/lcd/e3v2/jyersui/endstop_diag.h @@ -0,0 +1,39 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * DWIN End Stops diagnostic page + * Author: Miguel A. Risco-Castillo + * Version: 1.0 + * Date: 2021/11/06 + * + * Modded for JYERSUI by LCH-77 + */ + +class ESDiagClass { +public: + void Draw(); + void Update(); +}; + +extern ESDiagClass ESDiag; diff --git a/Marlin/src/lcd/e3v2/jyersui/gcode_preview.cpp b/Marlin/src/lcd/e3v2/jyersui/gcode_preview.cpp new file mode 100644 index 000000000000..26037a9ce9ba --- /dev/null +++ b/Marlin/src/lcd/e3v2/jyersui/gcode_preview.cpp @@ -0,0 +1,244 @@ +/** + * 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 . + * + */ + +/** + * DWIN G-code thumbnail preview + * Author: Miguel A. Risco-Castillo + * version: 2.1 + * Date: 2021/06/19 + * + * Modded for JYERSUI by LCH-77 + */ + +#include "../../../inc/MarlinConfigPre.h" +#if ENABLED(DWIN_CREALITY_LCD_JYERSUI) + +#include "dwin_defines.h" + +#if HAS_GCODE_PREVIEW + +#include "../../../core/types.h" +#include "../../marlinui.h" +#include "../../../sd/cardreader.h" +#include "../../../MarlinCore.h" // for wait_for_user +#include "dwin_lcd.h" +#include "dwinui.h" +#include "dwin.h" +#include "base64.hpp" +#include "gcode_preview.h" + +typedef struct { + char name[13] = ""; //8.3 + null + uint32_t thumbstart = 0; + int thumbsize = 0; + int thumbheight = 0; + int thumbwidth = 0; + uint8_t *thumbdata = nullptr; + float time = 0; + float filament = 0; + float layer = 0; + float width = 0; + float height = 0; + float length = 0; + void setname(const char * const fn); + void clear(); +} fileprop_t; +fileprop_t fileprop; + +void fileprop_t::setname(const char * const fn) { + const uint8_t len = _MIN(sizeof(name) - 1, strlen(fn)); + memcpy(&name[0], fn, len); + name[len] = '\0'; +} + +void fileprop_t::clear() { + fileprop.name[0] = '\0'; + fileprop.thumbstart = 0; + fileprop.thumbsize = 0; + fileprop.thumbheight = 0; + fileprop.thumbwidth = 0; + fileprop.thumbdata = nullptr; + fileprop.time = 0; + fileprop.filament = 0; + fileprop.layer = 0; + fileprop.height = 0; + fileprop.width = 0; + fileprop.length = 0; +} + +void Get_Value(char *buf, const char * const key, float &value) { + char num[10] = ""; + char * posptr = 0; + uint8_t i = 0; + if (!!value) return; + posptr = strstr(buf, key); + if (posptr != nullptr) { + while (i < sizeof(num)) { + char c = posptr[0]; + if (!ISEOL(c) && (c != 0)) { + if ((c > 47 && c < 58) || (c == '.')) num[i++] = c; + posptr++; + } + else { + num[i] = '\0'; + value = atof(num); + return; + } + } + } +} + +bool Has_Preview() { + const char * tbstart = "; thumbnail begin 230x180"; + char * posptr = 0; + uint8_t nbyte = 1; + uint32_t indx = 0; + char buf[256]; + float tmp = 0; + + fileprop.clear(); + fileprop.setname(card.filename); + + card.openFileRead(fileprop.name); + + while ((nbyte > 0) && (indx < 4 * sizeof(buf)) && !fileprop.thumbstart) { + nbyte = card.read(buf, sizeof(buf) - 1); + if (nbyte > 0) { + buf[nbyte] = '\0'; + Get_Value(buf, ";TIME:", fileprop.time); + Get_Value(buf, ";Filament used:", fileprop.filament); + Get_Value(buf, ";Layer height:", fileprop.layer); + Get_Value(buf, ";MINX:", tmp); + Get_Value(buf, ";MAXX:", fileprop.width); + fileprop.width -= tmp; + tmp = 0; + Get_Value(buf, ";MINY:", tmp); + Get_Value(buf, ";MAXY:", fileprop.length); + fileprop.length -= tmp; + tmp = 0; + Get_Value(buf, ";MINZ:", tmp); + Get_Value(buf, ";MAXZ:", fileprop.height); + fileprop.height -= tmp; + posptr = strstr(buf, tbstart); + if (posptr != NULL) { + fileprop.thumbstart = indx + (posptr - &buf[0]); + } + else { + indx += _MAX(10, nbyte - (signed)strlen(tbstart)); + card.setIndex(indx); + } + } + } + + if (!fileprop.thumbstart) { + card.closefile(); + LCD_MESSAGE_F("Thumbnail not found"); + return 0; + } + + // Get the size of the thumbnail + card.setIndex(fileprop.thumbstart + strlen(tbstart)); + for (uint8_t i = 0; i < 16; i++) { + char c = card.get(); + if (!ISEOL(c)) { + buf[i] = c; + } + else { + buf[i] = '\0'; + break; + } + } + fileprop.thumbsize = atoi(buf); + + // Exit if there isn't a thumbnail + if (!fileprop.thumbsize) { + card.closefile(); + LCD_MESSAGE_F("Invalid Thumbnail Size"); + return 0; + } + + uint16_t readed = 0; + uint8_t buf64[fileprop.thumbsize]; + + fileprop.thumbdata = new uint8_t[3 + 3 * (fileprop.thumbsize / 4)]; // Reserve space for the JPEG thumbnail + + while (readed < fileprop.thumbsize) { + uint8_t c = card.get(); + if (!ISEOL(c) && (c != ';') && (c != ' ')) { + buf64[readed] = c; + readed++; + } + } + card.closefile(); + buf64[readed] = 0; + + fileprop.thumbsize = decode_base64(buf64, fileprop.thumbdata); card.closefile(); + DWINUI::WriteToSRAM(0x00, fileprop.thumbsize, fileprop.thumbdata); + delete[] fileprop.thumbdata; + return true; +} + +void Preview_DrawFromSD() { + bool _has_preview = Has_Preview(); + CrealityDWIN.Popup_Handler(PrintConfirm, _has_preview); + if (_has_preview) { + char buf[46]; + char str_1[6] = "", str_2[6] = "", str_3[6] = ""; + // DWIN_Draw_Rectangle(1, Def_Background_Color, 0, 0, DWIN_WIDTH, STATUS_Y - 1); + if (fileprop.time) { + sprintf_P(buf, PSTR("Estimated time: %i:%02i"), (uint16_t)fileprop.time / 3600, ((uint16_t)fileprop.time % 3600) / 60); + DWINUI::Draw_String(20, 10, buf); + } + if (fileprop.filament) { + sprintf_P(buf, PSTR("Filament used: %s m"), dtostrf(fileprop.filament, 1, 2, str_1)); + DWINUI::Draw_String(20, 30, buf); + } + if (fileprop.layer) { + sprintf_P(buf, PSTR("Layer height: %s mm"), dtostrf(fileprop.layer, 1, 2, str_1)); + DWINUI::Draw_String(20, 50, buf); + } + if (fileprop.width) { + sprintf_P(buf, PSTR("Volume: %sx%sx%s mm"), dtostrf(fileprop.width, 1, 1, str_1), dtostrf(fileprop.length, 1, 1, str_2), dtostrf(fileprop.height, 1, 1, str_3)); + DWINUI::Draw_String(20, 70, buf); + } + // DWINUI::Draw_Button(BTN_Print, 26, 290); + // DWINUI::Draw_Button(BTN_Cancel, 146, 290); + DWIN_ICON_Show(0, 0, 1, 21, 90, 0x00); + // Draw_Select_Highlight(true, 290); + DWIN_UpdateLCD(); + } + // else { + // HMI_flag.select_flag = 1; + // wait_for_user = false; + // } +} + +bool Preview_Valid() { + return !!fileprop.thumbstart; +} + +void Preview_Reset() { + fileprop.thumbsize = 0; +} + +#endif // HAS_GCODE_PREVIEW +#endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/jyersui/gcode_preview.h b/Marlin/src/lcd/e3v2/jyersui/gcode_preview.h new file mode 100644 index 000000000000..d10663e08bb0 --- /dev/null +++ b/Marlin/src/lcd/e3v2/jyersui/gcode_preview.h @@ -0,0 +1,34 @@ +/** + * 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 . + * + */ + +/** + * DWIN G-code thumbnail preview + * Author: Miguel A. Risco-Castillo + * version: 2.1 + * Date: 2021/06/19 + */ + +#pragma once + +void Preview_DrawFromSD(); +bool Preview_Valid(); +void Preview_Reset(); diff --git a/Marlin/src/lcd/e3v2/jyersui/lockscreen.cpp b/Marlin/src/lcd/e3v2/jyersui/lockscreen.cpp new file mode 100644 index 000000000000..5ed6dd3317b1 --- /dev/null +++ b/Marlin/src/lcd/e3v2/jyersui/lockscreen.cpp @@ -0,0 +1,83 @@ +/** + * 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 . + * + */ + +/** + * Lock screen implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 2.2.0 + * Date: 2022/04/11 + * + * Modded for JYERSUI by LCH-77 + */ + +#include "../../../inc/MarlinConfigPre.h" + +#if ENABLED(DWIN_CREALITY_LCD_JYERSUI) + +#include "dwin_defines.h" + +#if HAS_LOCKSCREEN + +#include "../common/dwin_color.h" +#include "dwinui.h" +#include "dwin.h" +#include "lockscreen.h" + +LockScreenClass lockScreen; + +uint8_t LockScreenClass::lock_pos = 0; +bool LockScreenClass::unlocked = false; +uint8_t LockScreenClass::rprocess = 0; + +void LockScreenClass::init() { + lock_pos = 0; + unlocked = false; + draw(); +} + +void LockScreenClass::draw() { + CrealityDWINClass::Clear_Screen(1); + CrealityDWINClass::Draw_Title(GET_TEXT_F(MSG_LOCKSCREEN)); + DWINUI::ClearMainArea(); + DWINUI::Draw_Icon(ICON_LOGO, 71, 120); // CREALITY logo + DWINUI::Draw_CenteredString(Color_White, 180, GET_TEXT_F(MSG_LOCKSCREEN_LOCKED)); + DWINUI::Draw_CenteredString(Color_White, 200, GET_TEXT_F(MSG_LOCKSCREEN_UNLOCK)); + DWINUI::Draw_CenteredString(Color_White, 240, F("-> | <-")); + DWIN_Draw_Box(1, BarFill_Color, 0, 260, DWIN_WIDTH, 20); + DWIN_Draw_VLine(Color_Yellow, lock_pos * DWIN_WIDTH / 255, 260, 20); + DWIN_UpdateLCD(); +} + +void LockScreenClass::onEncoder(EncoderState encoder_diffState) { + switch (encoder_diffState) { + case ENCODER_DIFF_CW: lock_pos += 8; break; + case ENCODER_DIFF_CCW: lock_pos -= 8; break; + case ENCODER_DIFF_ENTER: unlocked = (lock_pos == 128); break; + default: break; + } + DWIN_Draw_Box(1, BarFill_Color, 0, 260, DWIN_WIDTH, 20); + DWIN_Draw_VLine(Color_Yellow, lock_pos * DWIN_WIDTH / 255, 260, 20); + DWIN_UpdateLCD(); +} + +#endif // HAS_LOCKSCREEN +#endif // DWIN_CREALITY_LCD_JYERSUI diff --git a/Marlin/src/lcd/e3v2/jyersui/lockscreen.h b/Marlin/src/lcd/e3v2/jyersui/lockscreen.h new file mode 100644 index 000000000000..99c22a37da23 --- /dev/null +++ b/Marlin/src/lcd/e3v2/jyersui/lockscreen.h @@ -0,0 +1,49 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * Lock screen implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 2.2.0 + * Date: 2022/04/11 + * + * Modded for JYERSUI by LCH-77 + */ + +#include "../../../core/types.h" +#include "../common/encoder.h" +#include + +class LockScreenClass { +private: + static bool unlocked; + static uint8_t lock_pos; +public: + static uint8_t rprocess; + static void init(); + static void onEncoder(EncoderState encoder_diffState); + static void draw(); + static bool isUnlocked() { return unlocked; } +}; + +extern LockScreenClass lockScreen; diff --git a/Marlin/src/lcd/e3v2/jyersui/plot.cpp b/Marlin/src/lcd/e3v2/jyersui/plot.cpp new file mode 100644 index 000000000000..c0c283f5c0be --- /dev/null +++ b/Marlin/src/lcd/e3v2/jyersui/plot.cpp @@ -0,0 +1,86 @@ +/** + * 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 . + * + */ + +/** + * DWIN Single var plot + * Author: Miguel A. Risco-Castillo + * Version: 2.0 + * Date: 2022/01/31 + * + * Modded for JYERSUI by LCH-77 + */ + +#include "../../../inc/MarlinConfigPre.h" + +#ifdef DWIN_CREALITY_LCD_JYERSUI + +#include "dwin_defines.h" + +#ifdef HAS_PIDPLOT + +#include "plot.h" + +#include "../../../core/types.h" +#include "../../marlinui.h" +#include "dwin_lcd.h" +#include "dwinui.h" +#include "dwin.h" + +#define Plot_Bg_Color RGB( 1, 12, 8) + +PlotClass Plot; + +uint16_t grphpoints, r, x2, y2 = 0; +frame_rect_t grphframe = {0}; +float scale = 0; + +void PlotClass::Draw(const frame_rect_t frame, const float max, const float ref) { + grphframe = frame; + grphpoints = 0; + scale = frame.h / max; + x2 = frame.x + frame.w - 1; + y2 = frame.y + frame.h - 1; + r = round((y2) - ref * scale); + DWINUI::Draw_Box(1, Plot_Bg_Color, frame); + for (uint8_t i = 1; i < 4; i++) if (i*50 < frame.w) DWIN_Draw_VLine(Line_Color, i*50 + frame.x, frame.y, frame.h); + DWINUI::Draw_Box(0, Color_White, DWINUI::ExtendFrame(frame, 1)); + DWIN_Draw_HLine(Color_Red, frame.x, r, frame.w); +} + +void PlotClass::Update(const float value) { + if (!scale) return; + uint16_t y = round((y2) - value * scale); + if (grphpoints < grphframe.w) { + DWIN_Draw_Point(Color_Yellow, 1, 1, grphpoints + grphframe.x, y); + } + else { + DWIN_Frame_AreaMove(1, 0, 1, Plot_Bg_Color, grphframe.x, grphframe.y, x2, y2); + if ((grphpoints % 50) == 0) DWIN_Draw_VLine(Line_Color, x2 - 1, grphframe.y + 1, grphframe.h - 2); + DWIN_Draw_Point(Color_Red, 1, 1, x2 - 1, r); + DWIN_Draw_Point(Color_Yellow, 1, 1, x2 - 1, y); + } + grphpoints++; +} + +#endif // HAS_PIDPLOT + +#endif // DWIN_CREALITY_LCD_JYERSUI diff --git a/Marlin/src/lcd/e3v2/jyersui/plot.h b/Marlin/src/lcd/e3v2/jyersui/plot.h new file mode 100644 index 000000000000..1f97eafb71ba --- /dev/null +++ b/Marlin/src/lcd/e3v2/jyersui/plot.h @@ -0,0 +1,41 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * DWIN Single var plot + * Author: Miguel A. Risco-Castillo + * Version: 1.0 + * Date: 2022/01/30 + * + * Modded for JYERSUI by LCH-77 + */ + +#include "dwinui.h" + +class PlotClass { +public: + void Draw(frame_rect_t frame, float max, float ref = 0); + void Update(float value); +}; + +extern PlotClass Plot; diff --git a/Marlin/src/lcd/e3v2/proui/base64.hpp b/Marlin/src/lcd/e3v2/proui/base64.hpp index d82d0b27e8ac..7a933df321b8 100644 --- a/Marlin/src/lcd/e3v2/proui/base64.hpp +++ b/Marlin/src/lcd/e3v2/proui/base64.hpp @@ -152,7 +152,7 @@ uint16_t encode_base64(unsigned char input[], uint16_t input_length, unsigned ch output += 4; } - switch(input_length % 3) { + switch (input_length % 3) { case 0: output[0] = '\0'; break; @@ -192,7 +192,7 @@ uint16_t decode_base64(unsigned char input[], uint16_t input_length, unsigned ch output += 3; } - switch(output_length % 3) { + switch (output_length % 3) { case 1: output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4; break; @@ -205,4 +205,4 @@ uint16_t decode_base64(unsigned char input[], uint16_t input_length, unsigned ch return output_length; } -#endif // ifndef +#endif // BASE64_H_INCLUDED diff --git a/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp b/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp index adb23a96646b..4257728f73e3 100644 --- a/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp +++ b/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp @@ -21,7 +21,7 @@ */ /** - * DWIN g-code thumbnail preview + * DWIN G-code thumbnail preview * Author: Miguel A. Risco-Castillo * version: 2.1 * Date: 2021/06/19 @@ -214,9 +214,7 @@ bool Has_Preview() { void Preview_DrawFromSD() { if (Has_Preview()) { char buf[46]; - char str_1[6] = ""; - char str_2[6] = ""; - char str_3[6] = ""; + char str_1[6] = "", str_2[6] = "", str_3[6] = ""; DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, 0, DWIN_WIDTH, STATUS_Y - 1); if (fileprop.time) { sprintf_P(buf, PSTR("Estimated time: %i:%02i"), (uint16_t)fileprop.time / 3600, ((uint16_t)fileprop.time % 3600) / 60); diff --git a/Marlin/src/lcd/e3v2/proui/gcode_preview.h b/Marlin/src/lcd/e3v2/proui/gcode_preview.h index 4417084a242d..97cf7fe5ac9d 100644 --- a/Marlin/src/lcd/e3v2/proui/gcode_preview.h +++ b/Marlin/src/lcd/e3v2/proui/gcode_preview.h @@ -1,5 +1,5 @@ /** - * DWIN g-code thumbnail preview + * DWIN G-code thumbnail preview * Author: Miguel A. Risco-Castillo * version: 2.1 * Date: 2021/06/19 diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 7ee3a87fce39..3d6e14b5f7f1 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -503,7 +503,7 @@ typedef struct SettingsDataStruct { #if ENABLED(DWIN_LCD_PROUI) uint8_t dwin_data[eeprom_data_size]; #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) - uint8_t dwin_settings[CrealityDWIN.eeprom_data_size]; + uint8_t dwin_settings[eeprom_data_size]; #endif // @@ -1525,7 +1525,7 @@ void MarlinSettings::postprocess() { #if ENABLED(DWIN_CREALITY_LCD_JYERSUI) { _FIELD_TEST(dwin_settings); - char dwin_settings[CrealityDWIN.eeprom_data_size] = { 0 }; + char dwin_settings[eeprom_data_size] = { 0 }; CrealityDWIN.Save_Settings(dwin_settings); EEPROM_WRITE(dwin_settings); } @@ -2497,7 +2497,7 @@ void MarlinSettings::postprocess() { } #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) { - const char dwin_settings[CrealityDWIN.eeprom_data_size] = { 0 }; + const char dwin_settings[eeprom_data_size] = { 0 }; _FIELD_TEST(dwin_settings); EEPROM_READ(dwin_settings); if (!validating) CrealityDWIN.Load_Settings(dwin_settings); diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 65b79d8bc464..f03213be1fb2 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -53,6 +53,8 @@ #include "../lcd/e3v2/creality/dwin.h" #elif ENABLED(DWIN_LCD_PROUI) #include "../lcd/e3v2/proui/dwin.h" +#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) + #include "../lcd/e3v2/jyersui/dwin.h" #endif #if ENABLED(EXTENSIBLE_UI) @@ -644,12 +646,14 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_STARTED)); TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(isbed ? PID_BED_START : PID_EXTR_START)); + TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(isbed ? PID_BED_START : PID_EXTR_START)); if (target > GHV(CHAMBER_MAX_TARGET, BED_MAX_TARGET, temp_range[heater_id].maxtemp - (HOTEND_OVERSHOOT))) { SERIAL_ECHOPGM(STR_PID_AUTOTUNE); SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH)); TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TEMP_TOO_HIGH)); + TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_TEMP_TOO_HIGH)); TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH))); return; } @@ -744,6 +748,7 @@ volatile bool Temperature::raw_temps_ready = false; SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH)); TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TEMP_TOO_HIGH)); + TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_TEMP_TOO_HIGH)); TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH))); break; } @@ -782,6 +787,7 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0)); TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TUNING_TIMEOUT)); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TUNING_TIMEOUT)); + TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_TUNING_TIMEOUT)); TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TIMEOUT))); SERIAL_ECHOPGM(STR_PID_AUTOTUNE); SERIAL_ECHOLNPGM(STR_PID_TIMEOUT); @@ -839,6 +845,7 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_DONE)); TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_DONE)); + TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_DONE)); goto EXIT_M303; } @@ -857,6 +864,7 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_DONE)); TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_DONE)); + TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_DONE)); EXIT_M303: TERN_(NO_FAN_SLOWING_IN_PID_TUNING, adaptive_fan_slowing = true);