From 3e559d5c1ca2cbdbb904de779ed9bb6029880890 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 29 Jul 2021 23:40:27 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20abs=20=3D>=20ABS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/probe_temp_comp.cpp | 4 ++-- Marlin/src/gcode/bedlevel/G35.cpp | 6 +++--- Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp | 2 +- .../lcd/extui/dgus/mks/DGUSScreenHandler.cpp | 20 +++++++++---------- .../generic/move_axis_screen.cpp | 2 +- .../lcd/extui/mks_ui/draw_baby_stepping.cpp | 4 ++-- Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp | 4 ++-- .../src/lcd/extui/mks_ui/draw_extrusion.cpp | 2 +- .../lcd/extui/mks_ui/draw_filament_change.cpp | 4 ++-- .../src/lcd/extui/mks_ui/draw_move_motor.cpp | 2 +- Marlin/src/lcd/menu/menu_bed_corners.cpp | 2 +- 11 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Marlin/src/feature/probe_temp_comp.cpp b/Marlin/src/feature/probe_temp_comp.cpp index c9d6c6cb3fc2..e39896d4dc09 100644 --- a/Marlin/src/feature/probe_temp_comp.cpp +++ b/Marlin/src/feature/probe_temp_comp.cpp @@ -143,13 +143,13 @@ bool ProbeTempComp::finish_calibration(const TempSensorID tsi) { // Sanity check for (calib_idx = 0; calib_idx < measurements; ++calib_idx) { // Restrict the max. offset - if (abs(data[calib_idx]) > 2000) { + if (ABS(data[calib_idx]) > 2000) { SERIAL_ECHOLNPGM("!Invalid Z-offset detected (0-2)."); clear_offsets(tsi); return false; } // 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)."); clear_offsets(TSI_PROBE); return false; diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index 9c8d343a46f4..3d75a7691537 100644 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -130,7 +130,7 @@ void GcodeSuite::G35() { // Calculate adjusts LOOP_S_L_N(i, 1, G35_PROBE_COUNT) { 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 float decimal_part = adjust - float(full_turns); @@ -138,8 +138,8 @@ void GcodeSuite::G35() { SERIAL_ECHOPGM("Turn "); 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"); - if (minutes) SERIAL_ECHOPAIR(" and ", abs(minutes), " minutes"); + SERIAL_ECHOPAIR(" ", (screw_thread & 1) == (adjust > 0) ? "CCW" : "CW", " by ", ABS(full_turns), " turns"); + if (minutes) SERIAL_ECHOPAIR(" and ", ABS(minutes), " minutes"); if (ENABLED(REPORT_TRAMMING_MM)) SERIAL_ECHOPAIR(" (", -diff, "mm)"); SERIAL_EOL(); } diff --git a/Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp b/Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp index 6c229b7aca22..97e516e70a9e 100644 --- a/Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp +++ b/Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp @@ -121,7 +121,7 @@ ENCODER_DiffState Encoder_ReceiveAnalyze() { 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; else temp_diffState = ENCODER_DIFF_CCW; diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp index 0ee382838770..0c022d3e8853 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp @@ -624,25 +624,25 @@ void DGUSScreenHandler::ManualAssistLeveling(DGUS_VP_Variable &var, void *val_pt switch (point_value) { case 0x0001: - enqueue_corner_move(X_MIN_POS + abs(mks_corner_offsets[0].x), - Y_MIN_POS + abs(mks_corner_offsets[0].y), level_speed); + enqueue_corner_move(X_MIN_POS + ABS(mks_corner_offsets[0].x), + Y_MIN_POS + ABS(mks_corner_offsets[0].y), level_speed); queue.enqueue_now_P(PSTR("G28Z")); break; case 0x0002: - enqueue_corner_move(X_MAX_POS - abs(mks_corner_offsets[1].x), - Y_MIN_POS + abs(mks_corner_offsets[1].y), level_speed); + enqueue_corner_move(X_MAX_POS - ABS(mks_corner_offsets[1].x), + Y_MIN_POS + ABS(mks_corner_offsets[1].y), level_speed); break; case 0x0003: - enqueue_corner_move(X_MAX_POS - abs(mks_corner_offsets[2].x), - Y_MAX_POS - abs(mks_corner_offsets[2].y), level_speed); + enqueue_corner_move(X_MAX_POS - ABS(mks_corner_offsets[2].x), + Y_MAX_POS - ABS(mks_corner_offsets[2].y), level_speed); break; case 0x0004: - enqueue_corner_move(X_MIN_POS + abs(mks_corner_offsets[3].x), - Y_MAX_POS - abs(mks_corner_offsets[3].y), level_speed); + enqueue_corner_move(X_MIN_POS + ABS(mks_corner_offsets[3].x), + Y_MAX_POS - ABS(mks_corner_offsets[3].y), level_speed); break; case 0x0005: - enqueue_corner_move(abs(mks_corner_offsets[4].x), - abs(mks_corner_offsets[4].y), level_speed); + enqueue_corner_move(ABS(mks_corner_offsets[4].x), + ABS(mks_corner_offsets[4].y), level_speed); break; } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/move_axis_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/move_axis_screen.cpp index 3bfe1784fc24..f55cf9015984 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/move_axis_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/move_axis_screen.cpp @@ -121,7 +121,7 @@ float BaseMoveAxisScreen::getManualFeedrate(uint8_t axis, float increment_mm) { // being held down, this allows enough margin for the planner to // connect segments and even out the motion. 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) { diff --git a/Marlin/src/lcd/extui/mks_ui/draw_baby_stepping.cpp b/Marlin/src/lcd/extui/mks_ui/draw_baby_stepping.cpp index 312353f47ed9..316519057952 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_baby_stepping.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_baby_stepping.cpp @@ -93,9 +93,9 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { has_adjust_z = 1; break; case ID_BABY_STEP_DIST: - if (abs((int)(100 * babystep_dist)) == 1) + if (ABS((int)(100 * babystep_dist)) == 1) babystep_dist = 0.05; - else if (abs((int)(100 * babystep_dist)) == 5) + else if (ABS((int)(100 * babystep_dist)) == 5) babystep_dist = 0.1; else babystep_dist = 0.01; diff --git a/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp b/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp index a1bfb7fc8641..638d0c5ec359 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp @@ -519,7 +519,7 @@ void filament_dialog_handle() { if (uiCfg.filament_load_heat_flg) { 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; lv_clear_dialog(); lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED); @@ -535,7 +535,7 @@ void filament_dialog_handle() { if (uiCfg.filament_unload_heat_flg) { 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; lv_clear_dialog(); lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_extrusion.cpp b/Marlin/src/lcd/extui/mks_ui/draw_extrusion.cpp index d070d249f399..2f9009bcdbdd 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_extrusion.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_extrusion.cpp @@ -89,7 +89,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { disp_extru_amount(); break; case ID_E_STEP: - switch (abs(uiCfg.extruStep)) { + switch (ABS(uiCfg.extruStep)) { case 1: uiCfg.extruStep = 5; break; case 5: uiCfg.extruStep = 10; break; case 10: uiCfg.extruStep = 1; break; diff --git a/Marlin/src/lcd/extui/mks_ui/draw_filament_change.cpp b/Marlin/src/lcd/extui/mks_ui/draw_filament_change.cpp index a3da638be625..311894825daa 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_filament_change.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_filament_change.cpp @@ -50,7 +50,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { switch (obj->mks_obj_id) { case ID_FILAMNT_IN: 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)) { lv_clear_filament_change(); 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: uiCfg.filament_unload_heat_flg = true; 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) ) { lv_clear_filament_change(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_move_motor.cpp b/Marlin/src/lcd/extui/mks_ui/draw_move_motor.cpp index 19abb855f544..7a37dc6a1556 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_move_motor.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_move_motor.cpp @@ -75,7 +75,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { switch (obj->mks_obj_id) { 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; else uiCfg.move_dist *= 10.0f; diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index 0ab82a9b1600..a670ba5b94f3 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -87,7 +87,7 @@ constexpr int lco[] = LEVEL_CORNERS_LEVELING_ORDER; 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."); -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."); constexpr int nr_edge_points = level_corners_3_points ? 3 : 4;