From ee861b0d1d795293830b61436cb00d40e0464e26 Mon Sep 17 00:00:00 2001 From: Michele Di Maria Date: Sun, 8 Jan 2012 17:35:40 +0100 Subject: - Removed driver "HD44780 fast" since the problem why this fork was created has been solved in a different way - Set the custom Keys and Menu section for the "sdelcd" driver - Added the Blacklight setting. Now it is possible to optionally turn the blacklight on, off or (default) to leave it managed by the panel - Added the "output led" support for the "CFontz633" driver. This is totally to test since my panel doesn't have any output led, worked almost blind --- config/lcdproc-dev/lcdproc.inc | 58 +++++++++--------- config/lcdproc-dev/lcdproc.xml | 41 +++++++++++-- config/lcdproc-dev/lcdproc_client.php | 104 ++++++++++++++++++++++++++++++++- config/lcdproc-dev/lcdproc_screens.xml | 2 +- 4 files changed, 170 insertions(+), 35 deletions(-) (limited to 'config') diff --git a/config/lcdproc-dev/lcdproc.inc b/config/lcdproc-dev/lcdproc.inc index 14e5dc73..cfea30f3 100644 --- a/config/lcdproc-dev/lcdproc.inc +++ b/config/lcdproc-dev/lcdproc.inc @@ -240,18 +240,38 @@ $config_text .= "DriverPath=/usr/local/lib/lcdproc/\n"; $config_text .= "GoodBye=\"Thanks for using\"\n"; $config_text .= "GoodBye=\" {$g['product_name']} \"\n"; - /* FIXME: Specific to the pyramid project */ - $config_text .= "ToggleRotateKey=Enter\n"; - $config_text .= "PrevScreenKey=Left\n"; - $config_text .= "NextScreenKey=Right\n"; - $config_text .= "ScrollUpKey=Up\n"; - $config_text .= "ScrollDownKey=Down\n"; - /* FIXME: pyramid test menu */ - $config_text .= "[menu]\n"; - $config_text .= "MenuKey=Escape\n"; - $config_text .= "EnterKey=Enter\n"; - $config_text .= "UpKey=Up\n"; - $config_text .= "DownKey=Down\n"; + if ($lcdproc_config[backlight] != "" && $lcdproc_config[backlight] != "default") + { + /* Backlight setting */ + $config_text .= "Backlight={$lcdproc_config[backlight]}\n"; + } + if ($lcdproc_config[driver] == "sdeclcd") + { + /* Sdeclcd Keys settings */ + $config_text .= "PrevScreenKey=Down\n"; + $config_text .= "NextScreenKey=Up\n"; + /* Sdeclcd Menu settings */ + $config_text .= "[menu]\n"; + $config_text .= "MenuKey=Left\n"; + $config_text .= "EnterKey=Right\n"; + $config_text .= "UpKey=Up\n"; + $config_text .= "DownKey=Down\n"; + } + else + { + /* Generic Keys settings */ + $config_text .= "ToggleRotateKey=Enter\n"; + $config_text .= "PrevScreenKey=Left\n"; + $config_text .= "NextScreenKey=Right\n"; + $config_text .= "ScrollUpKey=Up\n"; + $config_text .= "ScrollDownKey=Down\n"; + /* Generic Menu settings */ + $config_text .= "[menu]\n"; + $config_text .= "MenuKey=Escape\n"; + $config_text .= "EnterKey=Enter\n"; + $config_text .= "UpKey=Up\n"; + $config_text .= "DownKey=Down\n"; + } /* lcdproc default driver definitions */ switch($lcdproc_config[driver]) { case "bayrad": @@ -338,20 +358,6 @@ $config_text .= "DelayBus=true\n"; $config_text .= "Size={$lcdproc_config['size']}\n"; break; - case "hd44780 fast": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "ConnectionType=lcd2usb\n"; - $config_text .= "Charmap=hd44780_default\n"; - $config_text .= "Keypad=yes\n"; - $config_text .= set_lcd_value("contrast", 1000, 850); - $config_text .= set_lcd_value("brightness", 1000, 800); - $config_text .= set_lcd_value("offbrightness", 1000, 0); - $config_text .= "Backlight=yes\n"; - $config_text .= "OutputPort=no\n"; - $config_text .= "DelayMult=1\n"; - $config_text .= "DelayBus=no\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - break; case "icp_a106": $config_text .= "[{$lcdproc_config['driver']}]\n"; $config_text .= "Device={$realport}\n"; diff --git a/config/lcdproc-dev/lcdproc.xml b/config/lcdproc-dev/lcdproc.xml index fcb16997..77c11584 100644 --- a/config/lcdproc-dev/lcdproc.xml +++ b/config/lcdproc-dev/lcdproc.xml @@ -1,8 +1,8 @@ - Services: LCDproc 0.5.4 pkg v. 0.6 + Services: LCDproc 0.5.4 pkg v. 0.7 lcdproc - 0.5.4 pkg v. 0.6 + 0.5.4 pkg v. 0.7 Save /usr/local/pkg/lcdproc.inc @@ -203,10 +203,6 @@ hd44780 hd44780 - -1 + + + backlight + Backlight + Set the backlight setting. If set to the default value, then the backlight setting of the display can be influenced by the clients. This option is not supported by all the LCD panels, leave "default" if unsure. + select + + + + + + default + + + outputleds + Enable Output LEDs + Enable the Output LEDs present on some LCD panels. This feature is currently supported by the CFontz633 driver only. <br> + Each LED can be off or show two colors: RED (alarm) or GREEN (everything ok) and shows: <br> + LED1: NICs status (green: ok, red: at least one nic down);<br> + LED2: CARP status (green: master, red: backup, off: CARP not implemented);<br> + LED3: CPU status (green < 50, red > 50%);<br> + LED4: Gateway status (green: ok, red: at least one gateway not responding, off: no gateway configured). + checkbox + default diff --git a/config/lcdproc-dev/lcdproc_client.php b/config/lcdproc-dev/lcdproc_client.php index 52656fdc..aec8d8c3 100644 --- a/config/lcdproc-dev/lcdproc_client.php +++ b/config/lcdproc-dev/lcdproc_client.php @@ -455,6 +455,71 @@ } } + function outputled_enabled_CFontz633(){ + global $config; + $lcdproc_config = $config['installedpackages']['lcdproc']['config'][0]; + $value = $lcdproc_config['outputleds']; + if (is_null($value)) + {return false;} + else + { + if ($value && $lcdproc_config['driver'] == "CFontz633") + {return true;} + else + {return false;} + } + } + + function outputled_carp () { + /* Returns the status of CARP for the box. + Assumes ALL CARP status are the same for all the intefaces. + -1 = CARP Disabled + 0 = CARP on Backup + 1 = CARP on Master */ + global $g; + global $config; + + if(is_array($config['virtualip']['vip'])) { + $carpint = 0; + foreach($config['virtualip']['vip'] as $carp) { + if ($carp['mode'] != "carp") { + continue; + } + $carp_int = find_carp_interface($carp['subnet']); + $status = get_carp_interface_status($carp_int); + switch($status) { + case "MASTER": + return 1; + break; + case "BACKUP": + return 0; + break; + } + } + } else { + return -1; + } + } + + function outputled_gateway() { + /* Returns the status of the gateways. + -1 = No gateway defined + 0 = At least 1 gateway down or with issues + 1 = All gateway up */ + global $g; + global $config; + $gateways_status = array(); + $gateways_status = return_gateways_status(true); + foreach ($a_gateways as $gname => $gateway) + { + if ($gateways_status[$gname]['status'] != "none") + { + return 0; + } + } + return 1; + } + function get_traffic_stats(&$in_data, &$out_data){ global $config; global $traffic_last_ugmt, $traffic_last_ifin, $traffic_last_ifout; @@ -673,7 +738,7 @@ $lcd_summary_data = sprintf("%02d%% %02d%% %6d", cpu_usage(), mem_usage(), $summary_states[0]); if ($lcdpanel_width > "16") { $lcd_summary_data = $lcd_summary_data . sprintf(" %3d%%", get_cpufrequency_perc()); - } + } } else { $lcd_summary_data = "";} @@ -682,6 +747,42 @@ /* initializes the widget counter */ $widget_counter = 0; + + /* controls the output leds */ + if (outputled_enabled_CFontz633()) + { + $led_output_value = 0; + /* LED 1: Interface status */ + if (substr_count(get_interfaces_stats(), "Down") > 0 ) + {$led_output_value = $led_output_value + pow(2, 0);} + else + {$led_output_value = $led_output_value + pow(2, 4);} + /* LED 2: CARP status */ + switch (outputled_carp()) + { + case -1:/* CARP disabled */ + case 0: /* CARP on Backup */ + {$led_output_value = $led_output_value + pow(2, 1);} + case 1: /* CARP on Master */ + {$led_output_value = $led_output_value + pow(2, 5);} + } + /* LED 3: CPU Usage */ + if (cpu_usage() > 50) + {$led_output_value = $led_output_value + pow(2, 2);} + else + {$led_output_value = $led_output_value + pow(2, 6);} + /* LED 4: Gateway status */ + switch (outputled_gateway()) + { + case -1:/* Gateways not configured */ + case 0: /* Gateway down or with issues */ + {$led_output_value = $led_output_value + 2 ^ 3;} + case 1: /* All Gateways up */ + {$led_output_value = $led_output_value + 2 ^ 7;} + } + /* Sends the command to the panel */ + $lcd_cmds[] = "output {$led_output_value}"; + } /* process screens to display */ foreach((array) $lcdproc_screens_config as $name => $screen) { @@ -767,7 +868,6 @@ $lcd_cmds[] = "widget_set $name text_wdgt 1 2 \"{$out_data}\""; break; } - add_summary_values($lcd_cmds, $name, $lcd_summary_data, $lcdpanel_width); if ($name != "scr_traffic_interface") { $widget_counter++; add_summary_values($lcd_cmds, $name, $lcd_summary_data, $lcdpanel_width); diff --git a/config/lcdproc-dev/lcdproc_screens.xml b/config/lcdproc-dev/lcdproc_screens.xml index 0c967dff..9f98ea59 100644 --- a/config/lcdproc-dev/lcdproc_screens.xml +++ b/config/lcdproc-dev/lcdproc_screens.xml @@ -2,7 +2,7 @@ Services: LCDproc: Screens lcdproc_screens - 0.5.4 pkg v. 0.6 + 0.5.4 pkg v. 0.7 Save /usr/local/pkg/lcdproc.inc -- cgit v1.2.3