Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProUI general updates #25176

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions Marlin/src/feature/pause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,6 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool
#endif

TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_open(PROMPT_INFO, F("Pause"), FPSTR(DISMISS_STR)));
TERN_(DWIN_LCD_PROUI, DWIN_Print_Pause());

// Indicate that the printer is paused
++did_pause_print;
Expand Down Expand Up @@ -461,6 +460,7 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool

// If axes don't need to home then the nozzle can park
if (do_park) nozzle.park(0, park_point); // Park the nozzle by doing a Minimum Z Raise followed by an XY Move
TERN_(DWIN_LCD_PROUI, if (!do_park) ui.set_status(GET_TEXT_F(MSG_PARK_FAILED)));

#if ENABLED(DUAL_X_CARRIAGE)
const int8_t saved_ext = active_extruder;
Expand Down Expand Up @@ -710,13 +710,8 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_

TERN_(HAS_FILAMENT_SENSOR, runout.reset());

#if ENABLED(DWIN_LCD_PROUI)
DWIN_Print_Resume();
HMI_ReturnScreen();
#else
ui.reset_status();
ui.return_to_status();
#endif
ui.reset_status();
ui.return_to_status();
}

#endif // ADVANCED_PAUSE_FEATURE
2 changes: 1 addition & 1 deletion Marlin/src/gcode/config/M302.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "../../module/temperature.h"

#if ENABLED(DWIN_LCD_PROUI)
#include "../../lcd/e3v2/proui/dwin_defines.h"
#include "../../lcd/e3v2/proui/dwin.h"
#endif

/**
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/lcd/M145.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void GcodeSuite::M145() {
preheat_t &mat = ui.material_preset[material];
#if HAS_HOTEND
if (parser.seenval('H'))
mat.hotend_temp = constrain(parser.value_int(), EXTRUDE_MINTEMP, thermalManager.hotend_max_target(0));
mat.hotend_temp = constrain(parser.value_int(), thermalManager.extrude_min_temp, thermalManager.hotend_max_target(0));
#endif
#if HAS_HEATED_BED
if (parser.seenval('B'))
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/gcode/sd/M1001.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ void GcodeSuite::M1001() {
#endif

TERN_(EXTENSIBLE_UI, ExtUI::onPrintDone());
TERN_(DWIN_LCD_PROUI, DWIN_Print_Finished());

// Re-select the last printed file in the UI
TERN_(SD_REPRINT_LAST_SELECTED_FILE, ui.reselect_last_file());
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/gcode/sd/M524.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "../../sd/cardreader.h"

#if ENABLED(DWIN_LCD_PROUI)
#include "../../lcd/e3v2/proui/dwin.h"
#include "../../lcd/marlinui.h"
#endif

/**
Expand All @@ -38,7 +38,7 @@ void GcodeSuite::M524() {

#if ENABLED(DWIN_LCD_PROUI)

HMI_flag.abort_flag = true; // The LCD will handle it
ui.abort_print();

#else

Expand Down
5 changes: 1 addition & 4 deletions Marlin/src/gcode/stats/M75-M78.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
void GcodeSuite::M75() {
startOrResumeJob();
#if ENABLED(DWIN_LCD_PROUI)
DWIN_Print_Started(false);
if (!IS_SD_PRINTING()) DWIN_Print_Header(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT));
#endif
}
Expand All @@ -48,17 +47,15 @@ void GcodeSuite::M75() {
* M76: Pause print timer
*/
void GcodeSuite::M76() {
print_job_timer.pause();
TERN(DWIN_LCD_PROUI, ui.pause_print(), print_job_timer.pause());
TERN_(HOST_PAUSE_M76, hostui.pause());
TERN_(DWIN_LCD_PROUI, DWIN_Print_Pause());
}

/**
* M77: Stop print timer
*/
void GcodeSuite::M77() {
print_job_timer.stop();
TERN_(DWIN_LCD_PROUI, DWIN_Print_Finished());
}

#if ENABLED(PRINTCOUNTER)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/temp/M303.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void GcodeSuite::M303() {

#if ENABLED(DWIN_LCD_PROUI)
if (seenC) HMI_data.PidCycles = c;
if (seenS) { if (hid == H_BED) HMI_data.BedPidT = temp; else HMI_data.HotendPidT = temp; }
if (seenS) { if (hid == H_BED) HMI_data.BedPidT = temp; else TERN_(PIDTEMP, HMI_data.HotendPidT = temp); }
#endif

#if DISABLED(BUSY_WHILE_HEATING)
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -2472,6 +2472,7 @@
#define BED_MAX_TARGET (BED_MAXTEMP - (BED_OVERSHOOT))
#else
#undef PIDTEMPBED
#undef PREHEAT_BEFORE_LEVELING
#endif

#if HAS_TEMP_COOLER && PIN_EXISTS(COOLER)
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -940,8 +940,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#error "SD_REPRINT_LAST_SELECTED_FILE currently requires a Marlin-native LCD menu."
#endif

#if ANY(HAS_MARLINUI_MENU, TOUCH_UI_FTDI_EVE, EXTENSIBLE_UI) && !defined(MANUAL_FEEDRATE)
#error "MANUAL_FEEDRATE is required for MarlinUI, ExtUI, or FTDI EVE Touch UI."
#if ANY(HAS_MARLINUI_MENU, TOUCH_UI_FTDI_EVE, EXTENSIBLE_UI, DWIN_LCD_PROUI) && !defined(MANUAL_FEEDRATE)
#error "MANUAL_FEEDRATE is required for ProUI, MarlinUI, ExtUI, or FTDI EVE Touch UI."
#endif

/**
Expand Down
69 changes: 43 additions & 26 deletions Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,37 @@
* 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
*
* Version: 2.1.0
* Date: 2022/08/27
*
* Based on the original work of: Henri-J-Norden
* https://github.com/Jyers/Marlin/pull/126
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/

#include "../../../inc/MarlinConfigPre.h"
#include "bedlevel_tools.h"

#if BOTH(DWIN_LCD_PROUI, HAS_LEVELING)

#include "../../marlinui.h"
#include "../../../core/types.h"
#include "dwin.h"
#include "dwinui.h"
#include "dwin_popup.h"
#include "../../../feature/bedlevel/bedlevel.h"
#include "../../../module/probe.h"
#include "../../../gcode/gcode.h"
Expand All @@ -48,9 +58,14 @@
#include "../../../libs/least_squares_fit.h"
#include "../../../libs/vector_3.h"

BedLevelToolsClass BedLevelTools;
#include "dwin.h"
#include "dwinui.h"
#include "dwin_popup.h"
#include "bedlevel_tools.h"

BedLevelToolsClass bedLevelTools;

#if USE_UBL_VIEWER
#if ENABLED(USE_UBL_VIEWER)
bool BedLevelToolsClass::viewer_asymmetric_range = false;
bool BedLevelToolsClass::viewer_print_value = false;
#endif
Expand Down Expand Up @@ -153,26 +168,30 @@ void BedLevelToolsClass::manual_move(const uint8_t mesh_x, const uint8_t mesh_y,
}
}

// Move / Probe methods. As examples, not yet used.
void BedLevelToolsClass::MoveToXYZ() {
BedLevelTools.goto_mesh_value = true;
BedLevelTools.manual_move(BedLevelTools.mesh_x, BedLevelTools.mesh_y, false);
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);
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);
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)
const uint16_t Clear = Z_CLEARANCE_DEPLOY_PROBE;
sprintf_P(cmd, PSTR("G0Z%i\nG30X%sY%s"),
Clear,
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);
}

// Accessors
float BedLevelToolsClass::get_max_value() {
float max = __FLT_MAX__ * -1;
GRID_LOOP(x, y) {
Expand All @@ -191,18 +210,16 @@ float BedLevelToolsClass::get_min_value() {
return min;
}

// Return 'true' if mesh is good and within LCD limits
bool BedLevelToolsClass::meshvalidate() {
float min = __FLT_MAX__, max = __FLT_MAX__ * -1;

GRID_LOOP(x, y) {
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] > max) max = bedlevel.z_values[x][y];
const float v = bedlevel.z_values[x][y];
if (isnan(v) || !WITHIN(v, UBL_Z_OFFSET_MIN, UBL_Z_OFFSET_MAX)) return false;
}
return WITHIN(max, MESH_Z_OFFSET_MIN, MESH_Z_OFFSET_MAX);
return true;
}

#if USE_UBL_VIEWER
#if ENABLED(USE_UBL_VIEWER)

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
37 changes: 23 additions & 14 deletions Marlin/src/lcd/e3v2/proui/bedlevel_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,38 @@
/**
* Bed Level Tools for Pro UI
* Extended by: Miguel A. Risco-Castillo (MRISCOC)
* Version: 2.0.0
* Date: 2022/05/23
*
* Version: 2.1.0
* Date: 2022/08/27
*
* Based on the original work of: Henri-J-Norden
* https://github.com/Jyers/Marlin/pull/126
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/

#pragma once

#include "../../../inc/MarlinConfigPre.h"

#if ENABLED(AUTO_BED_LEVELING_UBL)
//#define USE_UBL_VIEWER 1
#endif
//#define USE_UBL_VIEWER 1

#define MESH_Z_OFFSET_MIN -3.0
#define MESH_Z_OFFSET_MAX 3.0
#define UBL_Z_OFFSET_MIN -3.0
#define UBL_Z_OFFSET_MAX 3.0

class BedLevelToolsClass {
public:
#if USE_UBL_VIEWER
#if ENABLED(USE_UBL_VIEWER)
static bool viewer_asymmetric_range;
static bool viewer_print_value;
#endif
Expand All @@ -66,12 +77,10 @@ class BedLevelToolsClass {
static float get_max_value();
static float get_min_value();
static bool meshvalidate();
#if USE_UBL_VIEWER
#if ENABLED(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 Set_Mesh_Viewer_Status();
#endif
};

extern BedLevelToolsClass BedLevelTools;

void Goto_MeshViewer();
extern BedLevelToolsClass bedLevelTools;
Loading