From 7313f3f1d734a6a2ee096f9e6d5617df38b05a26 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 7 Jul 2012 19:59:21 +0200 Subject: [PATCH] simple_display: use VFDSETTIME2 ioctl on spark Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/71a6d325bde5f970bdc4ce10ddda29b2331739fe Author: Stefan Seyfried Date: 2012-07-07 (Sat, 07 Jul 2012) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/simple_display.cpp | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/driver/simple_display.cpp b/src/driver/simple_display.cpp index f1c6f2166..5f87a59a1 100644 --- a/src/driver/simple_display.cpp +++ b/src/driver/simple_display.cpp @@ -35,7 +35,7 @@ //#include #include #if HAVE_SPARK_HARDWARE -#include "spark_led.h" +#include #define DISPLAY_DEV "/dev/vfd" #define DISPLAY_LEN 4 #endif @@ -219,11 +219,31 @@ void CLCD::showTime(bool force) if (force || last_display || (hour != t->tm_hour) || (minute != t->tm_min)) { hour = t->tm_hour; minute = t->tm_min; - if (DISPLAY_LEN < 5) - sprintf(timestr, "%02d%02d", hour, minute); - else /* pad with spaces on the left side to center the time string */ - sprintf(timestr, "%*s%02d:%02d",(DISPLAY_LEN - 5)/2, "", hour, minute); - display(timestr, false); +#if HAVE_SPARK_HARDWARE + now += t->tm_gmtoff; + int fd = dev_open(); +#if 0 /* VFDSETTIME is broken and too complicated anyway -> use VFDSETTIME2 */ + int mjd = 40587 + now / 86400; /* 1970-01-01 is mjd 40587 */ + struct aotom_ioctl_data d; + d.u.time.time[0] = mjd >> 8; + d.u.time.time[1] = mjd & 0xff; + d.u.time.time[2] = hour; + d.u.time.time[3] = minute; + d.u.time.time[4] = t->tm_sec; + int ret = ioctl(fd, VFDSETTIME, &d); +#else + int ret = ioctl(fd, VFDSETTIME2, &now); +#endif + close(fd); + if (ret < 0) +#endif + { + if (DISPLAY_LEN < 5) + sprintf(timestr, "%02d%02d", hour, minute); + else /* pad with spaces on the left side to center the time string */ + sprintf(timestr, "%*s%02d:%02d",(DISPLAY_LEN - 5)/2, "", hour, minute); + display(timestr, false); + } last_display = 0; } }