add ServerScreen=blank option value

This commit is contained in:
marschap
2007-05-13 11:13:09 +00:00
parent 3abb526cba
commit 6d1240be95
3 changed files with 117 additions and 51 deletions
+1
View File
@@ -16,6 +16,7 @@ v.0.5dev (ongoing development)
+ LCDd: config options TitleSpeed= and Heartbeat= + LCDd: config options TitleSpeed= and Heartbeat=
* overhauled CwLnx driver (Dave Platt) * overhauled CwLnx driver (Dave Platt)
* overhauled picolcd driver (Nicu Pavel) * overhauled picolcd driver (Nicu Pavel)
+ add ServerScreen=blank option value
v.0.5.2 v.0.5.2
* fix switching on/off the Load screen in lcdproc client using the menu * fix switching on/off the Load screen in lcdproc client using the menu
+17 -4
View File
@@ -388,20 +388,33 @@ settings for the LCDproc server <application>LCDd</application>.
<group choice="req"> <group choice="req">
<arg choice="plain"><literal><emphasis>yes</emphasis></literal></arg> <arg choice="plain"><literal><emphasis>yes</emphasis></literal></arg>
<arg choice="plain"><literal>no</literal></arg> <arg choice="plain"><literal>no</literal></arg>
<arg choice="plain"><literal>blank</literal></arg>
</group> </group>
</arg> </arg>
</term> </term>
<listitem> <listitem>
<para> <para>
Include the server screen, that shows the number of active clients and screens, Control the bahaviour of the server screen, that usually shows the number
into the screen rotation scheme when other screens exist. of active clients and screens.
Defaults to <literal>yes</literal>. When set to its default value <literal>yes</literal>, the server screen
is included into the screen rotation scheme when other screens exist.
Whet set to <literal>no</literal>, the server screen only shows up
when no other screen exists.
The special value <literal>blank</literal> is similar to <literal>no</literal>,
but instead of displaying the current number of clients and screens,
only a blank screen is displayed.
</para> </para>
<para> <para>
This setting can be overridden on <application>LCDd</application>'s This setting can be partially overridden on <application>LCDd</application>'s
command line using the <option>-i <replaceable>NUMBER</replaceable></option> option. command line using the <option>-i <replaceable>NUMBER</replaceable></option> option.
Passing <option>-i 1</option> on the command line enables server screen rotation, Passing <option>-i 1</option> on the command line enables server screen rotation,
while <option>-i 0</option> disables it. while <option>-i 0</option> disables it.
<note>
<para>
Using the command line, it is not possible to set the server screen to
<literal>blank</literal> mode.
</para>
</note>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
+97 -45
View File
@@ -42,6 +42,9 @@ int rotate_server_screen = UNSET_INT;
/* file-local variables */ /* file-local variables */
static int has_hello_msg = 0; static int has_hello_msg = 0;
/* file-local function declarations */
static int reset_server_screen(int rotate, int heartbeat, int title);
int int
server_screen_init(void) server_screen_init(void)
{ {
@@ -60,9 +63,6 @@ server_screen_init(void)
} }
server_screen->name = "Server screen"; server_screen->name = "Server screen";
server_screen->duration = RENDER_FREQ; /* 1 second, instead of 4...*/ server_screen->duration = RENDER_FREQ; /* 1 second, instead of 4...*/
server_screen->heartbeat = (has_hello_msg) ? HEARTBEAT_OFF : HEARTBEAT_OPEN;
server_screen->priority = (rotate_server_screen == SERVERSCREEN_ON)
? PRI_INFO : PRI_BACKGROUND;
/* Create all the widgets...*/ /* Create all the widgets...*/
for (i = 0; i < display_props->height; i++) { for (i = 0; i < display_props->height; i++) {
@@ -78,28 +78,32 @@ server_screen_init(void)
w->x = 1; w->x = 1;
w->y = i+1; w->y = i+1;
w->text = calloc(LCD_MAX_WIDTH+1, 1); w->text = calloc(LCD_MAX_WIDTH+1, 1);
}
/* depending on Hello in LCDd.conf set the widgets */ /* set parameters for server_screen and it's widgets */
if (has_hello_msg) { reset_server_screen(rotate_server_screen, !has_hello_msg, !has_hello_msg);
const char *line = config_get_string("Server", "Hello", i, "");
strncpy(w->text, line, LCD_MAX_WIDTH); /* set the widgets depending on the Hello option in LCDd.conf */
w->text[LCD_MAX_WIDTH] = '\0'; if (has_hello_msg) { /* show whole Hello message */
} int i;
else {
if (i == 0) { for (i = 0; i < display_props->height; i++) {
w->type = WID_TITLE; const char *line = config_get_string("Server", "Hello", i, "");
strncpy(w->text, "LCDproc Server", LCD_MAX_WIDTH); char id[8];
} else {
w->text[0] = '\0'; sprintf(id, "line%d", i+1);
w = screen_find_widget(server_screen, id);
if ((w != NULL) && (w->text != NULL)) {
strncpy(w->text, line, LCD_MAX_WIDTH);
w->text[LCD_MAX_WIDTH] = '\0';
} }
} }
} }
/* And enqueue the screen*/ /* And enqueue the screen */
screenlist_add(server_screen); screenlist_add(server_screen);
debug(RPT_DEBUG, "server_screen_init done"); debug(RPT_DEBUG, "%s() done", __FUNCTION__);
return 0; return 0;
} }
@@ -107,7 +111,7 @@ server_screen_init(void)
int int
server_screen_shutdown(void) server_screen_shutdown(void)
{ {
if (!server_screen) if (server_screen == NULL)
return -1; return -1;
screenlist_remove(server_screen); screenlist_remove(server_screen);
@@ -115,6 +119,7 @@ server_screen_shutdown(void)
return 0; return 0;
} }
int int
update_server_screen(void) update_server_screen(void)
{ {
@@ -129,14 +134,17 @@ update_server_screen(void)
/* turn off the Hello message after the first client onnected */ /* turn off the Hello message after the first client onnected */
if (has_hello_msg && !hello_done) { if (has_hello_msg && !hello_done) {
/* TODO:
* checking for num_clients is not really correct; we really
* want num_screens (see also comment in main.c).
* Unfortunately we do only get called if the server screen
* needs to be updated; therefore we get num_screen updated too
* late so that after a client disconnects to quickly (in its
* 1st round of screens showing) num_screens still is 0.
*/
if (num_clients != 0) { if (num_clients != 0) {
if (!hello_done) { if (!hello_done)
server_screen->heartbeat = HEARTBEAT_OPEN; reset_server_screen(rotate_server_screen, 1, 1);
w = screen_find_widget(server_screen, "line1");
w->type = WID_TITLE;
strncpy(w->text, "LCDproc Server", LCD_MAX_WIDTH);
}
hello_done = 1; hello_done = 1;
} }
if (!hello_done) if (!hello_done)
@@ -148,32 +156,36 @@ update_server_screen(void)
num_screens += client_screen_count(c); num_screens += client_screen_count(c);
} }
/* format strings for the appropriate display size ... */ /* update statistics if we do not only want to show a blank screen */
if (display_props->height >= 3) { /* >2-line display */ if (rotate_server_screen != SERVERSCREEN_BLANK) {
w = screen_find_widget(server_screen, "line2"); /* format strings for the appropriate display size ... */
if (w != NULL) { if (display_props->height >= 3) { /* >2-line display */
snprintf(w->text, LCD_MAX_WIDTH, w = screen_find_widget(server_screen, "line2");
"Clients: %i", num_clients); if ((w != NULL) && (w->text != NULL)) {
} snprintf(w->text, LCD_MAX_WIDTH,
"Clients: %i", num_clients);
}
w = screen_find_widget(server_screen, "line3"); w = screen_find_widget(server_screen, "line3");
if (w != NULL) { if ((w != NULL) && (w->text != NULL)) {
snprintf(w->text, LCD_MAX_WIDTH, snprintf(w->text, LCD_MAX_WIDTH,
"Screens: %i", num_screens); "Screens: %i", num_screens);
} }
} else { /* 2-line display */ } else { /* 2-line display */
w = screen_find_widget(server_screen, "line2"); w = screen_find_widget(server_screen, "line2");
if (w != NULL) { if ((w != NULL) && (w->text != NULL)) {
snprintf(w->text, LCD_MAX_WIDTH, snprintf(w->text, LCD_MAX_WIDTH,
((display_props->width >= 16) ((display_props->width >= 16)
? "Cli: %i Scr: %i" ? "Cli: %i Scr: %i"
: "C: %i S: %i"), : "C: %i S: %i"),
num_clients, num_screens); num_clients, num_screens);
}
} }
} }
return 0; return 0;
} }
int int
goodbye_screen(void) goodbye_screen(void)
{ {
@@ -214,3 +226,43 @@ goodbye_screen(void)
return 0; return 0;
} }
static int
reset_server_screen(int rotate, int heartbeat, int title)
{
int i;
if (server_screen == NULL)
return -1;
server_screen->heartbeat = (heartbeat && (rotate != SERVERSCREEN_BLANK))
? HEARTBEAT_OPEN : HEARTBEAT_OFF;
server_screen->priority = (rotate == SERVERSCREEN_ON)
? PRI_INFO : PRI_BACKGROUND;
for (i = 0; i < display_props->height; i++) {
char id[8];
Widget *w;
sprintf(id, "line%d", i+1);
w = screen_find_widget(server_screen, id);
if (w != NULL) {
w->x = 1;
w->y = i+1;
w->type = ((i == 0) && (title) && (rotate != SERVERSCREEN_BLANK))
? WID_TITLE : WID_STRING;
if (w->text != NULL) {
w->text[0] = '\0';
if ((i == 0) && (title) && (rotate != SERVERSCREEN_BLANK)) {
strncpy(w->text, "LCDproc Server", LCD_MAX_WIDTH);
w->text[LCD_MAX_WIDTH] = '\0';
}
}
}
}
return 0;
}