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:
Scott Lahteine
2018-05-13 01:10:34 -05:00
parent 083ec9963e
commit 99ecdf59af
52 changed files with 206 additions and 247 deletions

View File

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

View File

@ -55,14 +55,14 @@ void GcodeSuite::M106() {
fanSpeeds[p] = new_fanSpeeds[p];
break;
default:
new_fanSpeeds[p] = min(t, 255);
new_fanSpeeds[p] = MIN(t, 255);
break;
}
return;
}
#endif // EXTRA_FAN_SPEED
const uint16_t s = parser.ushortval('S', 255);
fanSpeeds[p] = min(s, 255);
fanSpeeds[p] = MIN(s, 255U);
}
}

View File

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