Parcourir la source

UBL Map Cleanup

Tannoo il y a 8 ans
Parent
révision
e90cbf5c16
3 fichiers modifiés avec 155 ajouts et 97 suppressions
  1. 2
    94
      Marlin/ultralcd.cpp
  2. 90
    0
      Marlin/ultralcd_impl_DOGM.h
  3. 63
    3
      Marlin/ultralcd_impl_HD44780.h

+ 2
- 94
Marlin/ultralcd.cpp Voir le fichier

@@ -108,7 +108,6 @@ uint16_t max_display_update_time = 0;
108 108
     extern bool powersupply_on;
109 109
   #endif
110 110
 
111
-
112 111
   ////////////////////////////////////////////
113 112
   ///////////////// Menu Tree ////////////////
114 113
   ////////////////////////////////////////////
@@ -2163,97 +2162,6 @@ void kill_screen(const char* lcd_msg) {
2163 2162
       enqueue_and_echo_command(ubl_lcd_gcode);
2164 2163
     }
2165 2164
 
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 2165
     /**
2258 2166
      * UBL LCD Map Movement
2259 2167
      */
@@ -2318,9 +2226,9 @@ void kill_screen(const char* lcd_msg) {
2318 2226
 
2319 2227
         if (lcdDrawUpdate) {
2320 2228
           #if ENABLED(DOGLCD)
2321
-            _lcd_ubl_plot_drawing_prep();
2229
+            _lcd_ubl_plot_DOGLCD(x_plot, y_plot);
2322 2230
           #else
2323
-            _lcd_ubl_output_char_lcd();
2231
+            _lcd_ubl_plot_HD44780(x_plot, y_plot);
2324 2232
           #endif
2325 2233
 
2326 2234
           ubl_map_move_to_xy(); // Move to current location

+ 90
- 0
Marlin/ultralcd_impl_DOGM.h Voir le fichier

@@ -939,6 +939,96 @@ static void lcd_implementation_status_screen() {
939 939
 
940 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_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);
977
+
978
+      /*********************************************************/
979
+      /************ Display Mesh Point Locations ***************/
980
+      /*********************************************************/
981
+
982
+      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
+      }
989
+
990
+      /*********************************************************/
991
+      /************ Fill in the Specified Mesh Point ***********/
992
+      /*********************************************************/
993
+
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);
998
+
999
+      /*********************************************************/
1000
+      /************** Put Relevent Text on Display *************/
1001
+      /*********************************************************/
1002
+
1003
+      // Show X and Y positions at top of screen
1004
+      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]))));
1011
+
1012
+      // 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(" -----");
1028
+      }
1029
+    }
1030
+  #endif // AUTO_BED_LEVELING_UBL
1031
+
942 1032
 #endif // ULTIPANEL
943 1033
 
944 1034
 #endif // __ULTRALCD_IMPL_DOGM_H

+ 63
- 3
Marlin/ultralcd_impl_HD44780.h Voir le fichier

@@ -31,6 +31,10 @@
31 31
 #include "utility.h"
32 32
 #include "duration_t.h"
33 33
 
34
+#if ENABLED(AUTO_BED_LEVELING_UBL)
35
+  #include "ubl.h"
36
+#endif
37
+
34 38
 extern volatile uint8_t buttons;  //an extended version of the last checked buttons in a bit array.
35 39
 
36 40
 ////////////////////////////////////
@@ -1080,9 +1084,65 @@ static void lcd_implementation_status_screen() {
1080 1084
 #endif // LCD_HAS_STATUS_INDICATORS
1081 1085
 
1082 1086
 #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.
1087
+
1088
+    // These are just basic data for the 20x4 LCD work that
1089
+    // is coming up very soon.
1090
+    // Soon this will morph into a map code.
1091
+
1092
+    void _lcd_ubl_plot_HD44780(uint8_t x_plot, uint8_t y_plot) {
1093
+
1094
+      uint8_t lcd_w_pos = 8, lcd_h_pos = 1;
1095
+
1096
+      #if LCD_WIDTH < 20
1097
+        lcd_w_pos = 8;
1098
+      #else
1099
+        lcd_w_pos = 12;
1100
+      #endif
1101
+      #if LCD_HEIGHT > 3
1102
+        lcd_h_pos = 3;
1103
+      #elif LCD_HEIGHT > 2
1104
+        lcd_h_pos = 2;
1105
+      #else
1106
+        lcd_h_pos = 1;
1107
+      #endif
1108
+
1109
+      // Show X and Y positions at top of screen
1110
+      lcd.setCursor(0, 0);
1111
+      #if LCD_WIDTH < 20
1112
+        lcd.print("X");
1113
+      #else
1114
+        lcd.print("X:");
1115
+      #endif
1116
+      lcd.print(ftostr32(LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]))));
1117
+      lcd.setCursor(lcd_w_pos, 0);
1118
+      #if LCD_WIDTH < 20
1119
+        lcd.print("Y");
1120
+      #else
1121
+        lcd.print("Y:");
1122
+      #endif
1123
+      lcd.print(ftostr32(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]))));
1124
+
1125
+      // Print plot position
1126
+      lcd.setCursor(0, lcd_h_pos);
1127
+      lcd.print("(");
1128
+      lcd.print(x_plot);
1129
+      lcd.print(",");
1130
+      lcd.print(y_plot);
1131
+      lcd.print(")");
1132
+
1133
+      // Show the location value
1134
+      lcd.setCursor(lcd_w_pos, lcd_h_pos);
1135
+      #if LCD_WIDTH < 20
1136
+        lcd.print("Z");
1137
+      #else
1138
+        lcd.print("Z:");
1139
+      #endif
1140
+      if (!isnan(ubl.z_values[x_plot][y_plot])) {
1141
+        lcd.print(ftostr43sign(ubl.z_values[x_plot][y_plot]));
1142
+      }
1143
+      else {
1144
+        lcd.print(" -----");
1145
+      }
1086 1146
     }
1087 1147
 
1088 1148
 #endif // AUTO_BED_LEVELING_UBL

Chargement…
Annuler
Enregistrer