summaryrefslogtreecommitdiff
path: root/apps/settings.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/settings.c')
-rw-r--r--apps/settings.c50
1 files changed, 37 insertions, 13 deletions
diff --git a/apps/settings.c b/apps/settings.c
index 3dafebc368..6c0b21d088 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -881,13 +881,6 @@ bool set_option(char* string, int* variable, char* options[],
881#define INDEX_X 0 881#define INDEX_X 0
882#define INDEX_Y 1 882#define INDEX_Y 1
883#define INDEX_WIDTH 2 883#define INDEX_WIDTH 2
884char *dayname[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
885char *monthname[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
886 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
887char cursor[][3] = {{ 0, 8, 12}, {18, 8, 12}, {36, 8, 12},
888 {24, 16, 24}, {54, 16, 18}, {78, 16, 12}};
889char daysinmonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
890
891bool set_time(char* string, int timedate[]) 884bool set_time(char* string, int timedate[])
892{ 885{
893 bool done = false; 886 bool done = false;
@@ -903,6 +896,29 @@ bool set_time(char* string, int timedate[])
903 unsigned int width, height; 896 unsigned int width, height;
904 unsigned int separator_width, weekday_width; 897 unsigned int separator_width, weekday_width;
905 unsigned int line_height, prev_line_height; 898 unsigned int line_height, prev_line_height;
899 char *dayname[] = {str(LANG_WEEKDAY_SUNDAY),
900 str(LANG_WEEKDAY_MONDAY),
901 str(LANG_WEEKDAY_TUESDAY),
902 str(LANG_WEEKDAY_WEDNESDAY),
903 str(LANF_WEEKDAY_THURSDAY),
904 str(LANG_WEEKDAY_FRIDAY),
905 str(LANG_WEEKDAY_SATURDAY)};
906 char *monthname[] = {str(LANG_MONTH_JANUARY),
907 str(LANG_MONTH_FEBRUARY),
908 str(LANG_MONTH_MARCH),
909 str(LANG_MONTH_APRIL),
910 str(LANG_MONTH_MAY),
911 str(LANG_MONTH_JUNE),
912 str(LANG_MONTH_JULY),
913 str(LANG_MONTH_AUGUST),
914 str(LANG_MONTH_SEPTEMBER),
915 str(LANG_MONTH_OCTOBER),
916 str(LANG_MONTH_NOVEMBER),
917 str(LANG_MONTH_DECEMBER)};
918 char cursor[][3] = {{ 0, 8, 12}, {18, 8, 12}, {36, 8, 12},
919 {24, 16, 24}, {54, 16, 18}, {78, 16, 12}};
920 char daysinmonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
921
906 922
907#ifdef HAVE_LCD_BITMAP 923#ifdef HAVE_LCD_BITMAP
908 if(global_settings.statusbar) 924 if(global_settings.statusbar)
@@ -945,6 +961,7 @@ bool set_time(char* string, int timedate[])
945 lcd_getstringsize(buffer, &width, &line_height); 961 lcd_getstringsize(buffer, &width, &line_height);
946 lcd_getstringsize(":", &separator_width, &height); 962 lcd_getstringsize(":", &separator_width, &height);
947 963
964 /* hour */
948 strncpy(reffub, buffer, 2); 965 strncpy(reffub, buffer, 2);
949 reffub[2] = '\0'; 966 reffub[2] = '\0';
950 lcd_getstringsize(reffub, &width, &height); 967 lcd_getstringsize(reffub, &width, &height);
@@ -952,6 +969,7 @@ bool set_time(char* string, int timedate[])
952 cursor[0][INDEX_Y] = prev_line_height; 969 cursor[0][INDEX_Y] = prev_line_height;
953 cursor[0][INDEX_WIDTH] = width; 970 cursor[0][INDEX_WIDTH] = width;
954 971
972 /* minute */
955 strncpy(reffub, buffer + 3, 2); 973 strncpy(reffub, buffer + 3, 2);
956 reffub[2] = '\0'; 974 reffub[2] = '\0';
957 lcd_getstringsize(reffub, &width, &height); 975 lcd_getstringsize(reffub, &width, &height);
@@ -959,6 +977,7 @@ bool set_time(char* string, int timedate[])
959 cursor[1][INDEX_Y] = prev_line_height; 977 cursor[1][INDEX_Y] = prev_line_height;
960 cursor[1][INDEX_WIDTH] = width; 978 cursor[1][INDEX_WIDTH] = width;
961 979
980 /* second */
962 strncpy(reffub, buffer + 6, 2); 981 strncpy(reffub, buffer + 6, 2);
963 reffub[2] = '\0'; 982 reffub[2] = '\0';
964 lcd_getstringsize(reffub, &width, &height); 983 lcd_getstringsize(reffub, &width, &height);
@@ -978,27 +997,32 @@ bool set_time(char* string, int timedate[])
978 997
979 /* recalculate the positions and offsets */ 998 /* recalculate the positions and offsets */
980 lcd_getstringsize(buffer, &width, &line_height); 999 lcd_getstringsize(buffer, &width, &line_height);
981 strncpy(reffub, buffer, 3); 1000
982 reffub[3] = '\0'; 1001 /* weekday */
1002 strncpy(reffub, buffer, strlen(dayname[timedate[6]]));
1003 reffub[strlen(dayname[timedate[6]])] = '\0';
983 lcd_getstringsize(reffub, &weekday_width, &height); 1004 lcd_getstringsize(reffub, &weekday_width, &height);
984 lcd_getstringsize(" ", &separator_width, &height); 1005 lcd_getstringsize(" ", &separator_width, &height);
985 1006
986 strncpy(reffub, buffer + 4, 4); 1007 /* year */
1008 strncpy(reffub, buffer + strlen(dayname[timedate[6]]) + 1, 4);
987 reffub[4] = '\0'; 1009 reffub[4] = '\0';
988 lcd_getstringsize(reffub, &width, &height); 1010 lcd_getstringsize(reffub, &width, &height);
989 cursor[3][INDEX_X] = weekday_width + separator_width; 1011 cursor[3][INDEX_X] = weekday_width + separator_width;
990 cursor[3][INDEX_Y] = cursor[0][INDEX_Y] + prev_line_height; 1012 cursor[3][INDEX_Y] = cursor[0][INDEX_Y] + prev_line_height;
991 cursor[3][INDEX_WIDTH] = width; 1013 cursor[3][INDEX_WIDTH] = width;
992 1014
993 strncpy(reffub, buffer + 9, 3); 1015 /* month */
994 reffub[3] = '\0'; 1016 strncpy(reffub, buffer + strlen(dayname[timedate[6]]) + 6, strlen(monthname[timedate[4] - 1]));
1017 reffub[strlen(monthname[timedate[4] - 1])] = '\0';
995 lcd_getstringsize(reffub, &width, &height); 1018 lcd_getstringsize(reffub, &width, &height);
996 cursor[4][INDEX_X] = weekday_width + separator_width + 1019 cursor[4][INDEX_X] = weekday_width + separator_width +
997 cursor[3][INDEX_WIDTH] + separator_width; 1020 cursor[3][INDEX_WIDTH] + separator_width;
998 cursor[4][INDEX_Y] = cursor[0][INDEX_Y] + prev_line_height; 1021 cursor[4][INDEX_Y] = cursor[0][INDEX_Y] + prev_line_height;
999 cursor[4][INDEX_WIDTH] = width; 1022 cursor[4][INDEX_WIDTH] = width;
1000 1023
1001 strncpy(reffub, buffer + 13, 2); 1024 /* day */
1025 strncpy(reffub, buffer + strlen(dayname[timedate[6]]) + strlen(monthname[timedate[4] - 1]) + 7, 2);
1002 reffub[2] = '\0'; 1026 reffub[2] = '\0';
1003 lcd_getstringsize(reffub, &width, &height); 1027 lcd_getstringsize(reffub, &width, &height);
1004 cursor[5][INDEX_X] = weekday_width + separator_width + 1028 cursor[5][INDEX_X] = weekday_width + separator_width +