This is a fun little patch that will use previous functions added to
libpayload to show the current date and time and keep it updated.
--
Jordan Crouse
Systems Software Development Engineer
Advanced Micro Devices, Inc.
coreinfo: Show the current time and date in the menu
Signed-off-by: Jordan Crouse <jordan.crouse(a)amd.com>
Index: coreinfo/coreinfo.c
===================================================================
--- coreinfo.orig/coreinfo.c 2008-04-25 10:17:41.000000000 -0600
+++ coreinfo/coreinfo.c 2008-04-25 11:40:49.000000000 -0600
@@ -108,6 +108,22 @@
mvprintw(SCREEN_Y - 2, 0, menu);
}
+#ifdef CONFIG_SHOW_DATE_TIME
+static void print_time_and_date(void)
+{
+ struct tm tm;
+
+ while(nvram_updating())
+ mdelay(10);
+
+ rtc_read_clock(&tm);
+
+ mvprintw(23, 57, "%02d/%02d/%04d - %02d:%02d:%02d",
+ tm.tm_mon, tm.tm_mday, 1900+tm.tm_year, tm.tm_hour,
+ tm.tm_min, tm.tm_sec);
+}
+#endif
+
static void print_menu(void)
{
int i, j;
@@ -125,13 +141,7 @@
mvprintw(SCREEN_Y - 1, 0, menu);
#ifdef CONFIG_SHOW_DATE_TIME
- mvprintw(SCREEN_Y - 1, 59, "%02d/%02d/20%02d - %02d:%02d:%02d",
- bcd2dec(nvram_read(NVRAM_RTC_MONTH)),
- bcd2dec(nvram_read(NVRAM_RTC_DAY)),
- bcd2dec(nvram_read(NVRAM_RTC_YEAR)),
- bcd2dec(nvram_read(NVRAM_RTC_HOURS)),
- bcd2dec(nvram_read(NVRAM_RTC_MINUTES)),
- bcd2dec(nvram_read(NVRAM_RTC_SECONDS)));
+ print_time_and_date();
#endif
}
@@ -210,7 +220,14 @@
print_submenu(&categories[curwin]);
redraw_module(&categories[curwin]);
+ halfdelay(10);
+
while (1) {
+#ifdef CONFIG_SHOW_DATE_TIME
+ print_time_and_date();
+ refresh();
+#endif
+
key = getch();
if (key == ERR)