Menu for Display

Hi Oliver,
so in my display mainly into my display I've:

{ "1:DEVICES", &el_num_menu },
{ "2:SET-TIMER", NULL },
{ ". 2-1:SpecifDate", &el_num_menu_timer },
{ ". 2-2:Weekly", &el_num_menu_timer_dw },
{ ". 2-3:Daily", &el_num_menu_timer_d },
{ ". 2-4:Working", &el_num_menu_timer_work },
{ "3:VIEW-TIMER", NULL },
{ ". 3-1:SpecifDate", &el_num_menu_timer_view },
{ ". 3-2:Weekly", &el_num_menu_timer_view_dw},
{ ". 3-3:Daily", &el_num_menu_timer_d_view },
{ ". 3-4:Working", &el_num_menu_timer_work_view },
{ "4:SETUP", &el_num_setup },
{ "5:DATE/TIME",&el_list_date },

where for entry into this list I press button, and for exit to welcome display i press another button as you explain :slight_smile:

so if you want i can collaborate with you without problem in this way i can understood better your library :slight_smile:

so yes another shortcut button i think will be ok i think, what do you think about that ?

Thanks
Gnux

Hi

I have added another home button (M2_KEY_HOME2, m2.setHome2(...)).

Oliver

m2tklib_arduino_lc_1.11pre1.zip (203 KB)

Thanks Oliver :wink: you are the number one :slight_smile: I will try it :slight_smile: ... and then i'll let you know :slight_smile:

from your point of view and experience ... if in a future i would like to implement another kind of display for example touch screen :slight_smile: what do you suggest to use :wink: ?

Thanks and nice week end,
Gnux

Hi

M2tklib has touch screen support. I did tests with U8glib, a dogm128 display and the touch screen mentioned in the data sheet of the dogm128: http://www.lcd-module.com/eng/pdf/grafik/dogm128e.pdf

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.

The components from here http://www.lcd-module.com/eng/pdf/grafik/dogm128e.pdf are known to work.

Oliver

Good Morning Oliver,
I've request a quotation :wink: for the display suggested by you :slight_smile:

this evening i'll let you know about modification that you have did to the library because I will test it :wink:

thanks you very much,
gnux

Ciao Oliver,
I've order the display touch indicate from you :slight_smile: after the vacation i will try install it maybe i will need more help :slight_smile: however i will beat my
head in front the situation and only after i will ask help :wink: ...

So another thing that I've in mind is do a voltmeter :slight_smile: but I would like to put the result on a graphic do you think is possible ?

http://arduinoprojects101.com/arduino-voltmeter/

my idea is put on the y the V and on the x the time for example one minute and do a line of the graphic trend but here i really don't know from start

Thansk for all your support,
regards,
Gnux

Hi

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 ...

m2.setPin(M2_KEY_HOME2,uiKeyDevPin);
m2.setHome2(&el_num_menu);

what could i check ?

thanks
gnux

Thanks for reporting. There was a small bug, which is fixed in the attached release.

Oliver

m2tklib_arduino_lc_1.11pre2.zip (203 KB)

Ciao Oliver,
sorry for the late but I was out of home I wasn't to work :frowning: ...

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 ?

thanks
Andrea

Hi

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
     }

See the also Google Code Archive - Long-term storage for Google Code Project Hosting.

Still amazing thread. I think you must have been used all the features of m2tklib until now... :astonished:

Oliver

Wonderful :slight_smile: Thanks it's working :slight_smile: i post you the code :slight_smile:

 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 :slight_smile: 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 :slight_smile: ... 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 :slight_smile:

Thanks again Oliver :slight_smile: number one without you I was lost :slight_smile: . 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 :slight_smile: for me and for other that use this fantastic library

Gnux

Ciao Oliver,
I take the opportunity to say to you " ... feast of the assumption :slight_smile: "

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 :slight_smile:

regards,
Gnux

Hi

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:

  1. 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!
  2. 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)

Oliver

Ciao Oliver,

how ever thanks :slight_smile:

I will double ramp message and then I'll let you know :slight_smile:

I'll modify the value into virtual wire library and I'll let you know

thansk again
Gnux

I think i made a small typing error. I wanted to write:

  1. 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!

Oliver

Ciao Oliver,
thanks so I've tried something ... like your suggestion ... so

  1. 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 ...

If you have any suggestion :wink: I very appreciate it :slight_smile:

Thanks
Gnux

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.

Oliver

Hi Oliver,
Ok :slight_smile: I've understand what you mean :slight_smile: ... 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 ?

Thanks
Gnux

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:

  if ( m2.handleKey() || display_update_required ) {
    m2.draw();
    display_update_required = 0;
  }

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.

Oliver