diff --git a/ChangeLog b/ChangeLog index 07b3ee7..fdab36c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,8 @@ v.0.5dev (ongoing development) * fixes to ula200 build environment and documentation (B. Walle) * update g15 driver to be compatible with g15daemon > 1.2 (Anthony J. Mirabella) * allow compiling with LDFLAG "--as-needed" (Robert Buchholz) + * optimize MtxOrb flush() + * make MtxOrb use Brightness and OffBrightness like CFontzPacket v.0.5.1 + config file support in lcdproc client (Andrew Foss) diff --git a/LCDd.conf b/LCDd.conf index 57de767..9cd3b10 100644 --- a/LCDd.conf +++ b/LCDd.conf @@ -627,22 +627,24 @@ Device=/dev/ttyS0 # Set the display size [default: 20x4] Size=20x4 -# Switch on the backlight? [default: yes] -# NOTE: The driver will ignore this if the display is a vfd or vkd -# as they crash if the backlight is turned off -Backlight=yes +# Set the display type [default: lcd; legal: lcd, lkd, vfd, vkd] +Type=lkd # Set the initial contrast [default: 480] # NOTE: The driver will ignore this if the display # is a vfd or vkd as they don't have this feature Contrast=480 +# 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 + # Set the communication speed [default: 19200; legal: 1200, 2400, 9600, 19200] Speed=19200 -# Set the display type [default: lcd; legal: lcd, lkd, vfd, vkd] -Type=lkd - # The following table translates from MtxOrb key letters to logical key names. # By default no keys are mapped, meaning the keypad is not used at all. #KeyMap_A=Left diff --git a/docs/lcdproc-user/drivers/mtxorb.docbook b/docs/lcdproc-user/drivers/mtxorb.docbook index beade4c..96df744 100644 --- a/docs/lcdproc-user/drivers/mtxorb.docbook +++ b/docs/lcdproc-user/drivers/mtxorb.docbook @@ -258,22 +258,22 @@ Slightly modified in order to include it in this document March 2002, Rene Wagne - Backlight= + Type= - yes - no + lcd + lkd + vfd + vkd - Switch on the backlight? [default: yes; legal: yes, no] - - - The driver will ignore this setting if the display - is a VFD or VKD as they crash if the backlight is turned off. - - + Set the display type [default: lcd; legal: lcd, + lkd, + vfd, + vkd] + @@ -293,6 +293,28 @@ Slightly modified in order to include it in this document March 2002, Rene Wagne + + + Brightness= + BRIGHTNESS + + + Set the initial brightness [default: 1000; legal: 0 - 1000] + + + + + + OffBrightness= + BRIGHTNESS + + + 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 + + + Speed= @@ -311,26 +333,6 @@ Slightly modified in order to include it in this document March 2002, Rene Wagne - - - Type= - - - lcd - lkd - vfd - vkd - - - - - Set the display type [default: lcd; legal: lcd, - lkd, - vfd, - vkd] - - - KeyMap_LETTER= diff --git a/server/drivers/MtxOrb.c b/server/drivers/MtxOrb.c index 110fd16..39cdd19 100644 --- a/server/drivers/MtxOrb.c +++ b/server/drivers/MtxOrb.c @@ -59,9 +59,9 @@ /* MO displays allow 25 keys that map by default to 'A' - 'Y' */ +#define MAX_KEY_MAP 25 // Don't forget to define key mappings in LCDd.conf: KeyMap_A=Enter, ... // otherwise you will not get your keypad working. -# define MAX_KEY_MAP 25 #define IS_LCD_DISPLAY (p->MtxOrb_type == MTXORB_LCD) #define IS_LKD_DISPLAY (p->MtxOrb_type == MTXORB_LKD) @@ -130,8 +130,8 @@ typedef struct { int output_state; /* static data from MtxOrb_output */ int contrast; /* static data from set/get_contrast */ - int backlight_state; /* static data from MtxOrb_backlight */ - int backlightenabled; + int brightness; + int offbrightness; MtxOrb_type_type MtxOrb_type; @@ -143,6 +143,7 @@ typedef struct { char info[255]; /* static data from MtxOrb_get_info */ } PrivateData; + /* Vars for the server core */ MODULE_EXPORT char *api_version = API_VERSION; MODULE_EXPORT int stay_in_foreground = 0; @@ -186,7 +187,6 @@ MtxOrb_init (Driver *drvthis) { struct termios portset; - int contrast = DEFAULT_CONTRAST; char device[256] = DEFAULT_DEVICE; int speed = DEFAULT_SPEED; char size[256] = DEFAULT_SIZE; @@ -214,11 +214,7 @@ MtxOrb_init (Driver *drvthis) p->framebuf = NULL; p->backingstore = NULL; - p->contrast = DEFAULT_CONTRAST; p->output_state = -1; /* static data from MtxOrb_output */ - p->backlight_state = 1; /* static data from MtxOrb_backlight */ - p->backlightenabled = DEFAULT_BACKLIGHT; - p->keypad_test_mode = 0; debug(RPT_INFO, "MtxOrb: init(%p)", drvthis); @@ -250,7 +246,27 @@ MtxOrb_init (Driver *drvthis) drvthis->name, DEFAULT_CONTRAST); tmp = DEFAULT_CONTRAST; } - contrast = tmp; + p->contrast = tmp; + + /* Which backlight brightness */ + tmp = drvthis->config_get_int(drvthis->name, "Brightness", 0, DEFAULT_BRIGHTNESS); + debug(RPT_INFO, "%s: Brightness (in config) is '%d'", __FUNCTION__, tmp); + 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; + } + p->brightness = tmp; + + /* Which backlight-off "brightness" */ + tmp = drvthis->config_get_int(drvthis->name, "OffBrightness", 0, DEFAULT_OFFBRIGHTNESS); + debug(RPT_INFO, "%s: OffBrightness (in config) is '%d'", __FUNCTION__, tmp); + 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; + } + p->offbrightness = tmp; /* Get speed */ tmp = drvthis->config_get_int(drvthis->name, "Speed", 0, DEFAULT_SPEED); @@ -273,9 +289,6 @@ MtxOrb_init (Driver *drvthis) drvthis->name, tmp); } - /* Get backlight setting */ - p->backlightenabled = drvthis->config_get_bool(drvthis->name, "Backlight", 0, DEFAULT_BACKLIGHT); - /* Get display type */ strncpy(buf, drvthis->config_get_string(drvthis->name, "Type", 0, DEFAULT_TYPE), sizeof(buf)); buf[sizeof(buf)-1] = '\0'; @@ -393,7 +406,8 @@ MtxOrb_init (Driver *drvthis) MtxOrb_linewrap(drvthis, DEFAULT_LINEWRAP); MtxOrb_autoscroll(drvthis, DEFAULT_AUTOSCROLL); MtxOrb_cursorblink(drvthis, DEFAULT_CURSORBLINK); - MtxOrb_set_contrast(drvthis, contrast); + MtxOrb_set_contrast(drvthis, p->contrast); + MtxOrb_backlight(drvthis, DEFAULT_BACKLIGHT); report(RPT_DEBUG, "%s: init() done", drvthis->name); @@ -597,7 +611,7 @@ MtxOrb_flush (Driver *drvthis) if (modified) memcpy(p->backingstore, p->framebuf, p->width * p->height); - debug(RPT_DEBUG, "MtxOrb: framebuffer flushed"); + debug(RPT_DEBUG, "MtxOrb: frame buffer flushed"); } @@ -679,40 +693,68 @@ MtxOrb_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 +MtxOrb_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 +MtxOrb_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 no get */ + if (state == BACKLIGHT_ON) { + p->brightness = promille; + MtxOrb_backlight(drvthis, BACKLIGHT_ON); + } + else { + p->offbrightness = promille; + MtxOrb_backlight(drvthis, BACKLIGHT_OFF); + } +} + + /** * Turn the LCD backlight on or off. * \param drvthis Pointer to driver structure. * \param on New backlight status. - * - * \warning on=0 switches vfd/vkd displays off entirely - * - * \warning There seems to be a movement afoot to add more functions than just on/off to this.. */ MODULE_EXPORT void MtxOrb_backlight (Driver *drvthis, int on) { - PrivateData *p = drvthis->private_data; + PrivateData *p = drvthis->private_data; + unsigned char out[5] = { '\xFE', '\x99', 0 }; + int promille = (on == BACKLIGHT_ON) + ? p->brightness + : p->offbrightness; - p->backlight_state = on; + /* map range [0, 1000] -> [0, 255] that the hardware understands */ + out[2] = (unsigned char) ((long) promille * 255 / 1000); - switch (on) { - case BACKLIGHT_ON: - debug(RPT_DEBUG, "MtxOrb: display timer set to leave display on indefinitely"); - write(p->fd, "\xFE" "B" "\0", 3); /* 0 minutes == never turn display off */ - break; - case BACKLIGHT_OFF: - if (IS_VKD_DISPLAY || IS_VFD_DISPLAY) { - debug(RPT_DEBUG, "MtxOrb: backlight off ignored - not LCD or LKD display"); - ; /* turns display off entirely (whoops!) */ - } else { - debug(RPT_DEBUG, "MtxOrb: backlight turned off"); - write(p->fd, "\xFE" "F", 2); - } - break; - default: /* ignored... */ - debug(RPT_DEBUG, "MtxOrb: backlight - invalid setting"); - break; - } + write(p->fd, out, 3); + + debug(RPT_DEBUG, "MtxOrb: changed brightness to %d", out[2]); } diff --git a/server/drivers/MtxOrb.h b/server/drivers/MtxOrb.h index e958cc6..0e9fa16 100644 --- a/server/drivers/MtxOrb.h +++ b/server/drivers/MtxOrb.h @@ -4,6 +4,8 @@ #include "lcd.h" #define DEFAULT_CONTRAST 480 +#define DEFAULT_BRIGHTNESS 1000 +#define DEFAULT_OFFBRIGHTNESS 0 #define DEFAULT_DEVICE "/dev/lcd" #define DEFAULT_SPEED 19200 #define DEFAULT_LINEWRAP 1 @@ -37,6 +39,8 @@ MODULE_EXPORT void MtxOrb_set_char (Driver *drvthis, int n, unsigned char *dat); MODULE_EXPORT int MtxOrb_get_contrast (Driver *drvthis); MODULE_EXPORT void MtxOrb_set_contrast (Driver *drvthis, int promille); +MODULE_EXPORT int MtxOrb_get_brightness(Driver *drvthis, int state); +MODULE_EXPORT void MtxOrb_set_brightness(Driver *drvthis, int state, int promille); MODULE_EXPORT void MtxOrb_backlight (Driver *drvthis, int on); MODULE_EXPORT void MtxOrb_output (Driver *drvthis, int state); MODULE_EXPORT const char * MtxOrb_get_info (Driver *drvthis);