Apply LIMIT macro
This commit is contained in:
@ -67,8 +67,7 @@ void reset_ball() {
|
||||
void BrickoutGame::game_screen() {
|
||||
if (game_frame()) { // Run logic twice for finer resolution
|
||||
// Update Paddle Position
|
||||
paddle_x = (int8_t)ui.encoderPosition;
|
||||
paddle_x = constrain(paddle_x, 0, (LCD_PIXEL_WIDTH - (PADDLE_W)) / (PADDLE_VEL));
|
||||
paddle_x = constrain(int8_t(ui.encoderPosition), 0, (LCD_PIXEL_WIDTH - (PADDLE_W)) / (PADDLE_VEL));
|
||||
ui.encoderPosition = paddle_x;
|
||||
paddle_x *= (PADDLE_VEL);
|
||||
|
||||
|
@ -263,8 +263,7 @@ void InvadersGame::game_screen() {
|
||||
if (ui.first_page) {
|
||||
|
||||
// Update Cannon Position
|
||||
int16_t ep = int16_t(ui.encoderPosition);
|
||||
ep = constrain(ep, 0, (LCD_PIXEL_WIDTH - (CANNON_W)) / (CANNON_VEL));
|
||||
int16_t ep = constrain(int16_t(ui.encoderPosition), 0, (LCD_PIXEL_WIDTH - (CANNON_W)) / (CANNON_VEL));
|
||||
ui.encoderPosition = ep;
|
||||
|
||||
ep *= (CANNON_VEL);
|
||||
|
@ -70,7 +70,7 @@ static void lcd_factory_settings() {
|
||||
return;
|
||||
}
|
||||
bar_percent += (int8_t)ui.encoderPosition;
|
||||
bar_percent = constrain(bar_percent, 0, 100);
|
||||
LIMIT(bar_percent, 0, 100);
|
||||
ui.encoderPosition = 0;
|
||||
draw_menu_item_static(0, PSTR(MSG_PROGRESS_BAR_TEST), true, true);
|
||||
lcd_moveto((LCD_WIDTH) / 2 - 2, LCD_HEIGHT - 2);
|
||||
|
Reference in New Issue
Block a user