Thanks Oliver you are the number one I will try it ... and then i'll let you know
from your point of view and experience ... if in a future i would like to implement another kind of display for example touch screen what do you suggest to use ?
In general almost no effort is required for resistive touch screens, u8glib and m2tklib, so my suggestion is to look for a graphics display, which is supported by u8glib and has a resistive touch screen.
Ciao Oliver,
I've order the display touch indicate from you after the vacation i will try install it maybe i will need more help however i will beat my
head in front the situation and only after i will ask help ...
So another thing that I've in mind is do a voltmeter but I would like to put the result on a graphic do you think is possible ?
First: Sample the values over some time and store the values in an array:
for( i = 0; i < 100; i++ )
array = analogRead(...) Second: Plot the array over time for( i = 0; i < 100; i++ )
u8g.drawPixel(i, display_height-1-array(i));* Oliver
Good Morning Oliver, just come back from my vacation I've tried to use the new library version with the other shortcut like did for the other but seems is not working... I've tried also to change the button in case of broken but was ok ...
Ciao Oliver,
sorry for the late but I was out of home I wasn't to work ...
So I've tried and now the library seems it's working ... but I've a trouble ...
so it's pass a little bit time but i try to explain you ... i'm loop I've this:
if ( m2.getRoot() == &m2_null_element )
{
digitalWrite(13, HIGH);
// yes, it is our manual written screen
// place your manual commands here
lcd.setCursor(1, 2);
lcd.print("*Home Sweet Home*");
digitalClockDisplay();
// check if the user has pressed a key while manual screen is active
if ( m2.getKey() != M2_KEY_NONE )
{
digitalWrite(13, LOW);
m2.setRoot(&top_el_expandable_menu); // refer to a suitable menu
}
}
// do normal menu display
m2.checkKey();
if ( m2.handleKey() ) {
m2.draw();
}
right now I press a button i can entry into the menu ... because the condition is verified ...
I've tried to change this structure in order to when I press a shortcut button i can entry into the menu ... but without success ...I've did something like this ...
if ( m2.getKey() != M2_KEY_NONE )
{
if (m2.getKey() == M2_KEY_HOME2) --> new shortcut
{
digitalWrite(13, LOW);
m2.setRoot(&el_num_menu); // refer to a suitable menu
}
digitalWrite(13, LOW);
m2.setRoot(&top_el_expandable_menu); // refer to a suitable menu
}
but due the fact I've strange result ... could you ask kindly where I m wrong from your point of view ?
getKey() will remove the event from the queue. So any other call to getKey() will return NONE or another key. You must only call getKey() once, store the result and then check for the key:
uint8_t key = m2.getKey();
if ( key != M2_KEY_NONE )
{
if (key == M2_KEY_HOME2) --> new shortcut
{
digitalWrite(13, LOW);
m2.setRoot(&el_num_menu); // refer to a suitable menu
}
digitalWrite(13, LOW);
m2.setRoot(&top_el_expandable_menu); // refer to a suitable menu
}
if ( key != M2_KEY_NONE )
{
if (key == M2_KEY_HOME2)
{
digitalWrite(13, LOW);
m2.setRoot(&el_num_menu); // refer to a suitable menu
}
else
{
digitalWrite(13, LOW);
m2.setRoot(&top_el_expandable_menu); // refer to a suitable menu
}
}
you have reason it's a very long topic but I think that if a person will need to use m2tklib i think that if will search on the forum it's a very great example how to use this library ... I think this is the very real forum sense ...
Look into the forum the solution,
try, if not ok
ask
and give back the feed back, behind that i think there is respect
Thanks again Oliver number one without you I was lost . When will arrive the other display I'll try and I'll you know ...
When Will be finished the project I would like to a summary of this topic in order to a have a small guide for me and for other that use this fantastic library
Ciao Oliver,
I take the opportunity to say to you " ... feast of the assumption "
so waiting the other display I was tuning my communication inside my project. Mainly in my project I'm using your library M2TKLIB and Virtual Wire Library, well basically I've a menu from where I send out data and I wait the answer. happen sometimes that I miss the answer back and then I need to transmit back the message again. With re-transmission it's ok. but I was trying to lose less message is possible.
Removing Display and doing a simple program that transmit and receive it's everything ok. Why your great experience what could i check in order to fix the issues ?
So I've a procedure that is called on the "OK" button from the menu. Is there any pause, delay at low level into display library ?
How ever thanks for the support, i will try also by my self to discovered and fix the issues
m2.draw() might take some time. Not knowing virtual wire at all, maybe the following ideas might help or at least the should be checked:
ensure that there are no pending messages before calling m2tklib.draw(). That means you need to call m2tklib.draw() as long as vw_have_message() returns true. Read and handle messages until vw_have_message() returns false!
Maybe you can increase the internal message buffer. Maybe double the value of VW_RX_RAMP_LEN from 160 to 320 (if there is enough RAM available)
I think i made a small typing error. I wanted to write:
ensure that there are no pending messages before calling m2tklib.draw(). That means you need to call vw_get_message() as long as vw_have_message() returns true. Read and handle messages until vw_have_message() returns false!
Ciao Oliver,
thanks so I've tried something ... like your suggestion ... so
m2.draw(); is called when I push a button
m2.checkKey();
if ( m2.handleKey() ) {
m2.draw();
}
then inside that I decide from a menu when send out a message, so what I doing is sendout message and then call a procedure for wait the answer
if (vw_wait_rx_max(2000))
{
if (vw_get_message(buf, &buflen)) // Non-blocking
{
msgrx = buf[0];
}
}
in this case I think (please correct me if i wrong) that m2.draw(); is already running
I've tried also to modify into the library the VW_RX_RAMP_LEN from 160 to 320 i think there isn't ram issues because i didn't have error from this stand point but the devices are not synchronized ... to be honest I didn't understand the scope of VW_RX_RAMP_LEN (ok I've understand that is a something like buffer but not exactly what is doing ...) ...
Is strange because due the fact I'm already inside the menu and inside the procedure that I call I've the TX and RX like in the example of virtual wire ......
Ok I've the RE-TRY transmission procedure but should be used only a extreme cases ...
Well, i have no idea about that virtual wire library.
I was thinking that something like
m2.checkKey();
// read and process all messages...
while( vw_have_message() )
{
if (vw_get_message(buf, &buflen)) // Non-blocking
{
... // handle message
}
}
// ... before any redraw
if ( m2.handleKey() ) {
m2.draw();
}
might solve the problem.
But this is just an idea.
Hi Oliver,
Ok I've understand what you mean ... but I was thinking ...
the fact the transmission part is inside the menu ... than should be already draw the menu or the menu is re-draw each time ? so for example when I press the ok button after I go to the previuos level and in this way after I can see the label changing based on the devices state ... in this time the menu is re-draw or is draw only one time ?
You are in the Arduino loop(). Inside this loop you see this code:
if ( m2.handleKey() ) {
m2.draw();
}
This means: Whenever you pressed a button, the menu will be redrawn.
You might have additional sources, which might require redraw. For example if you receive a message with an information which should be displayed, then this might also require a redraw:
With this expanded code, whenever you set display_update_required to 1, it will refresh the screen once.
Not sure if i really answered your question. All in all, m2.draw() just draws the screen and then returns back to your program.