Merge pull request #4080 from gudnimg/PFW-1504-v2
PFW-1504 fix conflicting UI issues
This commit is contained in:
commit
491d4d2a20
|
|
@ -546,14 +546,14 @@ void lcd_print(const char* s)
|
||||||
while (*s) lcd_write(*(s++));
|
while (*s) lcd_write(*(s++));
|
||||||
}
|
}
|
||||||
|
|
||||||
char lcd_print_pad(const char* s, uint8_t len)
|
uint8_t lcd_print_pad(const char* s, uint8_t len)
|
||||||
{
|
{
|
||||||
while (len && *s) {
|
while (len && *s) {
|
||||||
lcd_write(*(s++));
|
lcd_write(*(s++));
|
||||||
--len;
|
--len;
|
||||||
}
|
}
|
||||||
lcd_space(len);
|
lcd_space(len);
|
||||||
return *s;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t lcd_print_pad_P(const char* s, uint8_t len)
|
uint8_t lcd_print_pad_P(const char* s, uint8_t len)
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ extern void lcd_space(uint8_t n);
|
||||||
extern void lcd_printNumber(unsigned long n, uint8_t base);
|
extern void lcd_printNumber(unsigned long n, uint8_t base);
|
||||||
|
|
||||||
extern void lcd_print(const char*);
|
extern void lcd_print(const char*);
|
||||||
extern char lcd_print_pad(const char* s, uint8_t len);
|
extern uint8_t lcd_print_pad(const char* s, uint8_t len);
|
||||||
|
|
||||||
/// @brief print a string from PROGMEM with left-adjusted padding
|
/// @brief print a string from PROGMEM with left-adjusted padding
|
||||||
/// @param s string from PROGMEM.
|
/// @param s string from PROGMEM.
|
||||||
|
|
|
||||||
|
|
@ -305,6 +305,8 @@ bool MMU2::VerifyFilamentEnteredPTFE() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Disable_E0();
|
Disable_E0();
|
||||||
|
TryLoadUnloadProgressbarEcho();
|
||||||
|
TryLoadUnloadProgressbarDeinit();
|
||||||
|
|
||||||
if (fsensorState) {
|
if (fsensorState) {
|
||||||
IncrementLoadFails();
|
IncrementLoadFails();
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include "mmu2.h"
|
#include "mmu2.h"
|
||||||
|
#include "mmu2_log.h"
|
||||||
#include "mmu2_reporting.h"
|
#include "mmu2_reporting.h"
|
||||||
#include "mmu2_error_converter.h"
|
#include "mmu2_error_converter.h"
|
||||||
#include "mmu2/error_codes.h"
|
#include "mmu2/error_codes.h"
|
||||||
|
|
@ -283,16 +284,29 @@ void ReportProgressHook(CommandInProgress cip, uint16_t ec) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TryLoadUnloadProgressbarInit() {
|
void TryLoadUnloadProgressbarInit() {
|
||||||
// Clear the status line
|
lcd_clearstatus();
|
||||||
lcd_set_cursor(0, 3);
|
}
|
||||||
lcd_space(LCD_WIDTH);
|
|
||||||
|
void TryLoadUnloadProgressbarDeinit() {
|
||||||
|
// Delay the next status message just so
|
||||||
|
// the user can see the results clearly
|
||||||
|
lcd_reset_status_message_timeout();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TryLoadUnloadProgressbarEcho() {
|
||||||
|
char buf[LCD_WIDTH];
|
||||||
|
lcd_getstatus(buf);
|
||||||
|
for (uint8_t i = 0; i < sizeof(buf); i++) {
|
||||||
|
// 0xFF is -1 when converting from unsigned to signed char
|
||||||
|
// If the number is negative, that means filament is present
|
||||||
|
buf[i] = (buf[i] < 0) ? '1' : '0';
|
||||||
|
}
|
||||||
|
MMU2_ECHO_MSGLN(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TryLoadUnloadProgressbar(uint8_t col, bool sensorState) {
|
void TryLoadUnloadProgressbar(uint8_t col, bool sensorState) {
|
||||||
// Set the cursor position each time in case some other
|
lcd_insert_char_into_status(col, sensorState ? '-' : LCD_STR_SOLID_BLOCK[0]);
|
||||||
// part of the firmware changes the cursor position
|
if (!lcd_update_enabled) lcdui_print_status_line();
|
||||||
lcd_putc_at(col, 3, sensorState ? '-' : LCD_STR_SOLID_BLOCK[0]);
|
|
||||||
lcd_reset_status_message_timeout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IncrementLoadFails(){
|
void IncrementLoadFails(){
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,12 @@ void ReportProgressHook(CommandInProgress cip, uint16_t ec);
|
||||||
/// @brief Clear the status line and setup the LCD cursor
|
/// @brief Clear the status line and setup the LCD cursor
|
||||||
void TryLoadUnloadProgressbarInit();
|
void TryLoadUnloadProgressbarInit();
|
||||||
|
|
||||||
|
/// @brief Clear the status line and setup the LCD cursor
|
||||||
|
void TryLoadUnloadProgressbarDeinit();
|
||||||
|
|
||||||
|
/// @brief Report the results to serial
|
||||||
|
void TryLoadUnloadProgressbarEcho();
|
||||||
|
|
||||||
/// @brief Add one block to the progress bar
|
/// @brief Add one block to the progress bar
|
||||||
/// @param col pixel position on the LCD status line, should range from 0 to (LCD_WIDTH - 1)
|
/// @param col pixel position on the LCD status line, should range from 0 to (LCD_WIDTH - 1)
|
||||||
/// @param sensorState if true, filament is not present, else filament is present. This controls which character to render
|
/// @param sensorState if true, filament is not present, else filament is present. This controls which character to render
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@ static float manual_feedrate[] = MANUAL_FEEDRATE;
|
||||||
/* LCD message status */
|
/* LCD message status */
|
||||||
static LongTimer lcd_status_message_timeout;
|
static LongTimer lcd_status_message_timeout;
|
||||||
static uint8_t lcd_status_message_level;
|
static uint8_t lcd_status_message_level;
|
||||||
|
static uint8_t lcd_status_message_idx = 0;
|
||||||
static char lcd_status_message[LCD_WIDTH + 1];
|
static char lcd_status_message[LCD_WIDTH + 1];
|
||||||
|
|
||||||
/* !Configuration settings */
|
/* !Configuration settings */
|
||||||
|
|
@ -542,7 +543,7 @@ void lcdui_print_status_line(void) {
|
||||||
{
|
{
|
||||||
// If printing from SD, show what we are printing
|
// If printing from SD, show what we are printing
|
||||||
const char* longFilenameOLD = (card.longFilename[0] ? card.longFilename : card.filename);
|
const char* longFilenameOLD = (card.longFilename[0] ? card.longFilename : card.filename);
|
||||||
if( lcd_print_pad(&longFilenameOLD[scrollstuff], LCD_WIDTH) )
|
if( lcd_print_pad(&longFilenameOLD[scrollstuff], LCD_WIDTH) == 0)
|
||||||
{
|
{
|
||||||
scrollstuff++;
|
scrollstuff++;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -562,7 +563,11 @@ void lcdui_print_status_line(void) {
|
||||||
case CustomMsg::M0Wait: // M0/M1 Wait command working even from SD
|
case CustomMsg::M0Wait: // M0/M1 Wait command working even from SD
|
||||||
case CustomMsg::FilamentLoading: // If loading filament, print status
|
case CustomMsg::FilamentLoading: // If loading filament, print status
|
||||||
case CustomMsg::MMUProgress: // MMU Progress Codes
|
case CustomMsg::MMUProgress: // MMU Progress Codes
|
||||||
lcd_print_pad(lcd_status_message, LCD_WIDTH);
|
{
|
||||||
|
lcd_set_cursor(lcd_status_message_idx, 3);
|
||||||
|
const uint8_t padding = lcd_print_pad(&lcd_status_message[lcd_status_message_idx], LCD_WIDTH - lcd_status_message_idx);
|
||||||
|
lcd_status_message_idx = LCD_WIDTH - padding;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CustomMsg::MeshBedLeveling: // If mesh bed leveling in progress, show the status
|
case CustomMsg::MeshBedLeveling: // If mesh bed leveling in progress, show the status
|
||||||
if (custom_message_state > 10) {
|
if (custom_message_state > 10) {
|
||||||
|
|
@ -684,6 +689,12 @@ void lcdui_print_status_screen(void)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void lcdui_refresh(uint8_t clear = true)
|
||||||
|
{
|
||||||
|
clear ? lcd_refresh() : lcd_refresh_noclear();
|
||||||
|
lcd_status_message_idx = 0; // Re-draw message from beginning
|
||||||
|
}
|
||||||
|
|
||||||
// Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependent
|
// Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependent
|
||||||
void lcd_status_screen() // NOT static due to using inside "Marlin_main" module ("manage_inactivity()")
|
void lcd_status_screen() // NOT static due to using inside "Marlin_main" module ("manage_inactivity()")
|
||||||
{
|
{
|
||||||
|
|
@ -727,13 +738,15 @@ void lcd_status_screen() // NOT static due to using ins
|
||||||
ReInitLCD++;
|
ReInitLCD++;
|
||||||
if (ReInitLCD == 30)
|
if (ReInitLCD == 30)
|
||||||
{
|
{
|
||||||
lcd_refresh(); // to maybe revive the LCD if static electricity killed it.
|
|
||||||
ReInitLCD = 0 ;
|
ReInitLCD = 0 ;
|
||||||
|
lcdui_refresh();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((ReInitLCD % 10) == 0)
|
if ((ReInitLCD % 10) == 0)
|
||||||
lcd_refresh_noclear(); //to maybe revive the LCD if static electricity killed it.
|
{
|
||||||
|
lcdui_refresh(false); //to maybe revive the LCD if static electricity killed it.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lcdui_print_status_screen();
|
lcdui_print_status_screen();
|
||||||
|
|
@ -988,7 +1001,7 @@ void lcd_commands()
|
||||||
|
|
||||||
void lcd_return_to_status()
|
void lcd_return_to_status()
|
||||||
{
|
{
|
||||||
lcd_refresh(); // to maybe revive the LCD if static electricity killed it.
|
lcdui_refresh(); // to maybe revive the LCD if static electricity killed it.
|
||||||
menu_goto(lcd_status_screen, 0, true);
|
menu_goto(lcd_status_screen, 0, true);
|
||||||
menu_depth = 0;
|
menu_depth = 0;
|
||||||
eFilamentAction = FilamentAction::None; // i.e. non-autoLoad
|
eFilamentAction = FilamentAction::None; // i.e. non-autoLoad
|
||||||
|
|
@ -5759,7 +5772,7 @@ void lcd_sdcard_menu()
|
||||||
if (_md->isDir)
|
if (_md->isDir)
|
||||||
lcd_print(LCD_STR_FOLDER[0]);
|
lcd_print(LCD_STR_FOLDER[0]);
|
||||||
|
|
||||||
if( lcd_print_pad(&_md->scrollPointer[_md->offset], len) )
|
if( lcd_print_pad(&_md->scrollPointer[_md->offset], len) == 0)
|
||||||
{
|
{
|
||||||
_md->lcd_scrollTimer.start();
|
_md->lcd_scrollTimer.start();
|
||||||
_md->offset++;
|
_md->offset++;
|
||||||
|
|
@ -7039,6 +7052,7 @@ static void lcd_updatestatus(const char *message, bool progmem = false)
|
||||||
strncpy(lcd_status_message, message, LCD_WIDTH);
|
strncpy(lcd_status_message, message, LCD_WIDTH);
|
||||||
|
|
||||||
lcd_status_message[LCD_WIDTH] = 0;
|
lcd_status_message[LCD_WIDTH] = 0;
|
||||||
|
lcd_status_message_idx = 0; // Print message from beginning
|
||||||
|
|
||||||
SERIAL_PROTOCOLLNRPGM(MSG_LCD_STATUS_CHANGED);
|
SERIAL_PROTOCOLLNRPGM(MSG_LCD_STATUS_CHANGED);
|
||||||
|
|
||||||
|
|
@ -7052,6 +7066,23 @@ void lcd_setstatus(const char* message)
|
||||||
lcd_updatestatus(message);
|
lcd_updatestatus(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lcd_insert_char_into_status(uint8_t position, const char message)
|
||||||
|
{
|
||||||
|
if (position > LCD_WIDTH - 1) return;
|
||||||
|
lcd_status_message[position] = message;
|
||||||
|
lcd_draw_update = 1; // force redraw
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcd_clearstatus()
|
||||||
|
{
|
||||||
|
memset(lcd_status_message, 0, sizeof(lcd_status_message));
|
||||||
|
lcd_status_message_idx = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcd_getstatus(char buf[LCD_WIDTH]) {
|
||||||
|
strncpy(buf, lcd_status_message, LCD_WIDTH);
|
||||||
|
}
|
||||||
|
|
||||||
void lcd_setstatuspgm(const char* message)
|
void lcd_setstatuspgm(const char* message)
|
||||||
{
|
{
|
||||||
if (lcd_message_check(LCD_STATUS_NONE))
|
if (lcd_message_check(LCD_STATUS_NONE))
|
||||||
|
|
@ -7243,7 +7274,7 @@ void menu_lcd_lcdupdate_func(void)
|
||||||
lcd_return_to_status();
|
lcd_return_to_status();
|
||||||
lcd_draw_update = 2;
|
lcd_draw_update = 2;
|
||||||
}
|
}
|
||||||
if (lcd_draw_update == 2) lcd_clear();
|
if (lcd_draw_update == 2) lcdui_refresh();
|
||||||
if (lcd_draw_update) lcd_draw_update--;
|
if (lcd_draw_update) lcd_draw_update--;
|
||||||
lcd_next_update_millis = _millis() + LCD_UPDATE_INTERVAL;
|
lcd_next_update_millis = _millis() + LCD_UPDATE_INTERVAL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,13 @@ void ultralcd_init();
|
||||||
#define LCD_STATUS_DELAYED_TIMEOUT 4000
|
#define LCD_STATUS_DELAYED_TIMEOUT 4000
|
||||||
|
|
||||||
// Set the current status message (equivalent to LCD_STATUS_NONE)
|
// Set the current status message (equivalent to LCD_STATUS_NONE)
|
||||||
|
void lcdui_print_status_line(void);
|
||||||
|
void lcd_clearstatus();
|
||||||
|
|
||||||
|
/// @brief Copy the contents of lcd_status_message
|
||||||
|
/// @param buf destination buffer
|
||||||
|
void lcd_getstatus(char buf[LCD_WIDTH]);
|
||||||
|
void lcd_insert_char_into_status(uint8_t position, const char message);
|
||||||
void lcd_setstatus(const char* message);
|
void lcd_setstatus(const char* message);
|
||||||
void lcd_setstatuspgm(const char* message);
|
void lcd_setstatuspgm(const char* message);
|
||||||
void lcd_setstatus_serial(const char* message);
|
void lcd_setstatus_serial(const char* message);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue