From c5d5c375fdee7c4912b22e717caa82465ce6ccf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Fri, 24 Feb 2023 03:29:47 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Reduce=20edit=5Fscreen=20c?= =?UTF-8?q?ode=20size=20(#25420)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/menu/menu.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Marlin/src/lcd/menu/menu.cpp b/Marlin/src/lcd/menu/menu.cpp index 7f55f79f03..c529ae757a 100644 --- a/Marlin/src/lcd/menu/menu.cpp +++ b/Marlin/src/lcd/menu/menu.cpp @@ -117,8 +117,7 @@ void MenuEditItemBase::edit_screen(strfunc_t strfunc, loadfunc_t loadfunc) { // Reset repeat_delay for Touch Buttons TERN_(HAS_TOUCH_BUTTONS, ui.repeat_delay = BUTTON_DELAY_EDIT); // Constrain ui.encoderPosition to 0 ... maxEditValue (calculated in encoder steps) - if (int32_t(ui.encoderPosition) < 0) ui.encoderPosition = 0; - if (int32_t(ui.encoderPosition) > maxEditValue) ui.encoderPosition = maxEditValue; + ui.encoderPosition = constrain(int32_t(ui.encoderPosition), 0, maxEditValue); // If drawing is flagged then redraw the (whole) edit screen if (ui.should_draw()) draw_edit_screen(strfunc(ui.encoderPosition + minEditValue));