From f71123792a91555a43aa0f0d1a6feed9a6e8f0ab Mon Sep 17 00:00:00 2001 From: Jyers Date: Wed, 3 Feb 2021 00:57:17 -0500 Subject: [PATCH 1/8] Improved Status Area --- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 163 +++++++++++++++++++----------- 1 file changed, 105 insertions(+), 58 deletions(-) diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index 39f161f5adfc..569521c20a09 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -207,6 +207,9 @@ uint16_t remain_time = 0; float dwin_zoffset = 0, last_zoffset = 0; #endif +float zoffsetvalue; +uint16_t flowrate = 100; + #define DWIN_LANGUAGE_EEPROM_ADDRESS 0x01 // Between 0x01 and 0x63 (EEPROM_OFFSET-1) // BL24CXX::check() uses 0x00 @@ -1532,10 +1535,10 @@ void HMI_StepXYZE() { void update_variable() { #if HAS_HOTEND - static float last_temp_hotend_target = 0, last_temp_hotend_current = 0; + static float last_temp_hotend_target = 0; #endif #if HAS_HEATED_BED - static float last_temp_bed_target = 0, last_temp_bed_current = 0; + static float last_temp_bed_target = 0; #endif #if HAS_FAN static uint8_t last_fan_speed = 0; @@ -1577,38 +1580,70 @@ void update_variable() { #endif } - /* Bottom temperature update */ - #if HAS_HOTEND - if (last_temp_hotend_current != thermalManager.temp_hotend[0].celsius) { - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 33, 382, thermalManager.temp_hotend[0].celsius); - last_temp_hotend_current = thermalManager.temp_hotend[0].celsius; - } - if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) { - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 33 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_hotend[0].target); - last_temp_hotend_target = thermalManager.temp_hotend[0].target; - } - #endif - #if HAS_HEATED_BED - if (last_temp_bed_current != thermalManager.temp_bed.celsius) { - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 178, 382, thermalManager.temp_bed.celsius); - last_temp_bed_current = thermalManager.temp_bed.celsius; + zoffsetvalue = BABY_Z_VAR; // Temporary Statement for Compatability + + static float hotend = 0; + static float bed = 0; + static int16_t hotendtarget = 0; + static int16_t bedtarget = 0; + static int16_t feedrate = 100; + static int16_t flow = flowrate; + static uint8_t fan = 0; + static float offset = zoffsetvalue; + static float x = current_position.x; + static float y = current_position.y; + static float z = current_position.z; + if (thermalManager.temp_hotend[0].celsius != hotend) { + hotend = thermalManager.temp_hotend[0].celsius; + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 384, thermalManager.temp_hotend[0].celsius); + } + if (thermalManager.temp_bed.celsius != bed) { + bed = thermalManager.temp_bed.celsius; + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 417, thermalManager.temp_bed.celsius); + } + if (thermalManager.temp_hotend[0].target != hotendtarget) { + hotendtarget = thermalManager.temp_hotend[0].target; + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 384, thermalManager.temp_hotend[0].target); + } + if (thermalManager.temp_bed.target != bedtarget) { + bedtarget = thermalManager.temp_bed.target; + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 417, thermalManager.temp_bed.target); + } + if (feedrate_percentage != feedrate) { + feedrate = feedrate_percentage; + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 116 + 2 * STAT_CHR_W, 384, feedrate_percentage); + } + if (flowrate != flow) { + flow = flowrate; + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 116 + 2 * STAT_CHR_W, 417, flowrate); + } + if (thermalManager.fan_speed[0] != fan) { + fan = thermalManager.fan_speed[0]; + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 195 + 2 * STAT_CHR_W, 384, thermalManager.fan_speed[0]); + } + if (zoffsetvalue != offset) { + offset = zoffsetvalue; + if (zoffsetvalue < 0) { + DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 2, 2, 207, 417, -zoffsetvalue * 100); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 205, 419, (char*)"-"); } - if (last_temp_bed_target != thermalManager.temp_bed.target) { - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 178 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_bed.target); - last_temp_bed_target = thermalManager.temp_bed.target; + else { + DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 2, 2, 207, 417, zoffsetvalue* 100); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 205, 419, (char*)" "); } - #endif - static uint16_t last_speed = 0; - if (last_speed != feedrate_percentage) { - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 33 + 2 * STAT_CHR_W, 429, feedrate_percentage); - last_speed = feedrate_percentage; } - #if HAS_ZOFFSET_ITEM - if (last_zoffset != BABY_Z_VAR) { - DWIN_Draw_Signed_Float(DWIN_FONT_STAT, Color_Bg_Black, 2, 2, 178 + STAT_CHR_W, 429, BABY_Z_VAR * 100); - last_zoffset = BABY_Z_VAR; - } - #endif + if (current_position.x != x) { + x = current_position.x; + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 35, 459, current_position.x * 10); + } + if (current_position.y != y) { + y = current_position.y; + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 120, 459, current_position.y * 10); + } + if (current_position.z != z) { + z = current_position.z; + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 205, 459, current_position.z * 10); + } } /** @@ -1800,38 +1835,50 @@ void HMI_SDCardUpdate() { // void Draw_Status_Area(const bool with_update) { - // Clear the bottom area of the screen DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, STATUS_Y, DWIN_WIDTH, DWIN_HEIGHT - 1); - // - // Status Area - // - #if HAS_HOTEND - DWIN_ICON_Show(ICON, ICON_HotendTemp, 13, 381); - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 33, 382, thermalManager.temp_hotend[0].celsius); - DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 33 + 3 * STAT_CHR_W + 5, 383, F("/")); - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 33 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_hotend[0].target); - #endif - #if HOTENDS > 1 - // DWIN_ICON_Show(ICON,ICON_HotendTemp, 13, 381); - #endif + DWIN_ICON_Show(ICON, ICON_HotendTemp, 10, 383); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 384, thermalManager.temp_hotend[0].celsius); + DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 384, (char*)"/"); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 384, thermalManager.temp_hotend[0].target); - #if HAS_HEATED_BED - DWIN_ICON_Show(ICON, ICON_BedTemp, 158, 381); - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 178, 382, thermalManager.temp_bed.celsius); - DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 178 + 3 * STAT_CHR_W + 5, 383, F("/")); - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 178 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_bed.target); - #endif + DWIN_ICON_Show(ICON, ICON_BedTemp, 10, 416); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 417, thermalManager.temp_bed.celsius); + DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 417, (char*)"/"); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 417, thermalManager.temp_bed.target); - DWIN_ICON_Show(ICON, ICON_Speed, 13, 429); - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 33 + 2 * STAT_CHR_W, 429, feedrate_percentage); - DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 33 + 5 * STAT_CHR_W + 2, 429, F("%")); + DWIN_ICON_Show(ICON, ICON_Speed, 113, 383); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 116 + 2 * STAT_CHR_W, 384, feedrate_percentage); + DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 116 + 5 * STAT_CHR_W + 2, 384, (char*)"%"); - #if HAS_ZOFFSET_ITEM - DWIN_ICON_Show(ICON, ICON_Zoffset, 158, 428); - dwin_zoffset = BABY_Z_VAR; - DWIN_Draw_Signed_Float(DWIN_FONT_STAT, Color_Bg_Black, 2, 2, 178, 429, dwin_zoffset * 100); - #endif + DWIN_ICON_Show(ICON, ICON_StepE, 112, 417); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 116 + 2 * STAT_CHR_W, 417, flowrate); + DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 116 + 5 * STAT_CHR_W + 2, 417, (char*)"%"); + + DWIN_ICON_Show(ICON, ICON_FanSpeed, 187, 383); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 195 + 2 * STAT_CHR_W, 384, thermalManager.fan_speed[0]); + + DWIN_ICON_Show(ICON, ICON_Zoffset, 187, 416); + + zoffsetvalue = BABY_Z_VAR; // Temporary Statement for Compatability + + if (zoffsetvalue < 0) { + DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 2, 2, 207, 417, -zoffsetvalue * 100); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 205, 419, (char*)"-"); + } + else { + DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 2, 2, 207, 417, zoffsetvalue * 100); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 205, 419, (char*)" "); + } + + DWIN_Draw_Rectangle(1, Line_Color, 0, 449, DWIN_WIDTH, 451); + + DWIN_ICON_Show(ICON, ICON_MaxSpeedX, 10, 456); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 35, 459, current_position.x * 10); + DWIN_ICON_Show(ICON, ICON_MaxSpeedY, 95, 456); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 120, 459, current_position.y * 10); + DWIN_ICON_Show(ICON, ICON_MaxSpeedZ, 180, 456); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 205, 459, current_position.z * 10); if (with_update) { DWIN_UpdateLCD(); From 1f49ffe900a2d954f4e6e1e5465dc6d188ee685b Mon Sep 17 00:00:00 2001 From: Jyers Date: Thu, 4 Feb 2021 14:51:57 -0500 Subject: [PATCH 2/8] Fixed Position Display for Non-Homed Axis --- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 39 ++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index 569521c20a09..2f6827c7a2a8 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -1593,6 +1593,9 @@ void update_variable() { static float x = current_position.x; static float y = current_position.y; static float z = current_position.z; + static float xhome = axis_was_homed(X_AXIS); + static float yhome = axis_was_homed(Y_AXIS); + static float zhome = axis_was_homed(Z_AXIS); if (thermalManager.temp_hotend[0].celsius != hotend) { hotend = thermalManager.temp_hotend[0].celsius; DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 384, thermalManager.temp_hotend[0].celsius); @@ -1632,17 +1635,26 @@ void update_variable() { DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 205, 419, (char*)" "); } } - if (current_position.x != x) { + if (current_position.x != x || xhome != axis_was_homed(X_AXIS)) { x = current_position.x; - DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 35, 459, current_position.x * 10); + if (axis_was_homed(X_AXIS)) + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 35, 459, current_position.x * 10); + else + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 35, 459, (char*)"?"); } - if (current_position.y != y) { + if (current_position.y != y || yhome != axis_was_homed(Y_AXIS)) { y = current_position.y; - DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 120, 459, current_position.y * 10); + if (axis_was_homed(Y_AXIS)) + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 120, 459, current_position.y * 10); + else + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 120, 459, (char*)"?"); } - if (current_position.z != z) { + if (current_position.z != z || zhome != axis_was_homed(Z_AXIS)) { z = current_position.z; - DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 205, 459, current_position.z * 10); + if (axis_was_homed(Z_AXIS)) + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 205, 459, current_position.z * 10); + else + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 205, 459, (char*)"?"); } } @@ -1874,11 +1886,20 @@ void Draw_Status_Area(const bool with_update) { DWIN_Draw_Rectangle(1, Line_Color, 0, 449, DWIN_WIDTH, 451); DWIN_ICON_Show(ICON, ICON_MaxSpeedX, 10, 456); - DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 35, 459, current_position.x * 10); + if (axis_was_homed(X_AXIS)) + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 35, 459, current_position.x * 10); + else + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 35, 459, (char*)"?"); DWIN_ICON_Show(ICON, ICON_MaxSpeedY, 95, 456); - DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 120, 459, current_position.y * 10); + if (axis_was_homed(Y_AXIS)) + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 120, 459, current_position.y * 10); + else + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 120, 459, (char*)"?"); DWIN_ICON_Show(ICON, ICON_MaxSpeedZ, 180, 456); - DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 205, 459, current_position.z * 10); + if (axis_was_homed(Z_AXIS)) + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 205, 459, current_position.z * 10); + else + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 205, 459, (char*)"?"); if (with_update) { DWIN_UpdateLCD(); From e193883291ba65f8744a8ead8b2900e64311ad14 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 8 Feb 2021 22:31:21 -0600 Subject: [PATCH 3/8] Thinkify --- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 225 +++++++++++++++--------------- 1 file changed, 113 insertions(+), 112 deletions(-) diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index 2f035b265597..69520fa0a76b 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -203,9 +203,6 @@ static uint16_t _remain_time = 0; float dwin_zoffset = 0, last_zoffset = 0; #endif -float zoffsetvalue; -uint16_t flowrate = 100; - #define DWIN_LANGUAGE_EEPROM_ADDRESS 0x01 // Between 0x01 and 0x63 (EEPROM_OFFSET-1) // BL24CXX::check() uses 0x00 @@ -1521,6 +1518,29 @@ void HMI_StepXYZE() { } } +// Draw X, Y, Z and blink if in an un-homed or un-trusted state +void _draw_axis_value(const AxisEnum axis, const uint16_t x, const uint16_t y, const bool blink) { + static bool _blink = false; + const bool draw_qmark = axis_should_home(axis), + draw_empty = NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !draw_qmark && !axis_is_trusted(axis); + + // Check for a position change + static xyz_pos_t oldpos = { -1, -1, -1 }; + const float p = current_position[axis]; + bool changed = oldpos[axis] != p; + if (changed) oldpos[axis] = p; + + if (changed || (blink != _blink && (draw_qmark || draw_empty))) { + _blink = blink; + if (blink && draw_qmark) + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, x, y, F("???.?")); + else if (blink && draw_empty) + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, x, y, F(" ")); + else + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, x, y, p * 10); + } +} + void update_variable() { TERN_(HAS_HOTEND, static float last_temp_hotend_target = 0); TERN_(HAS_HEATED_BED, static float last_temp_bed_target = 0); @@ -1570,82 +1590,68 @@ void update_variable() { #endif } - zoffsetvalue = BABY_Z_VAR; // Temporary Statement for Compatability - - static float hotend = 0; - static float bed = 0; - static int16_t hotendtarget = 0; - static int16_t bedtarget = 0; - static int16_t feedrate = 100; - static int16_t flow = flowrate; - static uint8_t fan = 0; - static float offset = zoffsetvalue; - static float x = current_position.x; - static float y = current_position.y; - static float z = current_position.z; - static float xhome = axis_was_homed(X_AXIS); - static float yhome = axis_was_homed(Y_AXIS); - static float zhome = axis_was_homed(Z_AXIS); - if (thermalManager.temp_hotend[0].celsius != hotend) { - hotend = thermalManager.temp_hotend[0].celsius; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 384, thermalManager.temp_hotend[0].celsius); - } - if (thermalManager.temp_bed.celsius != bed) { - bed = thermalManager.temp_bed.celsius; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 417, thermalManager.temp_bed.celsius); - } - if (thermalManager.temp_hotend[0].target != hotendtarget) { - hotendtarget = thermalManager.temp_hotend[0].target; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 384, thermalManager.temp_hotend[0].target); - } - if (thermalManager.temp_bed.target != bedtarget) { - bedtarget = thermalManager.temp_bed.target; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 417, thermalManager.temp_bed.target); - } - if (feedrate_percentage != feedrate) { - feedrate = feedrate_percentage; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 116 + 2 * STAT_CHR_W, 384, feedrate_percentage); - } - if (flowrate != flow) { - flow = flowrate; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 116 + 2 * STAT_CHR_W, 417, flowrate); - } - if (thermalManager.fan_speed[0] != fan) { - fan = thermalManager.fan_speed[0]; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 195 + 2 * STAT_CHR_W, 384, thermalManager.fan_speed[0]); + #if HAS_HOTEND + static float _hotendtemp = 0; + if (_hotendtemp != thermalManager.temp_hotend[0].celsius) { + _hotendtemp = thermalManager.temp_hotend[0].celsius; + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 384, _hotendtemp); + } + static int16_t _hotendtarget = 0; + if (_hotendtarget != thermalManager.temp_hotend[0].target) { + _hotendtarget = thermalManager.temp_hotend[0].target; + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 384, _hotendtarget); + } + static int16_t _flow = planner.flow_percentage[0]; + if (_flow != planner.flow_percentage[0]) { + _flow = planner.flow_percentage[0]; + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 116 + 2 * STAT_CHR_W, 417, _flow); + } + #endif + + #if HAS_HEATED_BED + static float _bedtemp = 0; + if (_bedtemp != thermalManager.temp_bed.celsius) { + _bedtemp = thermalManager.temp_bed.celsius; + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 417, _bedtemp); + } + static int16_t _bedtarget = 0; + if (_bedtarget != thermalManager.temp_bed.target) { + _bedtarget = thermalManager.temp_bed.target; + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 417, _bedtarget); + } + #endif + + static int16_t _feedrate = 100; + if (_feedrate != feedrate_percentage) { + _feedrate = feedrate_percentage; + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 116 + 2 * STAT_CHR_W, 384, _feedrate); } - if (zoffsetvalue != offset) { - offset = zoffsetvalue; - if (zoffsetvalue < 0) { - DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 2, 2, 207, 417, -zoffsetvalue * 100); - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 205, 419, (char*)"-"); + + #if HAS_FAN + static uint8_t _fanspeed = 0; + if (_fanspeed != thermalManager.fan_speed[0]) { + _fanspeed = thermalManager.fan_speed[0]; + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 195 + 2 * STAT_CHR_W, 384, _fanspeed); + } + #endif + + static float _offset = 0; + if (BABY_Z_VAR != _offset) { + _offset = BABY_Z_VAR; + if (BABY_Z_VAR < 0) { + DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 2, 2, 207, 417, -_offset * 100); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 205, 419, F("-")); } else { - DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 2, 2, 207, 417, zoffsetvalue* 100); - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 205, 419, (char*)" "); + DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 2, 2, 207, 417, _offset * 100); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 205, 419, F(" ")); } } - if (current_position.x != x || xhome != axis_was_homed(X_AXIS)) { - x = current_position.x; - if (axis_was_homed(X_AXIS)) - DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 35, 459, current_position.x * 10); - else - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 35, 459, (char*)"?"); - } - if (current_position.y != y || yhome != axis_was_homed(Y_AXIS)) { - y = current_position.y; - if (axis_was_homed(Y_AXIS)) - DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 120, 459, current_position.y * 10); - else - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 120, 459, (char*)"?"); - } - if (current_position.z != z || zhome != axis_was_homed(Z_AXIS)) { - z = current_position.z; - if (axis_was_homed(Z_AXIS)) - DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 205, 459, current_position.z * 10); - else - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 205, 459, (char*)"?"); - } + + const bool blink = (millis() / 1000) & 1; // Is this an odd second? + _draw_axis_value(X_AXIS, 35, 459, blink); + _draw_axis_value(Y_AXIS, 120, 459, blink); + _draw_axis_value(Z_AXIS, 205, 459, blink); } /** @@ -1839,57 +1845,52 @@ void Draw_Status_Area(const bool with_update) { DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, STATUS_Y, DWIN_WIDTH, DWIN_HEIGHT - 1); - DWIN_ICON_Show(ICON, ICON_HotendTemp, 10, 383); - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 384, thermalManager.temp_hotend[0].celsius); - DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 384, (char*)"/"); - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 384, thermalManager.temp_hotend[0].target); + #if HAS_HOTEND + DWIN_ICON_Show(ICON, ICON_HotendTemp, 10, 383); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 384, thermalManager.temp_hotend[0].celsius); + DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 384, F("/")); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 384, thermalManager.temp_hotend[0].target); + + DWIN_ICON_Show(ICON, ICON_StepE, 112, 417); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 116 + 2 * STAT_CHR_W, 417, planner.flow_percentage[0]); + DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 116 + 5 * STAT_CHR_W + 2, 417, F("%")); + #endif - DWIN_ICON_Show(ICON, ICON_BedTemp, 10, 416); - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 417, thermalManager.temp_bed.celsius); - DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 417, (char*)"/"); - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 417, thermalManager.temp_bed.target); + #if HAS_HEATED_BED + DWIN_ICON_Show(ICON, ICON_BedTemp, 10, 416); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 417, thermalManager.temp_bed.celsius); + DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 417, F("/")); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 417, thermalManager.temp_bed.target); + #endif DWIN_ICON_Show(ICON, ICON_Speed, 113, 383); DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 116 + 2 * STAT_CHR_W, 384, feedrate_percentage); - DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 116 + 5 * STAT_CHR_W + 2, 384, (char*)"%"); - - DWIN_ICON_Show(ICON, ICON_StepE, 112, 417); - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 116 + 2 * STAT_CHR_W, 417, flowrate); - DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 116 + 5 * STAT_CHR_W + 2, 417, (char*)"%"); + DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 116 + 5 * STAT_CHR_W + 2, 384, F("%")); - DWIN_ICON_Show(ICON, ICON_FanSpeed, 187, 383); - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 195 + 2 * STAT_CHR_W, 384, thermalManager.fan_speed[0]); - - DWIN_ICON_Show(ICON, ICON_Zoffset, 187, 416); + #if HAS_FAN + DWIN_ICON_Show(ICON, ICON_FanSpeed, 187, 383); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 195 + 2 * STAT_CHR_W, 384, thermalManager.fan_speed[0]); + #endif - zoffsetvalue = BABY_Z_VAR; // Temporary Statement for Compatability + #if HAS_ZOFFSET_ITEM + DWIN_ICON_Show(ICON, ICON_Zoffset, 187, 416); + #endif - if (zoffsetvalue < 0) { - DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 2, 2, 207, 417, -zoffsetvalue * 100); - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 205, 419, (char*)"-"); + if (BABY_Z_VAR < 0) { + DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 2, 2, 207, 417, -BABY_Z_VAR * 100); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 205, 419, F("-")); } else { - DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 2, 2, 207, 417, zoffsetvalue * 100); - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 205, 419, (char*)" "); + DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 2, 2, 207, 417, BABY_Z_VAR * 100); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 205, 419, F(" ")); } DWIN_Draw_Rectangle(1, Line_Color, 0, 449, DWIN_WIDTH, 451); - DWIN_ICON_Show(ICON, ICON_MaxSpeedX, 10, 456); - if (axis_was_homed(X_AXIS)) - DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 35, 459, current_position.x * 10); - else - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 35, 459, (char*)"?"); - DWIN_ICON_Show(ICON, ICON_MaxSpeedY, 95, 456); - if (axis_was_homed(Y_AXIS)) - DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 120, 459, current_position.y * 10); - else - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 120, 459, (char*)"?"); - DWIN_ICON_Show(ICON, ICON_MaxSpeedZ, 180, 456); - if (axis_was_homed(Z_AXIS)) - DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 205, 459, current_position.z * 10); - else - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 205, 459, (char*)"?"); + const bool blink = (millis() / 1000) & 1; // Is this an odd second? + DWIN_ICON_Show(ICON, ICON_MaxSpeedX, 10, 456); _draw_axis_value(X_AXIS, 35, 459, blink); + DWIN_ICON_Show(ICON, ICON_MaxSpeedY, 95, 456); _draw_axis_value(Y_AXIS, 120, 459, blink); + DWIN_ICON_Show(ICON, ICON_MaxSpeedZ, 180, 456); _draw_axis_value(Z_AXIS, 205, 459, blink); if (with_update) { DWIN_UpdateLCD(); From 96a932910453350c7b30ec583fccec11d379250d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 9 Feb 2021 17:44:02 -0600 Subject: [PATCH 4/8] Fix fan speed, etc. --- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 26 ++++++++++------------ Marlin/src/lcd/dwin/e3v2/dwin.h | 7 ++---- Marlin/src/pins/stm32f1/pins_CREALITY_V4.h | 8 +++++-- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index 69520fa0a76b..272cb08eb870 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -1369,7 +1369,7 @@ void HMI_Move_Z() { #endif // HAS_HEATED_BED -#if HAS_PREHEAT +#if HAS_PREHEAT && HAS_FAN void HMI_FanSpeed() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); @@ -1401,7 +1401,7 @@ void HMI_Move_Z() { else checkkey = Tune; DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(fan_line), HMI_ValueStruct.Fan_speed); - thermalManager.set_fan_speed(0, HMI_ValueStruct.Fan_speed); + TERN_(HAS_FAN, thermalManager.set_fan_speed(0, HMI_ValueStruct.Fan_speed)); return; } // Fan_speed limit @@ -1411,7 +1411,7 @@ void HMI_Move_Z() { } } -#endif // HAS_PREHEAT +#endif // HAS_PREHEAT && HAS_FAN void HMI_PrintSpeed() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); @@ -1533,7 +1533,7 @@ void _draw_axis_value(const AxisEnum axis, const uint16_t x, const uint16_t y, c if (changed || (blink != _blink && (draw_qmark || draw_empty))) { _blink = blink; if (blink && draw_qmark) - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, x, y, F("???.?")); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, x, y, F(" ??? ")); else if (blink && draw_empty) DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, x, y, F(" ")); else @@ -2407,19 +2407,17 @@ void HMI_Prepare() { #endif break; #endif - #if HAS_HOTEND + #if HAS_PREHEAT case PREPARE_CASE_PLA: // PLA preheat - thermalManager.setTargetHotend(ui.material_preset[0].hotend_temp, 0); - thermalManager.setTargetBed(ui.material_preset[0].bed_temp); - thermalManager.set_fan_speed(0, ui.material_preset[0].fan_speed); + TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[0].hotend_temp, 0)); + TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(ui.material_preset[0].bed_temp)); + TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[0].fan_speed)); break; case PREPARE_CASE_ABS: // ABS preheat - thermalManager.setTargetHotend(ui.material_preset[1].hotend_temp, 0); - thermalManager.setTargetBed(ui.material_preset[1].bed_temp); - thermalManager.set_fan_speed(0, ui.material_preset[1].fan_speed); + TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[1].hotend_temp, 0)); + TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(ui.material_preset[1].bed_temp)); + TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[1].fan_speed)); break; - #endif - #if HAS_PREHEAT case PREPARE_CASE_COOL: // Cool TERN_(HAS_FAN, thermalManager.zero_fan_speeds()); #if HAS_HOTEND || HAS_HEATED_BED @@ -3709,7 +3707,7 @@ void DWIN_HandleScreen() { #if HAS_HEATED_BED case BedTemp: HMI_BedTemp(); break; #endif - #if HAS_PREHEAT + #if HAS_PREHEAT && HAS_FAN case FanSpeed: HMI_FanSpeed(); break; #endif case PrintSpeed: HMI_PrintSpeed(); break; diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.h b/Marlin/src/lcd/dwin/e3v2/dwin.h index 57f987314586..217127ed11b1 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.h +++ b/Marlin/src/lcd/dwin/e3v2/dwin.h @@ -236,7 +236,7 @@ extern millis_t dwin_heat_time; typedef struct { TERN_(HAS_HOTEND, int16_t E_Temp = 0); TERN_(HAS_HEATED_BED, int16_t Bed_Temp = 0); - TERN_(HAS_PREHEAT, int16_t Fan_speed = 0); + TERN_(HAS_FAN, int16_t Fan_speed = 0); int16_t print_speed = 100; float Max_Feedspeed = 0; float Max_Acceleration = 0; @@ -270,10 +270,7 @@ typedef struct { #if HAS_LEVELING bool leveling_offset_flag:1; #endif - #if HAS_FAN - AxisEnum feedspeed_axis; - #endif - AxisEnum acc_axis, jerk_axis, step_axis; + AxisEnum feedspeed_axis, acc_axis, jerk_axis, step_axis; } HMI_Flag_t; extern HMI_value_t HMI_ValueStruct; diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h index 8b5b8562a2bb..88806bdb18f4 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h @@ -132,8 +132,12 @@ #define HEATER_0_PIN PA1 // HEATER1 #define HEATER_BED_PIN PA2 // HOT BED -#define FAN_PIN PA0 // FAN -#define FAN_SOFT_PWM +#ifndef FAN_PIN + #define FAN_PIN PA0 // FAN +#endif +#if PIN_EXISTS(FAN) + #define FAN_SOFT_PWM +#endif // // SD Card From 2459d3234e9896bba66ddcb2835e1b76f84378ec Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 12 Feb 2021 02:26:24 -0600 Subject: [PATCH 5/8] clean up, fix blink --- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 430 ++++++++++++++++++------------ 1 file changed, 262 insertions(+), 168 deletions(-) diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index 272cb08eb870..a6840ded0740 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -98,6 +98,7 @@ #define PAUSE_HEAT #define USE_STRING_HEADINGS +#define USE_STRING_TITLES #define DWIN_FONT_MENU font8x16 #define DWIN_FONT_STAT font10x20 @@ -136,9 +137,10 @@ #define UNITFDIGITS 1 #define MINUNITMULT pow(10, UNITFDIGITS) -#define ENCODER_WAIT 20 -#define DWIN_SCROLL_UPDATE_INTERVAL 2000 -#define DWIN_REMAIN_TIME_UPDATE_INTERVAL 20000 +#define ENCODER_WAIT_MS 20 +#define DWIN_VAR_UPDATE_INTERVAL 1024 +#define DWIN_SCROLL_UPDATE_INTERVAL SEC_TO_MS(2) +#define DWIN_REMAIN_TIME_UPDATE_INTERVAL SEC_TO_MS(20) constexpr uint16_t TROWS = 6, MROWS = TROWS - 1, // Total rows, and other-than-Back TITLE_HEIGHT = 30, // Title bar height @@ -400,28 +402,28 @@ void ICON_Stop() { } } -inline void Clear_Title_Bar() { +void Clear_Title_Bar() { DWIN_Draw_Rectangle(1, Color_Bg_Blue, 0, 0, DWIN_WIDTH, 30); } -inline void Draw_Title(const char * const title) { +void Draw_Title(const char * const title) { DWIN_Draw_String(false, false, DWIN_FONT_HEAD, Color_White, Color_Bg_Blue, 14, 4, (char*)title); } -inline void Draw_Title(const __FlashStringHelper * title) { +void Draw_Title(const __FlashStringHelper * title) { DWIN_Draw_String(false, false, DWIN_FONT_HEAD, Color_White, Color_Bg_Blue, 14, 4, (char*)title); } -inline void Clear_Menu_Area() { +void Clear_Menu_Area() { DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, 31, DWIN_WIDTH, STATUS_Y); } -inline void Clear_Main_Window() { +void Clear_Main_Window() { Clear_Title_Bar(); Clear_Menu_Area(); } -inline void Clear_Popup_Area() { +void Clear_Popup_Area() { Clear_Title_Bar(); DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, 31, DWIN_WIDTH, DWIN_HEIGHT); } @@ -430,30 +432,30 @@ void Draw_Popup_Bkgd_105() { DWIN_Draw_Rectangle(1, Color_Bg_Window, 14, 105, 258, 374); } -inline void Draw_More_Icon(const uint8_t line) { +void Draw_More_Icon(const uint8_t line) { DWIN_ICON_Show(ICON, ICON_More, 226, MBASE(line) - 3); } -inline void Draw_Menu_Cursor(const uint8_t line) { +void Draw_Menu_Cursor(const uint8_t line) { // DWIN_ICON_Show(ICON,ICON_Rectangle, 0, MBASE(line) - 18); DWIN_Draw_Rectangle(1, Rectangle_Color, 0, MBASE(line) - 18, 14, MBASE(line + 1) - 20); } -inline void Erase_Menu_Cursor(const uint8_t line) { +void Erase_Menu_Cursor(const uint8_t line) { DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, MBASE(line) - 18, 14, MBASE(line + 1) - 20); } -inline void Move_Highlight(const int16_t from, const uint16_t newline) { +void Move_Highlight(const int16_t from, const uint16_t newline) { Erase_Menu_Cursor(newline - from); Draw_Menu_Cursor(newline); } -inline void Add_Menu_Line() { +void Add_Menu_Line() { Move_Highlight(1, MROWS); DWIN_Draw_Line(Line_Color, 16, MBASE(MROWS + 1) - 20, 256, MBASE(MROWS + 1) - 19); } -inline void Scroll_Menu(const uint8_t dir) { +void Scroll_Menu(const uint8_t dir) { DWIN_Frame_AreaMove(1, dir, MLINE, Color_Bg_Black, 0, 31, DWIN_WIDTH, 349); switch (dir) { case DWIN_SCROLL_DOWN: Move_Highlight(-1, 0); break; @@ -465,22 +467,22 @@ inline uint16_t nr_sd_menu_items() { return card.get_num_Files() + !card.flag.workDirIsRoot; } -inline void Draw_Menu_Icon(const uint8_t line, const uint8_t icon) { +void Draw_Menu_Icon(const uint8_t line, const uint8_t icon) { DWIN_ICON_Show(ICON, icon, 26, MBASE(line) - 3); } -inline void Erase_Menu_Text(const uint8_t line) { +void Erase_Menu_Text(const uint8_t line) { DWIN_Draw_Rectangle(1, Color_Bg_Black, LBLX, MBASE(line) - 14, 271, MBASE(line) + 28); } -inline void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, const char * const label=nullptr) { +void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, const char * const label=nullptr) { if (label) DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(line) - 1, (char*)label); if (icon) Draw_Menu_Icon(line, icon); DWIN_Draw_Line(Line_Color, 16, MBASE(line) + 33, 256, MBASE(line) + 34); } // The "Back" label is always on the first line -inline void Draw_Back_Label() { +void Draw_Back_Label() { if (HMI_IsChinese()) DWIN_Frame_AreaCopy(1, 129, 72, 156, 84, LBLX, MBASE(0)); else @@ -488,7 +490,7 @@ inline void Draw_Back_Label() { } // Draw "Back" line at the top -inline void Draw_Back_First(const bool is_sel=true) { +void Draw_Back_First(const bool is_sel=true) { Draw_Menu_Line(0, ICON_Back); Draw_Back_Label(); if (is_sel) Draw_Menu_Cursor(0); @@ -554,40 +556,61 @@ inline bool Apply_Encoder(const ENCODER_DiffState &encoder_diffState, auto &valr // Draw Menus // -inline void draw_move_en(const uint16_t line) { - DWIN_Frame_AreaCopy(1, 69, 61, 102, 71, LBLX, line); // "Move" +void DWIN_Draw_Label(const uint16_t y, char *string) { + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, y, string); +} +void DWIN_Draw_Label(const uint16_t y, const __FlashStringHelper *title) { + DWIN_Draw_Label(y, (char*)title); +} + +void draw_move_en(const uint16_t line) { + #ifdef USE_STRING_TITLES + DWIN_Draw_Label(line, F("Move")); + #else + DWIN_Frame_AreaCopy(1, 69, 61, 102, 71, LBLX, line); // "Move" + #endif } -inline void DWIN_Frame_TitleCopy(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) { DWIN_Frame_AreaCopy(id, x1, y1, x2, y2, 14, 8); } +void DWIN_Frame_TitleCopy(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) { DWIN_Frame_AreaCopy(id, x1, y1, x2, y2, 14, 8); } -inline void Item_Prepare_Move(const uint8_t row) { +void Item_Prepare_Move(const uint8_t row) { if (HMI_IsChinese()) DWIN_Frame_AreaCopy(1, 159, 70, 200, 84, LBLX, MBASE(row)); else - draw_move_en(MBASE(row)); // "Move >" + draw_move_en(MBASE(row)); // "Move" Draw_Menu_Line(row, ICON_Axis); Draw_More_Icon(row); } -inline void Item_Prepare_Disable(const uint8_t row) { +void Item_Prepare_Disable(const uint8_t row) { if (HMI_IsChinese()) DWIN_Frame_AreaCopy(1, 204, 70, 259, 82, LBLX, MBASE(row)); - else - DWIN_Frame_AreaCopy(1, 103, 59, 200, 74, LBLX, MBASE(row)); // "Disable Stepper" + else { + #ifdef USE_STRING_TITLES + DWIN_Draw_Label(MBASE(row), GET_TEXT_F(MSG_DISABLE_STEPPERS)); + #else + DWIN_Frame_AreaCopy(1, 103, 59, 200, 74, LBLX, MBASE(row)); // "Disable Stepper" + #endif + } Draw_Menu_Line(row, ICON_CloseMotor); } -inline void Item_Prepare_Home(const uint8_t row) { +void Item_Prepare_Home(const uint8_t row) { if (HMI_IsChinese()) DWIN_Frame_AreaCopy(1, 0, 89, 41, 101, LBLX, MBASE(row)); - else - DWIN_Frame_AreaCopy(1, 202, 61, 271, 71, LBLX, MBASE(row)); // "Auto Home" + else { + #ifdef USE_STRING_TITLES + DWIN_Draw_Label(MBASE(row), GET_TEXT_F(MSG_AUTO_HOME)); + #else + DWIN_Frame_AreaCopy(1, 202, 61, 271, 71, LBLX, MBASE(row)); // "Auto Home" + #endif + } Draw_Menu_Line(row, ICON_Homing); } #if HAS_ZOFFSET_ITEM - inline void Item_Prepare_Offset(const uint8_t row) { + void Item_Prepare_Offset(const uint8_t row) { if (HMI_IsChinese()) { #if HAS_BED_PROBE DWIN_Frame_AreaCopy(1, 174, 164, 223, 177, LBLX, MBASE(row)); @@ -598,10 +621,18 @@ inline void Item_Prepare_Home(const uint8_t row) { } else { #if HAS_BED_PROBE - DWIN_Frame_AreaCopy(1, 93, 179, 141, 189, LBLX, MBASE(row)); // "Z-Offset" + #ifdef USE_STRING_TITLES + DWIN_Draw_Label(MBASE(row), GET_TEXT_F(MSG_ZPROBE_ZOFFSET)); + #else + DWIN_Frame_AreaCopy(1, 93, 179, 141, 189, LBLX, MBASE(row)); // "Z-Offset" + #endif DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 2, 2, 202, MBASE(row), probe.offset.z * 100); #else - DWIN_Frame_AreaCopy(1, 1, 76, 106, 86, LBLX, MBASE(row)); // "..." + #ifdef USE_STRING_TITLES + DWIN_Draw_Label(MBASE(row), GET_TEXT_F(MSG_SET_HOME_OFFSETS)); + #else + DWIN_Frame_AreaCopy(1, 1, 76, 106, 86, LBLX, MBASE(row)); // "Set home offsets" + #endif #endif } Draw_Menu_Line(row, ICON_SetHome); @@ -610,52 +641,67 @@ inline void Item_Prepare_Home(const uint8_t row) { #endif #if HAS_HOTEND - inline void Item_Prepare_PLA(const uint8_t row) { + void Item_Prepare_PLA(const uint8_t row) { if (HMI_IsChinese()) { DWIN_Frame_AreaCopy(1, 100, 89, 151, 101, LBLX, MBASE(row)); } else { - DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(row)); // "Preheat" - DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX + 52, MBASE(row)); // "PLA" + #ifdef USE_STRING_TITLES + DWIN_Draw_Label(MBASE(row), F("Preheat " PREHEAT_1_LABEL)); + #else + DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(row)); // "Preheat" + DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX + 52, MBASE(row)); // "PLA" + #endif } Draw_Menu_Line(row, ICON_PLAPreheat); } - inline void Item_Prepare_ABS(const uint8_t row) { + void Item_Prepare_ABS(const uint8_t row) { if (HMI_IsChinese()) { DWIN_Frame_AreaCopy(1, 180, 89, 233, 100, LBLX, MBASE(row)); } else { - DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(row)); // "Preheat" - DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX + 52, MBASE(row)); // "ABS" + #ifdef USE_STRING_TITLES + DWIN_Draw_Label(MBASE(row), F("Preheat " PREHEAT_2_LABEL)); + #else + DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(row)); // "Preheat" + DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX + 52, MBASE(row)); // "ABS" + #endif } Draw_Menu_Line(row, ICON_ABSPreheat); } #endif #if HAS_PREHEAT - inline void Item_Prepare_Cool(const uint8_t row) { + void Item_Prepare_Cool(const uint8_t row) { if (HMI_IsChinese()) DWIN_Frame_AreaCopy(1, 1, 104, 56, 117, LBLX, MBASE(row)); - else - DWIN_Frame_AreaCopy(1, 200, 76, 264, 86, LBLX, MBASE(row)); // "Cooldown" + else { + #ifdef USE_STRING_TITLES + DWIN_Draw_Label(MBASE(row), GET_TEXT_F(MSG_COOLDOWN)); + #else + DWIN_Frame_AreaCopy(1, 200, 76, 264, 86, LBLX, MBASE(row)); // "Cooldown" + #endif + } Draw_Menu_Line(row, ICON_Cool); } #endif -inline void Item_Prepare_Lang(const uint8_t row) { - if (HMI_IsChinese()) { +void Item_Prepare_Lang(const uint8_t row) { + if (HMI_IsChinese()) DWIN_Frame_AreaCopy(1, 239, 134, 266, 146, LBLX, MBASE(row)); - DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, 226, MBASE(row), F("CN")); - } else { - DWIN_Frame_AreaCopy(1, 0, 194, 121, 207, LBLX, MBASE(row)); // "Language selection" - DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, 226, MBASE(row), F("EN")); + #ifdef USE_STRING_TITLES + DWIN_Draw_Label(MBASE(row), F("UI Language")); + #else + DWIN_Frame_AreaCopy(1, 0, 194, 121, 207, LBLX, MBASE(row)); // "Language selection" + #endif } + DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, 226, MBASE(row), HMI_IsChinese() ? F("CN") : F("EN")); Draw_Menu_Icon(row, ICON_Language); } -inline void Draw_Prepare_Menu() { +void Draw_Prepare_Menu() { Clear_Main_Window(); const int16_t scroll = MROWS - index_prepare; // Scrolled-up lines @@ -692,7 +738,19 @@ inline void Draw_Prepare_Menu() { if (select_prepare.now) Draw_Menu_Cursor(PSCROL(select_prepare.now)); } -inline void Draw_Control_Menu() { +void Item_Control_Info(const uint16_t line) { + if (HMI_IsChinese()) + DWIN_Frame_AreaCopy(1, 231, 104, 258, 116, LBLX, line); + else { + #ifdef USE_STRING_TITLES + DWIN_Draw_Label(line, F("Info")); + #else + DWIN_Frame_AreaCopy(1, 0, 104, 24, 114, LBLX, line); + #endif + } +} + +void Draw_Control_Menu() { Clear_Main_Window(); #if CONTROL_CASE_TOTAL >= 6 @@ -717,36 +775,36 @@ inline void Draw_Control_Menu() { DWIN_Frame_AreaCopy(1, 174, 103, 229, 116, LBLX, CLINE(CONTROL_CASE_LOAD)); // Read Configuration DWIN_Frame_AreaCopy(1, 1, 118, 56, 131, LBLX, CLINE(CONTROL_CASE_RESET)); // Reset Configuration #endif - - if (CVISI(CONTROL_CASE_INFO)) - DWIN_Frame_AreaCopy(1, 231, 104, 258, 116, LBLX, CLINE(CONTROL_CASE_TEMP)); // Info > } else { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_CONTROL)); - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, CLINE(CONTROL_CASE_TEMP), GET_TEXT_F(MSG_TEMPERATURE)); - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, CLINE(CONTROL_CASE_MOVE), GET_TEXT_F(MSG_MOTION)); + #else + DWIN_Frame_TitleCopy(1, 128, 2, 176, 12); // "Control" + #endif + #ifdef USE_STRING_TITLES + DWIN_Draw_Label(CLINE(CONTROL_CASE_TEMP), GET_TEXT_F(MSG_TEMPERATURE)); + DWIN_Draw_Label(CLINE(CONTROL_CASE_MOVE), GET_TEXT_F(MSG_MOTION)); #if ENABLED(EEPROM_SETTINGS) - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, CLINE(CONTROL_CASE_SAVE), GET_TEXT_F(MSG_STORE_EEPROM)); - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, CLINE(CONTROL_CASE_LOAD), GET_TEXT_F(MSG_LOAD_EEPROM)); - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, CLINE(CONTROL_CASE_RESET), GET_TEXT_F(MSG_RESTORE_DEFAULTS)); + DWIN_Draw_Label(CLINE(CONTROL_CASE_SAVE), GET_TEXT_F(MSG_STORE_EEPROM)); + DWIN_Draw_Label(CLINE(CONTROL_CASE_LOAD), GET_TEXT_F(MSG_LOAD_EEPROM)); + DWIN_Draw_Label(CLINE(CONTROL_CASE_RESET), GET_TEXT_F(MSG_RESTORE_DEFAULTS)); #endif - if (CVISI(CONTROL_CASE_INFO)) DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, CLINE(CONTROL_CASE_INFO), F("Info")); #else - DWIN_Frame_TitleCopy(1, 128, 2, 176, 12); // "Control" DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX, CLINE(CONTROL_CASE_TEMP)); // Temperature > DWIN_Frame_AreaCopy(1, 84, 89, 128, 99, LBLX, CLINE(CONTROL_CASE_MOVE)); // Motion > #if ENABLED(EEPROM_SETTINGS) - DWIN_Frame_AreaCopy(1, 148, 89, 268, 101, LBLX , CLINE(CONTROL_CASE_SAVE // "Store Configuration" + DWIN_Frame_AreaCopy(1, 148, 89, 268, 101, LBLX , CLINE(CONTROL_CASE_SAVE)); // "Store Configuration" DWIN_Frame_AreaCopy(1, 26, 104, 57, 114, LBLX , CLINE(CONTROL_CASE_LOAD)); // "Read" DWIN_Frame_AreaCopy(1, 182, 89, 268, 101, LBLX + 34, CLINE(CONTROL_CASE_LOAD)); // "Configuration" DWIN_Frame_AreaCopy(1, 59, 104, 93, 114, LBLX , CLINE(CONTROL_CASE_RESET)); // "Reset" DWIN_Frame_AreaCopy(1, 182, 89, 268, 101, LBLX + 37, CLINE(CONTROL_CASE_RESET)); // "Configuration" #endif - if (CVISI(CONTROL_CASE_INFO)) DWIN_Frame_AreaCopy(1, 0, 104, 25, 115, LBLX, CLINE(CONTROL_CASE_INFO)); // Info > #endif } + if (CVISI(CONTROL_CASE_INFO)) Item_Control_Info(CLINE(CONTROL_CASE_INFO)); + if (select_control.now && CVISI(select_control.now)) Draw_Menu_Cursor(CSCROL(select_control.now)); @@ -770,7 +828,7 @@ inline void Draw_Control_Menu() { if (CVISI(CONTROL_CASE_INFO)) Draw_More_Icon(CSCROL(i)); } -inline void Draw_Tune_Menu() { +void Draw_Tune_Menu() { Clear_Main_Window(); if (HMI_IsChinese()) { @@ -792,19 +850,22 @@ inline void Draw_Tune_Menu() { else { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_TUNE)); - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TUNE_CASE_SPEED), GET_TEXT_F(MSG_SPEED)); + #else + DWIN_Frame_AreaCopy(1, 94, 2, 126, 12, 14, 9); + #endif + #ifdef USE_STRING_TITLES + DWIN_Draw_Label(MBASE(TUNE_CASE_SPEED), GET_TEXT_F(MSG_SPEED)); #if HAS_HOTEND - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TUNE_CASE_TEMP), GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND)); + DWIN_Draw_Label(MBASE(TUNE_CASE_TEMP), GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND)); #endif #if HAS_HEATED_BED - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TUNE_CASE_BED), GET_TEXT_F(MSG_UBL_SET_TEMP_BED)); + DWIN_Draw_Label(MBASE(TUNE_CASE_BED), GET_TEXT_F(MSG_UBL_SET_TEMP_BED)); #endif #if HAS_FAN - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TUNE_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED)); + DWIN_Draw_Label(MBASE(TUNE_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED)); #endif - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TUNE_CASE_ZOFF), GET_TEXT_F(MSG_ZPROBE_ZOFFSET)); + DWIN_Draw_Label(MBASE(TUNE_CASE_ZOFF), GET_TEXT_F(MSG_ZPROBE_ZOFFSET)); #else - DWIN_Frame_AreaCopy(1, 94, 2, 126, 12, 14, 9); DWIN_Frame_AreaCopy(1, 1, 179, 92, 190, LBLX, MBASE(TUNE_CASE_SPEED)); // Print speed #if HAS_HOTEND DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX, MBASE(TUNE_CASE_TEMP)); // Hotend... @@ -847,36 +908,36 @@ inline void Draw_Tune_Menu() { #endif } -inline void draw_max_en(const uint16_t line) { +void draw_max_en(const uint16_t line) { DWIN_Frame_AreaCopy(1, 245, 119, 269, 129, LBLX, line); // "Max" } -inline void draw_max_accel_en(const uint16_t line) { +void draw_max_accel_en(const uint16_t line) { draw_max_en(line); DWIN_Frame_AreaCopy(1, 1, 135, 79, 145, LBLX + 27, line); // "Acceleration" } -inline void draw_speed_en(const uint16_t inset, const uint16_t line) { +void draw_speed_en(const uint16_t inset, const uint16_t line) { DWIN_Frame_AreaCopy(1, 184, 119, 224, 132, LBLX + inset, line); // "Speed" } -inline void draw_jerk_en(const uint16_t line) { +void draw_jerk_en(const uint16_t line) { DWIN_Frame_AreaCopy(1, 64, 119, 106, 129, LBLX + 27, line); // "Jerk" } -inline void draw_steps_per_mm(const uint16_t line) { +void draw_steps_per_mm(const uint16_t line) { DWIN_Frame_AreaCopy(1, 1, 151, 101, 161, LBLX, line); // "Steps-per-mm" } -inline void say_x(const uint16_t inset, const uint16_t line) { +void say_x(const uint16_t inset, const uint16_t line) { DWIN_Frame_AreaCopy(1, 95, 104, 102, 114, LBLX + inset, line); // "X" } -inline void say_y(const uint16_t inset, const uint16_t line) { +void say_y(const uint16_t inset, const uint16_t line) { DWIN_Frame_AreaCopy(1, 104, 104, 110, 114, LBLX + inset, line); // "Y" } -inline void say_z(const uint16_t inset, const uint16_t line) { +void say_z(const uint16_t inset, const uint16_t line) { DWIN_Frame_AreaCopy(1, 112, 104, 120, 114, LBLX + inset, line); // "Z" } -inline void say_e(const uint16_t inset, const uint16_t line) { +void say_e(const uint16_t inset, const uint16_t line) { DWIN_Frame_AreaCopy(1, 237, 119, 244, 129, LBLX + inset, line); // "E" } -inline void Draw_Motion_Menu() { +void Draw_Motion_Menu() { Clear_Main_Window(); if (HMI_IsChinese()) { @@ -894,14 +955,17 @@ inline void Draw_Motion_Menu() { else { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_MOTION)); - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(MOTION_CASE_RATE), F("Feedrate")); - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(MOTION_CASE_ACCEL), GET_TEXT_F(MSG_ACCELERATION)); + #else + DWIN_Frame_TitleCopy(1, 144, 16, 189, 26); // "Motion" + #endif + #ifdef USE_STRING_TITLES + DWIN_Draw_Label(MBASE(MOTION_CASE_RATE), F("Feedrate")); + DWIN_Draw_Label(MBASE(MOTION_CASE_ACCEL), GET_TEXT_F(MSG_ACCELERATION)); #if HAS_CLASSIC_JERK - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(MOTION_CASE_JERK), GET_TEXT_F(MSG_JERK)); + DWIN_Draw_Label(MBASE(MOTION_CASE_JERK), GET_TEXT_F(MSG_JERK)); #endif - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(MOTION_CASE_STEPS), GET_TEXT_F(MSG_STEPS_PER_MM)); + DWIN_Draw_Label(MBASE(MOTION_CASE_STEPS), GET_TEXT_F(MSG_STEPS_PER_MM)); #else - DWIN_Frame_TitleCopy(1, 144, 16, 189, 26); // "Motion" draw_max_en(MBASE(MOTION_CASE_RATE)); draw_speed_en(27, MBASE(MOTION_CASE_RATE)); // "Max Speed" draw_max_accel_en(MBASE(MOTION_CASE_ACCEL)); // "Max Acceleration" #if HAS_CLASSIC_JERK @@ -959,7 +1023,7 @@ inline void Draw_Motion_Menu() { #endif -inline void Draw_Popup_Bkgd_60() { +void Draw_Popup_Bkgd_60() { DWIN_Draw_Rectangle(1, Color_Bg_Window, 14, 60, 258, 330); } @@ -1147,7 +1211,7 @@ inline ENCODER_DiffState get_encoder_state() { const millis_t ms = millis(); if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO; const ENCODER_DiffState state = Encoder_ReceiveAnalyze(); - if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT; + if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT_MS; return state; } @@ -1519,21 +1583,19 @@ void HMI_StepXYZE() { } // Draw X, Y, Z and blink if in an un-homed or un-trusted state -void _draw_axis_value(const AxisEnum axis, const uint16_t x, const uint16_t y, const bool blink) { - static bool _blink = false; +void _update_axis_value(const AxisEnum axis, const uint16_t x, const uint16_t y, const bool blink, const bool force) { const bool draw_qmark = axis_should_home(axis), draw_empty = NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !draw_qmark && !axis_is_trusted(axis); // Check for a position change static xyz_pos_t oldpos = { -1, -1, -1 }; const float p = current_position[axis]; - bool changed = oldpos[axis] != p; + const bool changed = oldpos[axis] != p; if (changed) oldpos[axis] = p; - if (changed || (blink != _blink && (draw_qmark || draw_empty))) { - _blink = blink; + if (force || changed || draw_qmark || draw_empty) { if (blink && draw_qmark) - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, x, y, F(" ??? ")); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, x, y, F("???.?")); else if (blink && draw_empty) DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, x, y, F(" ")); else @@ -1541,6 +1603,20 @@ void _draw_axis_value(const AxisEnum axis, const uint16_t x, const uint16_t y, c } } +void _draw_xyz_position(const bool force) { + //SERIAL_ECHOPGM("Draw XYZ:"); + static bool _blink = false; + const bool blink = !!(millis() & 0x400UL); + if (force || blink != _blink) { + _blink = blink; + //SERIAL_ECHOPGM(" (blink)"); + _update_axis_value(X_AXIS, 35, 459, blink, true); + _update_axis_value(Y_AXIS, 120, 459, blink, true); + _update_axis_value(Z_AXIS, 205, 459, blink, true); + } + //SERIAL_EOL(); +} + void update_variable() { TERN_(HAS_HOTEND, static float last_temp_hotend_target = 0); TERN_(HAS_HEATED_BED, static float last_temp_bed_target = 0); @@ -1648,10 +1724,7 @@ void update_variable() { } } - const bool blink = (millis() / 1000) & 1; // Is this an odd second? - _draw_axis_value(X_AXIS, 35, 459, blink); - _draw_axis_value(Y_AXIS, 120, 459, blink); - _draw_axis_value(Z_AXIS, 205, 459, blink); + _draw_xyz_position(false); } /** @@ -1666,7 +1739,7 @@ void update_variable() { #define strcasecmp_P(a, b) strcasecmp((a), (b)) #endif -inline void make_name_without_ext(char *dst, char *src, size_t maxlen=MENU_CHAR_LIMIT) { +void make_name_without_ext(char *dst, char *src, size_t maxlen=MENU_CHAR_LIMIT) { char * const name = card.longest_filename(); size_t pos = strlen(name); // index of ending nul @@ -1689,7 +1762,7 @@ inline void make_name_without_ext(char *dst, char *src, size_t maxlen=MENU_CHAR_ while (pos--) dst[pos] = src[pos]; } -inline void HMI_SDCardInit() { card.cdroot(); } +void HMI_SDCardInit() { card.cdroot(); } void MarlinUI::refresh() { /* Nothing to see here */ } @@ -1702,7 +1775,7 @@ void MarlinUI::refresh() { /* Nothing to see here */ } millis_t shift_ms; // = 0 // Init the shift name based on the highlighted item - inline void Init_Shift_Name() { + void Init_Shift_Name() { const bool is_subdir = !card.flag.workDirIsRoot; const int8_t filenum = select_file.now - 1 - is_subdir; // Skip "Back" and ".." const uint16_t fileCnt = card.get_num_Files(); @@ -1713,7 +1786,7 @@ void MarlinUI::refresh() { /* Nothing to see here */ } } } - inline void Init_SDItem_Shift() { + void Init_SDItem_Shift() { shift_amt = 0; shift_ms = select_file.now > 0 && strlen(shift_name) > MENU_CHAR_LIMIT ? millis() + 750UL : 0; @@ -1724,7 +1797,7 @@ void MarlinUI::refresh() { /* Nothing to see here */ } /** * Display an SD item, adding a CDUP for subfolders. */ -inline void Draw_SDItem(const uint16_t item, int16_t row=-1) { +void Draw_SDItem(const uint16_t item, int16_t row=-1) { if (row < 0) row = item + 1 + MROWS - index_file; const bool is_subdir = !card.flag.workDirIsRoot; if (is_subdir && item == 0) { @@ -1752,7 +1825,7 @@ inline void Draw_SDItem(const uint16_t item, int16_t row=-1) { #if ENABLED(SCROLL_LONG_FILENAMES) - inline void Draw_SDItem_Shifted(int8_t &shift) { + void Draw_SDItem_Shifted(int8_t &shift) { // Limit to the number of chars past the cutoff const size_t len = strlen(shift_name); NOMORE(shift, _MAX(len - MENU_CHAR_LIMIT, 0U)); @@ -1773,7 +1846,7 @@ inline void Draw_SDItem(const uint16_t item, int16_t row=-1) { #endif // Redraw the first set of SD Files -inline void Redraw_SD_List() { +void Redraw_SD_List() { select_file.reset(); index_file = MROWS; @@ -1796,13 +1869,13 @@ inline void Redraw_SD_List() { bool DWIN_lcd_sd_status = false; -inline void SDCard_Up() { +void SDCard_Up() { card.cdup(); Redraw_SD_List(); DWIN_lcd_sd_status = false; // On next DWIN_Update } -inline void SDCard_Folder(char * const dirname) { +void SDCard_Folder(char * const dirname) { card.cd(dirname); Redraw_SD_List(); DWIN_lcd_sd_status = false; // On next DWIN_Update @@ -1815,7 +1888,7 @@ void HMI_SDCardUpdate() { if (HMI_flag.home_flag) return; if (DWIN_lcd_sd_status != card.isMounted()) { DWIN_lcd_sd_status = card.isMounted(); - // SERIAL_ECHOLNPAIR("HMI_SDCardUpdate: ", DWIN_lcd_sd_status); + //SERIAL_ECHOLNPAIR("HMI_SDCardUpdate: ", DWIN_lcd_sd_status); if (DWIN_lcd_sd_status) { if (checkkey == SelectFile) Redraw_SD_List(); @@ -1887,10 +1960,10 @@ void Draw_Status_Area(const bool with_update) { DWIN_Draw_Rectangle(1, Line_Color, 0, 449, DWIN_WIDTH, 451); - const bool blink = (millis() / 1000) & 1; // Is this an odd second? - DWIN_ICON_Show(ICON, ICON_MaxSpeedX, 10, 456); _draw_axis_value(X_AXIS, 35, 459, blink); - DWIN_ICON_Show(ICON, ICON_MaxSpeedY, 95, 456); _draw_axis_value(Y_AXIS, 120, 459, blink); - DWIN_ICON_Show(ICON, ICON_MaxSpeedZ, 180, 456); _draw_axis_value(Z_AXIS, 205, 459, blink); + DWIN_ICON_Show(ICON, ICON_MaxSpeedX, 10, 456); + DWIN_ICON_Show(ICON, ICON_MaxSpeedY, 95, 456); + DWIN_ICON_Show(ICON, ICON_MaxSpeedZ, 180, 456); + _draw_xyz_position(true); if (with_update) { DWIN_UpdateLCD(); @@ -1903,11 +1976,11 @@ void HMI_StartFrame(const bool with_update) { Draw_Status_Area(with_update); } -inline void Draw_Info_Menu() { +void Draw_Info_Menu() { Clear_Main_Window(); - DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, (DWIN_WIDTH - strlen(MACHINE_SIZE) * MENU_CHR_W) / 2, 122, (char*)MACHINE_SIZE); - DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, (DWIN_WIDTH - strlen(SHORT_BUILD_VERSION) * MENU_CHR_W) / 2, 195, (char*)SHORT_BUILD_VERSION); + DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, (DWIN_WIDTH - strlen(MACHINE_SIZE) * MENU_CHR_W) / 2, 122, F(MACHINE_SIZE)); + DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, (DWIN_WIDTH - strlen(SHORT_BUILD_VERSION) * MENU_CHR_W) / 2, 195, F(SHORT_BUILD_VERSION)); if (HMI_IsChinese()) { DWIN_Frame_TitleCopy(1, 30, 17, 57, 29); // "Info" @@ -1915,7 +1988,7 @@ inline void Draw_Info_Menu() { DWIN_Frame_AreaCopy(1, 197, 149, 252, 161, 108, 102); DWIN_Frame_AreaCopy(1, 1, 164, 56, 176, 108, 175); DWIN_Frame_AreaCopy(1, 58, 164, 113, 176, 105, 248); - DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, (DWIN_WIDTH - strlen(CORP_WEBSITE_C) * MENU_CHR_W) / 2, 268, (char*)CORP_WEBSITE_C); + DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, (DWIN_WIDTH - strlen(CORP_WEBSITE_C) * MENU_CHR_W) / 2, 268, F(CORP_WEBSITE_C)); } else { #ifdef USE_STRING_HEADINGS @@ -1927,7 +2000,7 @@ inline void Draw_Info_Menu() { DWIN_Frame_AreaCopy(1, 120, 150, 146, 161, 124, 102); DWIN_Frame_AreaCopy(1, 146, 151, 254, 161, 82, 175); DWIN_Frame_AreaCopy(1, 0, 165, 94, 175, 89, 248); - DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, (DWIN_WIDTH - strlen(CORP_WEBSITE_E) * MENU_CHR_W) / 2, 268, (char*)CORP_WEBSITE_E); + DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, (DWIN_WIDTH - strlen(CORP_WEBSITE_E) * MENU_CHR_W) / 2, 268, F(CORP_WEBSITE_E)); } Draw_Back_First(); @@ -1937,7 +2010,7 @@ inline void Draw_Info_Menu() { } } -inline void Draw_Print_File_Menu() { +void Draw_Print_File_Menu() { Clear_Title_Bar(); if (HMI_IsChinese()) { @@ -2266,7 +2339,7 @@ void HMI_PauseOrStop() { DWIN_UpdateLCD(); } -inline void Draw_Move_Menu() { +void Draw_Move_Menu() { Clear_Main_Window(); if (HMI_IsChinese()) { @@ -2457,21 +2530,24 @@ void Draw_Temperature_Menu() { else { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_TEMPERATURE)); + #else + DWIN_Frame_TitleCopy(1, 56, 16, 141, 28); // "Temperature" + #endif + #ifdef USE_STRING_TITLES #if HAS_HOTEND - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TEMP_CASE_TEMP), GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND)); + DWIN_Draw_Label(MBASE(TEMP_CASE_TEMP), GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND)); #endif #if HAS_HEATED_BED - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TEMP_CASE_BED), GET_TEXT_F(MSG_UBL_SET_TEMP_BED)); + DWIN_Draw_Label(MBASE(TEMP_CASE_BED), GET_TEXT_F(MSG_UBL_SET_TEMP_BED)); #endif #if HAS_FAN - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TEMP_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED)); + DWIN_Draw_Label(MBASE(TEMP_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED)); #endif #if HAS_HOTEND - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TEMP_CASE_PLA), F("PLA Preheat Settings")); - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TEMP_CASE_ABS), F("ABS Preheat Settings")); + DWIN_Draw_Label(MBASE(TEMP_CASE_PLA), F("PLA Preheat Settings")); + DWIN_Draw_Label(MBASE(TEMP_CASE_ABS), F("ABS Preheat Settings")); #endif #else - DWIN_Frame_TitleCopy(1, 56, 16, 141, 28); // "Temperature" #if HAS_HOTEND DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX, MBASE(TEMP_CASE_TEMP)); // Nozzle... DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 44, MBASE(TEMP_CASE_TEMP)); // ...Temperature @@ -2537,10 +2613,7 @@ void HMI_Control() { Draw_More_Icon(CONTROL_CASE_MOVE + MROWS - index_control); // Motion > if (index_control > MROWS) { Draw_More_Icon(CONTROL_CASE_INFO + MROWS - index_control); // Info > - if (HMI_IsChinese()) - DWIN_Frame_AreaCopy(1, 231, 104, 258, 116, LBLX, MBASE(CONTROL_CASE_INFO - 1)); - else - DWIN_Frame_AreaCopy(1, 0, 104, 24, 114, LBLX, MBASE(CONTROL_CASE_INFO - 1)); + Item_Control_Info(MBASE(CONTROL_CASE_INFO - 1)); } } else { @@ -2766,18 +2839,21 @@ void HMI_Temperature() { else { #ifdef USE_STRING_HEADINGS Draw_Title("PLA Settings"); // TODO: GET_TEXT_F - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(PREHEAT_CASE_TEMP), F("Nozzle Temp")); + #else + DWIN_Frame_TitleCopy(1, 56, 16, 141, 28); // "PLA Settings" + #endif + #ifdef USE_STRING_TITLES + DWIN_Draw_Label(MBASE(PREHEAT_CASE_TEMP), F("Nozzle Temp")); #if HAS_HEATED_BED - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(PREHEAT_CASE_BED), F("Bed Temp")); + DWIN_Draw_Label(MBASE(PREHEAT_CASE_BED), F("Bed Temp")); #endif #if HAS_FAN - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(PREHEAT_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED)); + DWIN_Draw_Label(MBASE(PREHEAT_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED)); #endif #if ENABLED(EEPROM_SETTINGS) - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(PREHEAT_CASE_SAVE), GET_TEXT_F(MSG_STORE_EEPROM)); + DWIN_Draw_Label(MBASE(PREHEAT_CASE_SAVE), GET_TEXT_F(MSG_STORE_EEPROM)); #endif #else - DWIN_Frame_TitleCopy(1, 56, 16, 141, 28); // "PLA Settings" DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX, MBASE(PREHEAT_CASE_TEMP)); DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX + 27, MBASE(PREHEAT_CASE_TEMP)); DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 71, MBASE(PREHEAT_CASE_TEMP)); // PLA nozzle temp @@ -2842,18 +2918,21 @@ void HMI_Temperature() { else { #ifdef USE_STRING_HEADINGS Draw_Title("ABS Settings"); // TODO: GET_TEXT_F - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(PREHEAT_CASE_TEMP), F("Nozzle Temp")); + #else + DWIN_Frame_TitleCopy(1, 56, 16, 141, 28); // "ABS Settings" + #endif + #ifdef USE_STRING_TITLES + DWIN_Draw_Label(MBASE(PREHEAT_CASE_TEMP), F("Nozzle Temp")); #if HAS_HEATED_BED - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(PREHEAT_CASE_BED), F("Bed Temp")); + DWIN_Draw_Label(MBASE(PREHEAT_CASE_BED), F("Bed Temp")); #endif #if HAS_FAN - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(PREHEAT_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED)); + DWIN_Draw_Label(MBASE(PREHEAT_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED)); #endif #if ENABLED(EEPROM_SETTINGS) - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(PREHEAT_CASE_SAVE), GET_TEXT_F(MSG_STORE_EEPROM)); + DWIN_Draw_Label(MBASE(PREHEAT_CASE_SAVE), GET_TEXT_F(MSG_STORE_EEPROM)); #endif #else - DWIN_Frame_TitleCopy(1, 56, 16, 141, 28); // "ABS Settings" DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX, MBASE(PREHEAT_CASE_TEMP)); DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX + 27, MBASE(PREHEAT_CASE_TEMP)); DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 71, MBASE(PREHEAT_CASE_TEMP)); // ABS nozzle temp @@ -2898,7 +2977,7 @@ void HMI_Temperature() { DWIN_UpdateLCD(); } -inline void Draw_Max_Speed_Menu() { +void Draw_Max_Speed_Menu() { Clear_Main_Window(); if (HMI_IsChinese()) { @@ -2922,15 +3001,17 @@ inline void Draw_Max_Speed_Menu() { else { #ifdef USE_STRING_HEADINGS Draw_Title("Max Speed (mm/s)"); // TODO: GET_TEXT_F - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(1), F("Max Feedrate X")); - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(2), F("Max Feedrate Y")); - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(3), F("Max Feedrate Z")); + #else + DWIN_Frame_TitleCopy(1, 144, 16, 189, 26); // "Max Speed (mm/s)" + #endif + #ifdef USE_STRING_TITLES + DWIN_Draw_Label(MBASE(1), F("Max Feedrate X")); + DWIN_Draw_Label(MBASE(2), F("Max Feedrate Y")); + DWIN_Draw_Label(MBASE(3), F("Max Feedrate Z")); #if HAS_HOTEND - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(4), F("Max Feedrate E")); + DWIN_Draw_Label(MBASE(4), F("Max Feedrate E")); #endif #else - DWIN_Frame_TitleCopy(1, 144, 16, 189, 26); // "Max Speed (mm/s)" - draw_max_en(MBASE(1)); // "Max" DWIN_Frame_AreaCopy(1, 184, 119, 234, 132, LBLX + 27, MBASE(1)); // "Speed X" @@ -2960,7 +3041,7 @@ inline void Draw_Max_Speed_Menu() { #endif } -inline void Draw_Max_Accel_Menu() { +void Draw_Max_Accel_Menu() { Clear_Main_Window(); if (HMI_IsChinese()) { @@ -2984,14 +3065,17 @@ inline void Draw_Max_Accel_Menu() { else { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_ACCELERATION)); - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(1), F("Max Accel X")); - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(2), F("Max Accel Y")); - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(3), F("Max Accel Z")); + #else + DWIN_Frame_TitleCopy(1, 144, 16, 189, 26); // "Acceleration" + #endif + #ifdef USE_STRING_TITLES + DWIN_Draw_Label(MBASE(1), F("Max Accel X")); + DWIN_Draw_Label(MBASE(2), F("Max Accel Y")); + DWIN_Draw_Label(MBASE(3), F("Max Accel Z")); #if HAS_HOTEND - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(4), F("Max Accel E")); + DWIN_Draw_Label(MBASE(4), F("Max Accel E")); #endif #else - DWIN_Frame_TitleCopy(1, 144, 16, 189, 26); // "Acceleration" draw_max_accel_en(MBASE(1)); say_x(108, MBASE(1)); // "Max Acceleration X" draw_max_accel_en(MBASE(2)); say_y(108, MBASE(2)); // "Max Acceleration Y" draw_max_accel_en(MBASE(3)); say_z(108, MBASE(3)); // "Max Acceleration Z" @@ -3012,7 +3096,7 @@ inline void Draw_Max_Accel_Menu() { } #if HAS_CLASSIC_JERK - inline void Draw_Max_Jerk_Menu() { + void Draw_Max_Jerk_Menu() { Clear_Main_Window(); if (HMI_IsChinese()) { @@ -3040,14 +3124,17 @@ inline void Draw_Max_Accel_Menu() { else { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_JERK)); - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(1), F("Max Jerk X")); - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(2), F("Max Jerk Y")); - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(3), F("Max Jerk Z")); + #else + DWIN_Frame_TitleCopy(1, 144, 16, 189, 26); // "Jerk" + #endif + #ifdef USE_STRING_TITLES + DWIN_Draw_Label(MBASE(1), F("Max Jerk X")); + DWIN_Draw_Label(MBASE(2), F("Max Jerk Y")); + DWIN_Draw_Label(MBASE(3), F("Max Jerk Z")); #if HAS_HOTEND - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(4), F("Max Jerk E")); + DWIN_Draw_Label(MBASE(4), F("Max Jerk E")); #endif #else - DWIN_Frame_TitleCopy(1, 144, 16, 189, 26); // "Jerk" draw_max_en(MBASE(1)); // "Max" draw_jerk_en(MBASE(1)); // "Jerk" draw_speed_en(72, MBASE(1)); // "Speed" @@ -3083,7 +3170,7 @@ inline void Draw_Max_Accel_Menu() { } #endif -inline void Draw_Steps_Menu() { +void Draw_Steps_Menu() { Clear_Main_Window(); if (HMI_IsChinese()) { @@ -3103,14 +3190,17 @@ inline void Draw_Steps_Menu() { else { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_STEPS_PER_MM)); - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(1), F("Steps/mm X")); - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(2), F("Steps/mm Y")); - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(3), F("Steps/mm Z")); + #else + DWIN_Frame_TitleCopy(1, 144, 16, 189, 26); // "Steps per mm" + #endif + #ifdef USE_STRING_TITLES + DWIN_Draw_Label(MBASE(1), F("Steps/mm X")); + DWIN_Draw_Label(MBASE(2), F("Steps/mm Y")); + DWIN_Draw_Label(MBASE(3), F("Steps/mm Z")); #if HAS_HOTEND - DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(4), F("Steps/mm E")); + DWIN_Draw_Label(MBASE(4), F("Steps/mm E")); #endif #else - DWIN_Frame_TitleCopy(1, 144, 16, 189, 26); // "Steps per mm" draw_steps_per_mm(MBASE(1)); say_x(103, MBASE(1)); // "Steps-per-mm X" draw_steps_per_mm(MBASE(2)); say_y(103, MBASE(2)); // "Y" draw_steps_per_mm(MBASE(3)); say_z(103, MBASE(3)); // "Z" @@ -3535,14 +3625,17 @@ void DWIN_Update() { } void EachMomentUpdate() { - static millis_t next_rts_update_ms = 0; + static millis_t next_var_update_ms = 0, next_rts_update_ms = 0; + const millis_t ms = millis(); + if (ELAPSED(ms, next_var_update_ms)) { + next_var_update_ms = ms + DWIN_VAR_UPDATE_INTERVAL; + update_variable(); + } + if (PENDING(ms, next_rts_update_ms)) return; next_rts_update_ms = ms + DWIN_SCROLL_UPDATE_INTERVAL; - // variable update - update_variable(); - if (checkkey == PrintProcess) { // if print done if (HMI_flag.print_finish && !HMI_flag.done_confirm_flag) { @@ -3604,7 +3697,7 @@ void EachMomentUpdate() { static millis_t next_remain_time_update = 0; if (_card_percent > 1 && ELAPSED(ms, next_remain_time_update) && !HMI_flag.heat_flag) { _remain_time = (elapsed.value - dwin_heat_time) / (_card_percent * 0.01f) - (elapsed.value - dwin_heat_time); - next_remain_time_update += SEC_TO_MS(20); + next_remain_time_update += DWIN_REMAIN_TIME_UPDATE_INTERVAL; Draw_Print_ProgressRemain(); } } @@ -3667,6 +3760,7 @@ void EachMomentUpdate() { Draw_Status_Area(true); } #endif + DWIN_UpdateLCD(); } From 045624211c72d93099e41a9d6454fcc6ff6d2e53 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 12 Feb 2021 02:43:29 -0600 Subject: [PATCH 6/8] misc. cleanup --- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index a6840ded0740..c71849d57a8e 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -1626,20 +1626,20 @@ void update_variable() { if (checkkey == Tune) { #if HAS_HOTEND if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) { - DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_TEMP + MROWS - index_tune), thermalManager.temp_hotend[0].target); last_temp_hotend_target = thermalManager.temp_hotend[0].target; + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_TEMP + MROWS - index_tune), last_temp_hotend_target); } #endif #if HAS_HEATED_BED if (last_temp_bed_target != thermalManager.temp_bed.target) { - DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_BED + MROWS - index_tune), thermalManager.temp_bed.target); last_temp_bed_target = thermalManager.temp_bed.target; + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_BED + MROWS - index_tune), last_temp_bed_target); } #endif #if HAS_FAN if (last_fan_speed != thermalManager.fan_speed[0]) { - DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_FAN + MROWS - index_tune), thermalManager.fan_speed[0]); last_fan_speed = thermalManager.fan_speed[0]; + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_FAN + MROWS - index_tune), last_fan_speed); } #endif } @@ -1648,20 +1648,20 @@ void update_variable() { if (checkkey == TemperatureID) { #if HAS_HOTEND if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) { - DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TEMP_CASE_TEMP), thermalManager.temp_hotend[0].target); last_temp_hotend_target = thermalManager.temp_hotend[0].target; + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TEMP_CASE_TEMP), last_temp_hotend_target); } #endif #if HAS_HEATED_BED if (last_temp_bed_target != thermalManager.temp_bed.target) { - DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TEMP_CASE_BED), thermalManager.temp_bed.target); last_temp_bed_target = thermalManager.temp_bed.target; + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TEMP_CASE_BED), last_temp_bed_target); } #endif #if HAS_FAN if (last_fan_speed != thermalManager.fan_speed[0]) { - DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TEMP_CASE_FAN), thermalManager.fan_speed[0]); last_fan_speed = thermalManager.fan_speed[0]; + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TEMP_CASE_FAN), last_fan_speed); } #endif } From 61683c2c685147a3d009145015f4b4ffc609e51b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 12 Feb 2021 03:44:03 -0600 Subject: [PATCH 7/8] and a bit more cleanup --- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 94 +++++++++++++++---------------- 1 file changed, 45 insertions(+), 49 deletions(-) diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index c71849d57a8e..6be872ae31f6 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -98,7 +98,7 @@ #define PAUSE_HEAT #define USE_STRING_HEADINGS -#define USE_STRING_TITLES +//#define USE_STRING_TITLES #define DWIN_FONT_MENU font8x16 #define DWIN_FONT_STAT font10x20 @@ -1465,7 +1465,7 @@ void HMI_Move_Z() { else checkkey = Tune; DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(fan_line), HMI_ValueStruct.Fan_speed); - TERN_(HAS_FAN, thermalManager.set_fan_speed(0, HMI_ValueStruct.Fan_speed)); + thermalManager.set_fan_speed(0, HMI_ValueStruct.Fan_speed); return; } // Fan_speed limit @@ -1618,65 +1618,67 @@ void _draw_xyz_position(const bool force) { } void update_variable() { - TERN_(HAS_HOTEND, static float last_temp_hotend_target = 0); - TERN_(HAS_HEATED_BED, static float last_temp_bed_target = 0); - TERN_(HAS_FAN, static uint8_t last_fan_speed = 0); + #if HAS_HOTEND + static float _hotendtemp = 0; + const bool _new_hotend_temp = _hotendtemp != thermalManager.temp_hotend[0].celsius; + if (_new_hotend_temp) _hotendtemp = thermalManager.temp_hotend[0].celsius; + static int16_t _hotendtarget = 0; + const bool _new_hotend_target = _hotendtarget != thermalManager.temp_hotend[0].target; + if (_new_hotend_target) _hotendtarget = thermalManager.temp_hotend[0].target; + #endif + #if HAS_HEATED_BED + static float _bedtemp = 0; + const bool _new_bed_temp = _bedtemp != thermalManager.temp_bed.celsius; + if (_new_bed_temp) _bedtemp = thermalManager.temp_bed.celsius; + static int16_t _bedtarget = 0; + const bool _new_bed_target = _bedtarget != thermalManager.temp_bed.target; + if (_new_bed_target) _bedtarget = thermalManager.temp_bed.target; + #endif + #if HAS_FAN + static uint8_t _fanspeed = 0; + const bool _new_fanspeed = _fanspeed != thermalManager.fan_speed[0]; + if (_new_fanspeed) _fanspeed = thermalManager.fan_speed[0]; + #endif - /* Tune page temperature update */ if (checkkey == Tune) { + // Tune page temperature update #if HAS_HOTEND - if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) { - last_temp_hotend_target = thermalManager.temp_hotend[0].target; - DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_TEMP + MROWS - index_tune), last_temp_hotend_target); - } + if (_new_hotend_target) + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_TEMP + MROWS - index_tune), _hotendtarget); #endif #if HAS_HEATED_BED - if (last_temp_bed_target != thermalManager.temp_bed.target) { - last_temp_bed_target = thermalManager.temp_bed.target; - DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_BED + MROWS - index_tune), last_temp_bed_target); - } + if (_new_bed_target) + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_BED + MROWS - index_tune), _bedtarget); #endif #if HAS_FAN - if (last_fan_speed != thermalManager.fan_speed[0]) { - last_fan_speed = thermalManager.fan_speed[0]; - DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_FAN + MROWS - index_tune), last_fan_speed); - } + if (_new_fanspeed) + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_FAN + MROWS - index_tune), _fanspeed); #endif } - - /* Temperature page temperature update */ - if (checkkey == TemperatureID) { + else if (checkkey == TemperatureID) { + // Temperature page temperature update #if HAS_HOTEND - if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) { - last_temp_hotend_target = thermalManager.temp_hotend[0].target; - DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TEMP_CASE_TEMP), last_temp_hotend_target); - } + if (_new_hotend_target) + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TEMP_CASE_TEMP), _hotendtarget); #endif #if HAS_HEATED_BED - if (last_temp_bed_target != thermalManager.temp_bed.target) { - last_temp_bed_target = thermalManager.temp_bed.target; - DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TEMP_CASE_BED), last_temp_bed_target); - } + if (_new_bed_target) + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TEMP_CASE_BED), _bedtarget); #endif #if HAS_FAN - if (last_fan_speed != thermalManager.fan_speed[0]) { - last_fan_speed = thermalManager.fan_speed[0]; - DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TEMP_CASE_FAN), last_fan_speed); - } + if (_new_fanspeed) + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TEMP_CASE_FAN), _fanspeed); #endif } + // Bottom temperature update + #if HAS_HOTEND - static float _hotendtemp = 0; - if (_hotendtemp != thermalManager.temp_hotend[0].celsius) { - _hotendtemp = thermalManager.temp_hotend[0].celsius; + if (_new_hotend_temp) DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 384, _hotendtemp); - } - static int16_t _hotendtarget = 0; - if (_hotendtarget != thermalManager.temp_hotend[0].target) { - _hotendtarget = thermalManager.temp_hotend[0].target; + if (_new_hotend_target) DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 384, _hotendtarget); - } + static int16_t _flow = planner.flow_percentage[0]; if (_flow != planner.flow_percentage[0]) { _flow = planner.flow_percentage[0]; @@ -1685,16 +1687,10 @@ void update_variable() { #endif #if HAS_HEATED_BED - static float _bedtemp = 0; - if (_bedtemp != thermalManager.temp_bed.celsius) { - _bedtemp = thermalManager.temp_bed.celsius; + if (_new_bed_temp) DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 417, _bedtemp); - } - static int16_t _bedtarget = 0; - if (_bedtarget != thermalManager.temp_bed.target) { - _bedtarget = thermalManager.temp_bed.target; + if (_new_bed_target) DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 417, _bedtarget); - } #endif static int16_t _feedrate = 100; From 54bfd60c2b8bf1e633291c05914d0b878cfe483e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 12 Feb 2021 04:45:47 -0600 Subject: [PATCH 8/8] Merge followup --- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index 6be872ae31f6..d7af1208ad71 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -1700,7 +1700,6 @@ void update_variable() { } #if HAS_FAN - static uint8_t _fanspeed = 0; if (_fanspeed != thermalManager.fan_speed[0]) { _fanspeed = thermalManager.fan_speed[0]; DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 195 + 2 * STAT_CHR_W, 384, _fanspeed);