From 1cec74dc585157eb596b796fd01a7eb57b55e00a Mon Sep 17 00:00:00 2001 From: Treer Date: Thu, 26 Jan 2017 20:46:35 +1100 Subject: [PATCH] Add support for MatrixOrbital-specific driver settings. Adafruit are selling Matrix Orbital compatible LCDs which require non-default settings for display-type and hasAdjustibleBacklight. https://forum.pfsense.org/index.php?topic=124321.0 --- .../files/usr/local/pkg/lcdproc.inc | 4 +- .../local/www/packages/lcdproc/lcdproc.php | 100 ++++++++++++------ .../www/packages/lcdproc/lcdproc_screens.php | 4 + 3 files changed, 74 insertions(+), 34 deletions(-) diff --git a/sysutils/pfSense-pkg-LCDproc/files/usr/local/pkg/lcdproc.inc b/sysutils/pfSense-pkg-LCDproc/files/usr/local/pkg/lcdproc.inc index 8e722a5ba8d3..0c93bf79bae4 100644 --- a/sysutils/pfSense-pkg-LCDproc/files/usr/local/pkg/lcdproc.inc +++ b/sysutils/pfSense-pkg-LCDproc/files/usr/local/pkg/lcdproc.inc @@ -370,8 +370,8 @@ function sync_package_lcdproc() { $config_text .= "[{$lcdproc_config['driver']}]\n"; $config_text .= "Device={$realport}\n"; $config_text .= "Size={$lcdproc_config['size']}\n"; - $config_text .= "Type=lcd\n"; - $config_text .= "hasAdjustableBacklight=yes\n"; + $config_text .= "Type={$lcdproc_config['mtxorb_type']}\n"; + $config_text .= "hasAdjustableBacklight=" . ($lcdproc_config['mtxorb_adjustable_backlight'] ? "yes" : "no") . "\n"; $config_text .= "Reboot=no\n"; $config_text .= set_lcd_value("contrast", 1000, 480); $config_text .= set_lcd_value("brightness", 1000, 1000); diff --git a/sysutils/pfSense-pkg-LCDproc/files/usr/local/www/packages/lcdproc/lcdproc.php b/sysutils/pfSense-pkg-LCDproc/files/usr/local/www/packages/lcdproc/lcdproc.php index 9b66e88537c0..c03db0e908c9 100644 --- a/sysutils/pfSense-pkg-LCDproc/files/usr/local/www/packages/lcdproc/lcdproc.php +++ b/sysutils/pfSense-pkg-LCDproc/files/usr/local/www/packages/lcdproc/lcdproc.php @@ -29,37 +29,45 @@ // Set default values for anything not in the $config $pconfig = $lcdproc_config; -if (!isset($pconfig['enable'])) $pconfig['enable'] = ''; -if (!isset($pconfig['comport'])) $pconfig['enabled'] = 'ucom1'; -if (!isset($pconfig['size'])) $pconfig['size'] = '16x2'; -if (!isset($pconfig['driver'])) $pconfig['driver'] = 'pyramid'; -if (!isset($pconfig['connection_type'])) $pconfig['connection_type'] = 'lcd2usb'; -if (!isset($pconfig['refresh_frequency'])) $pconfig['refresh_frequency'] = '5'; -if (!isset($pconfig['port_speed'])) $pconfig['port_speed'] = '0'; -if (!isset($pconfig['brightness'])) $pconfig['brightness'] = '-1'; -if (!isset($pconfig['offbrightness'])) $pconfig['offbrightness'] = '-1'; -if (!isset($pconfig['contrast'])) $pconfig['contrast'] = '-1'; -if (!isset($pconfig['backlight'])) $pconfig['backlight'] = 'default'; -if (!isset($pconfig['outputleds'])) $pconfig['outputleds'] = 'no'; +if (!isset($pconfig['enable'])) $pconfig['enable'] = ''; +if (!isset($pconfig['comport'])) $pconfig['enabled'] = 'ucom1'; +if (!isset($pconfig['size'])) $pconfig['size'] = '16x2'; +if (!isset($pconfig['driver'])) $pconfig['driver'] = 'pyramid'; +if (!isset($pconfig['connection_type'])) $pconfig['connection_type'] = 'lcd2usb'; // specific to hd44780 driver +if (!isset($pconfig['refresh_frequency'])) $pconfig['refresh_frequency'] = '5'; +if (!isset($pconfig['port_speed'])) $pconfig['port_speed'] = '0'; +if (!isset($pconfig['brightness'])) $pconfig['brightness'] = '-1'; +if (!isset($pconfig['offbrightness'])) $pconfig['offbrightness'] = '-1'; +if (!isset($pconfig['contrast'])) $pconfig['contrast'] = '-1'; +if (!isset($pconfig['backlight'])) $pconfig['backlight'] = 'default'; +if (!isset($pconfig['outputleds'])) $pconfig['outputleds'] = 'no'; +if (!isset($pconfig['mtxorb_type'])) $pconfig['mtxorb_type'] = 'lcd'; // specific to Matrix Orbital driver +if (!isset($pconfig['mtxorb_adjustable_backlight'])) $pconfig['mtxorb_adjustable_backlight'] = true; // specific to Matrix Orbital driver if ($_POST) { unset($input_errors); $pconfig = $_POST; + // Input validation would go here, with any invalid values found + // in $_POST being added to $input_errors, e.g: + // $input_errors[] = "Descriptive error message for the user."; + if (!$input_errors) { - $lcdproc_config['enable'] = $pconfig['enable']; - $lcdproc_config['comport'] = $pconfig['comport']; - $lcdproc_config['size'] = $pconfig['size']; - $lcdproc_config['driver'] = $pconfig['driver']; - $lcdproc_config['connection_type'] = $pconfig['connection_type']; - $lcdproc_config['refresh_frequency'] = $pconfig['refresh_frequency']; - $lcdproc_config['port_speed'] = $pconfig['port_speed']; - $lcdproc_config['brightness'] = $pconfig['brightness']; - $lcdproc_config['offbrightness'] = $pconfig['offbrightness']; - $lcdproc_config['contrast'] = $pconfig['contrast']; - $lcdproc_config['backlight'] = $pconfig['backlight']; - $lcdproc_config['outputleds'] = $pconfig['outputleds']; + $lcdproc_config['enable'] = $pconfig['enable']; + $lcdproc_config['comport'] = $pconfig['comport']; + $lcdproc_config['size'] = $pconfig['size']; + $lcdproc_config['driver'] = $pconfig['driver']; + $lcdproc_config['connection_type'] = $pconfig['connection_type']; + $lcdproc_config['refresh_frequency'] = $pconfig['refresh_frequency']; + $lcdproc_config['port_speed'] = $pconfig['port_speed']; + $lcdproc_config['brightness'] = $pconfig['brightness']; + $lcdproc_config['offbrightness'] = $pconfig['offbrightness']; + $lcdproc_config['contrast'] = $pconfig['contrast']; + $lcdproc_config['backlight'] = $pconfig['backlight']; + $lcdproc_config['outputleds'] = $pconfig['outputleds']; + $lcdproc_config['mtxorb_type'] = $pconfig['mtxorb_type']; + $lcdproc_config['mtxorb_adjustable_backlight'] = $pconfig['mtxorb_adjustable_backlight']; write_config(); sync_package_lcdproc(); @@ -136,8 +144,7 @@ ) )->setHelp('Set the display size lcdproc should use.'); -$driverGroup = new Form_Group('Driver'); -$driverGroup->add( +$section->addInput( new Form_Select( 'driver', 'Driver', @@ -161,7 +168,7 @@ 'MD8800' => 'MD8800', 'ms6931' => 'ms6931', 'mtc_s16209x' => 'mtc_s16209x', - 'MtxOrb' => 'MtxOrb', + 'MtxOrb' => 'Matrix Orbital', 'nexcom' => 'nexcom (x86 only)', 'NoritakeVFD' => 'NoritakeVFD', 'picolcd' => 'picolcd', @@ -180,11 +187,11 @@ 'tyan' => 'tyan' ] ) -); +)->setHelp('Select the LCD driver LCDproc should use. Some drivers will show additional settings.'); // The connection type is HD44780-specific, so is hidden by javascript (below) // if the HD44780 driver is not being used. -$driverGroup->add( +$section->addInput( new Form_Select( 'connection_type', 'Connection type', @@ -210,9 +217,34 @@ 'i2c' => 'LCD driven by PCF8574/PCA9554 connected via i2c' ] ) +)->setHelp('Select the HD44780 connection type'); + +// The mtxorb_type and mtxorb_adjustable_backlight are Matrix-Orbital-specific, so are +// hidden by javascript (below) if the MtxOrb driver is not being used. +$subsection = new Form_Group('Display type'); +$subsection->add( + new Form_Select( + 'mtxorb_type', + 'Display type', + $pconfig['mtxorb_type'], // Initial value. + [ + 'lcd' => 'LCD (default)', + 'lkd' => 'LKD', + 'vfd' => 'VFD', + 'vkd' => 'VKD' + ] + ) +); +$subsection->add( + new Form_Checkbox( + 'mtxorb_adjustable_backlight', // checkbox name (id) + 'Has adjustable backlight', // label + 'Has adjustable backlight', // text + $pconfig['mtxorb_adjustable_backlight'] // initial value + ) ); -$driverGroup->setHelp('Set the LCD driver LCDproc should use.
If using a HD44780 driver, set the connection type using the second selection box, which will appear.'); -$section->add($driverGroup); +$subsection->setHelp('Select the Matrix Orbital display type.
Some old firmware versions of Matrix Orbital modules do not support an adjustable backlight but only can switch the backlight on/off. If you own such a module and experience randomly appearing block characters and backlight cannot be switched on or off, uncheck the adjustable backlight option.'); +$section->add($subsection); ?>