Hello,
I'm using the M2TKLib for over a year now and I'm still really happy about this nice piece of flexible software.
However, at the moment I have some strange problem, I cannot solve myself.
To make the description as short as possible:
I have a device that collects data when a key is pressed. The data and the number of measurement are displayed on the screen after measurement is completed.
My problem is, that the number of the measurement is displayed immediately after the measurement. The measured data itself is only displayed, when I click one of the available keys again.
Both are displayed as M2_LABEL. The problem is not connected with the type of data displayed, as when I replace the variable containing the measurement data with the variable containing the number of measurement the same effect can be observed (That means I see the measurement number two times on the screen. One immediately, one after I click some key).
For updating the screen I have this routine in a function called update_UI(), which is called in loop().
m2.checkKey();
if (m2.handleKey() || redraw_Flag == true) {
_update_strings();
u8g.firstPage();
do {
m2.draw();
} while (u8g.nextPage());
redraw_Flag = false;
}
Note, redraw_Flag is used to refresh the screen after the measurement is processed.
The strange thing is, that this program worked before. And I did not change the code connected with the display of the measurement data.
As I'm aware that his is very incomplete information, I would like to pose some question, that I think might help me.
When is the function m2.handleKey() not zero?
Why is it not possible to execute
u8g.firstPage();
do {
m2.draw();
} while (u8g.nextPage());
without calling m2.handleKey() first?
Is it possible to only refresh part of a menu structure?
Below I have printed the menu structure of the respective menu that is not working.
Obviously there is more shown than Measurement and Number of Measurement. I omitted the rest in my explanation for clarity. s_value is the string for the measurement. s_number_meas is the string for the number of measurements.
By the way, the program is running on Teensy 3.2, in Arduino 1.65-r5 with teensyduino 1.27.
Thank you for reading!
/*---------------------------------------------------------------------------------*/
/* Messoberfläche */
/*---------------------------------------------------------------------------------*/
//Header
M2_LABEL(el_Messen_label1, "f1x4y1", Kalibrierung_aktiv.Name);
M2_XBMLABELP(el_Messen_xbmlabel1, "h5w5x110y3", BATTERY_WIDTH, BATTERY_HEIGHT,
battery_status);
M2_LIST(list_Messen_list1) = {&el_Messen_xbmlabel1,&el_Messen_label1};
M2_XYLIST(list_Messen_list1_xylist, NULL, list_Messen_list1);
// Center
M2_LABEL(el_Messen_label3, "f2", symbol_upper_limit);
M2_ALIGN(el_Messen_label3_algn, "-1|1w11h12", &el_Messen_label3);
M2_LABEL(el_Messen_label3a, "f2", symbol_in_limits);
M2_ALIGN(el_Messen_label3a_algn, "-2|1w11h12", &el_Messen_label3a);
M2_LABEL(el_Messen_label3b, "f2", symbol_lower_limit);
M2_ALIGN(el_Messen_label3b_algn, "-1|1w11h12", &el_Messen_label3b);
M2_LIST(list_Messen_list1b) = {&el_Messen_label3_algn,&el_Messen_label3a_algn,&el_Messen_label3b_algn};
M2_VLIST(list_Messen_list1b_vlist, NULL, list_Messen_list1b);
M2_LABEL(el_Messen_label3c, "f0", onept_kali);
M2_ALIGN(el_Messen_label3c_algn, "-1|0w17h12", &el_Messen_label3c);
M2_LABEL(el_Messen_label3d, "f0", twopt_kali);
M2_ALIGN(el_Messen_label3d_algn, "-1|0w17h12", &el_Messen_label3d);
M2_LIST(list_Messen_list1c) = {&el_Messen_label3c_algn,&el_Messen_label3d_algn};
M2_VLIST(list_Messen_list1c_vlist, NULL, list_Messen_list1c);
M2_LABEL(el_Messen_label4, "f3", s_value);
M2_LABEL(el_Messen_label5, "f1", units);
M2_LIST(list_Messen_lista) = {&el_Messen_label4,&el_Messen_label5};
M2_HLIST(el_Messen_lista_hlist, NULL, list_Messen_lista);
M2_ALIGN(el_Messen_lista_hlist_algn, "-2|1w100h36", &el_Messen_lista_hlist);
M2_LIST(list_Messen_list2) = {&list_Messen_list1b_vlist,&list_Messen_list1c_vlist,&el_Messen_lista_hlist_algn};
M2_HLIST(el_Messen_list2_hlist, NULL, list_Messen_list2);
//Bottom
M2_LABEL(el_Messen_label55, "f0", "N=");
M2_LABEL(el_Messen_label6, "f0", s_number_meas);
M2_LIST(list_Messen_list25) = {&el_Messen_label55,&el_Messen_label6};
M2_HLIST(list_Messen_hlist25, NULL, list_Messen_list25);
M2_ALIGN(el_Messen_label6_algn, "-0|1h13w30", &list_Messen_hlist25);
M2_LABEL(el_Messen_label8, "f0", s_statistics);
M2_ALIGN(el_Messen_list3_hlist_algn, "-2|1h13w98", &el_Messen_label8);
M2_LIST(list_Messen_list4) = {&el_Messen_label6_algn,&el_Messen_list3_hlist_algn};
M2_HLIST(list_Messen_list4_hlist, FOOTER_FORMAT_MEASURE, list_Messen_list4);
M2_LIST(Messen_list) = {&list_Messen_list1_xylist, &el_Linie, &el_Messen_list2_hlist, &el_Linie, &list_Messen_list4_hlist};
M2_VLIST(top_el_Messen, NULL, Messen_list);