Hi Oliver. I'd like to see realtime values from sensor. For example, takes an A0.
I use a code, gived me early:
#include <glcd.h> // inform Arduino IDE that we will use GLCD library
#include "M2tk.h"
#include "utility/m2ghglcd.h"
uint8_t uiKeySelectPin = 53;
uint8_t uiKeyDownPin = 45;
uint8_t uiKeyUpPin = 47;
uint8_t uiKeyExitPin = 51;
//=================================================
uint32_t value_from_A0;
uint32_t value_from_A1;
uint32_t value_from_A5;
//=================================================
// Forward declaration of the toplevel element
M2_EXTERN_ALIGN(top_el_menu);
// show screen with my A0 pin value
M2_LABEL(el_a0_label, NULL, "A0");
M2_U32NUM(el_a0_u32, "c4r1", &value_from_A0);
M2_ROOT(el_a0_ok, NULL, " ok ", &top_el_menu);
M2_LIST(list_a0) = { &el_a0_label, &el_a0_u32, &el_a0_ok };
M2_VLIST(el_a0_vlist, NULL, list_a0);
M2_ALIGN(top_el_a0, "-1|1W64H64", &el_a0_vlist);
// show screen with my A1 pin value
M2_LABEL(el_a1_label, NULL, "A1");
M2_U32NUM(el_a1_u32, "c4r1", &value_from_A1);
M2_ROOT(el_a1_ok, NULL, " ok ", &top_el_menu);
M2_LIST(list_a1) = { &el_a1_label, &el_a1_u32, &el_a1_ok };
M2_VLIST(el_a1_vlist, NULL, list_a1);
M2_ALIGN(top_el_a1, "-1|1W64H64", &el_a1_vlist);
// show screen with my A5 pin value
M2_LABEL(el_temperature_label, NULL, "Temperature");
M2_U32NUM(el_temperature_u32, "c4r1", &value_from_A5);
M2_ROOT(el_temperature_ok, NULL, " ok ", &top_el_menu);
M2_LIST(list_temperature) = { &el_temperature_label, &el_temperature_u32, &el_temperature_ok };
M2_VLIST(el_temperature_vlist, NULL, list_temperature);
M2_ALIGN(top_el_temperature, "-1|1W64H64", &el_temperature_vlist);
// other voids that show any values
// Left entry: Menu name. Submenus must have a '.' at the beginning
// Right entry: Reference to the target dialog box (In this example all menus call the toplevel element again
m2_menu_entry m2_2lmenu_data[] =
{
{ "FFP", NULL },
{ ". volt", &top_el_a0 },
{ ". res", &top_el_a1},
{ "Temp", &top_el_temperature },
// etc..
{ NULL, NULL },
};
// The first visible line and the total number of visible lines.
// Both values are written by M2_2LMENU and read by M2_VSB
uint8_t m2_2lmenu_first;
uint8_t m2_2lmenu_cnt;
// M2_2LMENU definition
// Option l4 = four visible lines
// Option e15 = first column has a width of 15 pixel
// Option W43 = second column has a width of 43/64 of the display width
M2_2LMENU(el_2lmenu,"l4e15W43",&m2_2lmenu_first,&m2_2lmenu_cnt, m2_2lmenu_data,'+','-','\0');
M2_SPACE(el_space, "W1h1");
M2_VSB(el_vsb, "l4W2r1", &m2_2lmenu_first, &m2_2lmenu_cnt);
M2_LIST(list_2lmenu) = { &el_2lmenu, &el_space, &el_vsb };
M2_HLIST(el_hlist, NULL, list_2lmenu);
M2_ALIGN(top_el_menu, "-1|1W64H64", &el_hlist);
// m2 object and constructor
M2tk m2(&top_el_menu, m2_es_arduino, m2_eh_4bs, m2_gh_glcd_ffs);
void setup() {
m2.setPin(M2_KEY_SELECT, uiKeySelectPin);
m2.setPin(M2_KEY_NEXT, uiKeyDownPin);
m2.setPin(M2_KEY_PREV, uiKeyUpPin);
m2.setPin(M2_KEY_EXIT, uiKeyExitPin);
}
void loop() {
value_from_A0 = analogRead(A0);
value_from_A1 = analogRead(A1);
value_from_A5 = analogRead(A5);
m2.checkKey();
if ( m2.handleKey() ) {
m2.draw();
}
}
So it works but. The values updates if i only push any buttons. Is any solution to see in real time any values?
Thx.