Skip to content

Commit acfde4e

Browse files
committed
🎨 Use LIMIT macro
1 parent c5d5c37 commit acfde4e

File tree

5 files changed

+8
-16
lines changed

5 files changed

+8
-16
lines changed

Marlin/src/lcd/e3v2/jyersui/dwin.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -4229,8 +4229,7 @@ void CrealityDWINClass::Value_Control() {
42294229
if (funcpointer) funcpointer();
42304230
return;
42314231
}
4232-
NOLESS(tempvalue, (valuemin * valueunit));
4233-
NOMORE(tempvalue, (valuemax * valueunit));
4232+
LIMIT(tempvalue, valuemin * valueunit, valuemax * valueunit);
42344233
Draw_Float(tempvalue / valueunit, selection - scrollpos, true, valueunit);
42354234
DWIN_UpdateLCD();
42364235
if (active_menu == Move && livemove) {
@@ -4272,8 +4271,7 @@ void CrealityDWINClass::Option_Control() {
42724271
DWIN_UpdateLCD();
42734272
return;
42744273
}
4275-
NOLESS(tempvalue, valuemin);
4276-
NOMORE(tempvalue, valuemax);
4274+
LIMIT(tempvalue, valuemin, valuemax);
42774275
Draw_Option(tempvalue, static_cast<const char * const *>(valuepointer), selection - scrollpos, true);
42784276
DWIN_UpdateLCD();
42794277
}

Marlin/src/lcd/menu/game/brickout.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,11 @@ void BrickoutGame::game_screen() {
117117
}
118118
else if (diff <= 3) {
119119
bdat.ballh += fixed_t(random(-64, 0));
120-
NOLESS(bdat.ballh, BTOF(-2));
121-
NOMORE(bdat.ballh, BTOF(2));
120+
LIMIT(bdat.ballh, BTOF(-2), BTOF(2));
122121
}
123122
else if (diff >= PADDLE_W-1 - 3) {
124123
bdat.ballh += fixed_t(random( 0, 64));
125-
NOLESS(bdat.ballh, BTOF(-2));
126-
NOMORE(bdat.ballh, BTOF(2));
124+
LIMIT(bdat.ballh, BTOF(-2), BTOF(2));
127125
}
128126

129127
// Paddle hit after clearing the board? Reset the board.

Marlin/src/lcd/menu/menu_mixer.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@
5050
if (ui.encoderPosition) {
5151
zvar += float(int32_t(ui.encoderPosition)) * 0.1;
5252
ui.encoderPosition = 0;
53-
NOLESS(zvar, 0);
54-
NOMORE(zvar, Z_MAX_POS);
53+
LIMIT(zvar, 0, Z_MAX_POS);
5554
}
5655

5756
if (ui.should_draw()) {

Marlin/src/lcd/tft/touch.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,8 @@ void Touch::idle() {
113113
if (x != 0 && y != 0) {
114114
if (current_control) {
115115
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)) {
116-
NOLESS(x, current_control->x);
117-
NOMORE(x, current_control->x + current_control->width);
118-
NOLESS(y, current_control->y);
119-
NOMORE(y, current_control->y + current_control->height);
116+
LIMIT(x, current_control->x, current_control->x + current_control->width);
117+
LIMIT(y, current_control->y, current_control->y + current_control->height);
120118
touch(current_control);
121119
}
122120
else

Marlin/src/module/planner.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -3453,8 +3453,7 @@ void Planner::set_max_feedrate(const AxisEnum axis, float inMaxFeedrateMMS) {
34533453
// Doesn't matter because block_buffer_runtime_us is already too small an estimation.
34543454
bbru >>= 10;
34553455
// limit to about a minute.
3456-
NOMORE(bbru, 0x0000FFFFUL);
3457-
return bbru;
3456+
return _MIN(bbru, 0x0000FFFFUL);
34583457
}
34593458

34603459
void Planner::clear_block_buffer_runtime() {

0 commit comments

Comments
 (0)