|
@@ -341,7 +341,7 @@
|
341
|
341
|
if (code_seen('Q')) {
|
342
|
342
|
|
343
|
343
|
const int test_pattern = code_has_value() ? code_value_int() : -1;
|
344
|
|
- if (test_pattern < 0 || test_pattern > 2) {
|
|
344
|
+ if (!WITHIN(test_pattern, 0, 2)) {
|
345
|
345
|
SERIAL_PROTOCOLLNPGM("Invalid test_pattern value. (0-2)\n");
|
346
|
346
|
return;
|
347
|
347
|
}
|
|
@@ -374,7 +374,7 @@
|
374
|
374
|
/*
|
375
|
375
|
if (code_seen('U')) {
|
376
|
376
|
unlevel_value = code_value_int();
|
377
|
|
- //if (unlevel_value < 0 || unlevel_value > 7) {
|
|
377
|
+ //if (!WITHIN(unlevel_value, 0, 7)) {
|
378
|
378
|
// SERIAL_PROTOCOLLNPGM("Invalid Unlevel value. (0-4)\n");
|
379
|
379
|
// return;
|
380
|
380
|
//}
|
|
@@ -383,7 +383,7 @@
|
383
|
383
|
|
384
|
384
|
if (code_seen('P')) {
|
385
|
385
|
phase_value = code_value_int();
|
386
|
|
- if (phase_value < 0 || phase_value > 7) {
|
|
386
|
+ if (!WITHIN(phase_value, 0, 7)) {
|
387
|
387
|
SERIAL_PROTOCOLLNPGM("Invalid Phase value. (0-4)\n");
|
388
|
388
|
return;
|
389
|
389
|
}
|
|
@@ -566,7 +566,7 @@
|
566
|
566
|
|
567
|
567
|
const int16_t j = (UBL_LAST_EEPROM_INDEX - ubl.eeprom_start) / sizeof(ubl.z_values);
|
568
|
568
|
|
569
|
|
- if (storage_slot < 0 || storage_slot >= j || ubl.eeprom_start <= 0) {
|
|
569
|
+ if (!WITHIN(storage_slot, 0, j - 1) || ubl.eeprom_start <= 0) {
|
570
|
570
|
SERIAL_PROTOCOLLNPGM("?EEPROM storage not available for use.\n");
|
571
|
571
|
return;
|
572
|
572
|
}
|
|
@@ -600,7 +600,7 @@
|
600
|
600
|
|
601
|
601
|
const int16_t j = (UBL_LAST_EEPROM_INDEX - ubl.eeprom_start) / sizeof(ubl.z_values);
|
602
|
602
|
|
603
|
|
- if (storage_slot < 0 || storage_slot >= j || ubl.eeprom_start <= 0) {
|
|
603
|
+ if (!WITHIN(storage_slot, 0, j - 1) || ubl.eeprom_start <= 0) {
|
604
|
604
|
SERIAL_PROTOCOLLNPGM("?EEPROM storage not available for use.\n");
|
605
|
605
|
SERIAL_PROTOCOLLNPAIR("?Use 0 to ", j - 1);
|
606
|
606
|
goto LEAVE;
|
|
@@ -760,7 +760,7 @@
|
760
|
760
|
rawy = ubl.mesh_index_to_ypos[location.y_index];
|
761
|
761
|
|
762
|
762
|
// TODO: Change to use `position_is_reachable` (for SCARA-compatibility)
|
763
|
|
- if (rawx < (MIN_PROBE_X) || rawx > (MAX_PROBE_X) || rawy < (MIN_PROBE_Y) || rawy > (MAX_PROBE_Y)) {
|
|
763
|
+ if (!WITHIN(rawx, MIN_PROBE_X, MAX_PROBE_X) || !WITHIN(rawy, MIN_PROBE_Y, MAX_PROBE_Y)) {
|
764
|
764
|
SERIAL_ERROR_START;
|
765
|
765
|
SERIAL_ERRORLNPGM("Attempt to probe off the bed.");
|
766
|
766
|
ubl.has_control_of_lcd_panel = false;
|
|
@@ -910,7 +910,7 @@
|
910
|
910
|
rawy = ubl.mesh_index_to_ypos[location.y_index];
|
911
|
911
|
|
912
|
912
|
// TODO: Change to use `position_is_reachable` (for SCARA-compatibility)
|
913
|
|
- if (rawx < (X_MIN_POS) || rawx > (X_MAX_POS) || rawy < (Y_MIN_POS) || rawy > (Y_MAX_POS)) {
|
|
913
|
+ if (!WITHIN(rawx, X_MIN_POS, X_MAX_POS) || !WITHIN(rawy, Y_MIN_POS, Y_MAX_POS)) {
|
914
|
914
|
SERIAL_ERROR_START;
|
915
|
915
|
SERIAL_ERRORLNPGM("Attempt to probe off the bed.");
|
916
|
916
|
ubl.has_control_of_lcd_panel = false;
|
|
@@ -982,21 +982,21 @@
|
982
|
982
|
#endif
|
983
|
983
|
|
984
|
984
|
g29_verbose_level = code_seen('V') ? code_value_int() : 0;
|
985
|
|
- if (g29_verbose_level < 0 || g29_verbose_level > 4) {
|
|
985
|
+ if (!WITHIN(g29_verbose_level, 0, 4)) {
|
986
|
986
|
SERIAL_PROTOCOLLNPGM("Invalid Verbose Level specified. (0-4)\n");
|
987
|
987
|
return UBL_ERR;
|
988
|
988
|
}
|
989
|
989
|
|
990
|
990
|
x_flag = code_seen('X') && code_has_value();
|
991
|
991
|
x_pos = x_flag ? code_value_float() : current_position[X_AXIS];
|
992
|
|
- if (x_pos < LOGICAL_X_POSITION(X_MIN_POS) || x_pos > LOGICAL_X_POSITION(X_MAX_POS)) {
|
|
992
|
+ if (!WITHIN(RAW_X_POSITION(x_pos), X_MIN_POS, X_MAX_POS)) {
|
993
|
993
|
SERIAL_PROTOCOLLNPGM("Invalid X location specified.\n");
|
994
|
994
|
return UBL_ERR;
|
995
|
995
|
}
|
996
|
996
|
|
997
|
997
|
y_flag = code_seen('Y') && code_has_value();
|
998
|
998
|
y_pos = y_flag ? code_value_float() : current_position[Y_AXIS];
|
999
|
|
- if (y_pos < LOGICAL_Y_POSITION(Y_MIN_POS) || y_pos > LOGICAL_Y_POSITION(Y_MAX_POS)) {
|
|
999
|
+ if (!WITHIN(RAW_Y_POSITION(y_pos), Y_MIN_POS, Y_MAX_POS)) {
|
1000
|
1000
|
SERIAL_PROTOCOLLNPGM("Invalid Y location specified.\n");
|
1001
|
1001
|
return UBL_ERR;
|
1002
|
1002
|
}
|
|
@@ -1024,7 +1024,7 @@
|
1024
|
1024
|
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
1025
|
1025
|
if (code_seen('F') && code_has_value()) {
|
1026
|
1026
|
const float fh = code_value_float();
|
1027
|
|
- if (fh < 0.0 || fh > 100.0) {
|
|
1027
|
+ if (!WITHIN(fh, 0.0, 100.0)) {
|
1028
|
1028
|
SERIAL_PROTOCOLLNPGM("?Bed Level Correction Fade Height Not Plausible.\n");
|
1029
|
1029
|
return UBL_ERR;
|
1030
|
1030
|
}
|
|
@@ -1041,7 +1041,7 @@
|
1041
|
1041
|
}
|
1042
|
1042
|
|
1043
|
1043
|
map_type = code_seen('O') && code_has_value() ? code_value_int() : 0;
|
1044
|
|
- if (map_type < 0 || map_type > 1) {
|
|
1044
|
+ if (!WITHIN(map_type, 0, 1)) {
|
1045
|
1045
|
SERIAL_PROTOCOLLNPGM("Invalid map type.\n");
|
1046
|
1046
|
return UBL_ERR;
|
1047
|
1047
|
}
|
|
@@ -1049,7 +1049,7 @@
|
1049
|
1049
|
/*
|
1050
|
1050
|
if (code_seen('M')) { // Check if a map type was specified
|
1051
|
1051
|
map_type = code_has_value() ? code_value_int() : 0;
|
1052
|
|
- if (map_type < 0 || map_type > 1) {
|
|
1052
|
+ if (!WITHIN(map_type, 0, 1)) {
|
1053
|
1053
|
SERIAL_PROTOCOLLNPGM("Invalid map type.\n");
|
1054
|
1054
|
return UBL_ERR;
|
1055
|
1055
|
}
|
|
@@ -1249,7 +1249,7 @@
|
1249
|
1249
|
|
1250
|
1250
|
int16_t j = (UBL_LAST_EEPROM_INDEX - ubl.eeprom_start) / sizeof(tmp_z_values);
|
1251
|
1251
|
|
1252
|
|
- if (storage_slot < 0 || storage_slot > j || ubl.eeprom_start <= 0) {
|
|
1252
|
+ if (!WITHIN(storage_slot, 0, j - 1) || ubl.eeprom_start <= 0) {
|
1253
|
1253
|
SERIAL_PROTOCOLLNPGM("?EEPROM storage not available for use.\n");
|
1254
|
1254
|
return;
|
1255
|
1255
|
}
|
|
@@ -1296,7 +1296,7 @@
|
1296
|
1296
|
// Prune them from the list and ignore them till the next Phase (manual nozzle probing).
|
1297
|
1297
|
|
1298
|
1298
|
if (probe_as_reference &&
|
1299
|
|
- (rawx < (MIN_PROBE_X) || rawx > (MAX_PROBE_X) || rawy < (MIN_PROBE_Y) || rawy > (MAX_PROBE_Y))
|
|
1299
|
+ (!WITHIN(rawx, MIN_PROBE_X, MAX_PROBE_X) || !WITHIN(rawy, MIN_PROBE_Y, MAX_PROBE_Y))
|
1300
|
1300
|
) continue;
|
1301
|
1301
|
|
1302
|
1302
|
// Unreachable. Check if it's the closest location to the nozzle.
|
|
@@ -1360,7 +1360,7 @@
|
1360
|
1360
|
rawy = ubl.mesh_index_to_ypos[location.y_index];
|
1361
|
1361
|
|
1362
|
1362
|
// TODO: Change to use `position_is_reachable` (for SCARA-compatibility)
|
1363
|
|
- if (rawx < (X_MIN_POS) || rawx > (X_MAX_POS) || rawy < (Y_MIN_POS) || rawy > (Y_MAX_POS)) { // In theory, we don't need this check.
|
|
1363
|
+ if (!WITHIN(rawx, X_MIN_POS, X_MAX_POS) || !WITHIN(rawy, Y_MIN_POS, Y_MAX_POS)) { // In theory, we don't need this check.
|
1364
|
1364
|
SERIAL_ERROR_START;
|
1365
|
1365
|
SERIAL_ERRORLNPGM("Attempt to edit off the bed."); // This really can't happen, but do the check for now
|
1366
|
1366
|
ubl.has_control_of_lcd_panel = false;
|