diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 09ffc6910c10..0cd3274d8d36 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1139,34 +1139,35 @@ #endif // HAS_LCD_MENU -// Scroll a longer status message into view -#define STATUS_MESSAGE_SCROLLING +#if HAS_DISPLAY + // The timeout (in ms) to return to the status screen from sub-menus + //#define LCD_TIMEOUT_TO_STATUS 15000 -// On the Info Screen, display XY with one decimal place when possible -//#define LCD_DECIMAL_SMALL_XY + #if ENABLED(SHOW_BOOTSCREEN) + #define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s) + #endif -// The timeout (in ms) to return to the status screen from sub-menus -#define LCD_TIMEOUT_TO_STATUS 15000 + // Scroll a longer status message into view + //#define STATUS_MESSAGE_SCROLLING -// Add an 'M73' G-code to set the current percentage -#define LCD_SET_PROGRESS_MANUALLY + // On the Info Screen, display XY with one decimal place when possible + //#define LCD_DECIMAL_SMALL_XY -// Show the E position (filament used) during printing -//#define LCD_SHOW_E_TOTAL + // Add an 'M73' G-code to set the current percentage + //#define LCD_SET_PROGRESS_MANUALLY -#if ENABLED(SHOW_BOOTSCREEN) - #define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s) + // Show the E position (filament used) during printing + //#define LCD_SHOW_E_TOTAL #endif -#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL) - //#define PRINT_PROGRESS_SHOW_DECIMALS // Show progress with decimal digits - #define SHOW_REMAINING_TIME // Display estimated time to completion +#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL, EXTENSIBLE_UI) + //#define SHOW_REMAINING_TIME // Display estimated time to completion #if ENABLED(SHOW_REMAINING_TIME) #define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation #define ROTATE_PROGRESS_DISPLAY // Display (P)rogress, (E)lapsed, and (R)emaining time #endif - #if HAS_MARLINUI_U8GLIB + #if EITHER(HAS_MARLINUI_U8GLIB, EXTENSIBLE_UI) //#define PRINT_PROGRESS_SHOW_DECIMALS // Show progress with decimal digits #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index b56177462f35..a975ac1461b2 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -3211,10 +3211,8 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) #undef _PIN_CONFLICT #endif -#if !HAS_MARLINUI_U8GLIB - #if ENABLED(PRINT_PROGRESS_SHOW_DECIMALS) - #error "PRINT_PROGRESS_SHOW_DECIMALS currently requires a Graphical LCD." - #endif +#if NONE(HAS_MARLINUI_U8GLIB, EXTENSIBLE_UI) && ENABLED(PRINT_PROGRESS_SHOW_DECIMALS) + #error "PRINT_PROGRESS_SHOW_DECIMALS currently requires a Graphical LCD." #endif #if HAS_ADC_BUTTONS && defined(ADC_BUTTON_DEBOUNCE_DELAY) && ADC_BUTTON_DEBOUNCE_DELAY < 16 diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screens.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screens.h index 4a2a407bd762..4388eebae0b1 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screens.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screens.h @@ -277,7 +277,7 @@ class StatusScreen : public BaseScreen, public CachedScreen 0 && current_progress < progress_range + 1; + if (show_progress_bar) { + cmd.tag(0).font(font_medium) + .bgcolor(progress) + .progress(PROGRESSBAR_POS, current_progress, progress_range, OPT_FLAT); + } -#undef GRID_COLS + char progress_str[10]; + sprintf_P(progress_str, + #if ENABLED(PRINT_PROGRESS_SHOW_DECIMALS) + PSTR("%3d.%02d%%"), uint8_t(current_progress / 100), current_progress % 100 + #else + PSTR("%3d%%"), uint8_t(current_progress / 100) + #endif + ); + + #if ENABLED(TOUCH_UI_PORTRAIT) + const uint16_t texts_pos_h = show_progress_bar ? (BTN_H(1)) : (BTN_H(2)); + cmd.font(font_medium) + .tag(7).text(TIME_POS_X, PROGRESSZONE_FIRSTLINE_Y, TIME_POS_W, texts_pos_h, elapsed_str) + #if ENABLED(SHOW_REMAINING_TIME) + .text(REMAINING_POS_X, PROGRESSZONE_FIRSTLINE_Y, REMAINING_POS_W, texts_pos_h, remaining_str) + #endif + .text(PROGRESS_POS_X, PROGRESSZONE_FIRSTLINE_Y, PROGRESS_POS_W, texts_pos_h, progress_str); + #else + cmd.font(font_medium) + .tag(7).text(TIME_POS, elapsed_str) + #if ENABLED(SHOW_REMAINING_TIME) + .text(REMAINING_POS, remaining_str) + #endif + .text(PROGRESS_POS, progress_str); + #endif + } + #undef GRID_COLS +} void StatusScreen::draw_interaction_buttons(draw_mode_t what) { #define GRID_COLS 4 @@ -253,11 +304,11 @@ void StatusScreen::draw_interaction_buttons(draw_mode_t what) { using namespace ExtUI; #if ENABLED(TOUCH_UI_PORTRAIT) - #define MEDIA_BTN_POS BTN_POS(1,8), BTN_SIZE(2,1) - #define MENU_BTN_POS BTN_POS(3,8), BTN_SIZE(2,1) + #define MEDIA_BTN_POS BTN_POS(1,15), BTN_SIZE(2,2) + #define MENU_BTN_POS BTN_POS(3,15), BTN_SIZE(2,2) #else - #define MEDIA_BTN_POS BTN_POS(1,7), BTN_SIZE(2,2) - #define MENU_BTN_POS BTN_POS(3,7), BTN_SIZE(2,2) + #define MEDIA_BTN_POS BTN_POS(1,13), BTN_SIZE(2,4) + #define MENU_BTN_POS BTN_POS(3,13), BTN_SIZE(2,4) #endif const bool has_media = isMediaInserted() && !isPrintingFromMedia(); @@ -278,9 +329,9 @@ void StatusScreen::draw_status_message(draw_mode_t what, const char* message) { #define GRID_COLS 1 #if ENABLED(TOUCH_UI_PORTRAIT) - #define STATUS_POS BTN_POS(1,4), BTN_SIZE(1,1) + #define STATUS_POS BTN_POS(1,7), BTN_SIZE(1,2) #else - #define STATUS_POS BTN_POS(1,3), BTN_SIZE(1,2) + #define STATUS_POS BTN_POS(1,5), BTN_SIZE(1,4) #endif if (what & BACKGROUND) { diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 3bf06a68c24f..7611dbb98a64 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -245,7 +245,7 @@ namespace ExtUI { } #ifdef TOUCH_UI_LCD_TEMP_SCALING - #define GET_TEMP_ADJUSTMENT(A) float(A)/TOUCH_UI_LCD_TEMP_SCALING + #define GET_TEMP_ADJUSTMENT(A) (float(A) / (TOUCH_UI_LCD_TEMP_SCALING)) #else #define GET_TEMP_ADJUSTMENT(A) A #endif @@ -807,10 +807,6 @@ namespace ExtUI { #endif #endif - uint8_t getProgress_percent() { - return ui.get_progress_percent(); - } - uint32_t getProgress_seconds_elapsed() { const duration_t elapsed = print_job_timer.duration(); return elapsed.value; diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index cdf9b4412aa9..5322ac69ce58 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -43,6 +43,7 @@ ****************************************************************************/ #include "../../inc/MarlinConfig.h" +#include "../marlinui.h" namespace ExtUI { @@ -129,9 +130,19 @@ namespace ExtUI { float getTravelAcceleration_mm_s2(); float getFeedrate_percent(); int16_t getFlowPercentage(const extruder_t); - uint8_t getProgress_percent(); + + inline uint8_t getProgress_percent() { return ui.get_progress_percent(); } + + #if HAS_PRINT_PROGRESS_PERMYRIAD + inline uint16_t getProgress_permyriad() { return ui.get_progress_permyriad(); } + #endif + uint32_t getProgress_seconds_elapsed(); + #if ENABLED(SHOW_REMAINING_TIME) + inline uint32_t getProgress_seconds_remaining() { return ui.get_remaining_time(); } + #endif + #if HAS_LEVELING bool getLevelingActive(); void setLevelingActive(const bool); diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 8e968abda0af..e162dbdd2e2c 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -57,6 +57,10 @@ #define MULTI_MANUAL 1 #endif +#if HAS_DISPLAY + #include "../module/printcounter.h" +#endif + #if HAS_WIRED_LCD #include "../MarlinCore.h" @@ -357,11 +361,20 @@ class MarlinUI { static void set_progress(const progress_t p) { progress_override = _MIN(p, 100U * (PROGRESS_SCALE)); } static void set_progress_done() { progress_override = (PROGRESS_MASK + 1U) + 100U * (PROGRESS_SCALE); } static void progress_reset() { if (progress_override & (PROGRESS_MASK + 1U)) set_progress(0); } - #if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME) - static uint32_t remaining_time; - FORCE_INLINE static void set_remaining_time(const uint32_t r) { remaining_time = r; } - FORCE_INLINE static uint32_t get_remaining_time() { return remaining_time; } - FORCE_INLINE static void reset_remaining_time() { set_remaining_time(0); } + #if ENABLED(SHOW_REMAINING_TIME) + static inline uint32_t _calculated_remaining_time() { + const duration_t elapsed = print_job_timer.duration(); + const progress_t progress = _get_progress(); + return elapsed.value * (100 * (PROGRESS_SCALE) - progress) / progress; + } + #if ENABLED(USE_M73_REMAINING_TIME) + static uint32_t remaining_time; + FORCE_INLINE static void set_remaining_time(const uint32_t r) { remaining_time = r; } + FORCE_INLINE static uint32_t get_remaining_time() { return remaining_time ?: _calculated_remaining_time(); } + FORCE_INLINE static void reset_remaining_time() { set_remaining_time(0); } + #else + FORCE_INLINE static uint32_t get_remaining_time() { return _calculated_remaining_time(); } + #endif #endif #endif static progress_t _get_progress();