Skip to content

Commit

Permalink
🎨 Format, use status macros
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Mar 25, 2022
1 parent 4ff0634 commit 8dfdf51
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 31 deletions.
10 changes: 5 additions & 5 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1339,13 +1339,13 @@
#endif

#if EITHER(HAS_DISPLAY, DWIN_LCD_PROUI)
// The timeout (in ms) to return to the status screen from sub-menus
//#define LCD_TIMEOUT_TO_STATUS 15000
// The timeout to return to the status screen from sub-menus
//#define LCD_TIMEOUT_TO_STATUS 15000 // (ms)

#if ENABLED(SHOW_BOOTSCREEN)
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
#if EITHER(HAS_MARLINUI_U8GLIB, TFT_COLOR_UI)
#define BOOT_MARLIN_LOGO_SMALL // Show a smaller Marlin logo on the Boot Screen (saving lots of flash)
#define BOOT_MARLIN_LOGO_SMALL // Show a smaller Marlin logo on the Boot Screen (saving lots of flash)
#endif
#endif

Expand Down Expand Up @@ -3464,7 +3464,7 @@
#define SPINDLE_LASER_USE_PWM // Enable if your controller supports setting the speed/power
#if ENABLED(SPINDLE_LASER_USE_PWM)
#define SPINDLE_LASER_PWM_INVERT false // Set to "true" if the speed/power goes up when you want it to go slower
#define SPINDLE_LASER_FREQUENCY 2500 // (Hz) Spindle/laser frequency (only on supported HALs: AVR, ESP32 and LPC)
#define SPINDLE_LASER_FREQUENCY 2500 // (Hz) Spindle/laser frequency (only on supported HALs: AVR, ESP32, and LPC)
#endif

//#define AIR_EVACUATION // Cutter Vacuum / Laser Blower motor control with G-codes M10-M11
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/lcd/M117.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
void GcodeSuite::M117() {

if (parser.string_arg && parser.string_arg[0])
ui.set_status(parser.string_arg);
ui.set_status(parser.string_arg, true);
else
ui.reset_status();

Expand Down
5 changes: 2 additions & 3 deletions Marlin/src/gcode/temp/M140_M190.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ void GcodeSuite::M140_M190(const bool isM190) {
if (!got_temp) return;

thermalManager.setTargetBed(temp);
thermalManager.isHeatingBed() ? LCD_MESSAGE(MSG_BED_HEATING) : LCD_MESSAGE(MSG_BED_COOLING);

ui.set_status(thermalManager.isHeatingBed() ? GET_TEXT_F(MSG_BED_HEATING) : GET_TEXT_F(MSG_BED_COOLING));

// with PRINTJOB_TIMER_AUTOSTART, M190 can start the timer, and M140 can stop it
// With PRINTJOB_TIMER_AUTOSTART, M190 can start the timer, and M140 can stop it
TERN_(PRINTJOB_TIMER_AUTOSTART, thermalManager.auto_job_check_timer(isM190, !isM190));

if (isM190)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/temp/M192.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void GcodeSuite::M192() {
}

const celsius_t target_temp = parser.value_celsius();
ui.set_status(thermalManager.isProbeBelowTemp(target_temp) ? GET_TEXT_F(MSG_PROBE_HEATING) : GET_TEXT_F(MSG_PROBE_COOLING));
thermalManager.isProbeBelowTemp(target_temp) ? LCD_MESSAGE(MSG_PROBE_HEATING) : LCD_MESSAGE(MSG_PROBE_COOLING);
thermalManager.wait_for_probe(target_temp, no_wait_for_cooling);
}

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/e3v2/proui/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2304,7 +2304,7 @@ TERN(HAS_ONESTEP_LEVELING, float, void) Tram(uint8_t point) {
inLev = true;
zval = probe.probe_at_point(xpos, ypos, PROBE_PT_STOW);
if (isnan(zval))
ui.set_status(F("Position Not Reachable, check offsets"));
LCD_MESSAGE_F("Position Not Reachable, check offsets");
else {
sprintf_P(cmd, PSTR("X:%s, Y:%s, Z:%s"),
dtostrf(xpos, 1, 1, str_1),
Expand Down Expand Up @@ -2336,7 +2336,7 @@ void TramC () { Tram(4); }
void Trammingwizard() {
bed_mesh_t zval = {0};
if (HMI_data.FullManualTramming) {
ui.set_status(F("Disable manual tramming"));
LCD_MESSAGE_F("Disable manual tramming");
return;
}
zval[0][0] = Tram(0);
Expand Down
14 changes: 11 additions & 3 deletions Marlin/src/lcd/marlinui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ void MarlinUI::init() {
// share the same line on the display.
//

#if DISABLED(PROGRESS_MSG_ONCE) || (PROGRESS_MSG_EXPIRE > 0)
#if DISABLED(PROGRESS_MSG_ONCE) || PROGRESS_MSG_EXPIRE > 0
#define GOT_MS
const millis_t ms = millis();
#endif
Expand Down Expand Up @@ -1420,6 +1420,7 @@ void MarlinUI::init() {
#if SERVICE_INTERVAL_3 > 0
static PGMSTR(service3, "> " SERVICE_NAME_3 "!");
#endif

FSTR_P msg;
if (printingIsPaused())
msg = GET_TEXT_F(MSG_PRINT_PAUSED);
Expand Down Expand Up @@ -1450,13 +1451,18 @@ void MarlinUI::init() {
set_status(msg, -1);
}

/**
* Set Status with a fixed string and alert level.
* @param fstr A constant F-string to set as the status.
* @param level Alert level. Negative to ignore and reset the level. Non-zero never expires.
*/
void MarlinUI::set_status(FSTR_P const fstr, int8_t level) {
PGM_P const pstr = FTOP(fstr);
// Alerts block lower priority messages
if (level < 0) level = alert_level = 0;
if (level < alert_level) return;
alert_level = level;

TERN_(HOST_STATUS_NOTIFICATIONS, hostui.notify(fstr));
PGM_P const pstr = FTOP(fstr);

// Since the message is encoded in UTF8 it must
// only be cut on a character boundary.
Expand All @@ -1476,6 +1482,8 @@ void MarlinUI::init() {
strncpy_P(status_message, pstr, maxLen);
status_message[maxLen] = '\0';

TERN_(HOST_STATUS_NOTIFICATIONS, hostui.notify(fstr));

finish_status(level > 0);
}

Expand Down
4 changes: 0 additions & 4 deletions Marlin/src/lcd/marlinui.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@
#define HAS_ENCODER_ACTION 1
#endif

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

#if E_MANUAL > 1
#define MULTI_E_MANUAL 1
#endif
Expand Down
9 changes: 2 additions & 7 deletions Marlin/src/module/motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@
#include "stepper.h"
#include "planner.h"
#include "temperature.h"

#include "../gcode/gcode.h"

#include "../lcd/marlinui.h"
#include "../inc/MarlinConfig.h"

#if IS_SCARA
Expand All @@ -51,10 +50,6 @@
#include "../feature/bltouch.h"
#endif

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

#if HAS_FILAMENT_SENSOR
#include "../feature/runout.h"
#endif
Expand Down Expand Up @@ -1325,7 +1320,7 @@ void prepare_line_to_destination() {
);
SERIAL_ECHO_START();
SERIAL_ECHOLN(msg);
TERN_(HAS_STATUS_MESSAGE, ui.set_status(msg));
ui.set_status(msg);
return true;
}
return false;
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/module/probe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,9 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {
ui.set_status(ds_str, 99);
SERIAL_ECHOLNF(deploy ? GET_EN_TEXT_F(MSG_MANUAL_DEPLOY) : GET_EN_TEXT_F(MSG_MANUAL_STOW));

TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, F("Stow Probe"), FPSTR(CONTINUE_STR)));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("Stow Probe")));
TERN_(DWIN_LCD_PROUI, DWIN_Popup_Confirm(ICON_BLTouch, F("Stow Probe"), FPSTR(CONTINUE_STR)));
TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, ds_str, FPSTR(CONTINUE_STR)));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(ds_str));
TERN_(DWIN_LCD_PROUI, DWIN_Popup_Confirm(ICON_BLTouch, ds_str, FPSTR(CONTINUE_STR)));
TERN_(HAS_RESUME_CONTINUE, wait_for_user_response());
ui.reset_status();

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ volatile bool Temperature::raw_temps_ready = false;

// PID Tuning loop
wait_for_heatup = true; // Can be interrupted with M108
TERN_(HAS_STATUS_MESSAGE, ui.set_status(F("Wait for heat up...")));
LCD_MESSAGE(MSG_HEATING);
while (wait_for_heatup) {

const millis_t ms = millis();
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/sd/cardreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ void CardReader::mount() {
cdroot();
#if ENABLED(USB_FLASH_DRIVE_SUPPORT) || PIN_EXISTS(SD_DETECT)
else if (marlin_state != MF_INITIALIZING)
ui.set_status(GET_TEXT_F(MSG_MEDIA_INIT_FAIL), -1);
LCD_ALERTMESSAGE(MSG_MEDIA_INIT_FAIL);
#endif

ui.refresh();
Expand Down

0 comments on commit 8dfdf51

Please sign in to comment.