Skip to content

Commit

Permalink
Update - print/remain time, meshviewer/bedleveltools
Browse files Browse the repository at this point in the history
  • Loading branch information
classicrocker883 committed Jan 12, 2024
1 parent 8e66366 commit 5ac6cf3
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 79 deletions.
2 changes: 1 addition & 1 deletion Marlin/src/lcd/e3v2/common/dwin_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
42 changes: 16 additions & 26 deletions Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<MAX_CMD_SIZE> 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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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();
Expand Down
8 changes: 2 additions & 6 deletions Marlin/src/lcd/e3v2/proui/bedlevel_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand Down
65 changes: 30 additions & 35 deletions Marlin/src/lcd/e3v2/proui/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(); } }
Expand All @@ -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(); }
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/e3v2/proui/endstop_diag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Loading

0 comments on commit 5ac6cf3

Please sign in to comment.