make MtxOrb use Brightness & OffBrightness like CFontzPacket
This commit is contained in:
@@ -19,6 +19,8 @@ v.0.5dev (ongoing development)
|
|||||||
* fixes to ula200 build environment and documentation (B. Walle)
|
* fixes to ula200 build environment and documentation (B. Walle)
|
||||||
* update g15 driver to be compatible with g15daemon > 1.2 (Anthony J. Mirabella)
|
* update g15 driver to be compatible with g15daemon > 1.2 (Anthony J. Mirabella)
|
||||||
* allow compiling with LDFLAG "--as-needed" (Robert Buchholz)
|
* allow compiling with LDFLAG "--as-needed" (Robert Buchholz)
|
||||||
|
* optimize MtxOrb flush()
|
||||||
|
* make MtxOrb use Brightness and OffBrightness like CFontzPacket
|
||||||
|
|
||||||
v.0.5.1
|
v.0.5.1
|
||||||
+ config file support in lcdproc client (Andrew Foss)
|
+ config file support in lcdproc client (Andrew Foss)
|
||||||
|
|||||||
@@ -627,22 +627,24 @@ Device=/dev/ttyS0
|
|||||||
# Set the display size [default: 20x4]
|
# Set the display size [default: 20x4]
|
||||||
Size=20x4
|
Size=20x4
|
||||||
|
|
||||||
# Switch on the backlight? [default: yes]
|
# Set the display type [default: lcd; legal: lcd, lkd, vfd, vkd]
|
||||||
# NOTE: The driver will ignore this if the display is a vfd or vkd
|
Type=lkd
|
||||||
# as they crash if the backlight is turned off
|
|
||||||
Backlight=yes
|
|
||||||
|
|
||||||
# Set the initial contrast [default: 480]
|
# Set the initial contrast [default: 480]
|
||||||
# NOTE: The driver will ignore this if the display
|
# NOTE: The driver will ignore this if the display
|
||||||
# is a vfd or vkd as they don't have this feature
|
# is a vfd or vkd as they don't have this feature
|
||||||
Contrast=480
|
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]
|
# Set the communication speed [default: 19200; legal: 1200, 2400, 9600, 19200]
|
||||||
Speed=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.
|
# 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.
|
# By default no keys are mapped, meaning the keypad is not used at all.
|
||||||
#KeyMap_A=Left
|
#KeyMap_A=Left
|
||||||
|
|||||||
@@ -258,22 +258,22 @@ Slightly modified in order to include it in this document March 2002, Rene Wagne
|
|||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<command>Backlight=</command>
|
<command>Type=</command>
|
||||||
<arg choice="plain">
|
<arg choice="plain">
|
||||||
<group choice="req">
|
<group choice="req">
|
||||||
<arg choice="plain"><literal><emphasis>yes</emphasis></literal></arg>
|
<arg choice="plain"><literal><emphasis>lcd</emphasis></literal></arg>
|
||||||
<arg choice="plain"><literal>no</literal></arg>
|
<arg choice="plain"><literal>lkd</literal></arg>
|
||||||
|
<arg choice="plain"><literal>vfd</literal></arg>
|
||||||
|
<arg choice="plain"><literal>vkd</literal></arg>
|
||||||
</group>
|
</group>
|
||||||
</arg>
|
</arg>
|
||||||
</term>
|
</term>
|
||||||
<listitem><para>
|
<listitem><para>
|
||||||
Switch on the backlight? [default: <literal>yes</literal>; legal: <literal>yes</literal>, <literal>no</literal>]
|
Set the display type [default: <literal>lcd</literal>; legal: <literal>lcd</literal>,
|
||||||
</para>
|
<literal>lkd</literal>,
|
||||||
<note><para>
|
<literal>vfd</literal>,
|
||||||
The driver will ignore this setting if the display
|
<literal>vkd</literal>]
|
||||||
is a VFD or VKD as they crash if the backlight is turned off.
|
</para></listitem>
|
||||||
</para></note>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
@@ -293,6 +293,28 @@ Slightly modified in order to include it in this document March 2002, Rene Wagne
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<command>Brightness=</command>
|
||||||
|
<arg choice="plain"><replaceable>BRIGHTNESS</replaceable></arg>
|
||||||
|
</term>
|
||||||
|
<listitem><para>
|
||||||
|
Set the initial brightness [default: <literal>1000</literal>; legal: <literal>0</literal> - <literal>1000</literal>]
|
||||||
|
</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<command>OffBrightness=</command>
|
||||||
|
<arg choice="plain"><replaceable>BRIGHTNESS</replaceable></arg>
|
||||||
|
</term>
|
||||||
|
<listitem><para>
|
||||||
|
Set the initial off-brightness [default: <literal>0</literal>; legal: <literal>0</literal> - <literal>1000</literal>]
|
||||||
|
This value is used when the display is normally
|
||||||
|
switched off in case LCDd is inactive
|
||||||
|
</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<command>Speed=</command>
|
<command>Speed=</command>
|
||||||
@@ -311,26 +333,6 @@ Slightly modified in order to include it in this document March 2002, Rene Wagne
|
|||||||
</para></listitem>
|
</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term>
|
|
||||||
<command>Type=</command>
|
|
||||||
<arg choice="plain">
|
|
||||||
<group choice="req">
|
|
||||||
<arg choice="plain"><literal><emphasis>lcd</emphasis></literal></arg>
|
|
||||||
<arg choice="plain"><literal>lkd</literal></arg>
|
|
||||||
<arg choice="plain"><literal>vfd</literal></arg>
|
|
||||||
<arg choice="plain"><literal>vkd</literal></arg>
|
|
||||||
</group>
|
|
||||||
</arg>
|
|
||||||
</term>
|
|
||||||
<listitem><para>
|
|
||||||
Set the display type [default: <literal>lcd</literal>; legal: <literal>lcd</literal>,
|
|
||||||
<literal>lkd</literal>,
|
|
||||||
<literal>vfd</literal>,
|
|
||||||
<literal>vkd</literal>]
|
|
||||||
</para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<command>KeyMap_<replaceable>LETTER</replaceable>=</command>
|
<command>KeyMap_<replaceable>LETTER</replaceable>=</command>
|
||||||
|
|||||||
+78
-36
@@ -59,9 +59,9 @@
|
|||||||
|
|
||||||
|
|
||||||
/* MO displays allow 25 keys that map by default to 'A' - 'Y' */
|
/* 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, ...
|
// Don't forget to define key mappings in LCDd.conf: KeyMap_A=Enter, ...
|
||||||
// otherwise you will not get your keypad working.
|
// otherwise you will not get your keypad working.
|
||||||
# define MAX_KEY_MAP 25
|
|
||||||
|
|
||||||
#define IS_LCD_DISPLAY (p->MtxOrb_type == MTXORB_LCD)
|
#define IS_LCD_DISPLAY (p->MtxOrb_type == MTXORB_LCD)
|
||||||
#define IS_LKD_DISPLAY (p->MtxOrb_type == MTXORB_LKD)
|
#define IS_LKD_DISPLAY (p->MtxOrb_type == MTXORB_LKD)
|
||||||
@@ -130,8 +130,8 @@ typedef struct {
|
|||||||
|
|
||||||
int output_state; /* static data from MtxOrb_output */
|
int output_state; /* static data from MtxOrb_output */
|
||||||
int contrast; /* static data from set/get_contrast */
|
int contrast; /* static data from set/get_contrast */
|
||||||
int backlight_state; /* static data from MtxOrb_backlight */
|
int brightness;
|
||||||
int backlightenabled;
|
int offbrightness;
|
||||||
|
|
||||||
MtxOrb_type_type MtxOrb_type;
|
MtxOrb_type_type MtxOrb_type;
|
||||||
|
|
||||||
@@ -143,6 +143,7 @@ typedef struct {
|
|||||||
char info[255]; /* static data from MtxOrb_get_info */
|
char info[255]; /* static data from MtxOrb_get_info */
|
||||||
} PrivateData;
|
} PrivateData;
|
||||||
|
|
||||||
|
|
||||||
/* Vars for the server core */
|
/* Vars for the server core */
|
||||||
MODULE_EXPORT char *api_version = API_VERSION;
|
MODULE_EXPORT char *api_version = API_VERSION;
|
||||||
MODULE_EXPORT int stay_in_foreground = 0;
|
MODULE_EXPORT int stay_in_foreground = 0;
|
||||||
@@ -186,7 +187,6 @@ MtxOrb_init (Driver *drvthis)
|
|||||||
{
|
{
|
||||||
struct termios portset;
|
struct termios portset;
|
||||||
|
|
||||||
int contrast = DEFAULT_CONTRAST;
|
|
||||||
char device[256] = DEFAULT_DEVICE;
|
char device[256] = DEFAULT_DEVICE;
|
||||||
int speed = DEFAULT_SPEED;
|
int speed = DEFAULT_SPEED;
|
||||||
char size[256] = DEFAULT_SIZE;
|
char size[256] = DEFAULT_SIZE;
|
||||||
@@ -214,11 +214,7 @@ MtxOrb_init (Driver *drvthis)
|
|||||||
p->framebuf = NULL;
|
p->framebuf = NULL;
|
||||||
p->backingstore = NULL;
|
p->backingstore = NULL;
|
||||||
|
|
||||||
p->contrast = DEFAULT_CONTRAST;
|
|
||||||
p->output_state = -1; /* static data from MtxOrb_output */
|
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;
|
p->keypad_test_mode = 0;
|
||||||
|
|
||||||
debug(RPT_INFO, "MtxOrb: init(%p)", drvthis);
|
debug(RPT_INFO, "MtxOrb: init(%p)", drvthis);
|
||||||
@@ -250,7 +246,27 @@ MtxOrb_init (Driver *drvthis)
|
|||||||
drvthis->name, DEFAULT_CONTRAST);
|
drvthis->name, DEFAULT_CONTRAST);
|
||||||
tmp = 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 */
|
/* Get speed */
|
||||||
tmp = drvthis->config_get_int(drvthis->name, "Speed", 0, DEFAULT_SPEED);
|
tmp = drvthis->config_get_int(drvthis->name, "Speed", 0, DEFAULT_SPEED);
|
||||||
@@ -273,9 +289,6 @@ MtxOrb_init (Driver *drvthis)
|
|||||||
drvthis->name, tmp);
|
drvthis->name, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get backlight setting */
|
|
||||||
p->backlightenabled = drvthis->config_get_bool(drvthis->name, "Backlight", 0, DEFAULT_BACKLIGHT);
|
|
||||||
|
|
||||||
/* Get display type */
|
/* Get display type */
|
||||||
strncpy(buf, drvthis->config_get_string(drvthis->name, "Type", 0, DEFAULT_TYPE), sizeof(buf));
|
strncpy(buf, drvthis->config_get_string(drvthis->name, "Type", 0, DEFAULT_TYPE), sizeof(buf));
|
||||||
buf[sizeof(buf)-1] = '\0';
|
buf[sizeof(buf)-1] = '\0';
|
||||||
@@ -393,7 +406,8 @@ MtxOrb_init (Driver *drvthis)
|
|||||||
MtxOrb_linewrap(drvthis, DEFAULT_LINEWRAP);
|
MtxOrb_linewrap(drvthis, DEFAULT_LINEWRAP);
|
||||||
MtxOrb_autoscroll(drvthis, DEFAULT_AUTOSCROLL);
|
MtxOrb_autoscroll(drvthis, DEFAULT_AUTOSCROLL);
|
||||||
MtxOrb_cursorblink(drvthis, DEFAULT_CURSORBLINK);
|
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);
|
report(RPT_DEBUG, "%s: init() done", drvthis->name);
|
||||||
|
|
||||||
@@ -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.
|
* Turn the LCD backlight on or off.
|
||||||
* \param drvthis Pointer to driver structure.
|
* \param drvthis Pointer to driver structure.
|
||||||
* \param on New backlight status.
|
* \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
|
MODULE_EXPORT void
|
||||||
MtxOrb_backlight (Driver *drvthis, int on)
|
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) {
|
write(p->fd, out, 3);
|
||||||
case BACKLIGHT_ON:
|
|
||||||
debug(RPT_DEBUG, "MtxOrb: display timer set to leave display on indefinitely");
|
debug(RPT_DEBUG, "MtxOrb: changed brightness to %d", out[2]);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
|
|
||||||
#define DEFAULT_CONTRAST 480
|
#define DEFAULT_CONTRAST 480
|
||||||
|
#define DEFAULT_BRIGHTNESS 1000
|
||||||
|
#define DEFAULT_OFFBRIGHTNESS 0
|
||||||
#define DEFAULT_DEVICE "/dev/lcd"
|
#define DEFAULT_DEVICE "/dev/lcd"
|
||||||
#define DEFAULT_SPEED 19200
|
#define DEFAULT_SPEED 19200
|
||||||
#define DEFAULT_LINEWRAP 1
|
#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 int MtxOrb_get_contrast (Driver *drvthis);
|
||||||
MODULE_EXPORT void MtxOrb_set_contrast (Driver *drvthis, int promille);
|
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_backlight (Driver *drvthis, int on);
|
||||||
MODULE_EXPORT void MtxOrb_output (Driver *drvthis, int state);
|
MODULE_EXPORT void MtxOrb_output (Driver *drvthis, int state);
|
||||||
MODULE_EXPORT const char * MtxOrb_get_info (Driver *drvthis);
|
MODULE_EXPORT const char * MtxOrb_get_info (Driver *drvthis);
|
||||||
|
|||||||
Reference in New Issue
Block a user