Skip to content

Commit

Permalink
🎨 Use LIMIT macro
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead authored and EvilGremlin committed May 17, 2023
1 parent 213797f commit 551c4a9
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 16 deletions.
6 changes: 2 additions & 4 deletions Marlin/src/lcd/e3v2/jyersui/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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<const char * const *>(valuepointer), selection - scrollpos, true);
DWIN_UpdateLCD();
}
Expand Down
6 changes: 2 additions & 4 deletions Marlin/src/lcd/menu/game/brickout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/lcd/menu/menu_mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
6 changes: 2 additions & 4 deletions Marlin/src/lcd/tft/touch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/module/planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3453,8 +3453,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() {
Expand Down

0 comments on commit 551c4a9

Please sign in to comment.