From 071d54ec7082f265b3665ab086e5580925f8b124 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 23 Feb 2023 21:38:11 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Use=20LIMIT=20macro?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/e3v2/jyersui/dwin.cpp | 6 ++---- Marlin/src/lcd/menu/game/brickout.cpp | 6 ++---- Marlin/src/lcd/menu/menu_mixer.cpp | 3 +-- Marlin/src/lcd/tft/touch.cpp | 6 ++---- Marlin/src/module/planner.cpp | 3 +-- 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index 8894150c9885..3f13fe8b3bdc 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -4229,8 +4229,7 @@ void CrealityDWINClass::Value_Control() { if (funcpointer) funcpointer(); return; } - NOLESS(tempvalue, (valuemin * valueunit)); - NOMORE(tempvalue, (valuemax * valueunit)); + LIMIT(tempvalue, valuemin * valueunit, valuemax * valueunit); Draw_Float(tempvalue / valueunit, selection - scrollpos, true, valueunit); DWIN_UpdateLCD(); if (active_menu == Move && livemove) { @@ -4272,8 +4271,7 @@ void CrealityDWINClass::Option_Control() { DWIN_UpdateLCD(); return; } - NOLESS(tempvalue, valuemin); - NOMORE(tempvalue, valuemax); + LIMIT(tempvalue, valuemin, valuemax); Draw_Option(tempvalue, static_cast(valuepointer), selection - scrollpos, true); DWIN_UpdateLCD(); } diff --git a/Marlin/src/lcd/menu/game/brickout.cpp b/Marlin/src/lcd/menu/game/brickout.cpp index d738250b60a8..fc4d19b1d98d 100644 --- a/Marlin/src/lcd/menu/game/brickout.cpp +++ b/Marlin/src/lcd/menu/game/brickout.cpp @@ -117,13 +117,11 @@ void BrickoutGame::game_screen() { } else if (diff <= 3) { bdat.ballh += fixed_t(random(-64, 0)); - NOLESS(bdat.ballh, BTOF(-2)); - NOMORE(bdat.ballh, BTOF(2)); + LIMIT(bdat.ballh, BTOF(-2), BTOF(2)); } else if (diff >= PADDLE_W-1 - 3) { bdat.ballh += fixed_t(random( 0, 64)); - NOLESS(bdat.ballh, BTOF(-2)); - NOMORE(bdat.ballh, BTOF(2)); + LIMIT(bdat.ballh, BTOF(-2), BTOF(2)); } // Paddle hit after clearing the board? Reset the board. diff --git a/Marlin/src/lcd/menu/menu_mixer.cpp b/Marlin/src/lcd/menu/menu_mixer.cpp index feb4c59f181c..f18c5bbfebb9 100644 --- a/Marlin/src/lcd/menu/menu_mixer.cpp +++ b/Marlin/src/lcd/menu/menu_mixer.cpp @@ -50,8 +50,7 @@ if (ui.encoderPosition) { zvar += float(int32_t(ui.encoderPosition)) * 0.1; ui.encoderPosition = 0; - NOLESS(zvar, 0); - NOMORE(zvar, Z_MAX_POS); + LIMIT(zvar, 0, Z_MAX_POS); } if (ui.should_draw()) { diff --git a/Marlin/src/lcd/tft/touch.cpp b/Marlin/src/lcd/tft/touch.cpp index 6c81ebefcda7..b336395048d5 100644 --- a/Marlin/src/lcd/tft/touch.cpp +++ b/Marlin/src/lcd/tft/touch.cpp @@ -113,10 +113,8 @@ void Touch::idle() { if (x != 0 && y != 0) { if (current_control) { if (WITHIN(x, current_control->x - FREE_MOVE_RANGE, current_control->x + current_control->width + FREE_MOVE_RANGE) && WITHIN(y, current_control->y - FREE_MOVE_RANGE, current_control->y + current_control->height + FREE_MOVE_RANGE)) { - NOLESS(x, current_control->x); - NOMORE(x, current_control->x + current_control->width); - NOLESS(y, current_control->y); - NOMORE(y, current_control->y + current_control->height); + LIMIT(x, current_control->x, current_control->x + current_control->width); + LIMIT(y, current_control->y, current_control->y + current_control->height); touch(current_control); } else diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index db1516aeb67e..8bbb8830018f 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -3441,8 +3441,7 @@ void Planner::set_max_feedrate(const AxisEnum axis, float inMaxFeedrateMMS) { // Doesn't matter because block_buffer_runtime_us is already too small an estimation. bbru >>= 10; // limit to about a minute. - NOMORE(bbru, 0x0000FFFFUL); - return bbru; + return _MIN(bbru, 0x0000FFFFUL); } void Planner::clear_block_buffer_runtime() {