diff options
Diffstat (limited to 'apps/settings_menu.c')
-rw-r--r-- | apps/settings_menu.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/apps/settings_menu.c b/apps/settings_menu.c index 7ab1b0479d..948f1eb180 100644 --- a/apps/settings_menu.c +++ b/apps/settings_menu.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include "backlight.h" | 33 | #include "backlight.h" |
34 | #include "playlist.h" /* for playlist_shuffle */ | 34 | #include "playlist.h" /* for playlist_shuffle */ |
35 | #include "powermgmt.h" | 35 | #include "powermgmt.h" |
36 | #include "rtc.h" | ||
36 | 37 | ||
37 | static void shuffle(void) | 38 | static void shuffle(void) |
38 | { | 39 | { |
@@ -83,6 +84,47 @@ static void statusbar(void) | |||
83 | } | 84 | } |
84 | #endif | 85 | #endif |
85 | 86 | ||
87 | #ifdef HAVE_RTC | ||
88 | static void timedate_set(void) | ||
89 | { | ||
90 | int timedate[7]; /* hour,minute,second,day,month,year,dayofweek */ | ||
91 | |||
92 | |||
93 | timedate[0] = rtc_read(0x03); /* hour */ | ||
94 | timedate[1] = rtc_read(0x02); /* minute */ | ||
95 | timedate[2] = rtc_read(0x01); /* second */ | ||
96 | timedate[3] = rtc_read(0x05); /* day */ | ||
97 | timedate[4] = rtc_read(0x06); /* month */ | ||
98 | timedate[5] = rtc_read(0x07); /* year */ | ||
99 | /* day of week not read, calculated */ | ||
100 | timedate[0] = ((timedate[0] & 0x70) >> 4) * 10 + (timedate[0] & 0x0f); /* hour */ | ||
101 | timedate[1] = ((timedate[1] & 0xf0) >> 4) * 10 + (timedate[1] & 0x0f); /* minute */ | ||
102 | timedate[2] = ((timedate[2] & 0x30) >> 4) * 10 + (timedate[2] & 0x0f); /* second */ | ||
103 | timedate[3] = ((timedate[3] & 0x30) >> 4) * 10 + (timedate[3] & 0x0f); /* day */ | ||
104 | timedate[4] = ((timedate[4] & 0x30) >> 4) * 10 + (timedate[4] & 0x0f); /* month */ | ||
105 | timedate[5] = ((timedate[5] & 0x30) >> 4) * 10 + (timedate[5] & 0x0f); /* year */ | ||
106 | |||
107 | set_time("[Set time/date]",timedate); | ||
108 | |||
109 | if(timedate[0] != -1) { | ||
110 | timedate[0] = ((timedate[0]/10) << 4 | timedate[0]%10) & 0x3f; /* hour */ | ||
111 | timedate[1] = ((timedate[1]/10) << 4 | timedate[1]%10) & 0x7f; /* minute */ | ||
112 | timedate[2] = ((timedate[2]/10) << 4 | timedate[2]%10) & 0x7f; /* second */ | ||
113 | timedate[3] = ((timedate[3]/10) << 4 | timedate[3]%10) & 0x3f; /* day */ | ||
114 | timedate[4] = ((timedate[4]/10) << 4 | timedate[4]%10) & 0x1f; /* month */ | ||
115 | timedate[5] = ((timedate[5]/10) << 4 | timedate[5]%10) & 0xff; /* year */ | ||
116 | rtc_write(0x03, timedate[0] | (rtc_read(0x03) & 0xc0)); /* hour */ | ||
117 | rtc_write(0x02, timedate[1] | (rtc_read(0x02) & 0x80)); /* minute */ | ||
118 | rtc_write(0x01, timedate[2] | (rtc_read(0x01) & 0x80)); /* second */ | ||
119 | rtc_write(0x05, timedate[3] | (rtc_read(0x05) & 0xc0)); /* day */ | ||
120 | rtc_write(0x06, timedate[4] | (rtc_read(0x06) & 0xe0)); /* month */ | ||
121 | rtc_write(0x07, timedate[5]); /* year */ | ||
122 | rtc_write(0x04, timedate[6] | (rtc_read(0x04) & 0x07)); /* dayofweek */ | ||
123 | rtc_write(0x00, 0x00); /* 0.1 + 0.01 seconds */ | ||
124 | } | ||
125 | } | ||
126 | #endif | ||
127 | |||
86 | void settings_menu(void) | 128 | void settings_menu(void) |
87 | { | 129 | { |
88 | int m; | 130 | int m; |
@@ -99,6 +141,9 @@ void settings_menu(void) | |||
99 | #ifdef HAVE_LCD_BITMAP | 141 | #ifdef HAVE_LCD_BITMAP |
100 | { "Status bar", statusbar }, | 142 | { "Status bar", statusbar }, |
101 | #endif | 143 | #endif |
144 | #ifdef HAVE_RTC | ||
145 | { "Time/Date", timedate_set }, | ||
146 | #endif | ||
102 | }; | 147 | }; |
103 | bool old_shuffle = global_settings.playlist_shuffle; | 148 | bool old_shuffle = global_settings.playlist_shuffle; |
104 | 149 | ||