[Lcdproc] Re: help w/ hd44780 driver to support hd66712

Andrew Foss a.foss@f5.com
Sat May 6 01:49:01 2006


This is a multi-part message in MIME format.
--------------040000010604060509080203
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

lcdproc folks,

I've proposed the following for hd66712 in the attached patchfile to the 
0.5.0 release, though I've just built Andreas will need to test it.

Added to the LCDd.conf to enable hd66712 simplified RAM layout mode.
[hd44780] section

#HD66712=yes

I've modified the drivers PrivateData char ext_mode to be just mode and 
used as flags, where
EXT_MODE 1     enable the ext_mode linear addressing function
HD66712 2         to enable the hd66712 simplified RAM layout


Not sure if this is the best or an ok way, comments welcome, pending 
Andreas's word that it works.

thanks,
andrew

Andrew Foss wrote:
> lcdproc folks,
>
> anyone familiar w/ the hd44780 driver that could help point me toward 
> the best way to integrate patch and configuration to support hd66712?
>
> Attached is a test patchfile w/ #ifdef to force hd66712. Andreas is 
> testing to confirm that this works.
>
> It's essentially the hd44780 driver w/ a 2 line change to 
> hd44780_position() accommodate the hd66712's cleaner memory layout. 
> The question is how best to indicate hd66712 capability to the hd44780 
> driver?
>
> I'm thinking add an [hd66712] to the config file, referencing the 
> hd44780 driver w/ some flag to indicate it's an hd66712 for the right 
> mem layout.
>
> thanks in advance,
>
> andrew
>
> -------- Original Message --------
> Subject:     AW: [Lcdproc] Screen->Client List has timeout->-1
> Date:     Sat, 6 May 2006 01:06:45 +0200
> From:     Andreas <Andreaz@t-online.de>
> Reply-To:     <Andreaz@t-online.de>
> To:     'Andrew Foss' <a.foss@f5.com>
>
>
>
> Hello Andrew (again),
>
> sorry, the last mail is a failure.
> It's a lot more working than before...
>
> I forget to break the lcd4linux instance
> and mixed it together with lcdproc.
>
> For the first view it seems to be working.
> Output is fixed i believe. Let me test
> some more.
>
> For implement this. Wouldnt be an arg
> in the config file like "Model=hd66712"
> make sense? Or a complete new driver,
> with that name ?
>
> So far, seems to work... Ill test some
> more..
>
> Great work, Andrew !
>
> Thanks alot...
>
>
> -----Ursprüngliche Nachricht-----
> Von: Andrew Foss [mailto:a.foss@f5.com]
> Gesendet: Samstag, 6. Mai 2006 00:01
> An: Andreaz@t-online.de
> Betreff: Re: AW: AW: AW: [Lcdproc] Screen->Client List has timeout->-1
>
>
> Andreas,
>
> can you try the attached patch and see what it does? It will break a
> normal hd44780, but I'd like to see if this is what the hd66712 needs
> first, then we can figure out how to integrate it for real.
>
> If you're not familiar w/ patch and assuming this patchfile is in your ~
> directory, then
>
> cd lcdproc-0.5.0/server/drivers
> patch < ~/lcdprochd66712.testpatch
>
> then make clean;make
>
> replace the hd 44780 drivers on your system w/ these shouldn't need to
> touch the rest and let me know...
>
> andrew
>
> Andreas wrote:
>> I would love to test it out...
>>
>> Afternoon? Where you from? Here its already
>> late evening.. ;)
>>
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Andrew Foss [mailto:a.foss@f5.com]
>> Gesendet: Donnerstag, 4. Mai 2006 21:26
>> An: Andreaz@t-online.de
>> Betreff: Re: AW: AW: [Lcdproc] Screen->Client List has timeout->-1
>>
>>
>> that should get us going, if I have a moment this afternoon, I'll try a
>> test driver version that will just do the simple flush and senddata w/o
>> all the special cases and see if we don't learn something from that...
>>
>> Andreas wrote:
>>
>>> Just the driver code or the whole package?
>>> I start with just the driver...
>>>
>>> Attached...
>>>
>>> Thank you alot for your help!
>>>
>>> -----Ursprüngliche Nachricht-----
>>> *Von:* Andrew Foss [mailto:A.Foss@F5.com]
>>> *Gesendet:* Donnerstag, 4. Mai 2006 20:26
>>> *An:* Andreaz@t-online.de
>>> *Betreff:* RE: AW: [Lcdproc] Screen->Client List has timeout->-1
>>>
>>>     Ok were on the right track maybe we try the simple positioning as
>>>     you founf w/o the special cases. Could you email me the other
>>>     driver code that works in lcd4linux?
>>>
>>>      -----Original Message-----
>>>     From:   Andreas [mailto:Andreaz@t-online.de]
>>>     Sent:   Thu May 04 11:14:27 2006
>>>     To:     Andrew Foss
>>>     Subject:        AW: [Lcdproc] Screen->Client List has timeout->-1
>>>
>>>     ROFL. I also just realized it, compared to the ncurses driver.
>>>     Yeah, exactly... Line 3 and 2 seems to be swapped, also...
>>>
>>>     Seems its an complete different adressing method.
>>>
>>>     Im a lil angry that my c isnt any better. I dig around like
>>>     hell in that lcd4linux project. The one code-line ive found
>>>     so far is in the driver drv_hd44780 (of lcd4linux!):
>>>
>>>      if (Capabilities & CAP_HD66712) {
>>>             /* the HD66712 doesn't have a braindamadged RAM layout */
>>>             pos = row * 32 + col;
>>>         }
>>>
>>>     Maybe it means, the controller always think it got 32 columns per
>>>     row ?
>>>
>>>     Im still digging, maybe i find some more...
>>>
>>>
>>>     >Betreff: Re: AW: AW: [Lcdproc] Screen->Client List has timeout->-1
>>>     >
>>>     >ok, thanks, there's some odd looking code around the virtual
>>>     positioning
>>>     >in the hd44780 driver w/ some hardcoded constants that make me
>>>     wonder a
>>>     bit.
>>>     >
>>>     >Interestingly, Clients: 0 should be on line 2 and Screens: 0
>>>     should be
>>>     >on line 3, yet they seem reversed in yours?
>>>     >
>>>     >andrew
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>
> ------------------------------------------------------------------------
>
> --- hd44780.c.orig	2006-05-05 14:48:28.000000000 -0700
> +++ hd44780.c	2006-05-05 14:48:36.000000000 -0700
> @@ -435,6 +435,11 @@
>  		DDaddr = x + (relY % 2) * 0x40;
>  		if ((relY % 4) >= 2)
>  			DDaddr += p->width;
> +
> +#define HD66712
> +#ifdef HD66712
> +	DDaddr = x + relY * 0x20;
> +#endif //HD66712
>  	}
>  	p->hd44780_functions->senddata (p, dispID, RS_INSTR, POSITION | DDaddr);
>  	p->hd44780_functions->uPause (p, 40);  // Minimum exec time for all commands
>   

--------------040000010604060509080203
Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0";
 name="lcdprocHD66712.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="lcdprocHD66712.patch"

diff -uNr --exclude config.log lcdproc-0.5.0/LCDd.conf lcdproc-0.5.0.HD66712/LCDd.conf
--- lcdproc-0.5.0/LCDd.conf	2006-04-12 10:00:08.000000000 -0700
+++ lcdproc-0.5.0.HD66712/LCDd.conf	2006-05-05 18:17:28.000000000 -0700
@@ -341,9 +341,12 @@
 
 
 
-## Hitachi HD44780 driver ##
+## Hitachi HD44780 & HD66712 driver ##
 [hd44780]
 
+# HD66712 is an HD44780 w/ a simplified RAM layout
+#HD66712=yes
+
 # Port where the LPT is. Usual values are 0x278, 0x378 and 0x3BC
 Port=0x378
 
diff -uNr --exclude config.log lcdproc-0.5.0/server/drivers/hd44780.c lcdproc-0.5.0.HD66712/server/drivers/hd44780.c
--- lcdproc-0.5.0/server/drivers/hd44780.c	2006-04-14 05:19:11.000000000 -0700
+++ lcdproc-0.5.0.HD66712/server/drivers/hd44780.c	2006-05-05 18:27:44.000000000 -0700
@@ -147,7 +147,10 @@
 	//// 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 );
+	if ( drvthis->config_get_bool( drvthis->name, "extendedmode", 0, 0 ))
+		p->mode		|= EXT_MODE;
+	if ( drvthis->config_get_bool( drvthis->name, "HD66712", 0, 0 ))
+		p->mode		|= HD66712;
 	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 );
@@ -342,7 +345,7 @@
 void
 common_init (PrivateData *p, unsigned char if_bit)
 {
-	if (p->ext_mode) {
+	if (p->mode & 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);
@@ -420,9 +423,11 @@
 	int relY = y - p->dispVOffset[dispID - 1];
 	int DDaddr;
 
-	if (p->ext_mode) {
+	if (p->mode & EXT_MODE) {
 		// Linear addressing, each line starts 0x20 higher.
 		DDaddr = x + relY * 0x20;
+	} elseif (p->mode & HD66712) { //HD66712 simplified RAM layout
+		DDaddr = x + relY * 0x20;
 	} else {
 		// 16x1 is a special case
 		if (p->dispSizes[dispID - 1] == 1 && p->width == 16) {
@@ -435,6 +440,7 @@
 		DDaddr = x + (relY % 2) * 0x40;
 		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
diff -uNr --exclude config.log lcdproc-0.5.0/server/drivers/hd44780-lis2.c lcdproc-0.5.0.HD66712/server/drivers/hd44780-lis2.c
--- lcdproc-0.5.0/server/drivers/hd44780-lis2.c	2006-04-07 07:54:29.000000000 -0700
+++ lcdproc-0.5.0.HD66712/server/drivers/hd44780-lis2.c	2006-05-05 18:25:50.000000000 -0700
@@ -186,7 +186,7 @@
 			
 			pos = (ch & ~POSITION);
 	
-			if (p->ext_mode) {				
+			if (p->mode & EXT_MODE) {				
 				y = pos/0x20;
 				x = pos-(y*0x20);
 			}
diff -uNr --exclude config.log lcdproc-0.5.0/server/drivers/hd44780-low.h lcdproc-0.5.0.HD66712/server/drivers/hd44780-low.h
--- lcdproc-0.5.0/server/drivers/hd44780-low.h	2005-01-17 11:51:43.000000000 -0800
+++ lcdproc-0.5.0.HD66712/server/drivers/hd44780-low.h	2006-05-05 18:22:18.000000000 -0700
@@ -41,6 +41,10 @@
 	const char *helpMsg;
 } ConnectionMapping;
 
+/* Constants mode flags */
+#define EXT_MODE 1 // use of extended mode required for some weird controllers
+#define HD66712 2 // HD66712 simplified RAM layout
+
 typedef struct driver_private_data {
 
 	unsigned int port;
@@ -81,7 +85,7 @@
 	char have_keypad;	// off by default
 	char have_backlight;	// off by default
 	char have_output;	// have extra output port (off by default)
-	char ext_mode;		// use of extended mode required for some weird controllers
+	char mode;		// flags for extended mode or hd66712 mode
 	int delayMult;	 // Delay multiplier for slow displays
 	char delayBus;	 // Delay if the computer can send data too fast over
 				 // its bus to LPT port

--------------040000010604060509080203--