hd44780/serial: Add support for adjustable backlight. Solve some possible
problems that may arise by comparing signed and unsigned char values.
This commit is contained in:
@@ -28,6 +28,7 @@ v0.5dev (ongoing development)
|
|||||||
+ hd44780: Added 'usb4all' connection type (T. Mohaupt)
|
+ hd44780: Added 'usb4all' connection type (T. Mohaupt)
|
||||||
* Fix RPM init script hanging on recent OS (#3488223)
|
* Fix RPM init script hanging on recent OS (#3488223)
|
||||||
* lcdproc client: Fix build on OpenBSD >= 5.0
|
* lcdproc client: Fix build on OpenBSD >= 5.0
|
||||||
|
* hd44780/serial: Add support for adjustable backlight
|
||||||
|
|
||||||
v0.5.5
|
v0.5.5
|
||||||
+ sed1330 driver: Add support for HG25504 (L. Lagendijk)
|
+ sed1330 driver: Add support for HG25504 (L. Lagendijk)
|
||||||
|
|||||||
@@ -304,17 +304,26 @@ serial_HD44780_backlight(PrivateData *p, unsigned char state)
|
|||||||
{
|
{
|
||||||
unsigned char send;
|
unsigned char send;
|
||||||
|
|
||||||
if (SERIAL_IF.backlight) {
|
/* If backlight available and escape sequence defined send it */
|
||||||
if (SERIAL_IF.backlight_escape) {
|
if (SERIAL_IF.backlight && SERIAL_IF.backlight_escape) {
|
||||||
send = SERIAL_IF.backlight_escape;
|
send = SERIAL_IF.backlight_escape;
|
||||||
write(p->fd, &send, 1);
|
write(p->fd, &send, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SERIAL_IF.backlight == 1) { /* Backlight is just switchable */
|
||||||
if (state == BACKLIGHT_ON)
|
if (state == BACKLIGHT_ON)
|
||||||
send = SERIAL_IF.backlight_on;
|
send = SERIAL_IF.backlight_on;
|
||||||
else
|
else
|
||||||
send = SERIAL_IF.backlight_off;
|
send = SERIAL_IF.backlight_off;
|
||||||
write(p->fd, &send, 1);
|
write(p->fd, &send, 1);
|
||||||
}
|
}
|
||||||
|
else if (SERIAL_IF.backlight == 2) { /* Backlight is adjustable */
|
||||||
|
int val = (state == BACKLIGHT_ON) ? p->brightness : p->offbrightness;
|
||||||
|
|
||||||
|
/* Map the value to output range (rounding up) */
|
||||||
|
send = (val * (SERIAL_IF.backlight_on - SERIAL_IF.backlight_off) + 999) / 1000 + SERIAL_IF.backlight_off;;
|
||||||
|
write(p->fd, &send, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -330,7 +339,7 @@ serial_HD44780_scankeypad(PrivateData *p)
|
|||||||
char hangcheck = 100;
|
char hangcheck = 100;
|
||||||
|
|
||||||
read(p->fd, &buffer, 1);
|
read(p->fd, &buffer, 1);
|
||||||
if (buffer == (SERIAL_IF.keypad_escape & 0xFF)) {
|
if (buffer == SERIAL_IF.keypad_escape) {
|
||||||
while (hangcheck > 0) {
|
while (hangcheck > 0) {
|
||||||
/* Check if I can read another byte */
|
/* Check if I can read another byte */
|
||||||
if (read(p->fd, &buffer, 1) == 1) {
|
if (read(p->fd, &buffer, 1) == 1) {
|
||||||
|
|||||||
@@ -9,29 +9,55 @@
|
|||||||
#define SERIALIF_NAME_LENGTH 20
|
#define SERIALIF_NAME_LENGTH 20
|
||||||
#define DEFAULT_DEVICE "/dev/lcd"
|
#define DEFAULT_DEVICE "/dev/lcd"
|
||||||
|
|
||||||
/** Declares one configuration enty in the serial_interfaces table */
|
/** Declares one configuration entry in the serial_interfaces table */
|
||||||
struct hd44780_SerialInterface {
|
struct hd44780_SerialInterface {
|
||||||
int connectiontype; /**< Connection type from hd44780 config */
|
int connectiontype; /**< Connection type from hd44780 config */
|
||||||
/** Command escape character. This is always sent, even if 0x00 */
|
|
||||||
char instruction_escape;
|
/** \name Instruction / data escape sequence
|
||||||
/** Data escape character. Only sent if not NUL data is within range
|
* Determines if escape characters have to be sent for instruction or
|
||||||
* configure by data_escape_min and data_escape_max. */
|
* data values. The instruction escape character is always sent, even
|
||||||
char data_escape;
|
* if its value is 0x00. The data escape character is only sent it it
|
||||||
char data_escape_min; /**< Escaped data lower limit (inclusive) */
|
* is not NUL and data is within range set by data_escape_min and
|
||||||
char data_escape_max; /**< Escaped data upper limit (exclusive) */
|
* data_escape_max.
|
||||||
unsigned int default_bitrate; /**< Bitrate device is set to by default */
|
*@{*/
|
||||||
char if_bits; /**< Initialize to 8 or 4 bit interface */
|
unsigned char instruction_escape; /**< Instruction escape character. */
|
||||||
char keypad; /**< Flag: keypad available */
|
unsigned char data_escape; /**< Data escape character. */
|
||||||
char keypad_escape; /**< Keys are escaped with this character */
|
unsigned char data_escape_min; /**< Escaped data lower limit (inclusive) */
|
||||||
char backlight; /**< Flag: backlight available */
|
unsigned char data_escape_max; /**< Escaped data upper limit (exclusive) */
|
||||||
/** Escape character to send to indicate a backlight state change */
|
/**@}*/
|
||||||
char backlight_escape;
|
|
||||||
char backlight_off; /**< Character sent to set display off */
|
unsigned int default_bitrate; /**< Bitrate device is set to by default */
|
||||||
char backlight_on; /**< Character sent to set display on */
|
char if_bits; /**< Initialize to 8 or 4 bit interface */
|
||||||
|
|
||||||
|
/** \name Keypad settings
|
||||||
|
*@{*/
|
||||||
|
char keypad; /**< Flag: keypad available */
|
||||||
|
unsigned char keypad_escape; /**< Keys are escaped with this character */
|
||||||
|
/**@}*/
|
||||||
|
|
||||||
|
/** \name Backlight options
|
||||||
|
* The backlight flag determines the type of backlight available.
|
||||||
|
* If the backlight is just switchable, the backlight_off or
|
||||||
|
* backlight_on characters are sent according to backlight state.
|
||||||
|
* If the backlight is switchable, these characters must define a range
|
||||||
|
* of values that are understood as different brightness levels by
|
||||||
|
* the display. The 'brightness' and 'offbrightness' values from config
|
||||||
|
* are used according to the backlight state and mapped to this range.
|
||||||
|
*@{*/
|
||||||
|
char backlight; /**< Flag: backlight available
|
||||||
|
* 0 = none, 1 = switchable, 2 = adjustable */
|
||||||
|
unsigned char backlight_escape; /**< Escape character to send to indicate
|
||||||
|
* a backlight state change */
|
||||||
|
unsigned char backlight_off; /**< Character sent to set display off
|
||||||
|
* or minimum value if adjustable */
|
||||||
|
unsigned char backlight_on; /**< Character sent to set display on
|
||||||
|
* or maximum value if adjustable */
|
||||||
|
/**@}*/
|
||||||
|
|
||||||
/** Flag: Device has multiple controllers. If enabled, the displayID
|
/** Flag: Device has multiple controllers. If enabled, the displayID
|
||||||
* is added to data escape */
|
* is added to data_escape and it is always sent. */
|
||||||
char multiple_displays;
|
char multiple_displays;
|
||||||
char end_code; /**< Code to send on shutdown */
|
unsigned char end_code; /**< Code to send on shutdown */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user