🎨 abs => ABS

This commit is contained in:
Scott Lahteine 2021-07-29 23:40:27 -05:00 committed by Scott Lahteine
parent eb8649ba42
commit 3e559d5c1c
11 changed files with 26 additions and 26 deletions

View File

@ -143,13 +143,13 @@ bool ProbeTempComp::finish_calibration(const TempSensorID tsi) {
// Sanity check // Sanity check
for (calib_idx = 0; calib_idx < measurements; ++calib_idx) { for (calib_idx = 0; calib_idx < measurements; ++calib_idx) {
// Restrict the max. offset // Restrict the max. offset
if (abs(data[calib_idx]) > 2000) { if (ABS(data[calib_idx]) > 2000) {
SERIAL_ECHOLNPGM("!Invalid Z-offset detected (0-2)."); SERIAL_ECHOLNPGM("!Invalid Z-offset detected (0-2).");
clear_offsets(tsi); clear_offsets(tsi);
return false; return false;
} }
// Restrict the max. offset difference between two probings // Restrict the max. offset difference between two probings
if (calib_idx > 0 && abs(data[calib_idx - 1] - data[calib_idx]) > 800) { if (calib_idx > 0 && ABS(data[calib_idx - 1] - data[calib_idx]) > 800) {
SERIAL_ECHOLNPGM("!Invalid Z-offset between two probings detected (0-0.8)."); SERIAL_ECHOLNPGM("!Invalid Z-offset between two probings detected (0-0.8).");
clear_offsets(TSI_PROBE); clear_offsets(TSI_PROBE);
return false; return false;

View File

@ -130,7 +130,7 @@ void GcodeSuite::G35() {
// Calculate adjusts // Calculate adjusts
LOOP_S_L_N(i, 1, G35_PROBE_COUNT) { LOOP_S_L_N(i, 1, G35_PROBE_COUNT) {
const float diff = z_measured[0] - z_measured[i], const float diff = z_measured[0] - z_measured[i],
adjust = abs(diff) < 0.001f ? 0 : diff / threads_factor[(screw_thread - 30) / 10]; adjust = ABS(diff) < 0.001f ? 0 : diff / threads_factor[(screw_thread - 30) / 10];
const int full_turns = trunc(adjust); const int full_turns = trunc(adjust);
const float decimal_part = adjust - float(full_turns); const float decimal_part = adjust - float(full_turns);
@ -138,8 +138,8 @@ void GcodeSuite::G35() {
SERIAL_ECHOPGM("Turn "); SERIAL_ECHOPGM("Turn ");
SERIAL_ECHOPGM_P((char *)pgm_read_ptr(&tramming_point_name[i])); SERIAL_ECHOPGM_P((char *)pgm_read_ptr(&tramming_point_name[i]));
SERIAL_ECHOPAIR(" ", (screw_thread & 1) == (adjust > 0) ? "CCW" : "CW", " by ", abs(full_turns), " turns"); SERIAL_ECHOPAIR(" ", (screw_thread & 1) == (adjust > 0) ? "CCW" : "CW", " by ", ABS(full_turns), " turns");
if (minutes) SERIAL_ECHOPAIR(" and ", abs(minutes), " minutes"); if (minutes) SERIAL_ECHOPAIR(" and ", ABS(minutes), " minutes");
if (ENABLED(REPORT_TRAMMING_MM)) SERIAL_ECHOPAIR(" (", -diff, "mm)"); if (ENABLED(REPORT_TRAMMING_MM)) SERIAL_ECHOPAIR(" (", -diff, "mm)");
SERIAL_EOL(); SERIAL_EOL();
} }

View File

@ -121,7 +121,7 @@ ENCODER_DiffState Encoder_ReceiveAnalyze() {
lastEncoderBits = newbutton; lastEncoderBits = newbutton;
} }
if (abs(temp_diff) >= ENCODER_PULSES_PER_STEP) { if (ABS(temp_diff) >= ENCODER_PULSES_PER_STEP) {
if (temp_diff > 0) temp_diffState = ENCODER_DIFF_CW; if (temp_diff > 0) temp_diffState = ENCODER_DIFF_CW;
else temp_diffState = ENCODER_DIFF_CCW; else temp_diffState = ENCODER_DIFF_CCW;

View File

@ -624,25 +624,25 @@ void DGUSScreenHandler::ManualAssistLeveling(DGUS_VP_Variable &var, void *val_pt
switch (point_value) { switch (point_value) {
case 0x0001: case 0x0001:
enqueue_corner_move(X_MIN_POS + abs(mks_corner_offsets[0].x), enqueue_corner_move(X_MIN_POS + ABS(mks_corner_offsets[0].x),
Y_MIN_POS + abs(mks_corner_offsets[0].y), level_speed); Y_MIN_POS + ABS(mks_corner_offsets[0].y), level_speed);
queue.enqueue_now_P(PSTR("G28Z")); queue.enqueue_now_P(PSTR("G28Z"));
break; break;
case 0x0002: case 0x0002:
enqueue_corner_move(X_MAX_POS - abs(mks_corner_offsets[1].x), enqueue_corner_move(X_MAX_POS - ABS(mks_corner_offsets[1].x),
Y_MIN_POS + abs(mks_corner_offsets[1].y), level_speed); Y_MIN_POS + ABS(mks_corner_offsets[1].y), level_speed);
break; break;
case 0x0003: case 0x0003:
enqueue_corner_move(X_MAX_POS - abs(mks_corner_offsets[2].x), enqueue_corner_move(X_MAX_POS - ABS(mks_corner_offsets[2].x),
Y_MAX_POS - abs(mks_corner_offsets[2].y), level_speed); Y_MAX_POS - ABS(mks_corner_offsets[2].y), level_speed);
break; break;
case 0x0004: case 0x0004:
enqueue_corner_move(X_MIN_POS + abs(mks_corner_offsets[3].x), enqueue_corner_move(X_MIN_POS + ABS(mks_corner_offsets[3].x),
Y_MAX_POS - abs(mks_corner_offsets[3].y), level_speed); Y_MAX_POS - ABS(mks_corner_offsets[3].y), level_speed);
break; break;
case 0x0005: case 0x0005:
enqueue_corner_move(abs(mks_corner_offsets[4].x), enqueue_corner_move(ABS(mks_corner_offsets[4].x),
abs(mks_corner_offsets[4].y), level_speed); ABS(mks_corner_offsets[4].y), level_speed);
break; break;
} }

View File

@ -121,7 +121,7 @@ float BaseMoveAxisScreen::getManualFeedrate(uint8_t axis, float increment_mm) {
// being held down, this allows enough margin for the planner to // being held down, this allows enough margin for the planner to
// connect segments and even out the motion. // connect segments and even out the motion.
constexpr xyze_feedrate_t max_manual_feedrate = MANUAL_FEEDRATE; constexpr xyze_feedrate_t max_manual_feedrate = MANUAL_FEEDRATE;
return min(max_manual_feedrate[axis] / 60.0f, abs(increment_mm * (TOUCH_REPEATS_PER_SECOND) * 0.80f)); return min(max_manual_feedrate[axis] / 60.0f, ABS(increment_mm * (TOUCH_REPEATS_PER_SECOND) * 0.80f));
} }
void BaseMoveAxisScreen::setManualFeedrate(ExtUI::axis_t axis, float increment_mm) { void BaseMoveAxisScreen::setManualFeedrate(ExtUI::axis_t axis, float increment_mm) {

View File

@ -93,9 +93,9 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
has_adjust_z = 1; has_adjust_z = 1;
break; break;
case ID_BABY_STEP_DIST: case ID_BABY_STEP_DIST:
if (abs((int)(100 * babystep_dist)) == 1) if (ABS((int)(100 * babystep_dist)) == 1)
babystep_dist = 0.05; babystep_dist = 0.05;
else if (abs((int)(100 * babystep_dist)) == 5) else if (ABS((int)(100 * babystep_dist)) == 5)
babystep_dist = 0.1; babystep_dist = 0.1;
else else
babystep_dist = 0.01; babystep_dist = 0.01;

View File

@ -519,7 +519,7 @@ void filament_dialog_handle() {
if (uiCfg.filament_load_heat_flg) { if (uiCfg.filament_load_heat_flg) {
const celsius_t diff = thermalManager.wholeDegHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp; const celsius_t diff = thermalManager.wholeDegHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp;
if (abs(diff) < 2 || diff > 0) { if (ABS(diff) < 2 || diff > 0) {
uiCfg.filament_load_heat_flg = false; uiCfg.filament_load_heat_flg = false;
lv_clear_dialog(); lv_clear_dialog();
lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED); lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED);
@ -535,7 +535,7 @@ void filament_dialog_handle() {
if (uiCfg.filament_unload_heat_flg) { if (uiCfg.filament_unload_heat_flg) {
const celsius_t diff = thermalManager.wholeDegHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp; const celsius_t diff = thermalManager.wholeDegHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp;
if (abs(diff) < 2 || diff > 0) { if (ABS(diff) < 2 || diff > 0) {
uiCfg.filament_unload_heat_flg = false; uiCfg.filament_unload_heat_flg = false;
lv_clear_dialog(); lv_clear_dialog();
lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED); lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED);

View File

@ -89,7 +89,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
disp_extru_amount(); disp_extru_amount();
break; break;
case ID_E_STEP: case ID_E_STEP:
switch (abs(uiCfg.extruStep)) { switch (ABS(uiCfg.extruStep)) {
case 1: uiCfg.extruStep = 5; break; case 1: uiCfg.extruStep = 5; break;
case 5: uiCfg.extruStep = 10; break; case 5: uiCfg.extruStep = 10; break;
case 10: uiCfg.extruStep = 1; break; case 10: uiCfg.extruStep = 1; break;

View File

@ -50,7 +50,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_FILAMNT_IN: case ID_FILAMNT_IN:
uiCfg.filament_load_heat_flg = true; uiCfg.filament_load_heat_flg = true;
if (abs(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.wholeDegHotend(uiCfg.extruderIndex)) <= 1 if (ABS(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.wholeDegHotend(uiCfg.extruderIndex)) <= 1
|| gCfgItems.filament_limit_temp <= thermalManager.wholeDegHotend(uiCfg.extruderIndex)) { || gCfgItems.filament_limit_temp <= thermalManager.wholeDegHotend(uiCfg.extruderIndex)) {
lv_clear_filament_change(); lv_clear_filament_change();
lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED); lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED);
@ -67,7 +67,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
case ID_FILAMNT_OUT: case ID_FILAMNT_OUT:
uiCfg.filament_unload_heat_flg = true; uiCfg.filament_unload_heat_flg = true;
if (thermalManager.degTargetHotend(uiCfg.extruderIndex) if (thermalManager.degTargetHotend(uiCfg.extruderIndex)
&& (abs(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.wholeDegHotend(uiCfg.extruderIndex)) <= 1 && (ABS(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.wholeDegHotend(uiCfg.extruderIndex)) <= 1
|| thermalManager.wholeDegHotend(uiCfg.extruderIndex) >= gCfgItems.filament_limit_temp) || thermalManager.wholeDegHotend(uiCfg.extruderIndex) >= gCfgItems.filament_limit_temp)
) { ) {
lv_clear_filament_change(); lv_clear_filament_change();

View File

@ -75,7 +75,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_M_STEP: case ID_M_STEP:
if (abs(10 * (int)uiCfg.move_dist) == 100) if (ABS(10 * (int)uiCfg.move_dist) == 100)
uiCfg.move_dist = 0.1; uiCfg.move_dist = 0.1;
else else
uiCfg.move_dist *= 10.0f; uiCfg.move_dist *= 10.0f;

View File

@ -87,7 +87,7 @@ constexpr int lco[] = LEVEL_CORNERS_LEVELING_ORDER;
constexpr bool level_corners_3_points = COUNT(lco) == 2; constexpr bool level_corners_3_points = COUNT(lco) == 2;
static_assert(level_corners_3_points || COUNT(lco) == 4, "LEVEL_CORNERS_LEVELING_ORDER must have exactly 2 or 4 corners."); static_assert(level_corners_3_points || COUNT(lco) == 4, "LEVEL_CORNERS_LEVELING_ORDER must have exactly 2 or 4 corners.");
constexpr int lcodiff = abs(lco[0] - lco[1]); constexpr int lcodiff = ABS(lco[0] - lco[1]);
static_assert(COUNT(lco) == 4 || lcodiff == 1 || lcodiff == 3, "The first two LEVEL_CORNERS_LEVELING_ORDER corners must be on the same edge."); static_assert(COUNT(lco) == 4 || lcodiff == 1 || lcodiff == 3, "The first two LEVEL_CORNERS_LEVELING_ORDER corners must be on the same edge.");
constexpr int nr_edge_points = level_corners_3_points ? 3 : 4; constexpr int nr_edge_points = level_corners_3_points ? 3 : 4;