Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Oct 2, 2022
1 parent 6b8710e commit c8dcf79
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 51 deletions.
26 changes: 13 additions & 13 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1437,22 +1437,22 @@
// Add an 'M73' G-code to set the current percentage
//#define SET_PROGRESS_MANUALLY
#if ENABLED(SET_PROGRESS_MANUALLY)
#define USE_M73_PERCENT // Add 'P' pazrameter to set percentage done, else use Marlin's estimation
#define USE_M73_REMAINING_TIME // Add 'R' parameter to set remaining time, else use Marlin's estimation
//#define USE_M73_INTERACTION_TIME // Add 'C' parameter to set time until next filament change or other user interaction
//#define M73_REPORT // Report M73 values to host
//#define USE_M73_PERCENT // Add 'P' parameter to set percentage done, otherwise use Marlin's estimate
//#define USE_M73_REMAINING_TIME // Add 'R' parameter to set remaining time, otherwise use Marlin's estimate
//#define USE_M73_INTERACTION_TIME // Add 'C' parameter to set time until next filament change or other user interaction
#if ENABLED(USE_M73_INTERACTION_TIME)
#define SHOW_INTERACTION_TIME // Display time until next user interaction ('C' = filament change)
#endif
//#define M73_REPORT // Report M73 values to host
#endif

// LCD Print Progress options, multiple can be rotated depending on screen layout
#if HAS_DISPLAY && EITHER(SDSUPPORT, SET_PROGRESS_MANUALLY)
#define SHOW_PROGRESS_PERCENT // Show print progress percentage (doesn't affect progress bar)
#define SHOW_ELAPSED_TIME // Display elapsed printing time (prefix 'E')
#define SHOW_REMAINING_TIME // Display estimated time to completion (prefix 'R')
#if ENABLED(USE_M73_INTERACTION_TIME)
#define SHOW_INTERACTION_TIME // Display time to next user interaction (prefix 'C', for filament 'C'hange)
#endif
#define SHOW_PROGRESS_PERCENT // Show print progress percentage (doesn't affect progress bar)
#define SHOW_ELAPSED_TIME // Display elapsed printing time (prefix 'E')
//#define SHOW_REMAINING_TIME // Display estimated time to completion (prefix 'R')

//#define PRINT_PROGRESS_SHOW_DECIMALS // Show/report progress with decimal digits, not all UIs support this
//#define PRINT_PROGRESS_SHOW_DECIMALS // Show/report progress with decimal digits, not all UIs support this

#if EITHER(HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
//#define LCD_PROGRESS_BAR // Show a progress bar on HD44780 LCDs for SD printing
Expand Down Expand Up @@ -1802,8 +1802,8 @@
#endif // HAS_MARLINUI_U8GLIB

#if HAS_MARLINUI_U8GLIB || IS_DWIN_MARLINUI
#define MENU_HOLLOW_FRAME // Enable to save many cycles by drawing a hollow frame on Menu Screens
//#define OVERLAY_GFX_REVERSE // Swap the CW/CCW indicators in the graphics overlay
#define MENU_HOLLOW_FRAME // Enable to save many cycles by drawing a hollow frame on Menu Screens
//#define OVERLAY_GFX_REVERSE // Swap the CW/CCW indicators in the graphics overlay
#endif

//
Expand Down
34 changes: 19 additions & 15 deletions Marlin/src/gcode/lcd/M73.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@

/**
* M73: Set percentage complete (for display on LCD)
*
*
* Example:
* M73 P25.63 ; Set progress to 25.63%
* M73 R456 ; Set remaining time to 456 minutes
* M73 C12 ; Set next interaction countdown to 12 minutes
* M73 ; Report current values
*
* Use Prusa-like report format:
*
* Use Prusa-like report format:
* M73 Percent done: ---; Print time remaining in mins: -----; Change in mins: -----;
*
*
* When PRINT_PROGRESS_SHOW_DECIMALS is enabled - reports percent with 100 / 23.4 / 3.45 format
*
*
*/

void GcodeSuite::M73() {
Expand All @@ -67,24 +67,28 @@ void GcodeSuite::M73() {
#if ENABLED(USE_M73_REMAINING_TIME)
if (parser.seenval('R')) ui.set_remaining_time(60 * parser.value_ulong());
#endif

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

#endif

#if ENABLED(M73_REPORT)
SERIAL_ECHO_MSG(" M73 Percent done: ", TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui.get_progress_percent())
#if ENABLED(USE_M73_REMAINING_TIME)
, "; Print time remaining in mins: ", ui.remaining_time / 60
#endif
#if ENABLED(USE_M73_INTERACTION_TIME)
, "; Change in mins: ", ui.interaction_time/60
#endif
, ";");
{
SERIAL_ECHO_MSG(
" M73 Percent done: ",
TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui.get_progress_percent())
#if ENABLED(USE_M73_REMAINING_TIME)
, "%; Time left: ", ui.remaining_time / 60
#endif
#if ENABLED(USE_M73_INTERACTION_TIME)
, "m; Change: ", ui.interaction_time / 60
#endif
, "m"
);
}
#endif
}

#endif // SET_PROGRESS_MANUALLY

4 changes: 2 additions & 2 deletions Marlin/src/lcd/HD44780/marlinui_HD44780.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ void MarlinUI::draw_status_message(const bool blink) {
static uint8_t timepos = TPOFFSET - 6;
static char buffer[14];
static lcd_uint_t pc, pr;

#if ENABLED(SHOW_PROGRESS_PERCENT)
void MarlinUI::stringPercent(){
const uint8_t progress = ui.get_progress_percent();
Expand Down Expand Up @@ -769,7 +769,7 @@ void MarlinUI::draw_status_message(const bool blink) {
lcd_put_u8str(buffer);
}
}
#endif
#endif
#endif //HAS_PRINT_PROGRESS

/**
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/lcd/dogm/status_screen_DOGM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
lcd_put_u8str(value);
}

// Prepare strings for progress display
// Prepare strings for progress display
#if HAS_PRINT_PROGRESS
#define _PRGR_INFO_X(len) (LCD_PIXEL_WIDTH - (len) * (MENU_FONT_WIDTH))
#define PCENTERED 1 // center percent value over progress bar, else align to the right
Expand Down Expand Up @@ -563,7 +563,7 @@ void MarlinUI::draw_status_screen() {
progress_x_pos = TERN(PCENTERED, 77, _PRGR_INFO_X(strlen(progress_string) + 1));
#endif
}

#if ENABLED(SHOW_INTERACTION_TIME)
if (!(interaction_time)) {
interaction_string[0] = '\0';
Expand Down Expand Up @@ -787,7 +787,7 @@ void MarlinUI::draw_status_screen() {
// Progress bar solid part
if (PAGE_CONTAINS(PROGRESS_BAR_Y + 1, PROGRESS_BAR_Y + 2))
u8g.drawBox(PROGRESS_BAR_X + 1, PROGRESS_BAR_Y + 1, progress_bar_solid_width, 2);

// Progress strings
if (PAGE_CONTAINS(EXTRAS_BASELINE - INFO_FONT_ASCENT, EXTRAS_BASELINE - 1))
ui.rotate_progress();
Expand Down
18 changes: 9 additions & 9 deletions Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,26 @@

/** One hotend layout
* ------------------
* |⟱ xxx➜xxx° ✱xxx%
* |⟱ xxx➜xxx° ✱xxx%
* |_ xxx➜xxx° Fxxx%
* ||||||||||R•xxx:xx
* | status string
* | status string
* ------------------
*
*
* hotend temp | fan speed
* bed temp | feedrate
* progress bar| progress time
* status string
*
*
* ****************************
* Two hotends layout
* ------------------
* |⟱ xxx➜xxx° ✱xxx%
* |⟱ xxx➜xxx° ✱xxx%
* |⟱ xxx➜xxx°|||||||
* |_ xxx➜xxx°Rxxx:xx
* | status string
* | status string
* ------------------
*
*
* hotend temp | fan speed
* hotend temp | progress bar
* bed temp | progress time
Expand Down Expand Up @@ -697,9 +697,9 @@ bool ST7920_Lite_Status_Screen::indicators_changed() {
memcpy(&screenstr[2 - LSHIFT], \
TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui8tostr3rj(progress)), \
TERN(PRINT_PROGRESS_SHOW_DECIMALS, 4, 3));
screenstr[(TERN(PRINT_PROGRESS_SHOW_DECIMALS, 6, 5) - LSHIFT)] = '%';
screenstr[(TERN(PRINT_PROGRESS_SHOW_DECIMALS, 6, 5) - LSHIFT)] = '%';
draw_progress_string(PPOS, screenstr);
}
}
}
#endif
#if ENABLED(SHOW_REMAINING_TIME)
Expand Down
4 changes: 1 addition & 3 deletions Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,7 @@ void MarlinUI::draw_status_screen() {
dwin_string.set();
char prefix = ' ';
#if ENABLED(SHOW_REMAINING_TIME)
// i have no idea how this works and no hardwaer to dabble, someone please make it work with global MarlinUI::rotate_progress()
// if (TERN1(ROTATE_PROGRESS_DISPLAY, blink) && print_job_timer.isRunning())
if (blink && print_job_timer.isRunning()) {
if (TERN1(ROTATE_PROGRESS_DISPLAY, blink) && print_job_timer.isRunning()) {
time = get_remaining_time();
prefix = 'R';
}
Expand Down
13 changes: 7 additions & 6 deletions Marlin/src/lcd/marlinui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1725,7 +1725,7 @@ void MarlinUI::init() {
#endif
);
}

void (*const MarlinUI::string_ptr[])() = {
#if ENABLED(SHOW_REMAINING_TIME)
MarlinUI::stringRemain,
Expand All @@ -1740,18 +1740,19 @@ void MarlinUI::init() {
MarlinUI::stringElapsed
#endif
};
#define STRINGS (COUNT_ENABLED(SHOW_PROGRESS_PERCENT, SHOW_ELAPSED_TIME, SHOW_REMAINING_TIME, SHOW_INTERACTION_TIME))
void MarlinUI::rotate_progress(){ // Renew and redraw all enabled progress strings

#define STRINGS COUNT_ENABLED(SHOW_PROGRESS_PERCENT, SHOW_ELAPSED_TIME, SHOW_REMAINING_TIME, SHOW_INTERACTION_TIME)
void MarlinUI::rotate_progress() { // Renew and redraw all enabled progress strings
static bool prev_blink;
static uint8_t i;
if (prev_blink != get_blink()) {
prev_blink = get_blink();
if (++i >= STRINGS) i = 0;
(*string_ptr[i])();
}
};
#endif
}

#endif // HAS_PRINT_PROGRESS

#if ENABLED(SDSUPPORT)

Expand Down

0 comments on commit c8dcf79

Please sign in to comment.