Spirik / GEM

Good Enough Menu for Arduino
GNU Lesser General Public License v3.0
239 stars 36 forks source link

GEM_VAL_CHAR edition DEC HEXA #48

Closed Speedjf37 closed 2 years ago

Speedjf37 commented 2 years ago

Howto Add a parameter to limit caractere value ?

Normal all code

DEC 0 to 9 HEXA 0 to F

bonus TEXT a to Z

Thanks for the job !!!

JF

Spirik commented 2 years ago

Hi, JF!

Unfortunately, at the moment there is no explicit setting to limit character input values as you described. Although it is an interesting suggestion! I will look into it and consider adding these options to char[17] menu item in the future.

In the mean time the closest thing you can get to the described behavior (without editing source code of the library) is to validate input value via callback and update it accordingly (e.g. write callback function that will check entered HEX value for any unsupported characters and do something with it to fix it).

Thank you for your interest in GEM library!

Speedjf37 commented 2 years ago

Hi , Simple Callback for DEC:

void Action_STR_DEC() { for (n=0;n<strlen(str_Dec);n++) { if (str_Dec[n] > '9') str_Dec[n]='9'; if (str_Dec[n] < '0') str_Dec[n]='0'; } }

Not simple for HEXA

JF