Bug#861993: lcd4linux: picoLCDGraphic - backlight turns off when lcd4linux starts and cannot be re-enabled

2017-05-27 Thread Jonathan McCrohan
Package: lcd4linux
Followup-For: Bug #861993

Hi Mike,

Thanks for the patch. I've committed your change upstream as r1204 [1].

I hope to upload a new version of lcd4linux once Stretch is released.

Cheers,
Jon

[1] https://lcd4linux.bulix.org/changeset/1204



Bug#861993: lcd4linux: picoLCDGraphic - backlight turns off when lcd4linux starts and cannot be re-enabled

2017-05-06 Thread Mike Edwards
Package: lcd4linux
Version: 0.11.0~svn1203-1
Severity: important
Tags: patch

Dear Maintainer,

Using driver 'picoLCDGraphic' in lcd4linux.conf, backlight can only be set to 0 
or 1 (off/on).
While the backlight of the picolcd is on at boot, the moment lcd4linux starts, 
the backlight turns
off with either setting.

Looking at the source for the driver, I found that somewhere along the line, 
the function to
set the backlight had been changed to use an 8 bit value from 0 - 255, 
effectively making this
a brightness setting:

static int drv_pLG_backlight(int backlight)
{
unsigned char cmd[2] = { 0x91 };/* set backlight */

if (backlight < 0)
backlight = 0;
if (backlight > 255)
backlight = 255;

cmd[1] = backlight;
drv_pLG_send(cmd, 2);

return backlight;
}

... but the config option for backlight was still limited to only accepting a 0 
or 1:
if (cfg_number(section, "Backlight", 0, 0, 1, &value) > 0) {
info("Setting backlight to %d", value);
drv_pLG_backlight(value);
}

I've patched that if statement above to accept values between 0 and 255.  Now, 
setting the config
option for backlight to 255 in lcd4linux.conf does result in the backlight 
being turned on at
full brightness.



-- System Information:
Debian Release: 9.0
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64
 (x86_64)

Kernel: Linux 4.9.0-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages lcd4linux depends on:
ii  init-system-helpers  1.47
ii  libc62.24-10
ii  libdbus-1-3  1.10.18-1
ii  libftdi1 0.20-4
ii  libgd3   2.2.4-2
ii  libjpeg62-turbo  1:1.5.1-2
ii  libmariadbclient18   10.1.22-3
ii  libmpdclient22.9-1
ii  libncurses5  6.0+20161126-1
ii  libpython2.7 2.7.13-2
ii  libsqlite3-0 3.16.2-3
ii  libtinfo56.0+20161126-1
ii  libusb-0.1-4 2:0.1.12-30
ii  libvncserver10.9.11+dfsg-1
ii  libx11-6 2:1.6.4-3
ii  lsb-base 9.20161125

lcd4linux recommends no packages.

lcd4linux suggests no packages.

-- Configuration Files:
/etc/lcd4linux.conf [Errno 13] Permission denied: '/etc/lcd4linux.conf'
Relevant lines from lcd4linux.conf:
Display picoLCD {
Driver   'picoLCDGraphic'
Size '256x64'
#Contrast  230
Contrast  235
Backlight 255
Brightness 100
Inverted  0
Icons 1
}


-- no debconf information
diff --git a/drv_picoLCDGraphic.c b/drv_picoLCDGraphic.c
index 244cc5b..3f2e957 100644
--- a/drv_picoLCDGraphic.c
+++ b/drv_picoLCDGraphic.c
@@ -539,7 +539,7 @@ static int drv_pLG_start(const char *section, const int 
quiet)
drv_pLG_contrast(value);
 }
 
-if (cfg_number(section, "Backlight", 0, 0, 1, &value) > 0) {
+if (cfg_number(section, "Backlight", 0, 0, 255, &value) > 0) {
info("Setting backlight to %d", value);
drv_pLG_backlight(value);
 }