Browse Source

Fix and improve LCD value editing display

- Fix: When "100.0" changes to "99.0" the LCD shows "199.0"
- Use 2 rows if needed on character LCD, (allowing longer labels…
Germany, et. al.)
- Known issue: A certain length label combined with a certain value
drawing function could, for example, display 99.0 on 1 line, but 100.0
on two lines. Workaround would be to pass a nominal value size argument.
Scott Lahteine 8 years ago
parent
commit
725d9d9a56
2 changed files with 14 additions and 7 deletions
  1. 11
    6
      Marlin/ultralcd_impl_DOGM.h
  2. 3
    1
      Marlin/ultralcd_impl_HD44780.h

+ 11
- 6
Marlin/ultralcd_impl_DOGM.h View File

@@ -871,7 +871,7 @@ static void lcd_implementation_status_screen() {
871 871
     #if ENABLED(USE_BIG_EDIT_FONT)
872 872
       uint8_t lcd_width, char_width;
873 873
       if (labellen <= LCD_WIDTH_EDIT - 1) {
874
-        if (labellen >= LCD_WIDTH_EDIT - vallen) rows = 2;
874
+        if (labellen + vallen + 2 >= LCD_WIDTH_EDIT) rows = 2;
875 875
         lcd_width = LCD_WIDTH_EDIT + 1;
876 876
         char_width = DOG_CHAR_WIDTH_EDIT;
877 877
         lcd_setFont(FONT_MENU_EDIT);
@@ -890,16 +890,21 @@ static void lcd_implementation_status_screen() {
890 890
     const uint8_t segmentHeight = u8g.getHeight() / (rows + 1); // 1 / (rows+1) = 1/2 or 1/3
891 891
     uint8_t baseline = segmentHeight + (DOG_CHAR_HEIGHT_EDIT + 1) / 2;
892 892
 
893
-    if (PAGE_CONTAINS(baseline + 1 - (DOG_CHAR_HEIGHT_EDIT), baseline)) {
893
+    bool onpage = PAGE_CONTAINS(baseline + 1 - (DOG_CHAR_HEIGHT_EDIT), baseline);
894
+    if (onpage) {
894 895
       u8g.setPrintPos(0, baseline);
895 896
       lcd_printPGM(pstr);
896 897
     }
897 898
 
898 899
     if (value != NULL) {
899
-      baseline += (rows - 1) * segmentHeight;
900
-      if (PAGE_CONTAINS(baseline + 1 - (DOG_CHAR_HEIGHT_EDIT), baseline)) {
901
-        u8g.print(':');
902
-        u8g.setPrintPos((lcd_width - 1 - vallen) * char_width, baseline);
900
+      u8g.print(':');
901
+      if (rows == 2) {
902
+        baseline += segmentHeight;
903
+        onpage = PAGE_CONTAINS(baseline + 1 - (DOG_CHAR_HEIGHT_EDIT), baseline);
904
+      }
905
+      if (onpage) {
906
+        u8g.setPrintPos(((lcd_width - 1) - (vallen + 1)) * char_width, baseline); // Right-justified, leaving padded by spaces
907
+        u8g.print(' '); // overwrite char if value gets shorter
903 908
         lcd_print(value);
904 909
       }
905 910
     }

+ 3
- 1
Marlin/ultralcd_impl_HD44780.h View File

@@ -978,7 +978,9 @@ static void lcd_implementation_status_screen() {
978 978
     lcd_printPGM(pstr);
979 979
     if (value != NULL) {
980 980
       lcd.print(':');
981
-      lcd.setCursor(LCD_WIDTH - lcd_strlen(value), 1);
981
+      const uint8_t valrow = (lcd_strlen_P(pstr) + 1 + lcd_strlen(value) + 1) > (LCD_WIDTH - 2) ? 2 : 1;  // Value on the next row if it won't fit
982
+      lcd.setCursor((LCD_WIDTH - 1) - (lcd_strlen(value) + 1), valrow);                                   // Right-justified, padded by spaces
983
+      lcd.print(' ');                                                                                     // overwrite char if value gets shorter
982 984
       lcd_print(value);
983 985
     }
984 986
   }

Loading…
Cancel
Save