Improve warning behavior during thermal anomaly
The current code forces any warning to return the user to the status screen in order to show the message. Thermal anomaly warnings can repeat at very short intervals, making menu navigation (to pause/tune the print) impossible. We now check if the message to be displayed is the same and only force a kickback for new messages. This partially reverts https://github.com/prusa3d/Prusa-Firmware/pull/3600 since we need the string to be null terminated for ease of comparison. We pad the status line at display time instead using the new lcd_print_pad() function which achieves the same effect.
This commit is contained in:
parent
d4aeddf90d
commit
b710ca0e58
|
|
@ -528,6 +528,12 @@ void lcd_print(const char* s)
|
|||
while (*s) lcd_write(*(s++));
|
||||
}
|
||||
|
||||
void lcd_print_pad(const char* s, uint8_t len)
|
||||
{
|
||||
while (len-- && *s) lcd_write(*(s++));
|
||||
lcd_space(len);
|
||||
}
|
||||
|
||||
void lcd_print(char c, int base)
|
||||
{
|
||||
lcd_print((long) c, base);
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ extern void lcd_printNumber(unsigned long n, uint8_t base);
|
|||
extern void lcd_printFloat(double number, uint8_t digits);
|
||||
|
||||
extern void lcd_print(const char*);
|
||||
extern void lcd_print_pad(const char*, uint8_t len);
|
||||
extern void lcd_print(char, int = 0);
|
||||
extern void lcd_print(unsigned char, int = 0);
|
||||
extern void lcd_print(int, int = 10);
|
||||
|
|
|
|||
|
|
@ -617,7 +617,7 @@ void lcdui_print_status_line(void)
|
|||
case CustomMsg::M117: // M117 Set the status line message on the LCD
|
||||
case CustomMsg::Status: // Nothing special, print status message normally
|
||||
case CustomMsg::M0Wait: // M0/M1 Wait command working even from SD
|
||||
lcd_print(lcd_status_message);
|
||||
lcd_print_pad(lcd_status_message, LCD_WIDTH);
|
||||
break;
|
||||
case CustomMsg::MeshBedLeveling: // If mesh bed leveling in progress, show the status
|
||||
if (custom_message_state > 10) {
|
||||
|
|
@ -641,10 +641,10 @@ void lcdui_print_status_line(void)
|
|||
}
|
||||
break;
|
||||
case CustomMsg::FilamentLoading: // If loading filament, print status
|
||||
lcd_print(lcd_status_message);
|
||||
lcd_print_pad(lcd_status_message, LCD_WIDTH);
|
||||
break;
|
||||
case CustomMsg::PidCal: // PID tuning in progress
|
||||
lcd_print(lcd_status_message);
|
||||
lcd_print_pad(lcd_status_message, LCD_WIDTH);
|
||||
if (pid_cycle <= pid_number_of_cycles && custom_message_state > 0) {
|
||||
lcd_set_cursor(10, 3);
|
||||
lcd_print(itostr3(pid_cycle));
|
||||
|
|
@ -7482,16 +7482,6 @@ void menu_action_sddirectory(const char* filename)
|
|||
|
||||
/** LCD API **/
|
||||
|
||||
static void lcd_padstatus() {
|
||||
int len = strlen(lcd_status_message);
|
||||
if (len > 0) {
|
||||
while (len < LCD_WIDTH) {
|
||||
lcd_status_message[len++] = ' ';
|
||||
}
|
||||
}
|
||||
lcd_status_message[LCD_WIDTH] = '\0';
|
||||
}
|
||||
|
||||
void ultralcd_init()
|
||||
{
|
||||
{
|
||||
|
|
@ -7526,7 +7516,6 @@ void ultralcd_init()
|
|||
|
||||
// Initialise status line
|
||||
strncpy_P(lcd_status_message, MSG_WELCOME, LCD_WIDTH);
|
||||
lcd_padstatus();
|
||||
}
|
||||
|
||||
void lcd_ignore_click(bool b)
|
||||
|
|
@ -7537,7 +7526,6 @@ void lcd_ignore_click(bool b)
|
|||
|
||||
void lcd_finishstatus() {
|
||||
SERIAL_PROTOCOLLNRPGM(MSG_LCD_STATUS_CHANGED);
|
||||
lcd_padstatus();
|
||||
lcd_draw_update = 2;
|
||||
}
|
||||
|
||||
|
|
@ -7583,12 +7571,18 @@ void lcd_setstatuspgm(const char* message)
|
|||
void lcd_setalertstatus_(const char* message, uint8_t severity, bool progmem)
|
||||
{
|
||||
if (lcd_message_check(severity)) {
|
||||
bool same = !(progmem?
|
||||
strcmp_P(lcd_status_message, message):
|
||||
strcmp(lcd_status_message, message));
|
||||
lcd_updatestatus(message, progmem);
|
||||
lcd_status_message_timeout.start();
|
||||
lcd_status_message_level = severity;
|
||||
custom_message_type = CustomMsg::Status;
|
||||
custom_message_state = 0;
|
||||
lcd_return_to_status();
|
||||
if (!same) {
|
||||
// do not kick the user out of the menus if the message is unchanged
|
||||
lcd_return_to_status();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue