Fix MIN/MAX function collision with macros
This commit is contained in:
@ -126,7 +126,7 @@ typedef struct { int16_t X, Y, Z; } tmc
|
||||
typedef struct { bool X, Y, Z, X2, Y2, Z2, Z3, E0, E1, E2, E3, E4, E5; } tmc_stealth_enabled_t;
|
||||
|
||||
// Limit an index to an array size
|
||||
#define ALIM(I,ARR) MIN(I, COUNT(ARR) - 1)
|
||||
#define ALIM(I,ARR) _MIN(I, COUNT(ARR) - 1)
|
||||
|
||||
/**
|
||||
* Current EEPROM Layout
|
||||
|
@ -125,7 +125,7 @@ float destination[XYZE]; // = { 0 }
|
||||
);
|
||||
LOOP_XYZ(i) HOTEND_LOOP() hotend_offset[i][e] = tmp[i][e];
|
||||
#if ENABLED(DUAL_X_CARRIAGE)
|
||||
hotend_offset[X_AXIS][1] = MAX(X2_HOME_POS, X2_MAX_POS);
|
||||
hotend_offset[X_AXIS][1] = _MAX(X2_HOME_POS, X2_MAX_POS);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
@ -473,7 +473,7 @@ void clean_up_after_endstop_or_probe_move() {
|
||||
if (axis == X_AXIS) {
|
||||
|
||||
// In Dual X mode hotend_offset[X] is T1's home position
|
||||
const float dual_max_x = MAX(hotend_offset[X_AXIS][1], X2_MAX_POS);
|
||||
const float dual_max_x = _MAX(hotend_offset[X_AXIS][1], X2_MAX_POS);
|
||||
|
||||
if (new_tool_index != 0) {
|
||||
// T1 can move from X2_MIN_POS to X2_MAX_POS or X2 home position (whichever is larger)
|
||||
@ -484,7 +484,7 @@ void clean_up_after_endstop_or_probe_move() {
|
||||
// In Duplication Mode, T0 can move as far left as X1_MIN_POS
|
||||
// but not so far to the right that T1 would move past the end
|
||||
soft_endstop[X_AXIS].min = X1_MIN_POS;
|
||||
soft_endstop[X_AXIS].max = MIN(X1_MAX_POS, dual_max_x - duplicate_extruder_x_offset);
|
||||
soft_endstop[X_AXIS].max = _MIN(X1_MAX_POS, dual_max_x - duplicate_extruder_x_offset);
|
||||
}
|
||||
else {
|
||||
// In other modes, T0 can move from X1_MIN_POS to X1_MAX_POS
|
||||
@ -507,7 +507,7 @@ void clean_up_after_endstop_or_probe_move() {
|
||||
case X_AXIS:
|
||||
case Y_AXIS:
|
||||
// Get a minimum radius for clamping
|
||||
delta_max_radius = MIN(ABS(MAX(soft_endstop[X_AXIS].min, soft_endstop[Y_AXIS].min)), soft_endstop[X_AXIS].max, soft_endstop[Y_AXIS].max);
|
||||
delta_max_radius = _MIN(ABS(_MAX(soft_endstop[X_AXIS].min, soft_endstop[Y_AXIS].min)), soft_endstop[X_AXIS].max, soft_endstop[Y_AXIS].max);
|
||||
delta_max_radius_2 = sq(delta_max_radius);
|
||||
break;
|
||||
case Z_AXIS:
|
||||
@ -1441,7 +1441,7 @@ void homeaxis(const AxisEnum axis) {
|
||||
// When homing Z with probe respect probe clearance
|
||||
const float bump = axis_home_dir * (
|
||||
#if HOMING_Z_WITH_PROBE
|
||||
(axis == Z_AXIS && (Z_HOME_BUMP_MM)) ? MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_HOME_BUMP_MM) :
|
||||
(axis == Z_AXIS && (Z_HOME_BUMP_MM)) ? _MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_HOME_BUMP_MM) :
|
||||
#endif
|
||||
home_bump_mm(axis)
|
||||
);
|
||||
|
@ -733,7 +733,7 @@ void Planner::calculate_trapezoid_for_block(block_t* const block, const float &e
|
||||
// reach the final_rate exactly at the end of this block.
|
||||
if (plateau_steps < 0) {
|
||||
const float accelerate_steps_float = CEIL(intersection_distance(initial_rate, final_rate, accel, block->step_event_count));
|
||||
accelerate_steps = MIN(uint32_t(MAX(accelerate_steps_float, 0)), block->step_event_count);
|
||||
accelerate_steps = _MIN(uint32_t(_MAX(accelerate_steps_float, 0)), block->step_event_count);
|
||||
plateau_steps = 0;
|
||||
|
||||
#if ENABLED(S_CURVE_ACCELERATION)
|
||||
@ -855,7 +855,7 @@ void Planner::reverse_pass_kernel(block_t* const current, const block_t * const
|
||||
|
||||
const float new_entry_speed_sqr = TEST(current->flag, BLOCK_BIT_NOMINAL_LENGTH)
|
||||
? max_entry_speed_sqr
|
||||
: MIN(max_entry_speed_sqr, max_allowable_speed_sqr(-current->acceleration, next ? next->entry_speed_sqr : sq(float(MINIMUM_PLANNER_SPEED)), current->millimeters));
|
||||
: _MIN(max_entry_speed_sqr, max_allowable_speed_sqr(-current->acceleration, next ? next->entry_speed_sqr : sq(float(MINIMUM_PLANNER_SPEED)), current->millimeters));
|
||||
if (current->entry_speed_sqr != new_entry_speed_sqr) {
|
||||
|
||||
// Need to recalculate the block speed - Mark it now, so the stepper
|
||||
@ -1817,7 +1817,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
||||
}
|
||||
|
||||
block->steps[E_AXIS] = esteps;
|
||||
block->step_event_count = MAX(block->steps[A_AXIS], block->steps[B_AXIS], block->steps[C_AXIS], esteps);
|
||||
block->step_event_count = _MAX(block->steps[A_AXIS], block->steps[B_AXIS], block->steps[C_AXIS], esteps);
|
||||
|
||||
// Bail if this is a zero-length block
|
||||
if (block->step_event_count < MIN_STEPS_PER_SEGMENT) return false;
|
||||
@ -2128,9 +2128,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
||||
}
|
||||
ys0 = axis_segment_time_us[Y_AXIS][0] = ys0 + segment_time_us;
|
||||
|
||||
const uint32_t max_x_segment_time = MAX(xs0, xs1, xs2),
|
||||
max_y_segment_time = MAX(ys0, ys1, ys2),
|
||||
min_xy_segment_time = MIN(max_x_segment_time, max_y_segment_time);
|
||||
const uint32_t max_x_segment_time = _MAX(xs0, xs1, xs2),
|
||||
max_y_segment_time = _MAX(ys0, ys1, ys2),
|
||||
min_xy_segment_time = _MIN(max_x_segment_time, max_y_segment_time);
|
||||
if (min_xy_segment_time < MAX_FREQ_TIME_US) {
|
||||
const float low_sf = speed_factor * min_xy_segment_time / (MAX_FREQ_TIME_US);
|
||||
NOMORE(speed_factor, low_sf);
|
||||
@ -2370,7 +2370,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
||||
}
|
||||
|
||||
// Get the lowest speed
|
||||
vmax_junction_sqr = MIN(vmax_junction_sqr, block->nominal_speed_sqr, previous_nominal_speed_sqr);
|
||||
vmax_junction_sqr = _MIN(vmax_junction_sqr, block->nominal_speed_sqr, previous_nominal_speed_sqr);
|
||||
}
|
||||
else // Init entry speed to zero. Assume it starts from rest. Planner will correct this later.
|
||||
vmax_junction_sqr = 0;
|
||||
@ -2427,7 +2427,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
||||
// The junction velocity will be shared between successive segments. Limit the junction velocity to their minimum.
|
||||
// Pick the smaller of the nominal speeds. Higher speed shall not be achieved at the junction during coasting.
|
||||
const float previous_nominal_speed = SQRT(previous_nominal_speed_sqr);
|
||||
vmax_junction = MIN(nominal_speed, previous_nominal_speed);
|
||||
vmax_junction = _MIN(nominal_speed, previous_nominal_speed);
|
||||
|
||||
// Now limit the jerk in all axes.
|
||||
const float smaller_speed_factor = vmax_junction / previous_nominal_speed;
|
||||
@ -2448,9 +2448,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
||||
// Calculate jerk depending on whether the axis is coasting in the same direction or reversing.
|
||||
const float jerk = (v_exit > v_entry)
|
||||
? // coasting axis reversal
|
||||
( (v_entry > 0 || v_exit < 0) ? (v_exit - v_entry) : MAX(v_exit, -v_entry) )
|
||||
( (v_entry > 0 || v_exit < 0) ? (v_exit - v_entry) : _MAX(v_exit, -v_entry) )
|
||||
: // v_exit <= v_entry coasting axis reversal
|
||||
( (v_entry < 0 || v_exit > 0) ? (v_entry - v_exit) : MAX(-v_exit, v_entry) );
|
||||
( (v_entry < 0 || v_exit > 0) ? (v_entry - v_exit) : _MAX(-v_exit, v_entry) );
|
||||
|
||||
if (jerk > max_jerk[axis]) {
|
||||
v_factor *= max_jerk[axis] / jerk;
|
||||
@ -2470,7 +2470,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
||||
previous_safe_speed = safe_speed;
|
||||
|
||||
#if ENABLED(JUNCTION_DEVIATION)
|
||||
vmax_junction_sqr = MIN(vmax_junction_sqr, sq(vmax_junction));
|
||||
vmax_junction_sqr = _MIN(vmax_junction_sqr, sq(vmax_junction));
|
||||
#else
|
||||
vmax_junction_sqr = sq(vmax_junction);
|
||||
#endif
|
||||
@ -2485,7 +2485,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
||||
|
||||
// If we are trying to add a split block, start with the
|
||||
// max. allowed speed to avoid an interrupted first move.
|
||||
block->entry_speed_sqr = !split_move ? sq(float(MINIMUM_PLANNER_SPEED)) : MIN(vmax_junction_sqr, v_allowable_sqr);
|
||||
block->entry_speed_sqr = !split_move ? sq(float(MINIMUM_PLANNER_SPEED)) : _MIN(vmax_junction_sqr, v_allowable_sqr);
|
||||
|
||||
// Initialize planner efficiency flags
|
||||
// Set flag if block will always reach maximum junction speed regardless of entry/exit speeds.
|
||||
|
@ -948,6 +948,6 @@ class Planner {
|
||||
#endif // JUNCTION_DEVIATION
|
||||
};
|
||||
|
||||
#define PLANNER_XY_FEEDRATE() (MIN(planner.settings.max_feedrate_mm_s[X_AXIS], planner.settings.max_feedrate_mm_s[Y_AXIS]))
|
||||
#define PLANNER_XY_FEEDRATE() (_MIN(planner.settings.max_feedrate_mm_s[X_AXIS], planner.settings.max_feedrate_mm_s[Y_AXIS]))
|
||||
|
||||
extern Planner planner;
|
||||
|
@ -246,13 +246,13 @@ void PrintCounter::tick() {
|
||||
data.printTime += delta;
|
||||
|
||||
#if SERVICE_INTERVAL_1 > 0
|
||||
data.nextService1 -= MIN(delta, data.nextService1);
|
||||
data.nextService1 -= _MIN(delta, data.nextService1);
|
||||
#endif
|
||||
#if SERVICE_INTERVAL_2 > 0
|
||||
data.nextService2 -= MIN(delta, data.nextService2);
|
||||
data.nextService2 -= _MIN(delta, data.nextService2);
|
||||
#endif
|
||||
#if SERVICE_INTERVAL_3 > 0
|
||||
data.nextService3 -= MIN(delta, data.nextService3);
|
||||
data.nextService3 -= _MIN(delta, data.nextService3);
|
||||
#endif
|
||||
|
||||
update_next = now + updateInterval * 1000;
|
||||
|
@ -444,7 +444,7 @@ bool set_probe_deployed(const bool deploy) {
|
||||
#endif
|
||||
|
||||
if (deploy_stow_condition && unknown_condition)
|
||||
do_probe_raise(MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_CLEARANCE_DEPLOY_PROBE));
|
||||
do_probe_raise(_MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_CLEARANCE_DEPLOY_PROBE));
|
||||
|
||||
#if EITHER(Z_PROBE_SLED, Z_PROBE_ALLEN_KEY)
|
||||
#if ENABLED(Z_PROBE_SLED)
|
||||
@ -780,7 +780,7 @@ float probe_pt(const float &rx, const float &ry, const ProbePtRaise raise_after/
|
||||
const float nz =
|
||||
#if ENABLED(DELTA)
|
||||
// Move below clip height or xy move will be aborted by do_blocking_move_to
|
||||
MIN(current_position[Z_AXIS], delta_clip_start_height)
|
||||
_MIN(current_position[Z_AXIS], delta_clip_start_height)
|
||||
#else
|
||||
current_position[Z_AXIS]
|
||||
#endif
|
||||
|
@ -1291,7 +1291,7 @@ void Stepper::isr() {
|
||||
|
||||
uint32_t interval =
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
MIN(nextAdvanceISR, nextMainISR) // Nearest time interval
|
||||
_MIN(nextAdvanceISR, nextMainISR) // Nearest time interval
|
||||
#else
|
||||
nextMainISR // Remaining stepper ISR time
|
||||
#endif
|
||||
@ -1404,7 +1404,7 @@ void Stepper::stepper_pulse_phase_isr() {
|
||||
|
||||
// Count of pending loops and events for this iteration
|
||||
const uint32_t pending_events = step_event_count - step_events_completed;
|
||||
uint8_t events_to_do = MIN(pending_events, steps_per_isr);
|
||||
uint8_t events_to_do = _MIN(pending_events, steps_per_isr);
|
||||
|
||||
// Just update the value we will get at the end of the loop
|
||||
step_events_completed += events_to_do;
|
||||
|
@ -151,7 +151,7 @@
|
||||
#define MIN_ISR_LOOP_CYCLES (ISR_X_STEPPER_CYCLES + ISR_Y_STEPPER_CYCLES + ISR_Z_STEPPER_CYCLES + ISR_E_STEPPER_CYCLES + ISR_MIXING_STEPPER_CYCLES)
|
||||
|
||||
// Calculate the minimum MPU cycles needed per pulse to enforce, limited to the max stepper rate
|
||||
#define _MIN_STEPPER_PULSE_CYCLES(N) MAX(uint32_t((F_CPU) / (MAXIMUM_STEPPER_RATE)), ((F_CPU) / 500000UL) * (N))
|
||||
#define _MIN_STEPPER_PULSE_CYCLES(N) _MAX(uint32_t((F_CPU) / (MAXIMUM_STEPPER_RATE)), ((F_CPU) / 500000UL) * (N))
|
||||
#if MINIMUM_STEPPER_PULSE
|
||||
#define MIN_STEPPER_PULSE_CYCLES _MIN_STEPPER_PULSE_CYCLES(uint32_t(MINIMUM_STEPPER_PULSE))
|
||||
#elif HAS_DRIVER(LV8729)
|
||||
@ -174,7 +174,7 @@
|
||||
#define ADDED_STEP_TICKS (((MIN_STEPPER_PULSE_CYCLES) / (PULSE_TIMER_PRESCALE)) - (MIN_PULSE_TICKS))
|
||||
|
||||
// But the user could be enforcing a minimum time, so the loop time is
|
||||
#define ISR_LOOP_CYCLES (ISR_LOOP_BASE_CYCLES + MAX(MIN_STEPPER_PULSE_CYCLES, MIN_ISR_LOOP_CYCLES))
|
||||
#define ISR_LOOP_CYCLES (ISR_LOOP_BASE_CYCLES + _MAX(MIN_STEPPER_PULSE_CYCLES, MIN_ISR_LOOP_CYCLES))
|
||||
|
||||
// If linear advance is enabled, then it is handled separately
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
@ -192,7 +192,7 @@
|
||||
#endif
|
||||
|
||||
// And the real loop time
|
||||
#define ISR_LA_LOOP_CYCLES MAX(MIN_STEPPER_PULSE_CYCLES, MIN_ISR_LA_LOOP_CYCLES)
|
||||
#define ISR_LA_LOOP_CYCLES _MAX(MIN_STEPPER_PULSE_CYCLES, MIN_ISR_LA_LOOP_CYCLES)
|
||||
|
||||
#else
|
||||
#define ISR_LA_LOOP_CYCLES 0UL
|
||||
|
@ -143,7 +143,7 @@ hotend_info_t Temperature::temp_hotend[HOTENDS
|
||||
set_fan_speed(fan, new_fan_speed[fan]);
|
||||
break;
|
||||
default:
|
||||
new_fan_speed[fan] = MIN(tmp_temp, 255U);
|
||||
new_fan_speed[fan] = _MIN(tmp_temp, 255U);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -163,7 +163,7 @@ hotend_info_t Temperature::temp_hotend[HOTENDS
|
||||
|
||||
uint8_t Temperature::lcd_tmpfan_speed[
|
||||
#if ENABLED(SINGLENOZZLE)
|
||||
MAX(EXTRUDERS, FAN_COUNT)
|
||||
_MAX(EXTRUDERS, FAN_COUNT)
|
||||
#else
|
||||
FAN_COUNT
|
||||
#endif
|
||||
@ -976,13 +976,13 @@ void Temperature::manage_heater() {
|
||||
updateTemperaturesFromRawValues(); // also resets the watchdog
|
||||
|
||||
#if ENABLED(HEATER_0_USES_MAX6675)
|
||||
if (temp_hotend[0].current > MIN(HEATER_0_MAXTEMP, HEATER_0_MAX6675_TMAX - 1.0)) max_temp_error(H_E0);
|
||||
if (temp_hotend[0].current < MAX(HEATER_0_MINTEMP, HEATER_0_MAX6675_TMIN + .01)) min_temp_error(H_E0);
|
||||
if (temp_hotend[0].current > _MIN(HEATER_0_MAXTEMP, HEATER_0_MAX6675_TMAX - 1.0)) max_temp_error(H_E0);
|
||||
if (temp_hotend[0].current < _MAX(HEATER_0_MINTEMP, HEATER_0_MAX6675_TMIN + .01)) min_temp_error(H_E0);
|
||||
#endif
|
||||
|
||||
#if ENABLED(HEATER_1_USES_MAX6675)
|
||||
if (temp_hotend[1].current > MIN(HEATER_1_MAXTEMP, HEATER_1_MAX6675_TMAX - 1.0)) max_temp_error(H_E1);
|
||||
if (temp_hotend[1].current < MAX(HEATER_1_MINTEMP, HEATER_1_MAX6675_TMIN + .01)) min_temp_error(H_E1);
|
||||
if (temp_hotend[1].current > _MIN(HEATER_1_MAXTEMP, HEATER_1_MAX6675_TMAX - 1.0)) max_temp_error(H_E1);
|
||||
if (temp_hotend[1].current < _MAX(HEATER_1_MINTEMP, HEATER_1_MAX6675_TMIN + .01)) min_temp_error(H_E1);
|
||||
#endif
|
||||
|
||||
#define HAS_THERMAL_PROTECTION (ENABLED(THERMAL_PROTECTION_HOTENDS) || HAS_THERMALLY_PROTECTED_BED || ENABLED(THERMAL_PROTECTION_CHAMBER))
|
||||
@ -1325,7 +1325,7 @@ void Temperature::manage_heater() {
|
||||
//#endif
|
||||
|
||||
// Return degrees C (up to 999, as the LCD only displays 3 digits)
|
||||
return MIN(value + THERMISTOR_ABS_ZERO_C, 999);
|
||||
return _MIN(value + THERMISTOR_ABS_ZERO_C, 999);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1884,7 +1884,7 @@ void Temperature::init() {
|
||||
|
||||
#if ENABLED(ADAPTIVE_FAN_SLOWING)
|
||||
if (adaptive_fan_slowing && heater_id >= 0) {
|
||||
const int fan_index = MIN(heater_id, FAN_COUNT - 1);
|
||||
const int fan_index = _MIN(heater_id, FAN_COUNT - 1);
|
||||
if (fan_speed[fan_index] == 0 || current >= tr_target_temperature[heater_id] - (hysteresis_degc * 0.25f))
|
||||
fan_speed_scaler[fan_index] = 128;
|
||||
else if (current >= tr_target_temperature[heater_id] - (hysteresis_degc * 0.3335f))
|
||||
|
@ -140,7 +140,7 @@ enum ADCSensorState : char {
|
||||
// get all oversampled sensor readings
|
||||
#define MIN_ADC_ISR_LOOPS 10
|
||||
|
||||
#define ACTUAL_ADC_SAMPLES MAX(int(MIN_ADC_ISR_LOOPS), int(SensorsReady))
|
||||
#define ACTUAL_ADC_SAMPLES _MAX(int(MIN_ADC_ISR_LOOPS), int(SensorsReady))
|
||||
|
||||
#if HAS_PID_HEATING
|
||||
#define PID_K2 (1-float(PID_K1))
|
||||
@ -496,7 +496,7 @@ class Temperature {
|
||||
|
||||
static uint8_t lcd_tmpfan_speed[
|
||||
#if ENABLED(SINGLENOZZLE)
|
||||
MAX(EXTRUDERS, FAN_COUNT)
|
||||
_MAX(EXTRUDERS, FAN_COUNT)
|
||||
#else
|
||||
FAN_COUNT
|
||||
#endif
|
||||
@ -613,7 +613,7 @@ class Temperature {
|
||||
#if ENABLED(AUTO_POWER_CONTROL)
|
||||
powerManager.power_on();
|
||||
#endif
|
||||
temp_hotend[ee].target = MIN(celsius, temp_range[ee].maxtemp - 15);
|
||||
temp_hotend[ee].target = _MIN(celsius, temp_range[ee].maxtemp - 15);
|
||||
start_watching_hotend(ee);
|
||||
}
|
||||
|
||||
@ -627,7 +627,7 @@ class Temperature {
|
||||
static void setTargetChamber(const int16_t celsius) {
|
||||
temp_chamber.target =
|
||||
#ifdef CHAMBER_MAXTEMP
|
||||
MIN(celsius, CHAMBER_MAXTEMP)
|
||||
_MIN(celsius, CHAMBER_MAXTEMP)
|
||||
#else
|
||||
celsius
|
||||
#endif
|
||||
@ -676,7 +676,7 @@ class Temperature {
|
||||
#endif
|
||||
temp_bed.target =
|
||||
#ifdef BED_MAXTEMP
|
||||
MIN(celsius, BED_MAXTEMP - 10)
|
||||
_MIN(celsius, BED_MAXTEMP - 10)
|
||||
#else
|
||||
celsius
|
||||
#endif
|
||||
|
@ -942,7 +942,7 @@ void tool_change(const uint8_t tmp_extruder, bool no_move/*=false*/) {
|
||||
#elif ENABLED(SWITCHING_NOZZLE) && !SWITCHING_NOZZLE_TWO_SERVOS // Switching Nozzle (single servo)
|
||||
// Raise by a configured distance to avoid workpiece, except with
|
||||
// SWITCHING_NOZZLE_TWO_SERVOS, as both nozzles will lift instead.
|
||||
current_position[Z_AXIS] += MAX(-zdiff, 0.0) + toolchange_settings.z_raise;
|
||||
current_position[Z_AXIS] += _MAX(-zdiff, 0.0) + toolchange_settings.z_raise;
|
||||
#if HAS_SOFTWARE_ENDSTOPS
|
||||
NOMORE(current_position[Z_AXIS], soft_endstop[Z_AXIS].max);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user