🚸 Fix and update ProUI (#24477)

This commit is contained in:
Miguel Risco-Castillo 2022-07-14 00:00:33 -05:00 committed by Scott Lahteine
parent 3a19d34c75
commit 3c9789fda8
17 changed files with 376 additions and 303 deletions

View File

@ -21,6 +21,8 @@
*/ */
#pragma once #pragma once
typedef uint8_t fontid_t;
/** /**
* 3-.0The font size, 0x00-0x09, corresponds to the font size below: * 3-.0The font size, 0x00-0x09, corresponds to the font size below:
* 0x00=6*12 0x01=8*16 0x02=10*20 0x03=12*24 0x04=14*28 * 0x00=6*12 0x01=8*16 0x02=10*20 0x03=12*24 0x04=14*28

View File

@ -21,19 +21,20 @@
*/ */
/** /**
* UBL Tools and Mesh Viewer for Pro UI * Bed Level Tools for Pro UI
* Version: 1.0.0 * Extended by: Miguel A. Risco-Castillo (MRISCOC)
* Date: 2022/04/13 * Version: 2.0.0
* Date: 2022/05/23
* *
* Original Author: Henri-J-Norden * Based on the original work of: Henri-J-Norden
* Original Source: https://github.com/Jyers/Marlin/pull/126 * https://github.com/Jyers/Marlin/pull/126
*/ */
#include "../../../inc/MarlinConfigPre.h" #include "../../../inc/MarlinConfigPre.h"
#include "bedlevel_tools.h"
#if BOTH(DWIN_LCD_PROUI, AUTO_BED_LEVELING_UBL) #if BOTH(DWIN_LCD_PROUI, HAS_LEVELING)
#include "ubl_tools.h"
#include "../../marlinui.h" #include "../../marlinui.h"
#include "../../../core/types.h" #include "../../../core/types.h"
#include "dwin.h" #include "dwin.h"
@ -47,27 +48,29 @@
#include "../../../libs/least_squares_fit.h" #include "../../../libs/least_squares_fit.h"
#include "../../../libs/vector_3.h" #include "../../../libs/vector_3.h"
UBLMeshToolsClass ubl_tools; BedLevelToolsClass BedLevelTools;
#if ENABLED(USE_UBL_VIEWER) #if USE_UBL_VIEWER
bool UBLMeshToolsClass::viewer_asymmetric_range = false; bool BedLevelToolsClass::viewer_asymmetric_range = false;
bool UBLMeshToolsClass::viewer_print_value = false; bool BedLevelToolsClass::viewer_print_value = false;
#endif #endif
bool UBLMeshToolsClass::goto_mesh_value = false; bool BedLevelToolsClass::goto_mesh_value = false;
uint8_t UBLMeshToolsClass::tilt_grid = 1; uint8_t BedLevelToolsClass::mesh_x = 0;
uint8_t BedLevelToolsClass::mesh_y = 0;
uint8_t BedLevelToolsClass::tilt_grid = 1;
bool drawing_mesh = false; bool drawing_mesh = false;
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];
#if ENABLED(AUTO_BED_LEVELING_UBL) #if ENABLED(AUTO_BED_LEVELING_UBL)
void UBLMeshToolsClass::manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y, bool undefined/*=false*/) { void BedLevelToolsClass::manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y, bool undefined/*=false*/) {
sprintf_P(cmd, PSTR("M421 I%i J%i Z%s %s"), mesh_x, mesh_y, dtostrf(current_position.z, 1, 3, str_1), undefined ? "N" : ""); sprintf_P(cmd, PSTR("M421 I%i J%i Z%s %s"), mesh_x, mesh_y, dtostrf(current_position.z, 1, 3, str_1), undefined ? "N" : "");
gcode.process_subcommands_now(cmd); gcode.process_subcommands_now(cmd);
planner.synchronize(); planner.synchronize();
} }
bool UBLMeshToolsClass::create_plane_from_mesh() { bool BedLevelToolsClass::create_plane_from_mesh() {
struct linear_fit_data lsf_results; struct linear_fit_data lsf_results;
incremental_LSF_reset(&lsf_results); incremental_LSF_reset(&lsf_results);
GRID_LOOP(x, y) { GRID_LOOP(x, y) {
@ -119,7 +122,7 @@ char cmd[MAX_CMD_SIZE+16], str_1[16], str_2[16], str_3[16];
#else #else
void UBLMeshToolsClass::manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y) { void BedLevelToolsClass::manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y) {
sprintf_P(cmd, PSTR("G29 I%i J%i Z%s"), mesh_x, mesh_y, dtostrf(current_position.z, 1, 3, str_1)); sprintf_P(cmd, PSTR("G29 I%i J%i Z%s"), mesh_x, mesh_y, dtostrf(current_position.z, 1, 3, str_1));
gcode.process_subcommands_now(cmd); gcode.process_subcommands_now(cmd);
planner.synchronize(); planner.synchronize();
@ -127,7 +130,8 @@ char cmd[MAX_CMD_SIZE+16], str_1[16], str_2[16], str_3[16];
#endif #endif
void UBLMeshToolsClass::manual_move(const uint8_t mesh_x, const uint8_t mesh_y, bool zmove/*=false*/) { void BedLevelToolsClass::manual_move(const uint8_t mesh_x, const uint8_t mesh_y, bool zmove/*=false*/) {
gcode.process_subcommands_now(F("G28O"));
if (zmove) { if (zmove) {
planner.synchronize(); planner.synchronize();
current_position.z = goto_mesh_value ? bedlevel.z_values[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES; current_position.z = goto_mesh_value ? bedlevel.z_values[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES;
@ -149,8 +153,28 @@ void UBLMeshToolsClass::manual_move(const uint8_t mesh_x, const uint8_t mesh_y,
} }
} }
float UBLMeshToolsClass::get_max_value() { void BedLevelToolsClass::MoveToXYZ() {
float max = __FLT_MIN__; BedLevelTools.goto_mesh_value = true;
BedLevelTools.manual_move(BedLevelTools.mesh_x, BedLevelTools.mesh_y, false);
}
void BedLevelToolsClass::MoveToXY() {
BedLevelTools.goto_mesh_value = false;
BedLevelTools.manual_move(BedLevelTools.mesh_x, BedLevelTools.mesh_y, false);
}
void BedLevelToolsClass::MoveToZ() {
BedLevelTools.goto_mesh_value = true;
BedLevelTools.manual_move(BedLevelTools.mesh_x, BedLevelTools.mesh_y, true);
}
void BedLevelToolsClass::ProbeXY() {
sprintf_P(cmd, PSTR("G30X%sY%s"),
dtostrf(bedlevel.get_mesh_x(BedLevelTools.mesh_x), 1, 2, str_1),
dtostrf(bedlevel.get_mesh_y(BedLevelTools.mesh_y), 1, 2, str_2)
);
gcode.process_subcommands_now(cmd);
}
float BedLevelToolsClass::get_max_value() {
float max = __FLT_MAX__ * -1;
GRID_LOOP(x, y) { GRID_LOOP(x, y) {
if (!isnan(bedlevel.z_values[x][y]) && bedlevel.z_values[x][y] > max) if (!isnan(bedlevel.z_values[x][y]) && bedlevel.z_values[x][y] > max)
max = bedlevel.z_values[x][y]; max = bedlevel.z_values[x][y];
@ -158,7 +182,7 @@ float UBLMeshToolsClass::get_max_value() {
return max; return max;
} }
float UBLMeshToolsClass::get_min_value() { float BedLevelToolsClass::get_min_value() {
float min = __FLT_MAX__; float min = __FLT_MAX__;
GRID_LOOP(x, y) { GRID_LOOP(x, y) {
if (!isnan(bedlevel.z_values[x][y]) && bedlevel.z_values[x][y] < min) if (!isnan(bedlevel.z_values[x][y]) && bedlevel.z_values[x][y] < min)
@ -167,19 +191,20 @@ float UBLMeshToolsClass::get_min_value() {
return min; return min;
} }
bool UBLMeshToolsClass::validate() { bool BedLevelToolsClass::meshvalidate() {
float min = __FLT_MAX__, max = __FLT_MIN__; float min = __FLT_MAX__, max = __FLT_MAX__ * -1;
GRID_LOOP(x, y) { GRID_LOOP(x, y) {
if (isnan(bedlevel.z_values[x][y])) return false; if (isnan(bedlevel.z_values[x][y])) return false;
if (bedlevel.z_values[x][y] < min) min = bedlevel.z_values[x][y]; if (bedlevel.z_values[x][y] < min) min = bedlevel.z_values[x][y];
if (bedlevel.z_values[x][y] > max) max = bedlevel.z_values[x][y]; if (bedlevel.z_values[x][y] > max) max = bedlevel.z_values[x][y];
} }
return max <= UBL_Z_OFFSET_MAX && min >= UBL_Z_OFFSET_MIN; return WITHIN(max, MESH_Z_OFFSET_MIN, MESH_Z_OFFSET_MAX);
} }
#if ENABLED(USE_UBL_VIEWER) #if USE_UBL_VIEWER
void UBLMeshToolsClass::Draw_Bed_Mesh(int16_t selected /*= -1*/, uint8_t gridline_width /*= 1*/, uint16_t padding_x /*= 8*/, uint16_t padding_y_top /*= 40 + 53 - 7*/) {
void BedLevelToolsClass::Draw_Bed_Mesh(int16_t selected /*= -1*/, uint8_t gridline_width /*= 1*/, uint16_t padding_x /*= 8*/, uint16_t padding_y_top /*= 40 + 53 - 7*/) {
drawing_mesh = true; drawing_mesh = true;
const uint16_t total_width_px = DWIN_WIDTH - padding_x - padding_x; const uint16_t total_width_px = DWIN_WIDTH - padding_x - padding_x;
const uint16_t cell_width_px = total_width_px / (GRID_MAX_POINTS_X); const uint16_t cell_width_px = total_width_px / (GRID_MAX_POINTS_X);
@ -237,7 +262,7 @@ bool UBLMeshToolsClass::validate() {
} }
} }
void UBLMeshToolsClass::Set_Mesh_Viewer_Status() { // TODO: draw gradient with values as a legend instead void BedLevelToolsClass::Set_Mesh_Viewer_Status() { // TODO: draw gradient with values as a legend instead
float v_max = abs(get_max_value()), v_min = abs(get_min_value()), range = _MAX(v_min, v_max); float v_max = abs(get_max_value()), v_min = abs(get_min_value()), range = _MAX(v_min, v_max);
if (v_min > 3e+10F) v_min = 0.0000001; if (v_min > 3e+10F) v_min = 0.0000001;
if (v_max > 3e+10F) v_max = 0.0000001; if (v_max > 3e+10F) v_max = 0.0000001;
@ -255,6 +280,7 @@ bool UBLMeshToolsClass::validate() {
ui.set_status(msg); ui.set_status(msg);
drawing_mesh = false; drawing_mesh = false;
} }
#endif
#endif // DWIN_LCD_PROUI && AUTO_BED_LEVELING_UBL #endif // USE_UBL_VIEWER
#endif // DWIN_LCD_PROUI && HAS_LEVELING

View File

@ -1,10 +1,9 @@
/** /*
* UBL Tools and Mesh Viewer for Pro UI * Marlin 3D Printer Firmware
* Version: 1.0.0 * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* Date: 2022/04/13
* *
* Original Author: Henri-J-Norden (https://github.com/Henri-J-Norden) * Based on Sprinter and grbl.
* Original Source: https://github.com/Jyers/Marlin/pull/135 * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -20,22 +19,37 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
* *
*/ */
/**
* Bed Level Tools for Pro UI
* Extended by: Miguel A. Risco-Castillo (MRISCOC)
* Version: 2.0.0
* Date: 2022/05/23
*
* Based on the original work of: Henri-J-Norden
* https://github.com/Jyers/Marlin/pull/126
*/
#pragma once #pragma once
#include "../../../inc/MarlinConfigPre.h" #include "../../../inc/MarlinConfigPre.h"
//#define USE_UBL_VIEWER 1 #if ENABLED(AUTO_BED_LEVELING_UBL)
//#define USE_UBL_VIEWER 1
#endif
#define UBL_Z_OFFSET_MIN -3.0 #define MESH_Z_OFFSET_MIN -3.0
#define UBL_Z_OFFSET_MAX 3.0 #define MESH_Z_OFFSET_MAX 3.0
class UBLMeshToolsClass { class BedLevelToolsClass {
public: public:
#if ENABLED(USE_UBL_VIEWER) #if USE_UBL_VIEWER
static bool viewer_asymmetric_range; static bool viewer_asymmetric_range;
static bool viewer_print_value; static bool viewer_print_value;
#endif #endif
static bool goto_mesh_value; static bool goto_mesh_value;
static uint8_t mesh_x;
static uint8_t mesh_y;
static uint8_t tilt_grid; static uint8_t tilt_grid;
#if ENABLED(AUTO_BED_LEVELING_UBL) #if ENABLED(AUTO_BED_LEVELING_UBL)
@ -45,15 +59,19 @@ public:
static void manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y); static void manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y);
#endif #endif
static void manual_move(const uint8_t mesh_x, const uint8_t mesh_y, bool zmove=false); static void manual_move(const uint8_t mesh_x, const uint8_t mesh_y, bool zmove=false);
static void MoveToXYZ();
static void MoveToXY();
static void MoveToZ();
static void ProbeXY();
static float get_max_value(); static float get_max_value();
static float get_min_value(); static float get_min_value();
static bool validate(); static bool meshvalidate();
#if ENABLED(USE_UBL_VIEWER) #if USE_UBL_VIEWER
static void Draw_Bed_Mesh(int16_t selected = -1, uint8_t gridline_width = 1, uint16_t padding_x = 8, uint16_t padding_y_top = 40 + 53 - 7); static void Draw_Bed_Mesh(int16_t selected = -1, uint8_t gridline_width = 1, uint16_t padding_x = 8, uint16_t padding_y_top = 40 + 53 - 7);
static void Set_Mesh_Viewer_Status(); static void Set_Mesh_Viewer_Status();
#endif #endif
}; };
extern UBLMeshToolsClass ubl_tools; extern BedLevelToolsClass BedLevelTools;
void Goto_MeshViewer(); void Goto_MeshViewer();

View File

@ -101,17 +101,18 @@
#if HAS_MESH || HAS_ONESTEP_LEVELING #if HAS_MESH || HAS_ONESTEP_LEVELING
#include "../../../feature/bedlevel/bedlevel.h" #include "../../../feature/bedlevel/bedlevel.h"
#include "bedlevel_tools.h"
#endif #endif
#if HAS_BED_PROBE #if HAS_BED_PROBE
#include "../../../module/probe.h" #include "../../../module/probe.h"
#endif #endif
#ifdef BLTOUCH_HS_MODE #if ENABLED(BLTOUCH)
#include "../../../feature/bltouch.h" #include "../../../feature/bltouch.h"
#endif #endif
#if ANY(BABYSTEPPING, HAS_BED_PROBE, HAS_WORKSPACE_OFFSET) #if EITHER(BABYSTEPPING, HAS_BED_PROBE)
#define HAS_ZOFFSET_ITEM 1 #define HAS_ZOFFSET_ITEM 1
#if ENABLED(BABYSTEPPING) #if ENABLED(BABYSTEPPING)
#include "../../../feature/babystep.h" #include "../../../feature/babystep.h"
@ -141,10 +142,6 @@
#include "meshviewer.h" #include "meshviewer.h"
#endif #endif
#if ENABLED(AUTO_BED_LEVELING_UBL)
#include "ubl_tools.h"
#endif
#if ENABLED(PRINTCOUNTER) #if ENABLED(PRINTCOUNTER)
#include "printstats.h" #include "printstats.h"
#endif #endif
@ -157,16 +154,14 @@
#include "../../../feature/leds/leds.h" #include "../../../feature/leds/leds.h"
#endif #endif
#include <WString.h> #if HAS_LOCKSCREEN
#include <stdio.h> #include "lockscreen.h"
#include <string.h> #endif
#ifndef MACHINE_SIZE #ifndef MACHINE_SIZE
#define MACHINE_SIZE STRINGIFY(X_BED_SIZE) "x" STRINGIFY(Y_BED_SIZE) "x" STRINGIFY(Z_MAX_POS) #define MACHINE_SIZE STRINGIFY(X_BED_SIZE) "x" STRINGIFY(Y_BED_SIZE) "x" STRINGIFY(Z_MAX_POS)
#endif #endif
#include "lockscreen.h"
#define PAUSE_HEAT #define PAUSE_HEAT
#define MENU_CHAR_LIMIT 24 #define MENU_CHAR_LIMIT 24
@ -251,6 +246,7 @@ constexpr float max_feedrate_edit_values[] =
{ 1000, 1000, 10, 50 } { 1000, 1000, 10, 50 }
#endif #endif
; ;
constexpr float max_acceleration_edit_values[] = constexpr float max_acceleration_edit_values[] =
#ifdef MAX_ACCEL_EDIT_VALUES #ifdef MAX_ACCEL_EDIT_VALUES
MAX_ACCEL_EDIT_VALUES MAX_ACCEL_EDIT_VALUES
@ -258,6 +254,7 @@ constexpr float max_acceleration_edit_values[] =
{ 1000, 1000, 200, 2000 } { 1000, 1000, 200, 2000 }
#endif #endif
; ;
#if HAS_CLASSIC_JERK #if HAS_CLASSIC_JERK
constexpr float max_jerk_edit_values[] = constexpr float max_jerk_edit_values[] =
#ifdef MAX_JERK_EDIT_VALUES #ifdef MAX_JERK_EDIT_VALUES
@ -305,7 +302,9 @@ MenuClass *FilamentMenu = nullptr;
MenuClass *TemperatureMenu = nullptr; MenuClass *TemperatureMenu = nullptr;
MenuClass *MaxSpeedMenu = nullptr; MenuClass *MaxSpeedMenu = nullptr;
MenuClass *MaxAccelMenu = nullptr; MenuClass *MaxAccelMenu = nullptr;
MenuClass *MaxJerkMenu = nullptr; #if HAS_CLASSIC_JERK
MenuClass *MaxJerkMenu = nullptr;
#endif
MenuClass *StepsMenu = nullptr; MenuClass *StepsMenu = nullptr;
MenuClass *HotendPIDMenu = nullptr; MenuClass *HotendPIDMenu = nullptr;
MenuClass *BedPIDMenu = nullptr; MenuClass *BedPIDMenu = nullptr;
@ -552,14 +551,9 @@ void Popup_window_PauseOrStop() {
#endif #endif
// Draw status line // Draw status line
void DWIN_DrawStatusLine(const char *text) { void DWIN_DrawStatusLine() {
DWIN_Draw_Rectangle(1, HMI_data.StatusBg_Color, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20); DWIN_Draw_Rectangle(1, HMI_data.StatusBg_Color, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20);
if (text) DWINUI::Draw_CenteredString(HMI_data.StatusTxt_Color, STATUS_Y + 2, text); DWINUI::Draw_CenteredString(HMI_data.StatusTxt_Color, STATUS_Y + 2, ui.status_message);
}
void DWIN_DrawStatusLine(FSTR_P fstr) {
DWIN_Draw_Rectangle(1, HMI_data.StatusBg_Color, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20);
if (fstr) DWINUI::Draw_CenteredString(HMI_data.StatusTxt_Color, STATUS_Y + 2, fstr);
} }
// Clear & reset status line // Clear & reset status line
@ -588,7 +582,7 @@ void DWIN_DrawStatusMessage() {
// If the string fits the status line do not scroll it // If the string fits the status line do not scroll it
if (slen <= LCD_WIDTH) { if (slen <= LCD_WIDTH) {
if (hash_changed) { if (hash_changed) {
DWIN_DrawStatusLine(ui.status_message); DWIN_DrawStatusLine();
hash_changed = false; hash_changed = false;
} }
} }
@ -620,7 +614,7 @@ void DWIN_DrawStatusMessage() {
if (hash_changed) { if (hash_changed) {
ui.status_message[LCD_WIDTH] = 0; ui.status_message[LCD_WIDTH] = 0;
DWIN_DrawStatusLine(ui.status_message); DWIN_DrawStatusLine();
hash_changed = false; hash_changed = false;
} }
@ -663,7 +657,7 @@ void ICON_ResumeOrPause() {
} }
// Update filename on print // Update filename on print
void DWIN_Print_Header(const char *text = nullptr) { void DWIN_Print_Header(const char *text=nullptr) {
static char headertxt[31] = ""; // Print header text static char headertxt[31] = ""; // Print header text
if (text) { if (text) {
const int8_t size = _MIN(30U, strlen_P(text)); const int8_t size = _MIN(30U, strlen_P(text));
@ -1099,7 +1093,7 @@ void DWIN_Draw_Dashboard() {
DWINUI::Draw_Int(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 3, 195 + 2 * STAT_CHR_W, 384, thermalManager.fan_speed[0]); DWINUI::Draw_Int(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 3, 195 + 2 * STAT_CHR_W, 384, thermalManager.fan_speed[0]);
#endif #endif
#if BOTH(BABYSTEPPING, HAS_BED_PROBE) #if HAS_ZOFFSET_ITEM
DWINUI::Draw_Icon(planner.leveling_active ? ICON_SetZOffset : ICON_Zoffset, 187, 416); DWINUI::Draw_Icon(planner.leveling_active ? ICON_SetZOffset : ICON_Zoffset, 187, 416);
#endif #endif
@ -1370,13 +1364,15 @@ void Draw_Main_Area() {
case ESDiagProcess: Draw_EndStopDiag(); break; case ESDiagProcess: Draw_EndStopDiag(); break;
#endif #endif
case Popup: popupDraw(); break; case Popup: popupDraw(); break;
case Locked: lockScreen.draw(); break; #if HAS_LOCKSCREEN
case Locked: lockScreen.draw(); break;
#endif
case Menu: case Menu:
case SetInt: case SetInt:
case SetPInt: case SetPInt:
case SetIntNoDraw: case SetIntNoDraw:
case SetFloat: case SetFloat:
case SetPFloat: ReDrawMenu(); break; case SetPFloat: ReDrawMenu(true); break;
default: break; default: break;
} }
} }
@ -1567,7 +1563,9 @@ void DWIN_HandleScreen() {
case PrintProcess: HMI_Printing(); break; case PrintProcess: HMI_Printing(); break;
case Popup: HMI_Popup(); break; case Popup: HMI_Popup(); break;
case Leveling: break; case Leveling: break;
case Locked: HMI_LockScreen(); break; #if HAS_LOCKSCREEN
case Locked: HMI_LockScreen(); break;
#endif
case PrintDone: case PrintDone:
TERN_(HAS_ESDIAG, case ESDiagProcess:) TERN_(HAS_ESDIAG, case ESDiagProcess:)
case WaitResponse: HMI_WaitForUser(); break; case WaitResponse: HMI_WaitForUser(); break;
@ -1769,7 +1767,7 @@ void DWIN_Print_Aborted() {
Goto_PrintDone(); Goto_PrintDone();
} }
// Progress Bar update // Progress and remaining time update
void DWIN_M73() { void DWIN_M73() {
if (parser.seenval('P')) { if (parser.seenval('P')) {
_percent_done = parser.value_byte(); _percent_done = parser.value_byte();
@ -1843,11 +1841,6 @@ void DWIN_CopySettingsFrom(const char * const buff) {
TERN_(PREVENT_COLD_EXTRUSION, ApplyExtMinT()); TERN_(PREVENT_COLD_EXTRUSION, ApplyExtMinT());
feedrate_percentage = 100; feedrate_percentage = 100;
TERN_(BAUD_RATE_GCODE, HMI_SetBaudRate()); TERN_(BAUD_RATE_GCODE, HMI_SetBaudRate());
#if BOTH(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS)
// Apply Case light brightness
caselight.brightness = HMI_data.CaseLight_Brightness;
caselight.update_brightness();
#endif
#if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS)
leds.set_color( leds.set_color(
(HMI_data.LED_Color >> 16) & 0xFF, (HMI_data.LED_Color >> 16) & 0xFF,
@ -1880,7 +1873,7 @@ void DWIN_InitScreen() {
index_file = MROWS; index_file = MROWS;
hash_changed = true; hash_changed = true;
last_E = 0; last_E = 0;
DWIN_DrawStatusLine(FSTR_P(nullptr)); DWIN_DrawStatusLine();
DWIN_Draw_Dashboard(); DWIN_Draw_Dashboard();
Goto_Main_Menu(); Goto_Main_Menu();
} }
@ -1935,7 +1928,7 @@ void DWIN_RedrawScreen() {
case PAUSE_MESSAGE_PARKING: DWIN_Popup_Pause(GET_TEXT_F(MSG_PAUSE_PRINT_PARKING)); break; // M125 case PAUSE_MESSAGE_PARKING: DWIN_Popup_Pause(GET_TEXT_F(MSG_PAUSE_PRINT_PARKING)); break; // M125
case PAUSE_MESSAGE_CHANGING: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_INIT)); break; // pause_print (M125, M600) case PAUSE_MESSAGE_CHANGING: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_INIT)); break; // pause_print (M125, M600)
case PAUSE_MESSAGE_WAITING: DWIN_Popup_Pause(GET_TEXT_F(MSG_ADVANCED_PAUSE_WAITING), BTN_Continue); break; case PAUSE_MESSAGE_WAITING: DWIN_Popup_Pause(GET_TEXT_F(MSG_ADVANCED_PAUSE_WAITING), BTN_Continue); break;
case PAUSE_MESSAGE_INSERT: DWIN_Popup_Continue(ICON_BLTouch, GET_TEXT_F(MSG_ADVANCED_PAUSE), GET_TEXT_F(MSG_FILAMENT_CHANGE_INSERT)); break; case PAUSE_MESSAGE_INSERT: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_INSERT), BTN_Continue); break;
case PAUSE_MESSAGE_LOAD: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_LOAD)); break; case PAUSE_MESSAGE_LOAD: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_LOAD)); break;
case PAUSE_MESSAGE_UNLOAD: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_UNLOAD)); break; // Unload of pause and Unload of M702 case PAUSE_MESSAGE_UNLOAD: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_UNLOAD)); break; // Unload of pause and Unload of M702
case PAUSE_MESSAGE_PURGE: case PAUSE_MESSAGE_PURGE:
@ -1988,28 +1981,32 @@ void DWIN_RedrawScreen() {
} }
#endif // HAS_MESH #endif // HAS_MESH
void DWIN_LockScreen() {
if (checkkey != Locked) { #if HAS_LOCKSCREEN
lockScreen.rprocess = checkkey;
checkkey = Locked; void DWIN_LockScreen() {
lockScreen.init(); if (checkkey != Locked) {
lockScreen.rprocess = checkkey;
checkkey = Locked;
lockScreen.init();
}
} }
}
void DWIN_UnLockScreen() { void DWIN_UnLockScreen() {
if (checkkey == Locked) { if (checkkey == Locked) {
checkkey = lockScreen.rprocess; checkkey = lockScreen.rprocess;
Draw_Main_Area(); Draw_Main_Area();
}
} }
}
void HMI_LockScreen() { void HMI_LockScreen() {
EncoderState encoder_diffState = get_encoder_state(); EncoderState encoder_diffState = get_encoder_state();
if (encoder_diffState == ENCODER_DIFF_NO) return; if (encoder_diffState == ENCODER_DIFF_NO) return;
lockScreen.onEncoder(encoder_diffState); lockScreen.onEncoder(encoder_diffState);
if (lockScreen.isUnlocked()) DWIN_UnLockScreen(); if (lockScreen.isUnlocked()) DWIN_UnLockScreen();
} }
#endif // HAS_LOCKSCREEN
#if HAS_GCODE_PREVIEW #if HAS_GCODE_PREVIEW
@ -2051,7 +2048,8 @@ void HMI_LockScreen() {
#if ENABLED(EEPROM_SETTINGS) #if ENABLED(EEPROM_SETTINGS)
void WriteEeprom() { void WriteEeprom() {
DWIN_DrawStatusLine(GET_TEXT_F(MSG_STORE_EEPROM)); ui.set_status(GET_TEXT_F(MSG_STORE_EEPROM));
DWIN_DrawStatusLine();
DWIN_UpdateLCD(); DWIN_UpdateLCD();
DONE_BUZZ(settings.save()); DONE_BUZZ(settings.save());
} }
@ -2106,11 +2104,13 @@ void HomeX() { queue.inject(F("G28X")); }
void HomeY() { queue.inject(F("G28Y")); } void HomeY() { queue.inject(F("G28Y")); }
void HomeZ() { queue.inject(F("G28Z")); } void HomeZ() { queue.inject(F("G28Z")); }
void SetHome() { #if HAS_HOME_OFFSET
// Apply workspace offset, making the current position 0,0,0 // Apply workspace offset, making the current position 0,0,0
void SetHome() {
queue.inject(F("G92X0Y0Z0")); queue.inject(F("G92X0Y0Z0"));
DONE_BUZZ(true); DONE_BUZZ(true);
} }
#endif
#if HAS_ZOFFSET_ITEM #if HAS_ZOFFSET_ITEM
@ -2132,22 +2132,25 @@ void SetHome() {
void SetMoveZto0() { void SetMoveZto0() {
#if ENABLED(Z_SAFE_HOMING) #if ENABLED(Z_SAFE_HOMING)
char cmd[54], str_1[5], str_2[5]; char cmd[54], str_1[5], str_2[5];
sprintf_P(cmd, PSTR("G28XYO\nG28Z\nG0X%sY%sF5000\nM420S0\nG0Z0F300\nM400"), sprintf_P(cmd, PSTR("G28XYO\nG28Z\nG0X%sY%sF5000\nG0Z0F300\nM400"),
dtostrf(Z_SAFE_HOMING_X_POINT, 1, 1, str_1), dtostrf(Z_SAFE_HOMING_X_POINT, 1, 1, str_1),
dtostrf(Z_SAFE_HOMING_Y_POINT, 1, 1, str_2) dtostrf(Z_SAFE_HOMING_Y_POINT, 1, 1, str_2)
); );
gcode.process_subcommands_now(cmd); gcode.process_subcommands_now(cmd);
#else #else
gcode.process_subcommands_now(F("G28O\nM420S0\nG0Z0F300\nM400")); set_bed_leveling_enabled(false);
gcode.process_subcommands_now(F("G28O\nG0Z0F300\nM400"));
#endif #endif
ui.reset_status(); ui.reset_status();
DONE_BUZZ(true); DONE_BUZZ(true);
} }
void HomeZandDisable() { #if !HAS_BED_PROBE
SetMoveZto0(); void HomeZandDisable() {
DisableMotors(); SetMoveZto0();
} DisableMotors();
}
#endif
#endif // HAS_ZOFFSET_ITEM #endif // HAS_ZOFFSET_ITEM
@ -2840,9 +2843,6 @@ void onDrawGetColorItem(MenuItemClass* menuitem, int8_t line) {
DWIN_Draw_HLine(HMI_data.SplitLine_Color, 16, MYPOS(line + 1), 240); DWIN_Draw_HLine(HMI_data.SplitLine_Color, 16, MYPOS(line + 1), 240);
} }
#if HAS_FILAMENT_SENSOR
void onDrawRunoutEnable(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, runout.enabled); }
#endif
void onDrawPIDi(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, unscalePID_i(*(float*)static_cast<MenuItemPtrClass*>(menuitem)->value)); } void onDrawPIDi(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, unscalePID_i(*(float*)static_cast<MenuItemPtrClass*>(menuitem)->value)); }
void onDrawPIDd(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, unscalePID_d(*(float*)static_cast<MenuItemPtrClass*>(menuitem)->value)); } void onDrawPIDd(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, unscalePID_d(*(float*)static_cast<MenuItemPtrClass*>(menuitem)->value)); }
@ -3249,7 +3249,9 @@ void Draw_AdvancedSettings_Menu() {
MENU_ITEM_F(ICON_PrintStats, MSG_INFO_STATS_MENU, onDrawSubMenu, Goto_PrintStats); MENU_ITEM_F(ICON_PrintStats, MSG_INFO_STATS_MENU, onDrawSubMenu, Goto_PrintStats);
MENU_ITEM_F(ICON_PrintStatsReset, MSG_INFO_PRINT_COUNT_RESET, onDrawSubMenu, PrintStats.Reset); MENU_ITEM_F(ICON_PrintStatsReset, MSG_INFO_PRINT_COUNT_RESET, onDrawSubMenu, PrintStats.Reset);
#endif #endif
MENU_ITEM_F(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, DWIN_LockScreen); #if HAS_LOCKSCREEN
MENU_ITEM_F(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, DWIN_LockScreen);
#endif
} }
ui.reset_status(true); ui.reset_status(true);
UpdateMenu(AdvancedSettings); UpdateMenu(AdvancedSettings);
@ -3295,12 +3297,15 @@ void Draw_Move_Menu() {
EDIT_ITEM_F(ICON_ProbeOffsetX, MSG_ZPROBE_XOFFSET, onDrawPFloatMenu, SetProbeOffsetX, &probe.offset.x); EDIT_ITEM_F(ICON_ProbeOffsetX, MSG_ZPROBE_XOFFSET, onDrawPFloatMenu, SetProbeOffsetX, &probe.offset.x);
EDIT_ITEM_F(ICON_ProbeOffsetY, MSG_ZPROBE_YOFFSET, onDrawPFloatMenu, SetProbeOffsetY, &probe.offset.y); EDIT_ITEM_F(ICON_ProbeOffsetY, MSG_ZPROBE_YOFFSET, onDrawPFloatMenu, SetProbeOffsetY, &probe.offset.y);
EDIT_ITEM_F(ICON_ProbeOffsetZ, MSG_ZPROBE_ZOFFSET, onDrawPFloat2Menu, SetProbeOffsetZ, &probe.offset.z); EDIT_ITEM_F(ICON_ProbeOffsetZ, MSG_ZPROBE_ZOFFSET, onDrawPFloat2Menu, SetProbeOffsetZ, &probe.offset.z);
#ifdef BLTOUCH_HS_MODE #if ENABLED(BLTOUCH)
EDIT_ITEM_F(ICON_HSMode, MSG_ENABLE_HS_MODE, onDrawChkbMenu, SetHSMode, &bltouch.high_speed_mode); MENU_ITEM_F(ICON_ProbeStow, MSG_MANUAL_STOW, onDrawMenuItem, ProbeStow);
MENU_ITEM_F(ICON_ProbeDeploy, MSG_MANUAL_DEPLOY, onDrawMenuItem, ProbeDeploy);
MENU_ITEM_F(ICON_BltouchReset, MSG_BLTOUCH_RESET, onDrawMenuItem, bltouch._reset);
#ifdef BLTOUCH_HS_MODE
EDIT_ITEM_F(ICON_HSMode, MSG_ENABLE_HS_MODE, onDrawChkbMenu, SetHSMode, &bltouch.high_speed_mode);
#endif
#endif #endif
MENU_ITEM_F(ICON_ProbeTest, MSG_M48_TEST, onDrawMenuItem, ProbeTest); MENU_ITEM_F(ICON_ProbeTest, MSG_M48_TEST, onDrawMenuItem, ProbeTest);
MENU_ITEM_F(ICON_ProbeStow, MSG_MANUAL_STOW, onDrawMenuItem, ProbeStow);
MENU_ITEM_F(ICON_ProbeDeploy, MSG_MANUAL_DEPLOY, onDrawMenuItem, ProbeDeploy);
} }
UpdateMenu(ProbeSetMenu); UpdateMenu(ProbeSetMenu);
} }
@ -3384,14 +3389,24 @@ void Draw_GetColor_Menu() {
#endif #endif
#if ENABLED(LED_CONTROL_MENU) #if ENABLED(LED_CONTROL_MENU)
void Draw_LedControl_Menu() { void Draw_LedControl_Menu() {
checkkey = Menu; checkkey = Menu;
if (SetMenu(LedControlMenu, GET_TEXT_F(MSG_LED_CONTROL), 6)) { if (SetMenu(LedControlMenu, GET_TEXT_F(MSG_LED_CONTROL), 6)) {
BACK_ITEM(Draw_Control_Menu); BACK_ITEM(Draw_Control_Menu);
#if !BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL) #if !BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL)
EDIT_ITEM_F(ICON_LedControl, MSG_LEDS, onDrawChkbMenu, SetLedStatus, &leds.lights_on); EDIT_ITEM_F(ICON_LedControl, MSG_LEDS, onDrawChkbMenu, SetLedStatus, &leds.lights_on);
#endif #endif
#if HAS_COLOR_LEDS #if HAS_COLOR_LEDS
#if ENABLED(LED_COLOR_PRESETS)
MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_WHITE, onDrawMenuItem, leds.set_white);
MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_RED, onDrawMenuItem, leds.set_red);
MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_ORANGE, onDrawMenuItem, leds.set_orange);
MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_YELLOW, onDrawMenuItem, leds.set_yellow);
MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_GREEN, onDrawMenuItem, leds.set_green);
MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_BLUE, onDrawMenuItem, leds.set_blue);
MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_INDIGO, onDrawMenuItem, leds.set_indigo);
MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_VIOLET, onDrawMenuItem, leds.set_violet);
#else
EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_RED, onDrawPInt8Menu, SetLEDColorR, &leds.color.r); EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_RED, onDrawPInt8Menu, SetLEDColorR, &leds.color.r);
EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_GREEN, onDrawPInt8Menu, SetLEDColorG, &leds.color.g); EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_GREEN, onDrawPInt8Menu, SetLEDColorG, &leds.color.g);
EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_BLUE, onDrawPInt8Menu, SetLEDColorB, &leds.color.b); EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_BLUE, onDrawPInt8Menu, SetLEDColorB, &leds.color.b);
@ -3399,9 +3414,10 @@ void Draw_GetColor_Menu() {
EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_WHITE, onDrawPInt8Menu, SetLedColorW, &leds.color.w); EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_WHITE, onDrawPInt8Menu, SetLedColorW, &leds.color.w);
#endif #endif
#endif #endif
} #endif
UpdateMenu(LedControlMenu);
} }
UpdateMenu(LedControlMenu);
}
#endif #endif
void Draw_Tune_Menu() { void Draw_Tune_Menu() {
@ -3432,7 +3448,9 @@ void Draw_Tune_Menu() {
#if ENABLED(FWRETRACT) #if ENABLED(FWRETRACT)
MENU_ITEM_F(ICON_FWRetract, MSG_FWRETRACT, onDrawSubMenu, Draw_FWRetract_Menu); MENU_ITEM_F(ICON_FWRetract, MSG_FWRETRACT, onDrawSubMenu, Draw_FWRetract_Menu);
#endif #endif
MENU_ITEM_F(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, DWIN_LockScreen); #if HAS_LOCKSCREEN
MENU_ITEM_F(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, DWIN_LockScreen);
#endif
#if HAS_LCD_BRIGHTNESS #if HAS_LCD_BRIGHTNESS
EDIT_ITEM_F(ICON_Brightness, MSG_BRIGHTNESS, onDrawPInt8Menu, SetBrightness, &ui.brightness); EDIT_ITEM_F(ICON_Brightness, MSG_BRIGHTNESS, onDrawPInt8Menu, SetBrightness, &ui.brightness);
MENU_ITEM_F(ICON_Brightness, MSG_BRIGHTNESS_OFF, onDrawMenuItem, TurnOffBacklight); MENU_ITEM_F(ICON_Brightness, MSG_BRIGHTNESS_OFF, onDrawMenuItem, TurnOffBacklight);
@ -3750,15 +3768,14 @@ void Draw_Steps_Menu() {
#endif #endif
#if ENABLED(MESH_EDIT_MENU) #if ENABLED(MESH_EDIT_MENU)
uint8_t mesh_x = 0, mesh_y = 0;
#define Z_OFFSET_MIN -3 #define Z_OFFSET_MIN -3
#define Z_OFFSET_MAX 3 #define Z_OFFSET_MAX 3
void LiveEditMesh() { ((MenuItemPtrClass*)EditZValueItem)->value = &bedlevel.z_values[HMI_value.Select ? mesh_x : MenuData.Value][HMI_value.Select ? MenuData.Value : mesh_y]; EditZValueItem->redraw(); } void LiveEditMesh() { ((MenuItemPtrClass*)EditZValueItem)->value = &bedlevel.z_values[HMI_value.Select ? BedLevelTools.mesh_x : MenuData.Value][HMI_value.Select ? MenuData.Value : BedLevelTools.mesh_y]; EditZValueItem->redraw(); }
void ApplyEditMeshX() { mesh_x = MenuData.Value; } void ApplyEditMeshX() { BedLevelTools.mesh_x = MenuData.Value; }
void SetEditMeshX() { HMI_value.Select = 0; SetIntOnClick(0, GRID_MAX_POINTS_X - 1, mesh_x, ApplyEditMeshX, LiveEditMesh); } void SetEditMeshX() { HMI_value.Select = 0; SetIntOnClick(0, GRID_MAX_POINTS_X - 1, BedLevelTools.mesh_x, ApplyEditMeshX, LiveEditMesh); }
void ApplyEditMeshY() { mesh_y = MenuData.Value; } void ApplyEditMeshY() { BedLevelTools.mesh_y = MenuData.Value; }
void SetEditMeshY() { HMI_value.Select = 1; SetIntOnClick(0, GRID_MAX_POINTS_Y - 1, mesh_y, ApplyEditMeshY, LiveEditMesh); } void SetEditMeshY() { HMI_value.Select = 1; SetIntOnClick(0, GRID_MAX_POINTS_Y - 1, BedLevelTools.mesh_y, ApplyEditMeshY, LiveEditMesh); }
void SetEditZValue() { SetPFloatOnClick(Z_OFFSET_MIN, Z_OFFSET_MAX, 3); } void SetEditZValue() { SetPFloatOnClick(Z_OFFSET_MIN, Z_OFFSET_MAX, 3); }
#endif #endif
#endif #endif
@ -3772,14 +3789,14 @@ void Draw_Steps_Menu() {
onDrawIntMenu(menuitem, line, bedlevel.storage_slot); onDrawIntMenu(menuitem, line, bedlevel.storage_slot);
} }
void ApplyUBLTiltGrid() { ubl_tools.tilt_grid = MenuData.Value; } void ApplyUBLTiltGrid() { BedLevelTools.tilt_grid = MenuData.Value; }
void SetUBLTiltGrid() { SetIntOnClick(1, 3, ubl_tools.tilt_grid, ApplyUBLTiltGrid); } void SetUBLTiltGrid() { SetIntOnClick(1, 3, BedLevelTools.tilt_grid, ApplyUBLTiltGrid); }
void UBLTiltMesh() { void UBLTiltMesh() {
if (bedlevel.storage_slot < 0) bedlevel.storage_slot = 0; if (bedlevel.storage_slot < 0) bedlevel.storage_slot = 0;
char buf[15]; char buf[15];
if (ubl_tools.tilt_grid > 1) { if (BedLevelTools.tilt_grid > 1) {
sprintf_P(buf, PSTR("G28O\nG29 J%i"), ubl_tools.tilt_grid); sprintf_P(buf, PSTR("G28O\nG29 J%i"), BedLevelTools.tilt_grid);
gcode.process_subcommands_now(buf); gcode.process_subcommands_now(buf);
} }
else else
@ -3788,16 +3805,10 @@ void Draw_Steps_Menu() {
} }
void UBLSmartFillMesh() { void UBLSmartFillMesh() {
bedlevel.smart_fill_mesh(); LOOP_L_N(x, GRID_MAX_POINTS_Y) bedlevel.smart_fill_mesh();
LCD_MESSAGE(MSG_UBL_MESH_FILLED); LCD_MESSAGE(MSG_UBL_MESH_FILLED);
} }
bool UBLValidMesh() {
const bool valid = ubl_tools.validate();
if (!valid) bedlevel.invalidate();
return valid;
}
void UBLSaveMesh() { void UBLSaveMesh() {
if (bedlevel.storage_slot < 0) bedlevel.storage_slot = 0; if (bedlevel.storage_slot < 0) bedlevel.storage_slot = 0;
settings.store_mesh(bedlevel.storage_slot); settings.store_mesh(bedlevel.storage_slot);
@ -3808,14 +3819,6 @@ void Draw_Steps_Menu() {
void UBLLoadMesh() { void UBLLoadMesh() {
if (bedlevel.storage_slot < 0) bedlevel.storage_slot = 0; if (bedlevel.storage_slot < 0) bedlevel.storage_slot = 0;
settings.load_mesh(bedlevel.storage_slot); settings.load_mesh(bedlevel.storage_slot);
if (UBLValidMesh()) {
ui.status_printf(0, GET_TEXT_F(MSG_MESH_LOADED), bedlevel.storage_slot);
DONE_BUZZ(true);
}
else {
LCD_MESSAGE_F("Invalid Mesh Loaded");
DONE_BUZZ(false);
}
} }
#endif // AUTO_BED_LEVELING_UBL #endif // AUTO_BED_LEVELING_UBL
@ -3837,7 +3840,7 @@ void Draw_Steps_Menu() {
EDIT_ITEM_F(ICON_UBLActive, MSG_UBL_STORAGE_SLOT, onDrawUBLSlot, SetUBLSlot, &bedlevel.storage_slot); EDIT_ITEM_F(ICON_UBLActive, MSG_UBL_STORAGE_SLOT, onDrawUBLSlot, SetUBLSlot, &bedlevel.storage_slot);
MENU_ITEM_F(ICON_UBLActive, MSG_UBL_SAVE_MESH, onDrawMenuItem, UBLSaveMesh); MENU_ITEM_F(ICON_UBLActive, MSG_UBL_SAVE_MESH, onDrawMenuItem, UBLSaveMesh);
MENU_ITEM_F(ICON_UBLActive, MSG_UBL_LOAD_MESH, onDrawMenuItem, UBLLoadMesh); MENU_ITEM_F(ICON_UBLActive, MSG_UBL_LOAD_MESH, onDrawMenuItem, UBLLoadMesh);
EDIT_ITEM_F(ICON_UBLActive, MSG_UBL_TILTING_GRID, onDrawPInt8Menu, SetUBLTiltGrid, &ubl_tools.tilt_grid); EDIT_ITEM_F(ICON_UBLActive, MSG_UBL_TILTING_GRID, onDrawPInt8Menu, SetUBLTiltGrid, &BedLevelTools.tilt_grid);
MENU_ITEM_F(ICON_UBLActive, MSG_UBL_TILT_MESH, onDrawMenuItem, UBLTiltMesh); MENU_ITEM_F(ICON_UBLActive, MSG_UBL_TILT_MESH, onDrawMenuItem, UBLTiltMesh);
MENU_ITEM_F(ICON_UBLActive, MSG_UBL_SMART_FILLIN, onDrawMenuItem, UBLSmartFillMesh); MENU_ITEM_F(ICON_UBLActive, MSG_UBL_SMART_FILLIN, onDrawMenuItem, UBLSmartFillMesh);
#endif #endif
@ -3851,13 +3854,15 @@ void Draw_Steps_Menu() {
#if ENABLED(MESH_EDIT_MENU) #if ENABLED(MESH_EDIT_MENU)
void Draw_EditMesh_Menu() { void Draw_EditMesh_Menu() {
if (!leveling_is_valid()) { LCD_MESSAGE(MSG_UBL_MESH_INVALID); return; }
set_bed_leveling_enabled(false);
checkkey = Menu; checkkey = Menu;
if (SetMenu(EditMeshMenu, GET_TEXT_F(MSG_EDIT_MESH), 4)) { if (SetMenu(EditMeshMenu, GET_TEXT_F(MSG_EDIT_MESH), 4)) {
mesh_x = mesh_y = 0; BedLevelTools.mesh_x = BedLevelTools.mesh_y = 0;
BACK_ITEM(Draw_MeshSet_Menu); BACK_ITEM(Draw_MeshSet_Menu);
EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_X, onDrawPInt8Menu, SetEditMeshX, &mesh_x); EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_X, onDrawPInt8Menu, SetEditMeshX,&BedLevelTools.mesh_x);
EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_Y, onDrawPInt8Menu, SetEditMeshY, &mesh_y); EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_Y, onDrawPInt8Menu, SetEditMeshY,&BedLevelTools.mesh_y);
EditZValueItem = EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_EDIT_Z, onDrawPFloat3Menu, SetEditZValue, &bedlevel.z_values[mesh_x][mesh_y]); EditZValueItem = EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_EDIT_Z, onDrawPFloat3Menu, SetEditZValue, &bedlevel.z_values[BedLevelTools.mesh_x][BedLevelTools.mesh_y]);
} }
UpdateMenu(EditMeshMenu); UpdateMenu(EditMeshMenu);
} }

View File

@ -160,8 +160,7 @@ void Goto_PowerLossRecovery();
void Goto_ConfirmToPrint(); void Goto_ConfirmToPrint();
void DWIN_Draw_Dashboard(const bool with_update); // Status Area void DWIN_Draw_Dashboard(const bool with_update); // Status Area
void Draw_Main_Area(); // Redraw main area void Draw_Main_Area(); // Redraw main area
void DWIN_DrawStatusLine(const char *text); // Draw simple status text void DWIN_DrawStatusLine(); // Draw simple status text
void DWIN_DrawStatusLine(FSTR_P fstr);
void DWIN_RedrawDash(); // Redraw Dash and Status line void DWIN_RedrawDash(); // Redraw Dash and Status line
void DWIN_RedrawScreen(); // Redraw all screen elements void DWIN_RedrawScreen(); // Redraw all screen elements
void HMI_MainMenu(); // Main process screen void HMI_MainMenu(); // Main process screen
@ -210,9 +209,11 @@ void DWIN_RebootScreen();
#endif #endif
// Utility and extensions // Utility and extensions
void DWIN_LockScreen(); #if HAS_LOCKSCREEN
void DWIN_UnLockScreen(); void DWIN_LockScreen();
void HMI_LockScreen(); void DWIN_UnLockScreen();
void HMI_LockScreen();
#endif
#if HAS_MESH #if HAS_MESH
void DWIN_MeshViewer(); void DWIN_MeshViewer();
#endif #endif

View File

@ -28,23 +28,21 @@
* Date: 2022/02/28 * Date: 2022/02/28
*/ */
#define HAS_GCODE_PREVIEW 1
#define HAS_PIDPLOT 1
#define HAS_ESDIAG 1
#define HAS_LOCKSCREEN 1
//#define DEBUG_DWIN 1 //#define DEBUG_DWIN 1
//#define NEED_HEX_PRINT 1 //#define NEED_HEX_PRINT 1
#include "../../../inc/MarlinConfigPre.h" #include "../../../inc/MarlinConfigPre.h"
#include "../common/dwin_color.h"
#include <stddef.h> #include <stddef.h>
#define HAS_ESDIAG 1
#define HAS_PIDPLOT 1
#define HAS_GCODE_PREVIEW 1
#if defined(__STM32F1__) || defined(STM32F1) #if defined(__STM32F1__) || defined(STM32F1)
#define DASH_REDRAW 1 #define DASH_REDRAW 1
#endif #endif
#include "../common/dwin_color.h"
#if ENABLED(LED_CONTROL_MENU)
#include "../../../feature/leds/leds.h"
#endif
#define Def_Background_Color RGB( 1, 12, 8) #define Def_Background_Color RGB( 1, 12, 8)
#define Def_Cursor_color RGB(20, 49, 31) #define Def_Cursor_color RGB(20, 49, 31)
@ -65,9 +63,6 @@
#define Def_Indicator_Color Color_White #define Def_Indicator_Color Color_White
#define Def_Coordinate_Color Color_White #define Def_Coordinate_Color Color_White
#define Def_Button_Color RGB( 0, 23, 16) #define Def_Button_Color RGB( 0, 23, 16)
#define HAS_ESDIAG 1
#if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS)
#define Def_Leds_Color 0xFFFFFFFF #define Def_Leds_Color 0xFFFFFFFF
#endif #endif

View File

@ -23,8 +23,8 @@
/** /**
* DWIN Enhanced implementation for PRO UI * DWIN Enhanced implementation for PRO UI
* Author: Miguel A. Risco-Castillo (MRISCOC) * Author: Miguel A. Risco-Castillo (MRISCOC)
* Version: 3.17.1 * Version: 3.18.1
* Date: 2022/04/12 * Date: 2022/07/05
*/ */
#include "../../../inc/MarlinConfigPre.h" #include "../../../inc/MarlinConfigPre.h"
@ -44,7 +44,7 @@ uint16_t DWINUI::pencolor = Color_White;
uint16_t DWINUI::textcolor = Def_Text_Color; uint16_t DWINUI::textcolor = Def_Text_Color;
uint16_t DWINUI::backcolor = Def_Background_Color; uint16_t DWINUI::backcolor = Def_Background_Color;
uint16_t DWINUI::buttoncolor = Def_Button_Color; uint16_t DWINUI::buttoncolor = Def_Button_Color;
uint8_t DWINUI::font = font8x16; uint8_t DWINUI::fontid = font8x16;
FSTR_P const DWINUI::Author = F(STRING_CONFIG_H_AUTHOR); FSTR_P const DWINUI::Author = F(STRING_CONFIG_H_AUTHOR);
void (*DWINUI::onTitleDraw)(TitleClass* title) = nullptr; void (*DWINUI::onTitleDraw)(TitleClass* title) = nullptr;
@ -62,17 +62,15 @@ void DWINUI::init() {
textcolor = Def_Text_Color; textcolor = Def_Text_Color;
backcolor = Def_Background_Color; backcolor = Def_Background_Color;
buttoncolor = Def_Button_Color; buttoncolor = Def_Button_Color;
font = font8x16; fontid = font8x16;
} }
// Set text/number font // Set text/number font
void DWINUI::setFont(uint8_t cfont) { void DWINUI::setFont(fontid_t fid) { fontid = fid; }
font = cfont;
}
// Get font character width // Get font character width
uint8_t DWINUI::fontWidth(uint8_t cfont) { uint8_t DWINUI::fontWidth(fontid_t fid) {
switch (cfont) { switch (fid) {
case font6x12 : return 6; case font6x12 : return 6;
case font8x16 : return 8; case font8x16 : return 8;
case font10x20: return 10; case font10x20: return 10;
@ -88,8 +86,8 @@ uint8_t DWINUI::fontWidth(uint8_t cfont) {
} }
// Get font character height // Get font character height
uint8_t DWINUI::fontHeight(uint8_t cfont) { uint8_t DWINUI::fontHeight(fontid_t fid) {
switch (cfont) { switch (fid) {
case font6x12 : return 12; case font6x12 : return 12;
case font8x16 : return 16; case font8x16 : return 16;
case font10x20: return 20; case font10x20: return 20;
@ -105,14 +103,10 @@ uint8_t DWINUI::fontHeight(uint8_t cfont) {
} }
// Get screen x coordinates from text column // Get screen x coordinates from text column
uint16_t DWINUI::ColToX(uint8_t col) { uint16_t DWINUI::ColToX(uint8_t col) { return col * fontWidth(fontid); }
return col * fontWidth(font);
}
// Get screen y coordinates from text row // Get screen y coordinates from text row
uint16_t DWINUI::RowToY(uint8_t row) { uint16_t DWINUI::RowToY(uint8_t row) { return row * fontHeight(fontid); }
return row * fontHeight(font);
}
// Set text/number color // Set text/number color
void DWINUI::SetColors(uint16_t fgcolor, uint16_t bgcolor, uint16_t alcolor) { void DWINUI::SetColors(uint16_t fgcolor, uint16_t bgcolor, uint16_t alcolor) {
@ -152,9 +146,9 @@ void DWINUI::MoveBy(xy_int_t point) {
} }
// Draw a Centered string using arbitrary x1 and x2 margins // 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) { void DWINUI::Draw_CenteredString(bool bShow, fontid_t fid, 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; const uint16_t x = _MAX(0U, x2 + x1 - strlen_P(string) * fontWidth(fid)) / 2 - 1;
DWIN_Draw_String(bShow, size, color, bColor, x, y, string); DWIN_Draw_String(bShow, fid, color, bColor, x, y, string);
} }
// Draw a char // Draw a char
@ -164,13 +158,13 @@ void DWINUI::Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint1
// c: ASCII code of char // c: ASCII code of char
void DWINUI::Draw_Char(uint16_t color, uint16_t x, uint16_t y, const char c) { void DWINUI::Draw_Char(uint16_t color, uint16_t x, uint16_t y, const char c) {
const char string[2] = { c, 0}; const char string[2] = { c, 0};
DWIN_Draw_String(false, font, color, backcolor, x, y, string, 1); DWIN_Draw_String(false, fontid, color, backcolor, x, y, string, 1);
} }
// Draw a char at cursor position and increment cursor // Draw a char at cursor position and increment cursor
void DWINUI::Draw_Char(uint16_t color, const char c) { void DWINUI::Draw_Char(uint16_t color, const char c) {
Draw_Char(color, cursor.x, cursor.y, c); Draw_Char(color, cursor.x, cursor.y, c);
MoveBy(fontWidth(font), 0); MoveBy(fontWidth(fontid), 0);
} }
// Draw a string at cursor position // Draw a string at cursor position
@ -178,49 +172,49 @@ void DWINUI::Draw_Char(uint16_t color, const char c) {
// *string: The string // *string: The string
// rlimit: For draw less chars than string length use rlimit // rlimit: For draw less chars than string length use rlimit
void DWINUI::Draw_String(const char * const string, uint16_t 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); DWIN_Draw_String(false, fontid, textcolor, backcolor, cursor.x, cursor.y, string, rlimit);
MoveBy(strlen(string) * fontWidth(font), 0); MoveBy(strlen(string) * fontWidth(fontid), 0);
} }
void DWINUI::Draw_String(uint16_t color, const char * const string, uint16_t rlimit) { 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); DWIN_Draw_String(false, fontid, color, backcolor, cursor.x, cursor.y, string, rlimit);
MoveBy(strlen(string) * fontWidth(font), 0); MoveBy(strlen(string) * fontWidth(fontid), 0);
} }
// Draw a numeric integer value // Draw a numeric integer value
// bShow: true=display background color; false=don't display background color // bShow: true=display background color; false=don't display background color
// signedMode: 1=signed; 0=unsigned // signedMode: 1=signed; 0=unsigned
// size: Font size // fid: Font ID
// color: Character color // color: Character color
// bColor: Background color // bColor: Background color
// iNum: Number of digits // iNum: Number of digits
// x/y: Upper-left coordinate // x/y: Upper-left coordinate
// value: Integer value // 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) { void DWINUI::Draw_Int(uint8_t bShow, bool signedMode, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value) {
char nstr[10]; char nstr[10];
sprintf_P(nstr, PSTR("%*li"), (signedMode ? iNum + 1 : iNum), value); sprintf_P(nstr, PSTR("%*li"), (signedMode ? iNum + 1 : iNum), value);
DWIN_Draw_String(bShow, size, color, bColor, x, y, nstr); DWIN_Draw_String(bShow, fid, color, bColor, x, y, nstr);
} }
// Draw a numeric float value // Draw a numeric float value
// bShow: true=display background color; false=don't display background color // bShow: true=display background color; false=don't display background color
// signedMode: 1=signed; 0=unsigned // signedMode: 1=signed; 0=unsigned
// size: Font size // fid: Font ID
// color: Character color // color: Character color
// bColor: Background color // bColor: Background color
// iNum: Number of digits // iNum: Number of digits
// fNum: Number of decimal digits // fNum: Number of decimal digits
// x/y: Upper-left coordinate // x/y: Upper-left coordinate
// value: float value // 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) { void DWINUI::Draw_Float(uint8_t bShow, bool signedMode, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
char nstr[10]; char nstr[10];
DWIN_Draw_String(bShow, size, color, bColor, x, y, dtostrf(value, iNum + (signedMode ? 2:1) + fNum, fNum, nstr)); DWIN_Draw_String(bShow, fid, color, bColor, x, y, dtostrf(value, iNum + (signedMode ? 2:1) + fNum, fNum, nstr));
} }
// ------------------------- Buttons ------------------------------// // ------------------------- 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) { 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); DWIN_Draw_Rectangle(1, bcolor, x1, y1, x2, y2);
Draw_CenteredString(0, font, color, bcolor, x1, x2, (y2 + y1 - fontHeight())/2, caption); Draw_CenteredString(0, fontid, color, bcolor, x1, x2, (y2 + y1 - fontHeight())/2, caption);
} }
void DWINUI::Draw_Button(uint8_t id, uint16_t x, uint16_t y) { void DWINUI::Draw_Button(uint8_t id, uint16_t x, uint16_t y) {

View File

@ -24,8 +24,8 @@
/** /**
* DWIN Enhanced implementation for PRO UI * DWIN Enhanced implementation for PRO UI
* Author: Miguel A. Risco-Castillo (MRISCOC) * Author: Miguel A. Risco-Castillo (MRISCOC)
* Version: 3.17.1 * Version: 3.18.1
* Date: 2022/04/12 * Date: 2022/07/05
*/ */
#include "dwin_lcd.h" #include "dwin_lcd.h"
@ -39,6 +39,7 @@
#define ICON_BedSizeY ICON_PrintSize #define ICON_BedSizeY ICON_PrintSize
#define ICON_BedTramming ICON_SetHome #define ICON_BedTramming ICON_SetHome
#define ICON_Binary ICON_Contact #define ICON_Binary ICON_Contact
#define ICON_BltouchReset ICON_StockConfiguration
#define ICON_Brightness ICON_Motion #define ICON_Brightness ICON_Motion
#define ICON_Cancel ICON_StockConfiguration #define ICON_Cancel ICON_StockConfiguration
#define ICON_CustomPreheat ICON_SetEndTemp #define ICON_CustomPreheat ICON_SetEndTemp
@ -145,7 +146,7 @@
#define DWIN_FONT_HEAD font10x20 #define DWIN_FONT_HEAD font10x20
#define DWIN_FONT_ALERT font10x20 #define DWIN_FONT_ALERT font10x20
#define STATUS_Y 354 #define STATUS_Y 354
#define LCD_WIDTH (DWIN_WIDTH / 8) // only if the default font is font8x16 #define LCD_WIDTH (DWIN_WIDTH / 8) // only if the default fontid is font8x16
// Minimum unit (0.1) : multiple (10) // Minimum unit (0.1) : multiple (10)
#define UNITFDIGITS 1 #define UNITFDIGITS 1
@ -156,7 +157,7 @@ constexpr uint8_t TITLE_HEIGHT = 30, // Title bar heig
TROWS = (STATUS_Y - TITLE_HEIGHT) / MLINE, // Total rows TROWS = (STATUS_Y - TITLE_HEIGHT) / MLINE, // Total rows
MROWS = TROWS - 1, // Other-than-Back MROWS = TROWS - 1, // Other-than-Back
ICOX = 26, // Menu item icon X position ICOX = 26, // Menu item icon X position
LBLX = 60, // Menu item label X position LBLX = 55, // Menu item label X position
VALX = 210, // Menu item value X position VALX = 210, // Menu item value X position
MENU_CHR_W = 8, MENU_CHR_H = 16, // Menu font 8x16 MENU_CHR_W = 8, MENU_CHR_H = 16, // Menu font 8x16
STAT_CHR_W = 10; STAT_CHR_W = 10;
@ -196,7 +197,7 @@ namespace DWINUI {
extern uint16_t textcolor; extern uint16_t textcolor;
extern uint16_t backcolor; extern uint16_t backcolor;
extern uint16_t buttoncolor; extern uint16_t buttoncolor;
extern uint8_t font; extern fontid_t fontid;
extern FSTR_P const Author; extern FSTR_P const Author;
extern void (*onTitleDraw)(TitleClass* title); extern void (*onTitleDraw)(TitleClass* title);
@ -205,15 +206,15 @@ namespace DWINUI {
void init(); void init();
// Set text/number font // Set text/number font
void setFont(uint8_t cfont); void setFont(fontid_t cfont);
// Get font character width // Get font character width
uint8_t fontWidth(uint8_t cfont); uint8_t fontWidth(fontid_t cfont);
inline uint8_t fontWidth() { return fontWidth(font); }; inline uint8_t fontWidth() { return fontWidth(fontid); };
// Get font character height // Get font character height
uint8_t fontHeight(uint8_t cfont); uint8_t fontHeight(fontid_t cfont);
inline uint8_t fontHeight() { return fontHeight(font); }; inline uint8_t fontHeight() { return fontHeight(fontid); };
// Get screen x coordinates from text column // Get screen x coordinates from text column
uint16_t ColToX(uint8_t col); uint16_t ColToX(uint8_t col);
@ -278,108 +279,108 @@ namespace DWINUI {
// Draw a numeric integer value // Draw a numeric integer value
// bShow: true=display background color; false=don't display background color // bShow: true=display background color; false=don't display background color
// signedMode: 1=signed; 0=unsigned // signedMode: 1=signed; 0=unsigned
// size: Font size // fid: Font ID
// color: Character color // color: Character color
// bColor: Background color // bColor: Background color
// iNum: Number of digits // iNum: Number of digits
// x/y: Upper-left coordinate // x/y: Upper-left coordinate
// value: Integer value // 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); void Draw_Int(uint8_t bShow, bool signedMode, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value);
// Draw a positive integer // 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) { inline void Draw_Int(uint8_t bShow, fontid_t fid, 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); Draw_Int(bShow, 0, fid, color, bColor, iNum, x, y, value);
} }
inline void Draw_Int(uint8_t iNum, long value) { inline void Draw_Int(uint8_t iNum, long value) {
Draw_Int(false, 0, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value); Draw_Int(false, 0, fontid, textcolor, backcolor, iNum, cursor.x, cursor.y, value);
MoveBy(iNum * fontWidth(font), 0); MoveBy(iNum * fontWidth(fontid), 0);
} }
inline void Draw_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) { 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); Draw_Int(false, 0, fontid, textcolor, backcolor, iNum, x, y, value);
} }
inline void Draw_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long 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); Draw_Int(false, 0, fontid, 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) { 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); Draw_Int(true, 0, fontid, 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) { inline void Draw_Int(fontid_t fid, 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_Int(true, 0, fid, color, bColor, iNum, x, y, value);
} }
// Draw a signed integer // 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) { inline void Draw_Signed_Int(uint8_t bShow, fontid_t fid, 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); Draw_Int(bShow, 1, fid, color, bColor, iNum, x, y, value);
} }
inline void Draw_Signed_Int(uint8_t iNum, long value) { inline void Draw_Signed_Int(uint8_t iNum, long value) {
Draw_Int(false, 1, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value); Draw_Int(false, 1, fontid, textcolor, backcolor, iNum, cursor.x, cursor.y, value);
MoveBy(iNum * fontWidth(font), 0); MoveBy(iNum * fontWidth(fontid), 0);
} }
inline void Draw_Signed_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) { 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); Draw_Int(false, 1, fontid, 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) { 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); Draw_Int(false, 1, fontid, 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) { 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); Draw_Int(true, 1, fontid, 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) { inline void Draw_Signed_Int(fontid_t fid, 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_Int(true, 1, fid, color, bColor, iNum, x, y, value);
} }
// Draw a numeric float value // Draw a numeric float value
// bShow: true=display background color; false=don't display background color // bShow: true=display background color; false=don't display background color
// signedMode: 1=signed; 0=unsigned // signedMode: 1=signed; 0=unsigned
// size: Font size // fid: Font ID
// color: Character color // color: Character color
// bColor: Background color // bColor: Background color
// iNum: Number of digits // iNum: Number of digits
// fNum: Number of decimal digits // fNum: Number of decimal digits
// x/y: Upper-left coordinate // x/y: Upper-left coordinate
// value: float value // 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); void Draw_Float(uint8_t bShow, bool signedMode, fontid_t fid, 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 // 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) { inline void Draw_Float(uint8_t bShow, fontid_t fid, 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); Draw_Float(bShow, 0, fid, color, bColor, iNum, fNum, x, y, value);
} }
inline void Draw_Float(uint8_t iNum, uint8_t fNum, float 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); Draw_Float(false, 0, fontid, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value);
MoveBy((iNum + fNum + 1) * fontWidth(font), 0); MoveBy((iNum + fNum + 1) * fontWidth(fontid), 0);
} }
inline void Draw_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { 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); Draw_Float(false, 0, fontid, 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) { inline void Draw_Float(fontid_t fid, 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); Draw_Float(false, 0, fid, 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) { 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); Draw_Float(true, 0, fontid, 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) { inline void Draw_Float(fontid_t fid, 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_Float(true, 0, fid, color, bColor, iNum, fNum, x, y, value);
} }
// Draw a signed floating point number // 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) { inline void Draw_Signed_Float(uint8_t bShow, fontid_t fid, 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); Draw_Float(bShow, 1, fid, color, bColor, iNum, fNum, x, y, value);
} }
inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, float 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); Draw_Float(false, 1, fontid, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value);
MoveBy((iNum + fNum + 1) * fontWidth(font), 0); MoveBy((iNum + fNum + 1) * fontWidth(fontid), 0);
} }
inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { 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); Draw_Float(false, 1, fontid, 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) { inline void Draw_Signed_Float(fontid_t fid, 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); Draw_Float(false, 1, fid, 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) { 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); Draw_Float(true, 1, fontid, 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) { inline void Draw_Signed_Float(fontid_t fid, 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_Float(true, 1, fid, color, bColor, iNum, fNum, x, y, value);
} }
// Draw a char // Draw a char
@ -407,70 +408,70 @@ namespace DWINUI {
} }
// Draw a string // Draw a string
// size: Font size // fid: Font ID
// color: Character color // color: Character color
// bColor: Background color // bColor: Background color
// x/y: Upper-left coordinate of the string // x/y: Upper-left coordinate of the string
// *string: The string // *string: The string
inline void Draw_String(uint16_t x, uint16_t y, const char * const 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); DWIN_Draw_String(false, fontid, textcolor, backcolor, x, y, string);
} }
inline void Draw_String(uint16_t x, uint16_t y, FSTR_P title) { inline void Draw_String(uint16_t x, uint16_t y, FSTR_P title) {
DWIN_Draw_String(false, font, textcolor, backcolor, x, y, FTOP(title)); DWIN_Draw_String(false, fontid, textcolor, backcolor, x, y, FTOP(title));
} }
inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, const char * const string) { 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); DWIN_Draw_String(false, fontid, color, backcolor, x, y, string);
} }
inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, FSTR_P title) { 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); DWIN_Draw_String(false, fontid, 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) { 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); DWIN_Draw_String(true, fontid, color, bgcolor, x, y, string);
} }
inline void Draw_String(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) { 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); DWIN_Draw_String(true, fontid, 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) { inline void Draw_String(fontid_t fid, 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); DWIN_Draw_String(true, fid, 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) { inline void Draw_String(fontid_t fid, 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); DWIN_Draw_String(true, fid, color, bgcolor, x, y, title);
} }
// Draw a centered string using DWIN_WIDTH // Draw a centered string using DWIN_WIDTH
// bShow: true=display background color; false=don't display background color // bShow: true=display background color; false=don't display background color
// size: Font size // fid: Font ID
// color: Character color // color: Character color
// bColor: Background color // bColor: Background color
// y: Upper coordinate of the string // y: Upper coordinate of the string
// *string: 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); void Draw_CenteredString(bool bShow, fontid_t fid, 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) { inline void Draw_CenteredString(bool bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint16_t y, const char * const string) {
Draw_CenteredString(bShow, size, color, bColor, 0, DWIN_WIDTH, y, string); Draw_CenteredString(bShow, fid, 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) { inline void Draw_CenteredString(bool bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint16_t y, FSTR_P string) {
Draw_CenteredString(bShow, size, color, bColor, y, FTOP(string)); Draw_CenteredString(bShow, fid, color, bColor, y, FTOP(string));
} }
inline void Draw_CenteredString(uint16_t color, uint16_t bcolor, uint16_t y, const char * const 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); Draw_CenteredString(true, fontid, color, bcolor, y, string);
} }
inline void Draw_CenteredString(uint8_t size, uint16_t color, uint16_t y, const char * const string) { inline void Draw_CenteredString(fontid_t fid, uint16_t color, uint16_t y, const char * const string) {
Draw_CenteredString(false, size, color, backcolor, y, string); Draw_CenteredString(false, fid, color, backcolor, y, string);
} }
inline void Draw_CenteredString(uint8_t size, uint16_t color, uint16_t y, FSTR_P title) { inline void Draw_CenteredString(fontid_t fid, uint16_t color, uint16_t y, FSTR_P title) {
Draw_CenteredString(false, size, color, backcolor, y, title); Draw_CenteredString(false, fid, color, backcolor, y, title);
} }
inline void Draw_CenteredString(uint16_t color, uint16_t y, const char * const string) { inline void Draw_CenteredString(uint16_t color, uint16_t y, const char * const string) {
Draw_CenteredString(false, font, color, backcolor, y, string); Draw_CenteredString(false, fontid, color, backcolor, y, string);
} }
inline void Draw_CenteredString(uint16_t color, uint16_t y, FSTR_P title) { inline void Draw_CenteredString(uint16_t color, uint16_t y, FSTR_P title) {
Draw_CenteredString(false, font, color, backcolor, y, title); Draw_CenteredString(false, fontid, color, backcolor, y, title);
} }
inline void Draw_CenteredString(uint16_t y, const char * const string) { inline void Draw_CenteredString(uint16_t y, const char * const string) {
Draw_CenteredString(false, font, textcolor, backcolor, y, string); Draw_CenteredString(false, fontid, textcolor, backcolor, y, string);
} }
inline void Draw_CenteredString(uint16_t y, FSTR_P title) { inline void Draw_CenteredString(uint16_t y, FSTR_P title) {
Draw_CenteredString(false, font, textcolor, backcolor, y, title); Draw_CenteredString(false, fontid, textcolor, backcolor, y, title);
} }
// Draw a box // Draw a box

View File

@ -31,8 +31,10 @@
#if ENABLED(DWIN_LCD_PROUI) #if ENABLED(DWIN_LCD_PROUI)
#include "../../../core/types.h" #include "dwin_defines.h"
#include "dwin_lcd.h"
#if HAS_LOCKSCREEN
#include "dwinui.h" #include "dwinui.h"
#include "dwin.h" #include "dwin.h"
#include "lockscreen.h" #include "lockscreen.h"
@ -73,4 +75,6 @@ void LockScreenClass::onEncoder(EncoderState encoder_diffState) {
DWIN_UpdateLCD(); DWIN_UpdateLCD();
} }
#endif // HAS_LOCKSCREEN
#endif // DWIN_LCD_PROUI #endif // DWIN_LCD_PROUI

View File

@ -23,8 +23,8 @@
/** /**
* Menu functions for ProUI * Menu functions for ProUI
* Author: Miguel A. Risco-Castillo * Author: Miguel A. Risco-Castillo
* Version: 1.4.1 * Version: 1.5.1
* Date: 2022/04/14 * Date: 2022/05/23
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as * it under the terms of the GNU Lesser General Public License as
@ -166,6 +166,17 @@ void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line) {
onDrawChkbMenu(menuitem, line, val); onDrawChkbMenu(menuitem, line, val);
} }
void DrawItemEdit() {
switch (checkkey) {
case SetIntNoDraw: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break;
case SetInt:
case SetPInt: DWINUI::Draw_Signed_Int(HMI_data.Text_Color, HMI_data.Selected_Color, 4 , VALX, MBASE(CurrentMenu->line()) - 1, MenuData.Value); break;
case SetFloat:
case SetPFloat: DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, MenuData.dp, VALX - MenuData.dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), MenuData.Value / POW(10, MenuData.dp)); break;
default: break;
}
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// On click functions // On click functions
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -307,7 +318,7 @@ int8_t HMI_GetInt(const int32_t lo, const int32_t hi) {
return 2; return 2;
} }
LIMIT(MenuData.Value, lo, hi); LIMIT(MenuData.Value, lo, hi);
DWINUI::Draw_Signed_Int(HMI_data.Text_Color, HMI_data.Selected_Color, 4 , VALX, MBASE(CurrentMenu->line()) - 1, MenuData.Value); DrawItemEdit();
return 1; return 1;
} }
return 0; return 0;
@ -361,7 +372,7 @@ int8_t HMI_GetFloat(uint8_t dp, int32_t lo, int32_t hi) {
return 2; return 2;
} }
LIMIT(MenuData.Value, lo, hi); LIMIT(MenuData.Value, lo, hi);
DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), MenuData.Value / POW(10, dp)); DrawItemEdit();
return 1; return 1;
} }
return 0; return 0;
@ -469,7 +480,7 @@ void MenuItemClass::SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2,
} }
void MenuItemClass::draw(int8_t line) { void MenuItemClass::draw(int8_t line) {
if (line < 0 || line >= TROWS) return; if (!WITHIN(line, 0, TROWS - 1)) return;
if (onDraw != nullptr) (*onDraw)(this, line); if (onDraw != nullptr) (*onDraw)(this, line);
}; };
@ -547,6 +558,9 @@ void UpdateMenu(MenuClass* &menu) {
menu->draw(); menu->draw();
} }
void ReDrawMenu() { if (CurrentMenu && checkkey==Menu) CurrentMenu->draw(); } void ReDrawMenu(const bool force/*=false*/) {
if (CurrentMenu && (force || checkkey == Menu)) CurrentMenu->draw();
if (force) DrawItemEdit();
}
#endif // DWIN_LCD_PROUI #endif // DWIN_LCD_PROUI

View File

@ -23,8 +23,8 @@
/** /**
* Menu functions for ProUI * Menu functions for ProUI
* Author: Miguel A. Risco-Castillo * Author: Miguel A. Risco-Castillo
* Version: 1.4.1 * Version: 1.5.1
* Date: 2022/04/14 * Date: 2022/05/23
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as * it under the terms of the GNU Lesser General Public License as
@ -168,7 +168,7 @@ bool SetMenu(MenuClass* &menu, FSTR_P title, int8_t totalitems);
void UpdateMenu(MenuClass* &menu); void UpdateMenu(MenuClass* &menu);
//Redraw the current Menu if it is valid //Redraw the current Menu if it is valid
void ReDrawMenu(); void ReDrawMenu(const bool force=false);
// Clear MenuItems array and free MenuItems elements // Clear MenuItems array and free MenuItems elements
void MenuItemsClear(); void MenuItemsClear();

View File

@ -31,8 +31,6 @@
#if BOTH(DWIN_LCD_PROUI, HAS_MESH) #if BOTH(DWIN_LCD_PROUI, HAS_MESH)
#include "meshviewer.h"
#include "../../../core/types.h" #include "../../../core/types.h"
#include "../../marlinui.h" #include "../../marlinui.h"
#include "dwin_lcd.h" #include "dwin_lcd.h"
@ -40,9 +38,10 @@
#include "dwin.h" #include "dwin.h"
#include "dwin_popup.h" #include "dwin_popup.h"
#include "../../../feature/bedlevel/bedlevel.h" #include "../../../feature/bedlevel/bedlevel.h"
#include "meshviewer.h"
#if ENABLED(AUTO_BED_LEVELING_UBL) #if ENABLED(AUTO_BED_LEVELING_UBL)
#include "ubl_tools.h" #include "bedlevel_tools.h"
#endif #endif
MeshViewerClass MeshViewer; MeshViewerClass MeshViewer;
@ -112,10 +111,10 @@ void MeshViewerClass::DrawMesh(bed_mesh_t zval, const uint8_t sizex, const uint8
void MeshViewerClass::Draw(bool withsave /*= false*/) { void MeshViewerClass::Draw(bool withsave /*= false*/) {
Title.ShowCaption(GET_TEXT_F(MSG_MESH_VIEWER)); Title.ShowCaption(GET_TEXT_F(MSG_MESH_VIEWER));
#if ENABLED(USE_UBL_VIEWER) #if USE_UBL_VIEWER
DWINUI::ClearMainArea(); DWINUI::ClearMainArea();
ubl_tools.viewer_print_value = true; BedLevelTools.viewer_print_value = true;
ubl_tools.Draw_Bed_Mesh(-1, 1, 8, 10 + TITLE_HEIGHT); BedLevelTools.Draw_Bed_Mesh(-1, 1, 8, 10 + TITLE_HEIGHT);
#else #else
DrawMesh(bedlevel.z_values, GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y); DrawMesh(bedlevel.z_values, GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y);
#endif #endif
@ -127,8 +126,8 @@ void MeshViewerClass::Draw(bool withsave /*= false*/) {
else else
DWINUI::Draw_Button(BTN_Continue, 86, 305); DWINUI::Draw_Button(BTN_Continue, 86, 305);
#if ENABLED(USE_UBL_VIEWER) #if USE_UBL_VIEWER
ubl_tools.Set_Mesh_Viewer_Status(); BedLevelTools.Set_Mesh_Viewer_Status();
#else #else
char str_1[6], str_2[6] = ""; char str_1[6], str_2[6] = "";
ui.status_printf(0, F("Mesh minZ: %s, maxZ: %s"), ui.status_printf(0, F("Mesh minZ: %s, maxZ: %s"),

View File

@ -21,9 +21,6 @@
*/ */
#pragma once #pragma once
#include "../../../core/types.h"
#include "../../../feature/bedlevel/bedlevel.h"
/** /**
* Mesh Viewer for PRO UI * Mesh Viewer for PRO UI
* Author: Miguel A. Risco-Castillo (MRISCOC) * Author: Miguel A. Risco-Castillo (MRISCOC)

View File

@ -46,13 +46,16 @@
#ifdef DWIN_LCD_PROUI #ifdef DWIN_LCD_PROUI
#include "dwin_defines.h"
#if HAS_PIDPLOT
#include "plot.h" #include "plot.h"
#include "../../../core/types.h" #include "../../../core/types.h"
#include "../../marlinui.h" #include "../../marlinui.h"
#include "dwin_lcd.h" #include "dwin_lcd.h"
#include "dwinui.h" #include "dwinui.h"
#include "dwin_popup.h"
#include "dwin.h" #include "dwin.h"
#define Plot_Bg_Color RGB( 1, 12, 8) #define Plot_Bg_Color RGB( 1, 12, 8)
@ -71,7 +74,7 @@ void PlotClass::Draw(const frame_rect_t frame, const float max, const float ref)
y2 = frame.y + frame.h - 1; y2 = frame.y + frame.h - 1;
r = round((y2) - ref * scale); r = round((y2) - ref * scale);
DWINUI::Draw_Box(1, Plot_Bg_Color, frame); 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); 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)); DWINUI::Draw_Box(0, Color_White, DWINUI::ExtendFrame(frame, 1));
DWIN_Draw_HLine(Color_Red, frame.x, r, frame.w); DWIN_Draw_HLine(Color_Red, frame.x, r, frame.w);
} }
@ -91,4 +94,6 @@ void PlotClass::Update(const float value) {
grphpoints++; grphpoints++;
} }
#endif // HAS_PIDPLOT
#endif // DWIN_LCD_PROUI #endif // DWIN_LCD_PROUI

View File

@ -254,6 +254,7 @@ namespace Language_en {
LSTR MSG_UBL_SMART_FILLIN = _UxGT("Smart Fill-in"); LSTR MSG_UBL_SMART_FILLIN = _UxGT("Smart Fill-in");
LSTR MSG_UBL_FILLIN_MESH = _UxGT("Fill-in Mesh"); LSTR MSG_UBL_FILLIN_MESH = _UxGT("Fill-in Mesh");
LSTR MSG_UBL_MESH_FILLED = _UxGT("Missing Points Filled"); LSTR MSG_UBL_MESH_FILLED = _UxGT("Missing Points Filled");
LSTR MSG_UBL_MESH_INVALID = _UxGT("Invalid Mesh");
LSTR MSG_UBL_INVALIDATE_ALL = _UxGT("Invalidate All"); LSTR MSG_UBL_INVALIDATE_ALL = _UxGT("Invalidate All");
LSTR MSG_UBL_INVALIDATE_CLOSEST = _UxGT("Invalidate Closest"); LSTR MSG_UBL_INVALIDATE_CLOSEST = _UxGT("Invalidate Closest");
LSTR MSG_UBL_FINE_TUNE_ALL = _UxGT("Fine Tune All"); LSTR MSG_UBL_FINE_TUNE_ALL = _UxGT("Fine Tune All");

View File

@ -188,7 +188,7 @@ typedef struct {
* The "nominal" values are as-specified by G-code, and * The "nominal" values are as-specified by G-code, and
* may never actually be reached due to acceleration limits. * may never actually be reached due to acceleration limits.
*/ */
typedef struct block_t { typedef struct PlannerBlock {
volatile block_flags_t flag; // Block flags volatile block_flags_t flag; // Block flags

View File

@ -76,6 +76,7 @@
#include "../lcd/extui/ui_api.h" #include "../lcd/extui/ui_api.h"
#elif ENABLED(DWIN_LCD_PROUI) #elif ENABLED(DWIN_LCD_PROUI)
#include "../lcd/e3v2/proui/dwin.h" #include "../lcd/e3v2/proui/dwin.h"
#include "../lcd/e3v2/proui/bedlevel_tools.h"
#endif #endif
#if ENABLED(HOST_PROMPT_SUPPORT) #if ENABLED(HOST_PROMPT_SUPPORT)
@ -2756,7 +2757,7 @@ void MarlinSettings::postprocess() {
#endif #endif
persistentStore.access_start(); persistentStore.access_start();
const uint16_t status = persistentStore.read_data(pos, dest, MESH_STORE_SIZE, &crc); uint16_t status = persistentStore.read_data(pos, dest, MESH_STORE_SIZE, &crc);
persistentStore.access_finish(); persistentStore.access_finish();
#if ENABLED(OPTIMIZED_MESH_STORAGE) #if ENABLED(OPTIMIZED_MESH_STORAGE)
@ -2769,6 +2770,16 @@ void MarlinSettings::postprocess() {
bedlevel.set_mesh_from_store(z_mesh_store, bedlevel.z_values); bedlevel.set_mesh_from_store(z_mesh_store, bedlevel.z_values);
#endif #endif
#if ENABLED(DWIN_LCD_PROUI)
status = !BedLevelTools.meshvalidate();
if (status) {
bedlevel.invalidate();
LCD_MESSAGE(MSG_UBL_MESH_INVALID);
}
else
ui.status_printf(0, GET_TEXT_F(MSG_MESH_LOADED), bedlevel.storage_slot);
#endif
if (status) SERIAL_ECHOLNPGM("?Unable to load mesh data."); if (status) SERIAL_ECHOLNPGM("?Unable to load mesh data.");
else DEBUG_ECHOLNPGM("Mesh loaded from slot ", slot); else DEBUG_ECHOLNPGM("Mesh loaded from slot ", slot);