|
@@ -2565,7 +2565,7 @@ static void clean_up_after_endstop_or_probe_move() {
|
2565
|
2565
|
ep = ABL_GRID_MAX_POINTS_X - 1;
|
2566
|
2566
|
ip = ABL_GRID_MAX_POINTS_X - 2;
|
2567
|
2567
|
}
|
2568
|
|
- if (y > 0 && y < ABL_TEMP_POINTS_Y - 1)
|
|
2568
|
+ if (WITHIN(y, 1, ABL_TEMP_POINTS_Y - 2))
|
2569
|
2569
|
return LINEAR_EXTRAPOLATION(
|
2570
|
2570
|
bed_level_grid[ep][y - 1],
|
2571
|
2571
|
bed_level_grid[ip][y - 1]
|
|
@@ -2581,7 +2581,7 @@ static void clean_up_after_endstop_or_probe_move() {
|
2581
|
2581
|
ep = ABL_GRID_MAX_POINTS_Y - 1;
|
2582
|
2582
|
ip = ABL_GRID_MAX_POINTS_Y - 2;
|
2583
|
2583
|
}
|
2584
|
|
- if (x > 0 && x < ABL_TEMP_POINTS_X - 1)
|
|
2584
|
+ if (WITHIN(x, 1, ABL_TEMP_POINTS_X - 2))
|
2585
|
2585
|
return LINEAR_EXTRAPOLATION(
|
2586
|
2586
|
bed_level_grid[x - 1][ep],
|
2587
|
2587
|
bed_level_grid[x - 1][ip]
|
|
@@ -3024,9 +3024,9 @@ bool position_is_reachable(float target[XYZ]
|
3024
|
3024
|
return HYPOT2(dx, dy) <= sq((float)(DELTA_PRINTABLE_RADIUS));
|
3025
|
3025
|
#else
|
3026
|
3026
|
const float dz = RAW_Z_POSITION(target[Z_AXIS]);
|
3027
|
|
- return dx >= X_MIN_POS - 0.0001 && dx <= X_MAX_POS + 0.0001
|
3028
|
|
- && dy >= Y_MIN_POS - 0.0001 && dy <= Y_MAX_POS + 0.0001
|
3029
|
|
- && dz >= Z_MIN_POS - 0.0001 && dz <= Z_MAX_POS + 0.0001;
|
|
3027
|
+ return WITHIN(dx, X_MIN_POS - 0.0001, X_MAX_POS + 0.0001)
|
|
3028
|
+ && WITHIN(dy, Y_MIN_POS - 0.0001, Y_MAX_POS + 0.0001)
|
|
3029
|
+ && WITHIN(dz, Z_MIN_POS - 0.0001, Z_MAX_POS + 0.0001);
|
3030
|
3030
|
#endif
|
3031
|
3031
|
}
|
3032
|
3032
|
|
|
@@ -3790,7 +3790,7 @@ inline void gcode_G28() {
|
3790
|
3790
|
#endif
|
3791
|
3791
|
|
3792
|
3792
|
const MeshLevelingState state = code_seen('S') ? (MeshLevelingState)code_value_byte() : MeshReport;
|
3793
|
|
- if (state < 0 || state > 5) {
|
|
3793
|
+ if (!WITHIN(state, 0, 5)) {
|
3794
|
3794
|
SERIAL_PROTOCOLLNPGM("S out of range (0-5).");
|
3795
|
3795
|
return;
|
3796
|
3796
|
}
|
|
@@ -3865,7 +3865,7 @@ inline void gcode_G28() {
|
3865
|
3865
|
case MeshSet:
|
3866
|
3866
|
if (code_seen('X')) {
|
3867
|
3867
|
px = code_value_int() - 1;
|
3868
|
|
- if (px < 0 || px >= MESH_NUM_X_POINTS) {
|
|
3868
|
+ if (!WITHIN(px, 0, MESH_NUM_X_POINTS - 1)) {
|
3869
|
3869
|
SERIAL_PROTOCOLLNPGM("X out of range (1-" STRINGIFY(MESH_NUM_X_POINTS) ").");
|
3870
|
3870
|
return;
|
3871
|
3871
|
}
|
|
@@ -3877,7 +3877,7 @@ inline void gcode_G28() {
|
3877
|
3877
|
|
3878
|
3878
|
if (code_seen('Y')) {
|
3879
|
3879
|
py = code_value_int() - 1;
|
3880
|
|
- if (py < 0 || py >= MESH_NUM_Y_POINTS) {
|
|
3880
|
+ if (!WITHIN(py, 0, MESH_NUM_Y_POINTS - 1)) {
|
3881
|
3881
|
SERIAL_PROTOCOLLNPGM("Y out of range (1-" STRINGIFY(MESH_NUM_Y_POINTS) ").");
|
3882
|
3882
|
return;
|
3883
|
3883
|
}
|
|
@@ -4967,7 +4967,7 @@ inline void gcode_M42() {
|
4967
|
4967
|
if (!code_seen('S')) return;
|
4968
|
4968
|
|
4969
|
4969
|
int pin_status = code_value_int();
|
4970
|
|
- if (pin_status < 0 || pin_status > 255) return;
|
|
4970
|
+ if (!WITHIN(pin_status, 0, 255)) return;
|
4971
|
4971
|
|
4972
|
4972
|
int pin_number = code_seen('P') ? code_value_int() : LED_PIN;
|
4973
|
4973
|
if (pin_number < 0) return;
|
|
@@ -5111,7 +5111,7 @@ inline void gcode_M42() {
|
5111
|
5111
|
if (axis_unhomed_error(true, true, true)) return;
|
5112
|
5112
|
|
5113
|
5113
|
int8_t verbose_level = code_seen('V') ? code_value_byte() : 1;
|
5114
|
|
- if (verbose_level < 0 || verbose_level > 4) {
|
|
5114
|
+ if (!WITHIN(verbose_level, 0, 4)) {
|
5115
|
5115
|
SERIAL_PROTOCOLLNPGM("?Verbose Level not plausible (0-4).");
|
5116
|
5116
|
return;
|
5117
|
5117
|
}
|
|
@@ -5120,7 +5120,7 @@ inline void gcode_M42() {
|
5120
|
5120
|
SERIAL_PROTOCOLLNPGM("M48 Z-Probe Repeatability Test");
|
5121
|
5121
|
|
5122
|
5122
|
int8_t n_samples = code_seen('P') ? code_value_byte() : 10;
|
5123
|
|
- if (n_samples < 4 || n_samples > 50) {
|
|
5123
|
+ if (!WITHIN(n_samples, 4, 50)) {
|
5124
|
5124
|
SERIAL_PROTOCOLLNPGM("?Sample size not plausible (4-50).");
|
5125
|
5125
|
return;
|
5126
|
5126
|
}
|
|
@@ -5132,7 +5132,7 @@ inline void gcode_M42() {
|
5132
|
5132
|
|
5133
|
5133
|
float X_probe_location = code_seen('X') ? code_value_axis_units(X_AXIS) : X_current + X_PROBE_OFFSET_FROM_EXTRUDER;
|
5134
|
5134
|
#if DISABLED(DELTA)
|
5135
|
|
- if (X_probe_location < LOGICAL_X_POSITION(MIN_PROBE_X) || X_probe_location > LOGICAL_X_POSITION(MAX_PROBE_X)) {
|
|
5135
|
+ if (!WITHIN(X_probe_location, LOGICAL_X_POSITION(MIN_PROBE_X), LOGICAL_X_POSITION(MAX_PROBE_X))) {
|
5136
|
5136
|
out_of_range_error(PSTR("X"));
|
5137
|
5137
|
return;
|
5138
|
5138
|
}
|
|
@@ -5140,7 +5140,7 @@ inline void gcode_M42() {
|
5140
|
5140
|
|
5141
|
5141
|
float Y_probe_location = code_seen('Y') ? code_value_axis_units(Y_AXIS) : Y_current + Y_PROBE_OFFSET_FROM_EXTRUDER;
|
5142
|
5142
|
#if DISABLED(DELTA)
|
5143
|
|
- if (Y_probe_location < LOGICAL_Y_POSITION(MIN_PROBE_Y) || Y_probe_location > LOGICAL_Y_POSITION(MAX_PROBE_Y)) {
|
|
5143
|
+ if (!WITHIN(Y_probe_location, LOGICAL_Y_POSITION(MIN_PROBE_Y), LOGICAL_Y_POSITION(MAX_PROBE_Y))) {
|
5144
|
5144
|
out_of_range_error(PSTR("Y"));
|
5145
|
5145
|
return;
|
5146
|
5146
|
}
|
|
@@ -6791,7 +6791,7 @@ inline void gcode_M226() {
|
6791
|
6791
|
inline void gcode_M280() {
|
6792
|
6792
|
if (!code_seen('P')) return;
|
6793
|
6793
|
int servo_index = code_value_int();
|
6794
|
|
- if (servo_index >= 0 && servo_index < NUM_SERVOS) {
|
|
6794
|
+ if (WITHIN(servo_index, 0, NUM_SERVOS - 1)) {
|
6795
|
6795
|
if (code_seen('S'))
|
6796
|
6796
|
MOVE_SERVO(servo_index, code_value_int());
|
6797
|
6797
|
else {
|
|
@@ -6998,7 +6998,7 @@ inline void gcode_M303() {
|
6998
|
6998
|
|
6999
|
6999
|
float temp = code_seen('S') ? code_value_temp_abs() : (e < 0 ? 70.0 : 150.0);
|
7000
|
7000
|
|
7001
|
|
- if (e >= 0 && e < HOTENDS)
|
|
7001
|
+ if (WITHIN(e, 0, HOTENDS - 1))
|
7002
|
7002
|
target_extruder = e;
|
7003
|
7003
|
|
7004
|
7004
|
KEEPALIVE_STATE(NOT_BUSY); // don't send "busy: processing" messages during autotune output
|
|
@@ -7219,7 +7219,7 @@ void quickstop_stepper() {
|
7219
|
7219
|
if (code_seen('L')) {
|
7220
|
7220
|
const int8_t storage_slot = code_has_value() ? code_value_int() : ubl.state.eeprom_storage_slot;
|
7221
|
7221
|
const int16_t j = (UBL_LAST_EEPROM_INDEX - ubl.eeprom_start) / sizeof(ubl.z_values);
|
7222
|
|
- if (storage_slot < 0 || storage_slot >= j || ubl.eeprom_start <= 0) {
|
|
7222
|
+ if (!WITHIN(storage_slot, 0, j - 1) || ubl.eeprom_start <= 0) {
|
7223
|
7223
|
SERIAL_PROTOCOLLNPGM("?EEPROM storage not available for use.\n");
|
7224
|
7224
|
return;
|
7225
|
7225
|
}
|
|
@@ -7312,7 +7312,7 @@ void quickstop_stepper() {
|
7312
|
7312
|
}
|
7313
|
7313
|
}
|
7314
|
7314
|
else if (hasI && hasJ && hasZ) {
|
7315
|
|
- if (px >= 0 && px < MESH_NUM_X_POINTS && py >= 0 && py < MESH_NUM_Y_POINTS)
|
|
7315
|
+ if (WITHIN(px, 0, MESH_NUM_X_POINTS - 1) && WITHIN(py, 0, MESH_NUM_Y_POINTS - 1))
|
7316
|
7316
|
mbl.set_z(px, py, z);
|
7317
|
7317
|
else {
|
7318
|
7318
|
SERIAL_ERROR_START;
|
|
@@ -7341,7 +7341,7 @@ void quickstop_stepper() {
|
7341
|
7341
|
if ((hasZ = code_seen('Z'))) z = code_value_axis_units(Z_AXIS);
|
7342
|
7342
|
|
7343
|
7343
|
if (hasI && hasJ && hasZ) {
|
7344
|
|
- if (px >= 0 && px < ABL_GRID_MAX_POINTS_X && py >= 0 && py < ABL_GRID_MAX_POINTS_X) {
|
|
7344
|
+ if (WITHIN(px, 0, ABL_GRID_MAX_POINTS_X - 1) && WITHIN(py, 0, ABL_GRID_MAX_POINTS_X - 1)) {
|
7345
|
7345
|
bed_level_grid[px][py] = z;
|
7346
|
7346
|
#if ENABLED(ABL_BILINEAR_SUBDIVISION)
|
7347
|
7347
|
bed_level_virt_interpolate();
|
|
@@ -7379,7 +7379,7 @@ void quickstop_stepper() {
|
7379
|
7379
|
if (axis_homed[i]) {
|
7380
|
7380
|
float base = (current_position[i] > (soft_endstop_min[i] + soft_endstop_max[i]) * 0.5) ? base_home_pos((AxisEnum)i) : 0,
|
7381
|
7381
|
diff = current_position[i] - LOGICAL_POSITION(base, i);
|
7382
|
|
- if (diff > -20 && diff < 20) {
|
|
7382
|
+ if (WITHIN(diff, -20, 20)) {
|
7383
|
7383
|
set_home_offset((AxisEnum)i, home_offset[i] - diff);
|
7384
|
7384
|
}
|
7385
|
7385
|
else {
|
|
@@ -7453,7 +7453,7 @@ inline void gcode_M503() {
|
7453
|
7453
|
|
7454
|
7454
|
if (code_seen('Z')) {
|
7455
|
7455
|
float value = code_value_axis_units(Z_AXIS);
|
7456
|
|
- if (Z_PROBE_OFFSET_RANGE_MIN <= value && value <= Z_PROBE_OFFSET_RANGE_MAX) {
|
|
7456
|
+ if (WITHIN(value, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
|
7457
|
7457
|
|
7458
|
7458
|
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
7459
|
7459
|
// Correct bilinear grid for new probe offset
|