From 5ac6cf314e73bf2c3216c7aeb5a8a2b957721239 Mon Sep 17 00:00:00 2001 From: classicrocker883 Date: Fri, 12 Jan 2024 12:33:53 -0500 Subject: [PATCH] Update - print/remain time, meshviewer/bedleveltools --- Marlin/src/lcd/e3v2/common/dwin_api.cpp | 2 +- Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp | 42 +++++-------- Marlin/src/lcd/e3v2/proui/bedlevel_tools.h | 8 +-- Marlin/src/lcd/e3v2/proui/dwin.cpp | 65 +++++++++----------- Marlin/src/lcd/e3v2/proui/endstop_diag.cpp | 4 +- Marlin/src/lcd/e3v2/proui/meshviewer.cpp | 16 +++-- Marlin/src/lcd/e3v2/proui/meshviewer.h | 1 + 7 files changed, 59 insertions(+), 79 deletions(-) diff --git a/Marlin/src/lcd/e3v2/common/dwin_api.cpp b/Marlin/src/lcd/e3v2/common/dwin_api.cpp index bd21522e72..4973387650 100644 --- a/Marlin/src/lcd/e3v2/common/dwin_api.cpp +++ b/Marlin/src/lcd/e3v2/common/dwin_api.cpp @@ -228,7 +228,7 @@ void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, DWIN_Byte(i, 0x11); // Bit 7: widthAdjust // Bit 6: bShow - // Bit 5-4: Unused (0) + // Bit 5-4: unused (0) // Bit 3-0: size DWIN_Byte(i, (widthAdjust * 0x80) | (bShow * 0x40) | size); DWIN_Word(i, color); diff --git a/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp index 4ad1708f84..a4168bbd48 100644 --- a/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp +++ b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp @@ -40,9 +40,6 @@ BedLevelToolsClass bedLevelTools; -#if USE_GRID_MESHVIEWER - bool BedLevelToolsClass::view_mesh = false; -#endif bool BedLevelToolsClass::goto_mesh_value = false; uint8_t BedLevelToolsClass::mesh_x = 0; uint8_t BedLevelToolsClass::mesh_y = 0; @@ -52,14 +49,6 @@ bool drawing_mesh = false; #if ENABLED(AUTO_BED_LEVELING_UBL) - void BedLevelToolsClass::manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y, bool undefined/*=false*/) { - MString cmd; - cmd.set(F("M421 I"), mesh_x, 'J', mesh_y, 'Z', p_float_t(current_position.z, 3)); - if (undefined) cmd += F(" N"); - gcode.process_subcommands_now(cmd); - planner.synchronize(); - } - bool BedLevelToolsClass::create_plane_from_mesh() { struct linear_fit_data lsf_results; incremental_LSF_reset(&lsf_results); @@ -99,17 +88,18 @@ bool drawing_mesh = false; return false; } -#else - - void BedLevelToolsClass::manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y) { - gcode.process_subcommands_now( - TS(F("G29 I"), mesh_x, 'J', mesh_y, 'Z', p_float_t(current_position.z, 3)) - ); - planner.synchronize(); - } - #endif +void BedLevelToolsClass::manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y, bool reset/*=false*/) { + float zval; + if (reset) { zval = 0; } + else { zval = current_position.z; } + gcode.process_subcommands_now( + TS(F(TERN(AUTO_BED_LEVELING_UBL, "M421 I", "G29 I")), mesh_x, 'J', mesh_y, 'Z', p_float_t(zval, 3)) + ); + planner.synchronize(); +} + 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) { @@ -187,8 +177,8 @@ bool BedLevelToolsClass::meshValidate() { } #if USE_GRID_MESHVIEWER - - constexpr uint8_t meshfont = TERN(TJC_DISPLAY, font8x16, font6x12); + #include "meshviewer.h" + bool BedLevelToolsClass::view_mesh = false; 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; @@ -224,10 +214,10 @@ bool BedLevelToolsClass::meshValidate() { LCD_SERIAL.flushTX(); // Draw value text on - const uint8_t fs = DWINUI::fontWidth(meshfont); + const uint8_t fs = DWINUI::fontWidth(MeshViewer.meshfont); const int8_t offset_y = cell_height_px / 2 - fs; if (isnan(z)) { // undefined - DWIN_Draw_String(false, meshfont, DWINUI::textcolor, DWINUI::backcolor, start_x_px + cell_width_px / 2 - 5, start_y_px + offset_y, F("X")); + DWIN_Draw_String(false, MeshViewer.meshfont, DWINUI::textcolor, DWINUI::backcolor, start_x_px + cell_width_px / 2 - 5, start_y_px + offset_y, F("X")); } else { // has value MString<12> msg; @@ -237,8 +227,8 @@ bool BedLevelToolsClass::meshValidate() { msg.set(p_float_t(abs(z), 2)); const int8_t offset_x = cell_width_px / 2 - (fs / 2) * msg.length() - 2; if ((GRID_MAX_POINTS_X) >= TERN(TJC_DISPLAY, 8, 10)) - DWIN_Draw_String(false, meshfont, DWINUI::textcolor, DWINUI::backcolor, start_x_px - 2 + offset_x, start_y_px + offset_y, F(".")); - DWIN_Draw_String(false, meshfont, DWINUI::textcolor, DWINUI::backcolor, start_x_px + 1 + offset_x, start_y_px + offset_y, msg); + DWIN_Draw_String(false, MeshViewer.meshfont, DWINUI::textcolor, DWINUI::backcolor, start_x_px - 2 + offset_x, start_y_px + offset_y, F(".")); + DWIN_Draw_String(false, MeshViewer.meshfont, DWINUI::textcolor, DWINUI::backcolor, start_x_px + 1 + offset_x, start_y_px + offset_y, msg); } safe_delay(10); LCD_SERIAL.flushTX(); diff --git a/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h index 80c49945f8..723d0e346b 100644 --- a/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h +++ b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h @@ -27,20 +27,15 @@ class BedLevelToolsClass { public: - #if USE_GRID_MESHVIEWER - static bool view_mesh; - #endif static bool goto_mesh_value; static uint8_t mesh_x; static uint8_t mesh_y; static uint8_t tilt_grid; #if ENABLED(AUTO_BED_LEVELING_UBL) - static void manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y, bool undefined=false); static bool create_plane_from_mesh(); - #else - static void manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y); #endif + static void manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y, bool reset=false); static void manual_move(const uint8_t mesh_x, const uint8_t mesh_y, bool zmove=false); static void MoveToXYZ(); static void MoveToXY(); @@ -51,6 +46,7 @@ class BedLevelToolsClass { static float get_min_value(); static bool meshValidate(); #if USE_GRID_MESHVIEWER + static bool view_mesh; 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(); #endif diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index 4e65f1591b..2386d4e0bc 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -31,6 +31,7 @@ #include "../../../core/serial.h" #include "../../../gcode/gcode.h" #include "../../../gcode/queue.h" +#include "../../../libs/numtostr.h" #include "../../../module/motion.h" #include "../../../module/planner.h" #include "../../../module/printcounter.h" @@ -143,7 +144,7 @@ // Editable temperature limits #define MIN_ETEMP 0 -#define MAX_ETEMP thermalManager.hotend_max_target(0) +#define MAX_ETEMP thermalManager.hotend_max_target(EXT) #define MIN_BEDTEMP 0 #define MAX_BEDTEMP BED_MAX_TARGET @@ -502,23 +503,24 @@ static uint8_t _percent_done = 242; void Draw_Print_ProgressBar() { DWINUI::Draw_IconWB(ICON_Bar, 15, 93); DWIN_Draw_Rectangle(1, HMI_data.Barfill_Color, 15 + (_percent_done * 242) / 100, 93, 257, 113); - DWINUI::Draw_Int(HMI_data.PercentTxt_Color, HMI_data.Background_Color, 3, 117, 133, _percent_done); - DWINUI::Draw_String(HMI_data.PercentTxt_Color, 142, 133, F("%")); + DWINUI::Draw_String(HMI_data.PercentTxt_Color, HMI_data.Background_Color, 117, 133, pcttostrpctrj(_percent_done)); } duration_t _printtime = print_job_timer.duration(); void Draw_Print_ProgressElapsed() { MString<14> buf; - buf.setf(F("%02i:%02i "), uint16_t(_printtime.hour()), uint16_t(_printtime.minute())); - DWINUI::Draw_String(HMI_data.Text_Color, HMI_data.Background_Color, 47, 192, buf); + const bool has_days = (_printtime.value > 60*60*24L); + buf.set(_printtime.toDigital(buf, has_days)); + DWINUI::Draw_String(HMI_data.Text_Color, HMI_data.Background_Color, 65, 192, buf); } #if ENABLED(SHOW_REMAINING_TIME) duration_t _remain_time = 0; void Draw_Print_ProgressRemain() { MString<14> buf; - buf.setf(F("%02i:%02i "), uint16_t(_remain_time.hour()), uint16_t(_remain_time.minute())); - DWINUI::Draw_String(HMI_data.Text_Color, HMI_data.Background_Color, 181, 192, buf); + const bool has_days = (_remain_time.value > 60*60*24L); + buf.set(_remain_time.toDigital(buf, has_days)); + DWINUI::Draw_String(HMI_data.Text_Color, HMI_data.Background_Color, 200, 192, buf); } #endif @@ -763,13 +765,13 @@ void update_variable() { #if HAS_HOTEND static celsius_t _hotendtemp = 0, _hotendtarget = 0; - const celsius_t hc = thermalManager.wholeDegHotend(0), - ht = thermalManager.degTargetHotend(0); + const celsius_t hc = thermalManager.wholeDegHotend(EXT), + ht = thermalManager.degTargetHotend(EXT); const bool _new_hotend_temp = _hotendtemp != hc, _new_hotend_target = _hotendtarget != ht; if (_new_hotend_temp) { _hotendtemp = hc; } if (_new_hotend_target) { _hotendtarget = ht; } - if (thermalManager.degHotendNear(0, ht) || thermalManager.isHeatingHotend(0)) { + if (thermalManager.degHotendNear(0, ht) || thermalManager.isHeatingHotend(EXT)) { DWIN_Draw_Box(1, HMI_data.Background_Color, 9, 383, 20, 20); DWINUI::Draw_Icon(ICON_SetEndTemp, 9, 383); } @@ -1044,9 +1046,9 @@ void DWIN_Draw_Dashboard() { #if HAS_HOTEND DWINUI::Draw_Icon(ICON_HotendTemp, 9, 383); - DWINUI::Draw_Int(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 3, 28, 384, thermalManager.wholeDegHotend(0)); + DWINUI::Draw_Int(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 3, 28, 384, thermalManager.wholeDegHotend(EXT)); DWINUI::Draw_String(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 25 + 3 * STAT_CHR_W + 5, 384, F("/")); - DWINUI::Draw_Int(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 3, 25 + 4 * STAT_CHR_W + 6, 384, thermalManager.degTargetHotend(0)); + DWINUI::Draw_Int(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 3, 25 + 4 * STAT_CHR_W + 6, 384, thermalManager.degTargetHotend(EXT)); DWIN_Draw_DegreeSymbol(HMI_data.Indicator_Color, 25 + 4 * STAT_CHR_W + 39, 384); DWINUI::Draw_Icon(ICON_StepE, 113, 416); @@ -1294,17 +1296,17 @@ void EachMomentUpdate() { #endif #if PROUI_TUNING_GRAPH if (checkkey == PidProcess) { - TERN_(PIDTEMP, if (HMI_value.tempControl == PID_EXTR_START) { plot.update(thermalManager.wholeDegHotend(0)); }) + TERN_(PIDTEMP, if (HMI_value.tempControl == PID_EXTR_START) { plot.update(thermalManager.wholeDegHotend(EXT)); }) TERN_(PIDTEMPBED, if (HMI_value.tempControl == PID_BED_START) { plot.update(thermalManager.wholeDegBed()); }) } if (checkkey == MPCProcess) { - TERN_(MPCTEMP, if (HMI_value.tempControl == MPCTEMP_START) { plot.update(thermalManager.wholeDegHotend(0)); }) + TERN_(MPCTEMP, if (HMI_value.tempControl == MPCTEMP_START) { plot.update(thermalManager.wholeDegHotend(EXT)); }) } #if ENABLED(PROUI_ITEM_PLOT) if (checkkey == PlotProcess) { - TERN_(PIDTEMP, if (HMI_value.tempControl == PID_EXTR_START) { plot.update(thermalManager.wholeDegHotend(0)); }) + TERN_(PIDTEMP, if (HMI_value.tempControl == PID_EXTR_START) { plot.update(thermalManager.wholeDegHotend(EXT)); }) TERN_(PIDTEMPBED, if (HMI_value.tempControl == PID_BED_START) { plot.update(thermalManager.wholeDegBed()); }) - TERN_(MPCTEMP, if (HMI_value.tempControl == MPCTEMP_START) { plot.update(thermalManager.wholeDegHotend(0)); }) + TERN_(MPCTEMP, if (HMI_value.tempControl == MPCTEMP_START) { plot.update(thermalManager.wholeDegHotend(EXT)); }) if (HMI_flag.abort_flag || HMI_flag.pause_flag || print_job_timer.isPaused()) { HMI_ReturnScreen(); } @@ -1578,9 +1580,9 @@ void DWIN_HomingDone() { if (!DEBUGGING(DRYRUN)) { probe.preheat_for_probing(LEVELING_NOZZLE_TEMP, HMI_data.BedLevT); } #else #if HAS_HOTEND - if (!DEBUGGING(DRYRUN) && thermalManager.degTargetHotend(0) < LEVELING_NOZZLE_TEMP) { + if (!DEBUGGING(DRYRUN) && thermalManager.degTargetHotend(EXT) < LEVELING_NOZZLE_TEMP) { thermalManager.setTargetHotend(LEVELING_NOZZLE_TEMP, 0); - thermalManager.wait_for_hotend(0); + thermalManager.wait_for_hotend(EXT); } #endif #if HAS_HEATED_BED @@ -1632,7 +1634,7 @@ void DWIN_HomingDone() { DWINUI::Draw_CenteredString(2,HMI_data.PopupTxt_Color, 70, GET_TEXT_F(MSG_MPC_AUTOTUNE)); DWINUI::Draw_String(HMI_data.PopupTxt_Color, gfrm.x, gfrm.y - DWINUI::fontHeight() - 4, GET_TEXT_F(MSG_MPC_TARGET)); DWINUI::Draw_CenteredString(2, HMI_data.PopupTxt_Color, 92, GET_TEXT_F(MSG_FOR_NOZZLE)); - _maxtemp = thermalManager.hotend_max_target(0); + _maxtemp = thermalManager.hotend_max_target(EXT); _target = 200; break; #endif @@ -1641,7 +1643,7 @@ void DWIN_HomingDone() { DWINUI::Draw_CenteredString(2, HMI_data.PopupTxt_Color, 70, GET_TEXT_F(MSG_PID_AUTOTUNE)); DWINUI::Draw_String(HMI_data.PopupTxt_Color, gfrm.x, gfrm.y - DWINUI::fontHeight() - 4, GET_TEXT_F(MSG_PID_TARGET)); DWINUI::Draw_CenteredString(2, HMI_data.PopupTxt_Color, 92, GET_TEXT_F(MSG_FOR_NOZZLE)); - _maxtemp = thermalManager.hotend_max_target(0); + _maxtemp = thermalManager.hotend_max_target(EXT); _target = HMI_data.HotendPidT; break; #endif @@ -1677,8 +1679,8 @@ void DWIN_HomingDone() { #endif Title.ShowCaption(GET_TEXT_F(MSG_HOTEND_TEMP_GRAPH)); DWINUI::Draw_CenteredString(3, HMI_data.PopupTxt_Color, 75, GET_TEXT_F(MSG_NOZZLE_TEMPERATURE)); - _maxtemp = thermalManager.hotend_max_target(0); - _target = thermalManager.degTargetHotend(0); + _maxtemp = thermalManager.hotend_max_target(EXT); + _target = thermalManager.degTargetHotend(EXT); break; #if ENABLED(PIDTEMPBED) case PID_BED_START: @@ -2398,7 +2400,7 @@ bool EnableLiveMove = false; void SetLiveMove() { Toggle_Chkb_Line(EnableLiveMove); } void AxisMove(AxisEnum axis) { #if HAS_HOTEND - if (axis == E_AXIS && thermalManager.tooColdToExtrude(0)) { + if (axis == E_AXIS && thermalManager.tooColdToExtrude(EXT)) { gcode.process_subcommands_now(F("G92E0")); // reset extruder position return DWIN_Popup_Confirm(ICON_TempTooLow, GET_TEXT_F(MSG_HOTEND_TOO_COLD), GET_TEXT_F(MSG_PLEASE_PREHEAT)); } @@ -2598,7 +2600,7 @@ void ApplyMove() { #if HAS_HOTEND void ApplyHotendTemp() { thermalManager.setTargetHotend(MenuData.Value, H_E0); } - void SetHotendTemp() { SetIntOnClick(MIN_ETEMP, MAX_ETEMP, thermalManager.degTargetHotend(0), ApplyHotendTemp); } + void SetHotendTemp() { SetIntOnClick(MIN_ETEMP, MAX_ETEMP, thermalManager.degTargetHotend(EXT), ApplyHotendTemp); } #endif #if HAS_HEATED_BED @@ -4125,19 +4127,12 @@ void Draw_MaxAccel_Menu() { #if ENABLED(MESH_EDIT_MENU) bool AutoMovToMesh = false; - void manualResetValue() { - gcode.process_subcommands_now( - TS(F("M421I"), bedLevelTools.mesh_x, 'J', bedLevelTools.mesh_y, 'Z', p_float_t(0, 3)) - ); - planner.synchronize(); - } - 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 LiveEditMeshZ() { *MenuData.P_Float = MenuData.Value / POW(10, 3); if (AutoMovToMesh) { bedLevelTools.MoveToZ(); } } void ApplyEditMeshX() { bedLevelTools.mesh_x = MenuData.Value; if (AutoMovToMesh) { bedLevelTools.MoveToXY(); } } void ApplyEditMeshY() { bedLevelTools.mesh_y = MenuData.Value; if (AutoMovToMesh) { bedLevelTools.MoveToXY(); } } - void ZeroMesh() { manualResetValue(); EditZValueItem->redraw(); LCD_MESSAGE(MSG_ZERO_MESH); } - void ZeroPoint() { bedLevelTools.mesh_reset(); LCD_MESSAGE(MSG_MESH_RESET); } + void ZeroPoint() { bedLevelTools.manual_value_update(bedLevelTools.mesh_x, bedLevelTools.mesh_y, true); EditZValueItem->redraw(); LCD_MESSAGE(MSG_ZERO_MESH); } + void ZeroMesh() { bedLevelTools.mesh_reset(); LCD_MESSAGE(MSG_MESH_RESET); } void SetEditMeshX() { HMI_value.Select = 0; SetIntOnClick(0, GRID_MAX_POINTS_X - 1, bedLevelTools.mesh_x, ApplyEditMeshX, 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, nullptr, LiveEditMeshZ); if (AutoMovToMesh) { bedLevelTools.MoveToXYZ(); } } @@ -4150,7 +4145,7 @@ void Draw_MaxAccel_Menu() { void OnClick_ResetMesh() { if (HMI_flag.select_flag) { HMI_ReturnScreen(); - ZeroPoint(); + ZeroMesh(); DONE_BUZZ(true); } else { HMI_ReturnScreen(); } @@ -4197,7 +4192,7 @@ void Draw_MaxAccel_Menu() { EDIT_ITEM(ICON_MeshEditY, MSG_MESH_Y, onDrawPInt8Menu, SetEditMeshY, &bedLevelTools.mesh_y); EditZValueItem = EDIT_ITEM(ICON_MeshEditZ, MSG_MESH_EDIT_Z, onDrawPFloat3Menu, SetEditZValue, &bedlevel.z_values[bedLevelTools.mesh_x][bedLevelTools.mesh_y]); TERN_(HAS_BED_PROBE, MENU_ITEM(ICON_Probe, MSG_PROBE_WIZARD_PROBING, onDrawMenuItem, bedLevelTools.ProbeXY);) - MENU_ITEM(ICON_SetZOffset, MSG_ZERO_MESH, onDrawMenuItem, ZeroMesh); + MENU_ITEM(ICON_SetZOffset, MSG_ZERO_MESH, onDrawMenuItem, ZeroPoint); } UpdateMenu(EditMeshMenu); } diff --git a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp index 0e2841026b..0c5b3a681d 100644 --- a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp +++ b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp @@ -113,7 +113,7 @@ void ESDiag::update() { #endif #if HAS_FILAMENT_SENSOR #if PROUI_EX - draw_es_state(!FilamentSensorDevice::poll_runout_state(0)); + draw_es_state(!FilamentSensorDevice::poll_runout_state(EXT)); #else //draw_es_state(!FilamentSensorSwitch::poll_runout_states()); draw_es_state(READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE); @@ -129,7 +129,7 @@ void ESDiag::update() { IF_DISABLED(USE_Z_MIN_PROBE, TERN_(USE_Z_MIN, ES_REPORT(Z_MIN);) TERN_(USE_Z_MAX, ES_REPORT(Z_MAX);)) #if HAS_FILAMENT_SENSOR #if PROUI_EX - draw_es_state(!FilamentSensorDevice::poll_runout_state(0), true); + draw_es_state(!FilamentSensorDevice::poll_runout_state(EXT), true); #else //draw_es_state(!FilamentSensorSwitch::poll_runout_states()); draw_es_state(READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE, true); diff --git a/Marlin/src/lcd/e3v2/proui/meshviewer.cpp b/Marlin/src/lcd/e3v2/proui/meshviewer.cpp index 99c23152c7..c2433331e9 100644 --- a/Marlin/src/lcd/e3v2/proui/meshviewer.cpp +++ b/Marlin/src/lcd/e3v2/proui/meshviewer.cpp @@ -36,7 +36,7 @@ bool meshredraw; // Redraw mesh points uint8_t sizex, sizey; // Mesh XY size uint8_t rmax; // Maximum radius #define margin 25 // XY Margins -#define rmin 5 // Minimum radius +#define rmin 5 // Minimum radius #define zmin -20 // rmin at z=-0.20 #define zmax 20 // rmax at z= 0.20 #define width DWIN_WIDTH - 2 * margin @@ -44,8 +44,6 @@ uint8_t rmax; // Maximum radius #define px(xp) (margin + (xp) * (width) / (sizex - 1)) #define py(yp) (30 + DWIN_WIDTH - margin - (yp) * (width) / (sizey - 1)) -constexpr uint8_t meshfont = TERN(TJC_DISPLAY, font8x16, font6x12); - MeshViewerClass MeshViewer; float MeshViewerClass::max, MeshViewerClass::min; @@ -65,7 +63,7 @@ void MeshViewerClass::DrawMeshGrid(const uint8_t csizex, const uint8_t csizey) { void MeshViewerClass::DrawMeshPoint(const uint8_t x, const uint8_t y, const float z) { if (isnan(z)) return; TERN_(HAS_BACKLIGHT_TIMEOUT, ui.refresh_backlight_timeout();) - const uint8_t fs = DWINUI::fontWidth(meshfont); + const uint8_t fs = DWINUI::fontWidth(MeshViewer.meshfont); const int16_t v = round(z * 100); NOLESS(max, z); NOMORE(min, z); const uint16_t color = DWINUI::RainbowInt(v, zmin, zmax); @@ -73,21 +71,21 @@ void MeshViewerClass::DrawMeshPoint(const uint8_t x, const uint8_t y, const floa TERN_(TJC_DISPLAY, delay(100)); const uint16_t fy = py(y) - fs; if (sizex < TERN(TJC_DISPLAY, 8, 9)) { - if (v == 0) DWINUI::Draw_Float(meshfont, 1, 2, px(x) - 2 * fs, fy, 0); - else DWINUI::Draw_Signed_Float(meshfont, 1, 2, px(x) - 3 * fs, fy, z); + if (v == 0) DWINUI::Draw_Float(MeshViewer.meshfont, 1, 2, px(x) - 2 * fs, fy, 0); + else DWINUI::Draw_Signed_Float(MeshViewer.meshfont, 1, 2, px(x) - 3 * fs, fy, z); } else { char msg[9]; msg[0] = '\0'; switch (v) { case -999 ... -100: // -9.99 .. -1.00 || 1.00 .. 9.99 - case 100 ... 999: DWINUI::Draw_Signed_Float(meshfont, 1, 1, px(x) - 3 * fs, fy, z); break; + case 100 ... 999: DWINUI::Draw_Signed_Float(MeshViewer.meshfont, 1, 1, px(x) - 3 * fs, fy, z); break; case -99 ... -1: sprintf_P(msg, PSTR("-.%2i"), -v); break; // -0.99 .. -0.01 mm case 1 ... 99: sprintf_P(msg, PSTR( ".%2i"), v); break; // 0.01 .. 0.99 mm default: - DWIN_Draw_String(false, meshfont, DWINUI::textcolor, DWINUI::backcolor, px(x) - 4, fy, "0"); + DWIN_Draw_String(false, MeshViewer.meshfont, DWINUI::textcolor, DWINUI::backcolor, px(x) - 4, fy, "0"); return; } - DWIN_Draw_String(false, meshfont, DWINUI::textcolor, DWINUI::backcolor, px(x) - 2 * fs, fy, msg); + DWIN_Draw_String(false, MeshViewer.meshfont, DWINUI::textcolor, DWINUI::backcolor, px(x) - 2 * fs, fy, msg); } SERIAL_FLUSH(); } diff --git a/Marlin/src/lcd/e3v2/proui/meshviewer.h b/Marlin/src/lcd/e3v2/proui/meshviewer.h index 67907cae91..f9cb282291 100644 --- a/Marlin/src/lcd/e3v2/proui/meshviewer.h +++ b/Marlin/src/lcd/e3v2/proui/meshviewer.h @@ -22,6 +22,7 @@ class MeshViewerClass { public: + const uint8_t meshfont = TERN(TJC_DISPLAY, font8x16, font6x12); static float max, min; static void DrawMeshGrid(const uint8_t csizex, const uint8_t csizey); static void DrawMeshPoint(const uint8_t x, const uint8_t y, const float z);