Germany
Offline
God Member
Karma: 69
Posts: 798
If you believe something is right, you won't see what's wrong (David Straker).
|
 |
« Reply #120 on: February 27, 2013, 01:57:55 pm » |
3v3 displays not only require 3v3 power supply, but also need logic levels, that do not exceed 3v3. This means, you need a level translation on each communication pin
Oliver
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 2
Posts: 354
|
 |
« Reply #121 on: March 01, 2013, 03:30:20 am » |
Thanks Oliver, I will tell this to my friend that is project the hardware :-)
So, just to be sure that I've develop the code with "awareness" I report to you how I've implement my code i'd like to know from your stand point and experience if I've wrong did some errors and have lose precious memory ... Yestarday after a lots of hour of code I've tried with ATMEGA328PU was like size but was not working. Then I've tried with ATMEGA2560 and was working without problem....
For the menu standpoint:
- I've try to design a menu with the element in the same position in special way for the label, in this way I can instance only one time the object and call it without loose a lot's of space. - Where possible I've re-use the function passing parameter in order to re-use everything without any problem.
From the other code-stand point: - I've try to do a general procedure where possible in order to re-use everything and just call the procedure with different parameter and use less global variable in order to save the space ...
So, if you have suggestion or tip please kindly let know,
So, from the display stand point unknowing all the library but just using it i don't know if are possible more optimization :-)
how ever thanks for the support and patience :-)
regards, gnux
|
|
|
|
|
Logged
|
|
|
|
|
Germany
Offline
God Member
Karma: 69
Posts: 798
If you believe something is right, you won't see what's wrong (David Straker).
|
 |
« Reply #122 on: March 01, 2013, 01:58:48 pm » |
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: 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
Sr. Member
Karma: 2
Posts: 354
|
 |
« Reply #123 on: March 02, 2013, 03:52:31 am » |
Ok :-) Thanks for the information, I can use your suggest for the separator like /, :, for the xy also :-)
Thanks you :-) gnux
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 2
Posts: 354
|
 |
« Reply #124 on: March 04, 2013, 06:04:18 am » |
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
Sr. Member
Karma: 2
Posts: 354
|
 |
« Reply #125 on: March 04, 2013, 10:40:12 am » |
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
God Member
Karma: 69
Posts: 798
If you believe something is right, you won't see what's wrong (David Straker).
|
 |
« Reply #126 on: March 04, 2013, 05:59:38 pm » |
Hi The code contains a programming error, use this: 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/t08Oliver
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 2
Posts: 354
|
 |
« Reply #127 on: March 05, 2013, 03:27:03 am » |
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: 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
God Member
Karma: 69
Posts: 798
If you believe something is right, you won't see what's wrong (David Straker).
|
 |
« Reply #128 on: March 05, 2013, 01:20:40 pm » |
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
Sr. Member
Karma: 2
Posts: 354
|
 |
« Reply #129 on: March 06, 2013, 09:37:27 am » |
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: 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: 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
God Member
Karma: 69
Posts: 798
If you believe something is right, you won't see what's wrong (David Straker).
|
 |
« Reply #130 on: March 06, 2013, 01:23:58 pm » |
the separator into view timer is missing I do not understand what you mean Is it a compiler error? If yes, please provide the full error message. Oliver
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 2
Posts: 354
|
 |
« Reply #131 on: March 07, 2013, 01:11:15 am » |
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
God Member
Karma: 69
Posts: 798
If you believe something is right, you won't see what's wrong (David Straker).
|
 |
« Reply #132 on: March 07, 2013, 05:15:02 pm » |
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
Sr. Member
Karma: 2
Posts: 354
|
 |
« Reply #133 on: March 08, 2013, 02:09:37 am » |
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: 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
God Member
Karma: 69
Posts: 798
If you believe something is right, you won't see what's wrong (David Straker).
|
 |
« Reply #134 on: March 08, 2013, 12:40:14 pm » |
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
|
|
|
|
|
|