PDA

View Full Version : Custom character on LCD



Sabai
10-26-2009, 01:36 AM
I am trying to make a custom character but I can not get it to work.

I creat the character:


Char12 DATA %01000
DATA %10100
DATA %01000
DATA %00000
DATA %00000
DATA %00000
DATA %00000

Char13 DATA %01000
DATA %10100
DATA %01000
DATA %00000
DATA %00000
DATA %00000
DATA %00000



And save it to the LCD


Download_Chars: ' download custom chars
char = LcdCGRam ' point to CG RAM
GOSUB LCD_Cmd
FOR idx = Char12 TO (Char13 + 7) ' prepare to write CG data
' build 4 custom chars
READ idx, char ' get byte from EEPROM
GOSUB LCD_Out ' put into LCD CG RAM
NEXT



But how do I use it?

Moskog
10-26-2009, 02:19 AM
Try this way to create an Arrow up·custom char: (BS2 and Parallax LCD)

' {$STAMP BS2}
' {$PBASIC 2.5}
LCD PIN 1 ' serial output to LCD
LcdBaud CON 32 ' 19,2K baud
LcdLine1 CON $94 ' move to line 1, column 0
LcdCC4 CON $FC ' define custom char arrow up
tall VAR Word ' Global word, used in several routines
index VAR Nib ' Loop Counter (max 0-15)

CC4 DATA LcdCC4, $04, $0E, $15, $04, $04, $04, $04, $00 'arrow up sign

Download_Chars:
FOR index = 0 TO 8 ' Download Custom Character arrow up
READ CC4 + index, tall ' Read EEPROM Data
SEROUT LCD, LcdBaud, [tall] ' Send To LCD CGRAM
NEXT

'Output to LCD:
SEROUT LCD, LcdBaud, [LcdLine1, 4," Arrow up"]

Sabai
10-26-2009, 02:28 AM
Thanks for your replay but I am using a parallel LCD

PJ Allen
10-26-2009, 02:39 AM
Assuming that you're writing to the CGRAM ($00 .. $0F, which is decimal 00 .. 15)·then you use that font code.

$41 is the font code for an·A, so you send $41 to get that letter.

You're storing character data for codes $12 and $13 (??) so you'd send a $12 or $13 as nec.

Sabai
10-26-2009, 02:53 AM
PJ Allen said...
Assuming that you're writing to the CGRAM ($00 .. $0F, which is decimal 00 .. 15) then you use that font code.

$41 is the font code for an A, so you send $41 to get that letter.

You're storing character data for codes $12 and $13 (??) so you'd send a $12 or $13 as nec.


Sorry I do not understand this!

PJ Allen
10-26-2009, 03:50 AM
Oh, wow!

Sabai
10-28-2009, 12:31 AM
Anybody know how to do this???

JD
10-28-2009, 01:55 AM
Sabai,

We have a book that I think would serve you well; it's Smart Sensors & Applications. It covers how to use a LCD display from general commands, to creating custom characters and the explanation behind it all. Here is a link for your convenience. There is a PDF and sample code that you can use.

Smart Sensors & Applications:
http://www.parallax.com/Store/Books/EducationalTexts/tabid/181/CategoryID/66/List/0/Level/a/ProductID/420/Default.aspx?SortField=ProductName%2cProductName

I hope this helps,

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Respectfully,


Joshua Donelson
www.parallax.com (http://www.parallax.com)

Sabai
10-28-2009, 02:10 AM
Jepp it covers serial LCD but I am still using a paralell. From the example 12 do they have this code to call the stored characters.

Animation:
FOR idx1 = 0 TO 15 ' cover 16 characters
READ (Msg2 + idx1), newChar ' get new char from Msg2
FOR idx2 = 0 TO 4 ' 5 characters in cycle
char = LcdLine2 + idx1 ' set new DDRAM address
GOSUB LCD_Cmd ' move cursor position
LOOKUP idx2, [0, 1, 2, 1, newChar], char ' get animation "frame"
GOSUB LCD_Out ' write "frame"
PAUSE 100 ' animation delay
NEXT
NEXT
PAUSE 2000

But I do not understand how the character are called I can see them but not how to call them.

JD
10-28-2009, 02:21 AM
Sabai,

Sorry about that, didn't even catch it was a parallel LCD; However, there is another book that I would suggest reading up on. It's called the StampWorks Manual,·it covers using the Parallel LCD with the BASIC Stamp 2 module; there is sample code and PDF (LCD control starts on pg 73)·like the previous book.

StampWorks Manual:
http://www.parallax.com/Store/Books/BASICStamp/tabid/168/CategoryID/42/List/0/Level/a/ProductID/144/Default.aspx?SortField=ProductName%2cProductName

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Respectfully,


Joshua Donelson
www.parallax.com (http://www.parallax.com)

Sabai
10-28-2009, 02:50 AM
Got that book but I can not say that it covers the subject very well the code I mention in my last post is from that book.

JD
10-28-2009, 03:03 AM
Sabai,

The custom characters are being called with the LOOKUP command. As the program cycles from 0 - 15 (for a 2x16 display) the pac-man looking character goes through 3 different steps each time; 0,1,2,1 to simulate "eating" of characters that are already shown.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Respectfully,


Joshua Donelson
www.parallax.com (http://www.parallax.com)