Skip to content

Commit

Permalink
🚸 Update DWIN ProUI (#26003)
Browse files Browse the repository at this point in the history
  • Loading branch information
mriscoc authored Jun 23, 2023
1 parent 2218bab commit 858916d
Show file tree
Hide file tree
Showing 35 changed files with 1,213 additions and 906 deletions.
10 changes: 8 additions & 2 deletions Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,14 @@ void unified_bed_leveling::G29() {
// Check for commands that require the printer to be homed
if (may_move) {
planner.synchronize();
// Send 'N' to force homing before G29 (internal only)
if (axes_should_home() || parser.seen_test('N')) gcode.home_all_axes();
#if ALL(DWIN_LCD_PROUI, ZHOME_BEFORE_LEVELING)
save_ubl_active_state_and_disable();
gcode.process_subcommands_now(F("G28Z"));
restore_ubl_active_state_and_leave();
#else
// Send 'N' to force homing before G29 (internal only)
if (axes_should_home() || parser.seen_test('N')) gcode.home_all_axes();
#endif
probe.use_probing_tool();

// Position bed horizontally and Z probe vertically.
Expand Down
8 changes: 4 additions & 4 deletions Marlin/src/feature/tmc_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class TMCMarlin : public TMC, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
#endif
#endif

#if HAS_MARLINUI_MENU
#if ANY(HAS_MARLINUI_MENU, DWIN_LCD_PROUI)
void refresh_stepper_current() { rms_current(this->val_mA); }

#if ENABLED(HYBRID_THRESHOLD)
Expand Down Expand Up @@ -207,7 +207,7 @@ class TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
}
#endif

#if HAS_MARLINUI_MENU
#if ANY(HAS_MARLINUI_MENU, DWIN_LCD_PROUI)
void refresh_stepper_current() { rms_current(this->val_mA); }

#if ENABLED(HYBRID_THRESHOLD)
Expand Down Expand Up @@ -269,7 +269,7 @@ class TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
}
#endif

#if HAS_MARLINUI_MENU
#if ANY(HAS_MARLINUI_MENU, DWIN_LCD_PROUI)
void refresh_stepper_current() { rms_current(this->val_mA); }

#if ENABLED(HYBRID_THRESHOLD)
Expand Down Expand Up @@ -315,7 +315,7 @@ class TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC266
}
#endif

#if HAS_MARLINUI_MENU
#if ANY(HAS_MARLINUI_MENU, DWIN_LCD_PROUI)
void refresh_stepper_current() { rms_current(this->val_mA); }

#if USE_SENSORLESS
Expand Down
32 changes: 12 additions & 20 deletions Marlin/src/gcode/lcd/M73.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,20 @@
*/
void GcodeSuite::M73() {

#if ENABLED(DWIN_LCD_PROUI)

DWIN_M73();

#else

#if ENABLED(SET_PROGRESS_PERCENT)
if (parser.seenval('P'))
ui.set_progress((PROGRESS_SCALE) > 1
? parser.value_float() * (PROGRESS_SCALE)
: parser.value_byte()
);
#endif

#if ENABLED(SET_REMAINING_TIME)
if (parser.seenval('R')) ui.set_remaining_time(60 * parser.value_ulong());
#endif
#if ENABLED(SET_PROGRESS_PERCENT)
if (parser.seenval('P'))
ui.set_progress((PROGRESS_SCALE) > 1
? parser.value_float() * (PROGRESS_SCALE)
: parser.value_byte()
);
#endif

#if ENABLED(SET_INTERACTION_TIME)
if (parser.seenval('C')) ui.set_interaction_time(60 * parser.value_ulong());
#endif
#if ENABLED(SET_REMAINING_TIME)
if (parser.seenval('R')) ui.set_remaining_time(60 * parser.value_ulong());
#endif

#if ENABLED(SET_INTERACTION_TIME)
if (parser.seenval('C')) ui.set_interaction_time(60 * parser.value_ulong());
#endif

#if ENABLED(M73_REPORT)
Expand Down
4 changes: 3 additions & 1 deletion Marlin/src/gcode/probe/G30.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ void GcodeSuite::G30() {

remember_feedrate_scaling_off();

TERN_(DWIN_CREALITY_LCD_JYERSUI, process_subcommands_now(F("G28O")));
#if ANY(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI)
process_subcommands_now(F("G28O"));
#endif

const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE;

Expand Down
16 changes: 10 additions & 6 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -2718,14 +2718,18 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L
#elif ENABLED(DWIN_LCD_PROUI)
#if !HAS_MEDIA
#error "DWIN_LCD_PROUI requires SDSUPPORT to be enabled."
#elif ANY(PID_EDIT_MENU, PID_AUTOTUNE_MENU)
#error "DWIN_LCD_PROUI does not support PID_EDIT_MENU or PID_AUTOTUNE_MENU."
#elif ANY(MPC_EDIT_MENU, MPC_AUTOTUNE_MENU)
#error "DWIN_LCD_PROUI does not support MPC_EDIT_MENU or MPC_AUTOTUNE_MENU."
#elif ENABLED(LCD_BED_TRAMMING)
#error "DWIN_LCD_PROUI does not support LCD_BED_TRAMMING."
#elif ALL(LCD_BED_LEVELING, PROBE_MANUALLY)
#error "DWIN_LCD_PROUI does not support LCD_BED_LEVELING with PROBE_MANUALLY."
#elif ENABLED(MEDIASORT_MENU_ITEM) && DISABLED(SDCARD_SORT_ALPHA)
#error "MEDIASORT_MENU_ITEM requires SDCARD_SORT_ALPHA."
#elif ENABLED(RUNOUT_TUNE_ITEM) && DISABLED(HAS_FILAMENT_SENSOR)
#error "RUNOUT_TUNE_ITEM requires HAS_FILAMENT_SENSOR."
#elif ENABLED(PLR_TUNE_ITEM) && DISABLED(POWER_LOSS_RECOVERY)
#error "PLR_TUNE_ITEM requires POWER_LOSS_RECOVERY."
#elif ENABLED(JD_TUNE_ITEM) && DISABLED(HAS_JUNCTION_DEVIATION)
#error "JD_TUNE_ITEM requires HAS_JUNCTION_DEVIATION."
#elif ENABLED(ADVK_TUNE_ITEM) && DISABLED(LIN_ADVANCE)
#error "ADVK_TUNE_ITEM requires LIN_ADVANCE."
#endif
#endif

Expand Down
12 changes: 7 additions & 5 deletions Marlin/src/lcd/e3v2/common/dwin_font.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ typedef uint8_t fontid_t;
* 0x00=6*12 0x01=8*16 0x02=10*20 0x03=12*24 0x04=14*28
* 0x05=16*32 0x06=20*40 0x07=24*48 0x08=28*56 0x09=32*64
*/
#define font6x12 0x00
#if DISABLED(TJC_DISPLAY)
#define font6x12 0x00
#define font20x40 0x06
#define font24x48 0x07
#define font28x56 0x08
#define font32x64 0x09
#endif
#define font8x16 0x01
#define font10x20 0x02
#define font12x24 0x03
#define font14x28 0x04
#define font16x32 0x05
#define font20x40 0x06
#define font24x48 0x07
#define font28x56 0x08
#define font32x64 0x09
8 changes: 7 additions & 1 deletion Marlin/src/lcd/e3v2/common/limits.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,10 @@ constexpr xyze_float_t min_acceleration_edit_values = LOGICAL_AXIS_ARRAY_1(MIN_A

constexpr xyze_float_t min_steps_edit_values = LOGICAL_AXIS_ARRAY_1(MIN_STEPS_EDIT_VALUE),
default_steps = DEFAULT_AXIS_STEPS_PER_UNIT,
max_steps_edit_values = default_steps * float(DEFAULT_MAX_MULTIPLIER);
max_steps_edit_values =
#ifdef MAX_STEPS_EDIT_VALUES
MAX_STEPS_EDIT_VALUES
#else
default_steps * float(DEFAULT_MAX_MULTIPLIER)
#endif
;
42 changes: 25 additions & 17 deletions Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
/**
* Bed Level Tools for Pro UI
* Extended by: Miguel A. Risco-Castillo (MRISCOC)
* Version: 2.1.0
* Date: 2022/08/27
* Version: 3.2.0
* Date: 2023/05/03
*
* Based on the original work of: Henri-J-Norden
* https://github.com/Jyers/Marlin/pull/126
Expand Down Expand Up @@ -65,7 +65,7 @@

BedLevelToolsClass bedLevelTools;

#if ENABLED(USE_UBL_VIEWER)
#if ENABLED(USE_GRID_MESHVIEWER)
bool BedLevelToolsClass::viewer_asymmetric_range = false;
bool BedLevelToolsClass::viewer_print_value = false;
#endif
Expand Down Expand Up @@ -170,15 +170,20 @@ void BedLevelToolsClass::MoveToZ() {
bedLevelTools.manual_move(bedLevelTools.mesh_x, bedLevelTools.mesh_y, true);
}
void BedLevelToolsClass::ProbeXY() {
const uint16_t Clear = Z_CLEARANCE_DEPLOY_PROBE;
sprintf_P(cmd, PSTR("G28O\nG0Z%i\nG30X%sY%s"),
Clear,
const uint16_t zclear = Z_CLEARANCE_DEPLOY_PROBE;
sprintf_P(cmd, PSTR("G0Z%i\nG30X%sY%s"),
zclear,
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);
}

void BedLevelToolsClass::mesh_reset() {
ZERO(bedlevel.z_values);
TERN_(AUTO_BED_LEVELING_BILINEAR, bedlevel.refresh_bed_level());
}

// Accessors
float BedLevelToolsClass::get_max_value() {
float max = __FLT_MAX__ * -1;
Expand Down Expand Up @@ -207,9 +212,11 @@ bool BedLevelToolsClass::meshvalidate() {
return true;
}

#if ENABLED(USE_UBL_VIEWER)
#if ENABLED(USE_GRID_MESHVIEWER)

constexpr uint8_t meshfont = TERN(TJC_DISPLAY, font8x16, font6x12);

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*/) {
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;
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);
Expand All @@ -227,7 +234,6 @@ bool BedLevelToolsClass::meshvalidate() {
}

// Draw value square grid
char buf[8];
GRID_LOOP(x, y) {
const auto start_x_px = padding_x + x * cell_width_px;
const auto end_x_px = start_x_px + cell_width_px - 1 - gridline_width;
Expand All @@ -246,20 +252,22 @@ bool BedLevelToolsClass::meshvalidate() {
LCD_SERIAL.flushTX();

// Draw value text on
char buf[8];
const uint8_t fs = DWINUI::fontWidth(meshfont);
if (viewer_print_value) {
int8_t offset_x, offset_y = cell_height_px / 2 - 6;
int8_t offset_x, offset_y = cell_height_px / 2 - fs;
if (isnan(bedlevel.z_values[x][y])) { // undefined
dwinDrawString(false, font6x12, Color_White, Color_Bg_Blue, start_x_px + cell_width_px / 2 - 5, start_y_px + offset_y, F("X"));
dwinDrawString(false, meshfont, Color_White, Color_Bg_Blue, start_x_px + cell_width_px / 2 - 5, start_y_px + offset_y, F("X"));
}
else { // has value
if (GRID_MAX_POINTS_X < 10)
if (GRID_MAX_POINTS_X < (ENABLED(TJC_DISPLAY) ? 8 : 10))
sprintf_P(buf, PSTR("%s"), dtostrf(abs(bedlevel.z_values[x][y]), 1, 2, str_1));
else
sprintf_P(buf, PSTR("%02i"), (uint16_t)(abs(bedlevel.z_values[x][y] - (int16_t)bedlevel.z_values[x][y]) * 100));
offset_x = cell_width_px / 2 - 3 * (strlen(buf)) - 2;
if (!(GRID_MAX_POINTS_X < 10))
dwinDrawString(false, font6x12, Color_White, Color_Bg_Blue, start_x_px - 2 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, F("."));
dwinDrawString(false, font6x12, Color_White, Color_Bg_Blue, start_x_px + 1 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, buf);
offset_x = cell_width_px / 2 - (fs/2) * (strlen(buf)) - 2;
if (!(GRID_MAX_POINTS_X < (ENABLED(TJC_DISPLAY) ? 8 : 10)))
dwinDrawString(false, meshfont, Color_White, Color_Bg_Blue, start_x_px - 2 + offset_x, start_y_px + offset_y, F("."));
dwinDrawString(false, meshfont, Color_White, Color_Bg_Blue, start_x_px + 1 + offset_x, start_y_px + offset_y, buf);
}
safe_delay(10);
LCD_SERIAL.flushTX();
Expand All @@ -286,6 +294,6 @@ bool BedLevelToolsClass::meshvalidate() {
drawing_mesh = false;
}

#endif // USE_UBL_VIEWER
#endif // USE_GRID_MESHVIEWER

#endif // DWIN_LCD_PROUI && HAS_LEVELING
13 changes: 6 additions & 7 deletions Marlin/src/lcd/e3v2/proui/bedlevel_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
/**
* Bed Level Tools for Pro UI
* Extended by: Miguel A. Risco-Castillo (MRISCOC)
* Version: 2.1.0
* Date: 2022/08/27
* Version: 3.2.0
* Date: 2023/05/03
*
* Based on the original work of: Henri-J-Norden
* https://github.com/Jyers/Marlin/pull/126
Expand All @@ -47,14 +47,12 @@

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

//#define USE_UBL_VIEWER 1

#define UBL_Z_OFFSET_MIN -3.0
#define UBL_Z_OFFSET_MAX 3.0

class BedLevelToolsClass {
public:
#if ENABLED(USE_UBL_VIEWER)
#if ENABLED(USE_GRID_MESHVIEWER)
static bool viewer_asymmetric_range;
static bool viewer_print_value;
#endif
Expand All @@ -74,11 +72,12 @@ class BedLevelToolsClass {
static void MoveToXY();
static void MoveToZ();
static void ProbeXY();
static void mesh_reset();
static float get_max_value();
static float get_min_value();
static bool meshvalidate();
#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);
#if ENABLED(USE_GRID_MESHVIEWER)
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
Loading

0 comments on commit 858916d

Please sign in to comment.