Only update the backlight setting if a change is necessary

This commit is contained in:
mmdolze
2009-02-24 21:41:04 +00:00
parent 8ff94b83ed
commit aaed3765a1
3 changed files with 11 additions and 5 deletions
+1
View File
@@ -63,6 +63,7 @@ v.0.5dev (ongoing development)
+ serialVFD driver: support Siemens/Wincor Nixdorf BA63/66 (Stefan Herdler)
+ new client lcdident.pl (Ethan Dicks)
* server: prevent stalling if time goes backwards (M. Vallevand)
* hd44780 driver: update the backlight setting only on change
v.0.5.2
* fix switching on/off the Load screen in lcdproc client using the menu
+1
View File
@@ -195,6 +195,7 @@ typedef struct hd44780_private_data {
int contrast; // Contrast setting (range 0 - 1000)
int brightness; // Brightness when backlight is "on" (range 0 - 1000)
int offbrightness; // Brightness when backlight is "off" (range 0 - 1000)
int backlightstate; // Saves the last backlight state
} PrivateData;
+9 -5
View File
@@ -158,6 +158,7 @@ HD44780_init(Driver *drvthis)
p->cellheight = 8; /* Do not change this !!! This is a controller property, not a display property !!! */
p->cellwidth = 5;
p->ccmode = standard;
p->backlightstate = -1; // Init to invalid value
//// READ THE CONFIG FILE
@@ -842,7 +843,9 @@ HD44780_set_brightness(Driver *drvthis, int state, int promille)
else {
p->offbrightness = promille;
}
//HD44780_backlight(drvthis, state);
// Make last backlight state invalid to force update on next rendering
p->backlightstate = -1;
}
@@ -856,13 +859,14 @@ HD44780_backlight(Driver *drvthis, int on)
{
PrivateData *p = (PrivateData *) drvthis->private_data;
// not sure if this is the correct solution.
// alternative: return immediately
if (!p->have_backlight)
on = 0;
// Immediately return if no backlight is available or no change is necessary
if (!p->have_backlight || p->backlightstate == on)
return;
if (p->hd44780_functions->backlight != NULL)
p->hd44780_functions->backlight(p, on);
p->backlightstate = on;
}