summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/settings.c108
-rw-r--r--apps/settings.h3
-rw-r--r--apps/settings_menu.c71
-rw-r--r--firmware/common/timefuncs.c60
-rw-r--r--firmware/include/timefuncs.h21
-rw-r--r--uisimulator/common/stubs.c9
-rw-r--r--uisimulator/win32/Makefile6
-rw-r--r--uisimulator/win32/timefuncs.h3
-rw-r--r--uisimulator/x11/Makefile5
-rw-r--r--uisimulator/x11/timefuncs.h3
10 files changed, 158 insertions, 131 deletions
diff --git a/apps/settings.c b/apps/settings.c
index 8a93617d64..b84ef52205 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -17,7 +17,6 @@
17 * KIND, either express or implied. 17 * KIND, either express or implied.
18 * 18 *
19 ****************************************************************************/ 19 ****************************************************************************/
20
21#include <stdio.h> 20#include <stdio.h>
22#include "config.h" 21#include "config.h"
23#include "kernel.h" 22#include "kernel.h"
@@ -47,6 +46,7 @@
47#include "errno.h" 46#include "errno.h"
48#include "system.h" 47#include "system.h"
49#include "misc.h" 48#include "misc.h"
49#include "timefuncs.h"
50#ifdef HAVE_LCD_BITMAP 50#ifdef HAVE_LCD_BITMAP
51#include "icons.h" 51#include "icons.h"
52#include "font.h" 52#include "font.h"
@@ -1963,17 +1963,33 @@ bool set_option(char* string, void* variable, enum optiontype type,
1963#ifdef HAVE_LCD_BITMAP 1963#ifdef HAVE_LCD_BITMAP
1964 1964
1965/* little helper function for voice output */ 1965/* little helper function for voice output */
1966static void say_time(int cursorpos, int timedate[]) 1966static void say_time(int cursorpos, struct tm *tm)
1967{ 1967{
1968 const int unit[] = { UNIT_HOUR, UNIT_MIN, UNIT_SEC, 0, 0, 0 }; 1968 const int unit[] = { UNIT_HOUR, UNIT_MIN, UNIT_SEC, 0, 0, 0 };
1969 int value = timedate[cursorpos]; 1969 int value = 0;
1970 1970
1971 if (!global_settings.talk_menu) 1971 if (!global_settings.talk_menu)
1972 return; 1972 return;
1973 1973
1974 if (cursorpos == 3) /* year */ 1974 switch(cursorpos)
1975 value += 2000; 1975 {
1976 1976 case 0:
1977 value = tm->tm_hour;
1978 break;
1979 case 1:
1980 value = tm->tm_min;
1981 break;
1982 case 2:
1983 value = tm->tm_sec;
1984 break;
1985 case 3:
1986 value = tm->tm_year + 1900;
1987 break;
1988 case 5:
1989 value = tm->tm_mday;
1990 break;
1991 }
1992
1977 if (cursorpos == 4) /* month */ 1993 if (cursorpos == 4) /* month */
1978 talk_id(LANG_MONTH_JANUARY + value - 1, false); 1994 talk_id(LANG_MONTH_JANUARY + value - 1, false);
1979 else 1995 else
@@ -1984,7 +2000,7 @@ static void say_time(int cursorpos, int timedate[])
1984#define INDEX_X 0 2000#define INDEX_X 0
1985#define INDEX_Y 1 2001#define INDEX_Y 1
1986#define INDEX_WIDTH 2 2002#define INDEX_WIDTH 2
1987bool set_time(char* string, int timedate[]) 2003bool set_time_screen(char* string, struct tm *tm)
1988{ 2004{
1989 bool done = false; 2005 bool done = false;
1990 int button; 2006 int button;
@@ -2024,6 +2040,7 @@ bool set_time(char* string, int timedate[])
2024 2040
2025 int monthname_len = 0, dayname_len = 0; 2041 int monthname_len = 0, dayname_len = 0;
2026 2042
2043 int *valptr = NULL;
2027 2044
2028#ifdef HAVE_LCD_BITMAP 2045#ifdef HAVE_LCD_BITMAP
2029 if(global_settings.statusbar) 2046 if(global_settings.statusbar)
@@ -2036,27 +2053,27 @@ bool set_time(char* string, int timedate[])
2036 2053
2037 while ( !done ) { 2054 while ( !done ) {
2038 /* calculate the number of days in febuary */ 2055 /* calculate the number of days in febuary */
2039 realyear = timedate[3] + 2000; 2056 realyear = tm->tm_year + 1900;
2040 if((realyear % 4 == 0 && !(realyear % 100 == 0)) || realyear % 400 == 0) 2057 if((realyear % 4 == 0 && !(realyear % 100 == 0)) || realyear % 400 == 0)
2041 daysinmonth[1] = 29; 2058 daysinmonth[1] = 29;
2042 else 2059 else
2043 daysinmonth[1] = 28; 2060 daysinmonth[1] = 28;
2044 2061
2045 /* fix day if month or year changed */ 2062 /* fix day if month or year changed */
2046 if (timedate[5] > daysinmonth[timedate[4] - 1]) 2063 if (tm->tm_mday > daysinmonth[tm->tm_mon])
2047 timedate[5] = daysinmonth[timedate[4] - 1]; 2064 tm->tm_mday = daysinmonth[tm->tm_mon];
2048 2065
2049 /* calculate day of week */ 2066 /* calculate day of week */
2050 julianday = 0; 2067 julianday = 0;
2051 for(i = 0; i < timedate[4] - 1; i++) { 2068 for(i = 0; i < tm->tm_mon; i++) {
2052 julianday += daysinmonth[i]; 2069 julianday += daysinmonth[i];
2053 } 2070 }
2054 julianday += timedate[5]; 2071 julianday += tm->tm_mday;
2055 timedate[6] = (realyear + julianday + (realyear - 1) / 4 - 2072 tm->tm_wday = (realyear + julianday + (realyear - 1) / 4 -
2056 (realyear - 1) / 100 + (realyear - 1) / 400 + 7 - 1) % 7; 2073 (realyear - 1) / 100 + (realyear - 1) / 400 + 7 - 1) % 7;
2057 2074
2058 snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d ", 2075 snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d ",
2059 timedate[0], timedate[1], timedate[2]); 2076 tm->tm_hour, tm->tm_min, tm->tm_sec);
2060 lcd_puts(0, 1, buffer); 2077 lcd_puts(0, 1, buffer);
2061 2078
2062 /* recalculate the positions and offsets */ 2079 /* recalculate the positions and offsets */
@@ -2091,17 +2108,17 @@ bool set_time(char* string, int timedate[])
2091 2108
2092 lcd_getstringsize(buffer, &width, &prev_line_height); 2109 lcd_getstringsize(buffer, &width, &prev_line_height);
2093 2110
2094 snprintf(buffer, sizeof(buffer), "%s 20%02d %s %02d ", 2111 snprintf(buffer, sizeof(buffer), "%s %04d %s %02d ",
2095 str(dayname[timedate[6]]), timedate[3], 2112 str(dayname[tm->tm_wday]), tm->tm_year+1900,
2096 str(monthname[timedate[4] - 1]), timedate[5]); 2113 str(monthname[tm->tm_mon]), tm->tm_mday);
2097 lcd_puts(0, 2, buffer); 2114 lcd_puts(0, 2, buffer);
2098 2115
2099 /* recalculate the positions and offsets */ 2116 /* recalculate the positions and offsets */
2100 lcd_getstringsize(buffer, &width, &line_height); 2117 lcd_getstringsize(buffer, &width, &line_height);
2101 2118
2102 /* store these 2 to prevent _repeated_ strlen calls */ 2119 /* store these 2 to prevent _repeated_ strlen calls */
2103 monthname_len = strlen(str(monthname[timedate[4] - 1])); 2120 monthname_len = strlen(str(monthname[tm->tm_mon]));
2104 dayname_len = strlen(str(dayname[timedate[6]])); 2121 dayname_len = strlen(str(dayname[tm->tm_wday]));
2105 2122
2106 /* weekday */ 2123 /* weekday */
2107 strncpy(reffub, buffer, dayname_len); 2124 strncpy(reffub, buffer, dayname_len);
@@ -2155,26 +2172,35 @@ bool set_time(char* string, int timedate[])
2155 case 0: /* hour */ 2172 case 0: /* hour */
2156 min = 0; 2173 min = 0;
2157 steps = 24; 2174 steps = 24;
2175 valptr = &tm->tm_hour;
2158 break; 2176 break;
2159 case 1: /* minute */ 2177 case 1: /* minute */
2178 min = 0;
2179 steps = 60;
2180 valptr = &tm->tm_min;
2181 break;
2160 case 2: /* second */ 2182 case 2: /* second */
2161 min = 0; 2183 min = 0;
2162 steps = 60; 2184 steps = 60;
2185 valptr = &tm->tm_sec;
2163 break; 2186 break;
2164 case 3: /* year */ 2187 case 3: /* year */
2165 min = 0; 2188 min = 1;
2166 steps = 100; 2189 steps = 200;
2190 valptr = &tm->tm_year;
2167 break; 2191 break;
2168 case 4: /* month */ 2192 case 4: /* month */
2169 min = 1; 2193 min = 0;
2170 steps = 12; 2194 steps = 12;
2195 valptr = &tm->tm_mon;
2171 break; 2196 break;
2172 case 5: /* day */ 2197 case 5: /* day */
2173 min = 1; 2198 min = 1;
2174 steps = daysinmonth[timedate[4] - 1]; 2199 steps = daysinmonth[tm->tm_mon];
2200 valptr = &tm->tm_mday;
2175 break; 2201 break;
2176 } 2202 }
2177 say_time(cursorpos, timedate); 2203 say_time(cursorpos, tm);
2178 } 2204 }
2179 2205
2180 button = button_get_w_tmo(HZ/2); 2206 button = button_get_w_tmo(HZ/2);
@@ -2187,43 +2213,27 @@ bool set_time(char* string, int timedate[])
2187 break; 2213 break;
2188 case BUTTON_UP: 2214 case BUTTON_UP:
2189 case BUTTON_UP | BUTTON_REPEAT: 2215 case BUTTON_UP | BUTTON_REPEAT:
2190 timedate[cursorpos] = (timedate[cursorpos] + steps - min + 1) % 2216 *valptr = (*valptr + steps - min + 1) %
2191 steps + min; 2217 steps + min;
2192 if(timedate[cursorpos] == 0) 2218 if(*valptr == 0)
2193 timedate[cursorpos] += min; 2219 *valptr = min;
2194 say_time(cursorpos, timedate); 2220 say_time(cursorpos, tm);
2195 break; 2221 break;
2196 case BUTTON_DOWN: 2222 case BUTTON_DOWN:
2197 case BUTTON_DOWN | BUTTON_REPEAT: 2223 case BUTTON_DOWN | BUTTON_REPEAT:
2198 timedate[cursorpos]=(timedate[cursorpos]+steps - min - 1) % 2224 *valptr = (*valptr + steps - min - 1) %
2199 steps + min; 2225 steps + min;
2200 if(timedate[cursorpos] == 0) 2226 if(*valptr == 0)
2201 timedate[cursorpos] += min; 2227 *valptr = min;
2202 say_time(cursorpos, timedate); 2228 say_time(cursorpos, tm);
2203 break; 2229 break;
2204 case BUTTON_ON: 2230 case BUTTON_ON:
2205 done = true; 2231 done = true;
2206 if (timedate[6] == 0) /* rtc needs 1 .. 7 */
2207 timedate[6] = 7;
2208 break; 2232 break;
2209 case BUTTON_OFF: 2233 case BUTTON_OFF:
2210 done = true; 2234 done = true;
2211 timedate[0] = -1; 2235 tm->tm_year = -1;
2212 break; 2236 break;
2213#ifdef HAVE_RECORDER_KEYPAD
2214 case BUTTON_F3:
2215#ifdef HAVE_LCD_BITMAP
2216 global_settings.statusbar = !global_settings.statusbar;
2217 settings_save();
2218 if(global_settings.statusbar)
2219 lcd_setmargins(0, STATUSBAR_HEIGHT);
2220 else
2221 lcd_setmargins(0, 0);
2222 lcd_clear_display();
2223 lcd_puts_scroll(0, 0, string);
2224#endif
2225 break;
2226#endif
2227 2237
2228 case SYS_USB_CONNECTED: 2238 case SYS_USB_CONNECTED:
2229 usb_screen(); 2239 usb_screen();
diff --git a/apps/settings.h b/apps/settings.h
index 0bf67b474b..8d602f17ac 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -23,6 +23,7 @@
23#include <stdbool.h> 23#include <stdbool.h>
24#include "config.h" 24#include "config.h"
25#include "file.h" 25#include "file.h"
26#include "timefuncs.h"
26 27
27#define ROCKBOX_DIR "/.rockbox" 28#define ROCKBOX_DIR "/.rockbox"
28#define FONT_DIR "/fonts" 29#define FONT_DIR "/fonts"
@@ -237,7 +238,7 @@ bool set_option(char* string, void* variable, enum optiontype type,
237 struct opt_items* options, int numoptions, void (*function)(int)); 238 struct opt_items* options, int numoptions, void (*function)(int));
238bool set_int(char* string, char* unit, int voice_unit, int* variable, 239bool set_int(char* string, char* unit, int voice_unit, int* variable,
239 void (*function)(int), int step, int min, int max ); 240 void (*function)(int), int step, int min, int max );
240bool set_time(char* string, int timedate[]); 241bool set_time_screen(char* string, struct tm *tm);
241int read_line(int fd, char* buffer, int buffer_size); 242int read_line(int fd, char* buffer, int buffer_size);
242void set_file(char* filename, char* setting, int maxlen); 243void set_file(char* filename, char* setting, int maxlen);
243 244
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index 10d3665b97..7150dd239d 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -21,6 +21,7 @@
21 21
22#include <stdio.h> 22#include <stdio.h>
23#include <stdbool.h> 23#include <stdbool.h>
24#include <string.h>
24 25
25#include "lcd.h" 26#include "lcd.h"
26#include "menu.h" 27#include "menu.h"
@@ -41,6 +42,7 @@
41#include "tree.h" 42#include "tree.h"
42#include "screens.h" 43#include "screens.h"
43#include "talk.h" 44#include "talk.h"
45#include "timefuncs.h"
44#ifdef HAVE_LCD_BITMAP 46#ifdef HAVE_LCD_BITMAP
45#include "peakmeter.h" 47#include "peakmeter.h"
46#endif 48#endif
@@ -685,7 +687,8 @@ static bool trickle_charge(void)
685#ifdef HAVE_RTC 687#ifdef HAVE_RTC
686static bool timedate_set(void) 688static bool timedate_set(void)
687{ 689{
688 int timedate[7]; /* hour,minute,second,year,month,day,dayofweek */ 690 struct tm tm;
691 int timedate[8];
689 bool result; 692 bool result;
690 693
691 timedate[0] = rtc_read(0x03); /* hour */ 694 timedate[0] = rtc_read(0x03); /* hour */
@@ -695,67 +698,27 @@ static bool timedate_set(void)
695 timedate[4] = rtc_read(0x06); /* month */ 698 timedate[4] = rtc_read(0x06); /* month */
696 timedate[5] = rtc_read(0x05); /* day */ 699 timedate[5] = rtc_read(0x05); /* day */
697 700
698 /* day of week not read, calculated in set_time() */ 701 /* Make a local copy of the time struct */
699 /* hour */ 702 memcpy(&tm, get_time(), sizeof(struct tm));
700 timedate[0] = ((timedate[0] & 0x30) >> 4) * 10 + (timedate[0] & 0x0f);
701 /* minute */
702 timedate[1] = ((timedate[1] & 0x70) >> 4) * 10 + (timedate[1] & 0x0f);
703 /* second */
704 timedate[2] = ((timedate[2] & 0x70) >> 4) * 10 + (timedate[2] & 0x0f);
705 /* year */
706 timedate[3] = ((timedate[3] & 0xf0) >> 4) * 10 + (timedate[3] & 0x0f);
707 /* month */
708 timedate[4] = ((timedate[4] & 0x10) >> 4) * 10 + (timedate[4] & 0x0f);
709 /* day */
710 timedate[5] = ((timedate[5] & 0x30) >> 4) * 10 + (timedate[5] & 0x0f);
711 703
712 /* do some range checks */ 704 /* do some range checks */
713 /* This prevents problems with time/date setting after a power loss */ 705 /* This prevents problems with time/date setting after a power loss */
714 if (timedate[0] < 0 || timedate[0] > 23 || 706 if (!valid_time(&tm))
715 timedate[1] < 0 || timedate[1] > 59 ||
716 timedate[2] < 0 || timedate[2] > 59 ||
717 timedate[3] < 0 || timedate[3] > 99 ||
718 timedate[4] < 1 || timedate[4] > 12 ||
719 timedate[5] < 1 || timedate[5] > 31)
720 { 707 {
721 /* hour */ 708 /* hour */
722 timedate[0] = 0; 709 tm.tm_hour = 0;
723 /* minute */ 710 tm.tm_min = 0;
724 timedate[1] = 0; 711 tm.tm_sec = 0;
725 /* second */ 712 tm.tm_mday = 1;
726 timedate[2] = 0; 713 tm.tm_mon = 0;
727 /* year */ 714 tm.tm_wday = 1;
728 timedate[3] = 3; 715 tm.tm_year = 100;
729 /* month */
730 timedate[4] = 1;
731 /* day */
732 timedate[5] = 1;
733 } 716 }
734 717
735 result = set_time(str(LANG_TIME),timedate); 718 result = set_time_screen(str(LANG_TIME), &tm);
736 719
737 if(timedate[0] != -1) { 720 if(tm.tm_year != -1) {
738 /* hour */ 721 set_time(&tm);
739 timedate[0] = ((timedate[0]/10) << 4 | timedate[0]%10) & 0x3f;
740 /* minute */
741 timedate[1] = ((timedate[1]/10) << 4 | timedate[1]%10) & 0x7f;
742 /* second */
743 timedate[2] = ((timedate[2]/10) << 4 | timedate[2]%10) & 0x7f;
744 /* year */
745 timedate[3] = ((timedate[3]/10) << 4 | timedate[3]%10) & 0xff;
746 /* month */
747 timedate[4] = ((timedate[4]/10) << 4 | timedate[4]%10) & 0x1f;
748 /* day */
749 timedate[5] = ((timedate[5]/10) << 4 | timedate[5]%10) & 0x3f;
750
751 rtc_write(0x03, timedate[0] | (rtc_read(0x03) & 0xc0)); /* hour */
752 rtc_write(0x02, timedate[1] | (rtc_read(0x02) & 0x80)); /* minute */
753 rtc_write(0x01, timedate[2] | (rtc_read(0x01) & 0x80)); /* second */
754 rtc_write(0x07, timedate[3]); /* year */
755 rtc_write(0x06, timedate[4] | (rtc_read(0x06) & 0xe0)); /* month */
756 rtc_write(0x05, timedate[5] | (rtc_read(0x05) & 0xc0)); /* day */
757 rtc_write(0x04, timedate[6] | (rtc_read(0x04) & 0xf8)); /* dayofweek */
758 rtc_write(0x00, 0x00); /* 0.1 + 0.01 seconds */
759 } 722 }
760 return result; 723 return result;
761} 724}
diff --git a/firmware/common/timefuncs.c b/firmware/common/timefuncs.c
index 23444e2e43..e682454ce2 100644
--- a/firmware/common/timefuncs.c
+++ b/firmware/common/timefuncs.c
@@ -23,10 +23,28 @@
23#include "timefuncs.h" 23#include "timefuncs.h"
24#include "debug.h" 24#include "debug.h"
25 25
26#ifndef SIMULATOR
26static struct tm tm; 27static struct tm tm;
28#endif
29
30bool valid_time(struct tm *tm)
31{
32 if (tm->tm_hour < 0 || tm->tm_hour > 23 ||
33 tm->tm_sec < 0 || tm->tm_sec > 59 ||
34 tm->tm_min < 0 || tm->tm_min > 59 ||
35 tm->tm_year < 100 || tm->tm_year > 199 ||
36 tm->tm_mon < 0 || tm->tm_mon > 11 ||
37 tm->tm_wday < 1 || tm->tm_wday > 7 ||
38 tm->tm_mday < 1 || tm->tm_mday > 31)
39 return false;
40 else
41 return true;
42}
43
27 44
28struct tm *get_time(void) 45struct tm *get_time(void)
29{ 46{
47#ifndef SIMULATOR
30#ifdef HAVE_RTC 48#ifdef HAVE_RTC
31 char rtcbuf[8]; 49 char rtcbuf[8];
32 50
@@ -41,6 +59,8 @@ struct tm *get_time(void)
41 tm.tm_mon = ((rtcbuf[6] & 0x10) >> 4) * 10 + (rtcbuf[6] & 0x0f) - 1; 59 tm.tm_mon = ((rtcbuf[6] & 0x10) >> 4) * 10 + (rtcbuf[6] & 0x0f) - 1;
42 tm.tm_year = ((rtcbuf[7] & 0xf0) >> 4) * 10 + (rtcbuf[7] & 0x0f) + 100; 60 tm.tm_year = ((rtcbuf[7] & 0xf0) >> 4) * 10 + (rtcbuf[7] & 0x0f) + 100;
43 tm.tm_wday = rtcbuf[4] & 0x07; 61 tm.tm_wday = rtcbuf[4] & 0x07;
62 if(tm.tm_wday == 7)
63 tm.tm_wday = 0;
44 tm.tm_yday = 0; /* Not implemented for now */ 64 tm.tm_yday = 0; /* Not implemented for now */
45 tm.tm_isdst = -1; /* Not implemented for now */ 65 tm.tm_isdst = -1; /* Not implemented for now */
46#else 66#else
@@ -55,4 +75,44 @@ struct tm *get_time(void)
55 tm.tm_isdst = -1; /* Not implemented for now */ 75 tm.tm_isdst = -1; /* Not implemented for now */
56#endif 76#endif
57 return &tm; 77 return &tm;
78#else
79 time_t now = time(NULL);
80 return localtime(&now);
81#endif
82}
83
84int set_time(struct tm *tm)
85{
86#ifdef HAVE_RTC
87 int rc;
88 int tmp;
89
90 if (valid_time(tm))
91 {
92 rc = rtc_write(1, ((tm->tm_sec/10) << 4) | (tm->tm_sec%10));
93 rc |= rtc_write(2, ((tm->tm_min/10) << 4) | (tm->tm_min%10));
94 rc |= rtc_write(3, ((tm->tm_hour/10) << 4) | (tm->tm_hour%10));
95 tmp = tm->tm_wday;
96 if(tmp == 0)
97 tmp = 7;
98 rc |= rtc_write(4, tmp);
99 rc |= rtc_write(5, ((tm->tm_mday/10) << 4) | (tm->tm_mday%10));
100 rc |= rtc_write(6, (((tm->tm_mon+1)/10) << 4) | ((tm->tm_mon+1)%10));
101 rc |= rtc_write(7, (((tm->tm_year-100)/10) << 4) | ((tm->tm_year-100)%10));
102
103 rc |= rtc_write(8, 0x80); /* Out=1, calibration = 0 */
104
105 if(rc)
106 return -1;
107 else
108 return 0;
109 }
110 else
111 {
112 return -2;
113 }
114#else
115 (void)tm;
116 return 0;
117#endif
58} 118}
diff --git a/firmware/include/timefuncs.h b/firmware/include/timefuncs.h
index 3845b946c5..5c6719e709 100644
--- a/firmware/include/timefuncs.h
+++ b/firmware/include/timefuncs.h
@@ -21,24 +21,11 @@
21#define _TIMEFUNCS_H_ 21#define _TIMEFUNCS_H_
22 22
23#include "config.h" 23#include "config.h"
24 24#include <stdbool.h>
25#ifndef SIMULATOR 25#include "time.h"
26
27struct tm
28{
29 int tm_sec; /* seconds */
30 int tm_min; /* minutes */
31 int tm_hour; /* hours */
32 int tm_mday; /* day of the month */
33 int tm_mon; /* month */
34 int tm_year; /* year since 1900 */
35 int tm_wday; /* day of the week */
36 int tm_yday; /* day in the year */
37 int tm_isdst; /* daylight saving time */
38};
39
40#endif
41 26
42struct tm *get_time(void); 27struct tm *get_time(void);
28int set_time(struct tm *tm);
29bool valid_time(struct tm *tm);
43 30
44#endif /* _TIMEFUNCS_H_ */ 31#endif /* _TIMEFUNCS_H_ */
diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c
index 98c574ffaa..fab61b8ed3 100644
--- a/uisimulator/common/stubs.c
+++ b/uisimulator/common/stubs.c
@@ -124,13 +124,6 @@ void backlight_set_on_when_charging(bool beep)
124 (void)beep; 124 (void)beep;
125} 125}
126 126
127/* original is in firmware/common/timefuncs.c */
128struct tm *get_time(void)
129{
130 time_t now = time(NULL);
131 return localtime(&now);
132}
133
134int rtc_read(int address) 127int rtc_read(int address)
135{ 128{
136 time_t now = time(NULL); 129 time_t now = time(NULL);
@@ -161,7 +154,7 @@ int rtc_read(int address)
161 154
162int rtc_write(int address, int value) 155int rtc_write(int address, int value)
163{ 156{
164 DEBUGF("write %x to address %x\n", value, address); 157 DEBUGF("write %02x to address %02x\n", value, address);
165 return 0; 158 return 0;
166} 159}
167 160
diff --git a/uisimulator/win32/Makefile b/uisimulator/win32/Makefile
index fe7086391b..05acb9c41c 100644
--- a/uisimulator/win32/Makefile
+++ b/uisimulator/win32/Makefile
@@ -97,7 +97,8 @@ else
97 LCDSRSC = lcd-playersim.c lcd-player.c lcd-player-charset.c font-player.c 97 LCDSRSC = lcd-playersim.c lcd-player.c lcd-player-charset.c font-player.c
98endif 98endif
99FIRMSRCS = $(LCDSRSC) id3.c mp3data.c usb.c mpeg.c mp3_playback.c \ 99FIRMSRCS = $(LCDSRSC) id3.c mp3data.c usb.c mpeg.c mp3_playback.c \
100 powermgmt.c power.c sprintf.c buffer.c lcd-common.c strtok.c random.c 100 powermgmt.c power.c sprintf.c buffer.c lcd-common.c strtok.c random.c \
101 timefuncs.c
101 102
102APPS = main.c tree.c menu.c credits.c main_menu.c icons.c language.c \ 103APPS = main.c tree.c menu.c credits.c main_menu.c icons.c language.c \
103 playlist.c wps.c wps-display.c settings.c status.c \ 104 playlist.c wps.c wps-display.c settings.c status.c \
@@ -284,6 +285,9 @@ $(OBJDIR)/sprintf.o: $(COMMON)/sprintf.c
284$(OBJDIR)/strtok.o: $(COMMON)/strtok.c 285$(OBJDIR)/strtok.o: $(COMMON)/strtok.c
285 $(CC) $(CFLAGS) -c $< -o $@ 286 $(CC) $(CFLAGS) -c $< -o $@
286 287
288$(OBJDIR)/timefuncs.o: $(COMMON)/timefuncs.c
289 $(CC) $(CFLAGS) -c $< -o $@
290
287$(OBJDIR)/stubs.o: $(SIMCOMMON)/stubs.c 291$(OBJDIR)/stubs.o: $(SIMCOMMON)/stubs.c
288 $(CC) $(CFLAGS) -c $< -o $@ 292 $(CC) $(CFLAGS) -c $< -o $@
289 293
diff --git a/uisimulator/win32/timefuncs.h b/uisimulator/win32/timefuncs.h
index c1b6ef8196..59e8b249eb 100644
--- a/uisimulator/win32/timefuncs.h
+++ b/uisimulator/win32/timefuncs.h
@@ -1,4 +1,7 @@
1#include <time.h> 1#include <time.h>
2#include <stdbool.h>
2 3
3/* struct tm defined */ 4/* struct tm defined */
4struct tm *get_time(void); 5struct tm *get_time(void);
6int set_time(struct tm *tm);
7bool valid_time(struct tm *tm);
diff --git a/uisimulator/x11/Makefile b/uisimulator/x11/Makefile
index fb609ea2c3..6fbc413a3c 100644
--- a/uisimulator/x11/Makefile
+++ b/uisimulator/x11/Makefile
@@ -97,7 +97,7 @@ else
97 LCDSRSC = lcd-playersim.c lcd-player.c font-player.c lcd-player-charset.c 97 LCDSRSC = lcd-playersim.c lcd-player.c font-player.c lcd-player-charset.c
98endif 98endif
99FIRMSRCS = $(LCDSRSC) id3.c debug.c usb.c mpeg.c mp3_playback.c power.c\ 99FIRMSRCS = $(LCDSRSC) id3.c debug.c usb.c mpeg.c mp3_playback.c power.c\
100 powermgmt.c panic.c mp3data.c sprintf.c buffer.c 100 powermgmt.c panic.c mp3data.c sprintf.c buffer.c timefuncs.c
101 101
102APPS = main.c tree.c menu.c credits.c main_menu.c language.c\ 102APPS = main.c tree.c menu.c credits.c main_menu.c language.c\
103 playlist.c wps.c wps-display.c settings.c status.c icons.c\ 103 playlist.c wps.c wps-display.c settings.c status.c icons.c\
@@ -264,6 +264,9 @@ $(OBJDIR)/buffer.o: $(FIRMWAREDIR)/buffer.c
264$(OBJDIR)/ctype.o: $(COMMON)/ctype.c 264$(OBJDIR)/ctype.o: $(COMMON)/ctype.c
265 $(CC) $(CFLAGS) $(APPINCLUDES) -c $< -o $@ 265 $(CC) $(CFLAGS) $(APPINCLUDES) -c $< -o $@
266 266
267$(OBJDIR)/timefuncs.o: $(COMMON)/timefuncs.c
268 $(CC) $(CFLAGS) $(APPINCLUDES) -c $< -o $@
269
267$(OBJDIR)/stubs.o: $(SIMCOMMON)/stubs.c 270$(OBJDIR)/stubs.o: $(SIMCOMMON)/stubs.c
268 $(CC) $(APPCFLAGS) -c $< -o $@ 271 $(CC) $(APPCFLAGS) -c $< -o $@
269 272
diff --git a/uisimulator/x11/timefuncs.h b/uisimulator/x11/timefuncs.h
index c1b6ef8196..59e8b249eb 100644
--- a/uisimulator/x11/timefuncs.h
+++ b/uisimulator/x11/timefuncs.h
@@ -1,4 +1,7 @@
1#include <time.h> 1#include <time.h>
2#include <stdbool.h>
2 3
3/* struct tm defined */ 4/* struct tm defined */
4struct tm *get_time(void); 5struct tm *get_time(void);
6int set_time(struct tm *tm);
7bool valid_time(struct tm *tm);