Learning to Drive an LCD DISPLAY with drivercode from Marks.

Haroen

Member
Hi,
I'm learning to send text and variables to a 20X2 with drivercode from Marks for a 20x4 LCD DISPLAY, Post #43:
http://www.picaxeforum.co.uk/showthread.php?19474-Learning-to-Drive-an-LCD-DISPLAY/page2

Some code mentioned:
Code:
BinToAscii W1,b8,b7,b6,b5,b4
INC W1

HI2COUT 0,(254,192) ' Command Line 2 Cursor Position
pause 10
HI2COUT 0,("*    Hi2C ",b8,b7,b6,b5,b4)
pause 40 
HI2COUT 0,(254,$21) ' Control A0 high
pause 2000 
HI2COUT 0,(254,192)
pause 10
HI2COUT 0,(" *   Hi2C ",b8,b7,b6,b5,b4)
pause 40 
HI2COUT 0,(254,$20) ' Control A0 low
pause 2000
1) How to send text to the first, third and fourth line?
2) How to clear a line?
3) I'm trying to visualize 8 variables on the screen with 4 on the left and 4 on the right. What is the best method to achieve this?
4) How to highlight a value so that the blue background with white text switches to white background with blue text?
5) Is there a full set of instructions listed somewhere?
 

hippy

Technical Support
Staff member
HI2COUT 0,(254,192) ' Command Line 2 Cursor Position

Which is the same as HI2COUT 0,(254,$C0) so that seems to fit with standard line addressing, though might be Line 3 on a four line display. Try $80, $A0, $C0, $E0 for each of the four lines.

To clear a line; select the line as a above then write 20 spaces.
 

AllyCat

Senior Member
Hi,

It looks to use a standard HD44780 control chip, so the data sheet is easily available and there are plenty of code examples on the forum.

However, rows 3 and 4 are a "continuation" of rows 1 and 2, so I believe their start addresses are $94 (148) and $D4 (212). The cursor (reversed square) can be switched on and off and applied to the full cell or just as an underline. This should be all explained in the datasheet, for example as linked by hippy in post #11 of the thread above.

Cheers, Alan.
 

Haroen

Member
Thanks,
1) That works fine for line addresses selection.
2) To clear a line with spaces worked too, I hoped there was a CLEAR function(address) build in.
3) 8 variables on the screen is now simple by adding 10 to the begin address resulting in...
Text1-----Text5-----
Text2-----Text6-----
Text3-----Text7-----
Text4-----Text8-----
5) Found the default datasheet in the thread link, thanks.
4) I want to reverse colours of the tekst to highlight a tekst or value so that the blue background with white text becomes a white background with blue tekst.
That's not the cursor sign meant such as in datasheet page 30.
I thought it would be reversed characters in the ASCII table?!
It should be something like this...
Bleu-White display.jpg
Yes it's a DOT matrix but found that a character display can be configured too like this...
Bleu-White display2.jpg
Is there an easy way or should I just blink the text with white squares?
 

AllyCat

Senior Member
Hi,

I thought it would be reversed characters in the ASCII table?!
Some LCDs have "light on dark" characters and others "dark on light", but I don't believe they can be changed. OLEDs are (always) light on dark. There is no ASCII character to "reverse" characters (because ASCII was originally developed for teletype/typewriter printing) and I don't believe a manufacturer would "waste" half of the ROM characters/addresses for a complete set of reversed characters.

Your second display is certainly "character-based" because of the background lines (between character cells) in the "picture". I believe some displays (particlarly OLED) can write "graphic" bit patterns to every character cell, but the HD44780 (and similar) control chips have (only) 8 "User-Defined" characters (numbered ASCII 0 - 7 and repeated between 8 and 15). Looking very carefully at the picture, it uses exactly 8 "special" (user-defined) characters in additiion to the "all-dark" space (ASCII $20) and "all-light" block (ASCII $FF). Here is how the characters might have been allocated in the "picture" :

Code:
FF FF 00 FF FF
FF 01 20 02 FF
FF 03 04 05 FF
FF 06 07 00 FF
Cheers, Alan.
 

hippy

Technical Support
Staff member
4) I want to reverse colours of the tekst to highlight a tekst or value so that the blue background with white text becomes a white background with blue tekst.
I thought it would be reversed characters in the ASCII table?!
If there are reversed characters in the font table then you can use those.

Otherwise you could use CGRAM characters which is how the Pololu example appears to do it. Quite cleverly as there are only 8 CGRAM characters yet the display graphic would seem to need 9.

You can flash characters by overwriting them.
 

AllyCat

Senior Member
Hi,

there are only 8 CGRAM characters yet the display graphic would seem to need 9.
That's correct, it can't be done with an AXE133 because it needs the "block" character (255); hence my thread a few months ago. ;)

Don't forget that if you want to create User-Defined characters to reverse (all) the ASCII characters "on the fly", you will need a large lookup table! I don't believe that the ROM character font data can be read from the HD44780, even if the Read function/pin is implemented.

Cheers, Alan.
 

hippy

Technical Support
Staff member
there are only 8 CGRAM characters yet the display graphic would seem to need 9.
That's correct, it can't be done with an AXE133 because it needs the "block" character (255)
I was meaning even without that full block character, but the trick is that the bottom right of the trunk (notional 9th) is the same as the top.

It's the AXE133 firmware which prevents 255 being used as a block character but the LCD would support it otherwise.
 

Attachments

AllyCat

Senior Member
Hi,

Indeed. That's why I showed "character 00" twice in my "code" block in post #5. Of course I could have numbered the second "00" as "08" which would still have worked, but totally confused the issue. ;)

Cheers, Alan.
 

hippy

Technical Support
Staff member
@ Alan : My fault ! I didn't pay enough attention to what you had written and misinterpreted your numbers as the definition for some character blocks, rather than recognising it as exactly what I later said !
 

Haroen

Member
Is there an easy way or should I just blink the text with white squares?
Is a Block Character in post #8 the same as a White square?

I Will need a lot of space for the project code and want the LCD display code simple, short and easy.
Highlighting, flashing, or something else for warnings on this LCD screen is essential.
What do other programmers use for his?
 
Last edited:

AllyCat

Senior Member
Hi,

The "block" is either a "light/white square" or "dark/black square" (strictly a 5 x 7 rectangle), depending on the foreground/background colours! ;)

Character-based displays are reasonably "fast", low-cost and easy to control, but not very versatile particularly on a "local" basis (i.e. not changing the whole display "globally").

To flash a group of characters you would need to repeatedly replace them with a "blank" string, which would normally be "space" characters (32) rather than the "block" (255), and then re-write the original character string a fraction of a second later. Not difficult, but not trivial either.

With PICaxe it is often recommended to use an "intelligent" display (i.e. with an additional microcontroller and serial comms.), anything from the AXE133 (where you could modify the embedded program to flash or perhaps even reverse characters) through to the "Nextion" displays, but of course at additional cost.

Cheers, Alan.
 
Last edited:

Haroen

Member
I think that flashing with the SPACE symbol Will do the job also to draw attention rather then the reverse symbols. For more White on blue contrast the BLOCK symbols should be fine to compare.
Both are fine solutions, thanks everybody.:cool:
 
Last edited:
Top