Use ASCII symbols for control #195
Replies: 3 comments
-
Looks overall nice, I see one potential issue with the above code, what if I want to use printable chars to control the menu e.g. with WASD? The library was mane in such a way that the way you control it is up to you, whether you use push buttons, keyboard, rotary encoder etc. the library would just work, you would just read your command from your desired input and perform the desired action on the menu. It is more intuitive to the person that has their input method to just call those humanly readable functions, so as far as readability/understandability/maintainability goes to those using the library, I feel like it's better to give explicitly named functions.
Yes this is true, but in some cases, I want only some characters to be allowed, for example I want only odd numbers 13579, I can't pass an upper and lower bound, I have to explicitly define it. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Closing this as it is now Live as from v5.0.0, thanks @ShishkinDmitriy |
Beta Was this translation helpful? Give feedback.
-
Right now
MenuItem
andLcdMenu
have a bunch of methods:virtual void up() {};
virtual void down() {};
virtual void enter() {};
virtual void back() {};
virtual void left() {};
virtual void right() {};
virtual void backspace() {};
virtual void typeChar(const char character) {};
virtual void clear() {};
Proposal is to have 1 method
bool handle(const char c)
. Name can be different.It will decrease number of virtual methods.
Both printable and control symbols (https://en.wikipedia.org/wiki/ASCII#Control_code_chart) are suported in ASCII table, so it's possible to use just 1 char, 1 byte is enough.
Need just reserve 4 symbols for arrows - looks like there were no stadart way for them when ASCII was created. Device control 1,2,3,4 looks pretty good for this.
Also one of Charset item implementation can be simplified to have lower char and upper char:
Beta Was this translation helpful? Give feedback.
All reactions