From 6e6900922ef5a1bf016e243df321688e5aba2fc6 Mon Sep 17 00:00:00 2001 From: mmdolze Date: Sat, 4 May 2013 08:17:32 +0000 Subject: [PATCH] Add option to turn off title and heartbeat on OldTime screen. --- ChangeLog | 1 + clients/lcdproc/chrono.c | 41 ++++++++++++++++++++++++++++++------ clients/lcdproc/lcdproc.conf | 6 ++++++ 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 03c427b..29fa9c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,7 @@ v0.5dev (ongoing development) * Build system: Rename configure.in to configure.ac + hd44780: Add support for FreeBSD's iic I2C framework + hd44780: New connection type 'piplate' (J. Brogdon) + * lcdproc client: Add option to turn off title and heartbeat on OldTime screen v0.5.6 - Remove deprecated CFontz633 driver. Use CFontzPacket with Model=633 instead! diff --git a/clients/lcdproc/chrono.c b/clients/lcdproc/chrono.c index 679eb32..02f36fa 100644 --- a/clients/lcdproc/chrono.c +++ b/clients/lcdproc/chrono.c @@ -174,6 +174,13 @@ time_screen(int rep, int display, int *flags_ptr) * | May 17, 2005 | * +--------------------+ * + * Alternate 2-line version without the title bar: + * + * +----------------+ + * | 2012-12-27 @| + * | 15:07:01 | + * +----------------+ + * *\endverbatim * * \param rep Time since last screen update @@ -188,6 +195,7 @@ clock_screen(int rep, int display, int *flags_ptr) char today[40]; int xoffs; static int heartbeat = 0; + static int showTitle = 1; static const char *timeFormat = NULL; static const char *dateFormat = NULL; time_t thetime; @@ -195,18 +203,23 @@ clock_screen(int rep, int display, int *flags_ptr) if ((*flags_ptr & INITIALIZED) == 0) { char tmp[257]; /* should be large enough for host name */ + int disableHeart; /* Disables server heartbeat icon */ *flags_ptr |= INITIALIZED; /* get config values */ timeFormat = config_get_string("OldTime", "TimeFormat", 0, "%H:%M:%S"); dateFormat = config_get_string("OldTime", "DateFormat", 0, "%b %d %Y"); + showTitle = config_get_bool("OldTime", "ShowTitle", 0, 1); + disableHeart = config_get_bool("OldTime", "DisableHeartbeat", 0, 0); sock_send_string(sock, "screen_add O\n"); sock_printf(sock, "screen_set O -name {Old Clock Screen: %s}\n", get_hostname()); - sock_send_string(sock, "widget_add O title title\n"); + if (disableHeart) + sock_send_string(sock, "screen_set O -heartbeat off\n"); sock_send_string(sock, "widget_add O one string\n"); if (lcd_hgt >= 4) { + sock_send_string(sock, "widget_add O title title\n"); sock_send_string(sock, "widget_add O two string\n"); sock_send_string(sock, "widget_add O three string\n"); @@ -217,7 +230,13 @@ clock_screen(int rep, int display, int *flags_ptr) sock_printf(sock, "widget_set O one %i 2 {%s}\n", xoffs, tmp); } else { - sock_printf(sock, "widget_set O title {TIME: %s}\n", get_hostname()); + if (showTitle) { + sock_send_string(sock, "widget_add O title title\n"); + sock_printf(sock, "widget_set O title {TIME: %s}\n", get_hostname()); + } + else { + sock_send_string(sock, "widget_add O two string\n"); + } } } @@ -243,10 +262,20 @@ clock_screen(int rep, int display, int *flags_ptr) sock_printf(sock, "widget_set O three %i 4 {%s}\n", xoffs, now); } else { /* 2-line version of the screen */ - xoffs = (lcd_wid > (strlen(today) + strlen(now) + 1)) - ? ((lcd_wid - ((strlen(today) + strlen(now) + 1))) / 2) + 1 : 1; - if (display) - sock_printf(sock, "widget_set O one %i 2 {%s %s}\n", xoffs, today, now); + if (showTitle) { + xoffs = (lcd_wid > (strlen(today) + strlen(now) + 1)) + ? ((lcd_wid - ((strlen(today) + strlen(now) + 1))) / 2) + 1 : 1; + if (display) + sock_printf(sock, "widget_set O one %i 2 {%s %s}\n", xoffs, today, now); + } + else { + xoffs = (lcd_wid > strlen(today)) ? ((lcd_wid - strlen(today)) / 2) + 1 : 1; + if (display) + sock_printf(sock, "widget_set O one %i 1 {%s}\n", xoffs, today); + xoffs = (lcd_wid > strlen(now)) ? ((lcd_wid - strlen(now)) / 2) + 1 : 1; + if (display) + sock_printf(sock, "widget_set O two %i 2 {%s}\n", xoffs, now); + } } return 0; diff --git a/clients/lcdproc/lcdproc.conf b/clients/lcdproc/lcdproc.conf index fcf0b5b..5d5643b 100644 --- a/clients/lcdproc/lcdproc.conf +++ b/clients/lcdproc/lcdproc.conf @@ -103,6 +103,12 @@ Active=false TimeFormat="%H:%M:%S" # date format [default: %x; legal: see strftime(3)] DateFormat="%x" +# Display the title bar in two-line mode. Note that with four lines or more +# the title is always shown. [default: true; legal: true, false] +#ShowTitle=false +# Disables the heartbeat icon in the top right corner. By default, the server +# setting for the heartbeat is used. [default: false; legal: true, false] +#DisableHeartbeat=true [BigClock]