[Lcdproc] [patch] Hitachi SP14Q002 added to sed1330 driver
Benjamin Wiedmann
benjamin.wiedmann@gmx.net
Sun Dec 31 21:31:01 2006
This is a multi-part message in MIME format.
--------------000003020601080908020708
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160
Peter Marschall wrote:
> Hi,
>
> On Friday, 29. December 2006 14:37, Benjamin Wiedmann wrote:
>> Hi,
>>
>> attached is the patch to add functionality for the hitachi sp14q002
>> (b/w) display with a resolution of 320 x 240 (w x h) dots.
>>
>> If possible it would be very nice if you can take this patch and put it
>> into the lcdproc source tree so it is usable by anybody without the need
>> to do the patching work first.
>
> Added to CSV with one slight change:
Thank you, that was pretty fast.
> WIRING_BITSHAKER is not defined by default to not break
> the build for other users that expect the "classic" connection type.
>
Ah, okay, but it shouldn't be a problem for users that not have defined
WIRING_BITSHAKER, as in those cases the default wiring scheme code would
be chosen by the preprocessor.
> You can easily define it at compile time by
> CPPFLAGS=-DWIRING_BITSHAKER ./configure ....
>
> If you feel inclined to hack a bit more on the code,
> you may convert this build time -define into a run-time configuration.
> Simply:
> - convert the defines for A0, nRESET, nWR into variables
> of the PrivateData structure
> - get ConnectionType from config file
> see hd44780 how to do it
> - set p->A0, p->nRESET, p->nWR according to the connection type
> - change the code that uses A0, nRESET, nWR
> to p->A0, p->nRESET, p->nWR
>
I had some spare time, see attachment :-). You can now specify the
scheme to use by having parameter "ConnectionType" in driver section of
sed1330 set. Valid wirings: classic, bitshaker. If not set it defaults
to classic so there won't be any incompatibilities on user side...
What about describing these new options/parameters in the manual? Where
to do that?
>
>> Apply the patch as following:
>>
>> $ patch -i sed1330.c.diff sed1330.c
> Please send in unified diffs (created by diff -u) next time.
Uhh, sorry. I missed that.
> They are easier to apply as they contain the names of the file to patch
> They even may contain patches for more than one file
>
>
> Thanks for helping LCDproc
> Peter
>
Thanks for providing lcdproc!
Happy new year & ciao,
Benjamin
- --
Windows: Designed for the Internet
The Internet: Designed for UN*X
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6-ecc01.6 (GNU/Linux)
iQCVAwUBRZgr1NdDWs1pp/7kAQNuoAP/X7JTIlhox2OrP2P+hlCl0Us9HOvoDrIr
/1mLb1mw3u2V2vqItzAxneDLcK4UuhK8Fh3vkXAL0dstp/CERXNf6x9pFIWNB/R/
tz0IgvPYbV1HB++rIZYjjnrXD6/0LXl0T1PRrcD1wIoLJOFv1z9CsT2Y7nKuUOMy
o3KUeAi/daA=
=+rDm
-----END PGP SIGNATURE-----
--------------000003020601080908020708
Content-Type: text/x-patch;
name="sed1330.c.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="sed1330.c.patch"
--- lcdproc/server/drivers/sed1330.c 2006-12-31 22:25:04.974440168 +0100
+++ lcdproc_hack/server/drivers/sed1330.c 2006-12-31 22:26:32.053202184 +0100
@@ -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 @@
struct timeval pressed_key_time;
int stuckinputs;
-
} PrivateData;
static char *defaultKeyMapDirect[KEYPAD_MAXX] = { "Enter", "Up", "Down", "Escape", "F1" };
@@ -422,6 +413,33 @@
}
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 @@
// 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 @@
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
}
}
--------------000003020601080908020708--