From fbaa97496f9717d7cf45456c47ce3e271da29e28 Mon Sep 17 00:00:00 2001 From: Marcin Bukat Date: Tue, 10 Apr 2018 13:26:56 +0200 Subject: Agptek Rocker: Implement RTC support Add define in config file to enable RTC support in rockbox, Fix time_menu.c to include radio.h only when tuner is present Implement time setting function on linux (was empty stub) Not tested. Change-Id: I40e6c4a6c1b66ada9cf4e698e502e221d0fc44df --- apps/menus/time_menu.c | 2 ++ firmware/export/config/agptekrocker.h | 2 +- firmware/target/hosted/rtc.c | 10 ++++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/menus/time_menu.c b/apps/menus/time_menu.c index 9ef4f7323c..a6885a3dbc 100644 --- a/apps/menus/time_menu.c +++ b/apps/menus/time_menu.c @@ -37,7 +37,9 @@ #include "list.h" #include "alarm_menu.h" #include "screens.h" +#if CONFIG_TUNER #include "radio.h" +#endif #include "font.h" #include "system.h" diff --git a/firmware/export/config/agptekrocker.h b/firmware/export/config/agptekrocker.h index fa010a109f..1c15117f9b 100644 --- a/firmware/export/config/agptekrocker.h +++ b/firmware/export/config/agptekrocker.h @@ -59,7 +59,7 @@ #define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING /* define this if you have a real-time clock */ -#define CONFIG_RTC 0 +#define CONFIG_RTC APPLICATION /* The number of bytes reserved for loadable codecs */ #define CODEC_SIZE 0x80000 diff --git a/firmware/target/hosted/rtc.c b/firmware/target/hosted/rtc.c index 8c430f3774..cb11d3ca3c 100644 --- a/firmware/target/hosted/rtc.c +++ b/firmware/target/hosted/rtc.c @@ -9,6 +9,7 @@ * * Based upon code (C) 2002 by Björn Stenberg * Copyright (C) 2011 by Thomas Jarosch + * Copyright (C) 2018 by Marcin Bukat * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -20,6 +21,7 @@ * ****************************************************************************/ #include +#include void rtc_init(void) { @@ -35,6 +37,10 @@ int rtc_read_datetime(struct tm *tm) int rtc_write_datetime(const struct tm *tm) { - (void)tm; - return -1; + struct timeval tv; + + tv.tv_sec = mktime((struct tm *)tm); + tv.tv_usec = 0; + + return settimeofday(&tv, NULL); } -- cgit v1.2.3