Offline
Sr. Member
Karma: 2
Posts: 363
|
 |
« Reply #45 on: January 25, 2013, 01:26:05 am » |
Good Morning Oliver, so, finally it's working :-) ... after a lots of try I've understand what was really missing ... a) setTime(RTC.get(DS1307_HR,true),RTC.get(DS1307_MIN,false),RTC.get(DS1307_SEC,false),RTC.get(DS1307_DATE,false),RTC.get(DS1307_MTH,false),13)
Looking the code you will note that like Year I've explict "13" --> "2013" before there was this : setTime(RTC.get(DS1307_HR,true),RTC.get(DS1307_MIN,false),RTC.get(DS1307_SEC,false),RTC.get(DS1307_DATE,false),RTC.get(DS1307_MTH,false),(RTC.get(DS1307_YR,false)-2000))
That I think means that doesn't accept the calcution in this way in fact is necessary put (), but I will do other try just to understand ... Maybe I will calculate into a variable and then I will pass the value to the function ... The other problems was that, into the loop is necessary put Alarm.delay(1000);
Otherwise the timer will not start ... Ok with the timer of course but i think is correct there is a little bit delay because off course in background there is the timer that is working ... So now i will study an efficient manner how to manage the timer ... I'll let you know because I think that you are a very good teacher... I've to found the way for do a input menu for a timer ... :-) maybe you can help me with this :-) my idea is do a menu for a timer structure in this way: Timer: - set timer --> select dev --> enable / disable --> put time start date time --> put time stop date time (could be the best do start / stop time with only row if is possible) - View Timer Set so for select a dev and enable/disable i think is not a problem ... for the other could be a issues ... because im not able to manage at the top the menu :-( Thanks and have nice day, gnux
|
|
|
|
« Last Edit: January 25, 2013, 01:44:55 am by gnusso »
|
Logged
|
|
|
|
|
Germany
Offline
God Member
Karma: 70
Posts: 848
If you believe something is right, you won't see what's wrong (David Straker).
|
 |
« Reply #46 on: January 25, 2013, 03:28:53 pm » |
Hi Maybe i have not yet fully understood your problem. Do you want to program exactly one timer or more than one timer? In either case, you need to know, what exactly needs to be entered for one timer. You mention date and time, start and dev. But it probably needs to be cut down to atomic data times like byte and words. So this is probably the first step: To break down the required information to small pieces. For example in this way: time: hour (byte, 0..23), minute (byte, 0..59), seconds (0..59) start: could be represented as a status byte: 0 for timer stopped, 1 for time is running. In that sense the variable should be better called "is_running". By the way it is a good practice to have a naming convention for variables. For example if all boolean variables start with "is_" then they are easily seen in the code. You could also do something like if ( is_running ) ... which will be executed if the time "runs" An open question to me is the mentioned "dev" (select dev). What exactly needs to be selected? How much selectable items are there. Can it be mapped to some integer (byte) variable? So, again, first step is to break down all this to variables. Then write some nice dialog entries for it. Once done, the question is: Is there only one timer or are there more timers to handle. Of course the existing dialogs should be reused for each different set of timer configuration variables. if you need to handle more than one timer, i think it will make sense to study tutorial 8: http://code.google.com/p/m2tklib/wiki/t08. Tutorial 8 has a configuration menu for the PWM output. Compare your timer data with the PWM output in this tutorial. This tutorial also introduces a top level menu. And: The PWM example is also available in the Arduino IDE (if m2tklib is installed correctly) Oliver
|
|
|
|
|
Logged
|
|
|
|
|
East Anglia (UK)
Offline
Edison Member
Karma: 55
Posts: 1601
May all of your blinks be without delay
|
 |
« Reply #47 on: January 26, 2013, 02:26:43 am » |
If Alarm.delay(1000) is causing you a problem because it blocks your code for 1 second then you should consider reducing the delay time or better, only calling Alarm.delay() when it will not interfere with the operation of your program, or both, of course.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 2
Posts: 363
|
 |
« Reply #48 on: January 26, 2013, 04:20:43 am » |
I think should be better reduce the delay maybe ...
because otherwise how can the timer start ?
Thanks gnux
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 2
Posts: 363
|
 |
« Reply #49 on: January 26, 2013, 04:31:24 am » |
Hi Oliver, you have exactly center my ideas ... :-)
So:
- N°Dev --> are the number of the devices for example: I can set up timer for the devices from 0 to 7 ...
when I setup the timer from a menu do this: - pass the menu value to: a) a timer b) in eeprom c) array (copy of eeprom) in this way if the electricity will be down automatically a timer will be set again if wrote into the eeprom. The first thing that the software do is read eeprom and pass the value to a local array that is identical to the eeprom.
Then my ideas is change dynamically a timer from a menu ... make sense for you ?
thanks gnux
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 2
Posts: 363
|
 |
« Reply #50 on: January 26, 2013, 06:21:34 am » |
Hi Oliver, sorry if i ask you ... But I need to more information about the menu ... looking this menu: #include <LiquidCrystal.h> // ensure that the include path is set #include "M2tk.h" #if defined(ARDUINO) && ARDUINO >= 100 #include "Arduino.h" #else #include "WProgram.h" #endif
// Forward declaration of the toplevel element M2_EXTERN_HLIST(top_el_expandable_menu);
/* SetDate 1-1 */ uint8_t dt_day = 1; uint8_t dt_month = 1; uint8_t dt_year = 12; uint8_t dt_min = 1; uint8_t dt_hour = 1;
void dt_current(void) { }
void dt_get_from_RTC(void) { }
void dt_put_to_RTC(void) { }
void dt_ok_date(m2_el_fnarg_p fnarg) { dt_put_to_RTC(); m2_SetRoot(&top_el_expandable_menu); }
void time_ok_button(m2_el_fnarg_p fnarg) { dt_put_to_RTC(); m2_SetRoot(&top_el_expandable_menu); }
void view_ok_button(m2_el_fnarg_p fnarg) { dt_current(); m2_SetRoot(&top_el_expandable_menu); }
M2_U8NUM(el_dt_year, "c2", 0,99,&dt_year); M2_LABEL(el_dt_sep1, "b1", "-"); M2_U8NUM(el_dt_month, "c2", 1,12,&dt_month); M2_LABEL(el_dt_sep2, "b1", "-"); M2_U8NUM(el_dt_day, "c2", 1,31,&dt_day);
M2_LIST(list_date) = { &el_dt_year, &el_dt_sep1, &el_dt_month, &el_dt_sep2, &el_dt_day }; M2_HLIST(el_date, NULL, list_date);
M2_ROOT(el_dt_cancel, NULL, "cancel", &top_el_expandable_menu); M2_BUTTON(el_dt_ok, NULL, "ok", dt_ok_date); M2_LIST(list_dt_buttons) = {&el_dt_cancel, &el_dt_ok }; M2_HLIST(el_dt_buttons, NULL, list_dt_buttons);
M2_LIST(list_dt) = {&el_date, &el_dt_buttons }; M2_VLIST(el_top_dt, NULL, list_dt);
/* Set time 1-2 ---------------------------------------------------------------------*/
M2_U8NUM(el_dt_hour, "c2", 0,23,&dt_hour); M2_LABEL(el_dt_c, "b1", ":"); M2_U8NUM(el_dt_min, "c2", 0,59,&dt_min);
M2_LIST(list_time) = { &el_dt_hour, &el_dt_c, &el_dt_min}; M2_HLIST(el_time, NULL, list_time);
M2_ROOT(el_time_cancel, NULL, "cancel", &top_el_expandable_menu); M2_BUTTON(el_time_ok, NULL, "ok", time_ok_button); M2_LIST(list_time_buttons) = {&el_time_cancel, &el_time_ok }; M2_HLIST(el_time_buttons, NULL, list_time_buttons);
M2_LIST(list_t) = {&el_time, &el_time_buttons}; M2_VLIST(el_top_time, NULL, list_t);
/* View DateTime 1-3 */ M2_LABEL(el_dt_view, "b1", "DateTimeNow"); M2_LIST(list_view) = {&el_dt_view}; M2_HLIST(el_view, NULL, list_view);
M2_ROOT(el_view_cancel, NULL, "cancel", &top_el_expandable_menu); M2_BUTTON(el_view_ok, NULL, "ok", view_ok_button); M2_LIST(list_view_buttons) = {&el_view_cancel, &el_view_ok }; M2_HLIST(el_view_buttons, NULL, list_view_buttons);
M2_LIST(list_v) = {&el_view, &el_view_buttons}; M2_VLIST(el_top_view, NULL, list_v);
/* -------------- DEVICE 2 ----------------------*/
uint8_t u8dev = 0; uint8_t u8stato = 0;
void fn_clean_dev(m2_el_fnarg_p fnarg) { u8dev = 0; }
void dev_ok_button(m2_el_fnarg_p fnarg) { }
void dev_stato_button(m2_el_fnarg_p fnarg) { // procedura per recuperare lo stato della periferica }
M2_LABEL(el_num_label1, NULL, "Select Dev:"); M2_U8NUM(el_num_1, NULL, 0, 64, &u8dev);
M2_LABEL(el_num_label2,NULL, "Turn Off/On:"); M2_U8NUM(el_num_2, NULL, 0, 1, &u8stato);
M2_BUTTON(el_num_zero, "f4", "zero", fn_clean_dev); M2_BUTTON(el_dev_ok, NULL, "ok", dev_ok_button); M2_BUTTON(el_dev_stato, NULL, "stato", dev_stato_button); M2_ROOT(el_num_goto_top, "f4", "back", &top_el_expandable_menu);
M2_LIST(num_list) = { &el_num_label1, &el_num_1, &el_num_label2, &el_num_2, &el_dev_ok, &el_num_zero, &el_num_goto_top,&el_dev_stato }; M2_GRIDLIST(el_num_menu, "c2", num_list);
/* --------------------------- TIMER 3-------------------------- */
uint8_t u8devTimer = 0; // used for select the devices uint8_t IsTimerEnable = 0; // used for say if enable or disable 0 disable 1 enable // set start date time uint8_t dt_day_start = 1; uint8_t dt_month_start = 1; uint8_t dt_year_start = 13; uint8_t dt_min_start = 1; uint8_t dt_hour_start = 1; // set stop date time uint8_t dt_day_stop = 1; uint8_t dt_month_stop = 1; uint8_t dt_year_stop = 13; uint8_t dt_min_stop = 1; uint8_t dt_hour_stop = 1;
void fn_clean_dev_timer(m2_el_fnarg_p fnarg) { u8devTimer = 0; }
void dev_ok_button_timer(m2_el_fnarg_p fnarg) { m2_SetRoot(&top_el_expandable_menu); }
M2_LABEL(el_num_timer, NULL, "Select Dev:"); M2_U8NUM(el_num_t1, NULL, 0, 64, &u8devTimer);
M2_LABEL(el_num_timer2,NULL, "Enable/Disable"); M2_U8NUM(el_num_t2, NULL, 0, 1, &IsTimerEnable); // Time M2_LABEL(el_num_timer3,NULL, "Start When"); M2_U8NUM(el_dt_hour_t1start, "c2", 0,23,&dt_hour_start); M2_LABEL(el_dt_ts, "b1", ":"); M2_U8NUM(el_dt_min_t1start, "c2", 0,59,&dt_min_start); // Date M2_U8NUM(dt_year_t1start, "c2", 0,99,&dt_year_start); M2_LABEL(el_dt_ts1, "b1", "-"); M2_U8NUM(dt_month_t1start, "c2", 1,12,&dt_month_start); M2_LABEL(el_dt_ts2, "b1", "-"); M2_U8NUM(dt_day_t1start, "c2", 1,31,&dt_day_start);
M2_BUTTON(el_num_zero_timer, "f4", "zero", fn_clean_dev_timer); M2_BUTTON(el_dev_ok_timer, NULL, "ok", dev_ok_button_timer); // M2_BUTTON(el_dev_stato_timer, NULL, "stato", dev_stato_button_timer); M2_ROOT(el_num_goto_top_timer, "f4", "back", &top_el_expandable_menu);
M2_LIST(num_list_timer) = { &el_num_timer, &el_num_t1, &el_num_timer2, &el_num_t2, &el_num_timer3, &el_dt_hour_t1start,&el_dt_ts,&el_dt_min_t1start, &el_dev_ok_timer, &el_num_zero_timer, &el_num_goto_top_timer }; M2_GRIDLIST(el_num_menu_timer, "c2", num_list_timer);
/* --------------------------- main menu-------------------------- */ m2_menu_entry m2_2lmenu_data[] = { { "DATE/TIME 1", NULL }, { ". SetDate 1-1", &el_top_dt }, { ". SetTime 1-2", &el_top_time}, { ". View DateTime 1-3", &el_top_view}, { "DEVICES 2", NULL}, { ". Manage 2-1", &el_num_menu}, { "TIMER 3", NULL}, { ". SetTimer 3-1", &el_num_menu_timer}, { ". ViewTimer 3-2", &el_top_view}, { NULL, NULL }, };
uint8_t m2_2lmenu_first; uint8_t m2_2lmenu_cnt;
M2_2LMENU(el_2lmenu,"l4e1w12",&m2_2lmenu_first,&m2_2lmenu_cnt, m2_2lmenu_data,'+','-','\0'); M2_VSB(el_vsb, "l4w1r1", &m2_2lmenu_first, &m2_2lmenu_cnt); M2_LIST(list_2lmenu) = { &el_2lmenu, &el_vsb }; M2_HLIST(top_el_expandable_menu, NULL, list_2lmenu);
// m2 object and constructor M2tk m2(&top_el_expandable_menu, m2_es_arduino_serial, m2_eh_2bs, m2_gh_arduino_serial);
/* --------------------------- end menu-------------------------- */
void setup() { }
void loop() { // Timer(); m2.checkKey(); m2.checkKey(); if ( m2.handleKey() ) m2.draw(); m2.checkKey(); }
right now I have this out put for the time if you try the sketch: +DATE/TIME 1 +DEVICES 2 -TIMER 3 [ SetTimer 3-1 s Start 01 : 01 ok zero back But I would like to have the outoput for the timer in this way: +DATE/TIME 1 +DEVICES 2 -TIMER 3 [ SetTimer 3-1 s Sel Dev: 01 E/D: 0 Start: 01:01 + date (need to implement again because i want to do step by step) Stop: 01:01 + date (need to implement again because i want to do step by step) Ok Zero Back I think is related to the hierarchy mention by you :-) but i need to take more feeling with that :-) is possible from your point of view ? Thanks for the support and have nice week end :-)
|
|
|
|
|
Logged
|
|
|
|
|
Germany
Offline
God Member
Karma: 70
Posts: 848
If you believe something is right, you won't see what's wrong (David Straker).
|
 |
« Reply #51 on: January 26, 2013, 09:34:51 am » |
Hi
I think there is some missunderstanding of the GRIDLIST. I would suggest to read documentation about it. Maybe you could instead of the GRIDLIST use the XYLIST, which might be simpler to use. With the XYLIST you must provide the left position of each child element, which lets you create more easily the menu element.
Oliver
|
|
|
|
|
Logged
|
|
|
|
|
East Anglia (UK)
Offline
Edison Member
Karma: 55
Posts: 1601
May all of your blinks be without delay
|
 |
« Reply #52 on: January 26, 2013, 05:56:30 pm » |
I can set up timer for the devices from 0 to 7 ...
TimeAlarms only normally allows up to 6 alarms to be set concurrently. You can change a line in TimeAlarms.h to increase the limit. #define dtNBR_ALARMS 6 // max is 255
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 2
Posts: 363
|
 |
« Reply #53 on: January 27, 2013, 01:14:08 am » |
Thanks to you guys :-) I will read the documentation for the menu :-) and I will try your suggest ...
So thanks also for the allarm is important Know how many alarms is possible set ...
warms regards, gnux
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 2
Posts: 363
|
 |
« Reply #54 on: January 27, 2013, 03:45:10 am » |
Hi Oliver, today after hours of I've build the menu ... I've understood how to use x,y list ... but now there is a little problem ... so I've available a lcd 20x4 ... well with my sketch i need more over di 4 rows ... with the sketch that I've did I've note that if i add more of 4 columns the display start to have some issues ... below reported the code ... so from my understating the code is correct: the problem is that with 20 character available, what I've understand is that i cannot put time and date only one rows ...because using x,y in cannot format the field ...then If not wrong this is the calculation : start date: [000][000][000][000][000] --> totally characters used: 27 (without label and separator) then i need to split on more rows ... :-( do you know If id possible fix it ? if try to copy and paste the code you should understand perfectly what I mean :-( in attachment screenshoot also ... thansk for the support ... now i start to understand better also the tutorial is more clear now ... see in the timer menu ;-) Thanks for the support :-) #include <LiquidCrystal.h> // ensure that the include path is set #include "M2tk.h" #if defined(ARDUINO) && ARDUINO >= 100 #include "Arduino.h" #else #include "WProgram.h" #endif
// Forward declaration of the toplevel element M2_EXTERN_HLIST(top_el_expandable_menu);
/* SetDate 1-1 */ uint8_t dt_day = 1; uint8_t dt_month = 1; uint8_t dt_year = 12; uint8_t dt_min = 1; uint8_t dt_hour = 1;
void dt_current(void) { }
void dt_get_from_RTC(void) { }
void dt_put_to_RTC(void) { }
void dt_ok_date(m2_el_fnarg_p fnarg) { dt_put_to_RTC(); m2_SetRoot(&top_el_expandable_menu); }
void time_ok_button(m2_el_fnarg_p fnarg) { dt_put_to_RTC(); m2_SetRoot(&top_el_expandable_menu); }
void view_ok_button(m2_el_fnarg_p fnarg) { dt_current(); m2_SetRoot(&top_el_expandable_menu); }
M2_U8NUM(el_dt_year, "c2", 0,99,&dt_year); M2_LABEL(el_dt_sep1, "b1", "-"); M2_U8NUM(el_dt_month, "c2", 1,12,&dt_month); M2_LABEL(el_dt_sep2, "b1", "-"); M2_U8NUM(el_dt_day, "c2", 1,31,&dt_day);
M2_LIST(list_date) = { &el_dt_year, &el_dt_sep1, &el_dt_month, &el_dt_sep2, &el_dt_day }; M2_HLIST(el_date, NULL, list_date);
M2_ROOT(el_dt_cancel, NULL, "cancel", &top_el_expandable_menu); M2_BUTTON(el_dt_ok, NULL, "ok", dt_ok_date); M2_LIST(list_dt_buttons) = {&el_dt_cancel, &el_dt_ok }; M2_HLIST(el_dt_buttons, NULL, list_dt_buttons);
M2_LIST(list_dt) = {&el_date, &el_dt_buttons }; M2_VLIST(el_top_dt, NULL, list_dt);
/* Set time 1-2 ---------------------------------------------------------------------*/
M2_U8NUM(el_dt_hour, "c2", 0,23,&dt_hour); M2_LABEL(el_dt_c, "b1", ":"); M2_U8NUM(el_dt_min, "c2", 0,59,&dt_min);
M2_LIST(list_time) = { &el_dt_hour, &el_dt_c, &el_dt_min}; M2_HLIST(el_time, NULL, list_time);
M2_ROOT(el_time_cancel, NULL, "cancel", &top_el_expandable_menu); M2_BUTTON(el_time_ok, NULL, "ok", time_ok_button); M2_LIST(list_time_buttons) = {&el_time_cancel, &el_time_ok }; M2_HLIST(el_time_buttons, NULL, list_time_buttons);
M2_LIST(list_t) = {&el_time, &el_time_buttons}; M2_VLIST(el_top_time, NULL, list_t);
/* View DateTime 1-3 */ // M2_LABEL(el_dt_view, "b1", "DateTimeNow"); //M2_LIST(list_view) = {&el_dt_view}; //M2_HLIST(el_view, NULL, list_view);
// M2_ROOT(el_view_cancel, NULL, "cancel", &top_el_expandable_menu); M2_BUTTON(el_view_ok, NULL, "ok", view_ok_button); M2_LIST(list_view_buttons) = {&el_view_ok }; M2_HLIST(el_view_buttons, NULL, list_view_buttons);
M2_LIST(list_v) = {&el_view_buttons}; M2_VLIST(el_top_view, NULL, list_v);
/* -------------- DEVICE 2 ----------------------*/
uint8_t u8dev = 0; uint8_t u8stato = 0;
void fn_clean_dev(m2_el_fnarg_p fnarg) { u8dev = 0; }
void dev_ok_button(m2_el_fnarg_p fnarg) { m2_SetRoot(&top_el_expandable_menu); }
void dev_stato_button(m2_el_fnarg_p fnarg) { // procedura per recuperare lo stato della periferica }
M2_LABEL(el_num_label1, NULL, "Select Dev:"); M2_U8NUM(el_num_1, NULL, 0, 64, &u8dev);
M2_LABEL(el_num_label2,NULL, "Turn Off/On:"); M2_U8NUM(el_num_2, NULL, 0, 1, &u8stato);
M2_BUTTON(el_num_zero, NULL, "Zero", fn_clean_dev); M2_BUTTON(el_dev_ok, NULL, "Ok", dev_ok_button); M2_BUTTON(el_dev_stato, NULL, "State", dev_stato_button); //M2_ROOT(el_num_goto_top, "f4", "back", &top_el_expandable_menu);
M2_LIST(num_list) = { &el_num_label1, &el_num_1, &el_num_label2, &el_num_2, &el_num_zero, &el_dev_stato, &el_dev_ok }; M2_GRIDLIST(el_num_menu, "c2", num_list);
/* --------------------------- TIMER 3-------------------------- */
uint8_t u8devTimer = 0; // used for select the devices uint8_t IsTimerEnable = 0; // used for say if enable or disable 0 disable 1 enable // set start date time uint8_t dt_day_start = 1; uint8_t dt_month_start = 1; uint8_t dt_year_start = 13; uint8_t dt_min_start = 1; uint8_t dt_hour_start = 1; // set stop date time uint8_t dt_day_stop = 1; uint8_t dt_month_stop = 1; uint8_t dt_year_stop = 13; uint8_t dt_min_stop = 1; uint8_t dt_hour_stop = 1;
void fn_clean_dev_timer(m2_el_fnarg_p fnarg) { u8devTimer = 0; }
void dev_ok_button_timer(m2_el_fnarg_p fnarg) { m2_SetRoot(&top_el_expandable_menu); }
M2_LABEL(el_num_timer1, "x0y5", "Dev:"); M2_U8NUM(el_num_t1, "x4y5",0, 64, &u8devTimer); M2_LABEL(el_num_timer2,"x11y5", "E/D:"); M2_U8NUM(el_num_t2, "x14y5", 0, 1, &IsTimerEnable);
M2_LABEL(el_num_timer3,"x0y4", "Start Time:"); M2_U8NUM(el_dt_hour_t1start,"x10y4", 0,23,&dt_hour_start); M2_U8NUM(el_dt_min_t1start, "x14y4", 0,59,&dt_min_start); // DATE M2_LABEL(el_num_timer4,"x0y3", "S.D.:"); M2_U8NUM(dt_day_t1start, "x5y3", 0,99,&dt_day_start); M2_U8NUM(dt_month_t1start, "x9y3", 1,12,&dt_month_start); M2_U8NUM(dt_year_t1start, "x13y3", 1,12,&dt_year_start);
// Stop Timer M2_LABEL(el_num_timer5,"x0y2", "Stop Time:"); M2_U8NUM(el_dt_hour_t1stop,"x10y2", 0,23,&dt_hour_stop); M2_U8NUM(el_dt_min_t1stop, "x14y2", 0,59,&dt_min_stop);
M2_LABEL(el_num_timer6,"x0y1", "E.D.:"); M2_U8NUM(dt_day_t1stop, "x5y1", 0,99,&dt_day_stop); M2_U8NUM(dt_month_t1stop, "x9y1", 1,12,&dt_month_stop); M2_U8NUM(dt_year_t1stop, "x13y1", 1,12,&dt_year_stop);
// pulsanti M2_BUTTON(el_num_zero_timer, "x0y0", "Zero", fn_clean_dev_timer); M2_BUTTON(el_dev_ok_timer, "x8y0", "ok", dev_ok_button_timer); M2_ROOT(el_num_goto_top_timer, "x13y0", "back", &top_el_expandable_menu);
M2_LIST(num_list_timer) = { &el_num_timer1, &el_num_t1, &el_num_timer2,&el_num_t2, &el_num_timer3,&el_dt_hour_t1start,&el_dt_min_t1start, &el_num_timer4,&dt_day_t1start,&dt_month_t1start,&dt_year_t1start, &el_num_timer5,&el_dt_hour_t1stop, &el_dt_min_t1stop, &el_num_timer6,&dt_day_t1stop,&dt_month_t1stop,&dt_year_t1stop, &el_num_zero_timer,&el_dev_ok_timer,&el_num_goto_top_timer, }; M2_XYLIST(el_num_menu_timer, NULL,num_list_timer); /* --------------------------- main menu-------------------------- */ m2_menu_entry m2_2lmenu_data[] = { { "DATE/TIME 1", NULL }, { ". SetDate 1-1", &el_top_dt }, { ". SetTime 1-2", &el_top_time}, { ". View DateTime 1-3", &el_top_view}, { "DEVICES 2", NULL}, { ". Manage 2-1", &el_num_menu}, { "TIMER 3", NULL}, { ". SetTimer 3-1", &el_num_menu_timer}, { ". ViewTimer 3-2", &el_top_view}, { NULL, NULL }, }; uint8_t m2_2lmenu_first; uint8_t m2_2lmenu_cnt;
M2_2LMENU(el_2lmenu,"l4e1w12",&m2_2lmenu_first,&m2_2lmenu_cnt, m2_2lmenu_data,'+','-','\0'); M2_VSB(el_vsb, "l4w1r1", &m2_2lmenu_first, &m2_2lmenu_cnt); M2_LIST(list_2lmenu) = { &el_2lmenu, &el_vsb }; M2_HLIST(top_el_expandable_menu, NULL, list_2lmenu);
// m2 object and constructor M2tk m2(&top_el_expandable_menu, m2_es_arduino_serial, m2_eh_2bs, m2_gh_arduino_serial); /* --------------------------- end menu-------------------------- */ void setup() { }
void loop() { // Timer(); m2.checkKey(); m2.checkKey(); if ( m2.handleKey() ) m2.draw(); m2.checkKey(); }
|
|
|
|
|
Logged
|
|
|
|
|
Germany
Offline
God Member
Karma: 70
Posts: 848
If you believe something is right, you won't see what's wrong (David Straker).
|
 |
« Reply #55 on: January 27, 2013, 04:37:32 am » |
Hi All number fields have a format option to limit the number of digits which are displayed. See here: http://code.google.com/p/m2tklib/wiki/elref#U8NUMThe relevant part is this: Format Options c: Number of digits, e.g. "c2" allows numbers between "00" and "99". Note, that this setting must fit to the min and max value. This means you get the following results M2_U8NUM(el,"c3",0,255,&number) --> "[000]" M2_U8NUM(el,"c2",0,31,&number) --> "[00]" M2_U8NUM(el,"c1",0,9,&number) --> "[0]"
The "c" format option is the key to format the output. For your xy-grid you need to combine everything: M2_U8NUM(el,"x0y1c2",0,31,&number) --> "[00]" at position (0,1) Hope this helps, Oliver Edit: Added "code" section
|
|
|
|
« Last Edit: January 27, 2013, 04:41:45 am by olikraus »
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 2
Posts: 363
|
 |
« Reply #56 on: January 27, 2013, 06:33:30 am » |
Hi Oliver :-), thanks for the useful information ,
i was see the tutorial :-) but and I was guess that was possible combine the value :-)
but I was pass the value into the wrong way :-) thanks in this way I think I can stay with the four row :-)
The concept to mix the format is always good ? thanks gnux ;-)
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 2
Posts: 363
|
 |
« Reply #57 on: January 27, 2013, 09:23:58 am » |
Hi Oliver, so now the output is like this :
Dev:[000] E/D:000 01 01 01 01 13 01 01 01 01 13 Zero ok back
I think is not Bad ... what do you think ? How do you will improve this ?
Gnux
|
|
|
|
|
Logged
|
|
|
|
|
Germany
Offline
God Member
Karma: 70
Posts: 848
If you believe something is right, you won't see what's wrong (David Straker).
|
 |
« Reply #58 on: January 27, 2013, 10:06:04 am » |
I am not a GUI designer. If it fullfills you needs, than it should be ok  Oliver
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 2
Posts: 363
|
 |
« Reply #59 on: January 27, 2013, 01:02:05 pm » |
Hi Oliver, I've play very well with the new function that I've learned ... so now I was working on the display time ... I don't understood why I cannot show nothing if I arrange the menu in this way... uint8_t dt_day_disp = RTC.get(DS1307_DATE,false); uint8_t dt_month_disp = RTC.get(DS1307_MTH,false); uint8_t dt_year_disp = (RTC.get(DS1307_YR,false)-2000); uint8_t dt_min_disp = RTC.get(DS1307_MIN,false); uint8_t dt_hour_disp = RTC.get(DS1307_HR,true);
M2_LABEL(el_dt_l1_disp, "x0y2", "ddmmyy:"); M2_U8NUM(el_dt_day_disp, "x7y2c2r1", 1,31,&dt_day_disp); M2_U8NUM(el_dt_month_disp, "x11y2c2r1", 1,12,&dt_month_disp); M2_U8NUM(el_dt_year_disp, "x15y2c2r1", 0,99,&dt_year_disp);
M2_LABEL(el_dt_l2_disp, "x0y1", "hhmm:"); M2_U8NUM(el_dt_hour_disp,"x7y1c2r1", 0,23,&dt_hour_disp); M2_U8NUM(el_dt_min_disp, "x11y1c2r1", 0,59,&dt_min_disp);
M2_ROOT(el_dt_ok_disp, "x0y0", "ok", &top_el_expandable_menu);
M2_LIST(num_list_date_disp) = { &el_dt_l1_disp,&el_dt_day_disp,&el_dt_month_disp,&el_dt_year_disp, &el_dt_l2_disp,&el_dt_hour_disp,&el_dt_min_disp, &el_dt_ok_disp }; M2_XYLIST(el_list_date_disp, NULL,num_list_date_disp);
and issues is related to this: uint8_t dt_day_disp = RTC.get(DS1307_DATE,false); uint8_t dt_month_disp = RTC.get(DS1307_MTH,false); uint8_t dt_year_disp = (RTC.get(DS1307_YR,false)-2000); uint8_t dt_min_disp = RTC.get(DS1307_MIN,false); uint8_t dt_hour_disp = RTC.get(DS1307_HR,true);
now the question that i did to my self and that I forward to you is ... ? Ok I've set a read only field ... but how can I retrieve dynamically date / time and put it on a display ... ? so i think to have follow your suggestion maybe correct if wrong :-) thanks 1000, gnux
|
|
|
|
|
Logged
|
|
|
|
|
|