make {Off,}Brightness run-time configurable in range [0, 1000]
This commit is contained in:
@@ -21,6 +21,7 @@ v.0.5dev (ongoing development)
|
||||
* allow compiling with LDFLAG "--as-needed" (Robert Buchholz)
|
||||
* optimize MtxOrb flush()
|
||||
* make MtxOrb use Brightness and OffBrightness like CFontzPacket
|
||||
* make Brightness & OffBrightness run-time configurable in CFontz & MtxOrb
|
||||
|
||||
v.0.5.1
|
||||
+ config file support in lcdproc client (Andrew Foss)
|
||||
|
||||
@@ -142,9 +142,9 @@ Device=/dev/ttyS0
|
||||
Size=20x4
|
||||
# Set the initial contrast [default: 560; legal: 0 - 1000]
|
||||
Contrast=350
|
||||
# Set the initial brightness [default: 255; legal: 0 - 255]
|
||||
Brightness=255
|
||||
# Set the initial off-brightness [default: 0; legal: 0 - 255]
|
||||
# Set the initial brightness [default: 1000; legal: 0 - 1000]
|
||||
Brightness=1000
|
||||
# Set the initial off-brightness [default: 0; legal: 0 - 1000]
|
||||
# This value is used when the display is normally
|
||||
# switched off in case LCDd is inactive
|
||||
OffBrightness=0
|
||||
|
||||
@@ -61,8 +61,8 @@ CFontz chipset.
|
||||
<listitem><para>
|
||||
Set the initial brightness.
|
||||
Legal values for <replaceable>BRIGHTNESS</replaceable> range from
|
||||
<literal>0</literal> to <literal>255</literal>.
|
||||
If not given, it defaults to <literal>255</literal>.
|
||||
<literal>0</literal> to <literal>1000</literal>.
|
||||
If not given, it defaults to <literal>1000</literal>.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -76,7 +76,7 @@ CFontz chipset.
|
||||
This value is used when the display is normally
|
||||
switched off in case LCDd is inactive.
|
||||
Legal values <replaceable>BRIGHTNESS</replaceable> are in the range
|
||||
from <literal>0</literal> to <literal>255</literal>.
|
||||
from <literal>0</literal> to <literal>1000</literal>.
|
||||
The default is <literal>0</literal>.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
+50
-6
@@ -161,8 +161,8 @@ CFontz_init(Driver *drvthis)
|
||||
|
||||
/* Which backlight brightness */
|
||||
tmp = drvthis->config_get_int(drvthis->name, "Brightness", 0, DEFAULT_BRIGHTNESS);
|
||||
if ((tmp < 0) || (tmp > 255)) {
|
||||
report(RPT_WARNING, "%s: Brightness must be between 0 and 255; using default %d",
|
||||
if ((tmp < 0) || (tmp > 1000)) {
|
||||
report(RPT_WARNING, "%s: Brightness must be between 0 and 1000; using default %d",
|
||||
drvthis->name, DEFAULT_BRIGHTNESS);
|
||||
tmp = DEFAULT_BRIGHTNESS;
|
||||
}
|
||||
@@ -170,8 +170,8 @@ CFontz_init(Driver *drvthis)
|
||||
|
||||
/* Which backlight-off "brightness" */
|
||||
tmp = drvthis->config_get_int(drvthis->name, "OffBrightness", 0, DEFAULT_OFFBRIGHTNESS);
|
||||
if ((tmp < 0) || (tmp > 255)) {
|
||||
report(RPT_WARNING, "%s: OffBrightness must be between 0 and 255; using default %d",
|
||||
if ((tmp < 0) || (tmp > 1000)) {
|
||||
report(RPT_WARNING, "%s: OffBrightness must be between 0 and 1000; using default %d",
|
||||
drvthis->name, DEFAULT_OFFBRIGHTNESS);
|
||||
tmp = DEFAULT_OFFBRIGHTNESS;
|
||||
}
|
||||
@@ -490,6 +490,48 @@ CFontz_set_contrast(Driver *drvthis, int promille)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve brightness.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
* \param state Brightness state (on/off) for which we want the value.
|
||||
* \return Stored brightness in promille.
|
||||
*/
|
||||
MODULE_EXPORT int
|
||||
CFontz_get_brightness(Driver *drvthis, int state)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
return (state == BACKLIGHT_ON) ? p->brightness : p->offbrightness;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set on/off brightness.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
* \param state Brightness state (on/off) for which we want to store the value.
|
||||
* \param promille New brightness in promille.
|
||||
*/
|
||||
MODULE_EXPORT void
|
||||
CFontz_set_brightness(Driver *drvthis, int state, int promille)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
/* Check it */
|
||||
if (promille < 0 || promille > 1000)
|
||||
return;
|
||||
|
||||
/* store the software value since there is not get */
|
||||
if (state == BACKLIGHT_ON) {
|
||||
p->brightness = promille;
|
||||
//CFontz_backlight(drvthis, BACKLIGHT_ON);
|
||||
}
|
||||
else {
|
||||
p->offbrightness = promille;
|
||||
//CFontz_backlight(drvthis, BACKLIGHT_OFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Turn the LCD backlight on or off.
|
||||
* \param drvthis Pointer to driver structure.
|
||||
@@ -499,9 +541,11 @@ MODULE_EXPORT void
|
||||
CFontz_backlight(Driver *drvthis, int on)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
char out[4] = { CFONTZ_Backlight_Control, 0 };
|
||||
unsigned char out[4] = { CFONTZ_Backlight_Control, 0 };
|
||||
int promille = (on == BACKLIGHT_ON) ? p->brightness : p->offbrightness;
|
||||
|
||||
out[1] = (on) ? p->brightness : p->offbrightness;
|
||||
/* map range [0, 1000] -> [0, 255] that the hardware understands */
|
||||
out[1] = (unsigned char) ((long) promille * 255 / 1000);
|
||||
write(p->fd, out, 2);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#define DEFAULT_CONTRAST 560
|
||||
#define DEFAULT_DEVICE "/dev/lcd"
|
||||
#define DEFAULT_SPEED B9600
|
||||
#define DEFAULT_BRIGHTNESS 60
|
||||
#define DEFAULT_BRIGHTNESS 1000
|
||||
#define DEFAULT_OFFBRIGHTNESS 0
|
||||
#define DEFAULT_SIZE "20x4"
|
||||
|
||||
@@ -65,6 +65,8 @@ MODULE_EXPORT void CFontz_set_char(Driver *drvthis, int n, unsigned char *dat);
|
||||
|
||||
MODULE_EXPORT int CFontz_get_contrast(Driver *drvthis);
|
||||
MODULE_EXPORT void CFontz_set_contrast(Driver *drvthis, int contrast);
|
||||
MODULE_EXPORT int CFontz_get_brightness(Driver *drvthis, int state);
|
||||
MODULE_EXPORT void CFontz_set_brightness(Driver *drvthis, int state, int promille);
|
||||
MODULE_EXPORT void CFontz_backlight(Driver *drvthis, int on);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user