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>
This commit is contained in:
@ -811,8 +811,8 @@ void Temperature::manage_heater() {
|
||||
updateTemperaturesFromRawValues(); // also resets the watchdog
|
||||
|
||||
#if ENABLED(HEATER_0_USES_MAX6675)
|
||||
if (current_temperature[0] > min(HEATER_0_MAXTEMP, MAX6675_TMAX - 1.0)) max_temp_error(0);
|
||||
if (current_temperature[0] < max(HEATER_0_MINTEMP, MAX6675_TMIN + .01)) min_temp_error(0);
|
||||
if (current_temperature[0] > MIN(HEATER_0_MAXTEMP, MAX6675_TMAX - 1.0)) max_temp_error(0);
|
||||
if (current_temperature[0] < MAX(HEATER_0_MINTEMP, MAX6675_TMIN + .01)) min_temp_error(0);
|
||||
#endif
|
||||
|
||||
#if WATCH_HOTENDS || WATCH_THE_BED || DISABLED(PIDTEMPBED) || HAS_AUTO_FAN || HEATER_IDLE_HANDLER
|
||||
@ -845,7 +845,7 @@ void Temperature::manage_heater() {
|
||||
|
||||
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
|
||||
// Make sure measured temperatures are close together
|
||||
if (FABS(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF)
|
||||
if (ABS(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF)
|
||||
_temp_error(0, PSTR(MSG_REDUNDANCY), PSTR(MSG_ERR_REDUNDANT_TEMP));
|
||||
#endif
|
||||
|
||||
@ -1097,7 +1097,7 @@ void Temperature::updateTemperaturesFromRawValues() {
|
||||
* a return value of 1.
|
||||
*/
|
||||
int8_t Temperature::widthFil_to_size_ratio() {
|
||||
if (FABS(filament_width_nominal - filament_width_meas) <= FILWIDTH_ERROR_MARGIN)
|
||||
if (ABS(filament_width_nominal - filament_width_meas) <= FILWIDTH_ERROR_MARGIN)
|
||||
return int(100.0 * filament_width_nominal / filament_width_meas) - 100;
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user