Skip to content

Commit 0f453d7

Browse files
slowbroptoal
authored andcommitted
🐛 Fix UBL 'R' parameter and adjust 'P' (MarlinFirmware#22129)
1 parent fa088c7 commit 0f453d7

4 files changed

Lines changed: 23 additions & 23 deletions

File tree

Marlin/src/feature/bedlevel/ubl/ubl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static void serial_echo_column_labels(const uint8_t sp) {
164164
* 2: TODO: Display on Graphical LCD
165165
* 4: Compact Human-Readable
166166
*/
167-
void unified_bed_leveling::display_map(const int map_type) {
167+
void unified_bed_leveling::display_map(const uint8_t map_type) {
168168
const bool was = gcode.set_autoreport_paused(true);
169169

170170
constexpr uint8_t eachsp = 1 + 6 + 1, // [-3.567]
@@ -263,7 +263,7 @@ bool unified_bed_leveling::sanity_check() {
263263
void GcodeSuite::M1004() {
264264

265265
#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")
267267

268268
#if HAS_HOTEND
269269
if (parser.seenval('H')) { // Handle H# parameter to set Hotend temp

Marlin/src/feature/bedlevel/ubl/ubl.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ struct mesh_index_pair;
4747

4848
typedef struct {
4949
bool C_seen;
50-
int8_t V_verbosity,
50+
int8_t KLS_storage_slot;
51+
uint8_t R_repetition,
52+
V_verbosity,
5153
P_phase,
52-
R_repetition,
53-
KLS_storage_slot,
5454
T_map_type;
5555
float B_shim_thickness,
5656
C_constant;
@@ -98,7 +98,7 @@ class unified_bed_leveling {
9898
static void report_state();
9999
static void save_ubl_active_state_and_disable();
100100
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;
102102
static mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const xy_pos_t&, const bool=false, MeshFlags *done_flags=nullptr) _O0;
103103
static mesh_index_pair find_furthest_invalid_mesh_point() _O0;
104104
static void reset();

Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ void unified_bed_leveling::G29() {
305305
bool probe_deployed = false;
306306
if (G29_parse_parameters()) return; // Abort on parameter error
307307

308-
const int8_t p_val = parser.intval('P', -1);
308+
const uint8_t p_val = parser.byteval('P');
309309
const bool may_move = p_val == 1 || p_val == 2 || p_val == 4 || parser.seen_test('J');
310310
#if ENABLED(HAS_MULTI_HOTEND)
311311
const uint8_t old_tool_index = active_extruder;
@@ -321,7 +321,7 @@ void unified_bed_leveling::G29() {
321321

322322
// Invalidate one or more nearby mesh points, possibly all.
323323
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;
325325
bool invalidate_all = count >= GRID_MAX_POINTS;
326326
if (!invalidate_all) {
327327
while (count--) {
@@ -345,7 +345,7 @@ void unified_bed_leveling::G29() {
345345
}
346346

347347
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;
349349
if (!WITHIN(test_pattern, -1, 2)) {
350350
SERIAL_ECHOLNPGM("Invalid test_pattern value. (-1 to 2)\n");
351351
return;
@@ -592,7 +592,7 @@ void unified_bed_leveling::G29() {
592592
//
593593

594594
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;
596596

597597
int16_t a = settings.calc_num_meshes();
598598

@@ -617,10 +617,10 @@ void unified_bed_leveling::G29() {
617617
//
618618

619619
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;
621621

622-
if (param.KLS_storage_slot == -1) // Special case, the user wants to 'Export' the mesh to the
623-
return report_current_mesh(); // host program to be saved on the user's computer
622+
if (param.KLS_storage_slot == -1) // Special case: 'Export' the mesh to the
623+
return report_current_mesh(); // host so it can be saved in a file.
624624

625625
int16_t a = settings.calc_num_meshes();
626626

@@ -673,7 +673,7 @@ void unified_bed_leveling::G29() {
673673
*/
674674
void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const_float_t offset) {
675675
float sum = 0;
676-
int n = 0;
676+
uint8_t n = 0;
677677
GRID_LOOP(x, y)
678678
if (!isnan(z_values[x][y])) {
679679
sum += z_values[x][y];
@@ -734,7 +734,7 @@ void unified_bed_leveling::shift_mesh_height() {
734734
do {
735735
if (do_ubl_mesh_map) display_map(param.T_map_type);
736736

737-
const int point_num = (GRID_MAX_POINTS) - count + 1;
737+
const uint8_t point_num = (GRID_MAX_POINTS - count) + 1;
738738
SERIAL_ECHOLNPAIR("Probing mesh point ", point_num, "/", GRID_MAX_POINTS, ".");
739739
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)));
740740

@@ -1083,22 +1083,22 @@ bool unified_bed_leveling::G29_parse_parameters() {
10831083
param.R_repetition = 0;
10841084

10851085
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;
10871087
NOMORE(param.R_repetition, GRID_MAX_POINTS);
10881088
if (param.R_repetition < 1) {
10891089
SERIAL_ECHOLNPGM("?(R)epetition count invalid (1+).\n");
10901090
return UBL_ERR;
10911091
}
10921092
}
10931093

1094-
param.V_verbosity = parser.intval('V');
1094+
param.V_verbosity = parser.byteval('V');
10951095
if (!WITHIN(param.V_verbosity, 0, 4)) {
10961096
SERIAL_ECHOLNPGM("?(V)erbose level implausible (0-4).\n");
10971097
err_flag = true;
10981098
}
10991099

11001100
if (parser.seen('P')) {
1101-
const int pv = parser.value_int();
1101+
const uint8_t pv = parser.value_byte();
11021102
#if !HAS_BED_PROBE
11031103
if (pv == 1) {
11041104
SERIAL_ECHOLNPGM("G29 P1 requires a probe.\n");
@@ -1181,7 +1181,7 @@ bool unified_bed_leveling::G29_parse_parameters() {
11811181
}
11821182
#endif
11831183

1184-
param.T_map_type = parser.intval('T');
1184+
param.T_map_type = parser.byteval('T');
11851185
if (!WITHIN(param.T_map_type, 0, 2)) {
11861186
SERIAL_ECHOLNPGM("Invalid map type.\n");
11871187
return UBL_ERR;
@@ -1833,7 +1833,7 @@ void unified_bed_leveling::smart_fill_mesh() {
18331833
return;
18341834
}
18351835

1836-
param.KLS_storage_slot = parser.value_int();
1836+
param.KLS_storage_slot = (int8_t)parser.value_int();
18371837

18381838
float tmp_z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
18391839
settings.load_mesh(param.KLS_storage_slot, &tmp_z_values);

Marlin/src/lcd/menu/menu_ubl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ void _menu_ubl_height_adjust() {
176176
void _lcd_ubl_edit_mesh() {
177177
START_MENU();
178178
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"));
180180
GCODES_ITEM(MSG_UBL_FINE_TUNE_CLOSEST, PSTR("G29P4T"));
181181
SUBMENU(MSG_UBL_MESH_HEIGHT_ADJUST, _menu_ubl_height_adjust);
182182
ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status);
@@ -594,9 +594,9 @@ void _menu_ubl_tools() {
594594
GCODES_ITEM(MSG_UBL_1_BUILD_COLD_MESH, PSTR("G29NP1"));
595595
GCODES_ITEM(MSG_UBL_2_SMART_FILLIN, PSTR("G29P3T0"));
596596
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"));
598598
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"));
600600
ACTION_ITEM(MSG_UBL_7_SAVE_MESH, _lcd_ubl_save_mesh_cmd);
601601
END_MENU();
602602
}

0 commit comments

Comments
 (0)