@ -1332,59 +1332,16 @@ void MarlinUI::update() {
# endif // HAS_WIRED_LCD
# endif // HAS_WIRED_LCD
# if HAS_DISPLAY
# if HAS_STATUS_MESSAGE
# if ENABLED(EXTENSIBLE_UI)
# include "extui/ui_api.h"
# endif
////////////////////////////////////////////
////////////////////////////////////////////
/////////////// Status Line // //////////////
////////////// Status Message //////////////
////////////////////////////////////////////
////////////////////////////////////////////
# if ENABLED(STATUS_MESSAGE_SCROLLING)
# if ENABLED(EXTENSIBLE_UI)
void MarlinUI : : advance_status_scroll ( ) {
# include "extui/ui_api.h"
// Advance by one UTF8 code-word
if ( status_scroll_offset < utf8_strlen ( status_message ) )
while ( ! START_OF_UTF8_CHAR ( status_message [ + + status_scroll_offset ] ) ) ;
else
status_scroll_offset = 0 ;
}
char * MarlinUI : : status_and_len ( uint8_t & len ) {
char * out = status_message + status_scroll_offset ;
len = utf8_strlen ( out ) ;
return out ;
}
# endif
# endif
void MarlinUI : : finish_status ( const bool persist ) {
# if !(ENABLED(LCD_PROGRESS_BAR) && (PROGRESS_MSG_EXPIRE) > 0)
UNUSED ( persist ) ;
# endif
# if ENABLED(LCD_PROGRESS_BAR) || BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT)
const millis_t ms = millis ( ) ;
# endif
# if ENABLED(LCD_PROGRESS_BAR) && !IS_TFTGLCD_PANEL
progress_bar_ms = ms ;
# if PROGRESS_MSG_EXPIRE > 0
expire_status_ms = persist ? 0 : ms + PROGRESS_MSG_EXPIRE ;
# endif
# endif
# if BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT)
next_filament_display = ms + 5000UL ; // Show status message for 5s
# endif
# if BOTH(HAS_WIRED_LCD, STATUS_MESSAGE_SCROLLING)
status_scroll_offset = 0 ;
# endif
TERN_ ( EXTENSIBLE_UI , ExtUI : : onStatusChanged ( status_message ) ) ;
}
bool MarlinUI : : has_status ( ) { return ( status_message [ 0 ] ! = ' \0 ' ) ; }
bool MarlinUI : : has_status ( ) { return ( status_message [ 0 ] ! = ' \0 ' ) ; }
void MarlinUI : : set_status ( const char * const message , const bool persist ) {
void MarlinUI : : set_status ( const char * const message , const bool persist ) {
@ -1414,16 +1371,45 @@ void MarlinUI::update() {
finish_status ( persist ) ;
finish_status ( persist ) ;
}
}
# include <stdarg.h>
/**
* Reset the status message
*/
void MarlinUI : : reset_status ( const bool no_welcome ) {
# if SERVICE_INTERVAL_1 > 0
static PGMSTR ( service1 , " > " SERVICE_NAME_1 " ! " ) ;
# endif
# if SERVICE_INTERVAL_2 > 0
static PGMSTR ( service2 , " > " SERVICE_NAME_2 " ! " ) ;
# endif
# if SERVICE_INTERVAL_3 > 0
static PGMSTR ( service3 , " > " SERVICE_NAME_3 " ! " ) ;
# endif
PGM_P msg ;
if ( printingIsPaused ( ) )
msg = GET_TEXT ( MSG_PRINT_PAUSED ) ;
# if ENABLED(SDSUPPORT)
else if ( IS_SD_PRINTING ( ) )
return set_status ( card . longest_filename ( ) , true ) ;
# endif
else if ( print_job_timer . isRunning ( ) )
msg = GET_TEXT ( MSG_PRINTING ) ;
void MarlinUI : : status_printf_P ( const uint8_t level , PGM_P const fmt , . . . ) {
# if SERVICE_INTERVAL_1 > 0
if ( level < alert_level ) return ;
else if ( print_job_timer . needsService ( 1 ) ) msg = service1 ;
alert_level = level ;
# endif
va_list args ;
# if SERVICE_INTERVAL_2 > 0
va_start ( args , fmt ) ;
else if ( print_job_timer . needsService ( 2 ) ) msg = service2 ;
vsnprintf_P ( status_message , MAX_MESSAGE_LENGTH , fmt , args ) ;
# endif
va_end ( args ) ;
# if SERVICE_INTERVAL_3 > 0
finish_status ( level > 0 ) ;
else if ( print_job_timer . needsService ( 3 ) ) msg = service3 ;
# endif
else if ( ! no_welcome )
msg = GET_TEXT ( WELCOME_MSG ) ;
else
return ;
set_status_P ( msg , - 1 ) ;
}
}
void MarlinUI : : set_status_P ( PGM_P const message , int8_t level ) {
void MarlinUI : : set_status_P ( PGM_P const message , int8_t level ) {
@ -1459,51 +1445,76 @@ void MarlinUI::update() {
TERN_ ( HAS_LCD_MENU , return_to_status ( ) ) ;
TERN_ ( HAS_LCD_MENU , return_to_status ( ) ) ;
}
}
PGM_P print_paused = GET_TEXT ( MSG_PRINT_PAUSED ) ;
# include <stdarg.h>
/**
void MarlinUI : : status_printf_P ( const uint8_t level , PGM_P const fmt , . . . ) {
* Reset the status message
if ( level < alert_level ) return ;
*/
alert_level = level ;
void MarlinUI : : reset_status ( const bool no_welcome ) {
va_list args ;
PGM_P printing = GET_TEXT ( MSG_PRINTING ) ;
va_start ( args , fmt ) ;
PGM_P welcome = GET_TEXT ( WELCOME_MSG ) ;
vsnprintf_P ( status_message , MAX_MESSAGE_LENGTH , fmt , args ) ;
# if SERVICE_INTERVAL_1 > 0
va_end ( args ) ;
static PGMSTR ( service1 , " > " SERVICE_NAME_1 " ! " ) ;
finish_status ( level > 0 ) ;
# endif
}
# if SERVICE_INTERVAL_2 > 0
static PGMSTR ( service2 , " > " SERVICE_NAME_2 " ! " ) ;
# endif
# if SERVICE_INTERVAL_3 > 0
static PGMSTR ( service3 , " > " SERVICE_NAME_3 " ! " ) ;
# endif
PGM_P msg ;
if ( printingIsPaused ( ) )
msg = print_paused ;
# if ENABLED(SDSUPPORT)
else if ( IS_SD_PRINTING ( ) )
return set_status ( card . longest_filename ( ) , true ) ;
# endif
else if ( print_job_timer . isRunning ( ) )
msg = printing ;
# if SERVICE_INTERVAL_1 > 0
void MarlinUI : : finish_status ( const bool persist ) {
else if ( print_job_timer . needsService ( 1 ) ) msg = service1 ;
# endif
# if SERVICE_INTERVAL_2 > 0
else if ( print_job_timer . needsService ( 2 ) ) msg = service2 ;
# endif
# if SERVICE_INTERVAL_3 > 0
else if ( print_job_timer . needsService ( 3 ) ) msg = service3 ;
# endif
else if ( ! no_welcome )
# if HAS_SPI_LCD
msg = welcome ;
else
return ;
set_status_P ( msg , - 1 ) ;
# if !(ENABLED(LCD_PROGRESS_BAR) && (PROGRESS_MSG_EXPIRE) > 0)
UNUSED ( persist ) ;
# endif
# if ENABLED(LCD_PROGRESS_BAR) || BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT)
const millis_t ms = millis ( ) ;
# endif
# if ENABLED(LCD_PROGRESS_BAR)
progress_bar_ms = ms ;
# if PROGRESS_MSG_EXPIRE > 0
expire_status_ms = persist ? 0 : ms + PROGRESS_MSG_EXPIRE ;
# endif
# endif
# if BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT)
next_filament_display = ms + 5000UL ; // Show status message for 5s
# endif
# if ENABLED(STATUS_MESSAGE_SCROLLING)
status_scroll_offset = 0 ;
# endif
# endif
TERN_ ( EXTENSIBLE_UI , ExtUI : : onStatusChanged ( status_message ) ) ;
}
}
# if ENABLED(STATUS_MESSAGE_SCROLLING)
void MarlinUI : : advance_status_scroll ( ) {
// Advance by one UTF8 code-word
if ( status_scroll_offset < utf8_strlen ( status_message ) )
while ( ! START_OF_UTF8_CHAR ( status_message [ + + status_scroll_offset ] ) ) ;
else
status_scroll_offset = 0 ;
}
char * MarlinUI : : status_and_len ( uint8_t & len ) {
char * out = status_message + status_scroll_offset ;
len = utf8_strlen ( out ) ;
return out ;
}
# endif
# endif
# if HAS_DISPLAY
# if ENABLED(SDSUPPORT)
extern bool wait_for_user , wait_for_heatup ;
# endif
void MarlinUI : : abort_print ( ) {
void MarlinUI : : abort_print ( ) {
# if ENABLED(SDSUPPORT)
# if ENABLED(SDSUPPORT)
wait_for_heatup = wait_for_user = false ;
wait_for_heatup = wait_for_user = false ;
@ -1514,7 +1525,7 @@ void MarlinUI::update() {
# endif
# endif
TERN_ ( HOST_PROMPT_SUPPORT , host_prompt_open ( PROMPT_INFO , PSTR ( " UI Aborted " ) , DISMISS_STR ) ) ;
TERN_ ( HOST_PROMPT_SUPPORT , host_prompt_open ( PROMPT_INFO , PSTR ( " UI Aborted " ) , DISMISS_STR ) ) ;
print_job_timer . stop ( ) ;
print_job_timer . stop ( ) ;
set_status_P ( GET_TEXT ( MSG_PRINT_ABORTED ) ) ;
LCD_MESSAGEPGM ( MSG_PRINT_ABORTED ) ;
TERN_ ( HAS_LCD_MENU , return_to_status ( ) ) ;
TERN_ ( HAS_LCD_MENU , return_to_status ( ) ) ;
}
}
@ -1530,7 +1541,7 @@ void MarlinUI::update() {
TERN_ ( HOST_PROMPT_SUPPORT , host_prompt_open ( PROMPT_PAUSE_RESUME , PSTR ( " UI Pause " ) , PSTR ( " Resume " ) ) ) ;
TERN_ ( HOST_PROMPT_SUPPORT , host_prompt_open ( PROMPT_PAUSE_RESUME , PSTR ( " UI Pause " ) , PSTR ( " Resume " ) ) ) ;
set_status_P ( print_paused ) ;
LCD_MESSAGEPGM ( MSG_PRINT_PAUSED ) ;
# if ENABLED(PARK_HEAD_ON_PAUSE)
# if ENABLED(PARK_HEAD_ON_PAUSE)
TERN_ ( HAS_WIRED_LCD , lcd_pause_show_message ( PAUSE_MESSAGE_PARKING , PAUSE_MODE_PAUSE_PRINT ) ) ; // Show message immediately to let user know about pause in progress
TERN_ ( HAS_WIRED_LCD , lcd_pause_show_message ( PAUSE_MESSAGE_PARKING , PAUSE_MODE_PAUSE_PRINT ) ) ; // Show message immediately to let user know about pause in progress
@ -1615,6 +1626,10 @@ void MarlinUI::update() {
# if ENABLED(SDSUPPORT)
# if ENABLED(SDSUPPORT)
# if ENABLED(EXTENSIBLE_UI)
# include "extui/ui_api.h"
# endif
void MarlinUI : : media_changed ( const uint8_t old_status , const uint8_t status ) {
void MarlinUI : : media_changed ( const uint8_t old_status , const uint8_t status ) {
if ( old_status = = status ) {
if ( old_status = = status ) {
TERN_ ( EXTENSIBLE_UI , ExtUI : : onMediaError ( ) ) ; // Failed to mount/unmount
TERN_ ( EXTENSIBLE_UI , ExtUI : : onMediaError ( ) ) ; // Failed to mount/unmount
@ -1629,7 +1644,7 @@ void MarlinUI::update() {
quick_feedback ( ) ;
quick_feedback ( ) ;
goto_screen ( MEDIA_MENU_GATEWAY ) ;
goto_screen ( MEDIA_MENU_GATEWAY ) ;
# else
# else
set_status_P ( GET_TEXT ( MSG_MEDIA_INSERTED ) ) ;
LCD_MESSAGEPGM ( MSG_MEDIA_INSERTED ) ;
# endif
# endif
}
}
}
}
@ -1637,7 +1652,7 @@ void MarlinUI::update() {
if ( old_status < 2 ) {
if ( old_status < 2 ) {
TERN_ ( EXTENSIBLE_UI , ExtUI : : onMediaRemoved ( ) ) ; // ExtUI response
TERN_ ( EXTENSIBLE_UI , ExtUI : : onMediaRemoved ( ) ) ; // ExtUI response
# if PIN_EXISTS(SD_DETECT)
# if PIN_EXISTS(SD_DETECT)
set_status_P ( GET_TEXT ( MSG_MEDIA_REMOVED ) ) ;
LCD_MESSAGEPGM ( MSG_MEDIA_REMOVED ) ;
# if HAS_LCD_MENU
# if HAS_LCD_MENU
if ( ! defer_return_to_status ) return_to_status ( ) ;
if ( ! defer_return_to_status ) return_to_status ( ) ;
# endif
# endif