Go Down

Topic: Simple menu m2tklib with example. (Read 3 times) previous topic - next topic

AVR_BY

Yes, GLCD lib. Mega2560 board.
Also i think to buy a DUE with 7' TFT display, and i am waiting for, when you build a m2tk lib for this things.
Look please:
http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=111008432389
PS. i downloaded the prerelease, great thanks.
If you don't mind, i will ask about other troubles with my project.


olikraus

Nice, but currently for M2tklib there is no low level graphics driver for the SSD1963

Oliver

AVR_BY

Dear Oliver, could you give me please the working example code? I tried to understand functions that you gave, but i see only a lot of warning :( It takes for you 5 minutes, and i can move next step of my project. I will be glad to see the example based on menu2L, or something like this.
Thank you.


olikraus

Hi

To write some code i need a more detailed specification. Let us start with the temperature. Do you want to display "in" and "out" temperature? Or do you need to edit and enter some target temperature?
Do you have some specific menu layout in mind?

Another question: Did you manage to compile an run other examples from m2tklib?

Oliver

AVR_BY

The menu structure should be something like this:
Code: [Select]

#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;


//=================================================
// Forward declaration of the toplevel element
M2_EXTERN_ALIGN(top_el_spacecb_menu);

uint8_t el_space_u8 = 0;

void FP_v(m2_el_fnarg_p fnarg) {
// show screen with my A0 pin value
}

void FFP_r(m2_el_fnarg_p fnarg) {
// show screen with my A1 pin value
}

void Temp(m2_el_fnarg_p fnarg) {
  // show screen with my A5 pin value
}

// other voids that show any values



//M2_SPACECB(el_space_cb_zero, NULL, FFP_v);
//M2_SPACECB(el_space_cb_inc, NULL, FFP_r);
//M2_SPACECB(el_space_cb_dec, NULL, Temp);

// 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_spacecb_menu },
  { ". res", &top_el_spacecb_menu},
  { "Temp",    &top_el_spacecb_menu },
// 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_spacecb_menu, "-1|1W64H64", &el_hlist);

// m2 object and constructor
M2tk m2(&top_el_spacecb_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() {
  m2.checkKey();
  if ( m2.handleKey() ) {
      m2.draw();
  }
}


By now, i don't need to input any values. Perhaps in the future.

So, could you please correct the code to show, how can i call my voids.
Thank you.

Go Up