mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 10:37:38 -04:00
Make seconds flow evenly and further throttle RTC reads solution partially thanks to amiconn
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8938 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
48a336851e
commit
40d0d752aa
1 changed files with 13 additions and 13 deletions
|
@ -46,13 +46,13 @@ bool valid_time(const struct tm *tm)
|
||||||
struct tm *get_time(void)
|
struct tm *get_time(void)
|
||||||
{
|
{
|
||||||
#ifndef SIMULATOR
|
#ifndef SIMULATOR
|
||||||
#ifdef CONFIG_RTC
|
|
||||||
static long last_tick = 0;
|
static long last_tick = 0;
|
||||||
|
|
||||||
/* Don't read the RTC more than 4 times per second */
|
/* Don't read the RTC more than 4 times per second */
|
||||||
if (last_tick + HZ/4 < current_tick) {
|
if (last_tick + HZ < current_tick) {
|
||||||
|
#ifdef CONFIG_RTC
|
||||||
char rtcbuf[7];
|
char rtcbuf[7];
|
||||||
last_tick = current_tick;
|
last_tick = HZ * (current_tick / HZ);
|
||||||
rtc_read_datetime(rtcbuf);
|
rtc_read_datetime(rtcbuf);
|
||||||
|
|
||||||
tm.tm_sec = ((rtcbuf[0] & 0x70) >> 4) * 10 + (rtcbuf[0] & 0x0f);
|
tm.tm_sec = ((rtcbuf[0] & 0x70) >> 4) * 10 + (rtcbuf[0] & 0x0f);
|
||||||
|
@ -65,7 +65,6 @@ struct tm *get_time(void)
|
||||||
|
|
||||||
tm.tm_yday = 0; /* Not implemented for now */
|
tm.tm_yday = 0; /* Not implemented for now */
|
||||||
tm.tm_isdst = -1; /* Not implemented for now */
|
tm.tm_isdst = -1; /* Not implemented for now */
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
tm.tm_sec = 0;
|
tm.tm_sec = 0;
|
||||||
tm.tm_min = 0;
|
tm.tm_min = 0;
|
||||||
|
@ -77,6 +76,7 @@ struct tm *get_time(void)
|
||||||
tm.tm_yday = 0; /* Not implemented for now */
|
tm.tm_yday = 0; /* Not implemented for now */
|
||||||
tm.tm_isdst = -1; /* Not implemented for now */
|
tm.tm_isdst = -1; /* Not implemented for now */
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
return &tm;
|
return &tm;
|
||||||
#else
|
#else
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue