support for contrast & brightness: now get_*() only, but prepare for set_*()
This commit is contained in:
@@ -47,6 +47,11 @@
|
|||||||
#define IF_TYPE_USB 3
|
#define IF_TYPE_USB 3
|
||||||
#define IF_TYPE_I2C 4
|
#define IF_TYPE_I2C 4
|
||||||
|
|
||||||
|
// symbolic default values
|
||||||
|
#define DEFAULT_CONTRAST 800
|
||||||
|
#define DEFAULT_BRIGHTNESS 800
|
||||||
|
#define DEFAULT_OFFBRIGHTNESS 300
|
||||||
|
|
||||||
|
|
||||||
// Maximum sizes of the keypad
|
// Maximum sizes of the keypad
|
||||||
// DO NOT CHANGE THESE 2 VALUES, unless you change the functions too
|
// DO NOT CHANGE THESE 2 VALUES, unless you change the functions too
|
||||||
@@ -56,6 +61,7 @@
|
|||||||
/* Constants for userdefchar_mode */
|
/* Constants for userdefchar_mode */
|
||||||
#define NUM_CCs 8 /* number of custom characters */
|
#define NUM_CCs 8 /* number of custom characters */
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
standard, /* only char 0 is used for heartbeat */
|
standard, /* only char 0 is used for heartbeat */
|
||||||
vbar, /* vertical bars */
|
vbar, /* vertical bars */
|
||||||
@@ -64,11 +70,13 @@ typedef enum {
|
|||||||
bigchar /* big characters */
|
bigchar /* big characters */
|
||||||
} CGmode;
|
} CGmode;
|
||||||
|
|
||||||
|
|
||||||
typedef struct cgram_cache {
|
typedef struct cgram_cache {
|
||||||
unsigned char cache[LCD_DEFAULT_CELLHEIGHT];
|
unsigned char cache[LCD_DEFAULT_CELLHEIGHT];
|
||||||
int clean;
|
int clean;
|
||||||
} CGram;
|
} CGram;
|
||||||
|
|
||||||
|
|
||||||
typedef struct ConnectionMapping {
|
typedef struct ConnectionMapping {
|
||||||
char *name;
|
char *name;
|
||||||
int connectiontype;
|
int connectiontype;
|
||||||
@@ -76,8 +84,8 @@ typedef struct ConnectionMapping {
|
|||||||
int (*init_fn)(Driver *drvthis);
|
int (*init_fn)(Driver *drvthis);
|
||||||
} ConnectionMapping;
|
} ConnectionMapping;
|
||||||
|
|
||||||
typedef struct driver_private_data {
|
|
||||||
|
|
||||||
|
typedef struct driver_private_data {
|
||||||
unsigned int port;
|
unsigned int port;
|
||||||
|
|
||||||
/* for serial connection type */
|
/* for serial connection type */
|
||||||
@@ -151,8 +159,13 @@ typedef struct driver_private_data {
|
|||||||
int keepalivedisplay; // When >0 refresh upper left char every <keepalivedisplay> seconds to keep display alive
|
int keepalivedisplay; // When >0 refresh upper left char every <keepalivedisplay> seconds to keep display alive
|
||||||
|
|
||||||
int output_state; // what was most recently output to the output port
|
int output_state; // what was most recently output to the output port
|
||||||
|
|
||||||
|
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)
|
||||||
} PrivateData;
|
} PrivateData;
|
||||||
|
|
||||||
|
|
||||||
// Structures holding pointers to HD44780 specific functions
|
// Structures holding pointers to HD44780 specific functions
|
||||||
typedef struct hwDependentFns {
|
typedef struct hwDependentFns {
|
||||||
// microsec pauses
|
// microsec pauses
|
||||||
@@ -168,6 +181,15 @@ typedef struct hwDependentFns {
|
|||||||
// state - to be or not to be on
|
// state - to be or not to be on
|
||||||
void (*backlight)(PrivateData *p, unsigned char state);
|
void (*backlight)(PrivateData *p, unsigned char state);
|
||||||
|
|
||||||
|
// Set the contrast
|
||||||
|
// value - new value to be set
|
||||||
|
void (*set_contrast)(PrivateData *p, unsigned char value);
|
||||||
|
|
||||||
|
// Switch the backlight on or off
|
||||||
|
// state - backlight state to set the new value for
|
||||||
|
// value - new value to be set
|
||||||
|
void (*set_brightness)(PrivateData *p, int backlight, unsigned char value);
|
||||||
|
|
||||||
// Read the keypad
|
// Read the keypad
|
||||||
// Ydata - the up to 11 bits that should be put on the Y side of the matrix
|
// Ydata - the up to 11 bits that should be put on the Y side of the matrix
|
||||||
// return - the up to 5 bits that are read out on the X side of the matrix
|
// return - the up to 5 bits that are read out on the X side of the matrix
|
||||||
@@ -193,57 +215,57 @@ void common_init(PrivateData *p, unsigned char if_bit);
|
|||||||
|
|
||||||
|
|
||||||
// commands for senddata
|
// commands for senddata
|
||||||
#define RS_DATA 0x00
|
#define RS_DATA 0x00
|
||||||
#define RS_INSTR 0x01
|
#define RS_INSTR 0x01
|
||||||
|
|
||||||
#define CLEAR 0x01
|
#define CLEAR 0x01
|
||||||
|
|
||||||
#define HOMECURSOR 0x02
|
#define HOMECURSOR 0x02
|
||||||
|
|
||||||
#define ENTRYMODE 0x04
|
#define ENTRYMODE 0x04
|
||||||
#define E_MOVERIGHT 0x02
|
#define E_MOVERIGHT 0x02
|
||||||
#define E_MOVELEFT 0x00
|
#define E_MOVELEFT 0x00
|
||||||
#define EDGESCROLL 0x01
|
#define EDGESCROLL 0x01
|
||||||
#define NOSCROLL 0x00
|
#define NOSCROLL 0x00
|
||||||
|
|
||||||
#define ONOFFCTRL 0x08 /* Only reachable with EXTREG clear */
|
#define ONOFFCTRL 0x08 /* Only reachable with EXTREG clear */
|
||||||
#define DISPON 0x04
|
#define DISPON 0x04
|
||||||
#define DISPOFF 0x00
|
#define DISPOFF 0x00
|
||||||
#define CURSORON 0x02
|
#define CURSORON 0x02
|
||||||
#define CURSOROFF 0x00
|
#define CURSOROFF 0x00
|
||||||
#define CURSORBLINK 0x01
|
#define CURSORBLINK 0x01
|
||||||
#define CURSORNOBLINK 0x00
|
#define CURSORNOBLINK 0x00
|
||||||
|
|
||||||
#define EXTMODESET 0x08 /* Only reachable with EXTREG set */
|
#define EXTMODESET 0x08 /* Only reachable with EXTREG set */
|
||||||
#define FONT6WIDE 0x04
|
#define FONT6WIDE 0x04
|
||||||
#define INVCURSOR 0x02
|
#define INVCURSOR 0x02
|
||||||
#define FOURLINE 0x01
|
#define FOURLINE 0x01
|
||||||
|
|
||||||
#define CURSORSHIFT 0x10 /* Only reachable with EXTREG clear */
|
#define CURSORSHIFT 0x10 /* Only reachable with EXTREG clear */
|
||||||
#define SCROLLDISP 0x08
|
#define SCROLLDISP 0x08
|
||||||
#define MOVECURSOR 0x00
|
#define MOVECURSOR 0x00
|
||||||
#define MOVERIGHT 0x04
|
#define MOVERIGHT 0x04
|
||||||
#define MOVELEFT 0x00
|
#define MOVELEFT 0x00
|
||||||
|
|
||||||
#define HSCROLLEN 0x10 /* Only reachable with EXTREG set */
|
#define HSCROLLEN 0x10 /* Only reachable with EXTREG set */
|
||||||
|
|
||||||
#define FUNCSET 0x20
|
#define FUNCSET 0x20
|
||||||
#define IF_8BIT 0x10
|
#define IF_8BIT 0x10
|
||||||
#define IF_4BIT 0x00
|
#define IF_4BIT 0x00
|
||||||
#define TWOLINE 0x08
|
#define TWOLINE 0x08
|
||||||
#define ONELINE 0x00
|
#define ONELINE 0x00
|
||||||
#define LARGECHAR 0x04 /* 5x11 characters */
|
#define LARGECHAR 0x04 /* 5x11 characters */
|
||||||
#define SMALLCHAR 0x00 /* 5x8 characters */
|
#define SMALLCHAR 0x00 /* 5x8 characters */
|
||||||
#define EXTREG 0x04 /* Select ext. registers (Yes, the same bits)*/
|
#define EXTREG 0x04 /* Select ext. registers (Yes, the same bits)*/
|
||||||
#define SEGBLINK 0x02 /* Only reachable with EXTREG set */
|
#define SEGBLINK 0x02 /* Only reachable with EXTREG set */
|
||||||
#define POWERDOWN 0x01 /* Only reachable with EXTREG set */
|
#define POWERDOWN 0x01 /* Only reachable with EXTREG set */
|
||||||
|
|
||||||
#define SETCHAR 0x40 /* Only reachable with EXTREG clear */
|
#define SETCHAR 0x40 /* Only reachable with EXTREG clear */
|
||||||
|
|
||||||
#define SETSEG 0x40 /* Only reachable with EXTREG set */
|
#define SETSEG 0x40 /* Only reachable with EXTREG set */
|
||||||
|
|
||||||
#define POSITION 0x80 /* Only reachable with EXTREG clear */
|
#define POSITION 0x80 /* Only reachable with EXTREG clear */
|
||||||
|
|
||||||
#define HSCROLLAMOUNT 0x80 /* Only reachable with EXTREG set */
|
#define HSCROLLAMOUNT 0x80 /* Only reachable with EXTREG set */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+254
-98
@@ -108,22 +108,29 @@ static char *defaultKeyMapMatrix[KEYPAD_MAXY][KEYPAD_MAXX] = {
|
|||||||
{ NULL, NULL, NULL, NULL, NULL },
|
{ NULL, NULL, NULL, NULL, NULL },
|
||||||
{ NULL, NULL, NULL, NULL, NULL }};
|
{ NULL, NULL, NULL, NULL, NULL }};
|
||||||
|
|
||||||
// function declarations
|
|
||||||
void HD44780_position(Driver *drvthis, int x, int y);
|
|
||||||
static void uPause(PrivateData *p, int usecs);
|
|
||||||
unsigned char HD44780_scankeypad(PrivateData *p);
|
|
||||||
static int parse_span_list(int *spanListArray[], int *spLsize, int *dispOffsets[], int *dOffsize, int *dispSizeArray[], const char *spanlist);
|
|
||||||
|
|
||||||
// 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;
|
||||||
MODULE_EXPORT int supports_multiple = 1; // yes, we have no global variables (except for constants)
|
MODULE_EXPORT int supports_multiple = 1; // yes, we have no global variables (except for constants)
|
||||||
MODULE_EXPORT char *symbol_prefix = "HD44780_";
|
MODULE_EXPORT char *symbol_prefix = "HD44780_";
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
/* Internal functions */
|
||||||
// Opens com port and sets baud correctly...
|
void HD44780_position(Driver *drvthis, int x, int y);
|
||||||
//
|
static void uPause(PrivateData *p, int usecs);
|
||||||
|
unsigned char HD44780_scankeypad(PrivateData *p);
|
||||||
|
static int parse_span_list(int *spanListArray[], int *spLsize, int *dispOffsets[], int *dOffsize, int *dispSizeArray[], const char *spanlist);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the driver.
|
||||||
|
* Initialize common part of drive & call sub-initialization
|
||||||
|
* routine depending on connection type.
|
||||||
|
* \param drvthis Pointer to driver structure.
|
||||||
|
* \retval 0 Success.
|
||||||
|
* \retval <0 Error.
|
||||||
|
*/
|
||||||
MODULE_EXPORT int
|
MODULE_EXPORT int
|
||||||
HD44780_init(Driver *drvthis)
|
HD44780_init(Driver *drvthis)
|
||||||
{
|
{
|
||||||
@@ -134,6 +141,7 @@ HD44780_init(Driver *drvthis)
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
int (*init_fn)(Driver *drvthis) = NULL;
|
int (*init_fn)(Driver *drvthis) = NULL;
|
||||||
int if_type = IF_TYPE_UNKNOWN;
|
int if_type = IF_TYPE_UNKNOWN;
|
||||||
|
int tmp;
|
||||||
PrivateData *p;
|
PrivateData *p;
|
||||||
|
|
||||||
// Alocate and store private data
|
// Alocate and store private data
|
||||||
@@ -199,6 +207,33 @@ HD44780_init(Driver *drvthis)
|
|||||||
report(RPT_ERR, "%s: cannot read Size %s", drvthis->name, s);
|
report(RPT_ERR, "%s: cannot read Size %s", drvthis->name, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* set contrast */
|
||||||
|
tmp = drvthis->config_get_int(drvthis->name, "Contrast", 0, DEFAULT_CONTRAST);
|
||||||
|
if ((tmp < 0) || (tmp > 1000)) {
|
||||||
|
report(RPT_WARNING, "%s: Contrast must be between 0 and 1000; using default %d",
|
||||||
|
drvthis->name, DEFAULT_CONTRAST);
|
||||||
|
tmp = DEFAULT_CONTRAST;
|
||||||
|
}
|
||||||
|
p->contrast = tmp;
|
||||||
|
|
||||||
|
/* set brightness */
|
||||||
|
tmp = drvthis->config_get_int(drvthis->name, "Brightness", 0, DEFAULT_BRIGHTNESS);
|
||||||
|
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;
|
||||||
|
|
||||||
|
/* set backlight-off "brightness" */
|
||||||
|
tmp = drvthis->config_get_int(drvthis->name, "OffBrightness", 0, DEFAULT_OFFBRIGHTNESS);
|
||||||
|
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;
|
||||||
|
|
||||||
// default case for when spans aren't indicated
|
// default case for when spans aren't indicated
|
||||||
if (p->numLines == 0) {
|
if (p->numLines == 0) {
|
||||||
if ((p->spanList = (int *) calloc(sizeof(int), p->height)) != NULL) {
|
if ((p->spanList = (int *) calloc(sizeof(int), p->height)) != NULL) {
|
||||||
@@ -215,6 +250,7 @@ HD44780_init(Driver *drvthis)
|
|||||||
if (p->numLines != p->height)
|
if (p->numLines != p->height)
|
||||||
report(RPT_ERR, "%s: height in Size does not match vSpan", drvthis->name);
|
report(RPT_ERR, "%s: height in Size does not match vSpan", drvthis->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->numDisplays == 0) {
|
if (p->numDisplays == 0) {
|
||||||
if (((p->dispVOffset = (int *) calloc(1, sizeof(int))) != NULL) &&
|
if (((p->dispVOffset = (int *) calloc(1, sizeof(int))) != NULL) &&
|
||||||
((p->dispSizes = (int *) calloc(1, sizeof(int))) != NULL)) {
|
((p->dispSizes = (int *) calloc(1, sizeof(int))) != NULL)) {
|
||||||
@@ -282,7 +318,7 @@ HD44780_init(Driver *drvthis)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (x = 0; x < KEYPAD_MAXX; x++) {
|
for (x = 0; x < KEYPAD_MAXX; x++) {
|
||||||
for (y = 0; y<KEYPAD_MAXY; y++) {
|
for (y = 0; y < KEYPAD_MAXY; y++) {
|
||||||
char buf[40];
|
char buf[40];
|
||||||
|
|
||||||
// First fill with default value
|
// First fill with default value
|
||||||
@@ -326,11 +362,18 @@ HD44780_init(Driver *drvthis)
|
|||||||
// Output latch state - init to a non-valid value
|
// Output latch state - init to a non-valid value
|
||||||
p->output_state = 999999;
|
p->output_state = 999999;
|
||||||
|
|
||||||
|
// allocate local function pointers
|
||||||
if ((p->hd44780_functions = (HD44780_functions *) calloc(1, sizeof(HD44780_functions))) == NULL) {
|
if ((p->hd44780_functions = (HD44780_functions *) calloc(1, sizeof(HD44780_functions))) == NULL) {
|
||||||
report(RPT_ERR, "%s: error mallocing", drvthis->name);
|
report(RPT_ERR, "%s: error mallocing", drvthis->name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
// pre-set local function pointers (may be overridden by local init function)
|
||||||
p->hd44780_functions->uPause = uPause;
|
p->hd44780_functions->uPause = uPause;
|
||||||
|
p->hd44780_functions->senddata = NULL;
|
||||||
|
p->hd44780_functions->backlight = NULL;
|
||||||
|
p->hd44780_functions->set_contrast = NULL;
|
||||||
|
p->hd44780_functions->set_brightness = NULL;
|
||||||
|
p->hd44780_functions->readkeypad = NULL;
|
||||||
p->hd44780_functions->scankeypad = HD44780_scankeypad;
|
p->hd44780_functions->scankeypad = HD44780_scankeypad;
|
||||||
p->hd44780_functions->output = NULL;
|
p->hd44780_functions->output = NULL;
|
||||||
p->hd44780_functions->close = NULL;
|
p->hd44780_functions->close = NULL;
|
||||||
@@ -339,6 +382,13 @@ HD44780_init(Driver *drvthis)
|
|||||||
if (init_fn(drvthis) != 0)
|
if (init_fn(drvthis) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
// fail if local senddata function was not defined
|
||||||
|
if (p->hd44780_functions->senddata == NULL) {
|
||||||
|
report(RPT_ERR, "%s: incomplete functions for connection type");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Display startup parameters on the LCD
|
// Display startup parameters on the LCD
|
||||||
HD44780_clear(drvthis);
|
HD44780_clear(drvthis);
|
||||||
sprintf(buf, "HD44780 %dx%d", p->width, p->height);
|
sprintf(buf, "HD44780 %dx%d", p->width, p->height);
|
||||||
@@ -380,12 +430,13 @@ HD44780_init(Driver *drvthis)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
|
||||||
// Common initialisation sequence - sets cursor off and not blinking,
|
/**
|
||||||
// clear display and homecursor
|
* Common initialisation sequence - sets cursor off and not blinking,
|
||||||
// Does not set twoline mode nor small characters (5x8). The init function of
|
* clear display and homecursor
|
||||||
// the connectiontype should do this.
|
* Does not set twoline mode nor small characters (5x8). The init function of
|
||||||
//
|
* the connectiontype should do this.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
common_init(PrivateData *p, unsigned char if_bit)
|
common_init(PrivateData *p, unsigned char if_bit)
|
||||||
{
|
{
|
||||||
@@ -406,25 +457,28 @@ common_init(PrivateData *p, unsigned char if_bit)
|
|||||||
p->hd44780_functions->uPause(p, 1600);
|
p->hd44780_functions->uPause(p, 1600);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
|
||||||
// Delay a number of microseconds
|
/**
|
||||||
//
|
* Delay a number of microseconds
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
uPause(PrivateData *p, int usecs)
|
uPause(PrivateData *p, int usecs)
|
||||||
{
|
{
|
||||||
timing_uPause(usecs * p->delayMult);
|
timing_uPause(usecs * p->delayMult);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
|
||||||
// Clean-up
|
/**
|
||||||
//
|
* Close the driver (do necessary clean-up).
|
||||||
|
* \param drvthis Pointer to driver structure.
|
||||||
|
*/
|
||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
HD44780_close(Driver *drvthis)
|
HD44780_close(Driver *drvthis)
|
||||||
{
|
{
|
||||||
PrivateData *p = (PrivateData *) drvthis->private_data;
|
PrivateData *p = (PrivateData *) drvthis->private_data;
|
||||||
|
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
if (p->hd44780_functions->close)
|
if (p->hd44780_functions->close != NULL)
|
||||||
p->hd44780_functions->close(p);
|
p->hd44780_functions->close(p);
|
||||||
|
|
||||||
if (p->framebuf)
|
if (p->framebuf)
|
||||||
@@ -438,9 +492,12 @@ HD44780_close(Driver *drvthis)
|
|||||||
drvthis->store_private_ptr(drvthis, NULL);
|
drvthis->store_private_ptr(drvthis, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
|
||||||
// Returns the display width
|
/**
|
||||||
//
|
* Return the display width in characters.
|
||||||
|
* \param drvthis Pointer to driver structure.
|
||||||
|
* \return Number of characters the display is wide.
|
||||||
|
*/
|
||||||
MODULE_EXPORT int
|
MODULE_EXPORT int
|
||||||
HD44780_width(Driver *drvthis)
|
HD44780_width(Driver *drvthis)
|
||||||
{
|
{
|
||||||
@@ -449,9 +506,12 @@ HD44780_width(Driver *drvthis)
|
|||||||
return p->width;
|
return p->width;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
|
||||||
// Returns the display height
|
/**
|
||||||
//
|
* Return the display height in characters.
|
||||||
|
* \param drvthis Pointer to driver structure.
|
||||||
|
* \return Number of characters the display is high.
|
||||||
|
*/
|
||||||
MODULE_EXPORT int
|
MODULE_EXPORT int
|
||||||
HD44780_height(Driver *drvthis)
|
HD44780_height(Driver *drvthis)
|
||||||
{
|
{
|
||||||
@@ -460,9 +520,12 @@ HD44780_height(Driver *drvthis)
|
|||||||
return p->height;
|
return p->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
|
||||||
// Returns the display's character cell width
|
/**
|
||||||
//
|
* Return the width of a character in pixels.
|
||||||
|
* \param drvthis Pointer to driver structure.
|
||||||
|
* \return Number of pixel columns a character cell is wide.
|
||||||
|
*/
|
||||||
MODULE_EXPORT int
|
MODULE_EXPORT int
|
||||||
HD44780_cellwidth(Driver *drvthis)
|
HD44780_cellwidth(Driver *drvthis)
|
||||||
{
|
{
|
||||||
@@ -471,9 +534,12 @@ HD44780_cellwidth(Driver *drvthis)
|
|||||||
return p->cellwidth;
|
return p->cellwidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
|
||||||
// Returns the display's character cell height
|
/**
|
||||||
//
|
* Return the height of a character in pixels.
|
||||||
|
* \param drvthis Pointer to driver structure.
|
||||||
|
* \return Number of pixel lines a character cell is high.
|
||||||
|
*/
|
||||||
MODULE_EXPORT int
|
MODULE_EXPORT int
|
||||||
HD44780_cellheight(Driver *drvthis)
|
HD44780_cellheight(Driver *drvthis)
|
||||||
{
|
{
|
||||||
@@ -482,10 +548,13 @@ HD44780_cellheight(Driver *drvthis)
|
|||||||
return p->cellheight;
|
return p->cellheight;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
|
||||||
// Set position (not part of API)
|
/**
|
||||||
//
|
* Set position (not part of API).
|
||||||
// x and y here are for the virtual p->height x p->width display
|
* \param drvthis Pointer to driver structure.
|
||||||
|
* \param x X-coordinate to go to.
|
||||||
|
* \param y Y-coordinate to go to.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
HD44780_position(Driver *drvthis, int x, int y)
|
HD44780_position(Driver *drvthis, int x, int y)
|
||||||
{
|
{
|
||||||
@@ -514,9 +583,11 @@ HD44780_position(Driver *drvthis, int x, int y)
|
|||||||
p->hd44780_functions->uPause(p, 40); // Minimum exec time for all commands
|
p->hd44780_functions->uPause(p, 40); // Minimum exec time for all commands
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
|
||||||
// Flush the framebuffer to the display
|
/**
|
||||||
//
|
* Flush data on screen to the LCD.
|
||||||
|
* \param drvthis Pointer to driver structure.
|
||||||
|
*/
|
||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
HD44780_flush(Driver *drvthis)
|
HD44780_flush(Driver *drvthis)
|
||||||
{
|
{
|
||||||
@@ -589,9 +660,11 @@ HD44780_flush(Driver *drvthis)
|
|||||||
debug(RPT_DEBUG, "%s: flushed %d custom chars", drvthis->name, count);
|
debug(RPT_DEBUG, "%s: flushed %d custom chars", drvthis->name, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
|
||||||
// Clear the framebuffer
|
/**
|
||||||
//
|
* Clear the screen.
|
||||||
|
* \param drvthis Pointer to driver structure.
|
||||||
|
*/
|
||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
HD44780_clear(Driver *drvthis)
|
HD44780_clear(Driver *drvthis)
|
||||||
{
|
{
|
||||||
@@ -601,9 +674,15 @@ HD44780_clear(Driver *drvthis)
|
|||||||
p->ccmode = standard;
|
p->ccmode = standard;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
|
||||||
// Place a character in the framebuffer
|
/**
|
||||||
//
|
* Print a character on the screen at position (x,y).
|
||||||
|
* The upper-left corner is (1,1), the lower-right corner is (p->width, p->height).
|
||||||
|
* \param drvthis Pointer to driver structure.
|
||||||
|
* \param x Horizontal character position (column).
|
||||||
|
* \param y Vertical character position (row).
|
||||||
|
* \param c Character that gets written.
|
||||||
|
*/
|
||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
HD44780_chr(Driver *drvthis, int x, int y, char ch)
|
HD44780_chr(Driver *drvthis, int x, int y, char ch)
|
||||||
{
|
{
|
||||||
@@ -616,9 +695,15 @@ HD44780_chr(Driver *drvthis, int x, int y, char ch)
|
|||||||
p->framebuf[(y * p->width) + x] = ch;
|
p->framebuf[(y * p->width) + x] = ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
|
||||||
// Place a string in the framebuffer
|
/**
|
||||||
//
|
* Print a string on the screen at position (x,y).
|
||||||
|
* The upper-left corner is (1,1), the lower-right corner is (p->width, p->height).
|
||||||
|
* \param drvthis Pointer to driver structure.
|
||||||
|
* \param x Horizontal character position (column).
|
||||||
|
* \param y Vertical character position (row).
|
||||||
|
* \param string String that gets written.
|
||||||
|
*/
|
||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
HD44780_string(Driver *drvthis, int x, int y, const char string[])
|
HD44780_string(Driver *drvthis, int x, int y, const char string[])
|
||||||
{
|
{
|
||||||
@@ -637,20 +722,62 @@ HD44780_string(Driver *drvthis, int x, int y, const char string[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
|
||||||
// Sets the backlight on or off
|
/**
|
||||||
//
|
* Get current LCD contrast.
|
||||||
|
* This is only the locally stored contrast, the contrast value
|
||||||
|
* cannot be retrieved from the LCD.
|
||||||
|
* \param drvthis Pointer to driver structure.
|
||||||
|
* \return Stored contrast in promille.
|
||||||
|
*/
|
||||||
|
MODULE_EXPORT int
|
||||||
|
HD44780_get_contrast(Driver *drvthis)
|
||||||
|
{
|
||||||
|
PrivateData *p = drvthis->private_data;
|
||||||
|
|
||||||
|
return p->contrast;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
HD44780_get_brightness(Driver *drvthis, int state)
|
||||||
|
{
|
||||||
|
PrivateData *p = drvthis->private_data;
|
||||||
|
|
||||||
|
return (state == BACKLIGHT_ON) ? p->brightness : p->offbrightness;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turn the LCD backlight on or off.
|
||||||
|
* \param drvthis Pointer to driver structure.
|
||||||
|
* \param on New backlight status.
|
||||||
|
*/
|
||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
HD44780_backlight(Driver *drvthis, int on)
|
HD44780_backlight(Driver *drvthis, int on)
|
||||||
{
|
{
|
||||||
PrivateData *p = (PrivateData *) drvthis->private_data;
|
PrivateData *p = (PrivateData *) drvthis->private_data;
|
||||||
|
|
||||||
p->hd44780_functions->backlight (p, on);
|
if (p->hd44780_functions->backlight != NULL)
|
||||||
|
p->hd44780_functions->backlight(p, on);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
|
||||||
// Draws a vertical bar...
|
/**
|
||||||
//
|
* Draw a vertical bar bottom-up.
|
||||||
|
* \param drvthis Pointer to driver structure.
|
||||||
|
* \param x Horizontal character position (column) of the starting point.
|
||||||
|
* \param y Vertical character position (row) of the starting point.
|
||||||
|
* \param len Number of characters that the bar is high at 100%
|
||||||
|
* \param promille Current height level of the bar in promille.
|
||||||
|
* \param options Options (currently unused).
|
||||||
|
*/
|
||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
HD44780_vbar(Driver *drvthis, int x, int y, int len, int promille, int options)
|
HD44780_vbar(Driver *drvthis, int x, int y, int len, int promille, int options)
|
||||||
{
|
{
|
||||||
@@ -687,9 +814,16 @@ HD44780_vbar(Driver *drvthis, int x, int y, int len, int promille, int options)
|
|||||||
lib_vbar_static(drvthis, x, y, len, promille, options, p->cellheight, 0);
|
lib_vbar_static(drvthis, x, y, len, promille, options, p->cellheight, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
|
||||||
// Draws a horizontal bar to the right.
|
/**
|
||||||
//
|
* Draw a horizontal bar to the right.
|
||||||
|
* \param drvthis Pointer to driver structure.
|
||||||
|
* \param x Horizontal character position (column) of the starting point.
|
||||||
|
* \param y Vertical character position (row) of the starting point.
|
||||||
|
* \param len Number of characters that the bar is long at 100%
|
||||||
|
* \param promille Current length level of the bar in promille.
|
||||||
|
* \param options Options (currently unused).
|
||||||
|
*/
|
||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
HD44780_hbar(Driver *drvthis, int x, int y, int len, int promille, int options)
|
HD44780_hbar(Driver *drvthis, int x, int y, int len, int promille, int options)
|
||||||
{
|
{
|
||||||
@@ -726,9 +860,12 @@ HD44780_hbar(Driver *drvthis, int x, int y, int len, int promille, int options)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
/**
|
||||||
// Writes a big number.
|
* Write a big number to the screen.
|
||||||
//
|
* \param drvthis Pointer to driver structure.
|
||||||
|
* \param x Horizontal character position (column).
|
||||||
|
* \param num Character to write (0 - 10 with 10 representing ':')
|
||||||
|
*/
|
||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
HD44780_num(Driver *drvthis, int x, int num)
|
HD44780_num(Driver *drvthis, int x, int num)
|
||||||
{
|
{
|
||||||
@@ -770,13 +907,15 @@ HD44780_get_free_chars(Driver *drvthis)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
/**
|
||||||
// Sets a custom character from 0-7...
|
* Define a custom character and write it to the LCD.
|
||||||
//
|
* \param drvthis Pointer to driver structure.
|
||||||
// For input, values > 0 mean "on" and values <= 0 are "off".
|
* \param n Custom character to define [0 - (NUM_CCs-1)].
|
||||||
//
|
* \param dat Array of 8(=cellheight) bytes, each representing a pixel row
|
||||||
// The input is just an array of characters...
|
* starting from the top to bottom.
|
||||||
//
|
* The bits in each byte represent the pixels where the LSB
|
||||||
|
* (least significant bit) is the rightmost pixel in each pixel row.
|
||||||
|
*/
|
||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
HD44780_set_char(Driver *drvthis, int n, unsigned char *dat)
|
HD44780_set_char(Driver *drvthis, int n, unsigned char *dat)
|
||||||
{
|
{
|
||||||
@@ -801,9 +940,15 @@ HD44780_set_char(Driver *drvthis, int n, unsigned char *dat)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////
|
|
||||||
// Set default icon into a userdef char
|
/**
|
||||||
//
|
* Place an icon on the screen.
|
||||||
|
* \param drvthis Pointer to driver structure.
|
||||||
|
* \param x Horizontal character position (column).
|
||||||
|
* \param y Vertical character position (row).
|
||||||
|
* \param icon synbolic value representing the icon.
|
||||||
|
* \return Information whether the icon is handled here or needs to be handled by the server core.
|
||||||
|
*/
|
||||||
MODULE_EXPORT int
|
MODULE_EXPORT int
|
||||||
HD44780_icon(Driver *drvthis, int x, int y, int icon)
|
HD44780_icon(Driver *drvthis, int x, int y, int icon)
|
||||||
{
|
{
|
||||||
@@ -975,9 +1120,12 @@ HD44780_icon(Driver *drvthis, int x, int y, int icon)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////
|
|
||||||
// Get a key from the keypad (if there is one)
|
/**
|
||||||
//
|
* Get next key from the key panel connected to the display.
|
||||||
|
* \param drvthis Pointer to driver structure.
|
||||||
|
* \return String representation of the key.
|
||||||
|
*/
|
||||||
MODULE_EXPORT const char *
|
MODULE_EXPORT const char *
|
||||||
HD44780_get_key(Driver *drvthis)
|
HD44780_get_key(Driver *drvthis)
|
||||||
{
|
{
|
||||||
@@ -1026,9 +1174,10 @@ HD44780_get_key(Driver *drvthis)
|
|||||||
return keystr;
|
return keystr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////
|
|
||||||
// Scan the keypad
|
/**
|
||||||
//
|
* Scan the keypad (not part of the API).
|
||||||
|
*/
|
||||||
unsigned char HD44780_scankeypad(PrivateData *p)
|
unsigned char HD44780_scankeypad(PrivateData *p)
|
||||||
{
|
{
|
||||||
unsigned int keybits;
|
unsigned int keybits;
|
||||||
@@ -1094,38 +1243,44 @@ unsigned char HD44780_scankeypad(PrivateData *p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////
|
/**
|
||||||
// Output to the optional output latch(es)
|
* Output to the optional output latch(es).
|
||||||
//
|
* \param drvthis Pointer to driver structure.
|
||||||
|
* \param state Integer with bits representing LED states.
|
||||||
|
*/
|
||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
HD44780_output(Driver *drvthis, int on)
|
HD44780_output(Driver *drvthis, int on)
|
||||||
{
|
{
|
||||||
PrivateData *p = drvthis->private_data;
|
PrivateData *p = drvthis->private_data;
|
||||||
|
|
||||||
if (!p->have_output) return; /* output disabled */
|
// return immediately if output is disabled
|
||||||
if (!p->hd44780_functions->output) return; /* unsupported for selected connectiontype */
|
if (!p->have_output)
|
||||||
|
return;
|
||||||
|
|
||||||
// perhaps it is better just to do this every time in case of a glitch
|
// perhaps it is better just to do this every time in case of a glitch
|
||||||
// but leaving this in does make sure that any latch-enable line glitches
|
// but leaving this in does make sure that any latch-enable line glitches
|
||||||
// are more easily seen
|
// are more easily seen
|
||||||
if (p->output_state == on) return;
|
if (p->output_state == on)
|
||||||
|
return;
|
||||||
|
|
||||||
p->output_state = on;
|
p->output_state = on;
|
||||||
p->hd44780_functions->output(p, on);
|
|
||||||
|
// call output function only if it is defined for the commenction type
|
||||||
|
if (p->hd44780_functions->output != NULL)
|
||||||
|
p->hd44780_functions->output(p, on);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////
|
/**
|
||||||
// Parse the span list
|
* Parse a span list, a comma separated list of numbers (e.g. "1,4,2").
|
||||||
// spanListArray - array to store vertical spans
|
* \param spanListArray Array to store vertical spans.
|
||||||
// spLsize - size of spanListArray
|
* \param spLsize Size of spanListArray.
|
||||||
// dispOffsets - array to store display offsets
|
* \param dispOffsets Array to store display offsets.
|
||||||
// dOffsize - size of dispOffsets
|
* \param dOffsize Size of dispOffsets.
|
||||||
// dispSizeArray - array of display vertical sizes (= spanlist)
|
* \param dispSizeArray Array of display vertical sizes (= spanlist).
|
||||||
// spanlist - null terminated input span list in comma delimited
|
* \param spanlist '\0'-terminated input span list in comma delimited format.
|
||||||
// format. All span elements [1-9] e.g. "1,4,2"
|
* \return Number of span elements, -1 on parse error.
|
||||||
// returns number of span elements, -1 on parse error
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
parse_span_list(int *spanListArray[], int *spLsize, int *dispOffsets[], int *dOffsize, int *dispSizeArray[], const char *spanlist)
|
parse_span_list(int *spanListArray[], int *spLsize, int *dispOffsets[], int *dOffsize, int *dispSizeArray[], const char *spanlist)
|
||||||
{
|
{
|
||||||
@@ -1165,3 +1320,4 @@ parse_span_list(int *spanListArray[], int *spLsize, int *dispOffsets[], int *dOf
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ MODULE_EXPORT int HD44780_icon(Driver *drvthis, int x, int y, int icon);
|
|||||||
MODULE_EXPORT void HD44780_set_char(Driver *drvthis, int n, unsigned char *dat);
|
MODULE_EXPORT void HD44780_set_char(Driver *drvthis, int n, unsigned char *dat);
|
||||||
MODULE_EXPORT int HD44780_get_free_chars(Driver *drvthis);
|
MODULE_EXPORT int HD44780_get_free_chars(Driver *drvthis);
|
||||||
|
|
||||||
|
MODULE_EXPORT int HD44780_get_contrast(Driver *drvthis);
|
||||||
|
//MODULE_EXPORT void HD44780_set_contrast(Driver *drvthis, int promille);
|
||||||
|
MODULE_EXPORT int HD44780_get_brightness(Driver *drvthis, int state);
|
||||||
|
//MODULE_EXPORT void HD44780_set_brightness(Driver *drvthis, int state, int promille);
|
||||||
MODULE_EXPORT void HD44780_backlight(Driver *drvthis, int on);
|
MODULE_EXPORT void HD44780_backlight(Driver *drvthis, int on);
|
||||||
MODULE_EXPORT void HD44780_output(Driver *drvthis, int state);
|
MODULE_EXPORT void HD44780_output(Driver *drvthis, int state);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user