neu-rah / ArduinoMenu

Arduino generic menu/interactivity system
GNU Lesser General Public License v2.1
929 stars 189 forks source link

Preventing the rotary encoder to cycle through #409

Closed dhysuiej closed 1 year ago

dhysuiej commented 1 year ago

I want a menu or numeric field to stop changing its value one it reaches the upper or lower limit in the range. Is that posible with the latest released version or would I need to change the corresponding classes?

keldonin commented 1 year ago

For both MENU and FIELD, use Menu::noStyle instead of Menu::wrapStyle for the last argument.

In the following example, both the menu and the "LED" field are constrained and do not wrap around.

MENU(mainMenu, "configuration", Menu::doNothing, Menu::noEvent, Menu::noStyle
  ,FIELD(pwmled,"LED","", 0,255,10,1,Menu::doNothing, Menu::noEvent, Menu::noStyle)
  ,EXIT("<Back")
);

It works for me, with the current library release.

dhysuiej commented 1 year ago

@keldonin thanks a lot.