diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2004-04-21 06:49:12 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2004-04-21 06:49:12 +0000 |
commit | 1de3dd570de9a223ef6294159047ce272859e388 (patch) | |
tree | 46bb5129a222116ff837fc0c657c15ee386bfdde /apps/settings.c | |
parent | a1273a4f2ea4bbbecb52967a1be42bd3e54bcfb7 (diff) | |
download | rockbox-1de3dd570de9a223ef6294159047ce272859e388.tar.gz rockbox-1de3dd570de9a223ef6294159047ce272859e388.zip |
Moved set_time_screen() to screens.c
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4534 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/settings.c')
-rw-r--r-- | apps/settings.c | 285 |
1 files changed, 0 insertions, 285 deletions
diff --git a/apps/settings.c b/apps/settings.c index b84ef52205..c9e281dae0 100644 --- a/apps/settings.c +++ b/apps/settings.c | |||
@@ -1960,291 +1960,6 @@ bool set_option(char* string, void* variable, enum optiontype type, | |||
1960 | return false; | 1960 | return false; |
1961 | } | 1961 | } |
1962 | 1962 | ||
1963 | #ifdef HAVE_LCD_BITMAP | ||
1964 | |||
1965 | /* little helper function for voice output */ | ||
1966 | static void say_time(int cursorpos, struct tm *tm) | ||
1967 | { | ||
1968 | const int unit[] = { UNIT_HOUR, UNIT_MIN, UNIT_SEC, 0, 0, 0 }; | ||
1969 | int value = 0; | ||
1970 | |||
1971 | if (!global_settings.talk_menu) | ||
1972 | return; | ||
1973 | |||
1974 | switch(cursorpos) | ||
1975 | { | ||
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 | |||
1993 | if (cursorpos == 4) /* month */ | ||
1994 | talk_id(LANG_MONTH_JANUARY + value - 1, false); | ||
1995 | else | ||
1996 | talk_value(value, unit[cursorpos], false); | ||
1997 | } | ||
1998 | |||
1999 | |||
2000 | #define INDEX_X 0 | ||
2001 | #define INDEX_Y 1 | ||
2002 | #define INDEX_WIDTH 2 | ||
2003 | bool set_time_screen(char* string, struct tm *tm) | ||
2004 | { | ||
2005 | bool done = false; | ||
2006 | int button; | ||
2007 | int min = 0, steps = 0; | ||
2008 | int cursorpos = 0; | ||
2009 | int lastcursorpos = !cursorpos; | ||
2010 | unsigned char buffer[19]; | ||
2011 | int realyear; | ||
2012 | int julianday; | ||
2013 | int i; | ||
2014 | unsigned char reffub[5]; | ||
2015 | unsigned int width, height; | ||
2016 | unsigned int separator_width, weekday_width; | ||
2017 | unsigned int line_height, prev_line_height; | ||
2018 | const int dayname[] = {LANG_WEEKDAY_SUNDAY, | ||
2019 | LANG_WEEKDAY_MONDAY, | ||
2020 | LANG_WEEKDAY_TUESDAY, | ||
2021 | LANG_WEEKDAY_WEDNESDAY, | ||
2022 | LANG_WEEKDAY_THURSDAY, | ||
2023 | LANG_WEEKDAY_FRIDAY, | ||
2024 | LANG_WEEKDAY_SATURDAY}; | ||
2025 | const int monthname[] = {LANG_MONTH_JANUARY, | ||
2026 | LANG_MONTH_FEBRUARY, | ||
2027 | LANG_MONTH_MARCH, | ||
2028 | LANG_MONTH_APRIL, | ||
2029 | LANG_MONTH_MAY, | ||
2030 | LANG_MONTH_JUNE, | ||
2031 | LANG_MONTH_JULY, | ||
2032 | LANG_MONTH_AUGUST, | ||
2033 | LANG_MONTH_SEPTEMBER, | ||
2034 | LANG_MONTH_OCTOBER, | ||
2035 | LANG_MONTH_NOVEMBER, | ||
2036 | LANG_MONTH_DECEMBER}; | ||
2037 | char cursor[][3] = {{ 0, 8, 12}, {18, 8, 12}, {36, 8, 12}, | ||
2038 | {24, 16, 24}, {54, 16, 18}, {78, 16, 12}}; | ||
2039 | char daysinmonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; | ||
2040 | |||
2041 | int monthname_len = 0, dayname_len = 0; | ||
2042 | |||
2043 | int *valptr = NULL; | ||
2044 | |||
2045 | #ifdef HAVE_LCD_BITMAP | ||
2046 | if(global_settings.statusbar) | ||
2047 | lcd_setmargins(0, STATUSBAR_HEIGHT); | ||
2048 | else | ||
2049 | lcd_setmargins(0, 0); | ||
2050 | #endif | ||
2051 | lcd_clear_display(); | ||
2052 | lcd_puts_scroll(0, 0, string); | ||
2053 | |||
2054 | while ( !done ) { | ||
2055 | /* calculate the number of days in febuary */ | ||
2056 | realyear = tm->tm_year + 1900; | ||
2057 | if((realyear % 4 == 0 && !(realyear % 100 == 0)) || realyear % 400 == 0) | ||
2058 | daysinmonth[1] = 29; | ||
2059 | else | ||
2060 | daysinmonth[1] = 28; | ||
2061 | |||
2062 | /* fix day if month or year changed */ | ||
2063 | if (tm->tm_mday > daysinmonth[tm->tm_mon]) | ||
2064 | tm->tm_mday = daysinmonth[tm->tm_mon]; | ||
2065 | |||
2066 | /* calculate day of week */ | ||
2067 | julianday = 0; | ||
2068 | for(i = 0; i < tm->tm_mon; i++) { | ||
2069 | julianday += daysinmonth[i]; | ||
2070 | } | ||
2071 | julianday += tm->tm_mday; | ||
2072 | tm->tm_wday = (realyear + julianday + (realyear - 1) / 4 - | ||
2073 | (realyear - 1) / 100 + (realyear - 1) / 400 + 7 - 1) % 7; | ||
2074 | |||
2075 | snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d ", | ||
2076 | tm->tm_hour, tm->tm_min, tm->tm_sec); | ||
2077 | lcd_puts(0, 1, buffer); | ||
2078 | |||
2079 | /* recalculate the positions and offsets */ | ||
2080 | lcd_getstringsize(string, &width, &prev_line_height); | ||
2081 | lcd_getstringsize(buffer, &width, &line_height); | ||
2082 | lcd_getstringsize(":", &separator_width, &height); | ||
2083 | |||
2084 | /* hour */ | ||
2085 | strncpy(reffub, buffer, 2); | ||
2086 | reffub[2] = '\0'; | ||
2087 | lcd_getstringsize(reffub, &width, &height); | ||
2088 | cursor[0][INDEX_X] = 0; | ||
2089 | cursor[0][INDEX_Y] = prev_line_height; | ||
2090 | cursor[0][INDEX_WIDTH] = width; | ||
2091 | |||
2092 | /* minute */ | ||
2093 | strncpy(reffub, buffer + 3, 2); | ||
2094 | reffub[2] = '\0'; | ||
2095 | lcd_getstringsize(reffub, &width, &height); | ||
2096 | cursor[1][INDEX_X] = cursor[0][INDEX_WIDTH] + separator_width; | ||
2097 | cursor[1][INDEX_Y] = prev_line_height; | ||
2098 | cursor[1][INDEX_WIDTH] = width; | ||
2099 | |||
2100 | /* second */ | ||
2101 | strncpy(reffub, buffer + 6, 2); | ||
2102 | reffub[2] = '\0'; | ||
2103 | lcd_getstringsize(reffub, &width, &height); | ||
2104 | cursor[2][INDEX_X] = cursor[0][INDEX_WIDTH] + separator_width + | ||
2105 | cursor[1][INDEX_WIDTH] + separator_width; | ||
2106 | cursor[2][INDEX_Y] = prev_line_height; | ||
2107 | cursor[2][INDEX_WIDTH] = width; | ||
2108 | |||
2109 | lcd_getstringsize(buffer, &width, &prev_line_height); | ||
2110 | |||
2111 | snprintf(buffer, sizeof(buffer), "%s %04d %s %02d ", | ||
2112 | str(dayname[tm->tm_wday]), tm->tm_year+1900, | ||
2113 | str(monthname[tm->tm_mon]), tm->tm_mday); | ||
2114 | lcd_puts(0, 2, buffer); | ||
2115 | |||
2116 | /* recalculate the positions and offsets */ | ||
2117 | lcd_getstringsize(buffer, &width, &line_height); | ||
2118 | |||
2119 | /* store these 2 to prevent _repeated_ strlen calls */ | ||
2120 | monthname_len = strlen(str(monthname[tm->tm_mon])); | ||
2121 | dayname_len = strlen(str(dayname[tm->tm_wday])); | ||
2122 | |||
2123 | /* weekday */ | ||
2124 | strncpy(reffub, buffer, dayname_len); | ||
2125 | reffub[dayname_len] = '\0'; | ||
2126 | lcd_getstringsize(reffub, &weekday_width, &height); | ||
2127 | lcd_getstringsize(" ", &separator_width, &height); | ||
2128 | |||
2129 | /* year */ | ||
2130 | strncpy(reffub, buffer + dayname_len + 1, 4); | ||
2131 | reffub[4] = '\0'; | ||
2132 | lcd_getstringsize(reffub, &width, &height); | ||
2133 | cursor[3][INDEX_X] = weekday_width + separator_width; | ||
2134 | cursor[3][INDEX_Y] = cursor[0][INDEX_Y] + prev_line_height; | ||
2135 | cursor[3][INDEX_WIDTH] = width; | ||
2136 | |||
2137 | /* month */ | ||
2138 | strncpy(reffub, buffer + dayname_len + 6, monthname_len); | ||
2139 | reffub[monthname_len] = '\0'; | ||
2140 | lcd_getstringsize(reffub, &width, &height); | ||
2141 | cursor[4][INDEX_X] = weekday_width + separator_width + | ||
2142 | cursor[3][INDEX_WIDTH] + separator_width; | ||
2143 | cursor[4][INDEX_Y] = cursor[0][INDEX_Y] + prev_line_height; | ||
2144 | cursor[4][INDEX_WIDTH] = width; | ||
2145 | |||
2146 | /* day */ | ||
2147 | strncpy(reffub, buffer + dayname_len + monthname_len + 7, 2); | ||
2148 | reffub[2] = '\0'; | ||
2149 | lcd_getstringsize(reffub, &width, &height); | ||
2150 | cursor[5][INDEX_X] = weekday_width + separator_width + | ||
2151 | cursor[3][INDEX_WIDTH] + separator_width + | ||
2152 | cursor[4][INDEX_WIDTH] + separator_width; | ||
2153 | cursor[5][INDEX_Y] = cursor[0][INDEX_Y] + prev_line_height; | ||
2154 | cursor[5][INDEX_WIDTH] = width; | ||
2155 | |||
2156 | lcd_invertrect(cursor[cursorpos][INDEX_X], | ||
2157 | cursor[cursorpos][INDEX_Y] + lcd_getymargin(), | ||
2158 | cursor[cursorpos][INDEX_WIDTH], | ||
2159 | line_height); | ||
2160 | |||
2161 | lcd_puts(0, 4, str(LANG_TIME_SET)); | ||
2162 | lcd_puts(0, 5, str(LANG_TIME_REVERT)); | ||
2163 | #ifdef HAVE_LCD_BITMAP | ||
2164 | status_draw(true); | ||
2165 | #endif | ||
2166 | lcd_update(); | ||
2167 | |||
2168 | /* calculate the minimum and maximum for the number under cursor */ | ||
2169 | if(cursorpos!=lastcursorpos) { | ||
2170 | lastcursorpos=cursorpos; | ||
2171 | switch(cursorpos) { | ||
2172 | case 0: /* hour */ | ||
2173 | min = 0; | ||
2174 | steps = 24; | ||
2175 | valptr = &tm->tm_hour; | ||
2176 | break; | ||
2177 | case 1: /* minute */ | ||
2178 | min = 0; | ||
2179 | steps = 60; | ||
2180 | valptr = &tm->tm_min; | ||
2181 | break; | ||
2182 | case 2: /* second */ | ||
2183 | min = 0; | ||
2184 | steps = 60; | ||
2185 | valptr = &tm->tm_sec; | ||
2186 | break; | ||
2187 | case 3: /* year */ | ||
2188 | min = 1; | ||
2189 | steps = 200; | ||
2190 | valptr = &tm->tm_year; | ||
2191 | break; | ||
2192 | case 4: /* month */ | ||
2193 | min = 0; | ||
2194 | steps = 12; | ||
2195 | valptr = &tm->tm_mon; | ||
2196 | break; | ||
2197 | case 5: /* day */ | ||
2198 | min = 1; | ||
2199 | steps = daysinmonth[tm->tm_mon]; | ||
2200 | valptr = &tm->tm_mday; | ||
2201 | break; | ||
2202 | } | ||
2203 | say_time(cursorpos, tm); | ||
2204 | } | ||
2205 | |||
2206 | button = button_get_w_tmo(HZ/2); | ||
2207 | switch ( button ) { | ||
2208 | case BUTTON_LEFT: | ||
2209 | cursorpos = (cursorpos + 6 - 1) % 6; | ||
2210 | break; | ||
2211 | case BUTTON_RIGHT: | ||
2212 | cursorpos = (cursorpos + 6 + 1) % 6; | ||
2213 | break; | ||
2214 | case BUTTON_UP: | ||
2215 | case BUTTON_UP | BUTTON_REPEAT: | ||
2216 | *valptr = (*valptr + steps - min + 1) % | ||
2217 | steps + min; | ||
2218 | if(*valptr == 0) | ||
2219 | *valptr = min; | ||
2220 | say_time(cursorpos, tm); | ||
2221 | break; | ||
2222 | case BUTTON_DOWN: | ||
2223 | case BUTTON_DOWN | BUTTON_REPEAT: | ||
2224 | *valptr = (*valptr + steps - min - 1) % | ||
2225 | steps + min; | ||
2226 | if(*valptr == 0) | ||
2227 | *valptr = min; | ||
2228 | say_time(cursorpos, tm); | ||
2229 | break; | ||
2230 | case BUTTON_ON: | ||
2231 | done = true; | ||
2232 | break; | ||
2233 | case BUTTON_OFF: | ||
2234 | done = true; | ||
2235 | tm->tm_year = -1; | ||
2236 | break; | ||
2237 | |||
2238 | case SYS_USB_CONNECTED: | ||
2239 | usb_screen(); | ||
2240 | return true; | ||
2241 | } | ||
2242 | } | ||
2243 | |||
2244 | return false; | ||
2245 | } | ||
2246 | #endif | ||
2247 | |||
2248 | #ifdef HAVE_MAS3587F | 1963 | #ifdef HAVE_MAS3587F |
2249 | /* This array holds the record timer interval lengths, in seconds */ | 1964 | /* This array holds the record timer interval lengths, in seconds */ |
2250 | static unsigned long rec_timer_seconds[] = | 1965 | static unsigned long rec_timer_seconds[] = |