aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/lcdproc/lcdproc.inc89
-rw-r--r--packages/lcdproc/lcdproc.xml49
-rw-r--r--packages/lcdproc/lcdproc_client.php178
-rw-r--r--packages/lcdproc/lcdproc_screens.xml22
4 files changed, 227 insertions, 111 deletions
diff --git a/packages/lcdproc/lcdproc.inc b/packages/lcdproc/lcdproc.inc
index 59fa6250..b296b841 100644
--- a/packages/lcdproc/lcdproc.inc
+++ b/packages/lcdproc/lcdproc.inc
@@ -111,6 +111,40 @@
break;
}
}
+ if($post['size']) {
+ switch($post['size']) {
+ case "12x1":
+ continue;
+ break;
+ case "12x2":
+ continue;
+ break;
+ case "12x4":
+ continue;
+ break;
+ case "16x1":
+ continue;
+ break;
+ case "16x2":
+ continue;
+ break;
+ case "16x4":
+ continue;
+ break;
+ case "20x1":
+ continue;
+ break;
+ case "20x2":
+ continue;
+ break;
+ case "20x4":
+ continue;
+ break;
+ default:
+ $input_errors[] = "The chosen display size is not valid";
+ break;
+ }
+ }
}
function validate_form_lcdproc_screens($post, $input_errors) {
// No validation required ?!
@@ -178,25 +212,25 @@
/* lcdproc default driver definitions */
switch($lcdproc_config[driver]) {
case "bayrad":
- $config_text .= "[{$lcdproc_config[driver]}]\n";
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
$config_text .= "Device={$realport}\n";
$config_text .= "Speed=9600\n";
break;
case "CFontz":
- $config_text .= "[{$lcdproc_config[driver]}]\n";
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
$config_text .= "Device={$realport}\n";
- $config_text .= "Size=20x4\n";
+ $config_text .= "Size={$lcdproc_config['size']}\n";
$config_text .= "Contrast=350\n";
$config_text .= "Brightness=1000\n";
- $config_text .= "OffBrightness=0\n";
+ $config_text .= "OffBrightness=50\n";
$config_text .= "Speed=9600\n";
$config_text .= "NewFirmware=no\n";
$config_text .= "Reboot=no\n";
break;
case "CFontz633":
- $config_text .= "[{$lcdproc_config[driver]}]\n";
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
$config_text .= "Device={$realport}\n";
- $config_text .= "Size=16x2\n";
+ $config_text .= "Size={$lcdproc_config['size']}\n";
$config_text .= "Contrast=350\n";
$config_text .= "Brightness=1000\n";
$config_text .= "OffBrightness=50\n";
@@ -205,10 +239,10 @@
$config_text .= "Reboot=yes\n";
break;
case "CFontzPacket":
- $config_text .= "[{$lcdproc_config[driver]}]\n";
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
$config_text .= "Device={$realport}\n";
$config_text .= "Model=635\n";
- $config_text .= "Size=20x4\n";
+ $config_text .= "Size={$lcdproc_config['size']}\n";
$config_text .= "Contrast=350\n";
$config_text .= "Brightness=1000\n";
$config_text .= "OffBrightness=50\n";
@@ -217,29 +251,30 @@
$config_text .= "Reboot=yes\n";
break;
case "curses":
- $config_text .= "[{$lcdproc_config[driver]}]\n";
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
$config_text .= "Foreground=blue\n";
$config_text .= "Background=cyan\n";
$config_text .= "Backlight=red\n";
- $config_text .= "Size=16x4\n";
+ $config_text .= "Size={$lcdproc_config['size']}\n";
$config_text .= "TopLeftX=7\n";
$config_text .= "TopLeftY=7\n";
$config_text .= "UseACS=no\n";
break;
case "CwLynx":
- $config_text .= "[{$lcdproc_config[driver]}]\n";
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
$config_text .= "Model=12232\n";
$config_text .= "Device={$realport}\n";
- $config_text .= "Size=20x4\n";
+ $config_text .= "Size={$lcdproc_config['size']}\n";
$config_text .= "Speed=19200\n";
$config_text .= "Reboot=no\n";
break;
case "pyramid":
- $config_text .= "[{$lcdproc_config[driver]}]\n";
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
$config_text .= "Device={$realport}\n";
+ $config_text .= "Size={$lcdproc_config['size']}\n";
break;
case "ea65":
- $config_text .= "[{$lcdproc_config[driver]}]\n";
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
$config_text .= "Device={$realport}\n";
$config_text .= "OffBrightness=0\n";
$config_text .= "Brightness=500\n";
@@ -250,27 +285,6 @@
}
/* generate rc file start and stop */
- $options = "";
- if(is_array($lcdproc_screens_config)) {
- foreach($lcdproc_screens_config as $name => $screen) {
- if($screen == "on") {
- switch($name) {
- case "scr_cpu":
- $options .= "P ";
- break;
- case "scr_time":
- $options .= "O ";
- break;
- case "scr_load":
- $options .= "L ";
- break;
- case "scr_uptime":
- $options .= "U ";
- break;
- }
- }
- }
- }
$client_script = <<<EOD
#!/bin/sh
@@ -278,10 +292,9 @@
counter=1
while [ "\$counter" -ne 0 ]
do
- # start the lcd client, lcdproc client for now until PHP client is finished
- #/usr/local/bin/lcdproc -f $options
+ # loop the client to drive the display
/usr/local/bin/php -f /usr/local/pkg/lcdproc_client.php
- sleep 10
+ sleep 1
done
EOD;
diff --git a/packages/lcdproc/lcdproc.xml b/packages/lcdproc/lcdproc.xml
index 48f1019f..8ec5737e 100644
--- a/packages/lcdproc/lcdproc.xml
+++ b/packages/lcdproc/lcdproc.xml
@@ -47,7 +47,7 @@
<fielddescr>Enable LCDproc</fielddescr>
<fieldname>enable</fieldname>
<type>checkbox</type>
- </field>
+ </field>
<field>
<fieldname>comport</fieldname>
<fielddescr>Com Port</fielddescr>
@@ -75,7 +75,52 @@
<name>Parallel port 1 (/dev/lpt0)</name>
</option>
</options>
- <default_value>0</default_value>
+ <default_value>ucom1</default_value>
+ </field>
+ <field>
+ <fieldname>size</fieldname>
+ <fielddescr>Display Size</fielddescr>
+ <description>Set the display size lcdproc should use.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <value>12x1</value>
+ <name>1 rows 12 colums</name>
+ </option>
+ <option>
+ <value>12x2</value>
+ <name>2 rows 12 colums</name>
+ </option>
+ <option>
+ <value>12x4</value>
+ <name>4 rows 12 colums</name>
+ </option>
+ <option>
+ <value>16x1</value>
+ <name>1 row 16 colums</name>
+ </option>
+ <option>
+ <value>16x2</value>
+ <name>2 rows 16 colums</name>
+ </option>
+ <option>
+ <value>16x4</value>
+ <name>4 rows 16 colums</name>
+ </option>
+ <option>
+ <value>20x1</value>
+ <name>1 row 20 colums</name>
+ </option>
+ <option>
+ <value>20x2</value>
+ <name>2 rows 20 colums</name>
+ </option>
+ <option>
+ <value>20x4</value>
+ <name>4 rows 20 colums</name>
+ </option>
+ </options>
+ <default_value>16x2</default_value>
</field>
<field>
<fieldname>driver</fieldname>
diff --git a/packages/lcdproc/lcdproc_client.php b/packages/lcdproc/lcdproc_client.php
index f8ae20d7..6da45197 100644
--- a/packages/lcdproc/lcdproc_client.php
+++ b/packages/lcdproc/lcdproc_client.php
@@ -30,6 +30,7 @@
// require_once("config.inc");
// require_once("functions.inc");
require_once("/usr/local/pkg/lcdproc.inc");
+ require_once("/usr/local/www/includes/functions.inc.php");
/* Define functions */
function send_lcd_commands($lcd, $lcd_cmds) {
@@ -44,6 +45,7 @@
die();
}
$cmd_output = fgets($lcd, 4096);
+ // FIXME: add support for interpreting menu commands here.
if(preg_match("/^huh?/", $cmd_output)) {
lcdproc_notice("LCDd output: \"$cmd_output\". Executed \"$lcd_cmd\"");
}
@@ -51,68 +53,16 @@
}
}
- function loop_status($lcd) {
- global $g;
- global $config;
- $lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0];
- /* keep a counter to see how many times we can loop */
- $i = 1;
- while($i) {
- $lcd_cmds = array();
- $lcd_cmds[] = "widget_set welcome_scr title_wdgt \"Welcome\"";
- $lcd_cmds[] = "widget_set welcome_scr text_wdgt 1 2 20 2 h 4 \"to {$g['product_name']}\"";
-
- /* process screens to display */
- if(is_array($lcdproc_screens_config)) {
- foreach($lcdproc_screens_config as $name => $screen) {
- if($screen == "on") {
- switch($name) {
- case "scr_cpu":
- $processor = "";
- $lcd_cmds[] = "widget_set $name title_wdgt \"Processor\"";
- $lcd_cmds[] = "widget_set $name text_wdgt 1 2 20 2 h 4 \"$processor\"";
- break;
- case "scr_time":
- $time = date ("F Y h:i:s");
- $lcd_cmds[] = "widget_set $name title_wdgt \"Time\"";
- $lcd_cmds[] = "widget_set $name text_wdgt 1 2 20 2 h 4 \"$time\"";
- break;
- case "scr_load":
- exec("/usr/bin/uptime", $output, $ret);
- $temp = explode($output, " ");
- $loadavg = "$temp[9] $temp[10] $temp[11] $temp[12] $temp[13]";
- $lcd_cmds[] = "widget_set $name title_wdgt \"Load average\"";
- $lcd_cmds[] = "widget_set $name text_wdgt 1 2 20 2 h 4 \"$loadavg\"";
- break;
- case "scr_uptime":
- exec("/usr/bin/uptime", $output, $ret);
- $temp = explode($output, " ");
- $uptime = "$temp[2] $temp[3] $temp[4] $temp[5] $temp[6] $temp[7] $temp[8]";
- $lcd_cmds[] = "widget_set $name title_wdgt \"Uptime\"";
- $lcd_cmds[] = "widget_set $name text_wdgt 1 2 20 2 h 4 \"$uptime\"";
-
- break;
- }
- }
- }
- }
-
- send_lcd_commands($lcd, $lcd_cmds);
- sleep(10);
- $i++;
- }
- }
-
function build_interface($lcd) {
global $g;
global $config;
$lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0];
+
$lcd_cmds = array();
$lcd_cmds[] = "hello";
$lcd_cmds[] = "client_set name pfSense";
$lcd_cmds[] = "screen_add welcome_scr";
$lcd_cmds[] = "screen_set welcome_scr heartbeat off";
- // $lcd_cmds[] = "screen_set welcome_scr duration 32";
$lcd_cmds[] = "screen_set welcome_scr name welcome";
$lcd_cmds[] = "widget_add welcome_scr title_wdgt title";
$lcd_cmds[] = "widget_add welcome_scr text_wdgt scroller";
@@ -122,26 +72,54 @@
foreach($lcdproc_screens_config as $name => $screen) {
if($screen == "on") {
switch($name) {
+ case "scr_time":
+ $lcd_cmds[] = "screen_add $name";
+ $lcd_cmds[] = "screen_set $name heartbeat off";
+ $lcd_cmds[] = "screen_set $name name $name";
+ $lcd_cmds[] = "widget_add $name title_wdgt string";
+ $lcd_cmds[] = "widget_add $name text_wdgt scroller";
+ break;
+ case "scr_uptime":
+ $lcd_cmds[] = "screen_add $name";
+ $lcd_cmds[] = "screen_set $name heartbeat off";
+ $lcd_cmds[] = "screen_set $name name $name";
+ $lcd_cmds[] = "widget_add $name title_wdgt string";
+ $lcd_cmds[] = "widget_add $name text_wdgt scroller";
+ break;
+ case "scr_hostname":
+ $lcd_cmds[] = "screen_add $name";
+ $lcd_cmds[] = "screen_set $name heartbeat off";
+ $lcd_cmds[] = "screen_set $name name $name";
+ $lcd_cmds[] = "widget_add $name title_wdgt string";
+ $lcd_cmds[] = "widget_add $name text_wdgt scroller";
+ break;
case "scr_cpu":
- $lcd_cmds[] = "screen_set $name name welcome";
- $lcd_cmds[] = "widget_add $name title_wdgt title";
+ $lcd_cmds[] = "screen_add $name";
+ $lcd_cmds[] = "screen_set $name heartbeat off";
+ $lcd_cmds[] = "screen_set $name name $name";
+ $lcd_cmds[] = "widget_add $name title_wdgt string";
$lcd_cmds[] = "widget_add $name text_wdgt scroller";
break;
- case "scr_time":
- $lcd_cmds[] = "screen_set $name name welcome";
- $lcd_cmds[] = "widget_add $name title_wdgt title";
+ case "scr_memory":
+ $lcd_cmds[] = "screen_add $name";
+ $lcd_cmds[] = "screen_set $name heartbeat off";
+ $lcd_cmds[] = "screen_set $name name $name";
+ $lcd_cmds[] = "widget_add $name title_wdgt string";
$lcd_cmds[] = "widget_add $name text_wdgt scroller";
break;
case "scr_load":
- $lcd_cmds[] = "screen_set $name name welcome";
- $lcd_cmds[] = "widget_add $name title_wdgt title";
+ $lcd_cmds[] = "screen_add $name";
+ $lcd_cmds[] = "screen_set $name heartbeat off";
+ $lcd_cmds[] = "screen_set $name name $name";
+ $lcd_cmds[] = "widget_add $name title_wdgt string";
$lcd_cmds[] = "widget_add $name text_wdgt scroller";
break;
- case "scr_uptime":
- $lcd_cmds[] = "screen_set $name name welcome";
- $lcd_cmds[] = "widget_add $name title_wdgt title";
+ case "scr_states":
+ $lcd_cmds[] = "screen_add $name";
+ $lcd_cmds[] = "screen_set $name heartbeat off";
+ $lcd_cmds[] = "screen_set $name name $name";
+ $lcd_cmds[] = "widget_add $name title_wdgt string";
$lcd_cmds[] = "widget_add $name text_wdgt scroller";
-
break;
}
}
@@ -150,6 +128,77 @@
send_lcd_commands($lcd, $lcd_cmds);
}
+ function loop_status($lcd) {
+ global $g;
+ global $config;
+ $lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0];
+ if(empty($g['product_name'])) {
+ $g['product_name'] = "pfSense";
+ }
+ $version = @file_get_contents("/etc/version");
+ /* keep a counter to see how many times we can loop */
+ $i = 1;
+ while($i) {
+ $lcd_cmds = array();
+ $lcd_cmds[] = "widget_set welcome_scr title_wdgt \"Welcome to\"";
+ $lcd_cmds[] = "widget_set welcome_scr text_wdgt 1 2 16 2 h 4 \"{$g['product_name']} $version\"";
+
+ /* process screens to display */
+ if(is_array($lcdproc_screens_config)) {
+ foreach($lcdproc_screens_config as $name => $screen) {
+ if($screen == "on") {
+ switch($name) {
+ case "scr_time":
+ $time = date ("n/j/Y H:i");
+ $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ System Time\"";
+ $lcd_cmds[] = "widget_set $name text_wdgt 1 2 16 2 h 2 \"$time\"";
+ break;
+ case "scr_uptime":
+ exec("/usr/bin/uptime", $output, $ret);
+ $temp = explode(" ", $output[0]);
+ $uptime = "$temp[3] $temp[4] $temp[5] $temp[6] $temp[7] ". substr($temp[8], 0, -1);
+ $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ System Uptime\"";
+ $lcd_cmds[] = "widget_set $name text_wdgt 1 2 16 2 h 2 \"$uptime\"";
+ break;
+ case "scr_hostname":
+ exec("/bin/hostname", $output, $ret);
+ $hostname = $output[0];
+ $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ System Name\"";
+ $lcd_cmds[] = "widget_set $name text_wdgt 1 2 16 2 h 2 \"$hostname\"";
+ break;
+ case "scr_cpu":
+ $processor = cpu_usage();
+ $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Processor Use\"";
+ $lcd_cmds[] = "widget_set $name text_wdgt 1 2 16 2 h 4 \"$processor Percent\"";
+ break;
+ case "scr_memory":
+ $memory = mem_usage();
+ $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Memory Use\"";
+ $lcd_cmds[] = "widget_set $name text_wdgt 1 2 16 2 h 4 \"$memory Percent\"";
+ break;
+ case "scr_load":
+ exec("/usr/bin/uptime", $output, $ret);
+ $temp = explode(" ", $output[0]);
+ $loadavg = "$temp[11] $temp[12] $temp[13]";
+ $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Load Averages\"";
+ $lcd_cmds[] = "widget_set $name text_wdgt 1 2 16 2 h 2 \"$loadavg\"";
+ break;
+ case "scr_states":
+ $states = get_pfstate();
+ $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Traffic States\"";
+ $lcd_cmds[] = "widget_set $name text_wdgt 1 2 16 2 h 2 \"$states States\"";
+ break;
+ }
+ }
+ }
+ }
+
+ send_lcd_commands($lcd, $lcd_cmds);
+ sleep(5);
+ $i++;
+ }
+ }
+
/* Connect to the LCDd port and interface with the LCD */
$lcd = fsockopen(LCDPROC_HOST, LCDPROC_PORT, $errno, $errstr, 10);
if (!$lcd) {
@@ -158,7 +207,6 @@
build_interface($lcd);
loop_status($lcd);
/* loop exited? Close fd and wait for the script to kick in again */
- // sleep(1);
fclose($lcd);
}
?>
diff --git a/packages/lcdproc/lcdproc_screens.xml b/packages/lcdproc/lcdproc_screens.xml
index 9c44852d..1edb59bc 100644
--- a/packages/lcdproc/lcdproc_screens.xml
+++ b/packages/lcdproc/lcdproc_screens.xml
@@ -24,23 +24,33 @@
</menu>
<fields>
<field>
+ <fielddescr>Enable Time</fielddescr>
+ <fieldname>scr_time</fieldname>
+ <type>checkbox</type>
+ </field>
+ <field>
+ <fielddescr>Enable Uptime</fielddescr>
+ <fieldname>scr_uptime</fieldname>
+ <type>checkbox</type>
+ </field>
+ <field>
<fielddescr>Enable CPU</fielddescr>
<fieldname>scr_cpu</fieldname>
<type>checkbox</type>
</field>
<field>
- <fielddescr>Enable Load</fielddescr>
- <fieldname>scr_load</fieldname>
+ <fielddescr>Enable Memory</fielddescr>
+ <fieldname>scr_memory</fieldname>
<type>checkbox</type>
</field>
<field>
- <fielddescr>Enable Time</fielddescr>
- <fieldname>scr_time</fieldname>
+ <fielddescr>Enable Load</fielddescr>
+ <fieldname>scr_load</fieldname>
<type>checkbox</type>
</field>
<field>
- <fielddescr>Enable Uptime</fielddescr>
- <fieldname>scr_uptime</fieldname>
+ <fielddescr>Enable States</fielddescr>
+ <fieldname>scr_states</fieldname>
<type>checkbox</type>
</field>
</fields>