configuration option ConnectionType for sed1330 (Benjamin Wiedmann)

This commit is contained in:
marschap
2007-01-01 16:00:58 +00:00
parent df7700662d
commit 92d099fb28
5 changed files with 153 additions and 54 deletions
+61 -43
View File
@@ -47,9 +47,14 @@
* - built for parport version of this interface: Wallbraun Electronics lcdinterface
* (specifications here: http://wallbraun-electronics.de/produkte/lcdinterface/index.html)
* - wiring scheme used: "bitshaker" (called "yasedw" in serdisplib)
* --> default wiring: wr=16; a0=17; rd=01; cs=14
* --> yasedw wiring: wr=01; a0=14; rd=16; cs=17
*
* --> classic wiring: wr=16; a0=17; rd=01; cs=14
* --> bitshaker wiring: wr=01; a0=14; rd=16; cs=17
* December 2006, Benjamin Wiedmann (additional changes, fixup)
* - wiring scheme can now be changed at run time using "ConnectionType" config parameter
* in sed1330 driver section
* Usage of ConnectionType in LCDd.conf:
* ConnectionType=<classic|bitshaker>
* - if no ConnectionType is set it defaults to "classic" wiring
*
* IMPORTANT: MODULES OTHER THAN G321D
* ===================================
@@ -187,6 +192,11 @@
* type=G191D
* type=G2446
* type=SP14Q002
*
* You can also change the wiring scheme by using the ConnectionType= option:
* ConnectionType=<classic|bitshaker>
* If not set, classic wiring is used.
*
* The port= value should be set to the LPT port address that the LCD is
* connected to. Examples:
* port=0x378
@@ -218,35 +228,6 @@
#define KEYPAD_AUTOREPEAT_DELAY 500
#define KEYPAD_AUTOREPEAT_FREQ 15
// LPT lines
// should we use the bitshaker wiring?
//#define WIRING_BITSHAKER
#ifdef WIRING_BITSHAKER
// use BITSHAKER / YASEDW wiring
// pin 14
#define A0 nLF
// pin 16
#define nRESET INIT
// pin 1
#define nWR STRB
#else
// use default wiring
// pin 17
#define A0 SEL
// pin 1
#define nRESET STRB
// pin 16
#define nWR INIT
#endif
// Command definitions
#define CMD_SYSTEM_SET 0x40
#define CMD_SLEEP_IN 0x53
@@ -283,12 +264,23 @@
#define SCR2_H 0x06
typedef struct p {
// display type
int type;
// wiring scheme variables to be set by sed1330_init()
int A0;
int nRESET;
int nWR;
// which lpt port to use
int port;
unsigned char * framebuf_text;
unsigned char * lcd_contents_text;
unsigned char * framebuf_graph;
unsigned char * lcd_contents_graph;
int width, height;
int cellwidth, cellheight;
int graph_width, graph_height;
@@ -309,7 +301,6 @@ typedef struct p {
struct timeval pressed_key_time;
int stuckinputs;
} PrivateData;
static char *defaultKeyMapDirect[KEYPAD_MAXX] = { "Enter", "Up", "Down", "Escape", "F1" };
@@ -422,6 +413,33 @@ sed1330_init( Driver * drvthis )
}
report(RPT_INFO, "%s: Using LCD type %s", drvthis->name, s);
// Set wiring scheme to be used
//
// Valid ConnectionTypes:
// - classic (default)
// - bitshaker
//
// Get ConnectionType, if no type is set, default to "classic" wiring so it even
// works with config files missing that ConnectionType entry in sed1330 driver section
s = drvthis->config_get_string(drvthis->name, "ConnectionType", 0, "classic");
// Set wiring initialization parameters based on ConnectionType
if (strcmp(s, "classic") == 0) {
// Use classic wiring
p->A0 = SEL; // port 17
p->nRESET = STRB; // port 1
p->nWR = INIT; // port 16
} else if(strcmp(s, "bitshaker") == 0) {
// Use bitshaker wiring
p->A0 = nLF; // port 14
p->nRESET = INIT; // port 16
p->nWR = STRB; // port 1
} else {
report(RPT_ERR, "%s: Unknown ConnectionType %s", drvthis->name, s);
return -1;
}
report(RPT_INFO, "%s: Using ConnectionType %s", drvthis->name, s);
// Keypad ?
p->have_keypad = drvthis->config_get_bool(drvthis->name, "keypad", 0, 0);
@@ -523,12 +541,12 @@ sed1330_init( Driver * drvthis )
// INITIALIZE THE LCD
// End reset-state
debug(RPT_DEBUG, "%s: initializing LCD", __FUNCTION__);
port_out(p->port+2, (nWR) ^ OUTMASK); // raise ^RD and ^WR
port_out(p->port+2, (nRESET|nWR) ^ OUTMASK); // lower RESET
port_out(p->port+2, (p->nWR) ^ OUTMASK); // raise ^RD and ^WR
port_out(p->port+2, (p->nRESET|p->nWR) ^ OUTMASK); // lower RESET
uPause(200);
port_out(p->port+2, (nWR) ^ OUTMASK); // raise RESET
port_out(p->port+2, (p->nWR) ^ OUTMASK); // raise RESET
uPause(200);
port_out(p->port+2, (nRESET|nWR) ^ OUTMASK); // lower RESET
port_out(p->port+2, (p->nRESET|p->nWR) ^ OUTMASK); // lower RESET
uPause(4000);
switch (p->type) {
@@ -596,16 +614,16 @@ sed1330_command( PrivateData * p, char command, int datacount, unsigned char * d
int i;
int port = p->port;
port_out(port+2, (nRESET|nWR|A0) ^ OUTMASK); // set A0 to indicate command
port_out(port+2, (p->nRESET|p->nWR|p->A0) ^ OUTMASK); // set A0 to indicate command
port_out(port, command); // set up p
port_out(port+2, (nRESET|A0) ^ OUTMASK); // activate ^WR
port_out(port+2, (nRESET|nWR|A0) ^ OUTMASK); // deactivate ^WR again
port_out(port+2, (nRESET|nWR) ^ OUTMASK); // clear A0 to indicate p
port_out(port+2, (p->nRESET|p->A0) ^ OUTMASK); // activate ^WR
port_out(port+2, (p->nRESET|p->nWR|p->A0) ^ OUTMASK); // deactivate ^WR again
port_out(port+2, (p->nRESET|p->nWR) ^ OUTMASK); // clear A0 to indicate p
for (i = 0; i < datacount; i++) {
port_out(port, data[i]); // set up data
port_out(port+2, (nRESET) ^ OUTMASK); // activate ^WR
port_out(port+2, (nRESET|nWR) ^ OUTMASK); // deactivate ^WR again
port_out(port+2, (p->nRESET) ^ OUTMASK); // activate ^WR
port_out(port+2, (p->nRESET|p->nWR) ^ OUTMASK); // deactivate ^WR again
}
}