Pages: 1 ... 7 8 [9] 10 11 ... 13   Go Down
Author Topic: Menu for Display  (Read 10690 times)
0 Members and 1 Guest are viewing this topic.
Germany
Offline Offline
Edison Member
*
Karma: 100
Posts: 1223
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If i understand you correctly, then your question is, how to save memory?

Regarding m2tklib, here are some ideas:

- Format string
  * use NULL instead of ""
  * reuse format strings:
     instead of M2_ALIGN(top_el_sisu_m1, "W64H64", &el_sisu_grid_m1);
     do this:
Code:
char fmt_W64H64[] = "W64H64";
M2_ALIGN(top_el_sisu_m1, fmt_W64H64, &el_sisu_grid_m1);
 
     reuse the format string as often as possible
- Reuse elements: Once you have definde a BUTTON, you can reuse the button everywhere
  See also here: http://code.google.com/p/m2tklib/issues/detail?id=89
- Limit the number of different elements.

Maybe this gives some ideas. Please note, that a graphics library, such as u8glib will probably require more space than a LiquidCrystal

Oliver
 
Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 407
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok :-) Thanks for the information,
I can use your suggest for the separator like /, :,
for the xy also :-)

Thanks you :-)
gnux
Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 407
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Oliver, sorry if i disturb you again... so now after to have develop a lot's of code a take the confidence with your library Im in fill in a "Black Hole" ... Now I've did a menu for put all timers ...

Now i need to build a menu for view a data stored into my byte array[][] ... I've tried to use a label technique but due the fact the value are stored like byte ... is there another way for retrieve this value ? I don't remember how to assign the value to M2_U8NUM elements ...

for example with the menu below reported I stored the value inside my array
----------------------------
DEV: 00  WDay:   START
BATHRO  monda   10:00
ST:On          STOP:
       Ok bk       12:15
---------------------------
array[u8dev][0] = 00;
array[u8dev][20] = 2 (monday)
array[u8dev][19] = 1; (on)
array[u8dev][21] = 10; (hour start)
array[u8dev][22] = 00; (minutes start)
array[u8dev][23] = 12; (hour stop)
array[u8dev][24] = 15; (minutes stop)

now I would like the same menu with the same element that when I changed dev I see the value that I've put into the array but in readonly ... for see how i've set the timer ...

It's a couple of days that i put the head again this ... idea ?

thanks for the support,
gnux
« Last Edit: March 04, 2013, 09:37:59 am by gnusso » Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 407
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi I've tried something like this :

const char *label_test(m2_rom_void_p element)

  char s[4];
  sprintf(s,  "%02d", array[u8dev][4]);
  Serial.println(s);   // or LCD.print(s);
  return s;
}

then call M2_LABELFN(el_v_Timer_test, "x3y1", label_test);

but in serial monitor the value change correctly but not into the menu ...
Logged

Germany
Offline Offline
Edison Member
*
Karma: 100
Posts: 1223
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi

The code contains a programming error, use this:
Code:
const char *label_test(m2_rom_void_p element)
{
  static char s[4];
  sprintf(s,  "%02d", array[u8dev][4]);
  Serial.println(s);   // or LCD.print(s);
  return s;
}

Then, i would strongly suggest to read tutorial 8: http://code.google.com/p/m2tklib/wiki/t08

Oliver
Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 407
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you oliver now it's working :-) great ! thanks you ...

so using mega I've added more button because of course is more confortable like below:
Code:

     uint8_t uiKeySelectPin = 36; // Button: Select (Pin:36)
     uint8_t uiKeyNextPin = 38;   // Button: Next   (Pin:38)
     uint8_t uiKeyHomePin = 40;   // Button: Home   (Pin:40)
     uint8_t uiKeyDownPin = 42;   // Button: Prev   (Pin:42)

     m2.setPin(M2_KEY_SELECT, uiKeySelectPin);
     m2.setPin(M2_KEY_NEXT, uiKeyNextPin);
     m2.setPin(M2_KEY_HOME, uiKeyHomePin);
     m2.setPin(M2_KEY_DATA_DOWN, uiKeyDownPin);

     M2tk m2(&m2_null_element, m2_es_arduino, m2_eh_4bs, m2_gh_lc);

So Home, next and select are working, but data down is not working ... could be useful because with select I can do a data up and select and with data down I can decrease the field without scan all range :-) is there a way how to fix that ?

Thanks for the support again :-)
gnux
Logged

Germany
Offline Offline
Edison Member
*
Karma: 100
Posts: 1223
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi

Fix is easy: You need to use m2_eh_6bs instead of m2_eh_4bs handler. See the function reference manual.

Oliver
Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 407
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks you Oliver :-) How ever the best :-) !!!!

So Now I've did a View Menu timer where I re-use the label because they are in the same position:
Menu entry:
Quote
M2_LABEL(el_v_Timer_Specific_Start, fmt_x8y3, "START");
M2_U8NUM(el_v_Timer_Specific_Day_Start, fmt_x14y3c2, 1,31,&dt_day_start);
M2_LABEL(el_v_Timer_Specific_Sep_Start, fmt_x17y3b1, "/");
M2_U8NUM(el_v_Timer_Specific_Month_Start, fmt_x17y3c2, 1,12,&dt_month_start);
M2_LABEL(el_v_Timer_Specific_Stop, fmt_x9y1, "STOP");
M2_LABELFN(el_v_Timer_State_Specific, fmt_x3y1, label_w_state_specific);
M2_U8NUM(el_v_Timer_Specific_Day_Stop, fmt_x14y1c2, 0,31,&dt_day_stop);
M2_LABEL(el_v_Timer_Specific_Sep_Stop, fmt_x17y1b1, "/");
M2_U8NUM(el_v_Timer_Specific_Month_Stop, fmt_x17y1c2, 1,12,&dt_month_stop);
M2_COMBO(el_v_Timer_Specific_sa, fmt_x3y0r1,&select_priority, 2, fn_w_S_to_Apply_specific);
M2_BUTTON(el_dev_ok_timer, fmt_x7y0, "ok", dev_ok_button_timer);

M2_LIST(num_list_timer) = { &el_G_Timer, &el_G_Timer_dev, &el_v_Timer_Specific_Start,&el_v_Timer_Specific_Day_Start,&el_v_Timer_Specific_Sep_Start,&el_v_Timer_Specific_Month_Start,
                            &el_G_What,&el_G_HourStart,&el_G_Timer_Start_Sep,&el_G_MinuteStart,
                            &el_G_Timer_State,&el_v_Timer_State_Specific,&el_v_Timer_Specific_Stop,&el_v_Timer_Specific_Day_Stop,&el_v_Timer_Specific_Sep_Stop,&el_v_Timer_Specific_Month_Stop,
                            &el_G_Timer_Ac,&el_v_Timer_Specific_sa,&el_dev_ok_timer,&el_G_back,&el_G_HourStop,&el_G_Timer_Stop_Sep,&el_G_MinStop,
                          };
M2_XYLIST(el_num_menu_timer, NULL,num_list_timer);


Menu View:
Quote
M2_LABELFN(el_v_Timer_lbl_SDayStart, fmt_x14y3c2, lbl_SDayStart);
M2_LABELFN(el_v_lbl_SMonthStart,     fmt_x17y3c2, lbl_SMonthStart);
M2_LABELFN(el_v_lbl_SHourStart,      fmt_x14y2c2, lbl_SHourStart);
M2_LABELFN(el_v_lbl_SMinuteStart,    fmt_x17y2c2, lbl_SMinuteStart);
M2_LABELFN(el_v_lbl_SDayStop,        fmt_x14y1c2, lbl_SDayStop);
M2_LABELFN(el_v_lbl_SMonthStop,      fmt_x17y1c2, lbl_SMonthStop);
M2_LABELFN(el_v_lbl_SHourStop,       fmt_x14y0c2, lbl_SHourStop);
M2_LABELFN(el_v_lbl_SMinuteStop,     fmt_x17y0c2, lbl_SMinuteStop);

M2_LIST(num_list_timer_view) = { &el_G_Timer, &el_G_Timer_dev, &el_v_Timer_Specific_Start,&el_v_Timer_lbl_SDayStart,&el_v_Timer_Specific_Sep_Start,&el_v_lbl_SMonthStart,
                                 &el_G_What,&el_v_lbl_SHourStart,&el_G_Timer_Start_Sep,&el_v_lbl_SMinuteStart,
                                 &el_G_Timer_State,&el_v_Timer_State_Specific,&el_v_Timer_Specific_Stop,&el_v_lbl_SDayStop,&el_v_Timer_Specific_Sep_Stop,&el_v_lbl_SMonthStop,
                                 &el_G_back,&el_v_lbl_SHourStop,&el_G_Timer_Stop_Sep,&el_v_lbl_SMinuteStop
                          };
M2_XYLIST(el_num_menu_timer_view, NULL,num_list_timer_view);

The field are in the same position: but is happen a strange things the separator into view timer is missing,
is necessary like a M2_LABEL and is not possible to re-use it ?

Thanks for the information
gnux :-)

Logged

Germany
Offline Offline
Edison Member
*
Karma: 100
Posts: 1223
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
the separator into view timer is missing

I do not understand what you mean  smiley-sad
Is it a compiler error? If yes, please provide the full error message.

Oliver
Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 407
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ciao Oliver, if you look the code I've re-used this separator defined into menu entry timer in this way:

M2_LABEL(el_v_Timer_Specific_Sep_Start, fmt_x17y3b1, "/");
M2_LABEL(el_v_Timer_Specific_Sep_Stop, fmt_x17y1b1, "/");

Then I've re-use the two elements for the menu timer view:

&el_v_Timer_Specific_Sep_Start
&el_v_Timer_Specific_Sep_Stop

the problem is that are not displayed and to be honest I don't understand why ...

Could you help kindly me ?

Thanks
Gnux
Logged

Germany
Offline Offline
Edison Member
*
Karma: 100
Posts: 1223
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok, got your point. I personally think that both seperator are overwritten by elements at the same position (x17y1 and x17y3).
For example:
M2_LABELFN(el_v_lbl_SMonthStart,     fmt_x17y3c2, lbl_SMonthStart);
and
M2_LABEL(el_v_Timer_Specific_Sep_Start, fmt_x17y3b1, "/");
If i interpret your fmt statement correctly, than both elements are at the same position.

Oliver
Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 407
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Good Morning Oliver, it's true are into the same position, because in this way are optimized.

Also for the menu entry timer are in the same position but I have different results :-( ... So if change the view timer menu i can see what I've in mind but what i don't understand is I've the same result with a different positioning ... below reported the definition ... the fmt is correct your understanding ...

Menu Entry Timer:
Code:

M2_U8NUM(el_G_HourStart,        fmt_x14y2c2, 0,23,&dt_hour_start);   // - Re - use in all menu entry timers
M2_LABEL(el_G_Timer_Start_Sep, fmt_x17y2b1, ":");                   // - Re - use in all menu entry timers
M2_U8NUM(el_G_MinuteStart,      fmt_x17y2c2, 0,59, &dt_min_start); // - Re - use in all menu entry timers
M2_U8NUM(el_G_HourStop,          fmt_x14y0c2, 0,23,&dt_hour_stop);     // - Re - use in all menu entry timers
M2_LABEL(el_G_Timer_Stop_Sep,   fmt_x17y0b1, ":");                    // - Re - use in all menu entry timers
M2_U8NUM(el_G_MinStop,             fmt_x17y0c2, 0,59,&dt_min_stop);        // - Re - use in all menu entry timers

M2_U8NUM(el_v_Timer_Specific_Day_Start, fmt_x14y3c2, 1,31,&dt_day_start);
M2_LABEL(el_v_Timer_Specific_Sep_Start, fmt_x17y3b1, "/");
M2_U8NUM(el_v_Timer_Specific_Month_Start, fmt_x17y3c2, 1,12,&dt_month_start);
M2_U8NUM(el_v_Timer_Specific_Day_Stop, fmt_x14y1c2, 0,31,&dt_day_stop);
M2_LABEL(el_v_Timer_Specific_Sep_Stop, fmt_x17y1b1, "/");
M2_U8NUM(el_v_Timer_Specific_Month_Stop, fmt_x17y1c2, 1,12,&dt_month_stop);
//  End Menu Entry
//  Start Menu View Entry
M2_LABELFN(el_v_Timer_lbl_SDayStart, "x15y3c2",   lbl_SDayStart);
M2_LABELFN(el_v_lbl_SMonthStart,       "x18y3c2",   lbl_SMonthStart);
M2_LABELFN(el_v_lbl_SHourStart,         "x15y2c2",   lbl_SHourStart);
M2_LABELFN(el_v_lbl_SMinuteStart,       "x18y2c2",   lbl_SMinuteStart);
M2_LABELFN(el_v_lbl_SDayStop,            "x15y1c2",   lbl_SDayStop);
M2_LABELFN(el_v_lbl_SMonthStop,         "x18y1c2",   lbl_SMonthStop);
M2_LABELFN(el_v_lbl_SHourStop,           "x15y0c2",   lbl_SHourStop);
M2_LABELFN(el_v_lbl_SMinuteStop,         "x18y0c2",   lbl_SMinuteStop);

As you can note the position are different but at the end I've the same result ...

Now what I don't understand is why the same element with the same size on the display is necessary the use  in a different way ...

From the Top-Down metodologies I would like the same position in this way just change one position into fmt, otherwise I will specify a new fmt and then I will use for the menu view menu timer ...

just for understand and use it at the top :-) sorry if i did you maybe a trivial questions for you ...


thansk for the support,
Gnux
Logged

Germany
Offline Offline
Edison Member
*
Karma: 100
Posts: 1223
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It is difficult to understand your question. Maybe you could send the display results along with the code.
But in general: The x/y position of an element is not an absolute position. Instead, it is relative to the origin of the XY List. This could explain your different results.

Oliver
Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 407
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Good Afternoon Oliver,
ok I have understand what you mean ... if i not understood bad depend in which kind situation and what you are using that time ... for example in the menu entry is a M2NUM element into viewer is a M2LABEL elements and is not true at 100% that are in the same position ... correct me if i wrong ,

thanks for your help,
have nice week end :-)
Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 407
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Good Morning Oliver,
Kindly could you tell me if is possible remove when i scroll the menu "black squares" on the right side ?


Thanks and have nice week end :-)
Gnux
Logged

Pages: 1 ... 7 8 [9] 10 11 ... 13   Go Up
Jump to: