neu-rah / ArduinoMenu

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

Combine data sel and menu sel #302

Open kapete23 opened 4 years ago

kapete23 commented 4 years ago

Hello Sir @neu-rah Can you help me? how to design the code to create a menu structure like this :

/////-----First Menu-----/////
// > Pin Name  Pin X     ///
//    Value  B10011101    ///
//    Enter value       ///
//    Show data     ///
//    Reset data        ///
//    Exit                  ///

“Enter value” functions as combining pin name and value. Example, Pin A : B10101111. Next will be stored in the data array (char data [4] = {...}). “Show data” functions as reading data from (char data [4] = {...}) and displaying data in the next menu.

/////-----Second Menu-----/////
///   > Pin A : B10011101   ////
///      Pin B : B11110001   ////
///      Pin C : B10010110   ////
///      Pin D : B11000001   ////
///      Count and convert   ////
///      Back                  ////

can we combine data sel and menu sel like the second menu above? Thanks.

neu-rah commented 4 years ago

Hi!

For those you probably don't need a special menu for edit, (maybe) you can use text fields , there are some on examples, with a mask allowing only "01" (binary). Provided that you do the conversion from the string to binary on the handler function and set the string every time you read the info from the ports.

menu will call the handler function on every change... enable update events to have differentiated enter and update events if desired

char* constMEM binDigits MEMMODE="01";
char* constMEM binMask[] MEMMODE={binDigits};
char portX[]="00000000";
...
//add this field to menu
,EDIT("PortX",portX,binMask,doNothing,noEvent,noStyle)

replace the doNothing by the name of your handler function and the noEvent mask by enterEvent

please note that i'm not compiling this... so it may need a tweak

EDIT("PortX",portX,binMask,binConvFunc,enterEvent,noStyle)

add as many fields needed, you can reuse the binMask and can make them with different sizes (mask is cyclic) you can also opt to not have an handler function and instead use an option to do the conversions when pressed.