소스 검색

Smarter MIN, MAX, ABS macros

Use macros that explicitly avoid double-evaluation and can be used for any datatype, replacing `min`, `max`, `abs`, `fabs`, `labs`, and `FABS`.

Co-Authored-By: ejtagle <ejtagle@hotmail.com>
Scott Lahteine 6 년 전
부모
커밋
99ecdf59af
52개의 변경된 파일206개의 추가작업 그리고 247개의 파일을 삭제
  1. 0
    73
      Marlin/src/HAL/HAL_DUE/usb/compiler.h
  2. 1
    1
      Marlin/src/HAL/HAL_DUE/usb/uotghs_device_due.c
  3. 1
    1
      Marlin/src/HAL/HAL_DUE/usb/uotghs_device_due.h
  4. 1
    1
      Marlin/src/HAL/HAL_LPC1768/SoftwareSPI.cpp
  5. 2
    5
      Marlin/src/HAL/HAL_LPC1768/include/Arduino.h
  6. 2
    2
      Marlin/src/HAL/HAL_STM32F1/HAL_timers_Stm32f1.cpp
  7. 1
    1
      Marlin/src/HAL/HAL_STM32F1/HAL_timers_Stm32f1.h
  8. 2
    2
      Marlin/src/HAL/HAL_STM32F7/TMC2660.cpp
  9. 1
    1
      Marlin/src/HAL/servo.cpp
  10. 43
    8
      Marlin/src/core/macros.h
  11. 10
    10
      Marlin/src/feature/I2CPositionEncoder.cpp
  12. 2
    2
      Marlin/src/feature/Max7219_Debug_LEDs.cpp
  13. 4
    4
      Marlin/src/feature/bedlevel/abl/abl.cpp
  14. 1
    1
      Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp
  15. 5
    5
      Marlin/src/feature/bedlevel/ubl/ubl.h
  16. 8
    8
      Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
  17. 3
    3
      Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp
  18. 1
    1
      Marlin/src/feature/digipot/digipot_mcp4018.cpp
  19. 1
    1
      Marlin/src/feature/digipot/digipot_mcp4451.cpp
  20. 3
    3
      Marlin/src/gcode/bedlevel/G26.cpp
  21. 1
    1
      Marlin/src/gcode/bedlevel/abl/G29.cpp
  22. 1
    1
      Marlin/src/gcode/bedlevel/mbl/G29.cpp
  23. 1
    1
      Marlin/src/gcode/calibrate/G28.cpp
  24. 1
    1
      Marlin/src/gcode/calibrate/M48.cpp
  25. 1
    1
      Marlin/src/gcode/control/M605.cpp
  26. 1
    1
      Marlin/src/gcode/feature/pause/M125.cpp
  27. 3
    3
      Marlin/src/gcode/feature/pause/M600.cpp
  28. 2
    2
      Marlin/src/gcode/feature/pause/M603.cpp
  29. 6
    6
      Marlin/src/gcode/feature/pause/M701_M702.cpp
  30. 1
    1
      Marlin/src/gcode/motion/G0_G1.cpp
  31. 1
    1
      Marlin/src/gcode/motion/G2_G3.cpp
  32. 3
    3
      Marlin/src/gcode/probe/G38.cpp
  33. 1
    1
      Marlin/src/gcode/temperature/M104_M109.cpp
  34. 2
    2
      Marlin/src/gcode/temperature/M106_M107.cpp
  35. 1
    1
      Marlin/src/gcode/temperature/M140_M190.cpp
  36. 10
    11
      Marlin/src/inc/Conditionals_post.h
  37. 2
    2
      Marlin/src/lcd/malyanlcd.cpp
  38. 9
    9
      Marlin/src/lcd/ultralcd.cpp
  39. 1
    1
      Marlin/src/lcd/ultralcd_impl_DOGM.h
  40. 5
    5
      Marlin/src/lcd/ultralcd_impl_HD44780.h
  41. 1
    1
      Marlin/src/libs/least_squares_fit.cpp
  42. 4
    4
      Marlin/src/libs/least_squares_fit.h
  43. 3
    3
      Marlin/src/libs/nozzle.cpp
  44. 1
    1
      Marlin/src/module/delta.cpp
  45. 11
    10
      Marlin/src/module/motion.cpp
  46. 1
    1
      Marlin/src/module/motion.h
  47. 29
    29
      Marlin/src/module/planner.cpp
  48. 1
    1
      Marlin/src/module/planner.h
  49. 1
    1
      Marlin/src/module/planner_bezier.cpp
  50. 2
    2
      Marlin/src/module/probe.cpp
  51. 4
    4
      Marlin/src/module/temperature.cpp
  52. 3
    3
      Marlin/src/module/temperature.h

+ 0
- 73
Marlin/src/HAL/HAL_DUE/usb/compiler.h 파일 보기

@@ -785,79 +785,6 @@ typedef struct
785 785
 
786 786
 //! @}
787 787
 
788
-
789
-/*! \name Mathematics
790
- *
791
- * The same considerations as for clz and ctz apply here but GCC does not
792
- * provide built-in functions to access the assembly instructions abs, min and
793
- * max and it does not produce them by itself in most cases, so two sets of
794
- * macros are defined here:
795
- *   - Abs, Min and Max to apply to constant expressions (values known at
796
- *     compile time);
797
- *   - abs, min and max to apply to non-constant expressions (values unknown at
798
- *     compile time), abs is found in stdlib.h.
799
- */
800
-//! @{
801
-
802
-/*! \brief Takes the absolute value of \a a.
803
- *
804
- * \param a Input value.
805
- *
806
- * \return Absolute value of \a a.
807
- *
808
- * \note More optimized if only used with values known at compile time.
809
- */
810
-#define Abs(a)              (((a) <  0 ) ? -(a) : (a))
811
-
812
-/*! \brief Takes the minimal value of \a a and \a b.
813
- *
814
- * \param a Input value.
815
- * \param b Input value.
816
- *
817
- * \return Minimal value of \a a and \a b.
818
- *
819
- * \note More optimized if only used with values known at compile time.
820
- */
821
-#define Min(a, b)           (((a) < (b)) ?  (a) : (b))
822
-
823
-/*! \brief Takes the maximal value of \a a and \a b.
824
- *
825
- * \param a Input value.
826
- * \param b Input value.
827
- *
828
- * \return Maximal value of \a a and \a b.
829
- *
830
- * \note More optimized if only used with values known at compile time.
831
- */
832
-#define Max(a, b)           (((a) > (b)) ?  (a) : (b))
833
-
834
-// abs() is already defined by stdlib.h
835
-
836
-/*! \brief Takes the minimal value of \a a and \a b.
837
- *
838
- * \param a Input value.
839
- * \param b Input value.
840
- *
841
- * \return Minimal value of \a a and \a b.
842
- *
843
- * \note More optimized if only used with values unknown at compile time.
844
- */
845
-#define min(a, b)   Min(a, b)
846
-
847
-/*! \brief Takes the maximal value of \a a and \a b.
848
- *
849
- * \param a Input value.
850
- * \param b Input value.
851
- *
852
- * \return Maximal value of \a a and \a b.
853
- *
854
- * \note More optimized if only used with values unknown at compile time.
855
- */
856
-#define max(a, b)   Max(a, b)
857
-
858
-//! @}
859
-
860
-
861 788
 /*! \brief Calls the routine at address \a addr.
862 789
  *
863 790
  * It generates a long call opcode.

+ 1
- 1
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)
1904 1904
 		ptr_src = &ptr_job->buf[ptr_job->buf_cnt];
1905 1905
 		nb_remain = ptr_job->buf_size - ptr_job->buf_cnt;
1906 1906
 		// Fill a bank even if no data (ZLP)
1907
-		nb_data = min(nb_remain, pkt_size);
1907
+		nb_data = MIN(nb_remain, pkt_size);
1908 1908
 		// Modify job information
1909 1909
 		ptr_job->buf_cnt += nb_data;
1910 1910
 		ptr_job->buf_load = nb_data;

+ 1
- 1
Marlin/src/HAL/HAL_DUE/usb/uotghs_device_due.h 파일 보기

@@ -290,7 +290,7 @@ extern "C" {
290 290
   //! Bounds given integer size to allowed range and rounds it up to the nearest
291 291
   //! available greater size, then applies register format of UOTGHS controller
292 292
   //! for endpoint size bit-field.
293
-#define udd_format_endpoint_size(size)            (32 - clz(((uint32_t)min(max(size, 8), 1024) << 1) - 1) - 1 - 3)
293
+#define udd_format_endpoint_size(size)            (32 - clz(((uint32_t)MIN(MAX(size, 8), 1024) << 1) - 1) - 1 - 3)
294 294
   //! Configures the selected endpoint size
295 295
 #define udd_configure_endpoint_size(ep, size)     (Wr_bitfield(UOTGHS_ARRAY(UOTGHS_DEVEPTCFG[0], ep), UOTGHS_DEVEPTCFG_EPSIZE_Msk, udd_format_endpoint_size(size)))
296 296
   //! Gets the configured selected endpoint size

+ 1
- 1
Marlin/src/HAL/HAL_LPC1768/SoftwareSPI.cpp 파일 보기

@@ -84,7 +84,7 @@ void swSpiBegin(const pin_t sck_pin, const pin_t miso_pin, const pin_t mosi_pin)
84 84
 uint8_t swSpiInit(const uint8_t spiRate, const pin_t sck_pin, const pin_t mosi_pin) {
85 85
   WRITE(mosi_pin, HIGH);
86 86
   WRITE(sck_pin, LOW);
87
-  return (SystemCoreClock == 120000000 ? 44 : 38) / POW(2, 6 - min(spiRate, 6));
87
+  return (SystemCoreClock == 120000000 ? 44 : 38) / POW(2, 6 - MIN(spiRate, 6));
88 88
 }
89 89
 
90 90
 #endif // TARGET_LPC1768

+ 2
- 5
Marlin/src/HAL/HAL_LPC1768/include/Arduino.h 파일 보기

@@ -50,9 +50,11 @@ typedef uint8_t byte;
50 50
 #define PSTR(v) (v)
51 51
 #define PGM_P const char *
52 52
 
53
+// Used for libraries, preprocessor, and constants
53 54
 #define min(a,b) ((a)<(b)?(a):(b))
54 55
 #define max(a,b) ((a)>(b)?(a):(b))
55 56
 #define abs(x) ((x)>0?(x):-(x))
57
+
56 58
 #ifndef isnan
57 59
   #define isnan std::isnan
58 60
 #endif
@@ -60,11 +62,6 @@ typedef uint8_t byte;
60 62
   #define isinf std::isinf
61 63
 #endif
62 64
 
63
-//not constexpr until c++14
64
-//#define max(v1, v2) std::max((int)v1,(int)v2)
65
-//#define min(v1, v2) std::min((int)v1,(int)v2)
66
-//#define abs(v) std::abs(v)
67
-
68 65
 #define sq(v) ((v) * (v))
69 66
 #define square(v) sq(v)
70 67
 #define constrain(value, arg_min, arg_max) ((value) < (arg_min) ? (arg_min) :((value) > (arg_max) ? (arg_max) : (value)))

+ 2
- 2
Marlin/src/HAL/HAL_STM32F1/HAL_timers_Stm32f1.cpp 파일 보기

@@ -121,7 +121,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
121 121
       timer_set_count(STEP_TIMER_DEV, 0);
122 122
       timer_set_prescaler(STEP_TIMER_DEV, (uint16)(STEPPER_TIMER_PRESCALE - 1));
123 123
       timer_set_reload(STEP_TIMER_DEV, 0xFFFF);
124
-      timer_set_compare(STEP_TIMER_DEV, STEP_TIMER_CHAN, min(HAL_TIMER_TYPE_MAX, (HAL_STEPPER_TIMER_RATE / frequency)));
124
+      timer_set_compare(STEP_TIMER_DEV, STEP_TIMER_CHAN, MIN(HAL_TIMER_TYPE_MAX, (HAL_STEPPER_TIMER_RATE / frequency)));
125 125
       timer_attach_interrupt(STEP_TIMER_DEV, STEP_TIMER_CHAN, stepTC_Handler);
126 126
       nvic_irq_set_priority(irq_num, 1);
127 127
       timer_generate_update(STEP_TIMER_DEV);
@@ -132,7 +132,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
132 132
       timer_set_count(TEMP_TIMER_DEV, 0);
133 133
       timer_set_prescaler(TEMP_TIMER_DEV, (uint16)(TEMP_TIMER_PRESCALE - 1));
134 134
       timer_set_reload(TEMP_TIMER_DEV, 0xFFFF);
135
-      timer_set_compare(TEMP_TIMER_DEV, TEMP_TIMER_CHAN, min(HAL_TIMER_TYPE_MAX, ((F_CPU / TEMP_TIMER_PRESCALE) / frequency)));
135
+      timer_set_compare(TEMP_TIMER_DEV, TEMP_TIMER_CHAN, MIN(HAL_TIMER_TYPE_MAX, ((F_CPU / TEMP_TIMER_PRESCALE) / frequency)));
136 136
       timer_attach_interrupt(TEMP_TIMER_DEV, TEMP_TIMER_CHAN, tempTC_Handler);
137 137
       nvic_irq_set_priority(irq_num, 2);
138 138
       timer_generate_update(TEMP_TIMER_DEV);

+ 1
- 1
Marlin/src/HAL/HAL_STM32F1/HAL_timers_Stm32f1.h 파일 보기

@@ -130,7 +130,7 @@ bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
130 130
  */
131 131
 
132 132
 FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) {
133
-  //compare = min(compare, HAL_TIMER_TYPE_MAX);
133
+  //compare = MIN(compare, HAL_TIMER_TYPE_MAX);
134 134
   switch (timer_num) {
135 135
   case STEP_TIMER_NUM:
136 136
     timer_set_compare(STEP_TIMER_DEV, STEP_TIMER_CHAN, compare);

+ 2
- 2
Marlin/src/HAL/HAL_STM32F7/TMC2660.cpp 파일 보기

@@ -237,7 +237,7 @@ unsigned int TMC26XStepper::getSpeed(void) { return this->speed; }
237 237
  */
238 238
 char TMC26XStepper::step(int steps_to_move) {
239 239
   if (this->steps_left == 0) {
240
-    this->steps_left = abs(steps_to_move);  // how many steps to take
240
+    this->steps_left = ABS(steps_to_move);  // how many steps to take
241 241
 
242 242
     // determine direction based on whether steps_to_move is + or -:
243 243
     if (steps_to_move > 0)
@@ -257,7 +257,7 @@ char TMC26XStepper::move(void) {
257 257
 
258 258
     // rem if (time >= this->next_step_time) {
259 259
 
260
-    if (abs(time - this->last_step_time) > this->step_delay) {
260
+    if (ABS(time - this->last_step_time) > this->step_delay) {
261 261
       // increment or decrement the step number,
262 262
       // depending on direction:
263 263
       if (this->direction == 1)

+ 1
- 1
Marlin/src/HAL/servo.cpp 파일 보기

@@ -99,7 +99,7 @@ int8_t Servo::attach(const int pin, const int min, const int max) {
99 99
   if (pin > 0) servo_info[this->servoIndex].Pin.nbr = pin;
100 100
   pinMode(servo_info[this->servoIndex].Pin.nbr, OUTPUT); // set servo pin to output
101 101
 
102
-  // todo min/max check: abs(min - MIN_PULSE_WIDTH) /4 < 128
102
+  // todo min/max check: ABS(min - MIN_PULSE_WIDTH) /4 < 128
103 103
   this->min = (MIN_PULSE_WIDTH - min) / 4; //resolution of min/max is 4 uS
104 104
   this->max = (MAX_PULSE_WIDTH - max) / 4;
105 105
 

+ 43
- 8
Marlin/src/core/macros.h 파일 보기

@@ -113,7 +113,7 @@
113 113
 #define DECIMAL_SIGNED(a) (DECIMAL(a) || (a) == '-' || (a) == '+')
114 114
 #define COUNT(a) (sizeof(a)/sizeof(*a))
115 115
 #define ZERO(a) memset(a,0,sizeof(a))
116
-#define COPY(a,b) memcpy(a,b,min(sizeof(a),sizeof(b)))
116
+#define COPY(a,b) memcpy(a,b,MIN(sizeof(a),sizeof(b)))
117 117
 
118 118
 // Macros for initializing arrays
119 119
 #define ARRAY_6(v1, v2, v3, v4, v5, v6, ...) { v1, v2, v3, v4, v5, v6 }
@@ -164,12 +164,48 @@
164 164
 
165 165
 #define CEILING(x,y) (((x) + (y) - 1) / (y))
166 166
 
167
-#define MIN3(a, b, c)       min(min(a, b), c)
168
-#define MIN4(a, b, c, d)    min(MIN3(a, b, c), d)
169
-#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
170
-#define MAX3(a, b, c)       max(max(a, b), c)
171
-#define MAX4(a, b, c, d)    max(MAX3(a, b, c), d)
172
-#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
167
+// Avoid double evaluation of arguments on MIN/MAX/ABS
168
+#undef MIN
169
+#undef MAX
170
+#undef ABS
171
+#ifdef __cplusplus
172
+
173
+  // C++11 solution that is standards compliant. Return type is deduced automatically
174
+  template <class L, class R> static inline constexpr auto MIN(const L lhs, const R rhs) -> decltype(lhs + rhs) {
175
+    return lhs < rhs ? lhs : rhs;
176
+  }
177
+  template <class L, class R> static inline constexpr auto MAX(const L lhs, const R rhs) -> decltype(lhs + rhs){
178
+    return lhs > rhs ? lhs : rhs;
179
+  }
180
+  template <class T> static inline constexpr const T ABS(const T v) {
181
+    return v >= 0 ? v : -v;
182
+  }
183
+#else
184
+
185
+  // Using GCC extensions, but Travis GCC version does not like it and gives
186
+  //  "error: statement-expressions are not allowed outside functions nor in template-argument lists"
187
+  #define MIN(a, b) \
188
+    ({__typeof__(a) _a = (a); \
189
+      __typeof__(b) _b = (b); \
190
+      _a < _b ? _a : _b;})
191
+
192
+  #define MAX(a, b) \
193
+    ({__typeof__(a) _a = (a); \
194
+      __typeof__(b) _b = (b); \
195
+      _a > _b ? _a : _b;})
196
+
197
+  #define ABS(a) \
198
+    ({__typeof__(a) _a = (a); \
199
+      _a >= 0 ? _a : -_a;})
200
+
201
+#endif
202
+
203
+#define MIN3(a, b, c)       MIN(MIN(a, b), c)
204
+#define MIN4(a, b, c, d)    MIN(MIN3(a, b, c), d)
205
+#define MIN5(a, b, c, d, e) MIN(MIN4(a, b, c, d), e)
206
+#define MAX3(a, b, c)       MAX(MAX(a, b), c)
207
+#define MAX4(a, b, c, d)    MAX(MAX3(a, b, c), d)
208
+#define MAX5(a, b, c, d, e) MAX(MAX4(a, b, c, d), e)
173 209
 
174 210
 #define UNEAR_ZERO(x) ((x) < 0.000001)
175 211
 #define NEAR_ZERO(x) WITHIN(x, -0.000001, 0.000001)
@@ -182,7 +218,6 @@
182 218
 // Maths macros that can be overridden by HAL
183 219
 //
184 220
 #define ATAN2(y, x) atan2(y, x)
185
-#define FABS(x)     fabs(x)
186 221
 #define POW(x, y)   pow(x, y)
187 222
 #define SQRT(x)     sqrt(x)
188 223
 #define CEIL(x)     ceil(x)

+ 10
- 10
Marlin/src/feature/I2CPositionEncoder.cpp 파일 보기

@@ -134,7 +134,7 @@ void I2CPositionEncoder::update() {
134 134
 
135 135
     #ifdef I2CPE_EC_THRESH_PROPORTIONAL
136 136
       const millis_t deltaTime = positionTime - lastPositionTime;
137
-      const uint32_t distance = abs(position - lastPosition),
137
+      const uint32_t distance = ABS(position - lastPosition),
138 138
                      speed = distance / deltaTime;
139 139
       const float threshold = constrain((speed / 50), 1, 50) * ecThreshold;
140 140
     #else
@@ -150,7 +150,7 @@ void I2CPositionEncoder::update() {
150 150
 
151 151
       LOOP_L_N(i, I2CPE_ERR_ARRAY_SIZE) {
152 152
         sum += err[i];
153
-        if (i) diffSum += abs(err[i-1] - err[i]);
153
+        if (i) diffSum += ABS(err[i-1] - err[i]);
154 154
       }
155 155
 
156 156
       const int32_t error = int32_t(sum / (I2CPE_ERR_ARRAY_SIZE + 1)); //calculate average for error
@@ -163,7 +163,7 @@ void I2CPositionEncoder::update() {
163 163
     //SERIAL_ECHOLN(error);
164 164
 
165 165
     #ifdef I2CPE_ERR_THRESH_ABORT
166
-      if (labs(error) > I2CPE_ERR_THRESH_ABORT * planner.axis_steps_per_mm[encoderAxis]) {
166
+      if (ABS(error) > I2CPE_ERR_THRESH_ABORT * planner.axis_steps_per_mm[encoderAxis]) {
167 167
         //kill("Significant Error");
168 168
         SERIAL_ECHOPGM("Axis error greater than set threshold, aborting!");
169 169
         SERIAL_ECHOLN(error);
@@ -175,8 +175,8 @@ void I2CPositionEncoder::update() {
175 175
       if (errIdx == 0) {
176 176
         // In order to correct for "error" but avoid correcting for noise and non-skips
177 177
         // it must be > threshold and have a difference average of < 10 and be < 2000 steps
178
-        if (labs(error) > threshold * planner.axis_steps_per_mm[encoderAxis] &&
179
-            diffSum < 10 * (I2CPE_ERR_ARRAY_SIZE - 1) && labs(error) < 2000) { // Check for persistent error (skip)
178
+        if (ABS(error) > threshold * planner.axis_steps_per_mm[encoderAxis] &&
179
+            diffSum < 10 * (I2CPE_ERR_ARRAY_SIZE - 1) && ABS(error) < 2000) { // Check for persistent error (skip)
180 180
           errPrst[errPrstIdx++] = error; // Error must persist for I2CPE_ERR_PRST_ARRAY_SIZE error cycles. This also serves to improve the average accuracy
181 181
           if (errPrstIdx >= I2CPE_ERR_PRST_ARRAY_SIZE) {
182 182
             float sumP = 0;
@@ -193,14 +193,14 @@ void I2CPositionEncoder::update() {
193 193
           errPrstIdx = 0;
194 194
       }
195 195
     #else
196
-      if (labs(error) > threshold * planner.axis_steps_per_mm[encoderAxis]) {
196
+      if (ABS(error) > threshold * planner.axis_steps_per_mm[encoderAxis]) {
197 197
         //SERIAL_ECHOLN(error);
198 198
         //SERIAL_ECHOLN(position);
199 199
         thermalManager.babystepsTodo[encoderAxis] = -LROUND(error / 2);
200 200
       }
201 201
     #endif
202 202
 
203
-    if (labs(error) > I2CPE_ERR_CNT_THRESH * planner.axis_steps_per_mm[encoderAxis]) {
203
+    if (ABS(error) > I2CPE_ERR_CNT_THRESH * planner.axis_steps_per_mm[encoderAxis]) {
204 204
       const millis_t ms = millis();
205 205
       if (ELAPSED(ms, nextErrorCountTime)) {
206 206
         SERIAL_ECHOPAIR("Large error on ", axis_codes[encoderAxis]);
@@ -258,7 +258,7 @@ float I2CPositionEncoder::get_axis_error_mm(const bool report) {
258 258
   actual = mm_from_count(position);
259 259
   error = actual - target;
260 260
 
261
-  if (labs(error) > 10000) error = 0; // ?
261
+  if (ABS(error) > 10000) error = 0; // ?
262 262
 
263 263
   if (report) {
264 264
     SERIAL_ECHO(axis_codes[encoderAxis]);
@@ -293,7 +293,7 @@ int32_t I2CPositionEncoder::get_axis_error_steps(const bool report) {
293 293
           error = (encoderCountInStepperTicksScaled - target);
294 294
 
295 295
   //suppress discontinuities (might be caused by bad I2C readings...?)
296
-  bool suppressOutput = (labs(error - errorPrev) > 100);
296
+  bool suppressOutput = (ABS(error - errorPrev) > 100);
297 297
 
298 298
   if (report) {
299 299
     SERIAL_ECHO(axis_codes[encoderAxis]);
@@ -435,7 +435,7 @@ void I2CPositionEncoder::calibrate_steps_mm(const uint8_t iter) {
435 435
     delay(250);
436 436
     stopCount = get_position();
437 437
 
438
-    travelledDistance = mm_from_count(abs(stopCount - startCount));
438
+    travelledDistance = mm_from_count(ABS(stopCount - startCount));
439 439
 
440 440
     SERIAL_ECHOPAIR("Attempted to travel: ", travelDistance);
441 441
     SERIAL_ECHOLNPGM("mm.");

+ 2
- 2
Marlin/src/feature/Max7219_Debug_LEDs.cpp 파일 보기

@@ -347,8 +347,8 @@ void Max7219_idle_tasks() {
347 347
       NOMORE(current_depth, 16);        // if the BLOCK_BUFFER_SIZE is greater than 16, two lines
348 348
                                         // of LEDs is enough to see if the buffer is draining
349 349
 
350
-      const uint8_t st = min(current_depth, last_depth),
351
-                    en = max(current_depth, last_depth);
350
+      const uint8_t st = MIN(current_depth, last_depth),
351
+                    en = MAX(current_depth, last_depth);
352 352
       if (current_depth < last_depth)
353 353
         for (uint8_t i = st; i <= en; i++)   // clear the highest order LEDs
354 354
           Max7219_LED_Off(MAX7219_DEBUG_STEPPER_QUEUE + (i & 1), i / 2);

+ 4
- 4
Marlin/src/feature/bedlevel/abl/abl.cpp 파일 보기

@@ -295,7 +295,7 @@ float bilinear_z_offset(const float raw[XYZ]) {
295 295
     #endif
296 296
 
297 297
     gridx = gx;
298
-    nextx = min(gridx + 1, ABL_BG_POINTS_X - 1);
298
+    nextx = MIN(gridx + 1, ABL_BG_POINTS_X - 1);
299 299
   }
300 300
 
301 301
   if (last_y != ry || last_gridx != gridx) {
@@ -312,7 +312,7 @@ float bilinear_z_offset(const float raw[XYZ]) {
312 312
       #endif
313 313
 
314 314
       gridy = gy;
315
-      nexty = min(gridy + 1, ABL_BG_POINTS_Y - 1);
315
+      nexty = MIN(gridy + 1, ABL_BG_POINTS_Y - 1);
316 316
     }
317 317
 
318 318
     if (last_gridx != gridx || last_gridy != gridy) {
@@ -336,7 +336,7 @@ float bilinear_z_offset(const float raw[XYZ]) {
336 336
 
337 337
   /*
338 338
   static float last_offset = 0;
339
-  if (FABS(last_offset - offset) > 0.2) {
339
+  if (ABS(last_offset - offset) > 0.2) {
340 340
     SERIAL_ECHOPGM("Sudden Shift at ");
341 341
     SERIAL_ECHOPAIR("x=", rx);
342 342
     SERIAL_ECHOPAIR(" / ", bilinear_grid_spacing[X_AXIS]);
@@ -389,7 +389,7 @@ float bilinear_z_offset(const float raw[XYZ]) {
389 389
     #define LINE_SEGMENT_END(A) (current_position[A ##_AXIS] + (destination[A ##_AXIS] - current_position[A ##_AXIS]) * normalized_dist)
390 390
 
391 391
     float normalized_dist, end[XYZE];
392
-    const int8_t gcx = max(cx1, cx2), gcy = max(cy1, cy2);
392
+    const int8_t gcx = MAX(cx1, cx2), gcy = MAX(cy1, cy2);
393 393
 
394 394
     // Crosses on the X and not already split on this X?
395 395
     // The x_splits flags are insurance against rounding errors.

+ 1
- 1
Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp 파일 보기

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

+ 5
- 5
Marlin/src/feature/bedlevel/ubl/ubl.h 파일 보기

@@ -242,7 +242,7 @@ class unified_bed_leveling {
242 242
       const float xratio = (rx0 - mesh_index_to_xpos(x1_i)) * (1.0 / (MESH_X_DIST)),
243 243
                   z1 = z_values[x1_i][yi];
244 244
 
245
-      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
245
+      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
246 246
                                                                                       // If it is, it is clamped to the last element of the
247 247
                                                                                       // z_values[][] array and no correction is applied.
248 248
     }
@@ -276,7 +276,7 @@ class unified_bed_leveling {
276 276
       const float yratio = (ry0 - mesh_index_to_ypos(y1_i)) * (1.0 / (MESH_Y_DIST)),
277 277
                   z1 = z_values[xi][y1_i];
278 278
 
279
-      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
279
+      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
280 280
                                                                                       // If it is, it is clamped to the last element of the
281 281
                                                                                       // z_values[][] array and no correction is applied.
282 282
     }
@@ -302,11 +302,11 @@ class unified_bed_leveling {
302 302
 
303 303
       const float z1 = calc_z0(rx0,
304 304
                                mesh_index_to_xpos(cx), z_values[cx][cy],
305
-                               mesh_index_to_xpos(cx + 1), z_values[min(cx, GRID_MAX_POINTS_X - 2) + 1][cy]);
305
+                               mesh_index_to_xpos(cx + 1), z_values[MIN(cx, GRID_MAX_POINTS_X - 2) + 1][cy]);
306 306
 
307 307
       const float z2 = calc_z0(rx0,
308
-                               mesh_index_to_xpos(cx), z_values[cx][min(cy, GRID_MAX_POINTS_Y - 2) + 1],
309
-                               mesh_index_to_xpos(cx + 1), z_values[min(cx, GRID_MAX_POINTS_X - 2) + 1][min(cy, GRID_MAX_POINTS_Y - 2) + 1]);
308
+                               mesh_index_to_xpos(cx), z_values[cx][MIN(cy, GRID_MAX_POINTS_Y - 2) + 1],
309
+                               mesh_index_to_xpos(cx + 1), z_values[MIN(cx, GRID_MAX_POINTS_X - 2) + 1][MIN(cy, GRID_MAX_POINTS_Y - 2) + 1]);
310 310
 
311 311
       float z0 = calc_z0(ry0,
312 312
                          mesh_index_to_ypos(cy), z1,

+ 8
- 8
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp 파일 보기

@@ -451,7 +451,7 @@
451 451
 
452 452
             if (parser.seen('B')) {
453 453
               g29_card_thickness = parser.has_value() ? parser.value_float() : measure_business_card_thickness((float) Z_CLEARANCE_BETWEEN_PROBES);
454
-              if (FABS(g29_card_thickness) > 1.5) {
454
+              if (ABS(g29_card_thickness) > 1.5) {
455 455
                 SERIAL_PROTOCOLLNPGM("?Error in Business Card measurement.");
456 456
                 return;
457 457
               }
@@ -796,7 +796,7 @@
796 796
       save_ubl_active_state_and_disable();   // Disable bed level correction for probing
797 797
 
798 798
       do_blocking_move_to(0.5 * (MESH_MAX_X - (MESH_MIN_X)), 0.5 * (MESH_MAX_Y - (MESH_MIN_Y)), in_height);
799
-        //, min(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS]) / 2.0);
799
+        //, MIN(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS]) / 2.0);
800 800
       planner.synchronize();
801 801
 
802 802
       SERIAL_PROTOCOLPGM("Place shim under nozzle");
@@ -816,7 +816,7 @@
816 816
 
817 817
       do_blocking_move_to_z(current_position[Z_AXIS] + Z_CLEARANCE_BETWEEN_PROBES);
818 818
 
819
-      const float thickness = abs(z1 - z2);
819
+      const float thickness = ABS(z1 - z2);
820 820
 
821 821
       if (g29_verbose_level > 1) {
822 822
         SERIAL_PROTOCOLPGM("Business Card is ");
@@ -1499,10 +1499,10 @@
1499 1499
     #include "../../../libs/vector_3.h"
1500 1500
 
1501 1501
     void unified_bed_leveling::tilt_mesh_based_on_probed_grid(const bool do_3_pt_leveling) {
1502
-      constexpr int16_t x_min = max(MIN_PROBE_X, MESH_MIN_X),
1503
-                        x_max = min(MAX_PROBE_X, MESH_MAX_X),
1504
-                        y_min = max(MIN_PROBE_Y, MESH_MIN_Y),
1505
-                        y_max = min(MAX_PROBE_Y, MESH_MAX_Y);
1502
+      constexpr int16_t x_min = MAX(MIN_PROBE_X, MESH_MIN_X),
1503
+                        x_max = MIN(MAX_PROBE_X, MESH_MAX_X),
1504
+                        y_min = MAX(MIN_PROBE_Y, MESH_MIN_Y),
1505
+                        y_max = MIN(MAX_PROBE_Y, MESH_MAX_Y);
1506 1506
 
1507 1507
       bool abort_flag = false;
1508 1508
 
@@ -1770,7 +1770,7 @@
1770 1770
 
1771 1771
       SERIAL_ECHOPGM("Extrapolating mesh...");
1772 1772
 
1773
-      const float weight_scaled = weight_factor * max(MESH_X_DIST, MESH_Y_DIST);
1773
+      const float weight_scaled = weight_factor * MAX(MESH_X_DIST, MESH_Y_DIST);
1774 1774
 
1775 1775
       for (uint8_t jx = 0; jx < GRID_MAX_POINTS_X; jx++)
1776 1776
         for (uint8_t jy = 0; jy < GRID_MAX_POINTS_Y; jy++)

+ 3
- 3
Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp 파일 보기

@@ -387,11 +387,11 @@
387 387
       inverse_kinematics(raw);  // this writes delta[ABC] from raw[XYZE]
388 388
                                 // should move the feedrate scaling to scara inverse_kinematics
389 389
 
390
-      const float adiff = FABS(delta[A_AXIS] - scara_oldA),
391
-                  bdiff = FABS(delta[B_AXIS] - scara_oldB);
390
+      const float adiff = ABS(delta[A_AXIS] - scara_oldA),
391
+                  bdiff = ABS(delta[B_AXIS] - scara_oldB);
392 392
       scara_oldA = delta[A_AXIS];
393 393
       scara_oldB = delta[B_AXIS];
394
-      float s_feedrate = max(adiff, bdiff) * scara_feed_factor;
394
+      float s_feedrate = MAX(adiff, bdiff) * scara_feed_factor;
395 395
 
396 396
       planner.buffer_segment(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], in_raw[E_AXIS], s_feedrate, active_extruder);
397 397
 

+ 1
- 1
Marlin/src/feature/digipot/digipot_mcp4018.cpp 파일 보기

@@ -87,7 +87,7 @@ static void i2c_send(const uint8_t channel, const byte v) {
87 87
 
88 88
 // This is for the MCP4018 I2C based digipot
89 89
 void digipot_i2c_set_current(const uint8_t channel, const float current) {
90
-  i2c_send(channel, current_to_wiper(min(max(current, 0.0f), float(DIGIPOT_A4988_MAX_CURRENT))));
90
+  i2c_send(channel, current_to_wiper(MIN(MAX(current, 0.0f), float(DIGIPOT_A4988_MAX_CURRENT))));
91 91
 }
92 92
 
93 93
 void digipot_i2c_init() {

+ 1
- 1
Marlin/src/feature/digipot/digipot_mcp4451.cpp 파일 보기

@@ -69,7 +69,7 @@ void digipot_i2c_set_current(const uint8_t channel, const float current) {
69 69
 
70 70
   // Set actual wiper value
71 71
   byte addresses[4] = { 0x00, 0x10, 0x60, 0x70 };
72
-  i2c_send(addr, addresses[channel & 0x3], current_to_wiper(min((float) max(current, 0.0f), DIGIPOT_I2C_MAX_CURRENT)));
72
+  i2c_send(addr, addresses[channel & 0x3], current_to_wiper(MIN((float) MAX(current, 0.0f), DIGIPOT_I2C_MAX_CURRENT)));
73 73
 }
74 74
 
75 75
 void digipot_i2c_init() {

+ 3
- 3
Marlin/src/gcode/bedlevel/G26.cpp 파일 보기

@@ -305,7 +305,7 @@ void print_line_from_here_to_there(const float &sx, const float &sy, const float
305 305
 
306 306
   // If the end point of the line is closer to the nozzle, flip the direction,
307 307
   // moving from the end to the start. On very small lines the optimization isn't worth it.
308
-  if (dist_end < dist_start && (INTERSECTION_CIRCLE_RADIUS) < FABS(line_length))
308
+  if (dist_end < dist_start && (INTERSECTION_CIRCLE_RADIUS) < ABS(line_length))
309 309
     return print_line_from_here_to_there(ex, ey, ez, sx, sy, sz);
310 310
 
311 311
   // Decide whether to retract & bump
@@ -427,7 +427,7 @@ inline bool turn_on_heaters() {
427 427
         #endif
428 428
     #endif
429 429
         thermalManager.setTargetBed(g26_bed_temp);
430
-        while (abs(thermalManager.degBed() - g26_bed_temp) > 3) {
430
+        while (ABS(thermalManager.degBed() - g26_bed_temp) > 3) {
431 431
 
432 432
           #if ENABLED(NEWPANEL)
433 433
             if (is_lcd_clicked()) return exit_from_g26();
@@ -450,7 +450,7 @@ inline bool turn_on_heaters() {
450 450
 
451 451
   // Start heating the nozzle and wait for it to reach temperature.
452 452
   thermalManager.setTargetHotend(g26_hotend_temp, 0);
453
-  while (abs(thermalManager.degHotend(0) - g26_hotend_temp) > 3) {
453
+  while (ABS(thermalManager.degHotend(0) - g26_hotend_temp) > 3) {
454 454
 
455 455
     #if ENABLED(NEWPANEL)
456 456
       if (is_lcd_clicked()) return exit_from_g26();

+ 1
- 1
Marlin/src/gcode/bedlevel/abl/G29.cpp 파일 보기

@@ -471,7 +471,7 @@ void GcodeSuite::G29() {
471 471
     if (verbose_level || seenQ) {
472 472
       SERIAL_PROTOCOLPGM("Manual G29 ");
473 473
       if (g29_in_progress) {
474
-        SERIAL_PROTOCOLPAIR("point ", min(abl_probe_index + 1, abl_points));
474
+        SERIAL_PROTOCOLPAIR("point ", MIN(abl_probe_index + 1, abl_points));
475 475
         SERIAL_PROTOCOLLNPAIR(" of ", abl_points);
476 476
       }
477 477
       else

+ 1
- 1
Marlin/src/gcode/bedlevel/mbl/G29.cpp 파일 보기

@@ -205,7 +205,7 @@ void GcodeSuite::G29() {
205 205
   } // switch(state)
206 206
 
207 207
   if (state == MeshNext) {
208
-    SERIAL_PROTOCOLPAIR("MBL G29 point ", min(mbl_probe_index, GRID_MAX_POINTS));
208
+    SERIAL_PROTOCOLPAIR("MBL G29 point ", MIN(mbl_probe_index, GRID_MAX_POINTS));
209 209
     SERIAL_PROTOCOLLNPAIR(" of ", int(GRID_MAX_POINTS));
210 210
   }
211 211
 

+ 1
- 1
Marlin/src/gcode/calibrate/G28.cpp 파일 보기

@@ -64,7 +64,7 @@
64 64
     const float mlx = max_length(X_AXIS),
65 65
                 mly = max_length(Y_AXIS),
66 66
                 mlratio = mlx > mly ? mly / mlx : mlx / mly,
67
-                fr_mm_s = min(homing_feedrate(X_AXIS), homing_feedrate(Y_AXIS)) * SQRT(sq(mlratio) + 1.0);
67
+                fr_mm_s = MIN(homing_feedrate(X_AXIS), homing_feedrate(Y_AXIS)) * SQRT(sq(mlratio) + 1.0);
68 68
 
69 69
     #if ENABLED(SENSORLESS_HOMING)
70 70
       sensorless_homing_per_axis(X_AXIS);

+ 1
- 1
Marlin/src/gcode/calibrate/M48.cpp 파일 보기

@@ -129,7 +129,7 @@ void GcodeSuite::M48() {
129 129
             (int) (0.1250000000 * (DELTA_PRINTABLE_RADIUS)),
130 130
             (int) (0.3333333333 * (DELTA_PRINTABLE_RADIUS))
131 131
           #else
132
-            (int) 5.0, (int) (0.125 * min(X_BED_SIZE, Y_BED_SIZE))
132
+            (int) 5.0, (int) (0.125 * MIN(X_BED_SIZE, Y_BED_SIZE))
133 133
           #endif
134 134
         );
135 135
 

+ 1
- 1
Marlin/src/gcode/control/M605.cpp 파일 보기

@@ -50,7 +50,7 @@
50 50
       case DXC_AUTO_PARK_MODE:
51 51
         break;
52 52
       case DXC_DUPLICATION_MODE:
53
-        if (parser.seen('X')) duplicate_extruder_x_offset = max(parser.value_linear_units(), X2_MIN_POS - x_home_pos(0));
53
+        if (parser.seen('X')) duplicate_extruder_x_offset = MAX(parser.value_linear_units(), X2_MIN_POS - x_home_pos(0));
54 54
         if (parser.seen('R')) duplicate_extruder_temp_offset = parser.value_celsius_diff();
55 55
         SERIAL_ECHO_START();
56 56
         SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);

+ 1
- 1
Marlin/src/gcode/feature/pause/M125.cpp 파일 보기

@@ -50,7 +50,7 @@
50 50
  */
51 51
 void GcodeSuite::M125() {
52 52
   // Initial retract before move to filament change position
53
-  const float retract = -FABS(parser.seen('L') ? parser.value_axis_units(E_AXIS) : 0
53
+  const float retract = -ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS) : 0
54 54
     #ifdef PAUSE_PARK_RETRACT_LENGTH
55 55
       + (PAUSE_PARK_RETRACT_LENGTH)
56 56
     #endif

+ 3
- 3
Marlin/src/gcode/feature/pause/M600.cpp 파일 보기

@@ -74,7 +74,7 @@ void GcodeSuite::M600() {
74 74
   #endif
75 75
 
76 76
   // Initial retract before move to filament change position
77
-  const float retract = -FABS(parser.seen('E') ? parser.value_axis_units(E_AXIS) : 0
77
+  const float retract = -ABS(parser.seen('E') ? parser.value_axis_units(E_AXIS) : 0
78 78
     #ifdef PAUSE_PARK_RETRACT_LENGTH
79 79
       + (PAUSE_PARK_RETRACT_LENGTH)
80 80
     #endif
@@ -93,14 +93,14 @@ void GcodeSuite::M600() {
93 93
   #endif
94 94
 
95 95
   // Unload filament
96
-  const float unload_length = -FABS(parser.seen('U') ? parser.value_axis_units(E_AXIS)
96
+  const float unload_length = -ABS(parser.seen('U') ? parser.value_axis_units(E_AXIS)
97 97
                                                      : filament_change_unload_length[active_extruder]);
98 98
 
99 99
   // Slow load filament
100 100
   constexpr float slow_load_length = FILAMENT_CHANGE_SLOW_LOAD_LENGTH;
101 101
 
102 102
   // Fast load filament
103
-  const float fast_load_length = FABS(parser.seen('L') ? parser.value_axis_units(E_AXIS)
103
+  const float fast_load_length = ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS)
104 104
                                                        : filament_change_load_length[active_extruder]);
105 105
 
106 106
   const int beep_count = parser.intval('B',

+ 2
- 2
Marlin/src/gcode/feature/pause/M603.cpp 파일 보기

@@ -47,7 +47,7 @@ void GcodeSuite::M603() {
47 47
 
48 48
   // Unload length
49 49
   if (parser.seen('U')) {
50
-    filament_change_unload_length[target_extruder] = FABS(parser.value_axis_units(E_AXIS));
50
+    filament_change_unload_length[target_extruder] = ABS(parser.value_axis_units(E_AXIS));
51 51
     #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
52 52
       NOMORE(filament_change_unload_length[target_extruder], EXTRUDE_MAXLENGTH);
53 53
     #endif
@@ -55,7 +55,7 @@ void GcodeSuite::M603() {
55 55
 
56 56
   // Load length
57 57
   if (parser.seen('L')) {
58
-    filament_change_load_length[target_extruder] = FABS(parser.value_axis_units(E_AXIS));
58
+    filament_change_load_length[target_extruder] = ABS(parser.value_axis_units(E_AXIS));
59 59
     #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
60 60
       NOMORE(filament_change_load_length[target_extruder], EXTRUDE_MAXLENGTH);
61 61
     #endif

+ 6
- 6
Marlin/src/gcode/feature/pause/M701_M702.cpp 파일 보기

@@ -74,18 +74,18 @@ void GcodeSuite::M701() {
74 74
 
75 75
   // Lift Z axis
76 76
   if (park_point.z > 0)
77
-    do_blocking_move_to_z(min(current_position[Z_AXIS] + park_point.z, Z_MAX_POS), NOZZLE_PARK_Z_FEEDRATE);
77
+    do_blocking_move_to_z(MIN(current_position[Z_AXIS] + park_point.z, Z_MAX_POS), NOZZLE_PARK_Z_FEEDRATE);
78 78
 
79 79
   // Load filament
80 80
   constexpr float slow_load_length = FILAMENT_CHANGE_SLOW_LOAD_LENGTH;
81
-  const float fast_load_length = FABS(parser.seen('L') ? parser.value_axis_units(E_AXIS)
81
+  const float fast_load_length = ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS)
82 82
                                                        : filament_change_load_length[active_extruder]);
83 83
   load_filament(slow_load_length, fast_load_length, ADVANCED_PAUSE_PURGE_LENGTH, FILAMENT_CHANGE_ALERT_BEEPS,
84 84
                 true, thermalManager.wait_for_heating(target_extruder), ADVANCED_PAUSE_MODE_LOAD_FILAMENT);
85 85
 
86 86
   // Restore Z axis
87 87
   if (park_point.z > 0)
88
-    do_blocking_move_to_z(max(current_position[Z_AXIS] - park_point.z, 0), NOZZLE_PARK_Z_FEEDRATE);
88
+    do_blocking_move_to_z(MAX(current_position[Z_AXIS] - park_point.z, 0), NOZZLE_PARK_Z_FEEDRATE);
89 89
 
90 90
   #if EXTRUDERS > 1
91 91
     // Restore toolhead if it was changed
@@ -136,7 +136,7 @@ void GcodeSuite::M702() {
136 136
 
137 137
   // Lift Z axis
138 138
   if (park_point.z > 0)
139
-    do_blocking_move_to_z(min(current_position[Z_AXIS] + park_point.z, Z_MAX_POS), NOZZLE_PARK_Z_FEEDRATE);
139
+    do_blocking_move_to_z(MIN(current_position[Z_AXIS] + park_point.z, Z_MAX_POS), NOZZLE_PARK_Z_FEEDRATE);
140 140
 
141 141
   // Unload filament
142 142
   #if EXTRUDERS > 1 && ENABLED(FILAMENT_UNLOAD_ALL_EXTRUDERS)
@@ -150,7 +150,7 @@ void GcodeSuite::M702() {
150 150
   #endif
151 151
   {
152 152
     // Unload length
153
-    const float unload_length = -FABS(parser.seen('U') ? parser.value_axis_units(E_AXIS) :
153
+    const float unload_length = -ABS(parser.seen('U') ? parser.value_axis_units(E_AXIS) :
154 154
                                                         filament_change_unload_length[target_extruder]);
155 155
 
156 156
     unload_filament(unload_length, true, ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT);
@@ -158,7 +158,7 @@ void GcodeSuite::M702() {
158 158
 
159 159
   // Restore Z axis
160 160
   if (park_point.z > 0)
161
-    do_blocking_move_to_z(max(current_position[Z_AXIS] - park_point.z, 0), NOZZLE_PARK_Z_FEEDRATE);
161
+    do_blocking_move_to_z(MAX(current_position[Z_AXIS] - park_point.z, 0), NOZZLE_PARK_Z_FEEDRATE);
162 162
 
163 163
   #if EXTRUDERS > 1
164 164
     // Restore toolhead if it was changed

+ 1
- 1
Marlin/src/gcode/motion/G0_G1.cpp 파일 보기

@@ -61,7 +61,7 @@ void GcodeSuite::G0_G1(
61 61
         if (fwretract.autoretract_enabled && parser.seen('E') && !(parser.seen('X') || parser.seen('Y') || parser.seen('Z'))) {
62 62
           const float echange = destination[E_AXIS] - current_position[E_AXIS];
63 63
           // Is this a retract or recover move?
64
-          if (WITHIN(FABS(echange), MIN_AUTORETRACT, MAX_AUTORETRACT) && fwretract.retracted[active_extruder] == (echange > 0.0)) {
64
+          if (WITHIN(ABS(echange), MIN_AUTORETRACT, MAX_AUTORETRACT) && fwretract.retracted[active_extruder] == (echange > 0.0)) {
65 65
             current_position[E_AXIS] = destination[E_AXIS]; // Hide a G1-based retract/recover from calculations
66 66
             sync_plan_position_e();                         // AND from the planner
67 67
             return fwretract.retract(echange < 0.0);        // Firmware-based retract/recover (double-retract ignored)

+ 1
- 1
Marlin/src/gcode/motion/G2_G3.cpp 파일 보기

@@ -91,7 +91,7 @@ void plan_arc(
91 91
     angular_travel = RADIANS(360);
92 92
 
93 93
   const float flat_mm = radius * angular_travel,
94
-              mm_of_travel = linear_travel ? HYPOT(flat_mm, linear_travel) : FABS(flat_mm);
94
+              mm_of_travel = linear_travel ? HYPOT(flat_mm, linear_travel) : ABS(flat_mm);
95 95
   if (mm_of_travel < 0.001) return;
96 96
 
97 97
   uint16_t segments = FLOOR(mm_of_travel / (MM_PER_ARC_SEGMENT));

+ 3
- 3
Marlin/src/gcode/probe/G38.cpp 파일 보기

@@ -39,8 +39,8 @@ static bool G38_run_probe() {
39 39
     // Get direction of move and retract
40 40
     float retract_mm[XYZ];
41 41
     LOOP_XYZ(i) {
42
-      float dist = destination[i] - current_position[i];
43
-      retract_mm[i] = FABS(dist) < G38_MINIMUM_MOVE ? 0 : home_bump_mm((AxisEnum)i) * (dist > 0 ? -1 : 1);
42
+      const float dist = destination[i] - current_position[i];
43
+      retract_mm[i] = ABS(dist) < G38_MINIMUM_MOVE ? 0 : home_bump_mm((AxisEnum)i) * (dist > 0 ? -1 : 1);
44 44
     }
45 45
   #endif
46 46
 
@@ -105,7 +105,7 @@ void GcodeSuite::G38(const bool is_38_2) {
105 105
 
106 106
   // If any axis has enough movement, do the move
107 107
   LOOP_XYZ(i)
108
-    if (FABS(destination[i] - current_position[i]) >= G38_MINIMUM_MOVE) {
108
+    if (ABS(destination[i] - current_position[i]) >= G38_MINIMUM_MOVE) {
109 109
       if (!parser.seenval('F')) feedrate_mm_s = homing_feedrate((AxisEnum)i);
110 110
       // If G38.2 fails throw an error
111 111
       if (!G38_run_probe() && is_38_2) {

+ 1
- 1
Marlin/src/gcode/temperature/M104_M109.cpp 파일 보기

@@ -216,7 +216,7 @@ void GcodeSuite::M109() {
216 216
 
217 217
     #if TEMP_RESIDENCY_TIME > 0
218 218
 
219
-      const float temp_diff = FABS(target_temp - temp);
219
+      const float temp_diff = ABS(target_temp - temp);
220 220
 
221 221
       if (!residency_start_ms) {
222 222
         // Start the TEMP_RESIDENCY_TIME timer when we reach target temp for the first time.

+ 2
- 2
Marlin/src/gcode/temperature/M106_M107.cpp 파일 보기

@@ -55,14 +55,14 @@ void GcodeSuite::M106() {
55 55
             fanSpeeds[p] = new_fanSpeeds[p];
56 56
             break;
57 57
           default:
58
-            new_fanSpeeds[p] = min(t, 255);
58
+            new_fanSpeeds[p] = MIN(t, 255);
59 59
             break;
60 60
         }
61 61
         return;
62 62
       }
63 63
     #endif // EXTRA_FAN_SPEED
64 64
     const uint16_t s = parser.ushortval('S', 255);
65
-    fanSpeeds[p] = min(s, 255);
65
+    fanSpeeds[p] = MIN(s, 255U);
66 66
   }
67 67
 }
68 68
 

+ 1
- 1
Marlin/src/gcode/temperature/M140_M190.cpp 파일 보기

@@ -145,7 +145,7 @@ void GcodeSuite::M190() {
145 145
 
146 146
     #if TEMP_BED_RESIDENCY_TIME > 0
147 147
 
148
-      const float temp_diff = FABS(target_temp - temp);
148
+      const float temp_diff = ABS(target_temp - temp);
149 149
 
150 150
       if (!residency_start_ms) {
151 151
         // Start the TEMP_BED_RESIDENCY_TIME timer when we reach target temp for the first time.

+ 10
- 11
Marlin/src/inc/Conditionals_post.h 파일 보기

@@ -35,6 +35,16 @@
35 35
   || MB(SCOOVO_X9H)                     \
36 36
 )
37 37
 
38
+#ifdef TEENSYDUINO
39
+  #undef max
40
+  #define max(a,b) ((a)>(b)?(a):(b))
41
+  #undef min
42
+  #define min(a,b) ((a)<(b)?(a):(b))
43
+
44
+  #undef NOT_A_PIN    // Override Teensyduino legacy CapSense define work-around
45
+  #define NOT_A_PIN 0 // For PINS_DEBUGGING
46
+#endif
47
+
38 48
 #define IS_SCARA (ENABLED(MORGAN_SCARA) || ENABLED(MAKERARM_SCARA))
39 49
 #define IS_KINEMATIC (ENABLED(DELTA) || IS_SCARA)
40 50
 #define IS_CARTESIAN !IS_KINEMATIC
@@ -1374,7 +1384,6 @@
1374 1384
   #undef LROUND
1375 1385
   #undef FMOD
1376 1386
   #define ATAN2(y, x) atan2f(y, x)
1377
-  #define FABS(x) fabsf(x)
1378 1387
   #define POW(x, y) powf(x, y)
1379 1388
   #define SQRT(x) sqrtf(x)
1380 1389
   #define CEIL(x) ceilf(x)
@@ -1383,16 +1392,6 @@
1383 1392
   #define FMOD(x, y) fmodf(x, y)
1384 1393
 #endif
1385 1394
 
1386
-#ifdef TEENSYDUINO
1387
-  #undef max
1388
-  #define max(a,b) ((a)>(b)?(a):(b))
1389
-  #undef min
1390
-  #define min(a,b) ((a)<(b)?(a):(b))
1391
-
1392
-  #undef NOT_A_PIN    // Override Teensyduino legacy CapSense define work-around
1393
-  #define NOT_A_PIN 0 // For PINS_DEBUGGING
1394
-#endif
1395
-
1396 1395
 // Number of VFAT entries used. Each entry has 13 UTF-16 characters
1397 1396
 #if ENABLED(SCROLL_LONG_FILENAMES)
1398 1397
   #define MAX_VFAT_ENTRIES (5)

+ 2
- 2
Marlin/src/lcd/malyanlcd.cpp 파일 보기

@@ -75,7 +75,7 @@ int inbound_count;
75 75
 // Everything written needs the high bit set.
76 76
 void write_to_lcd_P(const char * const message) {
77 77
   char encoded_message[MAX_CURLY_COMMAND];
78
-  uint8_t message_length = min(strlen_P(message), sizeof(encoded_message));
78
+  uint8_t message_length = MIN(strlen_P(message), sizeof(encoded_message));
79 79
 
80 80
   for (uint8_t i = 0; i < message_length; i++)
81 81
     encoded_message[i] = pgm_read_byte(&message[i]) | 0x80;
@@ -85,7 +85,7 @@ void write_to_lcd_P(const char * const message) {
85 85
 
86 86
 void write_to_lcd(const char * const message) {
87 87
   char encoded_message[MAX_CURLY_COMMAND];
88
-  const uint8_t message_length = min(strlen(message), sizeof(encoded_message));
88
+  const uint8_t message_length = MIN(strlen(message), sizeof(encoded_message));
89 89
 
90 90
   for (uint8_t i = 0; i < message_length; i++)
91 91
     encoded_message[i] = message[i] | 0x80;

+ 9
- 9
Marlin/src/lcd/ultralcd.cpp 파일 보기

@@ -629,7 +629,7 @@ uint16_t max_display_update_time = 0;
629 629
       screen_changed = false;
630 630
     }
631 631
     if (screen_items > 0 && encoderLine >= screen_items - limit) {
632
-      encoderLine = max(0, screen_items - limit);
632
+      encoderLine = MAX(0, screen_items - limit);
633 633
       encoderPosition = encoderLine * (ENCODER_STEPS_PER_MENU_ITEM);
634 634
     }
635 635
     if (is_menu) {
@@ -1579,7 +1579,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
1579 1579
    *
1580 1580
    */
1581 1581
   void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb, const int16_t fan) {
1582
-    if (temph > 0) thermalManager.setTargetHotend(min(heater_maxtemp[endnum], temph), endnum);
1582
+    if (temph > 0) thermalManager.setTargetHotend(MIN(heater_maxtemp[endnum], temph), endnum);
1583 1583
     #if HAS_HEATED_BED
1584 1584
       if (tempb >= 0) thermalManager.setTargetBed(tempb);
1585 1585
     #else
@@ -2118,7 +2118,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
2118 2118
       char UBL_LCD_GCODE[16];
2119 2119
       const int ind = ubl_height_amount > 0 ? 9 : 10;
2120 2120
       strcpy_P(UBL_LCD_GCODE, PSTR("G29 P6 C -"));
2121
-      sprintf_P(&UBL_LCD_GCODE[ind], PSTR(".%i"), abs(ubl_height_amount));
2121
+      sprintf_P(&UBL_LCD_GCODE[ind], PSTR(".%i"), ABS(ubl_height_amount));
2122 2122
       lcd_enqueue_command(UBL_LCD_GCODE);
2123 2123
     }
2124 2124
 
@@ -2441,7 +2441,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
2441 2441
       if (encoderPosition) {
2442 2442
         step_scaler += (int32_t)encoderPosition;
2443 2443
         x_plot += step_scaler / (ENCODER_STEPS_PER_MENU_ITEM);
2444
-        if (abs(step_scaler) >= ENCODER_STEPS_PER_MENU_ITEM) step_scaler = 0;
2444
+        if (ABS(step_scaler) >= ENCODER_STEPS_PER_MENU_ITEM) step_scaler = 0;
2445 2445
         encoderPosition = 0;
2446 2446
         lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
2447 2447
       }
@@ -2853,7 +2853,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
2853 2853
       do_blocking_move_to_xy(rx, ry);
2854 2854
 
2855 2855
       lcd_synchronize();
2856
-      move_menu_scale = max(PROBE_MANUALLY_STEP, MIN_STEPS_PER_SEGMENT / float(DEFAULT_XYZ_STEPS_PER_UNIT));
2856
+      move_menu_scale = MAX(PROBE_MANUALLY_STEP, MIN_STEPS_PER_SEGMENT / float(DEFAULT_XYZ_STEPS_PER_UNIT));
2857 2857
       lcd_goto_screen(lcd_move_z);
2858 2858
     }
2859 2859
 
@@ -3625,8 +3625,8 @@ void lcd_quick_feedback(const bool clear_buttons) {
3625 3625
         #define MINTEMP_ALL MIN3(HEATER_0_MINTEMP, HEATER_1_MINTEMP, HEATER_2_MINTEMP)
3626 3626
         #define MAXTEMP_ALL MAX3(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP)
3627 3627
       #elif HOTENDS > 1
3628
-        #define MINTEMP_ALL min(HEATER_0_MINTEMP, HEATER_1_MINTEMP)
3629
-        #define MAXTEMP_ALL max(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP)
3628
+        #define MINTEMP_ALL MIN(HEATER_0_MINTEMP, HEATER_1_MINTEMP)
3629
+        #define MAXTEMP_ALL MAX(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP)
3630 3630
       #else
3631 3631
         #define MINTEMP_ALL HEATER_0_MINTEMP
3632 3632
         #define MAXTEMP_ALL HEATER_0_MAXTEMP
@@ -5229,7 +5229,7 @@ void lcd_update() {
5229 5229
 
5230 5230
       #endif
5231 5231
 
5232
-      const bool encoderPastThreshold = (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP);
5232
+      const bool encoderPastThreshold = (ABS(encoderDiff) >= ENCODER_PULSES_PER_STEP);
5233 5233
       if (encoderPastThreshold || lcd_clicked) {
5234 5234
         if (encoderPastThreshold) {
5235 5235
           int32_t encoderMultiplier = 1;
@@ -5237,7 +5237,7 @@ void lcd_update() {
5237 5237
           #if ENABLED(ENCODER_RATE_MULTIPLIER)
5238 5238
 
5239 5239
             if (encoderRateMultiplierEnabled) {
5240
-              int32_t encoderMovementSteps = abs(encoderDiff) / ENCODER_PULSES_PER_STEP;
5240
+              int32_t encoderMovementSteps = ABS(encoderDiff) / ENCODER_PULSES_PER_STEP;
5241 5241
 
5242 5242
               if (lastEncoderMovementMillis) {
5243 5243
                 // Note that the rate is always calculated between two passes through the

+ 1
- 1
Marlin/src/lcd/ultralcd_impl_DOGM.h 파일 보기

@@ -534,7 +534,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
534 534
               name_hash = ((name_hash << 1) | (name_hash >> 7)) ^ filename[l];  // rotate, xor
535 535
             if (filename_scroll_hash != name_hash) {                            // If the hash changed...
536 536
               filename_scroll_hash = name_hash;                                 // Save the new hash
537
-              filename_scroll_max = max(0, utf8_strlen(longFilename) - maxlen); // Update the scroll limit
537
+              filename_scroll_max = MAX(0, utf8_strlen(longFilename) - maxlen); // Update the scroll limit
538 538
               filename_scroll_pos = 0;                                          // Reset scroll to the start
539 539
               lcd_status_update_delay = 8;                                      // Don't scroll right away
540 540
             }

+ 5
- 5
Marlin/src/lcd/ultralcd_impl_HD44780.h 파일 보기

@@ -352,12 +352,12 @@ void lcd_implementation_clear() { lcd.clear(); }
352 352
       lcd_put_u8str(text);
353 353
     #else
354 354
       char tmp[LCD_WIDTH + 1] = {0};
355
-      int16_t n = max(utf8_strlen_P(text) - len, 0);
355
+      int16_t n = MAX(utf8_strlen_P(text) - len, 0);
356 356
       for (int16_t i = 0; i <= n; i++) {
357
-        utf8_strncpy_p(tmp, text + i, min(len, LCD_WIDTH));
357
+        utf8_strncpy_p(tmp, text + i, MIN(len, LCD_WIDTH));
358 358
         lcd_moveto(col, line);
359 359
         lcd_put_u8str(tmp);
360
-        delay(time / max(n, 1));
360
+        delay(time / MAX(n, 1));
361 361
       }
362 362
     #endif
363 363
   }
@@ -875,7 +875,7 @@ static void lcd_implementation_status_screen() {
875 875
               name_hash = ((name_hash << 1) | (name_hash >> 7)) ^ filename[l];  // rotate, xor
876 876
             if (filename_scroll_hash != name_hash) {                            // If the hash changed...
877 877
               filename_scroll_hash = name_hash;                                 // Save the new hash
878
-              filename_scroll_max = max(0, utf8_strlen(longFilename) - n);  // Update the scroll limit
878
+              filename_scroll_max = MAX(0, utf8_strlen(longFilename) - n);  // Update the scroll limit
879 879
               filename_scroll_pos = 0;                                          // Reset scroll to the start
880 880
               lcd_status_update_delay = 8;                                      // Don't scroll right away
881 881
             }
@@ -1186,7 +1186,7 @@ static void lcd_implementation_status_screen() {
1186 1186
         //dump_custom_char("at entry:", &new_char);
1187 1187
 
1188 1188
         clear_custom_char(&new_char);
1189
-        const uint8_t ypix = min(upper_left.y_pixel_offset + pixels_per_y_mesh_pnt, ULTRA_Y_PIXELS_PER_CHAR);
1189
+        const uint8_t ypix = MIN(upper_left.y_pixel_offset + pixels_per_y_mesh_pnt, ULTRA_Y_PIXELS_PER_CHAR);
1190 1190
         for (j = upper_left.y_pixel_offset; j < ypix; j++) {
1191 1191
           i = upper_left.x_pixel_mask;
1192 1192
           for (k = 0; k < pixels_per_x_mesh_pnt; k++) {

+ 1
- 1
Marlin/src/libs/least_squares_fit.cpp 파일 보기

@@ -58,7 +58,7 @@ int finish_incremental_LSF(struct linear_fit_data *lsf) {
58 58
   lsf->xzbar = lsf->xzbar / N - lsf->xbar * lsf->zbar;
59 59
   const float DD = lsf->x2bar * lsf->y2bar - sq(lsf->xybar);
60 60
 
61
-  if (FABS(DD) <= 1e-10 * (lsf->max_absx + lsf->max_absy))
61
+  if (ABS(DD) <= 1e-10 * (lsf->max_absx + lsf->max_absy))
62 62
     return 1;
63 63
 
64 64
   lsf->A = (lsf->yzbar * lsf->xybar - lsf->xzbar * lsf->y2bar) / DD;

+ 4
- 4
Marlin/src/libs/least_squares_fit.h 파일 보기

@@ -63,8 +63,8 @@ void inline incremental_WLSF(struct linear_fit_data *lsf, const float &x, const
63 63
   lsf->xzbar += w * x * z;
64 64
   lsf->yzbar += w * y * z;
65 65
   lsf->N     += w;
66
-  lsf->max_absx = max(FABS(w * x), lsf->max_absx);
67
-  lsf->max_absy = max(FABS(w * y), lsf->max_absy);
66
+  lsf->max_absx = MAX(ABS(w * x), lsf->max_absx);
67
+  lsf->max_absy = MAX(ABS(w * y), lsf->max_absy);
68 68
 }
69 69
 
70 70
 void inline incremental_LSF(struct linear_fit_data *lsf, const float &x, const float &y, const float &z) {
@@ -77,8 +77,8 @@ void inline incremental_LSF(struct linear_fit_data *lsf, const float &x, const f
77 77
   lsf->xybar += x * y;
78 78
   lsf->xzbar += x * z;
79 79
   lsf->yzbar += y * z;
80
-  lsf->max_absx = max(FABS(x), lsf->max_absx);
81
-  lsf->max_absy = max(FABS(y), lsf->max_absy);
80
+  lsf->max_absx = MAX(ABS(x), lsf->max_absx);
81
+  lsf->max_absy = MAX(ABS(y), lsf->max_absy);
82 82
   lsf->N += 1.0;
83 83
 }
84 84
 

+ 3
- 3
Marlin/src/libs/nozzle.cpp 파일 보기

@@ -79,7 +79,7 @@
79 79
     do_blocking_move_to(start.x, start.y, start.z);
80 80
 
81 81
     const uint8_t zigs = objects << 1;
82
-    const bool horiz = FABS(diffx) >= FABS(diffy);    // Do a horizontal wipe?
82
+    const bool horiz = ABS(diffx) >= ABS(diffy);    // Do a horizontal wipe?
83 83
     const float P = (horiz ? diffx : diffy) / zigs;   // Period of each zig / zag
84 84
     const point_t *side;
85 85
     for (uint8_t j = 0; j < strokes; j++) {
@@ -172,11 +172,11 @@
172 172
         break;
173 173
 
174 174
       case 2: // Raise by Z-park height
175
-        do_blocking_move_to_z(min(current_position[Z_AXIS] + park.z, Z_MAX_POS), fr_z);
175
+        do_blocking_move_to_z(MIN(current_position[Z_AXIS] + park.z, Z_MAX_POS), fr_z);
176 176
         break;
177 177
 
178 178
       default: // Raise to at least the Z-park height
179
-        do_blocking_move_to_z(max(park.z, current_position[Z_AXIS]), fr_z);
179
+        do_blocking_move_to_z(MAX(park.z, current_position[Z_AXIS]), fr_z);
180 180
     }
181 181
 
182 182
     do_blocking_move_to_xy(park.x, park.y, fr_xy);

+ 1
- 1
Marlin/src/module/delta.cpp 파일 보기

@@ -150,7 +150,7 @@ float delta_safe_distance_from_top() {
150 150
   float centered_extent = delta[A_AXIS];
151 151
   cartesian[Y_AXIS] = DELTA_PRINTABLE_RADIUS;
152 152
   inverse_kinematics(cartesian);
153
-  return FABS(centered_extent - delta[A_AXIS]);
153
+  return ABS(centered_extent - delta[A_AXIS]);
154 154
 }
155 155
 
156 156
 /**

+ 11
- 10
Marlin/src/module/motion.cpp 파일 보기

@@ -552,7 +552,7 @@ float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS },
552 552
     float cartesian_mm = SQRT(sq(xdiff) + sq(ydiff) + sq(zdiff));
553 553
 
554 554
     // If the move is very short, check the E move distance
555
-    if (UNEAR_ZERO(cartesian_mm)) cartesian_mm = FABS(ediff);
555
+    if (UNEAR_ZERO(cartesian_mm)) cartesian_mm = ABS(ediff);
556 556
 
557 557
     // No E move either? Game over.
558 558
     if (UNEAR_ZERO(cartesian_mm)) return true;
@@ -665,6 +665,7 @@ float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS },
665 665
       const float diff2 = HYPOT2(delta[A_AXIS] - oldA, delta[B_AXIS] - oldB);
666 666
       if (diff2) {
667 667
         planner.buffer_segment(delta[A_AXIS], delta[B_AXIS], rtarget[Z_AXIS], rtarget[E_AXIS], SQRT(diff2) * inverse_secs, active_extruder);
668
+
668 669
         /*
669 670
         SERIAL_ECHOPAIR("final: A=", delta[A_AXIS]); SERIAL_ECHOPAIR(" B=", delta[B_AXIS]);
670 671
         SERIAL_ECHOPAIR(" adiff=", delta[A_AXIS] - oldA); SERIAL_ECHOPAIR(" bdiff=", delta[B_AXIS] - oldB);
@@ -710,7 +711,7 @@ float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS },
710 711
       // If the move is very short, check the E move distance
711 712
       // No E move either? Game over.
712 713
       float cartesian_mm = SQRT(sq(xdiff) + sq(ydiff) + sq(zdiff));
713
-      if (UNEAR_ZERO(cartesian_mm)) cartesian_mm = FABS(ediff);
714
+      if (UNEAR_ZERO(cartesian_mm)) cartesian_mm = ABS(ediff);
714 715
       if (UNEAR_ZERO(cartesian_mm)) return;
715 716
 
716 717
       // The length divided by the segment size
@@ -921,7 +922,7 @@ void prepare_move_to_destination() {
921 922
           }
922 923
         #endif // PREVENT_COLD_EXTRUSION
923 924
         #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
924
-          if (FABS(destination[E_AXIS] - current_position[E_AXIS]) * planner.e_factor[active_extruder] > (EXTRUDE_MAXLENGTH)) {
925
+          if (ABS(destination[E_AXIS] - current_position[E_AXIS]) * planner.e_factor[active_extruder] > (EXTRUDE_MAXLENGTH)) {
925 926
             current_position[E_AXIS] = destination[E_AXIS]; // Behave as if the move really took place, but ignore E part
926 927
             SERIAL_ECHO_START();
927 928
             SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP);
@@ -1289,7 +1290,7 @@ void homeaxis(const AxisEnum axis) {
1289 1290
   // When homing Z with probe respect probe clearance
1290 1291
   const float bump = axis_home_dir * (
1291 1292
     #if HOMING_Z_WITH_PROBE
1292
-      (axis == Z_AXIS && (Z_HOME_BUMP_MM)) ? max(Z_CLEARANCE_BETWEEN_PROBES, Z_HOME_BUMP_MM) :
1293
+      (axis == Z_AXIS && (Z_HOME_BUMP_MM)) ? MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_HOME_BUMP_MM) :
1293 1294
     #endif
1294 1295
     home_bump_mm(axis)
1295 1296
   );
@@ -1318,7 +1319,7 @@ void homeaxis(const AxisEnum axis) {
1318 1319
     #if ENABLED(X_DUAL_ENDSTOPS)
1319 1320
       if (axis == X_AXIS) {
1320 1321
         const bool lock_x1 = pos_dir ? (endstops.x_endstop_adj > 0) : (endstops.x_endstop_adj < 0);
1321
-        float adj = FABS(endstops.x_endstop_adj);
1322
+        float adj = ABS(endstops.x_endstop_adj);
1322 1323
         if (pos_dir) adj = -adj;
1323 1324
         if (lock_x1) stepper.set_x_lock(true); else stepper.set_x2_lock(true);
1324 1325
         do_homing_move(axis, adj);
@@ -1329,7 +1330,7 @@ void homeaxis(const AxisEnum axis) {
1329 1330
     #if ENABLED(Y_DUAL_ENDSTOPS)
1330 1331
       if (axis == Y_AXIS) {
1331 1332
         const bool lock_y1 = pos_dir ? (endstops.y_endstop_adj > 0) : (endstops.y_endstop_adj < 0);
1332
-        float adj = FABS(endstops.y_endstop_adj);
1333
+        float adj = ABS(endstops.y_endstop_adj);
1333 1334
         if (pos_dir) adj = -adj;
1334 1335
         if (lock_y1) stepper.set_y_lock(true); else stepper.set_y2_lock(true);
1335 1336
         do_homing_move(axis, adj);
@@ -1340,7 +1341,7 @@ void homeaxis(const AxisEnum axis) {
1340 1341
     #if ENABLED(Z_DUAL_ENDSTOPS)
1341 1342
       if (axis == Z_AXIS) {
1342 1343
         const bool lock_z1 = pos_dir ? (endstops.z_endstop_adj > 0) : (endstops.z_endstop_adj < 0);
1343
-        float adj = FABS(endstops.z_endstop_adj);
1344
+        float adj = ABS(endstops.z_endstop_adj);
1344 1345
         if (pos_dir) adj = -adj;
1345 1346
         if (lock_z1) stepper.set_z_lock(true); else stepper.set_z2_lock(true);
1346 1347
         do_homing_move(axis, adj);
@@ -1424,7 +1425,7 @@ void homeaxis(const AxisEnum axis) {
1424 1425
       if (axis == X_AXIS) {
1425 1426
 
1426 1427
         // In Dual X mode hotend_offset[X] is T1's home position
1427
-        float dual_max_x = max(hotend_offset[X_AXIS][1], X2_MAX_POS);
1428
+        float dual_max_x = MAX(hotend_offset[X_AXIS][1], X2_MAX_POS);
1428 1429
 
1429 1430
         if (active_extruder != 0) {
1430 1431
           // T1 can move from X2_MIN_POS to X2_MAX_POS or X2 home position (whichever is larger)
@@ -1435,7 +1436,7 @@ void homeaxis(const AxisEnum axis) {
1435 1436
           // In Duplication Mode, T0 can move as far left as X_MIN_POS
1436 1437
           // but not so far to the right that T1 would move past the end
1437 1438
           soft_endstop_min[X_AXIS] = base_min_pos(X_AXIS);
1438
-          soft_endstop_max[X_AXIS] = min(base_max_pos(X_AXIS), dual_max_x - duplicate_extruder_x_offset);
1439
+          soft_endstop_max[X_AXIS] = MIN(base_max_pos(X_AXIS), dual_max_x - duplicate_extruder_x_offset);
1439 1440
         }
1440 1441
         else {
1441 1442
           // In other modes, T0 can move from X_MIN_POS to X_MAX_POS
@@ -1471,7 +1472,7 @@ void homeaxis(const AxisEnum axis) {
1471 1472
           case X_AXIS:
1472 1473
           case Y_AXIS:
1473 1474
             // Get a minimum radius for clamping
1474
-            soft_endstop_radius = MIN3(FABS(max(soft_endstop_min[X_AXIS], soft_endstop_min[Y_AXIS])), soft_endstop_max[X_AXIS], soft_endstop_max[Y_AXIS]);
1475
+            soft_endstop_radius = MIN3(ABS(MAX(soft_endstop_min[X_AXIS], soft_endstop_min[Y_AXIS])), soft_endstop_max[X_AXIS], soft_endstop_max[Y_AXIS]);
1475 1476
             soft_endstop_radius_2 = sq(soft_endstop_radius);
1476 1477
             break;
1477 1478
         #endif

+ 1
- 1
Marlin/src/module/motion.h 파일 보기

@@ -260,7 +260,7 @@ void homeaxis(const AxisEnum axis);
260 260
     // Note: This won't work on SCARA since the probe offset rotates with the arm.
261 261
     inline bool position_is_reachable_by_probe(const float &rx, const float &ry) {
262 262
       return position_is_reachable(rx - (X_PROBE_OFFSET_FROM_EXTRUDER), ry - (Y_PROBE_OFFSET_FROM_EXTRUDER))
263
-             && position_is_reachable(rx, ry, FABS(MIN_PROBE_EDGE));
263
+             && position_is_reachable(rx, ry, ABS(MIN_PROBE_EDGE));
264 264
     }
265 265
   #endif
266 266
 

+ 29
- 29
Marlin/src/module/planner.cpp 파일 보기

@@ -833,7 +833,7 @@ void Planner::reverse_pass_kernel(block_t* const current, const block_t* const n
833 833
       // for max allowable speed if block is decelerating and nominal length is false.
834 834
       const float new_entry_speed = (TEST(current->flag, BLOCK_BIT_NOMINAL_LENGTH) || max_entry_speed <= next->entry_speed)
835 835
         ? max_entry_speed
836
-        : min(max_entry_speed, max_allowable_speed(-current->acceleration, next->entry_speed, current->millimeters));
836
+        : MIN(max_entry_speed, max_allowable_speed(-current->acceleration, next->entry_speed, current->millimeters));
837 837
       if (new_entry_speed != current->entry_speed) {
838 838
         current->entry_speed = new_entry_speed;
839 839
         SBI(current->flag, BLOCK_BIT_RECALCULATE);
@@ -859,7 +859,7 @@ void Planner::reverse_pass() {
859 859
       // for max allowable speed if block is decelerating and nominal length is false.
860 860
       const float new_entry_speed = TEST(current->flag, BLOCK_BIT_NOMINAL_LENGTH)
861 861
         ? max_entry_speed
862
-        : min(max_entry_speed, max_allowable_speed(-current->acceleration, MINIMUM_PLANNER_SPEED, current->millimeters));
862
+        : MIN(max_entry_speed, max_allowable_speed(-current->acceleration, MINIMUM_PLANNER_SPEED, current->millimeters));
863 863
       if (current->entry_speed != new_entry_speed) {
864 864
         current->entry_speed = new_entry_speed;
865 865
         SBI(current->flag, BLOCK_BIT_RECALCULATE);
@@ -884,7 +884,7 @@ void Planner::forward_pass_kernel(const block_t* const previous, block_t* const
884 884
     // guaranteed to be reached. No need to recheck.
885 885
     if (!TEST(previous->flag, BLOCK_BIT_NOMINAL_LENGTH)) {
886 886
       if (previous->entry_speed < current->entry_speed) {
887
-        const float new_entry_speed = min(current->entry_speed, max_allowable_speed(-previous->acceleration, previous->entry_speed, previous->millimeters));
887
+        const float new_entry_speed = MIN(current->entry_speed, max_allowable_speed(-previous->acceleration, previous->entry_speed, previous->millimeters));
888 888
         // Check for junction speed change
889 889
         if (current->entry_speed != new_entry_speed) {
890 890
           current->entry_speed = new_entry_speed;
@@ -1384,7 +1384,7 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE]
1384 1384
         }
1385 1385
       #endif // PREVENT_COLD_EXTRUSION
1386 1386
       #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
1387
-        if (labs(de * e_factor[extruder]) > (int32_t)axis_steps_per_mm[E_AXIS_N] * (EXTRUDE_MAXLENGTH)) { // It's not important to get max. extrusion length in a precision < 1mm, so save some cycles and cast to int
1387
+        if (ABS(de * e_factor[extruder]) > (int32_t)axis_steps_per_mm[E_AXIS_N] * (EXTRUDE_MAXLENGTH)) { // It's not important to get max. extrusion length in a precision < 1mm, so save some cycles and cast to int
1388 1388
           position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
1389 1389
           #if HAS_POSITION_FLOAT
1390 1390
             position_float[E_AXIS] = target_float[E_AXIS];
@@ -1425,7 +1425,7 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE]
1425 1425
   if (de < 0) SBI(dm, E_AXIS);
1426 1426
 
1427 1427
   const float esteps_float = de * e_factor[extruder];
1428
-  const int32_t esteps = abs(esteps_float) + 0.5;
1428
+  const int32_t esteps = ABS(esteps_float) + 0.5;
1429 1429
 
1430 1430
   // Wait for the next available block
1431 1431
   uint8_t next_buffer_head;
@@ -1440,26 +1440,26 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE]
1440 1440
   // Number of steps for each axis
1441 1441
   // See http://www.corexy.com/theory.html
1442 1442
   #if CORE_IS_XY
1443
-    block->steps[A_AXIS] = labs(da + db);
1444
-    block->steps[B_AXIS] = labs(da - db);
1445
-    block->steps[Z_AXIS] = labs(dc);
1443
+    block->steps[A_AXIS] = ABS(da + db);
1444
+    block->steps[B_AXIS] = ABS(da - db);
1445
+    block->steps[Z_AXIS] = ABS(dc);
1446 1446
   #elif CORE_IS_XZ
1447
-    block->steps[A_AXIS] = labs(da + dc);
1448
-    block->steps[Y_AXIS] = labs(db);
1449
-    block->steps[C_AXIS] = labs(da - dc);
1447
+    block->steps[A_AXIS] = ABS(da + dc);
1448
+    block->steps[Y_AXIS] = ABS(db);
1449
+    block->steps[C_AXIS] = ABS(da - dc);
1450 1450
   #elif CORE_IS_YZ
1451
-    block->steps[X_AXIS] = labs(da);
1452
-    block->steps[B_AXIS] = labs(db + dc);
1453
-    block->steps[C_AXIS] = labs(db - dc);
1451
+    block->steps[X_AXIS] = ABS(da);
1452
+    block->steps[B_AXIS] = ABS(db + dc);
1453
+    block->steps[C_AXIS] = ABS(db - dc);
1454 1454
   #elif IS_SCARA
1455
-    block->steps[A_AXIS] = labs(da);
1456
-    block->steps[B_AXIS] = labs(db);
1457
-    block->steps[Z_AXIS] = labs(dc);
1455
+    block->steps[A_AXIS] = ABS(da);
1456
+    block->steps[B_AXIS] = ABS(db);
1457
+    block->steps[Z_AXIS] = ABS(dc);
1458 1458
   #else
1459 1459
     // default non-h-bot planning
1460
-    block->steps[A_AXIS] = labs(da);
1461
-    block->steps[B_AXIS] = labs(db);
1462
-    block->steps[C_AXIS] = labs(dc);
1460
+    block->steps[A_AXIS] = ABS(da);
1461
+    block->steps[B_AXIS] = ABS(db);
1462
+    block->steps[C_AXIS] = ABS(dc);
1463 1463
   #endif
1464 1464
 
1465 1465
   block->steps[E_AXIS] = esteps;
@@ -1660,7 +1660,7 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE]
1660 1660
   delta_mm[E_AXIS] = esteps_float * steps_to_mm[E_AXIS_N];
1661 1661
 
1662 1662
   if (block->steps[A_AXIS] < MIN_STEPS_PER_SEGMENT && block->steps[B_AXIS] < MIN_STEPS_PER_SEGMENT && block->steps[C_AXIS] < MIN_STEPS_PER_SEGMENT) {
1663
-    block->millimeters = FABS(delta_mm[E_AXIS]);
1663
+    block->millimeters = ABS(delta_mm[E_AXIS]);
1664 1664
   }
1665 1665
   else if (!millimeters) {
1666 1666
     block->millimeters = SQRT(
@@ -1751,7 +1751,7 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE]
1751 1751
   // Calculate and limit speed in mm/sec for each axis
1752 1752
   float current_speed[NUM_AXIS], speed_factor = 1.0; // factor <1 decreases speed
1753 1753
   LOOP_XYZE(i) {
1754
-    const float cs = FABS((current_speed[i] = delta_mm[i] * inverse_secs));
1754
+    const float cs = ABS((current_speed[i] = delta_mm[i] * inverse_secs));
1755 1755
     #if ENABLED(DISTINCT_E_FACTORS)
1756 1756
       if (i == E_AXIS) i += extruder;
1757 1757
     #endif
@@ -1789,7 +1789,7 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE]
1789 1789
 
1790 1790
     const uint32_t max_x_segment_time = MAX3(xs0, xs1, xs2),
1791 1791
                    max_y_segment_time = MAX3(ys0, ys1, ys2),
1792
-                   min_xy_segment_time = min(max_x_segment_time, max_y_segment_time);
1792
+                   min_xy_segment_time = MIN(max_x_segment_time, max_y_segment_time);
1793 1793
     if (min_xy_segment_time < MAX_FREQ_TIME_US) {
1794 1794
       const float low_sf = speed_factor * min_xy_segment_time / (MAX_FREQ_TIME_US);
1795 1795
       NOMORE(speed_factor, low_sf);
@@ -1973,7 +1973,7 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE]
1973 1973
         vmax_junction = MINIMUM_PLANNER_SPEED;
1974 1974
       }
1975 1975
       else {
1976
-        junction_cos_theta = max(junction_cos_theta, -0.999999); // Check for numerical round-off to avoid divide by zero.
1976
+        junction_cos_theta = MAX(junction_cos_theta, -0.999999); // Check for numerical round-off to avoid divide by zero.
1977 1977
         const float sin_theta_d2 = SQRT(0.5 * (1.0 - junction_cos_theta)); // Trig half angle identity. Always positive.
1978 1978
 
1979 1979
         // TODO: Technically, the acceleration used in calculation needs to be limited by the minimum of the
@@ -2003,7 +2003,7 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE]
2003 2003
     float safe_speed = block->nominal_speed;
2004 2004
     uint8_t limited = 0;
2005 2005
     LOOP_XYZE(i) {
2006
-      const float jerk = FABS(current_speed[i]), maxj = max_jerk[i];
2006
+      const float jerk = ABS(current_speed[i]), maxj = max_jerk[i];
2007 2007
       if (jerk > maxj) {
2008 2008
         if (limited) {
2009 2009
           const float mjerk = maxj * block->nominal_speed;
@@ -2023,7 +2023,7 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE]
2023 2023
 
2024 2024
       // The junction velocity will be shared between successive segments. Limit the junction velocity to their minimum.
2025 2025
       // Pick the smaller of the nominal speeds. Higher speed shall not be achieved at the junction during coasting.
2026
-      vmax_junction = min(block->nominal_speed, previous_nominal_speed);
2026
+      vmax_junction = MIN(block->nominal_speed, previous_nominal_speed);
2027 2027
 
2028 2028
       // Factor to multiply the previous / current nominal velocities to get componentwise limited velocities.
2029 2029
       float v_factor = 1;
@@ -2043,9 +2043,9 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE]
2043 2043
         // Calculate jerk depending on whether the axis is coasting in the same direction or reversing.
2044 2044
         const float jerk = (v_exit > v_entry)
2045 2045
             ? //                                  coasting             axis reversal
2046
-              ( (v_entry > 0 || v_exit < 0) ? (v_exit - v_entry) : max(v_exit, -v_entry) )
2046
+              ( (v_entry > 0 || v_exit < 0) ? (v_exit - v_entry) : MAX(v_exit, -v_entry) )
2047 2047
             : // v_exit <= v_entry                coasting             axis reversal
2048
-              ( (v_entry < 0 || v_exit > 0) ? (v_entry - v_exit) : max(-v_exit, v_entry) );
2048
+              ( (v_entry < 0 || v_exit > 0) ? (v_entry - v_exit) : MAX(-v_exit, v_entry) );
2049 2049
 
2050 2050
         if (jerk > max_jerk[axis]) {
2051 2051
           v_factor *= max_jerk[axis] / jerk;
@@ -2072,7 +2072,7 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE]
2072 2072
   const float v_allowable = max_allowable_speed(-block->acceleration, MINIMUM_PLANNER_SPEED, block->millimeters);
2073 2073
   // If stepper ISR is disabled, this indicates buffer_segment wants to add a split block.
2074 2074
   // In this case start with the max. allowed speed to avoid an interrupted first move.
2075
-  block->entry_speed = STEPPER_ISR_ENABLED() ? MINIMUM_PLANNER_SPEED : min(vmax_junction, v_allowable);
2075
+  block->entry_speed = STEPPER_ISR_ENABLED() ? MINIMUM_PLANNER_SPEED : MIN(vmax_junction, v_allowable);
2076 2076
 
2077 2077
   // Initialize planner efficiency flags
2078 2078
   // Set flag if block will always reach maximum junction speed regardless of entry/exit speeds.

+ 1
- 1
Marlin/src/module/planner.h 파일 보기

@@ -710,7 +710,7 @@ class Planner {
710 710
 
711 711
 };
712 712
 
713
-#define PLANNER_XY_FEEDRATE() (min(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS]))
713
+#define PLANNER_XY_FEEDRATE() (MIN(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS]))
714 714
 
715 715
 extern Planner planner;
716 716
 

+ 1
- 1
Marlin/src/module/planner_bezier.cpp 파일 보기

@@ -67,7 +67,7 @@ inline static float eval_bezier(float a, float b, float c, float d, float t) {
67 67
  * We approximate Euclidean distance with the sum of the coordinates
68 68
  * offset (so-called "norm 1"), which is quicker to compute.
69 69
  */
70
-inline static float dist1(float x1, float y1, float x2, float y2) { return FABS(x1 - x2) + FABS(y1 - y2); }
70
+inline static float dist1(float x1, float y1, float x2, float y2) { return ABS(x1 - x2) + ABS(y1 - y2); }
71 71
 
72 72
 /**
73 73
  * The algorithm for computing the step is loosely based on the one in Kig

+ 2
- 2
Marlin/src/module/probe.cpp 파일 보기

@@ -392,7 +392,7 @@ bool set_probe_deployed(const bool deploy) {
392 392
   #endif
393 393
 
394 394
   if (deploy_stow_condition && unknown_condition)
395
-    do_probe_raise(max(Z_CLEARANCE_BETWEEN_PROBES, Z_CLEARANCE_DEPLOY_PROBE));
395
+    do_probe_raise(MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_CLEARANCE_DEPLOY_PROBE));
396 396
 
397 397
   #if ENABLED(Z_PROBE_SLED) || ENABLED(Z_PROBE_ALLEN_KEY)
398 398
     #if ENABLED(Z_PROBE_SLED)
@@ -672,7 +672,7 @@ float probe_pt(const float &rx, const float &ry, const ProbePtRaise raise_after/
672 672
   const float nz =
673 673
     #if ENABLED(DELTA)
674 674
       // Move below clip height or xy move will be aborted by do_blocking_move_to
675
-      min(current_position[Z_AXIS], delta_clip_start_height)
675
+      MIN(current_position[Z_AXIS], delta_clip_start_height)
676 676
     #else
677 677
       current_position[Z_AXIS]
678 678
     #endif

+ 4
- 4
Marlin/src/module/temperature.cpp 파일 보기

@@ -811,8 +811,8 @@ void Temperature::manage_heater() {
811 811
   updateTemperaturesFromRawValues(); // also resets the watchdog
812 812
 
813 813
   #if ENABLED(HEATER_0_USES_MAX6675)
814
-    if (current_temperature[0] > min(HEATER_0_MAXTEMP, MAX6675_TMAX - 1.0)) max_temp_error(0);
815
-    if (current_temperature[0] < max(HEATER_0_MINTEMP, MAX6675_TMIN + .01)) min_temp_error(0);
814
+    if (current_temperature[0] > MIN(HEATER_0_MAXTEMP, MAX6675_TMAX - 1.0)) max_temp_error(0);
815
+    if (current_temperature[0] < MAX(HEATER_0_MINTEMP, MAX6675_TMIN + .01)) min_temp_error(0);
816 816
   #endif
817 817
 
818 818
   #if WATCH_HOTENDS || WATCH_THE_BED || DISABLED(PIDTEMPBED) || HAS_AUTO_FAN || HEATER_IDLE_HANDLER
@@ -845,7 +845,7 @@ void Temperature::manage_heater() {
845 845
 
846 846
     #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
847 847
       // Make sure measured temperatures are close together
848
-      if (FABS(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF)
848
+      if (ABS(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF)
849 849
         _temp_error(0, PSTR(MSG_REDUNDANCY), PSTR(MSG_ERR_REDUNDANT_TEMP));
850 850
     #endif
851 851
 
@@ -1097,7 +1097,7 @@ void Temperature::updateTemperaturesFromRawValues() {
1097 1097
    * a return value of 1.
1098 1098
    */
1099 1099
   int8_t Temperature::widthFil_to_size_ratio() {
1100
-    if (FABS(filament_width_nominal - filament_width_meas) <= FILWIDTH_ERROR_MARGIN)
1100
+    if (ABS(filament_width_nominal - filament_width_meas) <= FILWIDTH_ERROR_MARGIN)
1101 1101
       return int(100.0 * filament_width_nominal / filament_width_meas) - 100;
1102 1102
     return 0;
1103 1103
   }

+ 3
- 3
Marlin/src/module/temperature.h 파일 보기

@@ -91,7 +91,7 @@ enum ADCSensorState : char {
91 91
 // get all oversampled sensor readings
92 92
 #define MIN_ADC_ISR_LOOPS 10
93 93
 
94
-#define ACTUAL_ADC_SAMPLES max(int(MIN_ADC_ISR_LOOPS), int(SensorsReady))
94
+#define ACTUAL_ADC_SAMPLES MAX(int(MIN_ADC_ISR_LOOPS), int(SensorsReady))
95 95
 
96 96
 #if HAS_PID_HEATING
97 97
   #define PID_K2 (1.0-PID_K1)
@@ -440,7 +440,7 @@ class Temperature {
440 440
         #endif
441 441
         target_temperature_bed =
442 442
           #ifdef BED_MAXTEMP
443
-            min(celsius, BED_MAXTEMP)
443
+            MIN(celsius, BED_MAXTEMP)
444 444
           #else
445 445
             celsius
446 446
           #endif
@@ -463,7 +463,7 @@ class Temperature {
463 463
     #endif
464 464
 
465 465
     FORCE_INLINE static bool wait_for_heating(const uint8_t e) {
466
-      return degTargetHotend(e) > TEMP_HYSTERESIS && abs(degHotend(e) - degTargetHotend(e)) > TEMP_HYSTERESIS;
466
+      return degTargetHotend(e) > TEMP_HYSTERESIS && ABS(degHotend(e) - degTargetHotend(e)) > TEMP_HYSTERESIS;
467 467
     }
468 468
 
469 469
     /**

Loading…
취소
저장