Browse Source

Merge pull request #7167 from thinkyhead/bf_20x4_lcd_update

UBL Map Cleanup and LCD display
Scott Lahteine 8 years ago
parent
commit
d1e8d4cd9d
3 changed files with 278 additions and 137 deletions
  1. 10
    104
      Marlin/ultralcd.cpp
  2. 90
    1
      Marlin/ultralcd_impl_DOGM.h
  3. 178
    32
      Marlin/ultralcd_impl_HD44780.h

+ 10
- 104
Marlin/ultralcd.cpp View File

108
     extern bool powersupply_on;
108
     extern bool powersupply_on;
109
   #endif
109
   #endif
110
 
110
 
111
-
112
   ////////////////////////////////////////////
111
   ////////////////////////////////////////////
113
   ///////////////// Menu Tree ////////////////
112
   ///////////////// Menu Tree ////////////////
114
   ////////////////////////////////////////////
113
   ////////////////////////////////////////////
790
       encoderPosition = 0;
789
       encoderPosition = 0;
791
       lcd_implementation_drawmenu_static(0, PSTR(MSG_PROGRESS_BAR_TEST), true, true);
790
       lcd_implementation_drawmenu_static(0, PSTR(MSG_PROGRESS_BAR_TEST), true, true);
792
       lcd.setCursor((LCD_WIDTH) / 2 - 2, LCD_HEIGHT - 2);
791
       lcd.setCursor((LCD_WIDTH) / 2 - 2, LCD_HEIGHT - 2);
793
-      lcd.print(itostr3(bar_percent)); lcd.print('%');
792
+      lcd.print(itostr3(bar_percent)); lcd.write('%');
794
       lcd.setCursor(0, LCD_HEIGHT - 1); lcd_draw_progress_bar(bar_percent);
793
       lcd.setCursor(0, LCD_HEIGHT - 1); lcd_draw_progress_bar(bar_percent);
795
     }
794
     }
796
 
795
 
2145
     void _lcd_ubl_map_homing() {
2144
     void _lcd_ubl_map_homing() {
2146
       if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_HOMING), NULL);
2145
       if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_HOMING), NULL);
2147
       lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
2146
       lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
2148
-      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
2149
         lcd_goto_screen(_lcd_ubl_output_map_lcd);
2151
         lcd_goto_screen(_lcd_ubl_output_map_lcd);
2152
+      }
2150
     }
2153
     }
2151
 
2154
 
2152
     /**
2155
     /**
2163
       enqueue_and_echo_command(ubl_lcd_gcode);
2166
       enqueue_and_echo_command(ubl_lcd_gcode);
2164
     }
2167
     }
2165
 
2168
 
2166
-  #if ENABLED(DOGLCD)
2167
-
2168
-    /**
2169
-     * UBL LCD "radar" map data
2170
-     */
2171
-    #define MAP_UPPER_LEFT_CORNER_X 35  // These probably should be moved to the .h file  But for now,
2172
-    #define MAP_UPPER_LEFT_CORNER_Y 8   // it is easier to play with things having them here
2173
-    #define MAP_MAX_PIXELS_X        53
2174
-    #define MAP_MAX_PIXELS_Y        49
2175
-
2176
-    void _lcd_ubl_plot_drawing_prep() {
2177
-      uint8_t i, j, x_offset, y_offset, x_map_pixels, y_map_pixels,
2178
-              pixels_per_X_mesh_pnt, pixels_per_Y_mesh_pnt, inverted_y;
2179
-
2180
-      /*********************************************************/
2181
-      /************ Scale the box pixels appropriately *********/
2182
-      /*********************************************************/
2183
-      x_map_pixels = ((MAP_MAX_PIXELS_X - 4) / (GRID_MAX_POINTS_X)) * (GRID_MAX_POINTS_X);
2184
-      y_map_pixels = ((MAP_MAX_PIXELS_Y - 4) / (GRID_MAX_POINTS_Y)) * (GRID_MAX_POINTS_Y);
2185
-
2186
-      pixels_per_X_mesh_pnt = x_map_pixels / (GRID_MAX_POINTS_X);
2187
-      pixels_per_Y_mesh_pnt = y_map_pixels / (GRID_MAX_POINTS_Y);
2188
-
2189
-      x_offset = MAP_UPPER_LEFT_CORNER_X + 1 + (MAP_MAX_PIXELS_X - x_map_pixels - 2) / 2;
2190
-      y_offset = MAP_UPPER_LEFT_CORNER_Y + 1 + (MAP_MAX_PIXELS_Y - y_map_pixels - 2) / 2;
2191
-
2192
-      /*********************************************************/
2193
-      /************ Clear the Mesh Map Box**********************/
2194
-      /*********************************************************/
2195
-
2196
-      u8g.setColorIndex(1);  // First draw the bigger box in White so we have a border around the mesh map box
2197
-      u8g.drawBox(x_offset - 2, y_offset - 2, x_map_pixels + 4, y_map_pixels + 4);
2198
-
2199
-      u8g.setColorIndex(0);  // Now actually clear the mesh map box
2200
-      u8g.drawBox(x_offset, y_offset, x_map_pixels, y_map_pixels);
2201
-
2202
-      /*********************************************************/
2203
-      /************ Display Mesh Point Locations ***************/
2204
-      /*********************************************************/
2205
-
2206
-      u8g.setColorIndex(1);
2207
-      for (i = 0; i < GRID_MAX_POINTS_X; i++) {
2208
-        for (j = 0; j < GRID_MAX_POINTS_Y; j++) {
2209
-          u8g.drawBox(x_offset + i * pixels_per_X_mesh_pnt + pixels_per_X_mesh_pnt / 2,
2210
-                      y_offset + j * pixels_per_Y_mesh_pnt + pixels_per_Y_mesh_pnt / 2, 1, 1);
2211
-        }
2212
-      }
2213
-
2214
-      /*********************************************************/
2215
-      /************ Fill in the Specified Mesh Point ***********/
2216
-      /*********************************************************/
2217
-
2218
-      inverted_y = GRID_MAX_POINTS_Y - y_plot - 1;    // The origin is typically in the lower right corner.  We need to
2219
-                                                      // invert the Y to get it to plot in the right location.
2220
-      u8g.drawBox(x_offset + x_plot * pixels_per_X_mesh_pnt, y_offset + inverted_y * pixels_per_Y_mesh_pnt,
2221
-                    pixels_per_X_mesh_pnt, pixels_per_Y_mesh_pnt);
2222
-
2223
-      /*********************************************************/
2224
-      /************** Put Relevent Text on Display *************/
2225
-      /*********************************************************/
2226
-
2227
-      // Show X and Y positions at top of screen
2228
-      u8g.setColorIndex(1);
2229
-      u8g.setPrintPos(5, 7);
2230
-      lcd_print("X:");
2231
-      lcd_print(ftostr32(LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]))));
2232
-      u8g.setPrintPos(74, 7);
2233
-      lcd_print("Y:");
2234
-      lcd_print(ftostr32(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]))));
2235
-
2236
-      // Print plot position
2237
-      u8g.setPrintPos(5, 64);
2238
-      lcd_print('(');
2239
-      u8g.print(x_plot);
2240
-      lcd_print(',');
2241
-      u8g.print(y_plot);
2242
-      lcd_print(')');
2243
-
2244
-      // Show the location value
2245
-      u8g.setPrintPos(74, 64);
2246
-      lcd_print("Z:");
2247
-      if (!isnan(ubl.z_values[x_plot][y_plot])) {
2248
-        lcd_print(ftostr43sign(ubl.z_values[x_plot][y_plot]));
2249
-      }
2250
-      else {
2251
-        lcd_print(" -----");
2252
-      }
2253
-    }
2254
-
2255
-  #endif // DOGLCD
2256
-
2257
     /**
2169
     /**
2258
      * UBL LCD Map Movement
2170
      * UBL LCD Map Movement
2259
      */
2171
      */
2309
         #if IS_KINEMATIC
2221
         #if IS_KINEMATIC
2310
           n_edit_pts = 9; //TODO: Delta accessible edit points
2222
           n_edit_pts = 9; //TODO: Delta accessible edit points
2311
         #else
2223
         #else
2312
-          if (x_plot < 1 || x_plot >= GRID_MAX_POINTS_X - 1)
2313
-            if (y_plot < 1 || y_plot >= GRID_MAX_POINTS_Y - 1) n_edit_pts = 4; // Corners
2314
-            else n_edit_pts = 6;
2315
-          else if (y_plot < 1 || y_plot >= GRID_MAX_POINTS_Y - 1) n_edit_pts = 6; // Edges
2316
-          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
2317
         #endif
2227
         #endif
2318
 
2228
 
2319
         if (lcdDrawUpdate) {
2229
         if (lcdDrawUpdate) {
2320
-          #if ENABLED(DOGLCD)
2321
-            _lcd_ubl_plot_drawing_prep();
2322
-          #else
2323
-            _lcd_ubl_output_char_lcd();
2324
-          #endif
2230
+          lcd_implementation_ubl_plot(x_plot, y_plot);
2325
 
2231
 
2326
           ubl_map_move_to_xy(); // Move to current location
2232
           ubl_map_move_to_xy(); // Move to current location
2327
 
2233
 

+ 90
- 1
Marlin/ultralcd_impl_DOGM.h View File

688
 
688
 
689
   #define STATUS_BASELINE (55 + INFO_FONT_HEIGHT)
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
     u8g.setPrintPos(0, STATUS_BASELINE);
692
     u8g.setPrintPos(0, STATUS_BASELINE);
693
 
693
 
694
     #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
694
     #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
939
 
939
 
940
   #endif // SDSUPPORT
940
   #endif // SDSUPPORT
941
 
941
 
942
+  #if ENABLED(AUTO_BED_LEVELING_UBL)
943
+
944
+    /**
945
+     * UBL LCD "radar" map data
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_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
+      }
973
+
974
+      // Display Mesh Point Locations
975
+
976
+      u8g.setColorIndex(1);
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);
983
+
984
+      // Fill in the Specified Mesh Point
985
+
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.
988
+
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
997
+
998
+      // Show X and Y positions at top of screen
999
+      u8g.setColorIndex(1);
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
+      }
1008
+
1009
+      // Print plot position
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(" -----"));
1025
+      }
1026
+
1027
+    }
1028
+
1029
+  #endif // AUTO_BED_LEVELING_UBL
1030
+
942
 #endif // ULTIPANEL
1031
 #endif // ULTIPANEL
943
 
1032
 
944
 #endif // __ULTRALCD_IMPL_DOGM_H
1033
 #endif // __ULTRALCD_IMPL_DOGM_H

+ 178
- 32
Marlin/ultralcd_impl_HD44780.h View File

31
 #include "utility.h"
31
 #include "utility.h"
32
 #include "duration_t.h"
32
 #include "duration_t.h"
33
 
33
 
34
+#if ENABLED(AUTO_BED_LEVELING_UBL)
35
+  #include "ubl.h"
36
+#endif
37
+
34
 extern volatile uint8_t buttons;  //an extended version of the last checked buttons in a bit array.
38
 extern volatile uint8_t buttons;  //an extended version of the last checked buttons in a bit array.
35
 
39
 
36
 ////////////////////////////////////
40
 ////////////////////////////////////
417
   void lcd_erase_line(const int16_t line) {
421
   void lcd_erase_line(const int16_t line) {
418
     lcd.setCursor(0, line);
422
     lcd.setCursor(0, line);
419
     for (uint8_t i = LCD_WIDTH + 1; --i;)
423
     for (uint8_t i = LCD_WIDTH + 1; --i;)
420
-      lcd.print(' ');
424
+      lcd.write(' ');
421
   }
425
   }
422
 
426
 
423
   // Scroll the PSTR 'text' in a 'len' wide field for 'time' milliseconds at position col,line
427
   // Scroll the PSTR 'text' in a 'len' wide field for 'time' milliseconds at position col,line
434
 
438
 
435
   static void logo_lines(const char* const extra) {
439
   static void logo_lines(const char* const extra) {
436
     int16_t indent = (LCD_WIDTH - 8 - lcd_strlen_P(extra)) / 2;
440
     int16_t indent = (LCD_WIDTH - 8 - lcd_strlen_P(extra)) / 2;
437
-    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');
438
     lcd.setCursor(indent, 1);                    lcd_printPGM(PSTR("|Marlin|"));  lcd_printPGM(extra);
442
     lcd.setCursor(indent, 1);                    lcd_printPGM(PSTR("|Marlin|"));  lcd_printPGM(extra);
439
-    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');
440
   }
444
   }
441
 
445
 
442
   void bootscreen() {
446
   void bootscreen() {
577
     lcd_printPGM(pstr);
581
     lcd_printPGM(pstr);
578
   else {
582
   else {
579
     if (!axis_homed[axis])
583
     if (!axis_homed[axis])
580
-      lcd.print('?');
584
+      lcd.write('?');
581
     else {
585
     else {
582
       #if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
586
       #if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
583
         if (!axis_known_position[axis])
587
         if (!axis_known_position[axis])
584
-          lcd.print(' ');
588
+          lcd.write(' ');
585
         else
589
         else
586
       #endif
590
       #endif
587
       lcd_printPGM(pstr);
591
       lcd_printPGM(pstr);
598
   if (prefix >= 0) lcd.print(prefix);
602
   if (prefix >= 0) lcd.print(prefix);
599
 
603
 
600
   lcd.print(itostr3(t1 + 0.5));
604
   lcd.print(itostr3(t1 + 0.5));
601
-  lcd.print('/');
605
+  lcd.write('/');
602
 
606
 
603
   #if HEATER_IDLE_HANDLER
607
   #if HEATER_IDLE_HANDLER
604
     const bool is_idle = (!isBed ? thermalManager.is_heater_idle(heater) :
608
     const bool is_idle = (!isBed ? thermalManager.is_heater_idle(heater) :
610
     );
614
     );
611
 
615
 
612
     if (!blink && is_idle) {
616
     if (!blink && is_idle) {
613
-      lcd.print(' ');
614
-      if (t2 >= 10) lcd.print(' ');
615
-      if (t2 >= 100) lcd.print(' ');
617
+      lcd.write(' ');
618
+      if (t2 >= 10) lcd.write(' ');
619
+      if (t2 >= 100) lcd.write(' ');
616
     }
620
     }
617
     else
621
     else
618
   #endif
622
   #endif
620
 
624
 
621
   if (prefix >= 0) {
625
   if (prefix >= 0) {
622
     lcd.print((char)LCD_DEGREE_CHAR);
626
     lcd.print((char)LCD_DEGREE_CHAR);
623
-    lcd.print(' ');
624
-    if (t2 < 10) lcd.print(' ');
627
+    lcd.write(' ');
628
+    if (t2 < 10) lcd.write(' ');
625
   }
629
   }
626
 }
630
 }
627
 
631
 
738
           lcd.print(itostr3(card.percentDone()));
742
           lcd.print(itostr3(card.percentDone()));
739
         else
743
         else
740
           lcd_printPGM(PSTR("---"));
744
           lcd_printPGM(PSTR("---"));
741
-          lcd.print('%');
745
+          lcd.write('%');
742
       #endif // SDSUPPORT
746
       #endif // SDSUPPORT
743
 
747
 
744
     #else // LCD_WIDTH >= 20
748
     #else // LCD_WIDTH >= 20
760
         _draw_axis_label(X_AXIS, PSTR(MSG_X), blink);
764
         _draw_axis_label(X_AXIS, PSTR(MSG_X), blink);
761
         lcd.print(ftostr4sign(current_position[X_AXIS]));
765
         lcd.print(ftostr4sign(current_position[X_AXIS]));
762
 
766
 
763
-        lcd.print(' ');
767
+        lcd.write(' ');
764
 
768
 
765
         _draw_axis_label(Y_AXIS, PSTR(MSG_Y), blink);
769
         _draw_axis_label(Y_AXIS, PSTR(MSG_Y), blink);
766
         lcd.print(ftostr4sign(current_position[Y_AXIS]));
770
         lcd.print(ftostr4sign(current_position[Y_AXIS]));
784
     lcd.setCursor(0, 2);
788
     lcd.setCursor(0, 2);
785
     lcd.print((char)LCD_FEEDRATE_CHAR);
789
     lcd.print((char)LCD_FEEDRATE_CHAR);
786
     lcd.print(itostr3(feedrate_percentage));
790
     lcd.print(itostr3(feedrate_percentage));
787
-    lcd.print('%');
791
+    lcd.write('%');
788
 
792
 
789
     #if LCD_WIDTH >= 20 && ENABLED(SDSUPPORT)
793
     #if LCD_WIDTH >= 20 && ENABLED(SDSUPPORT)
790
 
794
 
794
         lcd.print(itostr3(card.percentDone()));
798
         lcd.print(itostr3(card.percentDone()));
795
       else
799
       else
796
         lcd_printPGM(PSTR("---"));
800
         lcd_printPGM(PSTR("---"));
797
-      lcd.print('%');
801
+      lcd.write('%');
798
 
802
 
799
     #endif // LCD_WIDTH >= 20 && SDSUPPORT
803
     #endif // LCD_WIDTH >= 20 && SDSUPPORT
800
 
804
 
833
       lcd.print(ftostr12ns(filament_width_meas));
837
       lcd.print(ftostr12ns(filament_width_meas));
834
       lcd_printPGM(PSTR(" V"));
838
       lcd_printPGM(PSTR(" V"));
835
       lcd.print(itostr3(100.0 * volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
839
       lcd.print(itostr3(100.0 * volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
836
-      lcd.print('%');
840
+      lcd.write('%');
837
       return;
841
       return;
838
     }
842
     }
839
 
843
 
854
           lcd_print_utf(stat);                                  // The string leaves space
858
           lcd_print_utf(stat);                                  // The string leaves space
855
           chars -= slen - status_scroll_pos;                    // Amount of space left
859
           chars -= slen - status_scroll_pos;                    // Amount of space left
856
         }
860
         }
857
-        lcd.print('.');                                         // Always at 1+ spaces left, draw a dot
861
+        lcd.write('.');                                         // Always at 1+ spaces left, draw a dot
858
         if (--chars) {
862
         if (--chars) {
859
           if (status_scroll_pos < slen + 1)                     // Draw a second dot if there's space
863
           if (status_scroll_pos < slen + 1)                     // Draw a second dot if there's space
860
-            --chars, lcd.print('.');
864
+            --chars, lcd.write('.');
861
           if (chars) lcd_print_utf(lcd_status_message, chars);  // Print a second copy of the message
865
           if (chars) lcd_print_utf(lcd_status_message, chars);  // Print a second copy of the message
862
         }
866
         }
863
       }
867
       }
893
     lcd.setCursor(0, row);
897
     lcd.setCursor(0, row);
894
     if (center && !valstr) {
898
     if (center && !valstr) {
895
       int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2;
899
       int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2;
896
-      while (--pad >= 0) { lcd.print(' '); n--; }
900
+      while (--pad >= 0) { lcd.write(' '); n--; }
897
     }
901
     }
898
     while (n > 0 && (c = pgm_read_byte(pstr))) {
902
     while (n > 0 && (c = pgm_read_byte(pstr))) {
899
       n -= charset_mapper(c);
903
       n -= charset_mapper(c);
903
       n -= charset_mapper(c);
907
       n -= charset_mapper(c);
904
       valstr++;
908
       valstr++;
905
     }
909
     }
906
-    while (n-- > 0) lcd.print(' ');
910
+    while (n-- > 0) lcd.write(' ');
907
   }
911
   }
908
 
912
 
909
   static void lcd_implementation_drawmenu_generic(const bool sel, const uint8_t row, const char* pstr, const char pre_char, const char post_char) {
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) {
915
       n -= charset_mapper(c);
919
       n -= charset_mapper(c);
916
       pstr++;
920
       pstr++;
917
     }
921
     }
918
-    while (n--) lcd.print(' ');
922
+    while (n--) lcd.write(' ');
919
     lcd.print(post_char);
923
     lcd.print(post_char);
920
   }
924
   }
921
 
925
 
928
       n -= charset_mapper(c);
932
       n -= charset_mapper(c);
929
       pstr++;
933
       pstr++;
930
     }
934
     }
931
-    lcd.print(':');
932
-    while (n--) lcd.print(' ');
935
+    lcd.write(':');
936
+    while (n--) lcd.write(' ');
933
     lcd_print(data);
937
     lcd_print(data);
934
   }
938
   }
935
   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) {
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) {
941
       n -= charset_mapper(c);
945
       n -= charset_mapper(c);
942
       pstr++;
946
       pstr++;
943
     }
947
     }
944
-    lcd.print(':');
945
-    while (n--) lcd.print(' ');
948
+    lcd.write(':');
949
+    while (n--) lcd.write(' ');
946
     lcd_printPGM(data);
950
     lcd_printPGM(data);
947
   }
951
   }
948
 
952
 
977
     lcd.setCursor(1, 1);
981
     lcd.setCursor(1, 1);
978
     lcd_printPGM(pstr);
982
     lcd_printPGM(pstr);
979
     if (value != NULL) {
983
     if (value != NULL) {
980
-      lcd.print(':');
984
+      lcd.write(':');
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
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
982
       lcd.setCursor((LCD_WIDTH - 1) - (lcd_strlen(value) + 1), valrow);                                   // Right-justified, padded by spaces
986
       lcd.setCursor((LCD_WIDTH - 1) - (lcd_strlen(value) + 1), valrow);                                   // Right-justified, padded by spaces
983
-      lcd.print(' ');                                                                                     // overwrite char if value gets shorter
987
+      lcd.write(' ');                                                                                     // overwrite char if value gets shorter
984
       lcd_print(value);
988
       lcd_print(value);
985
     }
989
     }
986
   }
990
   }
1001
         n -= charset_mapper(c);
1005
         n -= charset_mapper(c);
1002
         filename++;
1006
         filename++;
1003
       }
1007
       }
1004
-      while (n--) lcd.print(' ');
1008
+      while (n--) lcd.write(' ');
1005
       lcd.print(post_char);
1009
       lcd.print(post_char);
1006
     }
1010
     }
1007
 
1011
 
1079
 
1083
 
1080
 #endif // LCD_HAS_STATUS_INDICATORS
1084
 #endif // LCD_HAS_STATUS_INDICATORS
1081
 
1085
 
1082
-#ifdef AUTO_BED_LEVELING_UBL
1083
-    void lcd_return_to_status();       // These are just place holders for the 20x4 LCD work that
1084
-    void _lcd_ubl_output_char_lcd() {  // is coming up very soon.   Soon this will morph into the
1085
-      lcd_return_to_status();          // real code.
1086
+#if ENABLED(AUTO_BED_LEVELING_UBL)
1087
+
1088
+    /* 
1089
+     * These are just basic data for the 20x4 LCD work that
1090
+     * is coming up very soon.
1091
+     * Soon this will morph into a map code.
1092
+     */
1093
+
1094
+    /**
1095
+    Possible map screens:
1096
+
1097
+    16x2   |X000.00  Y000.00|
1098
+           |(00,00)  Z00.000|
1099
+
1100
+    20x2   | X:000.00  Y:000.00 |
1101
+           | (00,00)   Z:00.000 |
1102
+
1103
+    16x4   |+-------+(00,00)|
1104
+           ||       |X000.00|
1105
+           ||       |Y000.00|
1106
+           |+-------+Z00.000|
1107
+
1108
+    20x4   | +-------+  (00,00) |
1109
+           | |       |  X:000.00|
1110
+           | |       |  Y:000.00|
1111
+           | +-------+  Z:00.000|
1112
+    */
1113
+
1114
+    void lcd_set_ubl_map_plot_chars() {
1115
+      #if LCD_HEIGHT > 3
1116
+        //#include "_ubl_lcd_map_characters.h"
1117
+        const static byte _lcd_box_top[8] PROGMEM = {
1118
+          B11111,
1119
+          B00000,
1120
+          B00000,
1121
+          B00000,
1122
+          B00000,
1123
+          B00000,
1124
+          B00000,
1125
+          B00000
1126
+        };
1127
+        const static byte _lcd_box_bottom[8] PROGMEM = {
1128
+          B00000,
1129
+          B00000,
1130
+          B00000,
1131
+          B00000,
1132
+          B00000,
1133
+          B00000,
1134
+          B00000,
1135
+          B11111
1136
+        };
1137
+        createChar_P(1, _lcd_box_top);
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
1176
+
1177
+        /**
1178
+         * Draw the Mesh Map Box
1179
+         */
1180
+        uint8_t m;
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
+        }
1187
+
1188
+        lcd.setCursor(_LCD_W_POS, 0);
1189
+
1190
+      #endif
1191
+
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
1205
+         */
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
+        /**
1215
+         * Show all values at right of screen
1216
+         */
1217
+        _XLABEL(_LCD_W_POS, 1);
1218
+        lcd.print(ftostr32(LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]))));
1219
+        _YLABEL(_LCD_W_POS, 2);
1220
+        lcd.print(ftostr32(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]))));
1221
+
1222
+        /**
1223
+         * Show the location value
1224
+         */
1225
+        _ZLABEL(_LCD_W_POS, 3);
1226
+        if (!isnan(ubl.z_values[x_plot][y_plot]))
1227
+          lcd.print(ftostr43sign(ubl.z_values[x_plot][y_plot]));
1228
+        else
1229
+          lcd_printPGM(PSTR(" -----"));
1230
+
1231
+      #endif // LCD_HEIGHT > 3
1086
     }
1232
     }
1087
 
1233
 
1088
 #endif // AUTO_BED_LEVELING_UBL
1234
 #endif // AUTO_BED_LEVELING_UBL

Loading…
Cancel
Save