neu-rah / ArduinoMenu

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

Using macros and custom strings #365

Open ACuppaJoes opened 3 years ago

ACuppaJoes commented 3 years ago

Hello

I was wondering if it was possible to use my own strings to later edit using the Edit macro. I would essentially like to be able to select a preset and also rename it using the menu. When I try to compile this code it, the compiler tells me "array must be initialized with a brace-enclosed initializer"

Does the SELECT macro not allow arguments pointing to custom strings?

const char* constMEM alphaNum MEMMODE=" 0123456789.ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz,\\|!\"#$%&/()=?~*^+-{}[]€";
const char* constMEM alphaNumMask[] MEMMODE={alphaNum};

String cust1="Custom 1";
String cust2="Custom 2";
String cust3="Custom 3";

int selPreset=0;
SELECT(selPreset,selPre,"Preset",doNothing,noEvent,wrapStyle
  ,VALUE(cust1,4,doNothing,noEvent)
  ,VALUE(cust2,5,doNothing,noEvent)
  ,VALUE(cust3,6,doNothing,noEvent)
polygonfuture commented 3 years ago

I was wondering something similar for FIELD objects "string" param.

For instance trying to use an extended ASCII character for a menu text:

I get "initializer fails to determine size of 'fieldLabel14'. My guess is because the macro is determining the size of the character array?

char* arrowUp = 30;

MENU(mainMenu, "Settings", doNothing, noEvent, wrapStyle
     , FIELD(dwellTop, arrowUp, " s", 5, 30, 1, 1, adjustDwellTop, enterEvent, wrapStyle)
     , EXIT("<  Sleep")
    );
ACuppaJoes commented 3 years ago

I don't think he checks the issues section regularly. I still haven't received a response but I am going to play around with the Target example. I think it might help us resolve this issue