View Full Version : LCD Code help..

04-02-2009, 09:48 AM
I found an old 40x2 optex parallel LCD unit in my box of toys and was wondering what needed to be modded in the LCDDEMO code to get full use out of my unit..

I quickly looked in the demo code and it showed the memory management for most units in the info in the header comments, but I couldn't find any line width variables.. so I am a little confused..

What I did see if code that did bit shifting and since its using 4 bit characters and the code did a 64 bit shift ( 4 x 16 chars ) and for the second line added 128, I am assuming this is the code I would have to change to shift 40 x 4 = 160 bits and then the offset would be plus 320 bits for the second line..

Does this make sense??

Anyone else have a 40x2 character display?



Peter Jakacki
04-02-2009, 10:02 AM
The only difference with many of the character displays is the mapping of the character position in the LCD memory itself. You will probably find though that the mapping is linear as the LCD controller chip itself only handles 80 characters so position 0 will be the top left, 39 will be top right, 40 bottom left, and 79 bottom right. I just had a quick look at the LCDDEMO code but it has been written for a graphics LCD whereas yours is a character based LCD. There are plenty of objects and examples available for these, you might just need to change where it goes to when the object performs a "new line" function. That's where a "SET DDRAM Address" command is written to the LCD command register to position where the character data will be written. In your case the position of the lines are 0 or 40.