- coding style harmonization
- check onsistency between Size & vSpan
This commit is contained in:
@@ -75,9 +75,9 @@
|
||||
// HD44780_senddata
|
||||
// HD44780_readkeypad
|
||||
|
||||
void lcdstat_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||
void lcdstat_HD44780_backlight (PrivateData *p, unsigned char state);
|
||||
unsigned char lcdstat_HD44780_readkeypad (PrivateData *p, unsigned int YData);
|
||||
void lcdstat_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||
void lcdstat_HD44780_backlight(PrivateData *p, unsigned char state);
|
||||
unsigned char lcdstat_HD44780_readkeypad(PrivateData *p, unsigned int YData);
|
||||
|
||||
#define RS 0x10
|
||||
#define RW 0x20
|
||||
@@ -94,7 +94,7 @@ static const unsigned char EnMask[] = { EN1, EN2, EN3, STRB, LF, INIT, SEL };
|
||||
|
||||
// initialisation function
|
||||
int
|
||||
hd_init_4bit (Driver *drvthis)
|
||||
hd_init_4bit(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = (PrivateData*) drvthis->private_data;
|
||||
HD44780_functions *hd44780_functions = p->hd44780_functions;
|
||||
@@ -109,60 +109,60 @@ hd_init_4bit (Driver *drvthis)
|
||||
hd44780_functions->readkeypad = lcdstat_HD44780_readkeypad;
|
||||
|
||||
// powerup the lcd now
|
||||
port_out (p->port + 2, 0 ^ OUTMASK);
|
||||
port_out (p->port, 0x03);
|
||||
if ( p->delayBus ) hd44780_functions->uPause (p, 1);
|
||||
port_out(p->port + 2, 0 ^ OUTMASK);
|
||||
port_out(p->port, 0x03);
|
||||
if (p->delayBus) hd44780_functions->uPause(p, 1);
|
||||
|
||||
/* We'll now send 0x03 a coulpe of times,
|
||||
* which is in fact (FUNCSET | IF_8BIT) >> 4 */
|
||||
port_out (p->port, enableLines | 0x03);
|
||||
port_out (p->port + 2, ALLEXT ^ OUTMASK);
|
||||
if ( p->delayBus ) hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port, 0x03);
|
||||
port_out (p->port + 2, 0 ^ OUTMASK);
|
||||
hd44780_functions->uPause (p, 15000);
|
||||
port_out(p->port, enableLines | 0x03);
|
||||
port_out(p->port + 2, ALLEXT ^ OUTMASK);
|
||||
if (p->delayBus) hd44780_functions->uPause(p, 1);
|
||||
port_out(p->port, 0x03);
|
||||
port_out(p->port + 2, 0 ^ OUTMASK);
|
||||
hd44780_functions->uPause(p, 15000);
|
||||
|
||||
port_out (p->port, enableLines | 0x03);
|
||||
port_out (p->port + 2, ALLEXT ^ OUTMASK);
|
||||
if ( p->delayBus ) hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port, 0x03);
|
||||
port_out (p->port + 2, 0 ^ OUTMASK);
|
||||
hd44780_functions->uPause (p, 5000);
|
||||
port_out(p->port, enableLines | 0x03);
|
||||
port_out(p->port + 2, ALLEXT ^ OUTMASK);
|
||||
if (p->delayBus) hd44780_functions->uPause(p, 1);
|
||||
port_out(p->port, 0x03);
|
||||
port_out(p->port + 2, 0 ^ OUTMASK);
|
||||
hd44780_functions->uPause(p, 5000);
|
||||
|
||||
port_out (p->port, enableLines | 0x03);
|
||||
port_out (p->port + 2, ALLEXT ^ OUTMASK);
|
||||
if ( p->delayBus ) hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port, 0x03);
|
||||
port_out (p->port + 2, 0 ^ OUTMASK);
|
||||
hd44780_functions->uPause (p, 100);
|
||||
port_out(p->port, enableLines | 0x03);
|
||||
port_out(p->port + 2, ALLEXT ^ OUTMASK);
|
||||
if (p->delayBus) hd44780_functions->uPause(p, 1);
|
||||
port_out(p->port, 0x03);
|
||||
port_out(p->port + 2, 0 ^ OUTMASK);
|
||||
hd44780_functions->uPause(p, 100);
|
||||
|
||||
port_out (p->port, enableLines | 0x03);
|
||||
port_out (p->port + 2, ALLEXT ^ OUTMASK);
|
||||
if ( p->delayBus ) hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port, 0x03);
|
||||
port_out (p->port + 2, 0 ^ OUTMASK);
|
||||
hd44780_functions->uPause (p, 100);
|
||||
port_out(p->port, enableLines | 0x03);
|
||||
port_out(p->port + 2, ALLEXT ^ OUTMASK);
|
||||
if (p->delayBus) hd44780_functions->uPause(p, 1);
|
||||
port_out(p->port, 0x03);
|
||||
port_out(p->port + 2, 0 ^ OUTMASK);
|
||||
hd44780_functions->uPause(p, 100);
|
||||
|
||||
// now in 8-bit mode... set 4-bit mode
|
||||
port_out (p->port, 0x02);
|
||||
if ( p->delayBus ) hd44780_functions->uPause (p, 1);
|
||||
port_out(p->port, 0x02);
|
||||
if (p->delayBus) hd44780_functions->uPause(p, 1);
|
||||
|
||||
port_out (p->port, enableLines | 0x02);
|
||||
port_out (p->port + 2, ALLEXT ^ OUTMASK);
|
||||
if ( p->delayBus ) hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port, 0x02);
|
||||
port_out (p->port + 2, 0 ^ OUTMASK);
|
||||
hd44780_functions->uPause (p, 100);
|
||||
port_out(p->port, enableLines | 0x02);
|
||||
port_out(p->port + 2, ALLEXT ^ OUTMASK);
|
||||
if (p->delayBus) hd44780_functions->uPause(p, 1);
|
||||
port_out(p->port, 0x02);
|
||||
port_out(p->port + 2, 0 ^ OUTMASK);
|
||||
hd44780_functions->uPause(p, 100);
|
||||
|
||||
// Set up two-line, small character (5x8) mode
|
||||
hd44780_functions->senddata (p, 0, RS_INSTR, FUNCSET | IF_4BIT | TWOLINE | SMALLCHAR );
|
||||
hd44780_functions->uPause (p, 40);
|
||||
hd44780_functions->senddata(p, 0, RS_INSTR, FUNCSET | IF_4BIT | TWOLINE | SMALLCHAR);
|
||||
hd44780_functions->uPause(p, 40);
|
||||
|
||||
common_init (p, IF_4BIT);
|
||||
common_init(p, IF_4BIT);
|
||||
|
||||
if (p->have_keypad) {
|
||||
// Remember which input lines are stuck
|
||||
p->stuckinputs = lcdstat_HD44780_readkeypad (p, 0);
|
||||
p->stuckinputs = lcdstat_HD44780_readkeypad(p, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -170,7 +170,7 @@ hd_init_4bit (Driver *drvthis)
|
||||
|
||||
// lcdstat_HD44780_senddata
|
||||
void
|
||||
lcdstat_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||
lcdstat_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||
{
|
||||
unsigned char enableLines = 0, portControl = 0;
|
||||
unsigned char h = (ch >> 4) & 0x0f; // high and low nibbles
|
||||
@@ -190,17 +190,17 @@ lcdstat_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char
|
||||
enableLines = EnMask[displayID - 1];
|
||||
}
|
||||
|
||||
port_out (p->port, portControl | h);
|
||||
if ( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port, enableLines | portControl | h);
|
||||
if ( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port, portControl | h);
|
||||
port_out(p->port, portControl | h);
|
||||
if (p->delayBus) p->hd44780_functions->uPause(p, 1);
|
||||
port_out(p->port, enableLines | portControl | h);
|
||||
if (p->delayBus) p->hd44780_functions->uPause(p, 1);
|
||||
port_out(p->port, portControl | h);
|
||||
|
||||
port_out (p->port, portControl | l);
|
||||
if ( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port, enableLines | portControl | l);
|
||||
if ( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port, portControl | l);
|
||||
port_out(p->port, portControl | l);
|
||||
if (p->delayBus) p->hd44780_functions->uPause(p, 1);
|
||||
port_out(p->port, enableLines | portControl | l);
|
||||
if (p->delayBus) p->hd44780_functions->uPause(p, 1);
|
||||
port_out(p->port, portControl | l);
|
||||
}
|
||||
|
||||
if (p->numDisplays > 3) {
|
||||
@@ -210,50 +210,50 @@ lcdstat_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char
|
||||
enableLines = EnMask[(displayID - 1)];
|
||||
}
|
||||
|
||||
port_out (p->port, portControl | h);
|
||||
if ( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port + 2, enableLines ^ OUTMASK);
|
||||
if ( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port + 2, 0 ^ OUTMASK);
|
||||
port_out(p->port, portControl | h);
|
||||
if (p->delayBus) p->hd44780_functions->uPause(p, 1);
|
||||
port_out(p->port + 2, enableLines ^ OUTMASK);
|
||||
if (p->delayBus) p->hd44780_functions->uPause(p, 1);
|
||||
port_out(p->port + 2, 0 ^ OUTMASK);
|
||||
|
||||
port_out (p->port, portControl | l);
|
||||
if ( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port + 2, enableLines ^ OUTMASK);
|
||||
if ( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port + 2, 0 ^ OUTMASK);
|
||||
port_out(p->port, portControl | l);
|
||||
if (p->delayBus) p->hd44780_functions->uPause(p, 1);
|
||||
port_out(p->port + 2, enableLines ^ OUTMASK);
|
||||
if (p->delayBus) p->hd44780_functions->uPause(p, 1);
|
||||
port_out(p->port + 2, 0 ^ OUTMASK);
|
||||
}
|
||||
}
|
||||
|
||||
void lcdstat_HD44780_backlight (PrivateData *p, unsigned char state)
|
||||
void lcdstat_HD44780_backlight(PrivateData *p, unsigned char state)
|
||||
{
|
||||
p->backlight_bit = ((!p->have_backlight||state)?0:BL);
|
||||
|
||||
port_out (p->port, p->backlight_bit);
|
||||
port_out(p->port, p->backlight_bit);
|
||||
}
|
||||
|
||||
unsigned char lcdstat_HD44780_readkeypad (PrivateData *p, unsigned int YData)
|
||||
unsigned char lcdstat_HD44780_readkeypad(PrivateData *p, unsigned int YData)
|
||||
{
|
||||
unsigned char readval;
|
||||
|
||||
// 10 bits output or 6 bits if >=3 displays
|
||||
// Convert the positive logic to the negative logic on the LPT port
|
||||
port_out (p->port, ~YData & 0x003F );
|
||||
port_out(p->port, ~YData & 0x003F);
|
||||
if (p->numDisplays<=3) {
|
||||
// Can't combine >3 displays with >6 keypad output lines
|
||||
port_out (p->port + 2, ( ((~YData & 0x03C0) << 6 )) ^ OUTMASK);
|
||||
port_out(p->port + 2, (((~YData & 0x03C0) << 6)) ^ OUTMASK);
|
||||
}
|
||||
if ( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
if (p->delayBus) p->hd44780_functions->uPause(p, 1);
|
||||
|
||||
// Read inputs
|
||||
readval = ~ port_in (p->port + 1) ^ INMASK;
|
||||
readval = ~ port_in(p->port + 1) ^ INMASK;
|
||||
|
||||
// Put port back into idle state for backlight
|
||||
port_out (p->port, p->backlight_bit);
|
||||
port_out(p->port, p->backlight_bit);
|
||||
|
||||
// And convert value back (MSB first).
|
||||
return (((readval & FAULT) / FAULT <<4) | /* pin 15 */
|
||||
((readval & SELIN) / SELIN <<3) | /* pin 13 */
|
||||
((readval & PAPEREND) / PAPEREND <<2) | /* pin 12 */
|
||||
((readval & BUSY) / BUSY <<1) | /* pin 11 */
|
||||
((readval & ACK) / ACK )) & ~p->stuckinputs; /* pin 10 */
|
||||
((readval & ACK) / ACK)) & ~p->stuckinputs; /* pin 10 */
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
#include "lcd.h" /* for Driver */
|
||||
|
||||
// initialise this particular driver
|
||||
int hd_init_4bit (Driver *drvthis);
|
||||
int hd_init_4bit(Driver *drvthis);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -38,7 +38,7 @@ static int bwct_usb_i;
|
||||
|
||||
// initialize the driver
|
||||
int
|
||||
hd_init_bwct_usb (Driver *drvthis)
|
||||
hd_init_bwct_usb(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = (PrivateData*) drvthis->private_data;
|
||||
|
||||
|
||||
@@ -17,47 +17,48 @@
|
||||
# include "hd44780-serialLpt.h"
|
||||
# include "hd44780-winamp.h"
|
||||
#endif
|
||||
#include "hd44780-serial.h"
|
||||
#include "hd44780-lis2.h"
|
||||
#ifdef HAVE_LIBUSB
|
||||
# include "hd44780-bwct-usb.h"
|
||||
# include "hd44780-lcd2usb.h"
|
||||
#endif
|
||||
#include "hd44780-serial.h"
|
||||
#include "hd44780-lis2.h"
|
||||
#ifdef HAVE_I2C
|
||||
# include "hd44780-i2c.h"
|
||||
#endif
|
||||
// add new connection type header files here
|
||||
|
||||
|
||||
static const ConnectionMapping connectionMapping[] = {
|
||||
// connectionType enumerator
|
||||
// string to identify connection on command line
|
||||
// your initialisation function
|
||||
// help string for your particular connection
|
||||
#ifdef HAVE_PCSTYLE_LPT_CONTROL
|
||||
{"4bit", hd_init_4bit, "\tnone\n"},
|
||||
{"8bit", hd_init_ext8bit, "\tnone\n"},
|
||||
{"serialLpt", hd_init_serialLpt, "\tnone\n"},
|
||||
{"winamp", hd_init_winamp, "\tnone\n"},
|
||||
{ "4bit", hd_init_4bit, "\tnone\n" },
|
||||
{ "8bit", hd_init_ext8bit, "\tnone\n" },
|
||||
{ "serialLpt", hd_init_serialLpt, "\tnone\n" },
|
||||
{ "winamp", hd_init_winamp, "\tnone\n" },
|
||||
#endif
|
||||
/* Serial connectiontypes */
|
||||
{"picanlcd", hd_init_serial, "\tnone\n"},
|
||||
{"lcdserializer", hd_init_serial, "\tnone\n"},
|
||||
{"los-panel", hd_init_serial, "\tnone\n"},
|
||||
{"vdr-lcd", hd_init_serial, "\tnone\n"},
|
||||
{"vdr-wakeup", hd_init_serial, "\tnone\n"},
|
||||
{"pertelian", hd_init_serial, "\tnone\n"},
|
||||
{ "picanlcd", hd_init_serial, "\tnone\n" },
|
||||
{ "lcdserializer", hd_init_serial, "\tnone\n" },
|
||||
{ "los-panel", hd_init_serial, "\tnone\n" },
|
||||
{ "vdr-lcd", hd_init_serial, "\tnone\n" },
|
||||
{ "vdr-wakeup", hd_init_serial, "\tnone\n" },
|
||||
{ "pertelian", hd_init_serial, "\tnone\n" },
|
||||
/* End serial connectiontypes */
|
||||
{"lis2", hd_init_lis2, "\tnone\n"},
|
||||
{ "lis2", hd_init_lis2, "\tnone\n" },
|
||||
#ifdef HAVE_LIBUSB
|
||||
{"bwctusb", hd_init_bwct_usb, "\tnone\n"},
|
||||
{"lcd2usb", hd_init_lcd2usb, "\tnone\n"},
|
||||
{ "bwctusb", hd_init_bwct_usb, "\tnone\n" },
|
||||
{ "lcd2usb", hd_init_lcd2usb, "\tnone\n" },
|
||||
#endif
|
||||
#ifdef HAVE_I2C
|
||||
{"i2c", hd_init_i2c, "\tnone\n"},
|
||||
{ "i2c", hd_init_i2c, "\tnone\n" },
|
||||
#endif
|
||||
// add new connection types and their string specifier here
|
||||
// default, end of structure element (do not delete)
|
||||
{NULL, NULL, NULL}
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -67,9 +67,9 @@
|
||||
// HD44780_senddata
|
||||
// HD44780_readkeypad
|
||||
|
||||
void lcdtime_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||
void lcdtime_HD44780_backlight (PrivateData *p, unsigned char state);
|
||||
unsigned char lcdtime_HD44780_readkeypad (PrivateData *p, unsigned int YData);
|
||||
void lcdtime_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||
void lcdtime_HD44780_backlight(PrivateData *p, unsigned char state);
|
||||
unsigned char lcdtime_HD44780_readkeypad(PrivateData *p, unsigned int YData);
|
||||
void lcdtime_HD44780_output(PrivateData *p, int data);
|
||||
|
||||
#define RS STRB
|
||||
@@ -82,12 +82,12 @@ static int semid;
|
||||
|
||||
// initialise the driver
|
||||
int
|
||||
hd_init_ext8bit (Driver *drvthis)
|
||||
hd_init_ext8bit(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = (PrivateData*) drvthis->private_data;
|
||||
HD44780_functions *hd44780_functions = p->hd44780_functions;
|
||||
|
||||
semid = sem_get ();
|
||||
semid = sem_get();
|
||||
|
||||
// Reserve the port registers
|
||||
port_access_multiple(p->port,3);
|
||||
@@ -97,18 +97,18 @@ hd_init_ext8bit (Driver *drvthis)
|
||||
hd44780_functions->readkeypad = lcdtime_HD44780_readkeypad;
|
||||
|
||||
// setup the lcd in 8 bit mode
|
||||
hd44780_functions->senddata (p, 0, RS_INSTR, FUNCSET | IF_8BIT);
|
||||
hd44780_functions->uPause (p, 4100);
|
||||
hd44780_functions->senddata (p, 0, RS_INSTR, FUNCSET | IF_8BIT);
|
||||
hd44780_functions->uPause (p, 100);
|
||||
hd44780_functions->senddata (p, 0, RS_INSTR, FUNCSET | IF_8BIT | TWOLINE | SMALLCHAR);
|
||||
hd44780_functions->uPause (p, 40);
|
||||
hd44780_functions->senddata(p, 0, RS_INSTR, FUNCSET | IF_8BIT);
|
||||
hd44780_functions->uPause(p, 4100);
|
||||
hd44780_functions->senddata(p, 0, RS_INSTR, FUNCSET | IF_8BIT);
|
||||
hd44780_functions->uPause(p, 100);
|
||||
hd44780_functions->senddata(p, 0, RS_INSTR, FUNCSET | IF_8BIT | TWOLINE | SMALLCHAR);
|
||||
hd44780_functions->uPause(p, 40);
|
||||
|
||||
common_init (p, IF_8BIT);
|
||||
|
||||
if (p->have_keypad) {
|
||||
// Remember which input lines are stuck
|
||||
p->stuckinputs = lcdtime_HD44780_readkeypad (p, 0);
|
||||
p->stuckinputs = lcdtime_HD44780_readkeypad(p, 0);
|
||||
}
|
||||
// Writes new value to the "bargraph" latches
|
||||
hd44780_functions->output = lcdtime_HD44780_output;
|
||||
@@ -117,7 +117,7 @@ hd_init_ext8bit (Driver *drvthis)
|
||||
|
||||
// lcdtime_HD44780_senddata
|
||||
void
|
||||
lcdtime_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||
lcdtime_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||
{
|
||||
unsigned char enableLines = 0, portControl;
|
||||
|
||||
@@ -131,53 +131,53 @@ lcdtime_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char
|
||||
|
||||
portControl |= p->backlight_bit;
|
||||
|
||||
sem_wait (semid);
|
||||
port_out (p->port + 2, portControl ^ OUTMASK);
|
||||
port_out (p->port, ch);
|
||||
if ( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port + 2, (enableLines|portControl) ^ OUTMASK);
|
||||
if ( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port + 2, portControl ^ OUTMASK);
|
||||
sem_signal (semid);
|
||||
sem_wait(semid);
|
||||
port_out(p->port + 2, portControl ^ OUTMASK);
|
||||
port_out(p->port, ch);
|
||||
if (p->delayBus) p->hd44780_functions->uPause(p, 1);
|
||||
port_out(p->port + 2, (enableLines|portControl) ^ OUTMASK);
|
||||
if (p->delayBus) p->hd44780_functions->uPause(p, 1);
|
||||
port_out(p->port + 2, portControl ^ OUTMASK);
|
||||
sem_signal(semid);
|
||||
}
|
||||
|
||||
void lcdtime_HD44780_backlight (PrivateData *p, unsigned char state)
|
||||
void lcdtime_HD44780_backlight(PrivateData *p, unsigned char state)
|
||||
{
|
||||
p->backlight_bit = (state?0:SEL);
|
||||
|
||||
// Semaphores not needed because backlight will not go together with
|
||||
// the bacrgraph anyway...
|
||||
port_out (p->port + 2, p->backlight_bit ^ OUTMASK);
|
||||
port_out(p->port + 2, p->backlight_bit ^ OUTMASK);
|
||||
}
|
||||
|
||||
unsigned char lcdtime_HD44780_readkeypad (PrivateData *p, unsigned int YData)
|
||||
unsigned char lcdtime_HD44780_readkeypad(PrivateData *p, unsigned int YData)
|
||||
{
|
||||
unsigned char readval;
|
||||
|
||||
sem_wait (semid);
|
||||
sem_wait(semid);
|
||||
|
||||
// 10 bits output or 8 bits if >=2 displays
|
||||
// Convert the positive logic to the negative logic on the LPT port
|
||||
port_out (p->port, ~YData & 0x00FF );
|
||||
port_out(p->port, ~YData & 0x00FF);
|
||||
if (p->numDisplays<=2) {
|
||||
// Can't combine >3 displays with >8 keypad output lines
|
||||
port_out (p->port + 2, ( ((~YData & 0x0100) >> 8) | ((~YData & 0x0200) >> 6)) ^ OUTMASK);
|
||||
port_out(p->port + 2, (((~YData & 0x0100) >> 8) | ((~YData & 0x0200) >> 6)) ^ OUTMASK);
|
||||
}
|
||||
if ( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
if (p->delayBus) p->hd44780_functions->uPause(p, 1);
|
||||
|
||||
// Read inputs
|
||||
readval = ~ port_in (p->port + 1) ^ INMASK;
|
||||
readval = ~ port_in(p->port + 1) ^ INMASK;
|
||||
|
||||
// Put port back into idle state for backlight
|
||||
port_out (p->port, p->backlight_bit ^ OUTMASK);
|
||||
sem_signal (semid);
|
||||
port_out(p->port, p->backlight_bit ^ OUTMASK);
|
||||
sem_signal(semid);
|
||||
|
||||
// And convert value back (MSB first).
|
||||
return (((readval & FAULT) / FAULT <<4) | /* pin 15 */
|
||||
((readval & SELIN) / SELIN <<3) | /* pin 13 */
|
||||
((readval & PAPEREND) / PAPEREND <<2) | /* pin 12 */
|
||||
((readval & BUSY) / BUSY <<1) | /* pin 11 */
|
||||
((readval & ACK) / ACK )) & ~p->stuckinputs; /* pin 10 */
|
||||
((readval & ACK) / ACK)) & ~p->stuckinputs; /* pin 10 */
|
||||
}
|
||||
|
||||
void lcdtime_HD44780_output(PrivateData *p, int data)
|
||||
@@ -185,8 +185,8 @@ void lcdtime_HD44780_output(PrivateData *p, int data)
|
||||
// Setup data bus
|
||||
port_out(p->port, data);
|
||||
// Strobe the latch (374 latches on rising edge, 3/574 on trailing. No matter)
|
||||
port_out (p->port + 2, (LE | p->backlight_bit) ^ OUTMASK);
|
||||
if ( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port + 2, (p->backlight_bit) ^ OUTMASK);
|
||||
if ( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
port_out(p->port + 2, (LE | p->backlight_bit) ^ OUTMASK);
|
||||
if (p->delayBus) p->hd44780_functions->uPause(p, 1);
|
||||
port_out(p->port + 2, (p->backlight_bit) ^ OUTMASK);
|
||||
if (p->delayBus) p->hd44780_functions->uPause(p, 1);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
#include "lcd.h" /* for Driver */
|
||||
|
||||
// initialise this particular driver
|
||||
int hd_init_ext8bit (Driver *drvthis);
|
||||
int hd_init_ext8bit(Driver *drvthis);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -71,8 +71,8 @@
|
||||
// HD44780_senddata
|
||||
// HD44780_readkeypad
|
||||
|
||||
void i2c_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||
void i2c_HD44780_backlight (PrivateData *p, unsigned char state);
|
||||
void i2c_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||
void i2c_HD44780_backlight(PrivateData *p, unsigned char state);
|
||||
|
||||
#define RS 0x10
|
||||
#define RW 0x20
|
||||
@@ -84,7 +84,7 @@ void i2c_HD44780_backlight (PrivateData *p, unsigned char state);
|
||||
#define I2C_PCAX_MASK 0x80
|
||||
|
||||
static void
|
||||
i2c_out (PrivateData *p, unsigned char val)
|
||||
i2c_out(PrivateData *p, unsigned char val)
|
||||
{
|
||||
__u8 data[2];
|
||||
int datalen;
|
||||
@@ -97,8 +97,8 @@ i2c_out (PrivateData *p, unsigned char val)
|
||||
data[0]=val;
|
||||
datalen=1;
|
||||
}
|
||||
if ( write(p->fd,data,datalen) != datalen ) {
|
||||
report( no_more_errormsgs?RPT_DEBUG:RPT_ERR, "HD44780: I2C: i2c write data %u to address %u failed: %s",
|
||||
if (write(p->fd,data,datalen) != datalen) {
|
||||
report(no_more_errormsgs?RPT_DEBUG:RPT_ERR, "HD44780: I2C: i2c write data %u to address %u failed: %s",
|
||||
val, p->port & I2C_ADDR_MASK, strerror(errno));
|
||||
no_more_errormsgs=1;
|
||||
}
|
||||
@@ -108,7 +108,7 @@ i2c_out (PrivateData *p, unsigned char val)
|
||||
|
||||
// initialisation function
|
||||
int
|
||||
hd_init_i2c (Driver *drvthis)
|
||||
hd_init_i2c(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = (PrivateData*) drvthis->private_data;
|
||||
HD44780_functions *hd44780_functions = p->hd44780_functions;
|
||||
@@ -160,7 +160,7 @@ hd_init_i2c (Driver *drvthis)
|
||||
// powerup the lcd now
|
||||
/* We'll now send 0x03 a couple of times,
|
||||
* which is in fact (FUNCSET | IF_8BIT) >> 4 */
|
||||
i2c_out (p, 0x03);
|
||||
i2c_out(p, 0x03);
|
||||
if (p->delayBus)
|
||||
hd44780_functions->uPause(p, 1);
|
||||
|
||||
@@ -200,7 +200,7 @@ hd_init_i2c (Driver *drvthis)
|
||||
hd44780_functions->uPause(p, 100);
|
||||
|
||||
// Set up two-line, small character (5x8) mode
|
||||
hd44780_functions->senddata(p, 0, RS_INSTR, FUNCSET | IF_4BIT | TWOLINE | SMALLCHAR );
|
||||
hd44780_functions->senddata(p, 0, RS_INSTR, FUNCSET | IF_4BIT | TWOLINE | SMALLCHAR);
|
||||
hd44780_functions->uPause(p, 40);
|
||||
|
||||
common_init(p, IF_4BIT);
|
||||
@@ -210,7 +210,7 @@ hd_init_i2c (Driver *drvthis)
|
||||
|
||||
// i2c_HD44780_senddata
|
||||
void
|
||||
i2c_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||
i2c_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||
{
|
||||
unsigned char enableLines = 0, portControl = 0;
|
||||
unsigned char h = (ch >> 4) & 0x0f; // high and low nibbles
|
||||
@@ -242,7 +242,7 @@ i2c_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char fla
|
||||
i2c_out(p, portControl | l);
|
||||
}
|
||||
|
||||
void i2c_HD44780_backlight (PrivateData *p, unsigned char state)
|
||||
void i2c_HD44780_backlight(PrivateData *p, unsigned char state)
|
||||
{
|
||||
p->backlight_bit = ((!p->have_backlight||state) ? 0 : BL);
|
||||
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
#include "lcd.h" /* for Driver */
|
||||
|
||||
// initialise this particular driver
|
||||
int hd_init_i2c (Driver *drvthis);
|
||||
int hd_init_i2c(Driver *drvthis);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -40,9 +40,9 @@
|
||||
#endif
|
||||
|
||||
|
||||
void lis2_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||
void lis2_HD44780_backlight (PrivateData *p, unsigned char state);
|
||||
unsigned char lis2_HD44780_scankeypad (PrivateData *p);
|
||||
void lis2_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||
void lis2_HD44780_backlight(PrivateData *p, unsigned char state);
|
||||
unsigned char lis2_HD44780_scankeypad(PrivateData *p);
|
||||
void SetMatrice(PrivateData *p,int fd, int matriceNum, int ligne, int point);
|
||||
void SetFan(int fd, int fan1, int fan2, int fan3, int fan4);
|
||||
void gotoXY(int fd, int x, int y);
|
||||
@@ -55,7 +55,7 @@ void clear(int fd);
|
||||
void writeChar(int fd, int code);
|
||||
|
||||
// initialise the driver
|
||||
int hd_init_lis2 (Driver *drvthis)
|
||||
int hd_init_lis2(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = (PrivateData*) drvthis->private_data;
|
||||
|
||||
@@ -100,7 +100,7 @@ int hd_init_lis2 (Driver *drvthis)
|
||||
p->hd44780_functions->backlight = lis2_HD44780_backlight;
|
||||
p->hd44780_functions->scankeypad = lis2_HD44780_scankeypad;
|
||||
|
||||
common_init (p, IF_8BIT);
|
||||
common_init(p, IF_8BIT);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -154,32 +154,28 @@ int mode = 0;
|
||||
int charNum = 0;
|
||||
int rowNum = 0;
|
||||
|
||||
void lis2_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||
void lis2_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||
{
|
||||
if (flags == RS_DATA) {
|
||||
if (mode == SETCHAR)
|
||||
{
|
||||
writeChar( p->fd, 0);
|
||||
writeChar( p->fd, 171);
|
||||
writeChar( p->fd, charNum);
|
||||
writeChar( p->fd, rowNum);
|
||||
writeChar( p->fd, ch);
|
||||
rowNum = rowNum + 1;
|
||||
if (rowNum==p->cellheight)
|
||||
{
|
||||
if (mode == SETCHAR) {
|
||||
writeChar(p->fd, 0);
|
||||
writeChar(p->fd, 171);
|
||||
writeChar(p->fd, charNum);
|
||||
writeChar(p->fd, rowNum);
|
||||
writeChar(p->fd, ch);
|
||||
rowNum++;
|
||||
if (rowNum == p->cellheight) {
|
||||
mode = 0;
|
||||
rowNum = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ch<7) ch=ch+1;
|
||||
write( p->fd, &ch, 1 );
|
||||
else {
|
||||
if (ch < 7) ch++;
|
||||
write(p->fd, &ch, 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ((ch & POSITION)!=0)
|
||||
{
|
||||
if ((ch & POSITION) != 0) {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int pos = 0;
|
||||
@@ -187,41 +183,38 @@ void lis2_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned ch
|
||||
pos = (ch & ~POSITION);
|
||||
|
||||
if (p->ext_mode) {
|
||||
y = pos/0x20;
|
||||
x = pos-(y*0x20);
|
||||
y = pos / 0x20;
|
||||
x = pos - (y * 0x20);
|
||||
}
|
||||
else {
|
||||
y = pos/0x40;
|
||||
x = pos-(y*0x40);
|
||||
y = pos / 0x40;
|
||||
x = pos - (y * 0x40);
|
||||
}
|
||||
|
||||
writeChar( p->fd, 0);
|
||||
writeChar( p->fd, 161 + y);
|
||||
writeChar( p->fd, x);
|
||||
writeChar( p->fd, 167);
|
||||
writeChar(p->fd, 0);
|
||||
writeChar(p->fd, 161 + y);
|
||||
writeChar(p->fd, x);
|
||||
writeChar(p->fd, 167);
|
||||
|
||||
}
|
||||
else if ((ch & SETCHAR)!=0)
|
||||
{
|
||||
else if ((ch & SETCHAR) != 0) {
|
||||
mode = SETCHAR;
|
||||
charNum = ((ch & ~SETCHAR)/8) + 1;
|
||||
if (charNum==8) charNum = 7;
|
||||
if (charNum == 8) charNum = 7;
|
||||
}
|
||||
else write( p->fd, &ch, 1 );
|
||||
else write(p->fd, &ch, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void lis2_HD44780_backlight (PrivateData *p, unsigned char state)
|
||||
void lis2_HD44780_backlight(PrivateData *p, unsigned char state)
|
||||
{
|
||||
/* No backlight control */
|
||||
}
|
||||
|
||||
unsigned char lis2_HD44780_scankeypad (PrivateData *p)
|
||||
unsigned char lis2_HD44780_scankeypad(PrivateData *p)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
#include "lcd.h" /* for Driver */
|
||||
|
||||
// initialise this particular driver
|
||||
int hd_init_lis2 (Driver *drvthis);
|
||||
int hd_init_lis2(Driver *drvthis);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -45,7 +45,7 @@ typedef struct cgram_cache {
|
||||
|
||||
typedef struct ConnectionMapping {
|
||||
char *name;
|
||||
int (*init_fn) (Driver *drvthis);
|
||||
int (*init_fn)(Driver *drvthis);
|
||||
const char *helpMsg;
|
||||
} ConnectionMapping;
|
||||
|
||||
@@ -129,40 +129,40 @@ typedef struct driver_private_data {
|
||||
// Structures holding pointers to HD44780 specific functions
|
||||
typedef struct hwDependentFns {
|
||||
// microsec pauses
|
||||
void (*uPause) (PrivateData *p, int usecs);
|
||||
void (*uPause)(PrivateData *p, int usecs);
|
||||
|
||||
// Senddata to the LCD
|
||||
// dispID - display to send data to (0 = all displays)
|
||||
// flags - data or instruction command (RS_DATA | RS_INSTR)
|
||||
// ch - character to display or instruction value
|
||||
void (*senddata) (PrivateData *p, unsigned char dispID, unsigned char flags, unsigned char ch);
|
||||
void (*senddata)(PrivateData *p, unsigned char dispID, unsigned char flags, unsigned char ch);
|
||||
|
||||
// Switch the backlight on or off
|
||||
// state - to be or not to be on
|
||||
void (*backlight) (PrivateData *p, unsigned char state);
|
||||
void (*backlight)(PrivateData *p, unsigned char state);
|
||||
|
||||
// Read the keypad
|
||||
// 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
|
||||
unsigned char (*readkeypad) (PrivateData *p, unsigned int Ydata);
|
||||
unsigned char (*readkeypad)(PrivateData *p, unsigned int Ydata);
|
||||
|
||||
// Scan the keypad and return a scancode.
|
||||
// The code is the Yvalue in the high nibble and the Xvalue in the low nibble.
|
||||
// A subdriver should do only one of two things:
|
||||
// - set readkeypad; or
|
||||
// - override scankeypad.
|
||||
unsigned char (*scankeypad) (PrivateData *p);
|
||||
unsigned char (*scankeypad)(PrivateData *p);
|
||||
|
||||
// Output "data" to output latch if there is one
|
||||
void (*output) (PrivateData *p, int data);
|
||||
void (*output)(PrivateData *p, int data);
|
||||
|
||||
// Close the interface on shutdown
|
||||
void (*close) (PrivateData *p);
|
||||
void (*close)(PrivateData *p);
|
||||
|
||||
} HD44780_functions; /* for want of a better name :-) */
|
||||
|
||||
|
||||
void common_init (PrivateData *p, unsigned char if_bit);
|
||||
void common_init(PrivateData *p, unsigned char if_bit);
|
||||
|
||||
|
||||
// commands for senddata
|
||||
|
||||
@@ -108,8 +108,8 @@ unsigned int bitrate_conversion[][2] = {
|
||||
|
||||
int convert_bitrate(unsigned int conf_bitrate, size_t *bitrate) {
|
||||
int counter;
|
||||
for ( counter=0 ; counter<sizeof(bitrate_conversion)/(2*sizeof(unsigned int)) ; counter++ )
|
||||
if (bitrate_conversion[counter][0]==conf_bitrate) {
|
||||
for (counter = 0; counter < sizeof(bitrate_conversion)/(2*sizeof(unsigned int)); counter++)
|
||||
if (bitrate_conversion[counter][0] == conf_bitrate) {
|
||||
*bitrate = (size_t) bitrate_conversion[counter][1];
|
||||
return 0;
|
||||
}
|
||||
@@ -118,14 +118,14 @@ int convert_bitrate(unsigned int conf_bitrate, size_t *bitrate) {
|
||||
|
||||
static int lastdisplayID;
|
||||
|
||||
void serial_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||
void serial_HD44780_backlight (PrivateData *p, unsigned char state);
|
||||
unsigned char serial_HD44780_scankeypad (PrivateData *p);
|
||||
void serial_HD44780_close (PrivateData *p);
|
||||
void serial_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||
void serial_HD44780_backlight(PrivateData *p, unsigned char state);
|
||||
unsigned char serial_HD44780_scankeypad(PrivateData *p);
|
||||
void serial_HD44780_close(PrivateData *p);
|
||||
|
||||
// initialize the driver
|
||||
int
|
||||
hd_init_serial (Driver *drvthis)
|
||||
hd_init_serial(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = (PrivateData*) drvthis->private_data;
|
||||
|
||||
@@ -155,17 +155,17 @@ hd_init_serial (Driver *drvthis)
|
||||
return -1;
|
||||
}
|
||||
|
||||
report (RPT_INFO,"HD44780: serial: device type: %s", SERIAL_IF.name);
|
||||
report(RPT_INFO,"HD44780: serial: device type: %s", SERIAL_IF.name);
|
||||
|
||||
/* Check if user knows the capabilities of his hardware ;-) */
|
||||
if (p->have_keypad && !(SERIAL_IF.keypad)) {
|
||||
report (RPT_ERR, "HD44780: serial: keypad is not supported by %s", SERIAL_IF.name);
|
||||
report (RPT_ERR, "HD44780: serial: check your configuration file and disable it");
|
||||
report(RPT_ERR, "HD44780: serial: keypad is not supported by %s", SERIAL_IF.name);
|
||||
report(RPT_ERR, "HD44780: serial: check your configuration file and disable it");
|
||||
return -1;
|
||||
}
|
||||
if (p->have_backlight && !(SERIAL_IF.backlight)) {
|
||||
report (RPT_ERR, "HD44780: serial: backlight control is not supported by %s", SERIAL_IF.name);
|
||||
report (RPT_ERR, "HD44780: serial: check your configuration file and disable it");
|
||||
report(RPT_ERR, "HD44780: serial: backlight control is not supported by %s", SERIAL_IF.name);
|
||||
report(RPT_ERR, "HD44780: serial: check your configuration file and disable it");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -180,12 +180,12 @@ hd_init_serial (Driver *drvthis)
|
||||
report(RPT_ERR, "HD44780: serial: invalid configured bitrate speed");
|
||||
return -1;
|
||||
}
|
||||
report (RPT_INFO,"HD44780: serial: using speed: %d", conf_bitrate);
|
||||
report(RPT_INFO,"HD44780: serial: using speed: %d", conf_bitrate);
|
||||
|
||||
/* Get serial device to use */
|
||||
strncpy(device, drvthis->config_get_string(drvthis->name, "device", 0, DEFAULT_DEVICE), sizeof(device));
|
||||
device[sizeof(device)-1] = '\0';
|
||||
report (RPT_INFO,"HD44780: serial: using device: %s", device);
|
||||
report(RPT_INFO,"HD44780: serial: using device: %s", device);
|
||||
|
||||
/* Set up io port correctly, and open it... */
|
||||
p->fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
@@ -232,7 +232,7 @@ hd_init_serial (Driver *drvthis)
|
||||
report(RPT_INFO,"HD44780: serial: initializing with 8 bits interface");
|
||||
common_init(p, IF_8BIT);
|
||||
} else {
|
||||
report (RPT_INFO,"HD44780: serial: initializing with 4 bits interface");
|
||||
report(RPT_INFO,"HD44780: serial: initializing with 4 bits interface");
|
||||
common_init(p, IF_4BIT);
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ hd_init_serial (Driver *drvthis)
|
||||
|
||||
// serial_HD44780_senddata
|
||||
void
|
||||
serial_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||
serial_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||
{
|
||||
/* Filter illegally sent escape characters (for interfaces without data escape) */
|
||||
if (flags == RS_DATA && SERIAL_IF.data_escape == 0 && ch == SERIAL_IF.instruction_escape)
|
||||
@@ -265,7 +265,7 @@ serial_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char
|
||||
}
|
||||
|
||||
void
|
||||
serial_HD44780_backlight (PrivateData *p, unsigned char state)
|
||||
serial_HD44780_backlight(PrivateData *p, unsigned char state)
|
||||
{
|
||||
unsigned char send[1];
|
||||
if (p->have_backlight) {
|
||||
@@ -284,7 +284,7 @@ serial_HD44780_backlight (PrivateData *p, unsigned char state)
|
||||
}
|
||||
|
||||
unsigned char
|
||||
serial_HD44780_scankeypad (PrivateData *p)
|
||||
serial_HD44780_scankeypad(PrivateData *p)
|
||||
{
|
||||
unsigned char buffer = 0;
|
||||
char hangcheck = 100;
|
||||
@@ -303,7 +303,7 @@ serial_HD44780_scankeypad (PrivateData *p)
|
||||
}
|
||||
|
||||
void
|
||||
serial_HD44780_close (PrivateData *p)
|
||||
serial_HD44780_close(PrivateData *p)
|
||||
{
|
||||
if (SERIAL_IF.end_code)
|
||||
write(p->fd, &SERIAL_IF.end_code, 1);
|
||||
|
||||
@@ -44,6 +44,6 @@ static const SerialInterface serial_interfaces[] = {
|
||||
};
|
||||
|
||||
/* initialize this particular driver */
|
||||
int hd_init_serial (Driver *drvthis);
|
||||
int hd_init_serial(Driver *drvthis);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -59,12 +59,12 @@
|
||||
#include <errno.h>
|
||||
|
||||
// Hardware specific functions
|
||||
void lcdserLpt_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||
void lcdserLpt_HD44780_backlight (PrivateData *p, unsigned char state);
|
||||
void lcdserLpt_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||
void lcdserLpt_HD44780_backlight(PrivateData *p, unsigned char state);
|
||||
|
||||
unsigned char lcdserLpt_HD44780_scankeypad (PrivateData *p);
|
||||
void rawshift (PrivateData *p, unsigned char r);
|
||||
void shiftreg (PrivateData *p, unsigned char displayID, unsigned char r);
|
||||
unsigned char lcdserLpt_HD44780_scankeypad(PrivateData *p);
|
||||
void rawshift(PrivateData *p, unsigned char r);
|
||||
void shiftreg(PrivateData *p, unsigned char displayID, unsigned char r);
|
||||
|
||||
#define RS 32
|
||||
#define LCDDATA 8
|
||||
@@ -74,7 +74,7 @@ void shiftreg (PrivateData *p, unsigned char displayID, unsigned char r);
|
||||
|
||||
// Initialisation
|
||||
int
|
||||
hd_init_serialLpt (Driver *drvthis)
|
||||
hd_init_serialLpt(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = (PrivateData*) drvthis->private_data;
|
||||
HD44780_functions *hd44780_functions = p->hd44780_functions;
|
||||
@@ -88,31 +88,31 @@ hd_init_serialLpt (Driver *drvthis)
|
||||
hd44780_functions->scankeypad = lcdserLpt_HD44780_scankeypad;
|
||||
|
||||
// setup the lcd in 4 bit mode
|
||||
shiftreg (p, enableLines, 3);
|
||||
hd44780_functions->uPause (p, 15000);
|
||||
shiftreg(p, enableLines, 3);
|
||||
hd44780_functions->uPause(p, 15000);
|
||||
|
||||
shiftreg (p, enableLines, 3);
|
||||
hd44780_functions->uPause (p, 5000);
|
||||
shiftreg(p, enableLines, 3);
|
||||
hd44780_functions->uPause(p, 5000);
|
||||
|
||||
shiftreg (p, enableLines, 3);
|
||||
hd44780_functions->uPause (p, 100);
|
||||
shiftreg(p, enableLines, 3);
|
||||
hd44780_functions->uPause(p, 100);
|
||||
|
||||
shiftreg (p, enableLines, 3);
|
||||
hd44780_functions->uPause (p, 100);
|
||||
shiftreg(p, enableLines, 3);
|
||||
hd44780_functions->uPause(p, 100);
|
||||
|
||||
shiftreg (p, enableLines, 2);
|
||||
hd44780_functions->uPause (p, 100);
|
||||
shiftreg(p, enableLines, 2);
|
||||
hd44780_functions->uPause(p, 100);
|
||||
|
||||
hd44780_functions->senddata (p, 0, RS_INSTR, FUNCSET | IF_4BIT | TWOLINE | SMALLCHAR);
|
||||
hd44780_functions->uPause (p, 40);
|
||||
hd44780_functions->senddata(p, 0, RS_INSTR, FUNCSET | IF_4BIT | TWOLINE | SMALLCHAR);
|
||||
hd44780_functions->uPause(p, 40);
|
||||
|
||||
common_init (p, IF_8BIT);
|
||||
common_init(p, IF_8BIT);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
lcdserLpt_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||
lcdserLpt_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||
{
|
||||
unsigned char enableLines;
|
||||
unsigned char portControl = 0;
|
||||
@@ -130,24 +130,24 @@ lcdserLpt_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned ch
|
||||
else
|
||||
portControl = 0;
|
||||
|
||||
shiftreg (p, enableLines, portControl | h);
|
||||
shiftreg (p, enableLines, portControl | l);
|
||||
shiftreg(p, enableLines, portControl | h);
|
||||
shiftreg(p, enableLines, portControl | l);
|
||||
|
||||
// Restore line status for backlight
|
||||
port_out (p->port, p->backlight_bit );
|
||||
port_out(p->port, p->backlight_bit);
|
||||
}
|
||||
|
||||
void
|
||||
lcdserLpt_HD44780_backlight (PrivateData *p, unsigned char state)
|
||||
lcdserLpt_HD44780_backlight(PrivateData *p, unsigned char state)
|
||||
{
|
||||
// Store new state
|
||||
p->backlight_bit = (state?LCDDATA:0);
|
||||
|
||||
// Set line status for backlight
|
||||
port_out (p->port, p->backlight_bit );
|
||||
port_out(p->port, p->backlight_bit);
|
||||
}
|
||||
|
||||
unsigned char lcdserLpt_HD44780_scankeypad (PrivateData *p)
|
||||
unsigned char lcdserLpt_HD44780_scankeypad(PrivateData *p)
|
||||
{
|
||||
// Unfortunately just bit shifting does not work with the 2-wire version...
|
||||
|
||||
@@ -169,14 +169,14 @@ unsigned char lcdserLpt_HD44780_scankeypad (PrivateData *p)
|
||||
// (Positioning the cursor out of screen does not work either :( )
|
||||
|
||||
// Set cursor position
|
||||
p->hd44780_functions->senddata (p, 0, RS_INSTR, POSITION | 0 );
|
||||
p->hd44780_functions->uPause (p, 40);
|
||||
p->hd44780_functions->senddata(p, 0, RS_INSTR, POSITION | 0);
|
||||
p->hd44780_functions->uPause(p, 40);
|
||||
|
||||
// Clear the shiftregister, needed for 3-wire version
|
||||
rawshift(p, 0);
|
||||
p->hd44780_functions->uPause (p, 1);
|
||||
p->hd44780_functions->uPause(p, 1);
|
||||
|
||||
readval = ~ port_in (p->port + 1) ^ INMASK;
|
||||
readval = ~ port_in(p->port + 1) ^ INMASK;
|
||||
|
||||
// And convert value back (MSB first).
|
||||
inputs_zero = (((readval & FAULT) / FAULT <<4) | /* pin 15 */
|
||||
@@ -186,24 +186,24 @@ unsigned char lcdserLpt_HD44780_scankeypad (PrivateData *p)
|
||||
((readval & ACK) / ACK )); /* pin 10 */
|
||||
|
||||
|
||||
if ( inputs_zero == 0 ) {
|
||||
if (inputs_zero == 0) {
|
||||
// No keys were pressed
|
||||
|
||||
// Restore line status for backlight.
|
||||
port_out (p->port, p->backlight_bit );
|
||||
port_out(p->port, p->backlight_bit);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Scan the keypad while sending the first half of the command (high nibble)
|
||||
for (i = 7; i >= 0; i--) { /* MSB first */
|
||||
port_out (p->port, LCDDATA); /*set up data */
|
||||
port_out (p->port, LCDDATA | LCDCLOCK); /*rising edge of clock */
|
||||
port_out(p->port, LCDDATA); /*set up data */
|
||||
port_out(p->port, LCDDATA | LCDCLOCK); /*rising edge of clock */
|
||||
|
||||
p->hd44780_functions->uPause (p, 1);
|
||||
p->hd44780_functions->uPause(p, 1);
|
||||
|
||||
if ( !scancode ) {
|
||||
if (!scancode) {
|
||||
// Read input line(s)
|
||||
readval = ~ port_in (p->port + 1) ^ INMASK;
|
||||
readval = ~ port_in(p->port + 1) ^ INMASK;
|
||||
|
||||
// And convert value back (MSB first).
|
||||
keybits = (((readval & FAULT) / FAULT <<4) | /* pin 15 */
|
||||
@@ -212,10 +212,10 @@ unsigned char lcdserLpt_HD44780_scankeypad (PrivateData *p)
|
||||
((readval & BUSY) / BUSY <<1) | /* pin 11 */
|
||||
((readval & ACK) / ACK )); /* pin 10 */
|
||||
|
||||
if ( keybits != inputs_zero ) {
|
||||
if (keybits != inputs_zero) {
|
||||
shiftingbit = 1;
|
||||
for (shiftcount=0; shiftcount<KEYPAD_MAXX && !scancode; shiftcount++) {
|
||||
if ( (keybits ^ inputs_zero ) & shiftingbit) {
|
||||
if ((keybits ^ inputs_zero) & shiftingbit) {
|
||||
// Found !
|
||||
scancode = ((8-i)<<4) | (shiftcount+1);
|
||||
}
|
||||
@@ -226,30 +226,30 @@ unsigned char lcdserLpt_HD44780_scankeypad (PrivateData *p)
|
||||
}
|
||||
|
||||
// Wait for 2-wire version to clear the latch...
|
||||
p->hd44780_functions->uPause (p, 6);
|
||||
p->hd44780_functions->uPause(p, 6);
|
||||
|
||||
// And again for the second half of the command (low nibble).
|
||||
// Needed for 2-wire version.
|
||||
rawshift (p, 0xFF);
|
||||
rawshift(p, 0xFF);
|
||||
|
||||
// Wait 6us for 2-wire version to clear the latch and wait for
|
||||
// the data to be processed
|
||||
p->hd44780_functions->uPause (p, 40);
|
||||
p->hd44780_functions->uPause(p, 40);
|
||||
|
||||
// Restore the screen state
|
||||
// Move back to home cursor position
|
||||
p->hd44780_functions->senddata (p, 0, RS_INSTR, POSITION | 0 );
|
||||
p->hd44780_functions->uPause (p, 40);
|
||||
p->hd44780_functions->senddata(p, 0, RS_INSTR, POSITION | 0);
|
||||
p->hd44780_functions->uPause(p, 40);
|
||||
|
||||
// Output the corect byte
|
||||
p->hd44780_functions->senddata (p, 1, RS_DATA,
|
||||
p->framebuf[0] );
|
||||
p->hd44780_functions->senddata(p, 1, RS_DATA,
|
||||
p->framebuf[0]);
|
||||
// ... and second display if connected ...
|
||||
if (p->numDisplays>1) {
|
||||
p->hd44780_functions->senddata (p, 2, RS_DATA,
|
||||
p->framebuf[ p->width * p->dispVOffset[2-1] ] );
|
||||
p->hd44780_functions->senddata(p, 2, RS_DATA,
|
||||
p->framebuf[ p->width * p->dispVOffset[2-1] ]);
|
||||
}
|
||||
p->hd44780_functions->uPause (p, 40);
|
||||
p->hd44780_functions->uPause(p, 40);
|
||||
|
||||
// No need to restore the line for backlight, already done by senddata.
|
||||
|
||||
@@ -258,23 +258,23 @@ unsigned char lcdserLpt_HD44780_scankeypad (PrivateData *p)
|
||||
|
||||
/* this function sends r out onto the shift register */
|
||||
void
|
||||
rawshift (PrivateData *p, unsigned char r)
|
||||
rawshift(PrivateData *p, unsigned char r)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 7; i >= 0; i--) { /* MSB first */
|
||||
port_out (p->port, ((r >> i) & 1) * LCDDATA); /*set up data */
|
||||
port_out (p->port, (((r >> i) & 1) * LCDDATA) | LCDCLOCK); /*rising edge of clock */
|
||||
port_out(p->port, ((r >> i) & 1) * LCDDATA); /*set up data */
|
||||
port_out(p->port, (((r >> i) & 1) * LCDDATA) | LCDCLOCK); /*rising edge of clock */
|
||||
}
|
||||
}
|
||||
|
||||
// enableLines = value on parallel port to toggle the correct display
|
||||
void
|
||||
shiftreg (PrivateData *p, unsigned char enableLines, unsigned char r)
|
||||
shiftreg(PrivateData *p, unsigned char enableLines, unsigned char r)
|
||||
{
|
||||
rawshift (p, r | 0x80); // highest bit always set to 1 for Clear for 2-wire version
|
||||
port_out (p->port, enableLines); // latch it, to correct display
|
||||
p->hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port, 0); // for 3-wire version
|
||||
p->hd44780_functions->uPause (p, 5); // wait for 2-wire version to clear the latch...
|
||||
rawshift(p, r | 0x80); // highest bit always set to 1 for Clear for 2-wire version
|
||||
port_out(p->port, enableLines); // latch it, to correct display
|
||||
p->hd44780_functions->uPause(p, 1);
|
||||
port_out(p->port, 0); // for 3-wire version
|
||||
p->hd44780_functions->uPause(p, 5); // wait for 2-wire version to clear the latch...
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
#include "lcd.h" /* for Driver */
|
||||
|
||||
// initialise this particular driver
|
||||
int hd_init_serialLpt (Driver *drvthis);
|
||||
int hd_init_serialLpt(Driver *drvthis);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -75,9 +75,9 @@
|
||||
// HD44780_senddata
|
||||
// HD44780_readkeypad
|
||||
|
||||
void lcdwinamp_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||
void lcdwinamp_HD44780_backlight (PrivateData *p, unsigned char state);
|
||||
unsigned char lcdwinamp_HD44780_readkeypad (PrivateData *p, unsigned int YData);
|
||||
void lcdwinamp_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||
void lcdwinamp_HD44780_backlight(PrivateData *p, unsigned char state);
|
||||
unsigned char lcdwinamp_HD44780_readkeypad(PrivateData *p, unsigned int YData);
|
||||
void lcdwinamp_HD44780_output(PrivateData *p, int data);
|
||||
|
||||
#define EN1 STRB
|
||||
@@ -92,7 +92,7 @@ static const unsigned char EnMask[] = { EN1, EN2, EN3 };
|
||||
|
||||
// initialise the driver
|
||||
int
|
||||
hd_init_winamp (Driver *drvthis)
|
||||
hd_init_winamp(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = (PrivateData*) drvthis->private_data;
|
||||
HD44780_functions *hd44780_functions = p->hd44780_functions;
|
||||
@@ -105,16 +105,16 @@ hd_init_winamp (Driver *drvthis)
|
||||
hd44780_functions->readkeypad = lcdwinamp_HD44780_readkeypad;
|
||||
|
||||
// setup the lcd in 8 bit mode
|
||||
hd44780_functions->senddata (p, 0, RS_INSTR, FUNCSET | IF_8BIT);
|
||||
hd44780_functions->uPause (p, 4100);
|
||||
hd44780_functions->senddata (p, 0, RS_INSTR, FUNCSET | IF_8BIT);
|
||||
hd44780_functions->uPause (p, 100);
|
||||
hd44780_functions->senddata(p, 0, RS_INSTR, FUNCSET | IF_8BIT);
|
||||
hd44780_functions->uPause(p, 4100);
|
||||
hd44780_functions->senddata(p, 0, RS_INSTR, FUNCSET | IF_8BIT);
|
||||
hd44780_functions->uPause(p, 100);
|
||||
|
||||
common_init (p, IF_8BIT);
|
||||
common_init(p, IF_8BIT);
|
||||
|
||||
if (p->have_keypad) {
|
||||
// Remember which input lines are stuck
|
||||
p->stuckinputs = lcdwinamp_HD44780_readkeypad (p, 0);
|
||||
p->stuckinputs = lcdwinamp_HD44780_readkeypad(p, 0);
|
||||
}
|
||||
|
||||
// Write new value to output port latches
|
||||
@@ -125,7 +125,7 @@ hd_init_winamp (Driver *drvthis)
|
||||
|
||||
// lcdwinamp_HD44780_senddata
|
||||
void
|
||||
lcdwinamp_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||
lcdwinamp_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||
{
|
||||
unsigned char enableLines = 0, portControl;
|
||||
|
||||
@@ -144,17 +144,17 @@ lcdwinamp_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned ch
|
||||
enableLines = EnMask[displayID - 1];
|
||||
|
||||
// 40 nS setup time for RS valid to EN high, so set RS
|
||||
port_out (p->port + 2, portControl ^ OUTMASK);
|
||||
port_out(p->port + 2, portControl ^ OUTMASK);
|
||||
|
||||
// Output the actual data
|
||||
port_out (p->port, ch);
|
||||
port_out(p->port, ch);
|
||||
|
||||
if ( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
if (p->delayBus) p->hd44780_functions->uPause(p, 1);
|
||||
|
||||
// then set EN high
|
||||
port_out (p->port + 2, (enableLines|portControl) ^ OUTMASK);
|
||||
port_out(p->port + 2, (enableLines|portControl) ^ OUTMASK);
|
||||
|
||||
if ( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
if (p->delayBus) p->hd44780_functions->uPause(p, 1);
|
||||
|
||||
// 80 nS setup from valid data to EN low will be met without any delay
|
||||
// unless you are running a REALLY FAST ISA bus (like 75 MHZ!)
|
||||
@@ -163,30 +163,30 @@ lcdwinamp_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned ch
|
||||
// ABOVE TEXT ignored now, using delays if delayBus is specified
|
||||
|
||||
// Set EN low and we're done...
|
||||
port_out (p->port + 2, portControl ^ OUTMASK);
|
||||
port_out(p->port + 2, portControl ^ OUTMASK);
|
||||
|
||||
// 10 nS data hold time provided by the length of ISA write for EN
|
||||
}
|
||||
|
||||
void lcdwinamp_HD44780_backlight (PrivateData *p, unsigned char state)
|
||||
void lcdwinamp_HD44780_backlight(PrivateData *p, unsigned char state)
|
||||
{
|
||||
p->backlight_bit = (state?0:nSEL);
|
||||
|
||||
port_out (p->port + 2, p->backlight_bit ^ OUTMASK);
|
||||
port_out(p->port + 2, p->backlight_bit ^ OUTMASK);
|
||||
}
|
||||
|
||||
unsigned char lcdwinamp_HD44780_readkeypad (PrivateData *p, unsigned int YData)
|
||||
unsigned char lcdwinamp_HD44780_readkeypad(PrivateData *p, unsigned int YData)
|
||||
{
|
||||
unsigned char readval;
|
||||
|
||||
// 8 bits output
|
||||
// Convert the positive logic to the negative logic on the LPT port
|
||||
port_out (p->port, ~YData & 0x00FF );
|
||||
port_out(p->port, ~YData & 0x00FF);
|
||||
|
||||
if ( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
if (p->delayBus) p->hd44780_functions->uPause(p, 1);
|
||||
|
||||
// Read inputs
|
||||
readval = ~ port_in (p->port + 1) ^ INMASK;
|
||||
readval = ~ port_in(p->port + 1) ^ INMASK;
|
||||
|
||||
// And convert value back (MSB first).
|
||||
return (((readval & FAULT) / FAULT <<4) | /* pin 15 */
|
||||
@@ -201,8 +201,8 @@ void lcdwinamp_HD44780_output(PrivateData *p, int data)
|
||||
// Setup data bus
|
||||
port_out(p->port, data);
|
||||
// Strobe the latch (374 latches on rising edge, 3/574 on trailing. No matter)
|
||||
port_out (p->port + 2, (LE | p->backlight_bit) ^ OUTMASK);
|
||||
if ( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
port_out (p->port + 2, (p->backlight_bit) ^ OUTMASK);
|
||||
if ( p->delayBus ) p->hd44780_functions->uPause (p, 1);
|
||||
port_out(p->port + 2, (LE | p->backlight_bit) ^ OUTMASK);
|
||||
if (p->delayBus) p->hd44780_functions->uPause(p, 1);
|
||||
port_out(p->port + 2, (p->backlight_bit) ^ OUTMASK);
|
||||
if (p->delayBus) p->hd44780_functions->uPause(p, 1);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
#include "lcd.h" /* for Driver */
|
||||
|
||||
// initialise this particular driver
|
||||
int hd_init_winamp (Driver *drvthis);
|
||||
int hd_init_winamp(Driver *drvthis);
|
||||
|
||||
#endif
|
||||
|
||||
+130
-126
@@ -108,10 +108,10 @@ static char *defaultKeyMapMatrix[KEYPAD_MAXY][KEYPAD_MAXX] = {
|
||||
{ NULL, NULL, NULL, NULL, NULL }};
|
||||
|
||||
// function declarations
|
||||
void HD44780_position (Driver *drvthis, int x, int y);
|
||||
static void uPause (PrivateData *p, int usecs);
|
||||
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);
|
||||
static int parse_span_list(int *spanListArray[], int *spLsize, int *dispOffsets[], int *dOffsize, int *dispSizeArray[], const char *spanlist);
|
||||
|
||||
// Vars for the server core
|
||||
MODULE_EXPORT char * api_version = API_VERSION;
|
||||
@@ -127,7 +127,7 @@ MODULE_EXPORT char *symbol_prefix = "HD44780_";
|
||||
// Opens com port and sets baud correctly...
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
HD44780_init (Driver *drvthis)
|
||||
HD44780_init(Driver *drvthis)
|
||||
{
|
||||
// TODO: remove the two magic numbers below
|
||||
// TODO: single point of return
|
||||
@@ -152,23 +152,23 @@ HD44780_init (Driver *drvthis)
|
||||
|
||||
//// READ THE CONFIG FILE
|
||||
|
||||
p->port = drvthis->config_get_int( drvthis->name, "port", 0, LPTPORT );
|
||||
p->ext_mode = drvthis->config_get_bool( drvthis->name, "extendedmode", 0, 0 );
|
||||
p->have_keypad = drvthis->config_get_bool( drvthis->name, "keypad", 0, 0 );
|
||||
p->have_backlight = drvthis->config_get_bool( drvthis->name, "backlight", 0, 0 );
|
||||
p->have_output = drvthis->config_get_bool( drvthis->name, "outputport", 0, 0 );
|
||||
p->delayMult = drvthis->config_get_int( drvthis->name, "delaymult", 0, 1 );
|
||||
p->delayBus = drvthis->config_get_bool( drvthis->name, "delaybus", 0, 1 );
|
||||
p->lastline = drvthis->config_get_bool( drvthis->name, "lastline", 0, 1 );
|
||||
p->port = drvthis->config_get_int(drvthis->name, "port", 0, LPTPORT);
|
||||
p->ext_mode = drvthis->config_get_bool(drvthis->name, "extendedmode", 0, 0);
|
||||
p->have_keypad = drvthis->config_get_bool(drvthis->name, "keypad", 0, 0);
|
||||
p->have_backlight = drvthis->config_get_bool(drvthis->name, "backlight", 0, 0);
|
||||
p->have_output = drvthis->config_get_bool(drvthis->name, "outputport", 0, 0);
|
||||
p->delayMult = drvthis->config_get_int(drvthis->name, "delaymult", 0, 1);
|
||||
p->delayBus = drvthis->config_get_bool(drvthis->name, "delaybus", 0, 1);
|
||||
p->lastline = drvthis->config_get_bool(drvthis->name, "lastline", 0, 1);
|
||||
|
||||
p->nextrefresh = 0;
|
||||
p->refreshdisplay = drvthis->config_get_int( drvthis->name, "refreshdisplay", 0, 0 );
|
||||
p->refreshdisplay = drvthis->config_get_int(drvthis->name, "refreshdisplay", 0, 0);
|
||||
p->nextkeepalive = 0;
|
||||
p->keepalivedisplay = drvthis->config_get_int( drvthis->name, "keepalivedisplay", 0, 0 );
|
||||
p->keepalivedisplay = drvthis->config_get_int(drvthis->name, "keepalivedisplay", 0, 0);
|
||||
|
||||
// Get and search for the connection type
|
||||
s = drvthis->config_get_string( drvthis->name, "ConnectionType", 0, "4bit" );
|
||||
for (i = 0; connectionMapping[i].name != NULL && strcmp (s, connectionMapping[i].name) != 0; i++);
|
||||
s = drvthis->config_get_string(drvthis->name, "ConnectionType", 0, "4bit");
|
||||
for (i = 0; connectionMapping[i].name != NULL && strcmp(s, connectionMapping[i].name) != 0; i++);
|
||||
if (connectionMapping[i].name == NULL) {
|
||||
report(RPT_ERR, "%s: unknown ConnectionType: %s", drvthis->name, s);
|
||||
return -1; // fatal error
|
||||
@@ -187,24 +187,23 @@ HD44780_init (Driver *drvthis)
|
||||
}
|
||||
|
||||
// Get and parse vspan only when specified
|
||||
s = drvthis->config_get_string( drvthis->name, "vspan", 0, "" );
|
||||
if ( s[0] != 0 ) {
|
||||
if (parse_span_list (&(p->spanList), &(p->numLines), &(p->dispVOffset), &(p->numDisplays), &(p->dispSizes), s) == -1) {
|
||||
s = drvthis->config_get_string(drvthis->name, "vspan", 0, "");
|
||||
if (s[0] != 0) {
|
||||
if (parse_span_list(&(p->spanList), &(p->numLines), &(p->dispVOffset), &(p->numDisplays), &(p->dispSizes), s) == -1) {
|
||||
report(RPT_ERR, "%s: invalid vspan value: %s", drvthis->name, s);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Get and parse size
|
||||
s = drvthis->config_get_string( drvthis->name, "size", 0, "20x4" );
|
||||
if ( sscanf( s, "%dx%d", &(p->width), &(p->height) ) != 2
|
||||
s = drvthis->config_get_string(drvthis->name, "size", 0, "20x4");
|
||||
if (sscanf(s, "%dx%d", &(p->width), &(p->height)) != 2
|
||||
|| (p->width <= 0) || (p->width > LCD_MAX_WIDTH)
|
||||
|| (p->height <= 0) || (p->height > LCD_MAX_HEIGHT)) {
|
||||
report(RPT_ERR, "%s: cannot read Size %s", drvthis->name, s);
|
||||
}
|
||||
|
||||
// default case for when spans aren't indicated
|
||||
// - add a sanity check against p->height ??
|
||||
if (p->numLines == 0) {
|
||||
if ((p->spanList = (int *) calloc(sizeof(int), p->height)) != NULL) {
|
||||
int i;
|
||||
@@ -215,6 +214,11 @@ HD44780_init (Driver *drvthis)
|
||||
} else
|
||||
report(RPT_ERR, "%s: error allocing", drvthis->name);
|
||||
}
|
||||
else {
|
||||
// sanity check against p->height
|
||||
if (p->numLines != p->height)
|
||||
report(RPT_ERR, "%s: height in Size does not match vSpan", drvthis->name);
|
||||
}
|
||||
if (p->numDisplays == 0) {
|
||||
if (((p->dispVOffset = (int *) calloc(1, sizeof(int))) != NULL) &&
|
||||
((p->dispSizes = (int *) calloc(1, sizeof(int))) != NULL)) {
|
||||
@@ -253,7 +257,7 @@ HD44780_init (Driver *drvthis)
|
||||
}
|
||||
|
||||
// Allocate and clear the buffer for incremental updates
|
||||
p->lcd_contents = (char *) calloc (p->width * p->height, sizeof(char));
|
||||
p->lcd_contents = (char *) calloc(p->width * p->height, sizeof(char));
|
||||
if (p->lcd_contents == NULL) {
|
||||
report(RPT_ERR, "%s: unable to allocate framebuffer backing store", drvthis->name);
|
||||
return -1;
|
||||
@@ -271,13 +275,13 @@ HD44780_init (Driver *drvthis)
|
||||
p->keyMapDirect[x] = defaultKeyMapDirect[x];
|
||||
|
||||
// Read config value
|
||||
sprintf( buf, "keydirect_%1d", x+1 );
|
||||
s = drvthis->config_get_string( drvthis->name, buf, 0, NULL );
|
||||
sprintf(buf, "keydirect_%1d", x+1);
|
||||
s = drvthis->config_get_string(drvthis->name, buf, 0, NULL);
|
||||
|
||||
// Was a key specified in the config file ?
|
||||
if ( s ) {
|
||||
p->keyMapDirect[x] = strdup( s );
|
||||
report(RPT_INFO, "HD44780: Direct key %d: \"%s\"", x, s );
|
||||
if (s) {
|
||||
p->keyMapDirect[x] = strdup(s);
|
||||
report(RPT_INFO, "HD44780: Direct key %d: \"%s\"", x, s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,13 +293,13 @@ HD44780_init (Driver *drvthis)
|
||||
p->keyMapMatrix[y][x] = defaultKeyMapMatrix[y][x];
|
||||
|
||||
// Read config value
|
||||
sprintf( buf, "keymatrix_%1d_%d", x+1, y+1 );
|
||||
s = drvthis->config_get_string( drvthis->name, buf, 0, NULL );
|
||||
sprintf(buf, "keymatrix_%1d_%d", x+1, y+1);
|
||||
s = drvthis->config_get_string(drvthis->name, buf, 0, NULL);
|
||||
|
||||
// Was a key specified in the config file ?
|
||||
if ( s ) {
|
||||
p->keyMapMatrix[y][x] = strdup( s );
|
||||
report(RPT_INFO, "HD44780: Matrix key %d %d: \"%s\"", x, y, s );
|
||||
if (s) {
|
||||
p->keyMapMatrix[y][x] = strdup(s);
|
||||
report(RPT_INFO, "HD44780: Matrix key %d %d: \"%s\"", x, y, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -340,34 +344,34 @@ HD44780_init (Driver *drvthis)
|
||||
return -1;
|
||||
|
||||
// Display startup parameters on the LCD
|
||||
HD44780_clear (drvthis);
|
||||
sprintf (buf, "HD44780 %dx%d", p->width, p->height );
|
||||
HD44780_string (drvthis, 1, 1, buf);
|
||||
HD44780_clear(drvthis);
|
||||
sprintf(buf, "HD44780 %dx%d", p->width, p->height);
|
||||
HD44780_string(drvthis, 1, 1, buf);
|
||||
switch(if_type) {
|
||||
case IF_TYPE_USB:
|
||||
sprintf (buf, "USB %s%s%s",
|
||||
sprintf(buf, "USB %s%s%s",
|
||||
(p->have_backlight?" bl":""),
|
||||
(p->have_keypad?" key":""),
|
||||
(p->have_output?" out":"")
|
||||
);
|
||||
break;
|
||||
case IF_TYPE_SERIAL:
|
||||
sprintf (buf, "SERIAL %s%s%s",
|
||||
sprintf(buf, "SERIAL %s%s%s",
|
||||
(p->have_backlight?" bl":""),
|
||||
(p->have_keypad?" key":""),
|
||||
(p->have_output?" out":"")
|
||||
);
|
||||
break;
|
||||
default:
|
||||
sprintf (buf, "LPT 0x%x%s%s%s", p->port,
|
||||
sprintf(buf, "LPT 0x%x%s%s%s", p->port,
|
||||
(p->have_backlight?" bl":""),
|
||||
(p->have_keypad?" key":""),
|
||||
(p->have_output?" out":"")
|
||||
);
|
||||
}
|
||||
HD44780_string (drvthis, 1, 2, buf);
|
||||
HD44780_flush (drvthis);
|
||||
sleep (2);
|
||||
HD44780_string(drvthis, 1, 2, buf);
|
||||
HD44780_flush(drvthis);
|
||||
sleep(2);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -379,32 +383,32 @@ HD44780_init (Driver *drvthis)
|
||||
// the connectiontype should do this.
|
||||
//
|
||||
void
|
||||
common_init (PrivateData *p, unsigned char if_bit)
|
||||
common_init(PrivateData *p, unsigned char if_bit)
|
||||
{
|
||||
if (p->ext_mode) {
|
||||
// Set up extended mode */
|
||||
p->hd44780_functions->senddata (p, 0, RS_INSTR, FUNCSET | if_bit | TWOLINE | SMALLCHAR | EXTREG );
|
||||
p->hd44780_functions->uPause (p, 40);
|
||||
p->hd44780_functions->senddata (p, 0, RS_INSTR, EXTMODESET | FOURLINE );
|
||||
p->hd44780_functions->uPause (p, 40);
|
||||
p->hd44780_functions->senddata(p, 0, RS_INSTR, FUNCSET | if_bit | TWOLINE | SMALLCHAR | EXTREG);
|
||||
p->hd44780_functions->uPause(p, 40);
|
||||
p->hd44780_functions->senddata(p, 0, RS_INSTR, EXTMODESET | FOURLINE);
|
||||
p->hd44780_functions->uPause(p, 40);
|
||||
}
|
||||
p->hd44780_functions->senddata (p, 0, RS_INSTR, FUNCSET | if_bit | TWOLINE | SMALLCHAR );
|
||||
p->hd44780_functions->uPause (p, 40);
|
||||
p->hd44780_functions->senddata (p, 0, RS_INSTR, ONOFFCTRL | DISPON | CURSOROFF | CURSORNOBLINK);
|
||||
p->hd44780_functions->uPause (p, 40);
|
||||
p->hd44780_functions->senddata (p, 0, RS_INSTR, CLEAR);
|
||||
p->hd44780_functions->uPause (p, 1600);
|
||||
p->hd44780_functions->senddata (p, 0, RS_INSTR, HOMECURSOR);
|
||||
p->hd44780_functions->uPause (p, 1600);
|
||||
p->hd44780_functions->senddata(p, 0, RS_INSTR, FUNCSET | if_bit | TWOLINE | SMALLCHAR);
|
||||
p->hd44780_functions->uPause(p, 40);
|
||||
p->hd44780_functions->senddata(p, 0, RS_INSTR, ONOFFCTRL | DISPON | CURSOROFF | CURSORNOBLINK);
|
||||
p->hd44780_functions->uPause(p, 40);
|
||||
p->hd44780_functions->senddata(p, 0, RS_INSTR, CLEAR);
|
||||
p->hd44780_functions->uPause(p, 1600);
|
||||
p->hd44780_functions->senddata(p, 0, RS_INSTR, HOMECURSOR);
|
||||
p->hd44780_functions->uPause(p, 1600);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Delay a number of microseconds
|
||||
//
|
||||
void
|
||||
uPause (PrivateData *p, int usecs)
|
||||
uPause(PrivateData *p, int usecs)
|
||||
{
|
||||
timing_uPause( usecs * p->delayMult );
|
||||
timing_uPause(usecs * p->delayMult);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
@@ -434,7 +438,7 @@ HD44780_close(Driver *drvthis)
|
||||
// Returns the display width
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
HD44780_width (Driver *drvthis)
|
||||
HD44780_width(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = (PrivateData *) drvthis->private_data;
|
||||
return p->width;
|
||||
@@ -444,7 +448,7 @@ HD44780_width (Driver *drvthis)
|
||||
// Returns the display height
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
HD44780_height (Driver *drvthis)
|
||||
HD44780_height(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = (PrivateData *) drvthis->private_data;
|
||||
return p->height;
|
||||
@@ -454,7 +458,7 @@ HD44780_height (Driver *drvthis)
|
||||
// Returns the display's character cell width
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
HD44780_cellwidth (Driver *drvthis)
|
||||
HD44780_cellwidth(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = (PrivateData *) drvthis->private_data;
|
||||
return p->cellwidth;
|
||||
@@ -464,7 +468,7 @@ HD44780_cellwidth (Driver *drvthis)
|
||||
// Returns the display's character cell height
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
HD44780_cellheight (Driver *drvthis)
|
||||
HD44780_cellheight(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = (PrivateData *) drvthis->private_data;
|
||||
return p->cellheight;
|
||||
@@ -475,7 +479,7 @@ HD44780_cellheight (Driver *drvthis)
|
||||
//
|
||||
// x and y here are for the virtual p->height x p->width display
|
||||
void
|
||||
HD44780_position (Driver *drvthis, int x, int y)
|
||||
HD44780_position(Driver *drvthis, int x, int y)
|
||||
{
|
||||
PrivateData *p = (PrivateData *) drvthis->private_data;
|
||||
int dispID = p->spanList[y];
|
||||
@@ -498,15 +502,15 @@ HD44780_position (Driver *drvthis, int x, int y)
|
||||
if ((relY % 4) >= 2)
|
||||
DDaddr += p->width;
|
||||
}
|
||||
p->hd44780_functions->senddata (p, dispID, RS_INSTR, POSITION | DDaddr);
|
||||
p->hd44780_functions->uPause (p, 40); // Minimum exec time for all commands
|
||||
p->hd44780_functions->senddata(p, dispID, RS_INSTR, POSITION | DDaddr);
|
||||
p->hd44780_functions->uPause(p, 40); // Minimum exec time for all commands
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Flush the framebuffer to the display
|
||||
//
|
||||
MODULE_EXPORT void
|
||||
HD44780_flush (Driver *drvthis)
|
||||
HD44780_flush(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = (PrivateData *) drvthis->private_data;
|
||||
int x, y;
|
||||
@@ -539,13 +543,13 @@ HD44780_flush (Driver *drvthis)
|
||||
drawing = 0;
|
||||
for (x = 0 ; x < wid; x++) {
|
||||
ch = p->framebuf[(y * wid) + x];
|
||||
if ( refreshNow || (x + y == 0 && keepaliveNow) || ch != p->lcd_contents[(y*wid)+x] ) {
|
||||
if ( !drawing || x % 8 == 0 ) { // x%8 is for 16x1 displays !
|
||||
if (refreshNow || (x + y == 0 && keepaliveNow) || ch != p->lcd_contents[(y*wid)+x]) {
|
||||
if (!drawing || x % 8 == 0) { // x%8 is for 16x1 displays !
|
||||
drawing = 1;
|
||||
HD44780_position(drvthis,x,y);
|
||||
}
|
||||
p->hd44780_functions->senddata (p, p->spanList[y], RS_DATA, available_charmaps[p->charmap].charmap[(unsigned char)ch]);
|
||||
p->hd44780_functions->uPause (p, 40); // Minimum exec time for all commands
|
||||
p->hd44780_functions->senddata(p, p->spanList[y], RS_DATA, available_charmaps[p->charmap].charmap[(unsigned char)ch]);
|
||||
p->hd44780_functions->uPause(p, 40); // Minimum exec time for all commands
|
||||
p->lcd_contents[(y*wid)+x] = ch;
|
||||
count++;
|
||||
}
|
||||
@@ -554,7 +558,7 @@ HD44780_flush (Driver *drvthis)
|
||||
}
|
||||
}
|
||||
}
|
||||
debug(RPT_DEBUG, "HD44780: flushed %d chars", count );
|
||||
debug(RPT_DEBUG, "HD44780: flushed %d chars", count);
|
||||
|
||||
/* Check which defineable chars we need to update */
|
||||
count = 0;
|
||||
@@ -562,13 +566,13 @@ HD44780_flush (Driver *drvthis)
|
||||
if (!p->cc[i].clean) {
|
||||
|
||||
/* Tell the HD44780 we will redefine char number i */
|
||||
p->hd44780_functions->senddata (p, 0, RS_INSTR, SETCHAR | i * 8);
|
||||
p->hd44780_functions->uPause (p, 40); // Minimum exec time for all commands
|
||||
p->hd44780_functions->senddata(p, 0, RS_INSTR, SETCHAR | i * 8);
|
||||
p->hd44780_functions->uPause(p, 40); // Minimum exec time for all commands
|
||||
|
||||
/* Send the subsequent rows */
|
||||
for (row = 0; row < p->cellheight; row++) {
|
||||
p->hd44780_functions->senddata (p, 0, RS_DATA, p->cc[i].cache[row]);
|
||||
p->hd44780_functions->uPause (p, 40); /* Minimum exec time for all commands */
|
||||
p->hd44780_functions->senddata(p, 0, RS_DATA, p->cc[i].cache[row]);
|
||||
p->hd44780_functions->uPause(p, 40); /* Minimum exec time for all commands */
|
||||
}
|
||||
p->cc[i].clean = 1; /* mark as clean */
|
||||
count++;
|
||||
@@ -581,7 +585,7 @@ HD44780_flush (Driver *drvthis)
|
||||
// Clear the framebuffer
|
||||
//
|
||||
MODULE_EXPORT void
|
||||
HD44780_clear (Driver *drvthis)
|
||||
HD44780_clear(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p = (PrivateData *) drvthis->private_data;
|
||||
memset(p->framebuf, ' ', p->width * p->height);
|
||||
@@ -592,21 +596,21 @@ HD44780_clear (Driver *drvthis)
|
||||
// Place a character in the framebuffer
|
||||
//
|
||||
MODULE_EXPORT void
|
||||
HD44780_chr (Driver *drvthis, int x, int y, char ch)
|
||||
HD44780_chr(Driver *drvthis, int x, int y, char ch)
|
||||
{
|
||||
PrivateData *p = (PrivateData *) drvthis->private_data;
|
||||
y--;
|
||||
x--;
|
||||
|
||||
if ((x >= 0) && (y >= 0) && (x < p->width) && (y < p->height))
|
||||
p->framebuf[ (y * p->width) + x] = ch;
|
||||
p->framebuf[(y * p->width) + x] = ch;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Place a string in the framebuffer
|
||||
//
|
||||
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[])
|
||||
{
|
||||
PrivateData *p = (PrivateData *) drvthis->private_data;
|
||||
int i;
|
||||
@@ -627,7 +631,7 @@ HD44780_string (Driver *drvthis, int x, int y, const char string[])
|
||||
// Sets the backlight on or off
|
||||
//
|
||||
MODULE_EXPORT void
|
||||
HD44780_backlight (Driver *drvthis, int on)
|
||||
HD44780_backlight(Driver *drvthis, int on)
|
||||
{
|
||||
PrivateData *p = (PrivateData *) drvthis->private_data;
|
||||
p->hd44780_functions->backlight (p, on);
|
||||
@@ -637,7 +641,7 @@ HD44780_backlight (Driver *drvthis, int on)
|
||||
// Draws a vertical bar...
|
||||
//
|
||||
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)
|
||||
{
|
||||
PrivateData *p = (PrivateData *) drvthis->private_data;
|
||||
|
||||
@@ -676,7 +680,7 @@ HD44780_vbar (Driver *drvthis, int x, int y, int len, int promille, int options)
|
||||
// Draws a horizontal bar to the right.
|
||||
//
|
||||
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)
|
||||
{
|
||||
PrivateData *p = (PrivateData *) drvthis->private_data;
|
||||
|
||||
@@ -715,7 +719,7 @@ HD44780_hbar (Driver *drvthis, int x, int y, int len, int promille, int options)
|
||||
// Writes a big number.
|
||||
//
|
||||
MODULE_EXPORT void
|
||||
HD44780_num (Driver *drvthis, int x, int num)
|
||||
HD44780_num(Driver *drvthis, int x, int num)
|
||||
{
|
||||
PrivateData *p = (PrivateData *) drvthis->private_data;
|
||||
int do_init = 0;
|
||||
@@ -763,7 +767,7 @@ HD44780_get_free_chars(Driver *drvthis)
|
||||
// The input is just an array of characters...
|
||||
//
|
||||
MODULE_EXPORT void
|
||||
HD44780_set_char (Driver *drvthis, int n, unsigned char *dat)
|
||||
HD44780_set_char(Driver *drvthis, int n, unsigned char *dat)
|
||||
{
|
||||
PrivateData *p = (PrivateData *) drvthis->private_data;
|
||||
unsigned char mask = (1 << p->cellwidth) - 1;
|
||||
@@ -790,7 +794,7 @@ HD44780_set_char (Driver *drvthis, int n, unsigned char *dat)
|
||||
// Set default icon into a userdef char
|
||||
//
|
||||
MODULE_EXPORT int
|
||||
HD44780_icon (Driver *drvthis, int x, int y, int icon)
|
||||
HD44780_icon(Driver *drvthis, int x, int y, int icon)
|
||||
{
|
||||
static unsigned char heart_open[] =
|
||||
{ b__XXXXX,
|
||||
@@ -915,44 +919,44 @@ HD44780_icon (Driver *drvthis, int x, int y, int icon)
|
||||
b__XXXXX };
|
||||
|
||||
/* Yes I know, this is a VERY BAD implementation */
|
||||
switch ( icon ) {
|
||||
switch (icon) {
|
||||
case ICON_BLOCK_FILLED:
|
||||
HD44780_set_char( drvthis, 6, block_filled );
|
||||
HD44780_chr( drvthis, x, y, 6);
|
||||
HD44780_set_char(drvthis, 6, block_filled);
|
||||
HD44780_chr(drvthis, x, y, 6);
|
||||
break;
|
||||
case ICON_HEART_FILLED:
|
||||
HD44780_set_char( drvthis, 0, heart_filled );
|
||||
HD44780_chr( drvthis, x, y, 0 );
|
||||
HD44780_set_char(drvthis, 0, heart_filled);
|
||||
HD44780_chr(drvthis, x, y, 0);
|
||||
break;
|
||||
case ICON_HEART_OPEN:
|
||||
HD44780_set_char( drvthis, 0, heart_open );
|
||||
HD44780_chr( drvthis, x, y, 0 );
|
||||
HD44780_set_char(drvthis, 0, heart_open);
|
||||
HD44780_chr(drvthis, x, y, 0);
|
||||
break;
|
||||
case ICON_ARROW_UP:
|
||||
HD44780_set_char( drvthis, 1, arrow_up );
|
||||
HD44780_chr( drvthis, x, y, 1 );
|
||||
HD44780_set_char(drvthis, 1, arrow_up);
|
||||
HD44780_chr(drvthis, x, y, 1);
|
||||
break;
|
||||
case ICON_ARROW_DOWN:
|
||||
HD44780_set_char( drvthis, 2, arrow_down );
|
||||
HD44780_chr( drvthis, x, y, 2 );
|
||||
HD44780_set_char(drvthis, 2, arrow_down);
|
||||
HD44780_chr(drvthis, x, y, 2);
|
||||
break;
|
||||
case ICON_ARROW_LEFT:
|
||||
HD44780_chr( drvthis, x, y, 0x7F );
|
||||
HD44780_chr(drvthis, x, y, 0x7F);
|
||||
break;
|
||||
case ICON_ARROW_RIGHT:
|
||||
HD44780_chr( drvthis, x, y, 0x7E );
|
||||
HD44780_chr(drvthis, x, y, 0x7E);
|
||||
break;
|
||||
case ICON_CHECKBOX_OFF:
|
||||
HD44780_set_char( drvthis, 3, checkbox_off );
|
||||
HD44780_chr( drvthis, x, y, 3 );
|
||||
HD44780_set_char(drvthis, 3, checkbox_off);
|
||||
HD44780_chr(drvthis, x, y, 3);
|
||||
break;
|
||||
case ICON_CHECKBOX_ON:
|
||||
HD44780_set_char( drvthis, 4, checkbox_on );
|
||||
HD44780_chr( drvthis, x, y, 4 );
|
||||
HD44780_set_char(drvthis, 4, checkbox_on);
|
||||
HD44780_chr(drvthis, x, y, 4);
|
||||
break;
|
||||
case ICON_CHECKBOX_GRAY:
|
||||
HD44780_set_char( drvthis, 5, checkbox_gray );
|
||||
HD44780_chr( drvthis, x, y, 5 );
|
||||
HD44780_set_char(drvthis, 5, checkbox_gray);
|
||||
HD44780_chr(drvthis, x, y, 5);
|
||||
break;
|
||||
default:
|
||||
return -1; /* Let the core do other icons */
|
||||
@@ -971,13 +975,13 @@ HD44780_get_key(Driver *drvthis)
|
||||
char * keystr = NULL;
|
||||
struct timeval curr_time, time_diff;
|
||||
|
||||
if ( ! p->have_keypad ) return NULL;
|
||||
if (!p->have_keypad) return NULL;
|
||||
|
||||
gettimeofday(&curr_time,NULL);
|
||||
gettimeofday(&curr_time, NULL);
|
||||
|
||||
scancode = p->hd44780_functions->scankeypad(p);
|
||||
if ( scancode ) {
|
||||
if ( scancode & 0xF0 ) {
|
||||
if (scancode) {
|
||||
if (scancode & 0xF0) {
|
||||
keystr = p->keyMapMatrix[((scancode&0xF0)>>4)-1][(scancode&0x0F)-1];
|
||||
}
|
||||
else {
|
||||
@@ -985,10 +989,10 @@ HD44780_get_key(Driver *drvthis)
|
||||
}
|
||||
}
|
||||
|
||||
if ( keystr != NULL ) {
|
||||
if (keystr != NULL) {
|
||||
if (keystr == p->pressed_key) {
|
||||
timersub (&curr_time, &(p->pressed_key_time), &time_diff);
|
||||
if (((time_diff.tv_usec / 1000 + time_diff.tv_sec * 1000) - KEYPAD_AUTOREPEAT_DELAY) < 1000 * p->pressed_key_repetitions / KEYPAD_AUTOREPEAT_FREQ ) {
|
||||
timersub(&curr_time, &(p->pressed_key_time), &time_diff);
|
||||
if (((time_diff.tv_usec / 1000 + time_diff.tv_sec * 1000) - KEYPAD_AUTOREPEAT_DELAY) < 1000 * p->pressed_key_repetitions / KEYPAD_AUTOREPEAT_FREQ) {
|
||||
// The key is already pressed quite some time
|
||||
// but it's not yet time to return a repeated keypress
|
||||
return NULL;
|
||||
@@ -1001,7 +1005,7 @@ HD44780_get_key(Driver *drvthis)
|
||||
p->pressed_key_time = curr_time;
|
||||
p->pressed_key_repetitions = 0;
|
||||
report(RPT_INFO, "HD44780_get_key: Key pressed: %s (%d,%d)",
|
||||
keystr, scancode&0x0F, (scancode&0xF0)>>4 );
|
||||
keystr, scancode&0x0F, (scancode&0xF0)>>4);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1027,14 +1031,14 @@ unsigned char HD44780_scankeypad(PrivateData *p)
|
||||
|
||||
// First check if a directly connected key is pressed
|
||||
// Put all zeros on Y of keypad
|
||||
keybits = p->hd44780_functions->readkeypad (p, 0);
|
||||
keybits = p->hd44780_functions->readkeypad(p, 0);
|
||||
|
||||
if (keybits) {
|
||||
// A directly connected key was pressed
|
||||
// Which key was it ?
|
||||
shiftingbit = 1;
|
||||
for (shiftcount=0; shiftcount<KEYPAD_MAXX && !scancode; shiftcount++) {
|
||||
if ( keybits & shiftingbit) {
|
||||
for (shiftcount = 0; shiftcount < KEYPAD_MAXX && !scancode; shiftcount++) {
|
||||
if (keybits & shiftingbit) {
|
||||
// Found ! Return from function.
|
||||
scancode = shiftcount+1;
|
||||
}
|
||||
@@ -1045,7 +1049,7 @@ unsigned char HD44780_scankeypad(PrivateData *p)
|
||||
// Now check the matrix
|
||||
// First check with all 1's
|
||||
Ypattern = (1 << KEYPAD_MAXY) - 1;
|
||||
if ( p->hd44780_functions->readkeypad (p, Ypattern)) {
|
||||
if (p->hd44780_functions->readkeypad(p, Ypattern)) {
|
||||
// Yes, a key on the matrix is pressed
|
||||
|
||||
// OK, now we know a key is pressed.
|
||||
@@ -1057,17 +1061,17 @@ unsigned char HD44780_scankeypad(PrivateData *p)
|
||||
Yval = 0;
|
||||
for (exp=3; exp>=0; exp--) {
|
||||
Ypattern = ((1 << (1 << exp)) - 1) << Yval;
|
||||
keybits = p->hd44780_functions->readkeypad (p, Ypattern);
|
||||
keybits = p->hd44780_functions->readkeypad(p, Ypattern);
|
||||
if (!keybits) {
|
||||
Yval += (1 << exp);
|
||||
}
|
||||
}
|
||||
|
||||
// Which key is pressed in that row ?
|
||||
keybits = p->hd44780_functions->readkeypad (p, 1<<Yval);
|
||||
shiftingbit=1;
|
||||
for (shiftcount=0; shiftcount<KEYPAD_MAXX && !scancode; shiftcount++) {
|
||||
if ( keybits & shiftingbit) {
|
||||
keybits = p->hd44780_functions->readkeypad(p, 1<<Yval);
|
||||
shiftingbit = 1;
|
||||
for (shiftcount = 0; shiftcount < KEYPAD_MAXX && !scancode; shiftcount++) {
|
||||
if (keybits & shiftingbit) {
|
||||
// Found !
|
||||
scancode = (Yval+1) << 4 | (shiftcount+1);
|
||||
}
|
||||
@@ -1083,7 +1087,7 @@ unsigned char HD44780_scankeypad(PrivateData *p)
|
||||
// Output to the optional output latch(es)
|
||||
//
|
||||
MODULE_EXPORT void
|
||||
HD44780_output (Driver *drvthis, int on)
|
||||
HD44780_output(Driver *drvthis, int on)
|
||||
{
|
||||
PrivateData *p = drvthis->private_data;
|
||||
|
||||
@@ -1112,22 +1116,22 @@ HD44780_output (Driver *drvthis, int on)
|
||||
// returns number of span elements, -1 on parse error
|
||||
|
||||
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)
|
||||
{
|
||||
int j = 0, retVal = 0;
|
||||
|
||||
*spLsize = 0;
|
||||
*dOffsize = 0;
|
||||
|
||||
while (j < strlen (spanlist)) {
|
||||
while (j < strlen(spanlist)) {
|
||||
if (spanlist[j] >= '1' && spanlist[j] <= '9') {
|
||||
int spansize = spanlist[j] - '0';
|
||||
|
||||
// add spansize lines to the span list, note the offset to
|
||||
// the previous display and the size of the display
|
||||
if ((*spanListArray = (int *) realloc (*spanListArray, sizeof (int) * (*spLsize + spansize)))
|
||||
&& (*dispOffsets = (int *) realloc (*dispOffsets, sizeof (int) * (*dOffsize + 1)))
|
||||
&& (*dispSizeArray = (int *) realloc (*dispSizeArray, sizeof (int) * (*dOffsize + 1)))) {
|
||||
if ((*spanListArray = (int *) realloc(*spanListArray, sizeof(int) * (*spLsize + spansize)))
|
||||
&& (*dispOffsets = (int *) realloc(*dispOffsets, sizeof(int) * (*dOffsize + 1)))
|
||||
&& (*dispSizeArray = (int *) realloc(*dispSizeArray, sizeof(int) * (*dOffsize + 1)))) {
|
||||
int k;
|
||||
for (k = 0; k < spansize; ++k)
|
||||
(*spanListArray)[*spLsize + k] = *dOffsize + 1;
|
||||
|
||||
+18
-18
@@ -18,28 +18,28 @@
|
||||
|
||||
#include "lcd.h"
|
||||
|
||||
MODULE_EXPORT int HD44780_init (Driver *drvthis);
|
||||
MODULE_EXPORT void HD44780_close (Driver *drvthis);
|
||||
MODULE_EXPORT int HD44780_width (Driver *drvthis);
|
||||
MODULE_EXPORT int HD44780_height (Driver *drvthis);
|
||||
MODULE_EXPORT int HD44780_cellwidth (Driver *drvthis);
|
||||
MODULE_EXPORT int HD44780_cellheight (Driver *drvthis);
|
||||
MODULE_EXPORT void HD44780_clear (Driver *drvthis);
|
||||
MODULE_EXPORT void HD44780_flush (Driver *drvthis);
|
||||
MODULE_EXPORT void HD44780_string (Driver *drvthis, int x, int y, const char s[]);
|
||||
MODULE_EXPORT void HD44780_chr (Driver *drvthis, int x, int y, char ch);
|
||||
MODULE_EXPORT int HD44780_init(Driver *drvthis);
|
||||
MODULE_EXPORT void HD44780_close(Driver *drvthis);
|
||||
MODULE_EXPORT int HD44780_width(Driver *drvthis);
|
||||
MODULE_EXPORT int HD44780_height(Driver *drvthis);
|
||||
MODULE_EXPORT int HD44780_cellwidth(Driver *drvthis);
|
||||
MODULE_EXPORT int HD44780_cellheight(Driver *drvthis);
|
||||
MODULE_EXPORT void HD44780_clear(Driver *drvthis);
|
||||
MODULE_EXPORT void HD44780_flush(Driver *drvthis);
|
||||
MODULE_EXPORT void HD44780_string(Driver *drvthis, int x, int y, const char s[]);
|
||||
MODULE_EXPORT void HD44780_chr(Driver *drvthis, int x, int y, char ch);
|
||||
|
||||
MODULE_EXPORT void HD44780_vbar (Driver *drvthis, int x, int y, int len, int promille, int options);
|
||||
MODULE_EXPORT void HD44780_hbar (Driver *drvthis, int x, int y, int len, int promille, int options);
|
||||
MODULE_EXPORT void HD44780_num (Driver *drvthis, int x, int num);
|
||||
MODULE_EXPORT int HD44780_icon (Driver *drvthis, int x, int y, int icon);
|
||||
MODULE_EXPORT void HD44780_vbar(Driver *drvthis, int x, int y, int len, int promille, int options);
|
||||
MODULE_EXPORT void HD44780_hbar(Driver *drvthis, int x, int y, int len, int promille, int options);
|
||||
MODULE_EXPORT void HD44780_num(Driver *drvthis, int x, int num);
|
||||
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 void HD44780_backlight (Driver *drvthis, int on);
|
||||
MODULE_EXPORT void HD44780_output (Driver *drvthis, int state);
|
||||
MODULE_EXPORT void HD44780_backlight(Driver *drvthis, int on);
|
||||
MODULE_EXPORT void HD44780_output(Driver *drvthis, int state);
|
||||
|
||||
MODULE_EXPORT const char * HD44780_get_key (Driver *drvthis);
|
||||
MODULE_EXPORT const char *HD44780_get_key(Driver *drvthis);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user