Ciao Oliver,
I've just tried to do this simple try with a simple combo example ... below the code:
#include <LiquidCrystal.h>
#include "M2tk.h"
#include "utility/m2ghlc.h"
LiquidCrystal lcd(10, 9, 3, 2, 1, 0);
uint8_t uiKeySelectPin = 22;
uint8_t uiKeyNextPin = 26;
uint8_t select_color = 0;
uint8_t select_priority = 0;
void fn_ok(m2_el_fnarg_p fnarg) {
/* accept selection */
}
void fn_cancel(m2_el_fnarg_p fnarg) {
/* discard selection */
}
const char *fn_idx_to_color(uint8_t idx)
{
if ( idx == 0 )
return "red";
else if (idx == 1 )
return "green";
return "blue";
}
const char *fn_idx_to_priority(uint8_t idx)
{
switch(idx)
{
case 0: return "lowest";
case 1: return "low";
case 2: return "medium";
case 3: return "high";
case 4: return "highest";
}
return "";
}
M2_LABEL(el_label1, NULL, "Color:");
M2_COMBO(el_combo1, NULL, &select_color, 3, fn_idx_to_color);
M2_LABEL(el_label2, NULL, "Prio.: ");
M2_COMBO(el_combo2, "v1", &select_priority, 5, fn_idx_to_priority);
M2_BUTTON(el_cancel, NULL, "cancel", fn_cancel);
M2_BUTTON(el_ok, NULL, " ok ", fn_ok);
M2_LIST(list) = {
&el_label1, &el_combo1,
&el_label2, &el_combo2,
&el_cancel, &el_ok
};
M2_GRIDLIST(list_element, "c2",list);
M2tk m2(&list_element, m2_es_arduino, m2_eh_2bs, m2_gh_lc);
void setup() {
m2_SetLiquidCrystal(&lcd, 20, 4);
m2.setPin(M2_KEY_SELECT, uiKeySelectPin);
m2.setPin(M2_KEY_NEXT, uiKeyNextPin);
}
void loop() {
if ( m2.getRoot() == &m2_null_element ) {
if ( m2.getKey() != M2_KEY_NONE )
m2.setRoot(&list_element);
}
}
When I push button nothing appears I've tried from serial menu also but nothing appears... so now I've a trouble ...
into the condition
m2.getRoot() == &m2_null_element
is necessary to assign "&m2_null_element" into the setup ? if yes is there particular sintax to follow ?
because looking the sketch there is no assignment for and then the condition will be never verified right ?
thanks
gnux