Skip to content

Commit

Permalink
Ender 3 V2 Status Line (MarlinFirmware#21369)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <[email protected]>
  • Loading branch information
mriscoc and thinkyhead committed Apr 29, 2021
1 parent 2a32d14 commit 3c9ffa7
Show file tree
Hide file tree
Showing 20 changed files with 66 additions and 47 deletions.
3 changes: 2 additions & 1 deletion Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@

#if ENABLED(DWIN_CREALITY_LCD)
#include "lcd/dwin/e3v2/dwin.h"
#include "lcd/dwin/dwin_lcd.h"
#include "lcd/dwin/e3v2/rotary_encoder.h"
#endif

Expand Down Expand Up @@ -1476,7 +1475,9 @@ void setup() {
#if ENABLED(DWIN_CREALITY_LCD)
Encoder_Configuration();
HMI_Init();
DWIN_JPG_CacheTo1(Language_English);
HMI_StartFrame(true);
DWIN_StatusChanged(GET_TEXT(WELCOME_MSG));
#endif

#if HAS_SERVICE_INTERVALS && DISABLED(DWIN_CREALITY_LCD)
Expand Down
10 changes: 5 additions & 5 deletions Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ void unified_bed_leveling::shift_mesh_height() {

const int point_num = (GRID_MAX_POINTS) - count + 1;
SERIAL_ECHOLNPAIR("Probing mesh point ", point_num, "/", GRID_MAX_POINTS, ".");
TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), point_num, int(GRID_MAX_POINTS)));
TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), point_num, int(GRID_MAX_POINTS)));

#if HAS_LCD_MENU
if (ui.button_pressed()) {
Expand Down Expand Up @@ -1440,7 +1440,7 @@ void unified_bed_leveling::smart_fill_mesh() {

if (do_3_pt_leveling) {
SERIAL_ECHOLNPGM("Tilting mesh (1/3)");
TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " 1/3"), GET_TEXT(MSG_LCD_TILTING_MESH)));
TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " 1/3"), GET_TEXT(MSG_LCD_TILTING_MESH)));

measured_z = probe.probe_at_point(points[0], PROBE_PT_RAISE, param.V_verbosity);
if (isnan(measured_z))
Expand All @@ -1459,7 +1459,7 @@ void unified_bed_leveling::smart_fill_mesh() {

if (!abort_flag) {
SERIAL_ECHOLNPGM("Tilting mesh (2/3)");
TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " 2/3"), GET_TEXT(MSG_LCD_TILTING_MESH)));
TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " 2/3"), GET_TEXT(MSG_LCD_TILTING_MESH)));

measured_z = probe.probe_at_point(points[1], PROBE_PT_RAISE, param.V_verbosity);
#ifdef VALIDATE_MESH_TILT
Expand All @@ -1479,7 +1479,7 @@ void unified_bed_leveling::smart_fill_mesh() {

if (!abort_flag) {
SERIAL_ECHOLNPGM("Tilting mesh (3/3)");
TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " 3/3"), GET_TEXT(MSG_LCD_TILTING_MESH)));
TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " 3/3"), GET_TEXT(MSG_LCD_TILTING_MESH)));

measured_z = probe.probe_at_point(points[2], PROBE_PT_STOW, param.V_verbosity);
#ifdef VALIDATE_MESH_TILT
Expand Down Expand Up @@ -1520,7 +1520,7 @@ void unified_bed_leveling::smart_fill_mesh() {

if (!abort_flag) {
SERIAL_ECHOLNPAIR("Tilting mesh point ", point_num, "/", total_points, "\n");
TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_LCD_TILTING_MESH), point_num, total_points));
TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_LCD_TILTING_MESH), point_num, total_points));

measured_z = probe.probe_at_point(rpos, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, param.V_verbosity); // TODO: Needs error handling

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/cancel_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void CancelObject::set_active_object(const int8_t obj) {
else
skipping = false;

#if HAS_DISPLAY
#if HAS_STATUS_MESSAGE
if (active_object >= 0)
ui.status_printf_P(0, PSTR(S_FMT " %i"), GET_TEXT(MSG_PRINTING_OBJECT), int(active_object));
else
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/pause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le
// Resume the print job timer if it was running
if (print_job_timer.isPaused()) print_job_timer.start();

TERN_(HAS_DISPLAY, ui.reset_status());
TERN_(HAS_STATUS_MESSAGE, ui.reset_status());
TERN_(HAS_LCD_MENU, ui.return_to_status());
}

Expand Down
8 changes: 4 additions & 4 deletions Marlin/src/gcode/bedlevel/abl/G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include "../../../module/temperature.h"
#endif

#if HAS_DISPLAY
#if HAS_STATUS_MESSAGE
#include "../../../lcd/marlinui.h"
#endif

Expand Down Expand Up @@ -638,7 +638,7 @@ G29_TYPE GcodeSuite::G29() {
if (TERN0(IS_KINEMATIC, !probe.can_reach(probePos))) continue;

if (verbose_level) SERIAL_ECHOLNPAIR("Probing mesh point ", pt_index, "/", abl_points, ".");
TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), int(pt_index), int(abl_points)));
TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), int(pt_index), int(abl_points)));

measured_z = faux ? 0.001f * random(-100, 101) : probe.probe_at_point(probePos, raise_after, verbose_level);

Expand Down Expand Up @@ -683,7 +683,7 @@ G29_TYPE GcodeSuite::G29() {

LOOP_L_N(i, 3) {
if (verbose_level) SERIAL_ECHOLNPAIR("Probing point ", i + 1, "/3.");
TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " %i/3"), GET_TEXT(MSG_PROBING_MESH), int(i + 1)));
TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %i/3"), GET_TEXT(MSG_PROBING_MESH), int(i + 1)));

// Retain the last probe position
probePos = points[i];
Expand All @@ -706,7 +706,7 @@ G29_TYPE GcodeSuite::G29() {

#endif // AUTO_BED_LEVELING_3POINT

TERN_(HAS_DISPLAY, ui.reset_status());
TERN_(HAS_STATUS_MESSAGE, ui.reset_status());

// Stow the probe. No raise for FIX_MOUNTED_PROBE.
if (probe.stow()) {
Expand Down
5 changes: 4 additions & 1 deletion Marlin/src/gcode/bedlevel/mbl/G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ void GcodeSuite::G29() {
// After recording the last point, activate home and activate
mbl_probe_index = -1;
SERIAL_ECHOLNPGM("Mesh probing done.");
TERN_(HAS_STATUS_MESSAGE, ui.set_status(GET_TEXT(MSG_MESH_DONE)));
BUZZ(100, 659);
BUZZ(100, 698);

Expand Down Expand Up @@ -180,8 +181,10 @@ void GcodeSuite::G29() {

} // switch(state)

if (state == MeshNext)
if (state == MeshNext) {
SERIAL_ECHOLNPAIR("MBL G29 point ", _MIN(mbl_probe_index, GRID_MAX_POINTS), " of ", GRID_MAX_POINTS);
if (mbl_probe_index > 0) TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), _MIN(mbl_probe_index, GRID_MAX_POINTS), int(GRID_MAX_POINTS)));
}

report_current_position();
}
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/gcode/calibrate/G34_M422.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ void GcodeSuite::G34() {
bool adjustment_reverse = false;
#endif

#if HAS_DISPLAY
#if HAS_STATUS_MESSAGE
PGM_P const msg_iteration = GET_TEXT(MSG_ITERATION);
const uint8_t iter_str_len = strlen_P(msg_iteration);
#endif
Expand All @@ -204,7 +204,7 @@ void GcodeSuite::G34() {

const int iter = iteration + 1;
SERIAL_ECHOLNPAIR("\nG34 Iteration: ", iter);
#if HAS_DISPLAY
#if HAS_STATUS_MESSAGE
char str[iter_str_len + 2 + 1];
sprintf_P(str, msg_iteration, iter);
ui.set_status(str);
Expand Down Expand Up @@ -290,7 +290,7 @@ void GcodeSuite::G34() {
, " Z3-Z1=", ABS(z_measured[2] - z_measured[0])
#endif
);
#if HAS_DISPLAY
#if HAS_STATUS_MESSAGE
char fstr1[10];
#if NUM_Z_STEPPER_DRIVERS == 2
char msg[6 + (6 + 5) * 1 + 1];
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/gcode/calibrate/M48.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void GcodeSuite::M48() {
float sample_sum = 0.0;

LOOP_L_N(n, n_samples) {
#if HAS_WIRED_LCD
#if HAS_STATUS_MESSAGE
// Display M48 progress in the status bar
ui.status_printf_P(0, PSTR(S_FMT ": %d/%d"), GET_TEXT(MSG_M48_POINT), int(n + 1), int(n_samples));
#endif
Expand Down Expand Up @@ -257,7 +257,7 @@ void GcodeSuite::M48() {
SERIAL_ECHOLNPGM("Finished!");
dev_report(verbose_level > 0, mean, sigma, min, max, true);

#if HAS_WIRED_LCD
#if HAS_STATUS_MESSAGE
// Display M48 results in the status bar
char sigma_str[8];
ui.status_printf_P(0, PSTR(S_FMT ": %s"), GET_TEXT(MSG_M48_DEVIATION), dtostrf(sigma, 2, 6, sigma_str));
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/temp/M104_M109.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void GcodeSuite::M109() {
thermalManager.auto_job_check_timer(true, true);
#endif

#if HAS_DISPLAY
#if HAS_STATUS_MESSAGE
if (thermalManager.isHeatingHotend(target_extruder) || !no_wait_for_cooling)
thermalManager.set_heating_message(target_extruder);
#endif
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@
#endif
#endif

#if EITHER(HAS_DISPLAY, GLOBAL_STATUS_MESSAGE)
#if ANY(HAS_DISPLAY, DWIN_CREALITY_LCD, GLOBAL_STATUS_MESSAGE)
#define HAS_STATUS_MESSAGE 1
#endif

Expand Down
9 changes: 8 additions & 1 deletion Marlin/src/lcd/dwin/e3v2/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ void Draw_Title(const __FlashStringHelper * title) {
}

void Clear_Menu_Area() {
DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, 31, DWIN_WIDTH, STATUS_Y);
DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, 31, DWIN_WIDTH, STATUS_Y - 1);
}

void Clear_Main_Window() {
Expand Down Expand Up @@ -3794,4 +3794,11 @@ void DWIN_CompletedLeveling() {
if (checkkey == Leveling) Goto_MainMenu();
}

void DWIN_StatusChanged(const char *text) {
DWIN_Draw_Rectangle(1, Color_Bg_Blue, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20);
const int8_t x = _MAX(0U, DWIN_WIDTH - strlen_P(text) * MENU_CHR_W) / 2;
DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Blue, x, STATUS_Y + 2, F(text));
DWIN_UpdateLCD();
}

#endif // DWIN_CREALITY_LCD
1 change: 1 addition & 0 deletions Marlin/src/lcd/dwin/e3v2/dwin.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ void HMI_Init();
void DWIN_Update();
void EachMomentUpdate();
void DWIN_HandleScreen();
void DWIN_StatusChanged(const char *text);

inline void DWIN_StartHoming() { HMI_flag.home_flag = true; }

Expand Down
1 change: 1 addition & 0 deletions Marlin/src/lcd/language/language_en.h
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ namespace Language_en {
PROGMEM Language_Str MSG_BILINEAR_LEVELING = _UxGT("Bilinear Leveling");
PROGMEM Language_Str MSG_UBL_LEVELING = _UxGT("Unified Bed Leveling");
PROGMEM Language_Str MSG_MESH_LEVELING = _UxGT("Mesh Leveling");
PROGMEM Language_Str MSG_MESH_DONE = _UxGT("Mesh probing done");
PROGMEM Language_Str MSG_INFO_STATS_MENU = _UxGT("Printer Stats");
PROGMEM Language_Str MSG_INFO_BOARD_MENU = _UxGT("Board Info");
PROGMEM Language_Str MSG_INFO_THERMISTOR_MENU = _UxGT("Thermistors");
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/lcd/lcdprint.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
#define SETCURSOR_RJ(len, row) lcd_moveto(LCD_COL_X_RJ(len), LCD_ROW_Y(row))
#define SETCURSOR_X(col) SETCURSOR(col, _lcdLineNr)
#define SETCURSOR_X_RJ(len) SETCURSOR_RJ(len, _lcdLineNr)
#define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80U)

int lcd_glyph_height();

Expand Down
41 changes: 24 additions & 17 deletions Marlin/src/lcd/marlinui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,16 @@ MarlinUI ui;
#include "../gcode/queue.h"
#include "fontutils.h"
#include "../sd/cardreader.h"
#if EITHER(EXTENSIBLE_UI, DWIN_CREALITY_LCD)
#define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80U)
#endif
#endif

#if ENABLED(DWIN_CREALITY_LCD)
#include "../module/printcounter.h"
#include "../MarlinCore.h"
#include "dwin/e3v2/dwin.h"
#endif

#if HAS_STATUS_MESSAGE
#define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80U)
#endif

#if LCD_HAS_WAIT_FOR_MOVE
Expand All @@ -55,25 +62,24 @@ MarlinUI ui;

constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;

#if HAS_WIRED_LCD
#if ENABLED(STATUS_MESSAGE_SCROLLING)
uint8_t MarlinUI::status_scroll_offset; // = 0
constexpr uint8_t MAX_MESSAGE_LENGTH = _MAX(LONG_FILENAME_LENGTH, MAX_LANG_CHARSIZE * 2 * (LCD_WIDTH));
#if HAS_STATUS_MESSAGE
#if HAS_WIRED_LCD
#if ENABLED(STATUS_MESSAGE_SCROLLING)
uint8_t MarlinUI::status_scroll_offset; // = 0
constexpr uint8_t MAX_MESSAGE_LENGTH = _MAX(LONG_FILENAME_LENGTH, MAX_LANG_CHARSIZE * 2 * (LCD_WIDTH));
#else
constexpr uint8_t MAX_MESSAGE_LENGTH = MAX_LANG_CHARSIZE * (LCD_WIDTH);
#endif
#else
constexpr uint8_t MAX_MESSAGE_LENGTH = MAX_LANG_CHARSIZE * (LCD_WIDTH);
constexpr uint8_t MAX_MESSAGE_LENGTH = 63;
#endif
#elif EITHER(EXTENSIBLE_UI, DWIN_CREALITY_LCD)
constexpr uint8_t MAX_MESSAGE_LENGTH = 63;
#endif

#if EITHER(HAS_WIRED_LCD, EXTENSIBLE_UI)
uint8_t MarlinUI::alert_level; // = 0
char MarlinUI::status_message[MAX_MESSAGE_LENGTH + 1];
uint8_t MarlinUI::alert_level; // = 0
#endif

#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
MarlinUI::progress_t MarlinUI::progress_override; // = 0
#if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME)
#if ENABLED(USE_M73_REMAINING_TIME)
uint32_t MarlinUI::remaining_time;
#endif
#endif
Expand Down Expand Up @@ -1461,6 +1467,7 @@ void MarlinUI::update() {
#endif

TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged(status_message));
TERN_(DWIN_CREALITY_LCD, DWIN_StatusChanged(status_message));
}

#if ENABLED(STATUS_MESSAGE_SCROLLING)
Expand Down Expand Up @@ -1581,7 +1588,7 @@ void MarlinUI::update() {

#endif

#else // !HAS_DISPLAY
#elif !HAS_STATUS_MESSAGE // && !HAS_DISPLAY

//
// Send the status line as a host notification
Expand All @@ -1596,7 +1603,7 @@ void MarlinUI::update() {
TERN(HOST_PROMPT_SUPPORT, host_action_notify_P(message), UNUSED(message));
}

#endif // !HAS_DISPLAY
#endif // !HAS_DISPLAY && !HAS_STATUS_MESSAGE

#if ENABLED(SDSUPPORT)

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/module/endstops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ void Endstops::event_handler() {
if (hit_state == prev_hit_state) return;
prev_hit_state = hit_state;
if (hit_state) {
#if HAS_WIRED_LCD
#if HAS_STATUS_MESSAGE
char chrX = ' ', chrY = ' ', chrZ = ' ', chrP = ' ';
#define _SET_STOP_CHAR(A,C) (chr## A = C)
#else
Expand Down Expand Up @@ -391,7 +391,7 @@ void Endstops::event_handler() {
#endif
SERIAL_EOL();

TERN_(HAS_WIRED_LCD, ui.status_printf_P(0, PSTR(S_FMT " %c %c %c %c"), GET_TEXT(MSG_LCD_ENDSTOPS), chrX, chrY, chrZ, chrP));
TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %c %c %c %c"), GET_TEXT(MSG_LCD_ENDSTOPS), chrX, chrY, chrZ, chrP));

#if BOTH(SD_ABORT_ON_ENDSTOP_HIT, SDSUPPORT)
if (planner.abort_on_endstop_hit) {
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/module/motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#include "../feature/bltouch.h"
#endif

#if HAS_DISPLAY
#if HAS_STATUS_MESSAGE
#include "../lcd/marlinui.h"
#endif

Expand Down Expand Up @@ -1144,7 +1144,7 @@ void prepare_line_to_destination() {
);
SERIAL_ECHO_START();
SERIAL_ECHOLN(msg);
TERN_(HAS_DISPLAY, ui.set_status(msg));
TERN_(HAS_STATUS_MESSAGE, ui.set_status(msg));
return true;
}
return false;
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/module/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2495,7 +2495,7 @@ void Temperature::disable_all_heaters() {
if (singlenozzle_temp[new_tool] && singlenozzle_temp[new_tool] != singlenozzle_temp[old_tool]) {
setTargetHotend(singlenozzle_temp[new_tool], 0);
TERN_(AUTOTEMP, planner.autotemp_update());
TERN_(HAS_DISPLAY, set_heating_message(0));
TERN_(HAS_STATUS_MESSAGE, set_heating_message(0));
(void)wait_for_hotend(0, false); // Wait for heating or cooling
}
}
Expand Down Expand Up @@ -3492,7 +3492,7 @@ void Temperature::tick() {
}
#endif

#if HAS_HOTEND && HAS_DISPLAY
#if HAS_HOTEND && HAS_STATUS_MESSAGE
void Temperature::set_heating_message(const uint8_t e) {
const bool heating = isHeatingHotend(e);
ui.status_printf_P(0,
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/temperature.h
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ class Temperature {
#endif
#endif

#if ENABLED(HAS_DISPLAY)
#if HAS_STATUS_MESSAGE
static void set_heating_message(const uint8_t e);
#endif

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/tool_change.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
#if HAS_MULTI_HOTEND
thermalManager.setTargetHotend(thermalManager.temp_hotend[active_extruder].target, migration_extruder);
TERN_(AUTOTEMP, planner.autotemp_update());
TERN_(HAS_DISPLAY, thermalManager.set_heating_message(0));
TERN_(HAS_STATUS_MESSAGE, thermalManager.set_heating_message(0));
thermalManager.wait_for_hotend(active_extruder);
#endif

Expand Down

0 comments on commit 3c9ffa7

Please sign in to comment.