min/max -> std::min/std::max

This commit is contained in:
Rob Giseburt
2020-03-11 11:57:52 -05:00
parent d45a7247ba
commit 55ef7e18a1
7 changed files with 27 additions and 27 deletions

View File

@@ -1833,7 +1833,7 @@ stat_t cm_run_jog(nvObj_t *nv)
static int8_t _coord(nvObj_t *nv) // extract coordinate system from 3rd character
{
char *ptr = ((*nv->group == 0) ? &nv->token[1] : &nv->group[1]); // skip past the 'g' to the number
return (max ((atoi(ptr)-53), -1)); // return G54-G59 as 0-5, error as -1
return (std::max ((atoi(ptr)-53), -1)); // return G54-G59 as 0-5, error as -1
}
/* _axis()

View File

@@ -315,7 +315,7 @@ static stat_t _homing_axis_start(int8_t axis) {
if (homing_to_max) {
hm.search_travel = travel_distance; // search travels in positive direction
hm.latch_backoff = std::abs(cm->a[axis].latch_backoff); // latch travels in positive direction
hm.zero_backoff = -max(0.0f, cm->a[axis].zero_backoff);// zero backoff is negative direction (or zero)
hm.zero_backoff = -std::max(0.0f, cm->a[axis].zero_backoff);// zero backoff is negative direction (or zero)
// will set the maximum position
// (plus any negative backoff)
hm.setpoint = cm->a[axis].travel_max + (std::max(0.0f, -cm->a[axis].zero_backoff));

View File

@@ -345,8 +345,8 @@ static stat_t _compute_arc(const bool radius_f)
float arc_time = 0;
float segments_for_minimum_time = _estimate_arc_time(arc_time) * (MICROSECONDS_PER_MINUTE / MIN_ARC_SEGMENT_USEC);
float segments_for_chordal_accuracy = cm->arc.length / sqrt(4*cm->chordal_tolerance * (2 * cm->arc.radius - cm->chordal_tolerance));
cm->arc.segments = floor(min(segments_for_chordal_accuracy, segments_for_minimum_time));
cm->arc.segments = max(cm->arc.segments, (float)1.0); //...but is at least 1 segment
cm->arc.segments = std::floor(std::min(segments_for_chordal_accuracy, segments_for_minimum_time));
cm->arc.segments = std::max(cm->arc.segments, (float)1.0); //...but is at least 1 segment
if (cm->arc.gm.feed_rate_mode == INVERSE_TIME_MODE) {
cm->arc.gm.feed_rate /= cm->arc.segments;
@@ -497,10 +497,10 @@ static float _estimate_arc_time (float arc_time)
}
// Downgrade the time if there is a rate-limiting axis
arc_time = max(arc_time, (float)std::abs(cm->arc.planar_travel/cm->a[cm->arc.plane_axis_0].feedrate_max));
arc_time = max(arc_time, (float)std::abs(cm->arc.planar_travel/cm->a[cm->arc.plane_axis_1].feedrate_max));
arc_time = std::max(arc_time, (float)std::abs(cm->arc.planar_travel/cm->a[cm->arc.plane_axis_0].feedrate_max));
arc_time = std::max(arc_time, (float)std::abs(cm->arc.planar_travel/cm->a[cm->arc.plane_axis_1].feedrate_max));
if (std::abs(cm->arc.linear_travel) > 0) {
arc_time = max(arc_time, (float)std::abs(cm->arc.linear_travel/cm->a[cm->arc.linear_axis].feedrate_max));
arc_time = std::max(arc_time, (float)std::abs(cm->arc.linear_travel/cm->a[cm->arc.linear_axis].feedrate_max));
}
return (arc_time);
}

View File

@@ -476,7 +476,7 @@ static float _get_meet_velocity(const float v_0,
const float q_recip_2_sqrt_j = bf->q_recip_2_sqrt_j;
// v_1 can never be smaller than v_0 or v_2, so we keep track of this value
const float min_v_1 = max(v_0, v_2);
const float min_v_1 = std::max(v_0, v_2);
// v_1 is our estimated return value.
// We estimate with the speed obtained by L/2 traveled from the highest speed of v_0 or v_2.

View File

@@ -713,7 +713,7 @@ struct PID {
if (!_rise_time_timeout.isSet() && (_set_point > (input + TEMP_MIN_RISE_DEGREES_FROM_TARGET))) {
_rise_time_timeout.set(TEMP_MIN_RISE_TIME);
_rise_time_checkpoint = min(input + _min_rise_over_time, _set_point + TEMP_SETPOINT_HYSTERESIS);
_rise_time_checkpoint = std::min(input + _min_rise_over_time, _set_point + TEMP_SETPOINT_HYSTERESIS);
}
}
@@ -928,7 +928,7 @@ stat_t temperature_callback()
sr_requested = true;
}
}
fan_temp = max(fan_temp, temp);
fan_temp = std::max(fan_temp, temp);
heater_fan1.newTemp(fan_temp);
@@ -1145,9 +1145,9 @@ stat_t cm_get_set_temperature(nvObj_t *nv)
void cm_set_set_temperature(const uint8_t heater, const float value)
{
switch(heater) {
case 1: { pid1._set_point = min(TEMP_MAX_SETPOINT, value); break; }
case 2: { pid2._set_point = min(TEMP_MAX_SETPOINT, value); break; }
case 3: { pid3._set_point = min(TEMP_MAX_SETPOINT, value); break; }
case 1: { pid1._set_point = std::min(TEMP_MAX_SETPOINT, value); break; }
case 2: { pid2._set_point = std::min(TEMP_MAX_SETPOINT, value); break; }
case 3: { pid3._set_point = std::min(TEMP_MAX_SETPOINT, value); break; }
// default to quiet the compiler
default: { break; }
@@ -1167,7 +1167,7 @@ stat_t cm_set_set_temperature(nvObj_t *nv)
float cm_get_fan_power(const uint8_t heater)
{
switch(heater) {
case 1: { return min(1.0f, heater_fan1.max_value); }
case 1: { return std::min(1.0f, heater_fan1.max_value); }
// case 2: { return min(1.0f, heater_fan2.max_value); }
// case 3: { return min(1.0f, heater_fan3.max_value); }
default: { break; }
@@ -1186,7 +1186,7 @@ stat_t cm_get_fan_power(nvObj_t *nv)
void cm_set_fan_power(const uint8_t heater, const float value)
{
switch(heater) {
case 1: { heater_fan1.max_value = max(0.0f, value); break; }
case 1: { heater_fan1.max_value = std::max(0.0f, value); break; }
// case 2: { heater_fan2.max_value = max(0.0, value); break; }
// case 3: { heater_fan3.max_value = max(0.0, value); break; }
default: { break; }
@@ -1220,9 +1220,9 @@ stat_t cm_get_fan_min_power(nvObj_t *nv)
stat_t cm_set_fan_min_power(nvObj_t *nv)
{
switch(_get_heater_number(nv)) {
case '1': { heater_fan1.max_value = min(0.0f, nv->value_flt); break; }
// case '2': { heater_fan2.min_value = min(0.0, nv->value_flt); break; }
// case '3': { heater_fan3.min_value = min(0.0, nv->value_flt); break; }
case '1': { heater_fan1.max_value = std::min(0.0, nv->value_flt); break; }
// case '2': { heater_fan2.min_value = std::min(0.0, nv->value_flt); break; }
// case '3': { heater_fan3.min_value = std::min(0.0, nv->value_flt); break; }
default: { break; }
}
return (STAT_OK);
@@ -1249,9 +1249,9 @@ stat_t cm_get_fan_low_temp(nvObj_t *nv)
stat_t cm_set_fan_low_temp(nvObj_t *nv)
{
switch(_get_heater_number(nv)) {
case '1': { heater_fan1.low_temp = min(0.0f, nv->value_flt); break; }
// case '2': { heater_fan2.low_temp = min(0.0f, nv->value_flt); break; }
// case '3': { heater_fan3.low_temp = min(0.0f, nv->value_flt); break; }
case '1': { heater_fan1.low_temp = std::min(0.0, nv->value_flt); break; }
// case '2': { heater_fan2.low_temp = std::min(0.0, nv->value_flt); break; }
// case '3': { heater_fan3.low_temp = std::min(0.0, nv->value_flt); break; }
default: { break; }
}
return (STAT_OK);
@@ -1278,7 +1278,7 @@ stat_t cm_get_fan_high_temp(nvObj_t *nv)
stat_t cm_set_fan_high_temp(nvObj_t *nv)
{
switch(_get_heater_number(nv)) {
case '1': { heater_fan1.high_temp = min(0.0f, nv->value_flt); break; }
case '1': { heater_fan1.high_temp = std::min(0.0, nv->value_flt); break; }
// case '2': { heater_fan2.high_temp = min(0.0f, nv->value_flt); break; }
// case '3': { heater_fan3.high_temp = min(0.0f, nv->value_flt); break; }
default: { break; }

View File

@@ -211,7 +211,7 @@ uint16_t compute_checksum(char const *string, const uint16_t length)
{
uint32_t h = 0;
uint16_t len = strlen(string);
if (length != 0) len = min(len, length);
if (length != 0) len = std::min(len, length);
for (uint16_t i=0; i<len; i++) {
h = 31 * h + string[i];
}
@@ -310,10 +310,10 @@ uint32_t crc32(uint32_t crc, const void *buf, size_t size)
{
const uint8_t *p = (uint8_t*)buf;
crc = crc ^ ~0U;
while (size--)
crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8);
return crc ^ ~0U;
}

View File

@@ -110,8 +110,8 @@ char inttoa(char *str, int n);
using std::isnan;
using std::isinf;
using std::min;
using std::max;
// using std::min;
// using std::max;
template <typename T>
inline T square(const T x) { return (x)*(x); } /* UNSAFE */