Browse Source

Merge pull request #3622 from leptun/MK3_MMU2_fix2

Mk3 mmu2 fix2
Alex Voinea 2 years ago
parent
commit
97cd0c5f08
4 changed files with 23 additions and 25 deletions
  1. 1 1
      Firmware/Dcodes.cpp
  2. 6 0
      Firmware/lcd.cpp
  3. 1 0
      Firmware/lcd.h
  4. 15 24
      Firmware/ultralcd.cpp

+ 1 - 1
Firmware/Dcodes.cpp

@@ -584,7 +584,7 @@ void dcode_9()
 			if (code_seen('V')) // value to be written as simulated
 			{
 				adc_sim_mask |= (1 << index);
-				adc_values[index] = (((int)code_value()) << 4);
+				adc_values[index] = ((uint16_t)code_value_short() << 4);
 				printf_P(PSTR("ADC%d=%4d\n"), index, adc_values[index] >> 4);
 			}
 		}

+ 6 - 0
Firmware/lcd.cpp

@@ -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);

+ 1 - 0
Firmware/lcd.h

@@ -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);

+ 15 - 24
Firmware/ultralcd.cpp

@@ -235,9 +235,6 @@ static void lcd_cutter_enabled();
 #endif
 static void lcd_babystep_z();
 
-//! Beware: has side effects - forces lcd_draw_update to 2, which means clear the display
-void lcd_finishstatus();
-
 static void lcd_sdcard_menu();
 static void lcd_sheet_menu();
 
@@ -624,8 +621,8 @@ 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);
-            break;
+            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) {
                 lcd_set_cursor(0, 3);
@@ -647,10 +644,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));
@@ -7412,7 +7409,6 @@ static bool check_file(const char* filename) {
 	card.printingHasFinished();
 
 	lcd_setstatuspgm(MSG_WELCOME);
-	lcd_finishstatus();
 	return result;
 }
 
@@ -7499,7 +7495,7 @@ void ultralcd_init()
   lcd_encoder_diff = 0;
 
   // Initialise status line
-  lcd_setstatuspgm(MSG_WELCOME);
+  strncpy_P(lcd_status_message, MSG_WELCOME, LCD_WIDTH);
 }
 
 void lcd_ignore_click(bool b)
@@ -7508,19 +7504,6 @@ void lcd_ignore_click(bool b)
   wait_for_unclick = false;
 }
 
-void lcd_finishstatus() {
-  SERIAL_PROTOCOLLNRPGM(MSG_LCD_STATUS_CHANGED);
-  int len = strlen(lcd_status_message);
-  if (len > 0) {
-    while (len < LCD_WIDTH) {
-      lcd_status_message[len++] = ' ';
-    }
-  }
-  lcd_status_message[LCD_WIDTH] = '\0';
-  lcd_draw_update = 2;
-
-}
-
 static bool lcd_message_check(uint8_t priority)
 {
     // regular priority check
@@ -7543,7 +7526,9 @@ static void lcd_updatestatus(const char *message, bool progmem = false)
         strncpy(lcd_status_message, message, LCD_WIDTH);
 
 	lcd_status_message[LCD_WIDTH] = 0;
-	lcd_finishstatus();
+
+	SERIAL_PROTOCOLLNRPGM(MSG_LCD_STATUS_CHANGED);
+
 	// hack lcd_draw_update to 1, i.e. without clear
 	lcd_draw_update = 1;
 }
@@ -7563,12 +7548,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();
+        }
     }
 }