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

🧑‍💻 Status / Host Prompt cleanup #25679

Merged
merged 5 commits into from
Apr 16, 2023
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
7 changes: 5 additions & 2 deletions Marlin/src/feature/host_actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
PROMPT_INFO
};

extern const char CONTINUE_STR[], DISMISS_STR[];

#endif

class HostUI {
Expand Down Expand Up @@ -111,6 +113,9 @@ class HostUI {
static void prompt_do(const PromptReason reason, FSTR_P const pstr, const char extra_char, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr);
static void prompt_do(const PromptReason reason, const char * const cstr, const char extra_char, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr);

static void continue_prompt(FSTR_P const fstr) { prompt_do(PROMPT_USER_CONTINUE, fstr, FPSTR(CONTINUE_STR)); }
static void continue_prompt(const char * const cstr) { prompt_do(PROMPT_USER_CONTINUE, cstr, FPSTR(CONTINUE_STR)); }

static void prompt_open(const PromptReason reason, FSTR_P const pstr, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr) {
if (host_prompt_reason == PROMPT_NOT_DEFINED) prompt_do(reason, pstr, btn1, btn2);
}
Expand All @@ -124,5 +129,3 @@ class HostUI {
};

extern HostUI hostui;

extern const char CONTINUE_STR[], DISMISS_STR[];
6 changes: 3 additions & 3 deletions Marlin/src/feature/mmu/mmu2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -978,10 +978,10 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) {
manage_response(false, false);

if (recover) {
LCD_MESSAGE(MSG_MMU2_EJECT_RECOVER);
LCD_MESSAGE(MSG_MMU2_REMOVE_AND_CLICK);
mmu2_attn_buzz();
TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, F("MMU2 Eject Recover"), FPSTR(CONTINUE_STR)));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("MMU2 Eject Recover")));
TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(GET_TEXT_F(MSG_MMU2_EJECT_RECOVER)));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_MMU2_EJECT_RECOVER)));
TERN_(HAS_RESUME_CONTINUE, wait_for_user_response());
mmu2_attn_buzz(true);

Expand Down
21 changes: 11 additions & 10 deletions Marlin/src/feature/pause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load
KEEPALIVE_STATE(PAUSED_FOR_USER);
wait_for_user = true; // LCD click or M108 will clear this

TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("Load Filament")));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_FILAMENTLOAD)));

#if ENABLED(HOST_PROMPT_SUPPORT)
const char tool = '0' + TERN0(MULTI_FILAMENT_SENSOR, active_extruder);
Expand Down Expand Up @@ -262,7 +262,7 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load
if (show_lcd) ui.pause_show_message(PAUSE_MESSAGE_PURGE);

TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE)));
TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE), FPSTR(CONTINUE_STR)));
TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE)));
wait_for_user = true; // A click or M108 breaks the purge_length loop
for (float purge_count = purge_length; purge_count > 0 && wait_for_user; --purge_count)
unscaled_e_move(1, ADVANCED_PAUSE_PURGE_FEEDRATE);
Expand Down Expand Up @@ -465,7 +465,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 (!do_park) LCD_MESSAGE(MSG_PARK_FAILED);

#if ENABLED(DUAL_X_CARRIAGE)
const int8_t saved_ext = active_extruder;
Expand Down Expand Up @@ -530,7 +530,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep

// Wait for filament insert by user and press button
KEEPALIVE_STATE(PAUSED_FOR_USER);
TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_NOZZLE_PARKED), FPSTR(CONTINUE_STR)));
TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(GET_TEXT_F(MSG_NOZZLE_PARKED)));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_NOZZLE_PARKED)));
wait_for_user = true; // LCD click or M108 will clear this
while (wait_for_user) {
Expand All @@ -554,9 +554,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep

TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_INFO, GET_TEXT_F(MSG_REHEATING)));

TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged(GET_TEXT_F(MSG_REHEATING)));

TERN_(DWIN_LCD_PROUI, LCD_MESSAGE(MSG_REHEATING));
LCD_MESSAGE(MSG_REHEATING);

// Re-enable the heaters if they timed out
HOTEND_LOOP() thermalManager.reset_hotend_idle_timer(e);
Expand All @@ -572,9 +570,12 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep

HOTEND_LOOP() thermalManager.heater_idle[e].start(nozzle_timeout);

TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_REHEATDONE), FPSTR(CONTINUE_STR)));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_REHEATDONE)));
TERN_(DWIN_LCD_PROUI, LCD_MESSAGE(MSG_REHEATDONE));
TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(GET_TEXT_F(MSG_REHEATDONE)));
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_REHEATDONE));
#else
LCD_MESSAGE(MSG_REHEATDONE);
#endif

IF_DISABLED(PAUSE_REHEAT_FAST_RESUME, wait_for_user = true);

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/feature/tmc_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,8 @@
case TMC_STEALTHCHOP: serialprint_truefalse(st.en_pwm_mode()); break;
case TMC_GLOBAL_SCALER:
{
uint16_t value = st.GLOBAL_SCALER();
SERIAL_ECHO(value ? value : 256);
const uint16_t value = st.GLOBAL_SCALER();
SERIAL_ECHO(value ?: 256);
SERIAL_ECHOPGM("/256");
}
break;
Expand Down
36 changes: 14 additions & 22 deletions Marlin/src/gcode/bedlevel/G26.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ float g26_random_deviation = 0.0;
*/
bool user_canceled() {
if (!ui.button_pressed()) return false; // Return if the button isn't pressed
ui.set_status(GET_TEXT_F(MSG_G26_CANCELED), 99);
TERN_(HAS_MARLINUI_MENU, ui.quick_feedback());
LCD_MESSAGE_MAX(MSG_G26_CANCELED);
ui.quick_feedback();
ui.wait_for_release();
return true;
}
Expand Down Expand Up @@ -321,11 +321,9 @@ typedef struct {
#if HAS_HEATED_BED

if (bed_temp > 25) {
#if HAS_WIRED_LCD
ui.set_status(GET_TEXT_F(MSG_G26_HEATING_BED), 99);
ui.quick_feedback();
TERN_(HAS_MARLINUI_MENU, ui.capture());
#endif
LCD_MESSAGE_MAX(MSG_G26_HEATING_BED);
ui.quick_feedback();
TERN_(HAS_MARLINUI_MENU, ui.capture());
thermalManager.setTargetBed(bed_temp);

// Wait for the temperature to stabilize
Expand All @@ -340,20 +338,16 @@ typedef struct {
#endif // HAS_HEATED_BED

// Start heating the active nozzle
#if HAS_WIRED_LCD
ui.set_status(GET_TEXT_F(MSG_G26_HEATING_NOZZLE), 99);
ui.quick_feedback();
#endif
LCD_MESSAGE_MAX(MSG_G26_HEATING_NOZZLE);
ui.quick_feedback();
thermalManager.setTargetHotend(hotend_temp, active_extruder);

// Wait for the temperature to stabilize
if (!thermalManager.wait_for_hotend(active_extruder, true OPTARG(G26_CLICK_CAN_CANCEL, true)))
return G26_ERR;

#if HAS_WIRED_LCD
ui.reset_status();
ui.quick_feedback();
#endif
ui.reset_status();
ui.completion_feedback();

return G26_OK;
}
Expand All @@ -371,7 +365,7 @@ typedef struct {

if (prime_flag == -1) { // The user wants to control how much filament gets purged
ui.capture();
ui.set_status(GET_TEXT_F(MSG_G26_MANUAL_PRIME), 99);
LCD_MESSAGE_MAX(MSG_G26_MANUAL_PRIME);
ui.chirp();

destination = current_position;
Expand All @@ -398,17 +392,15 @@ typedef struct {

ui.wait_for_release();

ui.set_status(GET_TEXT_F(MSG_G26_PRIME_DONE), 99);
LCD_MESSAGE_MAX(MSG_G26_PRIME_DONE);
ui.quick_feedback();
ui.release();
}
else
#endif
{
#if HAS_WIRED_LCD
ui.set_status(GET_TEXT_F(MSG_G26_FIXED_LENGTH), 99);
ui.quick_feedback();
#endif
LCD_MESSAGE_MAX(MSG_G26_FIXED_LENGTH);
ui.quick_feedback();
destination = current_position;
destination.e += prime_length;
prepare_internal_move_to_destination(fr_slow_e);
Expand Down Expand Up @@ -853,7 +845,7 @@ void GcodeSuite::G26() {
} while (--g26_repeats && location.valid());

LEAVE:
ui.set_status(GET_TEXT_F(MSG_G26_LEAVING), -1);
LCD_MESSAGE_MIN(MSG_G26_LEAVING);
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(location, ExtUI::G26_FINISH));

g26.retract_filament(destination);
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/calibrate/M48.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void GcodeSuite::M48() {
};

if (!probe.can_reach(test_position)) {
ui.set_status(GET_TEXT_F(MSG_M48_OUT_OF_BOUNDS), 99);
LCD_MESSAGE_MAX(MSG_M48_OUT_OF_BOUNDS);
SERIAL_ECHOLNPGM("? (X,Y) out of bounds.");
return;
}
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/config/M43.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ void GcodeSuite::M43() {
#if HAS_RESUME_CONTINUE
KEEPALIVE_STATE(PAUSED_FOR_USER);
wait_for_user = true;
TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, F("M43 Waiting..."), FPSTR(CONTINUE_STR)));
TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(F("M43 Waiting...")));
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onUserConfirmRequired(F("M43 Waiting..."));
#else
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/gcode/lcd/M0_M1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ void GcodeSuite::M0_M1() {

#if ENABLED(HOST_PROMPT_SUPPORT)
if (parser.string_arg)
hostui.prompt_do(PROMPT_USER_CONTINUE, parser.string_arg, FPSTR(CONTINUE_STR));
hostui.continue_prompt(parser.string_arg);
else
hostui.prompt_do(PROMPT_USER_CONTINUE, parser.codenum ? F("M1 Stop") : F("M0 Stop"), FPSTR(CONTINUE_STR));
hostui.continue_prompt(parser.codenum ? F("M1 Stop") : F("M0 Stop"));
#endif

TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(ms));
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/sd/M1001.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void GcodeSuite::M1001() {
if (long_print) {
printerEventLEDs.onPrintCompleted();
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_PRINT_DONE)));
TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_PRINT_DONE), FPSTR(CONTINUE_STR)));
TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(GET_TEXT_F(MSG_PRINT_DONE)));
TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(SEC_TO_MS(TERN(HAS_MARLINUI_MENU, PE_LEDS_COMPLETED_TIME, 30))));
printerEventLEDs.onResumeAfterWait();
}
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,14 +629,14 @@ void ST7920_Lite_Status_Screen::draw_position(const xyze_pos_t &pos, const bool
#endif
}
else {
write_byte(alt_label ? alt_label : 'X');
write_byte(alt_label ?: 'X');
write_str(dtostrf(pos.x, -4, 0, str), 4);

write_byte(alt_label ? alt_label : 'Y');
write_byte(alt_label ?: 'Y');
write_str(dtostrf(pos.y, -4, 0, str), 4);
}

write_byte(alt_label ? alt_label : 'Z');
write_byte(alt_label ?: 'Z');
write_str(dtostrf(pos.z, -5, 1, str), 5);
}

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/e3v2/creality/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,7 @@ void Goto_MainMenu() {
DWIN_Frame_TitleCopy(2, 2, 26, 13); // "Home" etc
else {
#ifdef USE_STRING_HEADINGS
Draw_Title(GET_TEXT_F(MSG_MAIN));
Draw_Title(GET_TEXT_F(MSG_MAIN_MENU));
#else
DWIN_Frame_TitleCopy(0, 2, 40, 11); // "Home"
#endif
Expand Down
Loading