Go Down

Topic: M2TKLIB - A User-Interface-Toolkit for the Arduino Hardware (Read 12155 times) previous topic - next topic

Hmm, it's good to know, it may come handy later on. I'll report back with the results.

By the way, it would be useful to revise the description of VSB element:
"The vertical scroll bar is an element which is usually used together with STRLIST or INFO elements. VSB will display a vertical scroll bar."
Actually VSB works _only_ with STRLIST or INFO elements. And of course with Menu(X)2L, but that's automatically implemented.
This may help others.

olikraus

Regarding VSB element you are probably right.

With the M2_HIDE: If you place M2_HIDE inside an XYLIST, the size of M2_HIDE should not matter. Infact child elements of XYLIST may overlap.

Oliver

km77

Hi all!
Could anybody explain how to execute user function from menu?

It would be great if some one show on sample.

Thanks

olikraus

Hi

You can use M2_BUTTON. M2_BUTTON will call a user function unce the button is selected.

The M2_SPACECB will call a user function at startup of the dialog.

Finally you can apply a user function when a dialog gets replaced by another dialog:

https://code.google.com/p/m2tklib/wiki/fnref#setRootChangeCallback

Oliver

Greetings Oliver,

Is there any progress regarding function S32NUMFN?
https://code.google.com/p/m2tklib/issues/detail?id=132

Thank you

olikraus

Hi

I have not received any further code.
All in all i do not have much time for M2tklib at the moment :-(

Oliver

km77

Thank you olikraus
Could You explain on Sample MenuX2L?
I'd like to execute MyFunction() when I push button "OK" on "Sub 2-1"
What should i do?

And how to return from MyFunction() to previous place of menu?

olikraus

Hi

I have one example here:
https://code.google.com/p/m2tklib/source/browse/arduino/u8g/MenuX2L/MenuX2L.pde

The example contains this menu:
Code: [Select]

m2_xmenu_entry xmenu_data[] =
{
  { "Menu 1", NULL, NULL },             /* expandable main menu entry */
  { ".", NULL, xmenu_value },           /* The label of this menu line is returned by the callback procedure */
  { ". Inc", NULL, xmenu_inc },         /* This callback increments the value */
  { ". Dec", NULL, xmenu_dec },         /* This callback decrements the value */
  { "Menu 2", NULL, NULL },
  { ". Sub 2-1", &top_el_mnu1_sel, NULL },
  { ". Sub 2-2", &top_el_mnu2_sel, NULL},
  { ". Sub 2-3", &top_el_mnu3_sel, NULL },
  { NULL, NULL, NULL },
};


Assume you have this function:

Code: [Select]
const char *my_fn(uint8_t idx, uint8_t msg) {
  if ( msg == M2_STRLIST_MSG_SELECT  ) {
    // do something
  }
  return "";
}


Then my_fn will be called for sub 2-1 , if you apply my_fn instead of NULL as third argument:

Code: [Select]

m2_xmenu_entry xmenu_data[] =
{
  { "Menu 1", NULL, NULL },             /* expandable main menu entry */
  { ".", NULL, xmenu_value },           /* The label of this menu line is returned by the callback procedure */
  { ". Inc", NULL, xmenu_inc },         /* This callback increments the value */
  { ". Dec", NULL, xmenu_dec },         /* This callback decrements the value */
  { "Menu 2", NULL, NULL },
  { ". Sub 2-1",NULL, my_fn },
  { ". Sub 2-2", &top_el_mnu2_sel, NULL},
  { ". Sub 2-3", &top_el_mnu3_sel, NULL },
  { NULL, NULL, NULL },
};


Oliver


jmcl

Hello all,

I'm evaluating menu systems for a project. Things are looking good with MENWIZ but I would really like to try M2tklib.
As a proof of concept I would like to build a simple menu like I did with MENWIZ. I took a quick look at the examples (plan to dedicate more time to this topic) and it does seem immediate (true, I have not invested enough time yet).
What would be the best example to achieve the same result as below (sample code for is for MENWIZ).
Thank you.

Code: [Select]
// ---------------------------------------------------------------------------------------------
// Start Sample Menu code.
// ---------------------------------------------------------------------------------------------
const int UP_BOTTON_PIN=6;
const int DOWN_BOTTON_PIN=7;
const int ESCAPE_BOTTON_PIN=8;
const int CONFIRM_BOTTON_PIN=9;

menwiz menu;
int serialSpeed=4;

void init_menu_system() {
 menu.begin(&lcd,16,2);
}

void build_menu_tree() {
 _menu *root,*sub1;
 
 root=menu.addMenu(MW_ROOT,NULL,F("Menu"));
 sub1=menu.addMenu(MW_VAR,root,F("COM Speed"));
   sub1->addVar(MW_LIST,&serialSpeed);
   sub1->addItem(MW_LIST,F("4800 bit/s"));
   sub1->addItem(MW_LIST,F("9600 bit/s"));
   sub1->addItem(MW_LIST,F("19200 bit/s"));
   sub1->addItem(MW_LIST,F("38400 bit/s"));
   sub1->addItem(MW_LIST,F("57600 bit/s"));
   sub1->addItem(MW_LIST,F("115200 bit/s"));
}

void set_menu_buttons() {
 menu.navButtons(UP_BOTTON_PIN,DOWN_BOTTON_PIN,ESCAPE_BOTTON_PIN,CONFIRM_BOTTON_PIN);
}

void menu_system_setup() {
 init_menu_system();
 build_menu_tree();
 set_menu_buttons();
}

void setup() {
 menu_system_setup();
}

void loop() {
 menu.draw();
}
// ---------------------------------------------------------------------------------------------
// End Sample Menu code.
// ---------------------------------------------------------------------------------------------

olikraus

You could use the M2_COMBO element (see the Combo example in m2tklib). However, the F() macro is not supported at the moment.

Oliver

Code: [Select]
uint8_t com_speed = 4;

const char *fn_idx_to_com_speed(uint8_t idx)
{
  switch(idx)
  {
    case 0: return "4800 bit/s";
    case 1: return "9600 bit/s";
    case 2: return "19200 bit/s";
    case 3: return "38400 bit/s";
    case 4: return "57600 bit/s";
    case 5: return "115200 bit/s";
  }
  return "";
}

M2_COMBO(el_com_speed_combo, NULL, &com_speed, 6, fn_idx_to_com_speed);

kb1sph

Hi, I'm trying to use this library with LiquitCrystal_I2C and the Menu2L example, and I get this error every time I try compiling it.

Menu2L.ino: In function 'void setup()':
Menu2L.ino:80:34: error: cannot convert 'LiquidCrystal_I2C*' to 'LiquidCrystal*' for argument '1' to 'void m2_SetLiquidCrystal(LiquidCrystal*, uint8_t, uint8_t)'
Error compiling.

Any suggestions?  Let me know if you need more info.  I'm pretty new to this.

Thanks in advance!

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy