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 | |
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')
-rw-r--r-- | apps/screens.c | 287 | ||||
-rw-r--r-- | apps/screens.h | 6 | ||||
-rw-r--r-- | apps/settings.c | 285 |
3 files changed, 293 insertions, 285 deletions
diff --git a/apps/screens.c b/apps/screens.c index c2320a0217..9e24ba9a18 100644 --- a/apps/screens.c +++ b/apps/screens.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include "powermgmt.h" | 38 | #include "powermgmt.h" |
39 | #include "adc.h" | 39 | #include "adc.h" |
40 | #include "action.h" | 40 | #include "action.h" |
41 | #include "talk.h" | ||
41 | 42 | ||
42 | #ifdef HAVE_LCD_BITMAP | 43 | #ifdef HAVE_LCD_BITMAP |
43 | #define BMPHEIGHT_usb_logo 32 | 44 | #define BMPHEIGHT_usb_logo 32 |
@@ -809,3 +810,289 @@ void charging_splash(void) | |||
809 | splash(2*HZ, true, str(LANG_BATTERY_CHARGE)); | 810 | splash(2*HZ, true, str(LANG_BATTERY_CHARGE)); |
810 | while (button_get(false)); | 811 | while (button_get(false)); |
811 | } | 812 | } |
813 | |||
814 | |||
815 | #ifdef HAVE_LCD_BITMAP | ||
816 | |||
817 | /* little helper function for voice output */ | ||
818 | static void say_time(int cursorpos, struct tm *tm) | ||
819 | { | ||
820 | const int unit[] = { UNIT_HOUR, UNIT_MIN, UNIT_SEC, 0, 0, 0 }; | ||
821 | int value = 0; | ||
822 | |||
823 | if (!global_settings.talk_menu) | ||
824 | return; | ||
825 | |||
826 | switch(cursorpos) | ||
827 | { | ||
828 | case 0: | ||
829 | value = tm->tm_hour; | ||
830 | break; | ||
831 | case 1: | ||
832 | value = tm->tm_min; | ||
833 | break; | ||
834 | case 2: | ||
835 | value = tm->tm_sec; | ||
836 | break; | ||
837 | case 3: | ||
838 | value = tm->tm_year + 1900; | ||
839 | break; | ||
840 | case 5: | ||
841 | value = tm->tm_mday; | ||
842 | break; | ||
843 | } | ||
844 | |||
845 | if (cursorpos == 4) /* month */ | ||
846 | talk_id(LANG_MONTH_JANUARY + value - 1, false); | ||
847 | else | ||
848 | talk_value(value, unit[cursorpos], false); | ||
849 | } | ||
850 | |||
851 | |||
852 | #define INDEX_X 0 | ||
853 | #define INDEX_Y 1 | ||
854 | #define INDEX_WIDTH 2 | ||
855 | bool set_time_screen(char* string, struct tm *tm) | ||
856 | { | ||
857 | bool done = false; | ||
858 | int button; | ||
859 | int min = 0, steps = 0; | ||
860 | int cursorpos = 0; | ||
861 | int lastcursorpos = !cursorpos; | ||
862 | unsigned char buffer[19]; | ||
863 | int realyear; | ||
864 | int julianday; | ||
865 | int i; | ||
866 | unsigned char reffub[5]; | ||
867 | unsigned int width, height; | ||
868 | unsigned int separator_width, weekday_width; | ||
869 | unsigned int line_height, prev_line_height; | ||
870 | const int dayname[] = {LANG_WEEKDAY_SUNDAY, | ||
871 | LANG_WEEKDAY_MONDAY, | ||
872 | LANG_WEEKDAY_TUESDAY, | ||
873 | LANG_WEEKDAY_WEDNESDAY, | ||
874 | LANG_WEEKDAY_THURSDAY, | ||
875 | LANG_WEEKDAY_FRIDAY, | ||
876 | LANG_WEEKDAY_SATURDAY}; | ||
877 | const int monthname[] = {LANG_MONTH_JANUARY, | ||
878 | LANG_MONTH_FEBRUARY, | ||
879 | LANG_MONTH_MARCH, | ||
880 | LANG_MONTH_APRIL, | ||
881 | LANG_MONTH_MAY, | ||
882 | LANG_MONTH_JUNE, | ||
883 | LANG_MONTH_JULY, | ||
884 | LANG_MONTH_AUGUST, | ||
885 | LANG_MONTH_SEPTEMBER, | ||
886 | LANG_MONTH_OCTOBER, | ||
887 | LANG_MONTH_NOVEMBER, | ||
888 | LANG_MONTH_DECEMBER}; | ||
889 | char cursor[][3] = {{ 0, 8, 12}, {18, 8, 12}, {36, 8, 12}, | ||
890 | {24, 16, 24}, {54, 16, 18}, {78, 16, 12}}; | ||
891 | char daysinmonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; | ||
892 | |||
893 | int monthname_len = 0, dayname_len = 0; | ||
894 | |||
895 | int *valptr = NULL; | ||
896 | |||
897 | #ifdef HAVE_LCD_BITMAP | ||
898 | if(global_settings.statusbar) | ||
899 | lcd_setmargins(0, STATUSBAR_HEIGHT); | ||
900 | else | ||
901 | lcd_setmargins(0, 0); | ||
902 | #endif | ||
903 | lcd_clear_display(); | ||
904 | lcd_puts_scroll(0, 0, string); | ||
905 | |||
906 | while ( !done ) { | ||
907 | /* calculate the number of days in febuary */ | ||
908 | realyear = tm->tm_year + 1900; | ||
909 | if((realyear % 4 == 0 && !(realyear % 100 == 0)) || realyear % 400 == 0) | ||
910 | daysinmonth[1] = 29; | ||
911 | else | ||
912 | daysinmonth[1] = 28; | ||
913 | |||
914 | /* fix day if month or year changed */ | ||
915 | if (tm->tm_mday > daysinmonth[tm->tm_mon]) | ||
916 | tm->tm_mday = daysinmonth[tm->tm_mon]; | ||
917 | |||
918 | /* calculate day of week */ | ||
919 | julianday = 0; | ||
920 | for(i = 0; i < tm->tm_mon; i++) { | ||
921 | julianday += daysinmonth[i]; | ||
922 | } | ||
923 | julianday += tm->tm_mday; | ||
924 | tm->tm_wday = (realyear + julianday + (realyear - 1) / 4 - | ||
925 | (realyear - 1) / 100 + (realyear - 1) / 400 + 7 - 1) % 7; | ||
926 | |||
927 | snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d ", | ||
928 | tm->tm_hour, tm->tm_min, tm->tm_sec); | ||
929 | lcd_puts(0, 1, buffer); | ||
930 | |||
931 | /* recalculate the positions and offsets */ | ||
932 | lcd_getstringsize(string, &width, &prev_line_height); | ||
933 | lcd_getstringsize(buffer, &width, &line_height); | ||
934 | lcd_getstringsize(":", &separator_width, &height); | ||
935 | |||
936 | /* hour */ | ||
937 | strncpy(reffub, buffer, 2); | ||
938 | reffub[2] = '\0'; | ||
939 | lcd_getstringsize(reffub, &width, &height); | ||
940 | cursor[0][INDEX_X] = 0; | ||
941 | cursor[0][INDEX_Y] = prev_line_height; | ||
942 | cursor[0][INDEX_WIDTH] = width; | ||
943 | |||
944 | /* minute */ | ||
945 | strncpy(reffub, buffer + 3, 2); | ||
946 | reffub[2] = '\0'; | ||
947 | lcd_getstringsize(reffub, &width, &height); | ||
948 | cursor[1][INDEX_X] = cursor[0][INDEX_WIDTH] + separator_width; | ||
949 | cursor[1][INDEX_Y] = prev_line_height; | ||
950 | cursor[1][INDEX_WIDTH] = width; | ||
951 | |||
952 | /* second */ | ||
953 | strncpy(reffub, buffer + 6, 2); | ||
954 | reffub[2] = '\0'; | ||
955 | lcd_getstringsize(reffub, &width, &height); | ||
956 | cursor[2][INDEX_X] = cursor[0][INDEX_WIDTH] + separator_width + | ||
957 | cursor[1][INDEX_WIDTH] + separator_width; | ||
958 | cursor[2][INDEX_Y] = prev_line_height; | ||
959 | cursor[2][INDEX_WIDTH] = width; | ||
960 | |||
961 | lcd_getstringsize(buffer, &width, &prev_line_height); | ||
962 | |||
963 | snprintf(buffer, sizeof(buffer), "%s %04d %s %02d ", | ||
964 | str(dayname[tm->tm_wday]), tm->tm_year+1900, | ||
965 | str(monthname[tm->tm_mon]), tm->tm_mday); | ||
966 | lcd_puts(0, 2, buffer); | ||
967 | |||
968 | /* recalculate the positions and offsets */ | ||
969 | lcd_getstringsize(buffer, &width, &line_height); | ||
970 | |||
971 | /* store these 2 to prevent _repeated_ strlen calls */ | ||
972 | monthname_len = strlen(str(monthname[tm->tm_mon])); | ||
973 | dayname_len = strlen(str(dayname[tm->tm_wday])); | ||
974 | |||
975 | /* weekday */ | ||
976 | strncpy(reffub, buffer, dayname_len); | ||
977 | reffub[dayname_len] = '\0'; | ||
978 | lcd_getstringsize(reffub, &weekday_width, &height); | ||
979 | lcd_getstringsize(" ", &separator_width, &height); | ||
980 | |||
981 | /* year */ | ||
982 | strncpy(reffub, buffer + dayname_len + 1, 4); | ||
983 | reffub[4] = '\0'; | ||
984 | lcd_getstringsize(reffub, &width, &height); | ||
985 | cursor[3][INDEX_X] = weekday_width + separator_width; | ||
986 | cursor[3][INDEX_Y] = cursor[0][INDEX_Y] + prev_line_height; | ||
987 | cursor[3][INDEX_WIDTH] = width; | ||
988 | |||
989 | /* month */ | ||
990 | strncpy(reffub, buffer + dayname_len + 6, monthname_len); | ||
991 | reffub[monthname_len] = '\0'; | ||
992 | lcd_getstringsize(reffub, &width, &height); | ||
993 | cursor[4][INDEX_X] = weekday_width + separator_width + | ||
994 | cursor[3][INDEX_WIDTH] + separator_width; | ||
995 | cursor[4][INDEX_Y] = cursor[0][INDEX_Y] + prev_line_height; | ||
996 | cursor[4][INDEX_WIDTH] = width; | ||
997 | |||
998 | /* day */ | ||
999 | strncpy(reffub, buffer + dayname_len + monthname_len + 7, 2); | ||
1000 | reffub[2] = '\0'; | ||
1001 | lcd_getstringsize(reffub, &width, &height); | ||
1002 | cursor[5][INDEX_X] = weekday_width + separator_width + | ||
1003 | cursor[3][INDEX_WIDTH] + separator_width + | ||
1004 | cursor[4][INDEX_WIDTH] + separator_width; | ||
1005 | cursor[5][INDEX_Y] = cursor[0][INDEX_Y] + prev_line_height; | ||
1006 | cursor[5][INDEX_WIDTH] = width; | ||
1007 | |||
1008 | lcd_invertrect(cursor[cursorpos][INDEX_X], | ||
1009 | cursor[cursorpos][INDEX_Y] + lcd_getymargin(), | ||
1010 | cursor[cursorpos][INDEX_WIDTH], | ||
1011 | line_height); | ||
1012 | |||
1013 | lcd_puts(0, 4, str(LANG_TIME_SET)); | ||
1014 | lcd_puts(0, 5, str(LANG_TIME_REVERT)); | ||
1015 | #ifdef HAVE_LCD_BITMAP | ||
1016 | status_draw(true); | ||
1017 | #endif | ||
1018 | lcd_update(); | ||
1019 | |||
1020 | /* calculate the minimum and maximum for the number under cursor */ | ||
1021 | if(cursorpos!=lastcursorpos) { | ||
1022 | lastcursorpos=cursorpos; | ||
1023 | switch(cursorpos) { | ||
1024 | case 0: /* hour */ | ||
1025 | min = 0; | ||
1026 | steps = 24; | ||
1027 | valptr = &tm->tm_hour; | ||
1028 | break; | ||
1029 | case 1: /* minute */ | ||
1030 | min = 0; | ||
1031 | steps = 60; | ||
1032 | valptr = &tm->tm_min; | ||
1033 | break; | ||
1034 | case 2: /* second */ | ||
1035 | min = 0; | ||
1036 | steps = 60; | ||
1037 | valptr = &tm->tm_sec; | ||
1038 | break; | ||
1039 | case 3: /* year */ | ||
1040 | min = 1; | ||
1041 | steps = 200; | ||
1042 | valptr = &tm->tm_year; | ||
1043 | break; | ||
1044 | case 4: /* month */ | ||
1045 | min = 0; | ||
1046 | steps = 12; | ||
1047 | valptr = &tm->tm_mon; | ||
1048 | break; | ||
1049 | case 5: /* day */ | ||
1050 | min = 1; | ||
1051 | steps = daysinmonth[tm->tm_mon]; | ||
1052 | valptr = &tm->tm_mday; | ||
1053 | break; | ||
1054 | } | ||
1055 | say_time(cursorpos, tm); | ||
1056 | } | ||
1057 | |||
1058 | button = button_get_w_tmo(HZ/2); | ||
1059 | switch ( button ) { | ||
1060 | case BUTTON_LEFT: | ||
1061 | cursorpos = (cursorpos + 6 - 1) % 6; | ||
1062 | break; | ||
1063 | case BUTTON_RIGHT: | ||
1064 | cursorpos = (cursorpos + 6 + 1) % 6; | ||
1065 | break; | ||
1066 | case BUTTON_UP: | ||
1067 | case BUTTON_UP | BUTTON_REPEAT: | ||
1068 | *valptr = (*valptr + steps - min + 1) % | ||
1069 | steps + min; | ||
1070 | if(*valptr == 0) | ||
1071 | *valptr = min; | ||
1072 | say_time(cursorpos, tm); | ||
1073 | break; | ||
1074 | case BUTTON_DOWN: | ||
1075 | case BUTTON_DOWN | BUTTON_REPEAT: | ||
1076 | *valptr = (*valptr + steps - min - 1) % | ||
1077 | steps + min; | ||
1078 | if(*valptr == 0) | ||
1079 | *valptr = min; | ||
1080 | say_time(cursorpos, tm); | ||
1081 | break; | ||
1082 | case BUTTON_ON: | ||
1083 | done = true; | ||
1084 | break; | ||
1085 | case BUTTON_OFF: | ||
1086 | done = true; | ||
1087 | tm->tm_year = -1; | ||
1088 | break; | ||
1089 | |||
1090 | case SYS_USB_CONNECTED: | ||
1091 | usb_screen(); | ||
1092 | return true; | ||
1093 | } | ||
1094 | } | ||
1095 | |||
1096 | return false; | ||
1097 | } | ||
1098 | #endif | ||
diff --git a/apps/screens.h b/apps/screens.h index 2fa081a272..55b31006ce 100644 --- a/apps/screens.h +++ b/apps/screens.h | |||
@@ -19,6 +19,8 @@ | |||
19 | #ifndef _SCREENS_H_ | 19 | #ifndef _SCREENS_H_ |
20 | #define _SCREENS_H_ | 20 | #define _SCREENS_H_ |
21 | 21 | ||
22 | #include "timefuncs.h" | ||
23 | |||
22 | void usb_display_info(void); | 24 | void usb_display_info(void); |
23 | void usb_screen(void); | 25 | void usb_screen(void); |
24 | int charging_screen(void); | 26 | int charging_screen(void); |
@@ -35,5 +37,9 @@ void splash(int ticks, /* how long */ | |||
35 | char *fmt, /* what to say *printf style */ | 37 | char *fmt, /* what to say *printf style */ |
36 | ...); | 38 | ...); |
37 | 39 | ||
40 | #ifdef HAVE_RTC | ||
41 | bool set_time_screen(char* string, struct tm *tm); | ||
42 | #endif | ||
43 | |||
38 | #endif | 44 | #endif |
39 | 45 | ||
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[] = |