Browse Source

Fix MIN/MAX function collision with macros

pull/1/head
Scott Lahteine 5 years ago
parent
commit
750a16ad38
  1. 2
      Marlin/src/HAL/HAL_DUE/usb/uotghs_device_due.c
  2. 2
      Marlin/src/HAL/HAL_DUE/usb/uotghs_device_due.h
  3. 2
      Marlin/src/HAL/HAL_LINUX/main.cpp
  4. 2
      Marlin/src/HAL/HAL_LPC1768/HAL_spi.cpp
  5. 4
      Marlin/src/HAL/HAL_STM32F1/HAL_timers_STM32F1.cpp
  6. 2
      Marlin/src/core/macros.h
  7. 8
      Marlin/src/core/minmax.h
  8. 2
      Marlin/src/feature/Max7219_Debug_LEDs.cpp
  9. 2
      Marlin/src/feature/backlash.cpp
  10. 2
      Marlin/src/feature/backlash.h
  11. 6
      Marlin/src/feature/bedlevel/abl/abl.cpp
  12. 4
      Marlin/src/feature/bedlevel/bedlevel.cpp
  13. 2
      Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp
  14. 10
      Marlin/src/feature/bedlevel/ubl/ubl.h
  15. 12
      Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
  16. 2
      Marlin/src/feature/bltouch.cpp
  17. 2
      Marlin/src/feature/dac/dac_mcp4728.cpp
  18. 2
      Marlin/src/feature/digipot/digipot_mcp4018.cpp
  19. 2
      Marlin/src/feature/digipot/digipot_mcp4451.cpp
  20. 4
      Marlin/src/feature/leds/tempstat.cpp
  21. 2
      Marlin/src/feature/mixing.cpp
  22. 4
      Marlin/src/feature/mixing.h
  23. 10
      Marlin/src/gcode/bedlevel/abl/G29.cpp
  24. 2
      Marlin/src/gcode/bedlevel/mbl/G29.cpp
  25. 2
      Marlin/src/gcode/calibrate/G28.cpp
  26. 2
      Marlin/src/gcode/calibrate/G33.cpp
  27. 12
      Marlin/src/gcode/calibrate/G34_M422.cpp
  28. 6
      Marlin/src/gcode/calibrate/G425.cpp
  29. 2
      Marlin/src/gcode/calibrate/M48.cpp
  30. 2
      Marlin/src/gcode/control/M605.cpp
  31. 8
      Marlin/src/gcode/feature/pause/M701_M702.cpp
  32. 2
      Marlin/src/gcode/feature/trinamic/M122.cpp
  33. 2
      Marlin/src/gcode/temperature/M106_M107.cpp
  34. 26
      Marlin/src/inc/Conditionals_post.h
  35. 2
      Marlin/src/inc/SanityCheck.h
  36. 4
      Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp
  37. 2
      Marlin/src/lcd/dogm/dogm_Statusscreen.h
  38. 2
      Marlin/src/lcd/dogm/status_screen_DOGM.cpp
  39. 2
      Marlin/src/lcd/dogm/ultralcd_DOGM.cpp
  40. 2
      Marlin/src/lcd/extensible_ui/ui_api.cpp
  41. 4
      Marlin/src/lcd/extui_malyan_lcd.cpp
  42. 4
      Marlin/src/lcd/menu/game/maze.cpp
  43. 24
      Marlin/src/lcd/menu/game/snake.cpp
  44. 2
      Marlin/src/lcd/menu/menu.cpp
  45. 4
      Marlin/src/lcd/menu/menu.h
  46. 20
      Marlin/src/lcd/menu/menu_configuration.cpp
  47. 2
      Marlin/src/lcd/menu/menu_delta_calibrate.cpp
  48. 2
      Marlin/src/lcd/menu/menu_temperature.cpp
  49. 2
      Marlin/src/lcd/ultralcd.cpp
  50. 2
      Marlin/src/lcd/ultralcd.h
  51. 8
      Marlin/src/libs/least_squares_fit.h
  52. 4
      Marlin/src/libs/nozzle.cpp
  53. 2
      Marlin/src/module/configuration_store.cpp
  54. 10
      Marlin/src/module/motion.cpp
  55. 24
      Marlin/src/module/planner.cpp
  56. 2
      Marlin/src/module/planner.h
  57. 6
      Marlin/src/module/printcounter.cpp
  58. 4
      Marlin/src/module/probe.cpp
  59. 4
      Marlin/src/module/stepper.cpp
  60. 6
      Marlin/src/module/stepper.h
  61. 16
      Marlin/src/module/temperature.cpp
  62. 10
      Marlin/src/module/temperature.h
  63. 2
      Marlin/src/module/tool_change.cpp

2
Marlin/src/HAL/HAL_DUE/usb/uotghs_device_due.c

@ -1904,7 +1904,7 @@ static void udd_ep_in_sent(udd_ep_id_t ep)
ptr_src = &ptr_job->buf[ptr_job->buf_cnt];
nb_remain = ptr_job->buf_size - ptr_job->buf_cnt;
// Fill a bank even if no data (ZLP)
nb_data = MIN(nb_remain, pkt_size);
nb_data = _MIN(nb_remain, pkt_size);
// Modify job information
ptr_job->buf_cnt += nb_data;
ptr_job->buf_load = nb_data;

2
Marlin/src/HAL/HAL_DUE/usb/uotghs_device_due.h

@ -291,7 +291,7 @@ extern "C" {
//! available greater size, then applies register format of UOTGHS controller
//! for endpoint size bit-field.
#undef udd_format_endpoint_size
#define udd_format_endpoint_size(size) (32 - clz(((uint32_t)MIN(MAX(size, 8), 1024) << 1) - 1) - 1 - 3)
#define udd_format_endpoint_size(size) (32 - clz(((uint32_t)_MIN(_MAX(size, 8), 1024) << 1) - 1) - 1 - 3)
//! Configures the selected endpoint size
#define udd_configure_endpoint_size(ep, size) (Wr_bitfield(UOTGHS_ARRAY(UOTGHS_DEVEPTCFG[0], ep), UOTGHS_DEVEPTCFG_EPSIZE_Msk, udd_format_endpoint_size(size)))
//! Gets the configured selected endpoint size

2
Marlin/src/HAL/HAL_LINUX/main.cpp

@ -49,7 +49,7 @@ void write_serial_thread() {
void read_serial_thread() {
char buffer[255] = {};
for (;;) {
std::size_t len = MIN(usb_serial.receive_buffer.free(), 254U);
std::size_t len = _MIN(usb_serial.receive_buffer.free(), 254U);
if (fgets(buffer, len, stdin))
for (std::size_t i = 0; i < strlen(buffer); i++)
usb_serial.receive_buffer.write(buffer[i]);

2
Marlin/src/HAL/HAL_LPC1768/HAL_spi.cpp

@ -162,7 +162,7 @@
// setup for SPI mode
SSP_CFG_Type HW_SPI_init; // data structure to hold init values
SSP_ConfigStructInit(&HW_SPI_init); // set values for SPI mode
HW_SPI_init.ClockRate = Marlin_speed[MIN(spiRate, 6)]; // put in the specified bit rate
HW_SPI_init.ClockRate = Marlin_speed[_MIN(spiRate, 6)]; // put in the specified bit rate
HW_SPI_init.Mode |= SSP_CR1_SSP_EN;
SSP_Init(LPC_SSPn, &HW_SPI_init); // puts the values into the proper bits in the SSP0 registers
}

4
Marlin/src/HAL/HAL_STM32F1/HAL_timers_STM32F1.cpp

@ -110,7 +110,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
timer_set_prescaler(STEP_TIMER_DEV, (uint16_t)(STEPPER_TIMER_PRESCALE - 1));
timer_set_reload(STEP_TIMER_DEV, 0xFFFF);
timer_oc_set_mode(STEP_TIMER_DEV, STEP_TIMER_CHAN, TIMER_OC_MODE_FROZEN, TIMER_OC_NO_PRELOAD); // no output pin change
timer_set_compare(STEP_TIMER_DEV, STEP_TIMER_CHAN, MIN(hal_timer_t(HAL_TIMER_TYPE_MAX), (STEPPER_TIMER_RATE / frequency)));
timer_set_compare(STEP_TIMER_DEV, STEP_TIMER_CHAN, _MIN(hal_timer_t(HAL_TIMER_TYPE_MAX), (STEPPER_TIMER_RATE / frequency)));
timer_no_ARR_preload_ARPE(STEP_TIMER_DEV); // Need to be sure no preload on ARR register
timer_attach_interrupt(STEP_TIMER_DEV, STEP_TIMER_CHAN, stepTC_Handler);
nvic_irq_set_priority(irq_num, STEP_TIMER_IRQ_PRIO);
@ -123,7 +123,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
timer_set_count(TEMP_TIMER_DEV, 0);
timer_set_prescaler(TEMP_TIMER_DEV, (uint16_t)(TEMP_TIMER_PRESCALE - 1));
timer_set_reload(TEMP_TIMER_DEV, 0xFFFF);
timer_set_compare(TEMP_TIMER_DEV, TEMP_TIMER_CHAN, MIN(hal_timer_t(HAL_TIMER_TYPE_MAX), ((F_CPU / TEMP_TIMER_PRESCALE) / frequency)));
timer_set_compare(TEMP_TIMER_DEV, TEMP_TIMER_CHAN, _MIN(hal_timer_t(HAL_TIMER_TYPE_MAX), ((F_CPU / TEMP_TIMER_PRESCALE) / frequency)));
timer_attach_interrupt(TEMP_TIMER_DEV, TEMP_TIMER_CHAN, tempTC_Handler);
nvic_irq_set_priority(irq_num, TEMP_TIMER_IRQ_PRIO);
timer_generate_update(TEMP_TIMER_DEV);

2
Marlin/src/core/macros.h

@ -190,7 +190,7 @@
#define ZERO(a) memset(a,0,sizeof(a))
#define COPY(a,b) do{ \
static_assert(sizeof(a[0]) == sizeof(b[0]), "COPY: '" STRINGIFY(a) "' and '" STRINGIFY(b) "' types (sizes) don't match!"); \
memcpy(&a[0],&b[0],MIN(sizeof(a),sizeof(b))); \
memcpy(&a[0],&b[0],_MIN(sizeof(a),sizeof(b))); \
}while(0)
// Macros for initializing arrays

8
Marlin/src/core/minmax.h

@ -36,14 +36,14 @@
extern "C++" {
// C++11 solution that is standards compliant. Return type is deduced automatically
template <class L, class R> static inline constexpr auto MIN(const L lhs, const R rhs) -> decltype(lhs + rhs) {
template <class L, class R> static inline constexpr auto _MIN(const L lhs, const R rhs) -> decltype(lhs + rhs) {
return lhs < rhs ? lhs : rhs;
}
template <class L, class R> static inline constexpr auto MAX(const L lhs, const R rhs) -> decltype(lhs + rhs) {
template <class L, class R> static inline constexpr auto _MAX(const L lhs, const R rhs) -> decltype(lhs + rhs) {
return lhs > rhs ? lhs : rhs;
}
template<class T, class ... Ts> static inline constexpr const T MIN(T V, Ts... Vs) { return MIN(V, MIN(Vs...)); }
template<class T, class ... Ts> static inline constexpr const T MAX(T V, Ts... Vs) { return MAX(V, MAX(Vs...)); }
template<class T, class ... Ts> static inline constexpr const T _MIN(T V, Ts... Vs) { return _MIN(V, _MIN(Vs...)); }
template<class T, class ... Ts> static inline constexpr const T _MAX(T V, Ts... Vs) { return _MAX(V, _MAX(Vs...)); }
}

2
Marlin/src/feature/Max7219_Debug_LEDs.cpp

@ -503,7 +503,7 @@ void Max7219::range16(const uint8_t y, const uint8_t ot, const uint8_t nt, const
// Apply changes to update a quantity
void Max7219::quantity16(const uint8_t y, const uint8_t ov, const uint8_t nv) {
for (uint8_t i = MIN(nv, ov); i < MAX(nv, ov); i++)
for (uint8_t i = _MIN(nv, ov); i < _MAX(nv, ov); i++)
#if MAX7219_X_LEDS == 8
#if MAX7219_Y_LEDS == 8
led_set(i >> 1, y + (i & 1), nv >= ov); // single 8x8 LED matrix. Use two lines to get 16 LED's

2
Marlin/src/feature/backlash.cpp

@ -106,7 +106,7 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const
// the current segment travels in the same direction as the correction
if (reversing == (error_correction < 0)) {
if (segment_proportion == 0)
segment_proportion = MIN(1.0f, block->millimeters / smoothing_mm);
segment_proportion = _MIN(1.0f, block->millimeters / smoothing_mm);
error_correction = CEIL(segment_proportion * error_correction);
}
else

2
Marlin/src/feature/backlash.h

@ -41,7 +41,7 @@ public:
#ifdef BACKLASH_SMOOTHING_MM
static float smoothing_mm;
#endif
static inline void set_correction(const float &v) { correction = MAX(0, MIN(1.0, v)) * all_on; }
static inline void set_correction(const float &v) { correction = _MAX(0, _MIN(1.0, v)) * all_on; }
static inline float get_correction() { return float(ui8_to_percent(correction)) / 100.0f; }
#else
static constexpr uint8_t correction = (BACKLASH_CORRECTION) * 0xFF;

6
Marlin/src/feature/bedlevel/abl/abl.cpp

@ -301,7 +301,7 @@ float bilinear_z_offset(const float raw[XYZ]) {
#endif
gridx = gx;
nextx = MIN(gridx + 1, ABL_BG_POINTS_X - 1);
nextx = _MIN(gridx + 1, ABL_BG_POINTS_X - 1);
}
if (last_y != ry || last_gridx != gridx) {
@ -318,7 +318,7 @@ float bilinear_z_offset(const float raw[XYZ]) {
#endif
gridy = gy;
nexty = MIN(gridy + 1, ABL_BG_POINTS_Y - 1);
nexty = _MIN(gridy + 1, ABL_BG_POINTS_Y - 1);
}
if (last_gridx != gridx || last_gridy != gridy) {
@ -384,7 +384,7 @@ float bilinear_z_offset(const float raw[XYZ]) {
#define LINE_SEGMENT_END(A) (current_position[_AXIS(A)] + (destination[_AXIS(A)] - current_position[_AXIS(A)]) * normalized_dist)
float normalized_dist, end[XYZE];
const int8_t gcx = MAX(cx1, cx2), gcy = MAX(cy1, cy2);
const int8_t gcx = _MAX(cx1, cx2), gcy = _MAX(cy1, cy2);
// Crosses on the X and not already split on this X?
// The x_splits flags are insurance against rounding errors.

4
Marlin/src/feature/bedlevel/bedlevel.cpp

@ -222,9 +222,9 @@ void reset_bed_level() {
#ifdef MANUAL_PROBE_START_Z
#if MANUAL_PROBE_HEIGHT > 0
do_blocking_move_to(rx, ry, MANUAL_PROBE_HEIGHT);
do_blocking_move_to_z(MAX(0,MANUAL_PROBE_START_Z));
do_blocking_move_to_z(_MAX(0,MANUAL_PROBE_START_Z));
#else
do_blocking_move_to(rx, ry, MAX(0,MANUAL_PROBE_START_Z));
do_blocking_move_to(rx, ry, _MAX(0,MANUAL_PROBE_START_Z));
#endif
#elif MANUAL_PROBE_HEIGHT > 0
const float prev_z = current_position[Z_AXIS];

2
Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp

@ -81,7 +81,7 @@
#define MBL_SEGMENT_END(A) (current_position[_AXIS(A)] + (destination[_AXIS(A)] - current_position[_AXIS(A)]) * normalized_dist)
float normalized_dist, end[XYZE];
const int8_t gcx = MAX(cx1, cx2), gcy = MAX(cy1, cy2);
const int8_t gcx = _MAX(cx1, cx2), gcy = _MAX(cy1, cy2);
// Crosses on the X and not already split on this X?
// The x_splits flags are insurance against rounding errors.

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

@ -213,7 +213,7 @@ class unified_bed_leveling {
const float xratio = (rx0 - mesh_index_to_xpos(x1_i)) * (1.0f / (MESH_X_DIST)),
z1 = z_values[x1_i][yi];
return z1 + xratio * (z_values[MIN(x1_i, GRID_MAX_POINTS_X - 2) + 1][yi] - z1); // Don't allow x1_i+1 to be past the end of the array
return z1 + xratio * (z_values[_MIN(x1_i, GRID_MAX_POINTS_X - 2) + 1][yi] - z1); // Don't allow x1_i+1 to be past the end of the array
// If it is, it is clamped to the last element of the
// z_values[][] array and no correction is applied.
}
@ -242,7 +242,7 @@ class unified_bed_leveling {
const float yratio = (ry0 - mesh_index_to_ypos(y1_i)) * (1.0f / (MESH_Y_DIST)),
z1 = z_values[xi][y1_i];
return z1 + yratio * (z_values[xi][MIN(y1_i, GRID_MAX_POINTS_Y - 2) + 1] - z1); // Don't allow y1_i+1 to be past the end of the array
return z1 + yratio * (z_values[xi][_MIN(y1_i, GRID_MAX_POINTS_Y - 2) + 1] - z1); // Don't allow y1_i+1 to be past the end of the array
// If it is, it is clamped to the last element of the
// z_values[][] array and no correction is applied.
}
@ -268,11 +268,11 @@ class unified_bed_leveling {
const float z1 = calc_z0(rx0,
mesh_index_to_xpos(cx), z_values[cx][cy],
mesh_index_to_xpos(cx + 1), z_values[MIN(cx, GRID_MAX_POINTS_X - 2) + 1][cy]);
mesh_index_to_xpos(cx + 1), z_values[_MIN(cx, GRID_MAX_POINTS_X - 2) + 1][cy]);
const float z2 = calc_z0(rx0,
mesh_index_to_xpos(cx), z_values[cx][MIN(cy, GRID_MAX_POINTS_Y - 2) + 1],
mesh_index_to_xpos(cx + 1), z_values[MIN(cx, GRID_MAX_POINTS_X - 2) + 1][MIN(cy, GRID_MAX_POINTS_Y - 2) + 1]);
mesh_index_to_xpos(cx), z_values[cx][_MIN(cy, GRID_MAX_POINTS_Y - 2) + 1],
mesh_index_to_xpos(cx + 1), z_values[_MIN(cx, GRID_MAX_POINTS_X - 2) + 1][_MIN(cy, GRID_MAX_POINTS_Y - 2) + 1]);
float z0 = calc_z0(ry0,
mesh_index_to_ypos(cy), z1,

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

@ -855,7 +855,7 @@
save_ubl_active_state_and_disable(); // Disable bed level correction for probing
do_blocking_move_to(0.5f * (MESH_MAX_X - (MESH_MIN_X)), 0.5f * (MESH_MAX_Y - (MESH_MIN_Y)), in_height);
//, MIN(planner.settings.max_feedrate_mm_s[X_AXIS], planner.settings.max_feedrate_mm_s[Y_AXIS]) * 0.5f);
//, _MIN(planner.settings.max_feedrate_mm_s[X_AXIS], planner.settings.max_feedrate_mm_s[Y_AXIS]) * 0.5f);
planner.synchronize();
SERIAL_ECHOPGM("Place shim under nozzle");
@ -1385,10 +1385,10 @@
#include "../../../libs/vector_3.h"
void unified_bed_leveling::tilt_mesh_based_on_probed_grid(const bool do_3_pt_leveling) {
constexpr int16_t x_min = MAX(MIN_PROBE_X, MESH_MIN_X),
x_max = MIN(MAX_PROBE_X, MESH_MAX_X),
y_min = MAX(MIN_PROBE_Y, MESH_MIN_Y),
y_max = MIN(MAX_PROBE_Y, MESH_MAX_Y);
constexpr int16_t x_min = _MAX(MIN_PROBE_X, MESH_MIN_X),
x_max = _MIN(MAX_PROBE_X, MESH_MAX_X),
y_min = _MAX(MIN_PROBE_Y, MESH_MIN_Y),
y_max = _MIN(MAX_PROBE_Y, MESH_MAX_Y);
bool abort_flag = false;
@ -1654,7 +1654,7 @@
SERIAL_ECHOPGM("Extrapolating mesh...");
const float weight_scaled = weight_factor * MAX(MESH_X_DIST, MESH_Y_DIST);
const float weight_scaled = weight_factor * _MAX(MESH_X_DIST, MESH_Y_DIST);
for (uint8_t jx = 0; jx < GRID_MAX_POINTS_X; jx++)
for (uint8_t jy = 0; jy < GRID_MAX_POINTS_Y; jy++)

2
Marlin/src/feature/bltouch.cpp

@ -40,7 +40,7 @@ void stop();
bool BLTouch::command(const BLTCommand cmd, const millis_t &ms) {
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("BLTouch Command :", cmd);
MOVE_SERVO(Z_PROBE_SERVO_NR, cmd);
safe_delay(MAX(ms, (uint32_t)BLTOUCH_DELAY)); // BLTOUCH_DELAY is also the *minimum* delay
safe_delay(_MAX(ms, (uint32_t)BLTOUCH_DELAY)); // BLTOUCH_DELAY is also the *minimum* delay
return triggered();
}

2
Marlin/src/feature/dac/dac_mcp4728.cpp

@ -108,7 +108,7 @@ uint16_t mcp4728_getValue(const uint8_t channel) { return mcp4728_values[channel
uint16_t mcp4728_getVout(const uint8_t channel) {
const uint32_t vref = 2048,
vOut = (vref * mcp4728_values[channel] * (_DAC_STEPPER_GAIN + 1)) / 4096;
return MIN(vOut, defaultVDD);
return _MIN(vOut, defaultVDD);
}
#endif

2
Marlin/src/feature/digipot/digipot_mcp4018.cpp

@ -87,7 +87,7 @@ static void i2c_send(const uint8_t channel, const byte v) {
// This is for the MCP4018 I2C based digipot
void digipot_i2c_set_current(const uint8_t channel, const float current) {
i2c_send(channel, current_to_wiper(MIN(MAX(current, 0), float(DIGIPOT_A4988_MAX_CURRENT))));
i2c_send(channel, current_to_wiper(_MIN(_MAX(current, 0), float(DIGIPOT_A4988_MAX_CURRENT))));
}
void digipot_i2c_init() {

2
Marlin/src/feature/digipot/digipot_mcp4451.cpp

@ -72,7 +72,7 @@ void digipot_i2c_set_current(const uint8_t channel, const float current) {
// Set actual wiper value
byte addresses[4] = { 0x00, 0x10, 0x60, 0x70 };
i2c_send(addr, addresses[channel & 0x3], current_to_wiper(MIN((float) MAX(current, 0), DIGIPOT_I2C_MAX_CURRENT)));
i2c_send(addr, addresses[channel & 0x3], current_to_wiper(MIN((float) _MAX(current, 0), DIGIPOT_I2C_MAX_CURRENT)));
}
void digipot_i2c_init() {

4
Marlin/src/feature/leds/tempstat.cpp

@ -38,10 +38,10 @@ void handle_status_leds(void) {
next_status_led_update_ms += 500; // Update every 0.5s
float max_temp = 0.0;
#if HAS_HEATED_BED
max_temp = MAX(thermalManager.degTargetBed(), thermalManager.degBed());
max_temp = _MAX(thermalManager.degTargetBed(), thermalManager.degBed());
#endif
HOTEND_LOOP()
max_temp = MAX(max_temp, thermalManager.degHotend(e), thermalManager.degTargetHotend(e));
max_temp = _MAX(max_temp, thermalManager.degHotend(e), thermalManager.degTargetHotend(e));
const int8_t new_red = (max_temp > 55.0) ? HIGH : (max_temp < 54.0 || old_red < 0) ? LOW : old_red;
if (new_red != old_red) {
old_red = new_red;

2
Marlin/src/feature/mixing.cpp

@ -136,7 +136,7 @@ void Mixer::refresh_collector(const float proportion/*=1.0*/, const uint8_t t/*=
float csum = 0, cmax = 0;
MIXER_STEPPER_LOOP(i) {
const float v = color[t][i];
cmax = MAX(cmax, v);
cmax = _MAX(cmax, v);
csum += v;
}
//SERIAL_ECHOPAIR("Mixer::refresh_collector(", proportion, ", ", int(t), ") cmax=", cmax, " csum=", csum, " color");

4
Marlin/src/feature/mixing.h

@ -103,7 +103,7 @@ class Mixer {
static void refresh_collector(const float proportion=1.0, const uint8_t t=selected_vtool, float (&c)[MIXING_STEPPERS]=collector);
// Used up to Planner level
FORCE_INLINE static void set_collector(const uint8_t c, const float f) { collector[c] = MAX(f, 0.0f); }
FORCE_INLINE static void set_collector(const uint8_t c, const float f) { collector[c] = _MAX(f, 0.0f); }
static void normalize(const uint8_t tool_index);
FORCE_INLINE static void normalize() { normalize(selected_vtool); }
@ -142,7 +142,7 @@ class Mixer {
static inline void copy_mix_to_color(mixer_comp_t (&tcolor)[MIXING_STEPPERS]) {
// Scale each component to the largest one in terms of COLOR_A_MASK
// So the largest component will be COLOR_A_MASK and the other will be in proportion to it
const float scale = (COLOR_A_MASK) * RECIPROCAL(float(MAX(mix[0], mix[1])));
const float scale = (COLOR_A_MASK) * RECIPROCAL(float(_MAX(mix[0], mix[1])));
// Scale all values so their maximum is COLOR_A_MASK
MIXER_STEPPER_LOOP(i) tcolor[i] = mix[i] * scale;

10
Marlin/src/gcode/bedlevel/abl/G29.cpp

@ -394,10 +394,10 @@ G29_TYPE GcodeSuite::G29() {
if (parser.seen('H')) {
const int16_t size = (int16_t)parser.value_linear_units();
left_probe_bed_position = MAX(X_CENTER - size / 2, MIN_PROBE_X);
right_probe_bed_position = MIN(left_probe_bed_position + size, MAX_PROBE_X);
front_probe_bed_position = MAX(Y_CENTER - size / 2, MIN_PROBE_Y);
back_probe_bed_position = MIN(front_probe_bed_position + size, MAX_PROBE_Y);
left_probe_bed_position = _MAX(X_CENTER - size / 2, MIN_PROBE_X);
right_probe_bed_position = _MIN(left_probe_bed_position + size, MAX_PROBE_X);
front_probe_bed_position = _MAX(Y_CENTER - size / 2, MIN_PROBE_Y);
back_probe_bed_position = _MIN(front_probe_bed_position + size, MAX_PROBE_Y);
}
else {
left_probe_bed_position = parser.seenval('L') ? (int)RAW_X_POSITION(parser.value_linear_units()) : LEFT_PROBE_BED_POSITION;
@ -511,7 +511,7 @@ G29_TYPE GcodeSuite::G29() {
if (verbose_level || seenQ) {
SERIAL_ECHOPGM("Manual G29 ");
if (g29_in_progress) {
SERIAL_ECHOPAIR("point ", MIN(abl_probe_index + 1, abl_points));
SERIAL_ECHOPAIR("point ", _MIN(abl_probe_index + 1, abl_points));
SERIAL_ECHOLNPAIR(" of ", abl_points);
}
else

2
Marlin/src/gcode/bedlevel/mbl/G29.cpp

@ -197,7 +197,7 @@ void GcodeSuite::G29() {
} // switch(state)
if (state == MeshNext) {
SERIAL_ECHOPAIR("MBL G29 point ", MIN(mbl_probe_index, GRID_MAX_POINTS));
SERIAL_ECHOPAIR("MBL G29 point ", _MIN(mbl_probe_index, GRID_MAX_POINTS));
SERIAL_ECHOLNPAIR(" of ", int(GRID_MAX_POINTS));
}

2
Marlin/src/gcode/calibrate/G28.cpp

@ -75,7 +75,7 @@
const float mlx = max_length(X_AXIS),
mly = max_length(Y_AXIS),
mlratio = mlx > mly ? mly / mlx : mlx / mly,
fr_mm_s = MIN(homing_feedrate(X_AXIS), homing_feedrate(Y_AXIS)) * SQRT(sq(mlratio) + 1.0);
fr_mm_s = _MIN(homing_feedrate(X_AXIS), homing_feedrate(Y_AXIS)) * SQRT(sq(mlratio) + 1.0);
#if ENABLED(SENSORLESS_HOMING)
sensorless_t stealth_states { false, false, false, false, false, false, false };

2
Marlin/src/gcode/calibrate/G33.cpp

@ -610,7 +610,7 @@ void GcodeSuite::G33() {
}
// adjust delta_height and endstops by the max amount
const float z_temp = MAX(delta_endstop_adj[A_AXIS], delta_endstop_adj[B_AXIS], delta_endstop_adj[C_AXIS]);
const float z_temp = _MAX(delta_endstop_adj[A_AXIS], delta_endstop_adj[B_AXIS], delta_endstop_adj[C_AXIS]);
delta_height -= z_temp;
LOOP_XYZ(axis) delta_endstop_adj[axis] -= z_temp;
}

12
Marlin/src/gcode/calibrate/G34_M422.cpp

@ -123,7 +123,7 @@ void GcodeSuite::G34() {
float z_probe = Z_BASIC_CLEARANCE + (G34_MAX_GRADE) * 0.01f * (
#if ENABLED(Z_TRIPLE_STEPPER_DRIVERS)
SQRT(MAX(HYPOT2(z_auto_align_xpos[0] - z_auto_align_ypos[0], z_auto_align_xpos[1] - z_auto_align_ypos[1]),
SQRT(_MAX(HYPOT2(z_auto_align_xpos[0] - z_auto_align_ypos[0], z_auto_align_xpos[1] - z_auto_align_ypos[1]),
HYPOT2(z_auto_align_xpos[1] - z_auto_align_ypos[1], z_auto_align_xpos[2] - z_auto_align_ypos[2]),
HYPOT2(z_auto_align_xpos[2] - z_auto_align_ypos[2], z_auto_align_xpos[0] - z_auto_align_ypos[0])))
#else
@ -174,7 +174,7 @@ void GcodeSuite::G34() {
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " measured position is ", z_measured[zstepper]);
// Remember the minimum measurement to calculate the correction later on
z_measured_min = MIN(z_measured_min, z_measured[zstepper]);
z_measured_min = _MIN(z_measured_min, z_measured[zstepper]);
} // for (zstepper)
if (err_break) break;
@ -182,11 +182,11 @@ void GcodeSuite::G34() {
// Adapt the next probe clearance height based on the new measurements.
// Safe_height = lowest distance to bed (= highest measurement) plus highest measured misalignment.
#if ENABLED(Z_TRIPLE_STEPPER_DRIVERS)
z_maxdiff = MAX(ABS(z_measured[0] - z_measured[1]), ABS(z_measured[1] - z_measured[2]), ABS(z_measured[2] - z_measured[0]));
z_probe = Z_BASIC_CLEARANCE + MAX(z_measured[0], z_measured[1], z_measured[2]) + z_maxdiff;
z_maxdiff = _MAX(ABS(z_measured[0] - z_measured[1]), ABS(z_measured[1] - z_measured[2]), ABS(z_measured[2] - z_measured[0]));
z_probe = Z_BASIC_CLEARANCE + _MAX(z_measured[0], z_measured[1], z_measured[2]) + z_maxdiff;
#else
z_maxdiff = ABS(z_measured[0] - z_measured[1]);
z_probe = Z_BASIC_CLEARANCE + MAX(z_measured[0], z_measured[1]) + z_maxdiff;
z_probe = Z_BASIC_CLEARANCE + _MAX(z_measured[0], z_measured[1]) + z_maxdiff;
#endif
SERIAL_ECHOPAIR("\n"
@ -210,7 +210,7 @@ void GcodeSuite::G34() {
z_align_abs = ABS(z_align_move);
// Optimize one iterations correction based on the first measurements
if (z_align_abs > 0.0f) amplification = iteration == 1 ? MIN(last_z_align_move[zstepper] / z_align_abs, 2.0f) : z_auto_align_amplification;
if (z_align_abs > 0.0f) amplification = iteration == 1 ? _MIN(last_z_align_move[zstepper] / z_align_abs, 2.0f) : z_auto_align_amplification;
// Check for less accuracy compared to last move
if (last_z_align_move[zstepper] < z_align_abs - 1.0) {

6
Marlin/src/gcode/calibrate/G425.cpp

@ -120,9 +120,9 @@ inline void move_to(
if (a3 != NO_AXIS) destination[a3] = p3;
// Make sure coordinates are within bounds
destination[X_AXIS] = MAX(MIN(destination[X_AXIS], X_MAX_POS), X_MIN_POS);
destination[Y_AXIS] = MAX(MIN(destination[Y_AXIS], Y_MAX_POS), Y_MIN_POS);
destination[Z_AXIS] = MAX(MIN(destination[Z_AXIS], Z_MAX_POS), Z_MIN_POS);
destination[X_AXIS] = _MAX(_MIN(destination[X_AXIS], X_MAX_POS), X_MIN_POS);
destination[Y_AXIS] = _MAX(_MIN(destination[Y_AXIS], Y_MAX_POS), Y_MIN_POS);
destination[Z_AXIS] = _MAX(_MIN(destination[Z_AXIS], Z_MAX_POS), Z_MIN_POS);
// Move to position
do_blocking_move_to(destination, MMM_TO_MMS(CALIBRATION_FEEDRATE_TRAVEL));

2
Marlin/src/gcode/calibrate/M48.cpp

@ -127,7 +127,7 @@ void GcodeSuite::M48() {
(int) (0.1250000000 * (DELTA_PRINTABLE_RADIUS)),
(int) (0.3333333333 * (DELTA_PRINTABLE_RADIUS))
#else
(int) 5.0, (int) (0.125 * MIN(X_BED_SIZE, Y_BED_SIZE))
(int) 5.0, (int) (0.125 * _MIN(X_BED_SIZE, Y_BED_SIZE))
#endif
);

2
Marlin/src/gcode/control/M605.cpp

@ -92,7 +92,7 @@
case DXC_AUTO_PARK_MODE:
break;
case DXC_DUPLICATION_MODE:
if (parser.seen('X')) duplicate_extruder_x_offset = MAX(parser.value_linear_units(), X2_MIN_POS - x_home_pos(0));
if (parser.seen('X')) duplicate_extruder_x_offset = _MAX(parser.value_linear_units(), X2_MIN_POS - x_home_pos(0));
if (parser.seen('R')) duplicate_extruder_temp_offset = parser.value_celsius_diff();
if (active_extruder != 0) tool_change(0);
break;

8
Marlin/src/gcode/feature/pause/M701_M702.cpp

@ -97,7 +97,7 @@ void GcodeSuite::M701() {
// Lift Z axis
if (park_point.z > 0)
do_blocking_move_to_z(MIN(current_position[Z_AXIS] + park_point.z, Z_MAX_POS), NOZZLE_PARK_Z_FEEDRATE);
do_blocking_move_to_z(_MIN(current_position[Z_AXIS] + park_point.z, Z_MAX_POS), NOZZLE_PARK_Z_FEEDRATE);
// Load filament
#if ENABLED(PRUSA_MMU2)
@ -116,7 +116,7 @@ void GcodeSuite::M701() {
// Restore Z axis
if (park_point.z > 0)
do_blocking_move_to_z(MAX(current_position[Z_AXIS] - park_point.z, 0), NOZZLE_PARK_Z_FEEDRATE);
do_blocking_move_to_z(_MAX(current_position[Z_AXIS] - park_point.z, 0), NOZZLE_PARK_Z_FEEDRATE);
#if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2)
// Restore toolhead if it was changed
@ -196,7 +196,7 @@ void GcodeSuite::M702() {
// Lift Z axis
if (park_point.z > 0)
do_blocking_move_to_z(MIN(current_position[Z_AXIS] + park_point.z, Z_MAX_POS), NOZZLE_PARK_Z_FEEDRATE);
do_blocking_move_to_z(_MIN(current_position[Z_AXIS] + park_point.z, Z_MAX_POS), NOZZLE_PARK_Z_FEEDRATE);
// Unload filament
#if ENABLED(PRUSA_MMU2)
@ -226,7 +226,7 @@ void GcodeSuite::M702() {
// Restore Z axis
if (park_point.z > 0)
do_blocking_move_to_z(MAX(current_position[Z_AXIS] - park_point.z, 0), NOZZLE_PARK_Z_FEEDRATE);
do_blocking_move_to_z(_MAX(current_position[Z_AXIS] - park_point.z, 0), NOZZLE_PARK_Z_FEEDRATE);
#if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2)
// Restore toolhead if it was changed

2
Marlin/src/gcode/feature/trinamic/M122.cpp

@ -41,7 +41,7 @@ void GcodeSuite::M122() {
#if ENABLED(MONITOR_DRIVER_STATUS)
const bool sflag = parser.seen('S'), s0 = sflag && !parser.value_bool();
if (sflag) tmc_set_report_interval(s0 ? 0 : MONITOR_DRIVER_STATUS_INTERVAL_MS);
if (!s0 && parser.seenval('P')) tmc_set_report_interval(MIN(parser.value_ushort(), MONITOR_DRIVER_STATUS_INTERVAL_MS));
if (!s0 && parser.seenval('P')) tmc_set_report_interval(_MIN(parser.value_ushort(), MONITOR_DRIVER_STATUS_INTERVAL_MS));
#endif
if (parser.seen('V'))

2
Marlin/src/gcode/temperature/M106_M107.cpp

@ -32,7 +32,7 @@
#define _ALT_P active_extruder
#define _CNT_P EXTRUDERS
#else
#define _ALT_P MIN(active_extruder, FAN_COUNT - 1)
#define _ALT_P _MIN(active_extruder, FAN_COUNT - 1)
#define _CNT_P FAN_COUNT
#endif

26
Marlin/src/inc/Conditionals_post.h

@ -1360,7 +1360,7 @@
#define _PROBE_RADIUS (DELTA_PRINTABLE_RADIUS - (MIN_PROBE_EDGE))
#ifndef DELTA_CALIBRATION_RADIUS
#ifdef X_PROBE_OFFSET_FROM_EXTRUDER
#define DELTA_CALIBRATION_RADIUS (DELTA_PRINTABLE_RADIUS - MAX(ABS(X_PROBE_OFFSET_FROM_EXTRUDER), ABS(Y_PROBE_OFFSET_FROM_EXTRUDER), ABS(MIN_PROBE_EDGE)))
#define DELTA_CALIBRATION_RADIUS (DELTA_PRINTABLE_RADIUS - _MAX(ABS(X_PROBE_OFFSET_FROM_EXTRUDER), ABS(Y_PROBE_OFFSET_FROM_EXTRUDER), ABS(MIN_PROBE_EDGE)))
#else
#define DELTA_CALIBRATION_RADIUS _PROBE_RADIUS
#endif
@ -1398,10 +1398,10 @@
#else
// Boundaries for Cartesian probing based on bed limits
#define _MIN_PROBE_X (MAX(X_MIN_BED + MIN_PROBE_EDGE, X_MIN_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
#define _MIN_PROBE_Y (MAX(Y_MIN_BED + MIN_PROBE_EDGE, Y_MIN_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
#define _MAX_PROBE_X (MIN(X_MAX_BED - (MIN_PROBE_EDGE), X_MAX_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
#define _MAX_PROBE_Y (MIN(Y_MAX_BED - (MIN_PROBE_EDGE), Y_MAX_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
#define _MIN_PROBE_X (_MAX(X_MIN_BED + MIN_PROBE_EDGE, X_MIN_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
#define _MIN_PROBE_Y (_MAX(Y_MIN_BED + MIN_PROBE_EDGE, Y_MIN_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
#define _MAX_PROBE_X (_MIN(X_MAX_BED - (MIN_PROBE_EDGE), X_MAX_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
#define _MAX_PROBE_Y (_MIN(Y_MAX_BED - (MIN_PROBE_EDGE), Y_MAX_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
#endif
@ -1438,15 +1438,15 @@
#else
// Boundaries for Cartesian probing based on set limits
#if ENABLED(AUTO_BED_LEVELING_UBL)
#define _MESH_MIN_X (MAX(X_MIN_BED + MESH_INSET, X_MIN_POS)) // UBL is careful not to probe off the bed. It does not
#define _MESH_MIN_Y (MAX(Y_MIN_BED + MESH_INSET, Y_MIN_POS)) // need *_PROBE_OFFSET_FROM_EXTRUDER in the mesh dimensions
#define _MESH_MAX_X (MIN(X_MAX_BED - (MESH_INSET), X_MAX_POS))
#define _MESH_MAX_Y (MIN(Y_MAX_BED - (MESH_INSET), Y_MAX_POS))
#define _MESH_MIN_X (_MAX(X_MIN_BED + MESH_INSET, X_MIN_POS)) // UBL is careful not to probe off the bed. It does not
#define _MESH_MIN_Y (_MAX(Y_MIN_BED + MESH_INSET, Y_MIN_POS)) // need *_PROBE_OFFSET_FROM_EXTRUDER in the mesh dimensions
#define _MESH_MAX_X (_MIN(X_MAX_BED - (MESH_INSET), X_MAX_POS))
#define _MESH_MAX_Y (_MIN(Y_MAX_BED - (MESH_INSET), Y_MAX_POS))
#else
#define _MESH_MIN_X (MAX(X_MIN_BED + MESH_INSET, X_MIN_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
#define _MESH_MIN_Y (MAX(Y_MIN_BED + MESH_INSET, Y_MIN_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
#define _MESH_MAX_X (MIN(X_MAX_BED - (MESH_INSET), X_MAX_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
#define _MESH_MAX_Y (MIN(Y_MAX_BED - (MESH_INSET), Y_MAX_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
#define _MESH_MIN_X (_MAX(X_MIN_BED + MESH_INSET, X_MIN_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
#define _MESH_MIN_Y (_MAX(Y_MIN_BED + MESH_INSET, Y_MIN_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
#define _MESH_MAX_X (_MIN(X_MAX_BED - (MESH_INSET), X_MAX_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
#define _MESH_MAX_Y (_MIN(Y_MAX_BED - (MESH_INSET), Y_MAX_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
#endif
#endif

2
Marlin/src/inc/SanityCheck.h

@ -2130,7 +2130,7 @@ constexpr float sanity_arr_1[] = DEFAULT_AXIS_STEPS_PER_UNIT,
sanity_arr_2[] = DEFAULT_MAX_FEEDRATE,
sanity_arr_3[] = DEFAULT_MAX_ACCELERATION;
#define _ARR_TEST(N,I) (sanity_arr_##N[MIN(I,int(COUNT(sanity_arr_##N))-1)] > 0)
#define _ARR_TEST(N,I) (sanity_arr_##N[_MIN(I,int(COUNT(sanity_arr_##N))-1)] > 0)
static_assert(COUNT(sanity_arr_1) >= XYZE, "DEFAULT_AXIS_STEPS_PER_UNIT requires X, Y, Z and E elements.");
static_assert(COUNT(sanity_arr_1) <= XYZE_N, "DEFAULT_AXIS_STEPS_PER_UNIT has too many elements. (Did you forget to enable DISTINCT_E_FACTORS?)");

4
Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp

@ -382,7 +382,7 @@ void MarlinUI::clear_lcd() { lcd.clear(); }
}
else {
PGM_P p = text;
int dly = time / MAX(slen, 1);
int dly = time / _MAX(slen, 1);
for (uint8_t i = 0; i <= slen; i++) {
// Go to the correct place
@ -1325,7 +1325,7 @@ void MarlinUI::draw_status_screen() {
*/
clear_custom_char(&new_char);
const uint8_t ypix = MIN(upper_left.y_pixel_offset + pixels_per_y_mesh_pnt, HD44780_CHAR_HEIGHT);
const uint8_t ypix = _MIN(upper_left.y_pixel_offset + pixels_per_y_mesh_pnt, HD44780_CHAR_HEIGHT);
for (j = upper_left.y_pixel_offset; j < ypix; j++) {
i = upper_left.x_pixel_mask;
for (k = 0; k < pixels_per_x_mesh_pnt; k++) {

2
Marlin/src/lcd/dogm/dogm_Statusscreen.h

@ -1170,7 +1170,7 @@
#define STATUS_LOGO_X 0
#endif
#ifndef STATUS_LOGO_Y
#define STATUS_LOGO_Y MIN(0, 10 - (STATUS_LOGO_HEIGHT) / 2)
#define STATUS_LOGO_Y _MIN(0, 10 - (STATUS_LOGO_HEIGHT) / 2)
#endif
#ifndef STATUS_LOGO_HEIGHT
#define STATUS_LOGO_HEIGHT (sizeof(status_logo_bmp) / (STATUS_LOGO_BYTEWIDTH))

2
Marlin/src/lcd/dogm/status_screen_DOGM.cpp

@ -96,7 +96,7 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons
#define CHAMBER_ALT() false
#endif
#define MAX_HOTEND_DRAW MIN(HOTENDS, ((LCD_PIXEL_WIDTH - (STATUS_LOGO_BYTEWIDTH + STATUS_FAN_BYTEWIDTH) * 8) / (STATUS_HEATERS_XSPACE)))
#define MAX_HOTEND_DRAW _MIN(HOTENDS, ((LCD_PIXEL_WIDTH - (STATUS_LOGO_BYTEWIDTH + STATUS_FAN_BYTEWIDTH) * 8) / (STATUS_HEATERS_XSPACE)))
#define STATUS_HEATERS_BOT (STATUS_HEATERS_Y + STATUS_HEATERS_HEIGHT - 1)
#if ENABLED(MARLIN_DEV_MODE)

2
Marlin/src/lcd/dogm/ultralcd_DOGM.cpp

@ -169,7 +169,7 @@ void MarlinUI::set_font(const MarlinFont font_nr) {
text_width_1 = (sizeof(STRING_SPLASH_LINE1) - 1) * (MENU_FONT_WIDTH),
text_width_2 = (sizeof(STRING_SPLASH_LINE2) - 1) * (MENU_FONT_WIDTH);
#endif
constexpr uint8_t text_max_width = MAX(text_width_1, text_width_2),
constexpr uint8_t text_max_width = _MAX(text_width_1, text_width_2),
rspace = width - (START_BMPWIDTH);
int8_t offx, offy, txt_base, txt_offx_1, txt_offx_2;

2
Marlin/src/lcd/extensible_ui/ui_api.cpp

@ -99,7 +99,7 @@
#endif
inline float clamp(const float value, const float minimum, const float maximum) {
return MAX(MIN(value, maximum), minimum);
return _MAX(_MIN(value, maximum), minimum);
}
static struct {

4
Marlin/src/lcd/extui_malyan_lcd.cpp

@ -80,7 +80,7 @@ bool last_printing_status = false;
// Everything written needs the high bit set.
void write_to_lcd_P(PGM_P const message) {
char encoded_message[MAX_CURLY_COMMAND];
uint8_t message_length = MIN(strlen_P(message), sizeof(encoded_message));
uint8_t message_length = _MIN(strlen_P(message), sizeof(encoded_message));
for (uint8_t i = 0; i < message_length; i++)
encoded_message[i] = pgm_read_byte(&message[i]) | 0x80;
@ -90,7 +90,7 @@ void write_to_lcd_P(PGM_P const message) {
void write_to_lcd(const char * const message) {
char encoded_message[MAX_CURLY_COMMAND];
const uint8_t message_length = MIN(strlen(message), sizeof(encoded_message));
const uint8_t message_length = _MIN(strlen(message), sizeof(encoded_message));
for (uint8_t i = 0; i < message_length; i++)
encoded_message[i] = message[i] | 0x80;

4
Marlin/src/lcd/menu/game/maze.cpp

@ -89,12 +89,12 @@ void MazeGame::game_screen() {
// for (uint8_t n = 0; n < head_ind; ++n) {
// const pos_t &p = maze_walls[n], &q = maze_walls[n + 1];
// if (p.x == q.x) {
// const int8_t y1 = GAMEY(MIN(p.y, q.y)), y2 = GAMEY(MAX(p.y, q.y));
// const int8_t y1 = GAMEY(_MIN(p.y, q.y)), y2 = GAMEY(_MAX(p.y, q.y));
// if (PAGE_CONTAINS(y1, y2))
// u8g.drawVLine(GAMEX(p.x), y1, y2 - y1 + 1);
// }
// else if (PAGE_CONTAINS(GAMEY(p.y), GAMEY(p.y))) {
// const int8_t x1 = GAMEX(MIN(p.x, q.x)), x2 = GAMEX(MAX(p.x, q.x));
// const int8_t x1 = GAMEX(_MIN(p.x, q.x)), x2 = GAMEX(_MAX(p.x, q.x));
// u8g.drawHLine(x1, GAMEY(p.y), x2 - x1 + 1);
// }
// }

24
Marlin/src/lcd/menu/game/snake.cpp

@ -102,10 +102,10 @@ inline bool food_on_line() {
for (uint8_t n = 0; n < head_ind; ++n) {
pos_t &p = snake_tail[n], &q = snake_tail[n + 1];
if (p.x == q.x) {
if ((foodx == p.x - 1 || foodx == p.x) && WITHIN(foody, MIN(p.y, q.y), MAX(p.y, q.y)))
if ((foodx == p.x - 1 || foodx == p.x) && WITHIN(foody, _MIN(p.y, q.y), _MAX(p.y, q.y)))
return true;
}
else if ((foody == p.y - 1 || foody == p.y) && WITHIN(foodx, MIN(p.x, q.x), MAX(p.x, q.x)))
else if ((foody == p.y - 1 || foody == p.y) && WITHIN(foodx, _MIN(p.x, q.x), _MAX(p.x, q.x)))
return true;
}
return false;
@ -164,9 +164,9 @@ bool snake_overlap() {
const pos_t &p = snake_tail[n], &q = snake_tail[n + 1];
if (p.x != q.x) {
// Crossing horizontal segment
if (WITHIN(h1.x, MIN(p.x, q.x), MAX(p.x, q.x)) && (h1.y <= p.y) == (h2.y >= p.y)) return true;
if (WITHIN(h1.x, _MIN(p.x, q.x), _MAX(p.x, q.x)) && (h1.y <= p.y) == (h2.y >= p.y)) return true;
} // Overlapping vertical segment
else if (h1.x == p.x && MIN(h1.y, h2.y) <= MAX(p.y, q.y) && MAX(h1.y, h2.y) >= MIN(p.y, q.y)) return true;
else if (h1.x == p.x && _MIN(h1.y, h2.y) <= _MAX(p.y, q.y) && _MAX(h1.y, h2.y) >= _MIN(p.y, q.y)) return true;
}
}
else {
@ -176,9 +176,9 @@ bool snake_overlap() {
const pos_t &p = snake_tail[n], &q = snake_tail[n + 1];
if (p.y != q.y) {
// Crossing vertical segment
if (WITHIN(h1.y, MIN(p.y, q.y), MAX(p.y, q.y)) && (h1.x <= p.x) == (h2.x >= p.x)) return true;
if (WITHIN(h1.y, _MIN(p.y, q.y), _MAX(p.y, q.y)) && (h1.x <= p.x) == (h2.x >= p.x)) return true;
} // Overlapping horizontal segment
else if (h1.y == p.y && MIN(h1.x, h2.x) <= MAX(p.x, q.x) && MAX(h1.x, h2.x) >= MIN(p.x, q.x)) return true;
else if (h1.y == p.y && _MIN(h1.x, h2.x) <= _MAX(p.x, q.x) && _MAX(h1.x, h2.x) >= _MIN(p.x, q.x)) return true;
}
}
return false;
@ -254,12 +254,12 @@ void SnakeGame::game_screen() {
for (uint8_t n = 0; n < head_ind; ++n) {
const pos_t &p = snake_tail[n], &q = snake_tail[n + 1];
if (p.x == q.x) {
const int8_t y1 = GAMEY(MIN(p.y, q.y)), y2 = GAMEY(MAX(p.y, q.y));
const int8_t y1 = GAMEY(_MIN(p.y, q.y)), y2 = GAMEY(_MAX(p.y, q.y));
if (PAGE_CONTAINS(y1, y2))
u8g.drawVLine(GAMEX(p.x), y1, y2 - y1 + 1);
}
else if (PAGE_CONTAINS(GAMEY(p.y), GAMEY(p.y))) {
const int8_t x1 = GAMEX(MIN(p.x, q.x)), x2 = GAMEX(MAX(p.x, q.x));
const int8_t x1 = GAMEX(_MIN(p.x, q.x)), x2 = GAMEX(_MAX(p.x, q.x));
u8g.drawHLine(x1, GAMEY(p.y), x2 - x1 + 1);
}
}
@ -270,14 +270,14 @@ void SnakeGame::game_screen() {
for (uint8_t n = 0; n < head_ind; ++n) {
const pos_t &p = snake_tail[n], &q = snake_tail[n + 1];
if (p.x == q.x) {
const int8_t y1 = GAMEY(MIN(p.y, q.y)), y2 = GAMEY(MAX(p.y, q.y));
const int8_t y1 = GAMEY(_MIN(p.y, q.y)), y2 = GAMEY(_MAX(p.y, q.y));
if (PAGE_CONTAINS(y1, y2 + 1))
u8g.drawFrame(GAMEX(p.x), y1, 2, y2 - y1 + 1 + 1);
}
else {
const int8_t py = GAMEY(p.y);
if (PAGE_CONTAINS(py, py + 1)) {
const int8_t x1 = GAMEX(MIN(p.x, q.x)), x2 = GAMEX(MAX(p.x, q.x));
const int8_t x1 = GAMEX(_MIN(p.x, q.x)), x2 = GAMEX(_MAX(p.x, q.x));
u8g.drawFrame(x1, py, x2 - x1 + 1 + 1, 2);
}
}
@ -289,7 +289,7 @@ void SnakeGame::game_screen() {
for (uint8_t n = 0; n < head_ind; ++n) {
const pos_t &p = snake_tail[n], &q = snake_tail[n + 1];
if (p.x == q.x) {
const int8_t y1 = MIN(p.y, q.y), y2 = MAX(p.y, q.y);
const int8_t y1 = _MIN(p.y, q.y), y2 = _MAX(p.y, q.y);
if (PAGE_CONTAINS(GAMEY(y1), GAMEY(y2) + SNAKE_SIZ - 1)) {
for (int8_t i = y1; i <= y2; ++i) {
const int8_t y = GAMEY(i);
@ -301,7 +301,7 @@ void SnakeGame::game_screen() {
else {
const int8_t py = GAMEY(p.y);
if (PAGE_CONTAINS(py, py + SNAKE_SIZ - 1)) {
const int8_t x1 = MIN(p.x, q.x), x2 = MAX(p.x, q.x);
const int8_t x1 = _MIN(p.x, q.x), x2 = _MAX(p.x, q.x);
for (int8_t i = x1; i <= x2; ++i)
u8g.drawBox(GAMEX(i), py, SNAKE_SIZ, SNAKE_SIZ);
}

2
Marlin/src/lcd/menu/menu.cpp

@ -326,7 +326,7 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
screen_changed = false;
}
if (screen_items > 0 && encoderLine >= screen_items - limit) {
encoderLine = MAX(0, screen_items - limit);
encoderLine = _MAX(0, screen_items - limit);
ui.encoderPosition = encoderLine * (ENCODER_STEPS_PER_MENU_ITEM);
}
if (is_menu) {

4
Marlin/src/lcd/menu/menu.h

@ -192,8 +192,8 @@ class TMenuItem : MenuItemBase {
public:
static void action_edit(PGM_P const pstr, type_t * const ptr, const type_t minValue, const type_t maxValue, const screenFunc_t callback=nullptr, const bool live=false) {
// Make sure minv and maxv fit within int16_t
const int32_t minv = MAX(scale(minValue), INT_MIN),
maxv = MIN(scale(maxValue), INT_MAX);
const int32_t minv = _MAX(scale(minValue), INT_MIN),
maxv = _MIN(scale(maxValue), INT_MAX);
init(pstr, ptr, minv, maxv - minv, scale(*ptr) - minv, edit, callback, live);
}
static void edit() { MenuItemBase::edit(to_string, load); }

20
Marlin/src/lcd/menu/menu_configuration.cpp

@ -283,20 +283,20 @@ static void lcd_factory_settings() {
void _menu_configuration_preheat_settings(const uint8_t material) {
#if HOTENDS > 5
#define MINTEMP_ALL MIN(HEATER_0_MINTEMP, HEATER_1_MINTEMP, HEATER_2_MINTEMP, HEATER_3_MINTEMP, HEATER_4_MINTEMP, HEATER_5_MINTEMP)
#define MAXTEMP_ALL MAX(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP)
#define MINTEMP_ALL _MIN(HEATER_0_MINTEMP, HEATER_1_MINTEMP, HEATER_2_MINTEMP, HEATER_3_MINTEMP, HEATER_4_MINTEMP, HEATER_5_MINTEMP)
#define MAXTEMP_ALL _MAX(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP)
#elif HOTENDS > 4
#define MINTEMP_ALL MIN(HEATER_0_MINTEMP, HEATER_1_MINTEMP, HEATER_2_MINTEMP, HEATER_3_MINTEMP, HEATER_4_MINTEMP)
#define MAXTEMP_ALL MAX(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP)
#define MINTEMP_ALL _MIN(HEATER_0_MINTEMP, HEATER_1_MINTEMP, HEATER_2_MINTEMP, HEATER_3_MINTEMP, HEATER_4_MINTEMP)
#define MAXTEMP_ALL _MAX(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP)
#elif HOTENDS > 3
#define MINTEMP_ALL MIN(HEATER_0_MINTEMP, HEATER_1_MINTEMP, HEATER_2_MINTEMP, HEATER_3_MINTEMP)
#define MAXTEMP_ALL MAX(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP)
#define MINTEMP_ALL _MIN(HEATER_0_MINTEMP, HEATER_1_MINTEMP, HEATER_2_MINTEMP, HEATER_3_MINTEMP)
#define MAXTEMP_ALL _MAX(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP)
#elif HOTENDS > 2
#define MINTEMP_ALL MIN(HEATER_0_MINTEMP, HEATER_1_MINTEMP, HEATER_2_MINTEMP)
#define MAXTEMP_ALL MAX(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP)
#define MINTEMP_ALL _MIN(HEATER_0_MINTEMP, HEATER_1_MINTEMP, HEATER_2_MINTEMP)
#define MAXTEMP_ALL _MAX(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP)
#elif HOTENDS > 1
#define MINTEMP_ALL MIN(HEATER_0_MINTEMP, HEATER_1_MINTEMP)
#define MAXTEMP_ALL MAX(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP)
#define MINTEMP_ALL _MIN(HEATER_0_MINTEMP, HEATER_1_MINTEMP)
#define MAXTEMP_ALL _MAX(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP)
#else
#define MINTEMP_ALL HEATER_0_MINTEMP
#define MAXTEMP_ALL HEATER_0_MAXTEMP

2
Marlin/src/lcd/menu/menu_delta_calibrate.cpp

@ -39,7 +39,7 @@
void _man_probe_pt(const float &rx, const float &ry) {
do_blocking_move_to(rx, ry, Z_CLEARANCE_BETWEEN_PROBES);
ui.synchronize();
move_menu_scale = MAX(PROBE_MANUALLY_STEP, MIN_STEPS_PER_SEGMENT / float(DEFAULT_XYZ_STEPS_PER_UNIT));
move_menu_scale = _MAX(PROBE_MANUALLY_STEP, MIN_STEPS_PER_SEGMENT / float(DEFAULT_XYZ_STEPS_PER_UNIT));
ui.goto_screen(lcd_move_z);
}

2
Marlin/src/lcd/menu/menu_temperature.cpp

@ -48,7 +48,7 @@ uint8_t MarlinUI::preheat_fan_speed[2];
//
void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb, const uint8_t fan) {
if (temph > 0) thermalManager.setTargetHotend(MIN(heater_maxtemp[endnum] - 15, temph), endnum);
if (temph > 0) thermalManager.setTargetHotend(_MIN(heater_maxtemp[endnum] - 15, temph), endnum);
#if HAS_HEATED_BED
if (tempb >= 0) thermalManager.setTargetBed(tempb);
#else

2
Marlin/src/lcd/ultralcd.cpp

@ -150,7 +150,7 @@ millis_t next_button_update_ms;
static uint8_t filename_scroll_hash;
if (filename_scroll_hash != hash) { // If the hash changed...
filename_scroll_hash = hash; // Save the new hash
filename_scroll_max = MAX(0, utf8_strlen(theCard.longFilename) - maxlen); // Update the scroll limit
filename_scroll_max = _MAX(0, utf8_strlen(theCard.longFilename) - maxlen); // Update the scroll limit
filename_scroll_pos = 0; // Reset scroll to the start
lcd_status_update_delay = 8; // Don't scroll right away
}

2
Marlin/src/lcd/ultralcd.h

@ -293,7 +293,7 @@ public:
#if HAS_PRINT_PROGRESS
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
static uint8_t progress_bar_percent;
static void set_progress(const uint8_t progress) { progress_bar_percent = MIN(progress, 100); }
static void set_progress(const uint8_t progress) { progress_bar_percent = _MIN(progress, 100); }
#endif
static uint8_t get_progress();
#else

8
Marlin/src/libs/least_squares_fit.h

@ -61,8 +61,8 @@ void inline incremental_WLSF(struct linear_fit_data *lsf, const float &x, const
lsf->xzbar += w * x * z;
lsf->yzbar += w * y * z;
lsf->N += w;
lsf->max_absx = MAX(ABS(w * x), lsf->max_absx);
lsf->max_absy = MAX(ABS(w * y), lsf->max_absy);
lsf->max_absx = _MAX(ABS(w * x), lsf->max_absx);
lsf->max_absy = _MAX(ABS(w * y), lsf->max_absy);
}
void inline incremental_LSF(struct linear_fit_data *lsf, const float &x, const float &y, const float &z) {
@ -75,8 +75,8 @@ void inline incremental_LSF(struct linear_fit_data *lsf, const float &x, const f
lsf->xybar += x * y;
lsf->xzbar += x * z;
lsf->yzbar += y * z;
lsf->max_absx = MAX(ABS(x), lsf->max_absx);
lsf->max_absy = MAX(ABS(y), lsf->max_absy);
lsf->max_absx = _MAX(ABS(x), lsf->max_absx);
lsf->max_absy = _MAX(ABS(y), lsf->max_absy);
lsf->N += 1.0;
}

4
Marlin/src/libs/nozzle.cpp

@ -172,11 +172,11 @@
break;
case 2: // Raise by Z-park height
do_blocking_move_to_z(MIN(current_position[Z_AXIS] + park.z, Z_MAX_POS), fr_z);
do_blocking_move_to_z(_MIN(current_position[Z_AXIS] + park.z, Z_MAX_POS), fr_z);
break;
default: // Raise to at least the Z-park height
do_blocking_move_to_z(MAX(park.z, current_position[Z_AXIS]), fr_z);
do_blocking_move_to_z(_MAX(park.z, current_position[Z_AXIS]), fr_z);
}
do_blocking_move_to_xy(park.x, park.y, fr_xy);

2
Marlin/src/module/configuration_store.cpp

@ -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

10
Marlin/src/module/motion.cpp

@ -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)
);

24
Marlin/src/module/planner.cpp

@ -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.

2
Marlin/src/module/planner.h

@ -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;

6
Marlin/src/module/printcounter.cpp

@ -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;

4
Marlin/src/module/probe.cpp

@ -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

4
Marlin/src/module/stepper.cpp

@ -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;

6
Marlin/src/module/stepper.h

@ -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

16
Marlin/src/module/temperature.cpp

@ -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))

10
Marlin/src/module/temperature.h

@ -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

2
Marlin/src/module/tool_change.cpp

@ -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

Loading…
Cancel
Save