changed display format for time/date setting menu
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1646 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
3181f68eff
commit
2012acf0a8
2 changed files with 26 additions and 24 deletions
|
@ -553,8 +553,10 @@ void set_option(char* string, int* variable, char* options[], int numoptions )
|
||||||
#ifdef HAVE_RTC
|
#ifdef HAVE_RTC
|
||||||
#define INDEX_X 0
|
#define INDEX_X 0
|
||||||
#define INDEX_Y 1
|
#define INDEX_Y 1
|
||||||
|
#define INDEX_WIDTH 2
|
||||||
char *dayname[]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
|
char *dayname[]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
|
||||||
char cursor[][2]={{9, 1}, {12, 1}, {15, 1}, {9, 2}, {12, 2}, {15, 2}};
|
char *monthname[]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
|
||||||
|
char cursor[][3]={{0, 1, 2}, {3, 1, 2}, {6, 1, 2}, {4, 2, 4}, {9, 2, 3}, {13, 2, 2}};
|
||||||
char daysinmonth[]={31,28,31,30,31,30,31,31,30,31,30,31};
|
char daysinmonth[]={31,28,31,30,31,30,31,31,30,31,30,31};
|
||||||
|
|
||||||
void set_time(char* string, int timedate[])
|
void set_time(char* string, int timedate[])
|
||||||
|
@ -574,36 +576,36 @@ void set_time(char* string, int timedate[])
|
||||||
|
|
||||||
while ( !done ) {
|
while ( !done ) {
|
||||||
/* calculate the number of days in febuary */
|
/* calculate the number of days in febuary */
|
||||||
realyear=timedate[5]+2000;
|
realyear=timedate[3]+2000;
|
||||||
if((realyear%4==0 && !(realyear%100 == 0)) || realyear%400 == 0) /* for february depends on year */
|
if((realyear%4==0 && !(realyear%100 == 0)) || realyear%400 == 0) /* for february depends on year */
|
||||||
daysinmonth[1]=29;
|
daysinmonth[1]=29;
|
||||||
else
|
else
|
||||||
daysinmonth[1]=28;
|
daysinmonth[1]=28;
|
||||||
|
|
||||||
/* fix day if month or year changed */
|
/* fix day if month or year changed */
|
||||||
timedate[3]=timedate[3]<daysinmonth[timedate[4]-1]?timedate[3]:daysinmonth[timedate[4]-1];
|
timedate[5]=timedate[5]<daysinmonth[timedate[4]-1]?timedate[5]:daysinmonth[timedate[4]-1];
|
||||||
|
|
||||||
/* calculate day of week */
|
/* calculate day of week */
|
||||||
julianday=0;
|
julianday=0;
|
||||||
for(i=0;i<timedate[4]-1;i++) {
|
for(i=0;i<timedate[4]-1;i++) {
|
||||||
julianday+=daysinmonth[i];
|
julianday+=daysinmonth[i];
|
||||||
}
|
}
|
||||||
julianday+=timedate[3];
|
julianday+=timedate[5];
|
||||||
timedate[6]=(realyear+julianday+(realyear-1)/4-(realyear-1)/100+(realyear-1)/400+7-1)%7;
|
timedate[6]=(realyear+julianday+(realyear-1)/4-(realyear-1)/100+(realyear-1)/400+7-1)%7;
|
||||||
|
|
||||||
snprintf(buffer, sizeof(buffer), "Time %02d:%02d:%02d",
|
snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d",
|
||||||
timedate[0],
|
timedate[0],
|
||||||
timedate[1],
|
timedate[1],
|
||||||
timedate[2]);
|
timedate[2]);
|
||||||
lcd_puts(0,1,buffer);
|
lcd_puts(0,1,buffer);
|
||||||
|
|
||||||
snprintf(buffer, sizeof(buffer), "Date %s %02d.%02d.%02d",
|
snprintf(buffer, sizeof(buffer), "%s 20%02d %s %02d",
|
||||||
dayname[timedate[6]],
|
dayname[timedate[6]],
|
||||||
timedate[3],
|
timedate[3],
|
||||||
timedate[4],
|
monthname[timedate[4]-1],
|
||||||
timedate[5]);
|
timedate[5]);
|
||||||
lcd_puts(0,2,buffer);
|
lcd_puts(0,2,buffer);
|
||||||
lcd_invertrect(cursor[cursorpos][INDEX_X]*6,cursor[cursorpos][INDEX_Y]*8,12,8);
|
lcd_invertrect(cursor[cursorpos][INDEX_X]*6,cursor[cursorpos][INDEX_Y]*8,cursor[cursorpos][INDEX_WIDTH]*6,8);
|
||||||
lcd_puts(0,4,"ON to set");
|
lcd_puts(0,4,"ON to set");
|
||||||
lcd_puts(0,5,"OFF to revert");
|
lcd_puts(0,5,"OFF to revert");
|
||||||
lcd_update();
|
lcd_update();
|
||||||
|
@ -621,17 +623,17 @@ void set_time(char* string, int timedate[])
|
||||||
min=0;
|
min=0;
|
||||||
steps=60;
|
steps=60;
|
||||||
break;
|
break;
|
||||||
case 3: /* day */
|
case 3: /* year */
|
||||||
min=1;
|
min=0;
|
||||||
steps=daysinmonth[timedate[4]-1];
|
steps=100;
|
||||||
break;
|
break;
|
||||||
case 4: /* month */
|
case 4: /* month */
|
||||||
min=1;
|
min=1;
|
||||||
steps=12;
|
steps=12;
|
||||||
break;
|
break;
|
||||||
case 5: /* year */
|
case 5: /* day */
|
||||||
min=0;
|
min=1;
|
||||||
steps=100;
|
steps=daysinmonth[timedate[4]-1];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,22 +87,22 @@ static void statusbar(void)
|
||||||
#ifdef HAVE_RTC
|
#ifdef HAVE_RTC
|
||||||
static void timedate_set(void)
|
static void timedate_set(void)
|
||||||
{
|
{
|
||||||
int timedate[7]; /* hour,minute,second,day,month,year,dayofweek */
|
int timedate[7]; /* hour,minute,second,year,month,day,dayofweek */
|
||||||
|
|
||||||
|
|
||||||
timedate[0] = rtc_read(0x03); /* hour */
|
timedate[0] = rtc_read(0x03); /* hour */
|
||||||
timedate[1] = rtc_read(0x02); /* minute */
|
timedate[1] = rtc_read(0x02); /* minute */
|
||||||
timedate[2] = rtc_read(0x01); /* second */
|
timedate[2] = rtc_read(0x01); /* second */
|
||||||
timedate[3] = rtc_read(0x05); /* day */
|
timedate[3] = rtc_read(0x07); /* year */
|
||||||
timedate[4] = rtc_read(0x06); /* month */
|
timedate[4] = rtc_read(0x06); /* month */
|
||||||
timedate[5] = rtc_read(0x07); /* year */
|
timedate[5] = rtc_read(0x05); /* day */
|
||||||
/* day of week not read, calculated */
|
/* day of week not read, calculated */
|
||||||
timedate[0] = ((timedate[0] & 0x70) >> 4) * 10 + (timedate[0] & 0x0f); /* hour */
|
timedate[0] = ((timedate[0] & 0x70) >> 4) * 10 + (timedate[0] & 0x0f); /* hour */
|
||||||
timedate[1] = ((timedate[1] & 0xf0) >> 4) * 10 + (timedate[1] & 0x0f); /* minute */
|
timedate[1] = ((timedate[1] & 0xf0) >> 4) * 10 + (timedate[1] & 0x0f); /* minute */
|
||||||
timedate[2] = ((timedate[2] & 0x30) >> 4) * 10 + (timedate[2] & 0x0f); /* second */
|
timedate[2] = ((timedate[2] & 0x30) >> 4) * 10 + (timedate[2] & 0x0f); /* second */
|
||||||
timedate[3] = ((timedate[3] & 0x30) >> 4) * 10 + (timedate[3] & 0x0f); /* day */
|
timedate[3] = ((timedate[3] & 0x30) >> 4) * 10 + (timedate[3] & 0x0f); /* year */
|
||||||
timedate[4] = ((timedate[4] & 0x30) >> 4) * 10 + (timedate[4] & 0x0f); /* month */
|
timedate[4] = ((timedate[4] & 0x30) >> 4) * 10 + (timedate[4] & 0x0f); /* month */
|
||||||
timedate[5] = ((timedate[5] & 0x30) >> 4) * 10 + (timedate[5] & 0x0f); /* year */
|
timedate[5] = ((timedate[5] & 0x30) >> 4) * 10 + (timedate[5] & 0x0f); /* day */
|
||||||
|
|
||||||
set_time("[Set time/date]",timedate);
|
set_time("[Set time/date]",timedate);
|
||||||
|
|
||||||
|
@ -110,16 +110,16 @@ static void timedate_set(void)
|
||||||
timedate[0] = ((timedate[0]/10) << 4 | timedate[0]%10) & 0x3f; /* hour */
|
timedate[0] = ((timedate[0]/10) << 4 | timedate[0]%10) & 0x3f; /* hour */
|
||||||
timedate[1] = ((timedate[1]/10) << 4 | timedate[1]%10) & 0x7f; /* minute */
|
timedate[1] = ((timedate[1]/10) << 4 | timedate[1]%10) & 0x7f; /* minute */
|
||||||
timedate[2] = ((timedate[2]/10) << 4 | timedate[2]%10) & 0x7f; /* second */
|
timedate[2] = ((timedate[2]/10) << 4 | timedate[2]%10) & 0x7f; /* second */
|
||||||
timedate[3] = ((timedate[3]/10) << 4 | timedate[3]%10) & 0x3f; /* day */
|
timedate[3] = ((timedate[3]/10) << 4 | timedate[3]%10) & 0xff; /* year */
|
||||||
timedate[4] = ((timedate[4]/10) << 4 | timedate[4]%10) & 0x1f; /* month */
|
timedate[4] = ((timedate[4]/10) << 4 | timedate[4]%10) & 0x1f; /* month */
|
||||||
timedate[5] = ((timedate[5]/10) << 4 | timedate[5]%10) & 0xff; /* year */
|
timedate[5] = ((timedate[5]/10) << 4 | timedate[5]%10) & 0x3f; /* day */
|
||||||
rtc_write(0x03, timedate[0] | (rtc_read(0x03) & 0xc0)); /* hour */
|
rtc_write(0x03, timedate[0] | (rtc_read(0x03) & 0xc0)); /* hour */
|
||||||
rtc_write(0x02, timedate[1] | (rtc_read(0x02) & 0x80)); /* minute */
|
rtc_write(0x02, timedate[1] | (rtc_read(0x02) & 0x80)); /* minute */
|
||||||
rtc_write(0x01, timedate[2] | (rtc_read(0x01) & 0x80)); /* second */
|
rtc_write(0x01, timedate[2] | (rtc_read(0x01) & 0x80)); /* second */
|
||||||
rtc_write(0x05, timedate[3] | (rtc_read(0x05) & 0xc0)); /* day */
|
rtc_write(0x07, timedate[3]); /* year */
|
||||||
rtc_write(0x06, timedate[4] | (rtc_read(0x06) & 0xe0)); /* month */
|
rtc_write(0x06, timedate[4] | (rtc_read(0x06) & 0xe0)); /* month */
|
||||||
rtc_write(0x07, timedate[5]); /* year */
|
rtc_write(0x05, timedate[5] | (rtc_read(0x05) & 0xc0)); /* day */
|
||||||
rtc_write(0x04, timedate[6] | (rtc_read(0x04) & 0x07)); /* dayofweek */
|
rtc_write(0x04, timedate[6] | (rtc_read(0x04) & 0xf8)); /* dayofweek */
|
||||||
rtc_write(0x00, 0x00); /* 0.1 + 0.01 seconds */
|
rtc_write(0x00, 0x00); /* 0.1 + 0.01 seconds */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue