Browse Source

Changes to reduce and simplify

Scott Lahteine 8 years ago
parent
commit
b492e0878d
3 changed files with 190 additions and 235 deletions
  1. 10
    12
      Marlin/ultralcd.cpp
  2. 70
    71
      Marlin/ultralcd_impl_DOGM.h
  3. 110
    152
      Marlin/ultralcd_impl_HD44780.h

+ 10
- 12
Marlin/ultralcd.cpp View File

@@ -789,7 +789,7 @@ void kill_screen(const char* lcd_msg) {
789 789
       encoderPosition = 0;
790 790
       lcd_implementation_drawmenu_static(0, PSTR(MSG_PROGRESS_BAR_TEST), true, true);
791 791
       lcd.setCursor((LCD_WIDTH) / 2 - 2, LCD_HEIGHT - 2);
792
-      lcd.print(itostr3(bar_percent)); lcd.print('%');
792
+      lcd.print(itostr3(bar_percent)); lcd.write('%');
793 793
       lcd.setCursor(0, LCD_HEIGHT - 1); lcd_draw_progress_bar(bar_percent);
794 794
     }
795 795
 
@@ -2144,8 +2144,12 @@ void kill_screen(const char* lcd_msg) {
2144 2144
     void _lcd_ubl_map_homing() {
2145 2145
       if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_HOMING), NULL);
2146 2146
       lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
2147
-      if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS])
2147
+      if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS]) {
2148
+        #if DISABLED(DOGLCD)
2149
+          lcd_set_ubl_map_plot_chars();
2150
+        #endif
2148 2151
         lcd_goto_screen(_lcd_ubl_output_map_lcd);
2152
+      }
2149 2153
     }
2150 2154
 
2151 2155
     /**
@@ -2217,19 +2221,13 @@ void kill_screen(const char* lcd_msg) {
2217 2221
         #if IS_KINEMATIC
2218 2222
           n_edit_pts = 9; //TODO: Delta accessible edit points
2219 2223
         #else
2220
-          if (x_plot < 1 || x_plot >= GRID_MAX_POINTS_X - 1)
2221
-            if (y_plot < 1 || y_plot >= GRID_MAX_POINTS_Y - 1) n_edit_pts = 4; // Corners
2222
-            else n_edit_pts = 6;
2223
-          else if (y_plot < 1 || y_plot >= GRID_MAX_POINTS_Y - 1) n_edit_pts = 6; // Edges
2224
-          else n_edit_pts = 9; // Field
2224
+          const bool xc = WITHIN(x_plot, 1, GRID_MAX_POINTS_X - 2),
2225
+                     yc = WITHIN(y_plot, 1, GRID_MAX_POINTS_Y - 2);
2226
+          n_edit_pts = yc ? (xc ? 9 : 6) : (xc ? 6 : 4); // Corners
2225 2227
         #endif
2226 2228
 
2227 2229
         if (lcdDrawUpdate) {
2228
-          #if ENABLED(DOGLCD)
2229
-            _lcd_ubl_plot_DOGLCD(x_plot, y_plot);
2230
-          #else
2231
-            _lcd_ubl_plot_HD44780(x_plot, y_plot);
2232
-          #endif
2230
+          lcd_implementation_ubl_plot(x_plot, y_plot);
2233 2231
 
2234 2232
           ubl_map_move_to_xy(); // Move to current location
2235 2233
 

+ 70
- 71
Marlin/ultralcd_impl_DOGM.h View File

@@ -688,7 +688,7 @@ static void lcd_implementation_status_screen() {
688 688
 
689 689
   #define STATUS_BASELINE (55 + INFO_FONT_HEIGHT)
690 690
 
691
-  if (PAGE_CONTAINS(STATUS_BASELINE + 1 - INFO_FONT_HEIGHT, STATUS_BASELINE)) {
691
+  if (PAGE_CONTAINS(STATUS_BASELINE - (INFO_FONT_HEIGHT - 1), STATUS_BASELINE)) {
692 692
     u8g.setPrintPos(0, STATUS_BASELINE);
693 693
 
694 694
     #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
@@ -944,89 +944,88 @@ static void lcd_implementation_status_screen() {
944 944
     /**
945 945
      * UBL LCD "radar" map data
946 946
      */
947
-  #define MAP_UPPER_LEFT_CORNER_X 35  // These probably should be moved to the .h file  But for now,
948
-  #define MAP_UPPER_LEFT_CORNER_Y 8  // it is easier to play with things having them here
949
-  #define MAP_MAX_PIXELS_X        53
950
-  #define MAP_MAX_PIXELS_Y        49
951
-
952
-    void _lcd_ubl_plot_DOGLCD(uint8_t x_plot, uint8_t y_plot) {
953
-      uint8_t i, j, x_offset, y_offset, x_map_pixels, y_map_pixels;
954
-      uint8_t pixels_per_X_mesh_pnt, pixels_per_Y_mesh_pnt, inverted_y;
955
-
956
-      /*********************************************************/
957
-      /************ Scale the box pixels appropriately *********/
958
-      /*********************************************************/
959
-      x_map_pixels = ((MAP_MAX_PIXELS_X - 4) / GRID_MAX_POINTS_X) * GRID_MAX_POINTS_X;
960
-      y_map_pixels = ((MAP_MAX_PIXELS_Y - 4) / GRID_MAX_POINTS_Y) * GRID_MAX_POINTS_Y;
961
-
962
-      pixels_per_X_mesh_pnt = x_map_pixels / GRID_MAX_POINTS_X;
963
-      pixels_per_Y_mesh_pnt = y_map_pixels / GRID_MAX_POINTS_Y;
964
-
965
-      x_offset = MAP_UPPER_LEFT_CORNER_X + 1 + (MAP_MAX_PIXELS_X-x_map_pixels-2)/2;
966
-      y_offset = MAP_UPPER_LEFT_CORNER_Y + 1 + (MAP_MAX_PIXELS_Y-y_map_pixels-2)/2;
967
-
968
-      /*********************************************************/
969
-      /************ Clear the Mesh Map Box**********************/
970
-      /*********************************************************/
971
-
972
-      u8g.setColorIndex(1);  // First draw the bigger box in White so we have a border around the mesh map box
973
-      u8g.drawBox(x_offset-2, y_offset-2, x_map_pixels+4, y_map_pixels+4);
974
-
975
-      u8g.setColorIndex(0);  // Now actually clear the mesh map box
976
-      u8g.drawBox(x_offset, y_offset, x_map_pixels, y_map_pixels);
947
+    #define MAP_UPPER_LEFT_CORNER_X 35  // These probably should be moved to the .h file  But for now,
948
+    #define MAP_UPPER_LEFT_CORNER_Y  8  // it is easier to play with things having them here
949
+    #define MAP_MAX_PIXELS_X        53
950
+    #define MAP_MAX_PIXELS_Y        49
951
+
952
+    void lcd_implementation_ubl_plot(const uint8_t x_plot, const uint8_t y_plot) {
953
+      // Scale the box pixels appropriately
954
+      uint8_t x_map_pixels = ((MAP_MAX_PIXELS_X - 4) / (GRID_MAX_POINTS_X)) * (GRID_MAX_POINTS_X),
955
+              y_map_pixels = ((MAP_MAX_PIXELS_Y - 4) / (GRID_MAX_POINTS_Y)) * (GRID_MAX_POINTS_Y),
956
+
957
+              pixels_per_X_mesh_pnt = x_map_pixels / (GRID_MAX_POINTS_X),
958
+              pixels_per_Y_mesh_pnt = y_map_pixels / (GRID_MAX_POINTS_Y),
959
+
960
+              x_offset = MAP_UPPER_LEFT_CORNER_X + 1 + (MAP_MAX_PIXELS_X - x_map_pixels - 2) / 2,
961
+              y_offset = MAP_UPPER_LEFT_CORNER_Y + 1 + (MAP_MAX_PIXELS_Y - y_map_pixels - 2) / 2;
962
+
963
+      // Clear the Mesh Map
964
+
965
+      if (PAGE_CONTAINS(y_offset - 2, y_offset + y_map_pixels + 4)) {
966
+        u8g.setColorIndex(1);  // First draw the bigger box in White so we have a border around the mesh map box
967
+        u8g.drawBox(x_offset - 2, y_offset - 2, x_map_pixels + 4, y_map_pixels + 4);
968
+        if (PAGE_CONTAINS(y_offset, y_offset + y_map_pixels)) {
969
+          u8g.setColorIndex(0);  // Now actually clear the mesh map box
970
+          u8g.drawBox(x_offset, y_offset, x_map_pixels, y_map_pixels);
971
+        }
972
+      }
977 973
 
978
-      /*********************************************************/
979
-      /************ Display Mesh Point Locations ***************/
980
-      /*********************************************************/
974
+      // Display Mesh Point Locations
981 975
 
982 976
       u8g.setColorIndex(1);
983
-      for (i = 0; i < GRID_MAX_POINTS_X; i++) {
984
-        for (j = 0; j < GRID_MAX_POINTS_Y; j++) {
985
-          u8g.drawBox(x_offset+i*pixels_per_X_mesh_pnt+pixels_per_X_mesh_pnt/2,  
986
-                      y_offset+j*pixels_per_Y_mesh_pnt+pixels_per_Y_mesh_pnt/2, 1, 1);
987
-        }
988
-      }
977
+      const uint8_t sx = x_offset + pixels_per_X_mesh_pnt / 2;
978
+            uint8_t  y = y_offset + pixels_per_Y_mesh_pnt / 2;
979
+      for (uint8_t j = 0; j < GRID_MAX_POINTS_Y; j++, y += pixels_per_Y_mesh_pnt)
980
+        if (PAGE_CONTAINS(y, y))
981
+          for (uint8_t i = 0, x = sx; i < GRID_MAX_POINTS_X; i++, x += pixels_per_X_mesh_pnt)
982
+            u8g.drawBox(sx, y, 1, 1);
989 983
 
990
-      /*********************************************************/
991
-      /************ Fill in the Specified Mesh Point ***********/
992
-      /*********************************************************/
984
+      // Fill in the Specified Mesh Point
993 985
 
994
-      inverted_y = GRID_MAX_POINTS_Y - y_plot - 1;    // The origin is typically in the lower right corner.  We need to
995
-                                                      // invert the Y to get it to plot in the right location.
996
-      u8g.drawBox(x_offset+x_plot*pixels_per_X_mesh_pnt, y_offset+inverted_y*pixels_per_Y_mesh_pnt, 
997
-                    pixels_per_X_mesh_pnt, pixels_per_Y_mesh_pnt);
986
+      uint8_t inverted_y = GRID_MAX_POINTS_Y - y_plot - 1;  // The origin is typically in the lower right corner.  We need to
987
+                                                            // invert the Y to get it to plot in the right location.
998 988
 
999
-      /*********************************************************/
1000
-      /************** Put Relevent Text on Display *************/
1001
-      /*********************************************************/
989
+      const uint8_t by = y_offset + inverted_y * pixels_per_Y_mesh_pnt;
990
+      if (PAGE_CONTAINS(by, by + pixels_per_Y_mesh_pnt))
991
+        u8g.drawBox(
992
+          x_offset + x_plot * pixels_per_X_mesh_pnt, by,
993
+          pixels_per_X_mesh_pnt, pixels_per_Y_mesh_pnt
994
+        );
995
+
996
+      // Put Relevant Text on Display
1002 997
 
1003 998
       // Show X and Y positions at top of screen
1004 999
       u8g.setColorIndex(1);
1005
-      u8g.setPrintPos(5, 7);
1006
-      lcd_print("X:");
1007
-      lcd_print(ftostr32(LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]))));
1008
-      u8g.setPrintPos(74, 7);
1009
-      lcd_print("Y:");
1010
-      lcd_print(ftostr32(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]))));
1000
+      if (PAGE_UNDER(7)) {
1001
+        u8g.setPrintPos(5, 7);
1002
+        lcd_print("X:");
1003
+        lcd_print(ftostr32(LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]))));
1004
+        u8g.setPrintPos(74, 7);
1005
+        lcd_print("Y:");
1006
+        lcd_print(ftostr32(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]))));
1007
+      }
1011 1008
 
1012 1009
       // Print plot position
1013
-      u8g.setPrintPos(5, 64);
1014
-      lcd_print("(");
1015
-      u8g.print(x_plot);
1016
-      lcd_print(",");
1017
-      u8g.print(y_plot);
1018
-      lcd_print(")");
1019
-
1020
-      // Show the location value
1021
-      u8g.setPrintPos(74, 64);
1022
-      lcd_print("Z:");
1023
-      if (!isnan(ubl.z_values[x_plot][y_plot])) {
1024
-        lcd_print(ftostr43sign(ubl.z_values[x_plot][y_plot]));
1025
-      }
1026
-      else {
1027
-        lcd_print(" -----");
1010
+      if (PAGE_CONTAINS(64 - (INFO_FONT_HEIGHT - 1), 64)) {
1011
+        u8g.setPrintPos(5, 64);
1012
+        lcd_print('(');
1013
+        u8g.print(x_plot);
1014
+        lcd_print(',');
1015
+        u8g.print(y_plot);
1016
+        lcd_print(')');
1017
+
1018
+        // Show the location value
1019
+        u8g.setPrintPos(74, 64);
1020
+        lcd_print("Z:");
1021
+        if (!isnan(ubl.z_values[x_plot][y_plot]))
1022
+          lcd_print(ftostr43sign(ubl.z_values[x_plot][y_plot]));
1023
+        else
1024
+          lcd_printPGM(PSTR(" -----"));
1028 1025
       }
1026
+
1029 1027
     }
1028
+
1030 1029
   #endif // AUTO_BED_LEVELING_UBL
1031 1030
 
1032 1031
 #endif // ULTIPANEL

+ 110
- 152
Marlin/ultralcd_impl_HD44780.h View File

@@ -421,7 +421,7 @@ void lcd_printPGM_utf(const char *str, uint8_t n=LCD_WIDTH) {
421 421
   void lcd_erase_line(const int16_t line) {
422 422
     lcd.setCursor(0, line);
423 423
     for (uint8_t i = LCD_WIDTH + 1; --i;)
424
-      lcd.print(' ');
424
+      lcd.write(' ');
425 425
   }
426 426
 
427 427
   // Scroll the PSTR 'text' in a 'len' wide field for 'time' milliseconds at position col,line
@@ -438,9 +438,9 @@ void lcd_printPGM_utf(const char *str, uint8_t n=LCD_WIDTH) {
438 438
 
439 439
   static void logo_lines(const char* const extra) {
440 440
     int16_t indent = (LCD_WIDTH - 8 - lcd_strlen_P(extra)) / 2;
441
-    lcd.setCursor(indent, 0); lcd.print('\x00'); lcd_printPGM(PSTR( "------" ));  lcd.print('\x01');
441
+    lcd.setCursor(indent, 0); lcd.print('\x00'); lcd_printPGM(PSTR( "------" ));  lcd.write('\x01');
442 442
     lcd.setCursor(indent, 1);                    lcd_printPGM(PSTR("|Marlin|"));  lcd_printPGM(extra);
443
-    lcd.setCursor(indent, 2); lcd.print('\x02'); lcd_printPGM(PSTR( "------" ));  lcd.print('\x03');
443
+    lcd.setCursor(indent, 2); lcd.write('\x02'); lcd_printPGM(PSTR( "------" ));  lcd.write('\x03');
444 444
   }
445 445
 
446 446
   void bootscreen() {
@@ -581,11 +581,11 @@ FORCE_INLINE void _draw_axis_label(const AxisEnum axis, const char* const pstr,
581 581
     lcd_printPGM(pstr);
582 582
   else {
583 583
     if (!axis_homed[axis])
584
-      lcd.print('?');
584
+      lcd.write('?');
585 585
     else {
586 586
       #if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
587 587
         if (!axis_known_position[axis])
588
-          lcd.print(' ');
588
+          lcd.write(' ');
589 589
         else
590 590
       #endif
591 591
       lcd_printPGM(pstr);
@@ -602,7 +602,7 @@ FORCE_INLINE void _draw_heater_status(const int8_t heater, const char prefix, co
602 602
   if (prefix >= 0) lcd.print(prefix);
603 603
 
604 604
   lcd.print(itostr3(t1 + 0.5));
605
-  lcd.print('/');
605
+  lcd.write('/');
606 606
 
607 607
   #if HEATER_IDLE_HANDLER
608 608
     const bool is_idle = (!isBed ? thermalManager.is_heater_idle(heater) :
@@ -614,9 +614,9 @@ FORCE_INLINE void _draw_heater_status(const int8_t heater, const char prefix, co
614 614
     );
615 615
 
616 616
     if (!blink && is_idle) {
617
-      lcd.print(' ');
618
-      if (t2 >= 10) lcd.print(' ');
619
-      if (t2 >= 100) lcd.print(' ');
617
+      lcd.write(' ');
618
+      if (t2 >= 10) lcd.write(' ');
619
+      if (t2 >= 100) lcd.write(' ');
620 620
     }
621 621
     else
622 622
   #endif
@@ -624,8 +624,8 @@ FORCE_INLINE void _draw_heater_status(const int8_t heater, const char prefix, co
624 624
 
625 625
   if (prefix >= 0) {
626 626
     lcd.print((char)LCD_DEGREE_CHAR);
627
-    lcd.print(' ');
628
-    if (t2 < 10) lcd.print(' ');
627
+    lcd.write(' ');
628
+    if (t2 < 10) lcd.write(' ');
629 629
   }
630 630
 }
631 631
 
@@ -742,7 +742,7 @@ static void lcd_implementation_status_screen() {
742 742
           lcd.print(itostr3(card.percentDone()));
743 743
         else
744 744
           lcd_printPGM(PSTR("---"));
745
-          lcd.print('%');
745
+          lcd.write('%');
746 746
       #endif // SDSUPPORT
747 747
 
748 748
     #else // LCD_WIDTH >= 20
@@ -764,7 +764,7 @@ static void lcd_implementation_status_screen() {
764 764
         _draw_axis_label(X_AXIS, PSTR(MSG_X), blink);
765 765
         lcd.print(ftostr4sign(current_position[X_AXIS]));
766 766
 
767
-        lcd.print(' ');
767
+        lcd.write(' ');
768 768
 
769 769
         _draw_axis_label(Y_AXIS, PSTR(MSG_Y), blink);
770 770
         lcd.print(ftostr4sign(current_position[Y_AXIS]));
@@ -788,7 +788,7 @@ static void lcd_implementation_status_screen() {
788 788
     lcd.setCursor(0, 2);
789 789
     lcd.print((char)LCD_FEEDRATE_CHAR);
790 790
     lcd.print(itostr3(feedrate_percentage));
791
-    lcd.print('%');
791
+    lcd.write('%');
792 792
 
793 793
     #if LCD_WIDTH >= 20 && ENABLED(SDSUPPORT)
794 794
 
@@ -798,7 +798,7 @@ static void lcd_implementation_status_screen() {
798 798
         lcd.print(itostr3(card.percentDone()));
799 799
       else
800 800
         lcd_printPGM(PSTR("---"));
801
-      lcd.print('%');
801
+      lcd.write('%');
802 802
 
803 803
     #endif // LCD_WIDTH >= 20 && SDSUPPORT
804 804
 
@@ -837,7 +837,7 @@ static void lcd_implementation_status_screen() {
837 837
       lcd.print(ftostr12ns(filament_width_meas));
838 838
       lcd_printPGM(PSTR(" V"));
839 839
       lcd.print(itostr3(100.0 * volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
840
-      lcd.print('%');
840
+      lcd.write('%');
841 841
       return;
842 842
     }
843 843
 
@@ -858,10 +858,10 @@ static void lcd_implementation_status_screen() {
858 858
           lcd_print_utf(stat);                                  // The string leaves space
859 859
           chars -= slen - status_scroll_pos;                    // Amount of space left
860 860
         }
861
-        lcd.print('.');                                         // Always at 1+ spaces left, draw a dot
861
+        lcd.write('.');                                         // Always at 1+ spaces left, draw a dot
862 862
         if (--chars) {
863 863
           if (status_scroll_pos < slen + 1)                     // Draw a second dot if there's space
864
-            --chars, lcd.print('.');
864
+            --chars, lcd.write('.');
865 865
           if (chars) lcd_print_utf(lcd_status_message, chars);  // Print a second copy of the message
866 866
         }
867 867
       }
@@ -897,7 +897,7 @@ static void lcd_implementation_status_screen() {
897 897
     lcd.setCursor(0, row);
898 898
     if (center && !valstr) {
899 899
       int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2;
900
-      while (--pad >= 0) { lcd.print(' '); n--; }
900
+      while (--pad >= 0) { lcd.write(' '); n--; }
901 901
     }
902 902
     while (n > 0 && (c = pgm_read_byte(pstr))) {
903 903
       n -= charset_mapper(c);
@@ -907,7 +907,7 @@ static void lcd_implementation_status_screen() {
907 907
       n -= charset_mapper(c);
908 908
       valstr++;
909 909
     }
910
-    while (n-- > 0) lcd.print(' ');
910
+    while (n-- > 0) lcd.write(' ');
911 911
   }
912 912
 
913 913
   static void lcd_implementation_drawmenu_generic(const bool sel, const uint8_t row, const char* pstr, const char pre_char, const char post_char) {
@@ -919,7 +919,7 @@ static void lcd_implementation_status_screen() {
919 919
       n -= charset_mapper(c);
920 920
       pstr++;
921 921
     }
922
-    while (n--) lcd.print(' ');
922
+    while (n--) lcd.write(' ');
923 923
     lcd.print(post_char);
924 924
   }
925 925
 
@@ -932,8 +932,8 @@ static void lcd_implementation_status_screen() {
932 932
       n -= charset_mapper(c);
933 933
       pstr++;
934 934
     }
935
-    lcd.print(':');
936
-    while (n--) lcd.print(' ');
935
+    lcd.write(':');
936
+    while (n--) lcd.write(' ');
937 937
     lcd_print(data);
938 938
   }
939 939
   static void lcd_implementation_drawmenu_setting_edit_generic_P(const bool sel, const uint8_t row, const char* pstr, const char pre_char, const char* const data) {
@@ -945,8 +945,8 @@ static void lcd_implementation_status_screen() {
945 945
       n -= charset_mapper(c);
946 946
       pstr++;
947 947
     }
948
-    lcd.print(':');
949
-    while (n--) lcd.print(' ');
948
+    lcd.write(':');
949
+    while (n--) lcd.write(' ');
950 950
     lcd_printPGM(data);
951 951
   }
952 952
 
@@ -981,10 +981,10 @@ static void lcd_implementation_status_screen() {
981 981
     lcd.setCursor(1, 1);
982 982
     lcd_printPGM(pstr);
983 983
     if (value != NULL) {
984
-      lcd.print(':');
984
+      lcd.write(':');
985 985
       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
986 986
       lcd.setCursor((LCD_WIDTH - 1) - (lcd_strlen(value) + 1), valrow);                                   // Right-justified, padded by spaces
987
-      lcd.print(' ');                                                                                     // overwrite char if value gets shorter
987
+      lcd.write(' ');                                                                                     // overwrite char if value gets shorter
988 988
       lcd_print(value);
989 989
     }
990 990
   }
@@ -1005,7 +1005,7 @@ static void lcd_implementation_status_screen() {
1005 1005
         n -= charset_mapper(c);
1006 1006
         filename++;
1007 1007
       }
1008
-      while (n--) lcd.print(' ');
1008
+      while (n--) lcd.write(' ');
1009 1009
       lcd.print(post_char);
1010 1010
     }
1011 1011
 
@@ -1083,7 +1083,7 @@ static void lcd_implementation_status_screen() {
1083 1083
 
1084 1084
 #endif // LCD_HAS_STATUS_INDICATORS
1085 1085
 
1086
-#ifdef AUTO_BED_LEVELING_UBL
1086
+#if ENABLED(AUTO_BED_LEVELING_UBL)
1087 1087
 
1088 1088
     /* 
1089 1089
      * These are just basic data for the 20x4 LCD work that
@@ -1111,75 +1111,10 @@ static void lcd_implementation_status_screen() {
1111 1111
            | +-------+  Z:00.000|
1112 1112
     */
1113 1113
 
1114
-    void _lcd_ubl_plot_HD44780(uint8_t x_plot, uint8_t y_plot) {
1115
-
1116
-      uint8_t lcd_w_pos;
1117
-
1118
-      #if LCD_WIDTH < 20
1119
-        lcd_w_pos = 8;
1120
-      #else
1121
-        lcd_w_pos = 12;
1122
-      #endif
1123
-
1124
-      #if LCD_HEIGHT < 3
1125
-
1126
-        /*
1127
-         *** 16x2 or 20x2 display **
1128
-         * 
1129
-         * Show X and Y positions
1130
-         */
1131
-        #if LCD_WIDTH < 20
1132
-          lcd.setCursor(0, 0);
1133
-          lcd.print("X");
1134
-        #else
1135
-          lcd.setCursor(1, 0);
1136
-          lcd.print("X:");
1137
-        #endif
1138
-        lcd.print(ftostr32(LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]))));
1139
-
1140
-        lcd.setCursor(lcd_w_pos, 0);
1141
-        #if LCD_WIDTH < 20
1142
-          lcd.print("Y");
1143
-        #else
1144
-          lcd.print("Y:");
1145
-        #endif
1146
-        lcd.print(ftostr32(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]))));
1147
-
1148
-        /*
1149
-         * Print plot position
1150
-         */
1151
-        #if LCD_WIDTH < 20
1152
-          lcd.setCursor(0, 1);
1153
-        #else
1154
-          lcd.setCursor(1, 1);
1155
-        #endif
1156
-        lcd.print("(");
1157
-        lcd.print(x_plot);
1158
-        lcd.print(",");
1159
-        lcd.print(y_plot);
1160
-        lcd.print(")");
1161
-
1162
-        /*
1163
-         * Print Z values
1164
-         */
1165
-        lcd.setCursor(lcd_w_pos, 1);
1166
-        #if LCD_WIDTH < 20
1167
-          lcd.print("Z");
1168
-        #else
1169
-          lcd.print("Z:");
1170
-        #endif
1171
-        if (!isnan(ubl.z_values[x_plot][y_plot])) {
1172
-          lcd.print(ftostr43sign(ubl.z_values[x_plot][y_plot]));
1173
-        }
1174
-        else {
1175
-          lcd.print(" -----");
1176
-        }
1177
-
1178
-      #elif LCD_HEIGHT > 3
1179
-
1114
+    void lcd_set_ubl_map_plot_chars() {
1115
+      #if LCD_HEIGHT > 3
1180 1116
         //#include "_ubl_lcd_map_characters.h"
1181
-
1182
-        const static PROGMEM byte _lcd_box_top[8] = {
1117
+        const static byte _lcd_box_top[8] PROGMEM = {
1183 1118
           B11111,
1184 1119
           B00000,
1185 1120
           B00000,
@@ -1189,8 +1124,7 @@ static void lcd_implementation_status_screen() {
1189 1124
           B00000,
1190 1125
           B00000
1191 1126
         };
1192
-
1193
-        const static PROGMEM byte _lcd_box_bottom[8] = {
1127
+        const static byte _lcd_box_bottom[8] PROGMEM = {
1194 1128
           B00000,
1195 1129
           B00000,
1196 1130
           B00000,
@@ -1200,75 +1134,99 @@ static void lcd_implementation_status_screen() {
1200 1134
           B00000,
1201 1135
           B11111
1202 1136
         };
1203
-
1204
-        /*
1205
-         * Draw the Mesh Map Box
1206
-         */
1207
-        // First create the box custom characters
1208 1137
         createChar_P(1, _lcd_box_top);
1209 1138
         createChar_P(2, _lcd_box_bottom);
1139
+      #endif
1140
+    }
1141
+
1142
+    void lcd_implementation_ubl_plot(const uint8_t x_plot, const uint8_t y_plot) {
1143
+
1144
+      #if LCD_WIDTH >= 20
1145
+        #define _LCD_W_POS 12
1146
+        #define _PLOT_X 1
1147
+        #define _MAP_X 3
1148
+        #define _LABEL(C,X,Y) lcd.setCursor(X, Y); lcd.print(C)
1149
+        #define _XLABEL(X,Y) _LABEL("X:",X,Y)
1150
+        #define _YLABEL(X,Y) _LABEL("Y:",X,Y)
1151
+        #define _ZLABEL(X,Y) _LABEL("Z:",X,Y)
1152
+      #else
1153
+        #define _LCD_W_POS 8
1154
+        #define _PLOT_X 0
1155
+        #define _MAP_X 1
1156
+        #define _LABEL(X,Y,C) lcd.setCursor(X, Y); lcd.write(C)
1157
+        #define _XLABEL(X,Y) _LABEL('X',X,Y)
1158
+        #define _YLABEL(X,Y) _LABEL('Y',X,Y)
1159
+        #define _ZLABEL(X,Y) _LABEL('Z',X,Y)
1160
+      #endif
1161
+
1162
+      #if LCD_HEIGHT <= 3   // 16x2 or 20x2 display
1163
+
1164
+        /**
1165
+         * Show X and Y positions
1166
+         */
1167
+        _XLABEL(_PLOT_X, 0);
1168
+        lcd.print(ftostr32(LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]))));
1169
+
1170
+        _YLABEL(_LCD_W_POS, 0);
1171
+        lcd.print(ftostr32(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]))));
1172
+
1173
+        lcd.setCursor(_PLOT_X, 0);
1174
+
1175
+      #else                 // 16x4 or 20x4 display
1210 1176
 
1211
-        // Draw the mesh map box
1177
+        /**
1178
+         * Draw the Mesh Map Box
1179
+         */
1212 1180
         uint8_t m;
1213
-        
1214
-        #if LCD_WIDTH < 20
1181
+        lcd.setCursor(_MAP_X, 0); for (m = 0; m < 5; m++) lcd.write(1); // Top
1182
+        lcd.setCursor(_MAP_X, 3); for (m = 0; m < 5; m++) lcd.write(2); // Bottom
1183
+        for (m = 0; m <= 3; m++) {
1184
+          lcd.setCursor(2, m); lcd.write('|'); // Left
1185
+          lcd.setCursor(8, m); lcd.write('|'); // Right
1186
+        }
1215 1187
 
1216
-          for(m = 1; m <= 5; m++) { lcd.setCursor(m, 0); lcd.write(1); } // Top
1217
-          for(m = 1; m <= 5; m++) { lcd.setCursor(m, 3); lcd.write(2); } // Bottom
1218
-          for(m = 0; m <= 3; m++) { lcd.setCursor(2, m); lcd.write('|'); } // Left
1219
-          for(m = 0; m <= 3; m++) { lcd.setCursor(8, m); lcd.write('|');  } // Right
1188
+        lcd.setCursor(_LCD_W_POS, 0);
1220 1189
 
1221
-        #else
1222
-        
1223
-          for(m = 3; m <= 7; m++) { lcd.setCursor(m, 0); lcd.write(1); } // Top
1224
-          for(m = 3; m <= 7; m++) { lcd.setCursor(m, 3); lcd.write(2); } // Bottom
1225
-          for(m = 0; m <= 3; m++) { lcd.setCursor(2, m); lcd.write('|'); } // Left
1226
-          for(m = 0; m <= 3; m++) { lcd.setCursor(8, m); lcd.write('|');  } // Right
1190
+      #endif
1227 1191
 
1228
-        #endif
1229
-        /*
1230
-         * Print plot position
1192
+      /**
1193
+       * Print plot position
1194
+       */
1195
+      lcd.write('(');
1196
+      lcd.print(x_plot);
1197
+      lcd.write(',');
1198
+      lcd.print(y_plot);
1199
+      lcd.write(')');
1200
+
1201
+      #if LCD_HEIGHT <= 3   // 16x2 or 20x2 display
1202
+
1203
+        /**
1204
+         * Print Z values
1231 1205
          */
1232
-        lcd.setCursor(lcd_w_pos, 0);
1233
-        lcd.print("(");
1234
-        lcd.print(x_plot);
1235
-        lcd.print(",");
1236
-        lcd.print(y_plot);
1237
-        lcd.print(")");
1238
-
1239
-        /*
1206
+        _ZLABEL(_LCD_W_POS, 1);
1207
+        if (!isnan(ubl.z_values[x_plot][y_plot]))
1208
+          lcd.print(ftostr43sign(ubl.z_values[x_plot][y_plot]));
1209
+        else
1210
+          lcd_printPGM(PSTR(" -----"));
1211
+
1212
+      #else                 // 16x4 or 20x4 display
1213
+
1214
+        /**
1240 1215
          * Show all values at right of screen
1241 1216
          */
1242
-        lcd.setCursor(lcd_w_pos, 1);
1243
-        #if LCD_WIDTH < 20
1244
-          lcd.print("X");
1245
-        #else
1246
-          lcd.print("X:");
1247
-        #endif
1217
+        _XLABEL(_LCD_W_POS, 1);
1248 1218
         lcd.print(ftostr32(LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]))));
1249
-        lcd.setCursor(lcd_w_pos, 2);
1250
-        #if LCD_WIDTH < 20
1251
-          lcd.print("Y");
1252
-        #else
1253
-          lcd.print("Y:");
1254
-        #endif
1219
+        _YLABEL(_LCD_W_POS, 2);
1255 1220
         lcd.print(ftostr32(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]))));
1256 1221
 
1257
-        /*
1222
+        /**
1258 1223
          * Show the location value
1259 1224
          */
1260
-        lcd.setCursor(lcd_w_pos, 3);
1261
-        #if LCD_WIDTH < 20
1262
-          lcd.print("Z");
1263
-        #else
1264
-          lcd.print("Z:");
1265
-        #endif
1266
-        if (!isnan(ubl.z_values[x_plot][y_plot])) {
1225
+        _ZLABEL(_LCD_W_POS, 3);
1226
+        if (!isnan(ubl.z_values[x_plot][y_plot]))
1267 1227
           lcd.print(ftostr43sign(ubl.z_values[x_plot][y_plot]));
1268
-        }
1269
-        else {
1270
-          lcd.print(" -----");
1271
-        }
1228
+        else
1229
+          lcd_printPGM(PSTR(" -----"));
1272 1230
 
1273 1231
       #endif // LCD_HEIGHT > 3
1274 1232
     }

Loading…
Cancel
Save