Browse Source

🐛 Fix UBL 'R' parameter and adjust 'P' (#22129)

Katelyn Schiesser 4 years ago
parent
commit
3a03f76f3c
No account linked to committer's email address

+ 2
- 2
Marlin/src/feature/bedlevel/ubl/ubl.cpp View File

164
  *   2: TODO: Display on Graphical LCD
164
  *   2: TODO: Display on Graphical LCD
165
  *   4: Compact Human-Readable
165
  *   4: Compact Human-Readable
166
  */
166
  */
167
-void unified_bed_leveling::display_map(const int map_type) {
167
+void unified_bed_leveling::display_map(const uint8_t map_type) {
168
   const bool was = gcode.set_autoreport_paused(true);
168
   const bool was = gcode.set_autoreport_paused(true);
169
 
169
 
170
   constexpr uint8_t eachsp = 1 + 6 + 1,                           // [-3.567]
170
   constexpr uint8_t eachsp = 1 + 6 + 1,                           // [-3.567]
263
   void GcodeSuite::M1004() {
263
   void GcodeSuite::M1004() {
264
 
264
 
265
     #define ALIGN_GCODE TERN(Z_STEPPER_AUTO_ALIGN, "G34", "")
265
     #define ALIGN_GCODE TERN(Z_STEPPER_AUTO_ALIGN, "G34", "")
266
-    #define PROBE_GCODE TERN(HAS_BED_PROBE, "G29P1\nG29P3", "G29P4R255")
266
+    #define PROBE_GCODE TERN(HAS_BED_PROBE, "G29P1\nG29P3", "G29P4R")
267
 
267
 
268
     #if HAS_HOTEND
268
     #if HAS_HOTEND
269
       if (parser.seenval('H')) {                          // Handle H# parameter to set Hotend temp
269
       if (parser.seenval('H')) {                          // Handle H# parameter to set Hotend temp

+ 4
- 4
Marlin/src/feature/bedlevel/ubl/ubl.h View File

47
 
47
 
48
 typedef struct {
48
 typedef struct {
49
   bool      C_seen;
49
   bool      C_seen;
50
-  int8_t    V_verbosity,
50
+  int8_t    KLS_storage_slot;
51
+  uint8_t   R_repetition,
52
+            V_verbosity,
51
             P_phase,
53
             P_phase,
52
-            R_repetition,
53
-            KLS_storage_slot,
54
             T_map_type;
54
             T_map_type;
55
   float     B_shim_thickness,
55
   float     B_shim_thickness,
56
             C_constant;
56
             C_constant;
98
   static void report_state();
98
   static void report_state();
99
   static void save_ubl_active_state_and_disable();
99
   static void save_ubl_active_state_and_disable();
100
   static void restore_ubl_active_state_and_leave();
100
   static void restore_ubl_active_state_and_leave();
101
-  static void display_map(const int) _O0;
101
+  static void display_map(const uint8_t) _O0;
102
   static mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const xy_pos_t&, const bool=false, MeshFlags *done_flags=nullptr) _O0;
102
   static mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const xy_pos_t&, const bool=false, MeshFlags *done_flags=nullptr) _O0;
103
   static mesh_index_pair find_furthest_invalid_mesh_point() _O0;
103
   static mesh_index_pair find_furthest_invalid_mesh_point() _O0;
104
   static void reset();
104
   static void reset();

+ 14
- 14
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp View File

305
   bool probe_deployed = false;
305
   bool probe_deployed = false;
306
   if (G29_parse_parameters()) return; // Abort on parameter error
306
   if (G29_parse_parameters()) return; // Abort on parameter error
307
 
307
 
308
-  const int8_t p_val = parser.intval('P', -1);
308
+  const uint8_t p_val = parser.byteval('P');
309
   const bool may_move = p_val == 1 || p_val == 2 || p_val == 4 || parser.seen_test('J');
309
   const bool may_move = p_val == 1 || p_val == 2 || p_val == 4 || parser.seen_test('J');
310
   #if ENABLED(HAS_MULTI_HOTEND)
310
   #if ENABLED(HAS_MULTI_HOTEND)
311
     const uint8_t old_tool_index = active_extruder;
311
     const uint8_t old_tool_index = active_extruder;
321
 
321
 
322
   // Invalidate one or more nearby mesh points, possibly all.
322
   // Invalidate one or more nearby mesh points, possibly all.
323
   if (parser.seen('I')) {
323
   if (parser.seen('I')) {
324
-    int16_t count = parser.has_value() ? parser.value_int() : 1;
324
+    uint8_t count = parser.has_value() ? parser.value_byte() : 1;
325
     bool invalidate_all = count >= GRID_MAX_POINTS;
325
     bool invalidate_all = count >= GRID_MAX_POINTS;
326
     if (!invalidate_all) {
326
     if (!invalidate_all) {
327
       while (count--) {
327
       while (count--) {
345
   }
345
   }
346
 
346
 
347
   if (parser.seen('Q')) {
347
   if (parser.seen('Q')) {
348
-    const int test_pattern = parser.has_value() ? parser.value_int() : -99;
348
+    const int16_t test_pattern = parser.has_value() ? parser.value_int() : -99;
349
     if (!WITHIN(test_pattern, -1, 2)) {
349
     if (!WITHIN(test_pattern, -1, 2)) {
350
       SERIAL_ECHOLNPGM("Invalid test_pattern value. (-1 to 2)\n");
350
       SERIAL_ECHOLNPGM("Invalid test_pattern value. (-1 to 2)\n");
351
       return;
351
       return;
592
   //
592
   //
593
 
593
 
594
   if (parser.seen('L')) {     // Load Current Mesh Data
594
   if (parser.seen('L')) {     // Load Current Mesh Data
595
-    param.KLS_storage_slot = parser.has_value() ? parser.value_int() : storage_slot;
595
+    param.KLS_storage_slot = parser.has_value() ? (int8_t)parser.value_int() : storage_slot;
596
 
596
 
597
     int16_t a = settings.calc_num_meshes();
597
     int16_t a = settings.calc_num_meshes();
598
 
598
 
617
   //
617
   //
618
 
618
 
619
   if (parser.seen('S')) {     // Store (or Save) Current Mesh Data
619
   if (parser.seen('S')) {     // Store (or Save) Current Mesh Data
620
-    param.KLS_storage_slot = parser.has_value() ? parser.value_int() : storage_slot;
620
+    param.KLS_storage_slot = parser.has_value() ? (int8_t)parser.value_int() : storage_slot;
621
 
621
 
622
-    if (param.KLS_storage_slot == -1)                     // Special case, the user wants to 'Export' the mesh to the
622
+    if (param.KLS_storage_slot == -1)               // Special case: 'Export' the mesh to the
623
-      return report_current_mesh();                 // host program to be saved on the user's computer
623
+      return report_current_mesh();                 // host so it can be saved in a file.
624
 
624
 
625
     int16_t a = settings.calc_num_meshes();
625
     int16_t a = settings.calc_num_meshes();
626
 
626
 
673
  */
673
  */
674
 void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const_float_t offset) {
674
 void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const_float_t offset) {
675
   float sum = 0;
675
   float sum = 0;
676
-  int n = 0;
676
+  uint8_t n = 0;
677
   GRID_LOOP(x, y)
677
   GRID_LOOP(x, y)
678
     if (!isnan(z_values[x][y])) {
678
     if (!isnan(z_values[x][y])) {
679
       sum += z_values[x][y];
679
       sum += z_values[x][y];
734
     do {
734
     do {
735
       if (do_ubl_mesh_map) display_map(param.T_map_type);
735
       if (do_ubl_mesh_map) display_map(param.T_map_type);
736
 
736
 
737
-      const int point_num = (GRID_MAX_POINTS) - count + 1;
737
+      const uint8_t point_num = (GRID_MAX_POINTS - count) + 1;
738
       SERIAL_ECHOLNPAIR("Probing mesh point ", point_num, "/", GRID_MAX_POINTS, ".");
738
       SERIAL_ECHOLNPAIR("Probing mesh point ", point_num, "/", GRID_MAX_POINTS, ".");
739
       TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), point_num, int(GRID_MAX_POINTS)));
739
       TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), point_num, int(GRID_MAX_POINTS)));
740
 
740
 
1083
   param.R_repetition = 0;
1083
   param.R_repetition = 0;
1084
 
1084
 
1085
   if (parser.seen('R')) {
1085
   if (parser.seen('R')) {
1086
-    param.R_repetition = parser.has_value() ? parser.value_int() : GRID_MAX_POINTS;
1086
+    param.R_repetition = parser.has_value() ? parser.value_byte() : GRID_MAX_POINTS;
1087
     NOMORE(param.R_repetition, GRID_MAX_POINTS);
1087
     NOMORE(param.R_repetition, GRID_MAX_POINTS);
1088
     if (param.R_repetition < 1) {
1088
     if (param.R_repetition < 1) {
1089
       SERIAL_ECHOLNPGM("?(R)epetition count invalid (1+).\n");
1089
       SERIAL_ECHOLNPGM("?(R)epetition count invalid (1+).\n");
1091
     }
1091
     }
1092
   }
1092
   }
1093
 
1093
 
1094
-  param.V_verbosity = parser.intval('V');
1094
+  param.V_verbosity = parser.byteval('V');
1095
   if (!WITHIN(param.V_verbosity, 0, 4)) {
1095
   if (!WITHIN(param.V_verbosity, 0, 4)) {
1096
     SERIAL_ECHOLNPGM("?(V)erbose level implausible (0-4).\n");
1096
     SERIAL_ECHOLNPGM("?(V)erbose level implausible (0-4).\n");
1097
     err_flag = true;
1097
     err_flag = true;
1098
   }
1098
   }
1099
 
1099
 
1100
   if (parser.seen('P')) {
1100
   if (parser.seen('P')) {
1101
-    const int pv = parser.value_int();
1101
+    const uint8_t pv = parser.value_byte();
1102
     #if !HAS_BED_PROBE
1102
     #if !HAS_BED_PROBE
1103
       if (pv == 1) {
1103
       if (pv == 1) {
1104
         SERIAL_ECHOLNPGM("G29 P1 requires a probe.\n");
1104
         SERIAL_ECHOLNPGM("G29 P1 requires a probe.\n");
1181
     }
1181
     }
1182
   #endif
1182
   #endif
1183
 
1183
 
1184
-  param.T_map_type = parser.intval('T');
1184
+  param.T_map_type = parser.byteval('T');
1185
   if (!WITHIN(param.T_map_type, 0, 2)) {
1185
   if (!WITHIN(param.T_map_type, 0, 2)) {
1186
     SERIAL_ECHOLNPGM("Invalid map type.\n");
1186
     SERIAL_ECHOLNPGM("Invalid map type.\n");
1187
     return UBL_ERR;
1187
     return UBL_ERR;
1833
       return;
1833
       return;
1834
     }
1834
     }
1835
 
1835
 
1836
-    param.KLS_storage_slot = parser.value_int();
1836
+    param.KLS_storage_slot = (int8_t)parser.value_int();
1837
 
1837
 
1838
     float tmp_z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
1838
     float tmp_z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
1839
     settings.load_mesh(param.KLS_storage_slot, &tmp_z_values);
1839
     settings.load_mesh(param.KLS_storage_slot, &tmp_z_values);

+ 3
- 3
Marlin/src/lcd/menu/menu_ubl.cpp View File

176
 void _lcd_ubl_edit_mesh() {
176
 void _lcd_ubl_edit_mesh() {
177
   START_MENU();
177
   START_MENU();
178
   BACK_ITEM(MSG_UBL_TOOLS);
178
   BACK_ITEM(MSG_UBL_TOOLS);
179
-  GCODES_ITEM(MSG_UBL_FINE_TUNE_ALL, PSTR("G29P4R999T"));
179
+  GCODES_ITEM(MSG_UBL_FINE_TUNE_ALL, PSTR("G29P4RT"));
180
   GCODES_ITEM(MSG_UBL_FINE_TUNE_CLOSEST, PSTR("G29P4T"));
180
   GCODES_ITEM(MSG_UBL_FINE_TUNE_CLOSEST, PSTR("G29P4T"));
181
   SUBMENU(MSG_UBL_MESH_HEIGHT_ADJUST, _menu_ubl_height_adjust);
181
   SUBMENU(MSG_UBL_MESH_HEIGHT_ADJUST, _menu_ubl_height_adjust);
182
   ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status);
182
   ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status);
594
     GCODES_ITEM(MSG_UBL_1_BUILD_COLD_MESH, PSTR("G29NP1"));
594
     GCODES_ITEM(MSG_UBL_1_BUILD_COLD_MESH, PSTR("G29NP1"));
595
     GCODES_ITEM(MSG_UBL_2_SMART_FILLIN, PSTR("G29P3T0"));
595
     GCODES_ITEM(MSG_UBL_2_SMART_FILLIN, PSTR("G29P3T0"));
596
     SUBMENU(MSG_UBL_3_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
596
     SUBMENU(MSG_UBL_3_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
597
-    GCODES_ITEM(MSG_UBL_4_FINE_TUNE_ALL, PSTR("G29P4R999T"));
597
+    GCODES_ITEM(MSG_UBL_4_FINE_TUNE_ALL, PSTR("G29P4RT"));
598
     SUBMENU(MSG_UBL_5_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
598
     SUBMENU(MSG_UBL_5_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
599
-    GCODES_ITEM(MSG_UBL_6_FINE_TUNE_ALL, PSTR("G29P4R999T"));
599
+    GCODES_ITEM(MSG_UBL_6_FINE_TUNE_ALL, PSTR("G29P4RT"));
600
     ACTION_ITEM(MSG_UBL_7_SAVE_MESH, _lcd_ubl_save_mesh_cmd);
600
     ACTION_ITEM(MSG_UBL_7_SAVE_MESH, _lcd_ubl_save_mesh_cmd);
601
     END_MENU();
601
     END_MENU();
602
   }
602
   }

Loading…
Cancel
Save