DaveC3
- 12th May 2011, 16:30
In my previous post I showed how to setup and talk to the GLCD. The next thing to do is get some text on the screen. The controller on this display does not have built in text so you need to provide the text. This is done in a couple of look-up tables,
'=================
'FONT SAMPLE 5x7
'=================
Table1:
lu1 = charpos + char_row
lookup lu1, [0,0,0,0,0,_ 'space
$00,$00,$5f,$00,$00,_ '// 21 !
$00,$07,$00,$07,$00,_ ' 22 "
$14,$7f,$14,$7f,$14,_ ' 23 #
$24,$2a,$7f,$2a,$12,_ ' 24 $
$23,$13,$08,$64,$62,_ ' 25%
$36,$49,$55,$22,$50,_ ' 26 &
$00,$05,$03,$00,$00,_ ' 27 '
$00,$1c,$22,$41,$00,_ ' 28 (
$00,$41,$22,$1c,$00,_ ' 29 )
$14,$08,$3e,$08,$14,_ ' 2a *
$08,$08,$3e,$08,$08,_ ' 2b +
$00,$50,$30,$00,$00,_ ' 2c ,
$08,$08,$08,$08,$08,_ ' 2d -
$00,$60,$60,$00,$00,_ ' 2e .
$20,$10,$08,$04,$02,_ ' 2f /
$3e,$51,$49,$45,$3e,_ ' 30 0
$00,$42,$7f,$40,$00,_ ' 31 1
$42,$61,$51,$49,$46,_ ' 32 2
$21,$41,$45,$4b,$31,_ ' 33 3
$18,$14,$12,$7f,$10,_ ' 34 4
$27,$45,$45,$45,$39,_ ' 35 5
$3c,$4a,$49,$49,$30,_ ' 36 6
$01,$71,$09,$05,$03,_ ' 37 7
$36,$49,$49,$49,$36,_ ' 38 8
$06,$49,$49,$29,$1e,_ '// 39 9
$00,$36,$36,$00,$00,_ '// 3a :
$00,$56,$36,$00,$00,_ '// 3b ;
$08,$14,$22,$41,$00,_ '// 3c <
$14,$14,$14,$14,$14,_ '// 3d =
$00,$41,$22,$14,$08,_ '// 3e >
$02,$01,$51,$09,$06,_ '// 3f ?
$32,$49,$79,$41,$3e,_ '// 40 @
$7e,$11,$11,$11,$7e,_ '// 41 A
$7f,$49,$49,$49,$36,_ '// 42 B
$3e,$41,$41,$41,$22,_ '// 43 C
$7f,$41,$41,$22,$1c,_ '// 44 D
$7f,$49,$49,$49,$41,_ '// 45 E
$7f,$09,$09,$09,$01,_ '// 46 F
$3e,$41,$49,$49,$7a,_ ''// 47 G
$7f,$08,$08,$08,$7f,_ '// 48 H
$00,$41,$7f,$41,$00,_ '// 49 I
$20,$40,$41,$3f,$01,_ '// 4a J
$7f,$08,$14,$22,$41,_ '// 4b K
$7f,$40,$40,$40,$40,_ '// 4c L
$7f,$02,$0c,$02,$7f,_ '// 4d M
$7f,$04,$08,$10,$7f,_ '// 4e N
$3e,$41,$41,$41,$3e],temp '// 4f O
chardata[char_row + 1] = temp
Return
Table2:
lu1 = charpos + char_row
lookup lu1, [$7f,$09,$09,$09,$06,_ '// 50 P
$3e,$41,$51,$21,$5e,_ '// 51 Q
$7f,$09,$19,$29,$46,_ '// 52 R
$46,$49,$49,$49,$31,_ '// 53 S
$01,$01,$7f,$01,$01,_ '// 54 T
$3f,$40,$40,$40,$3f,_ '// 55 U
$1f,$20,$40,$20,$1f,_ '// 56 V
$3f,$40,$38,$40,$3f,_ '// 57 W
$63,$14,$08,$14,$63,_ '// 58 X
$07,$08,$70,$08,$07,_ '// 59 Y
$61,$51,$49,$45,$43,_ '// 5a Z
$00,$7f,$41,$41,$00,_ '// 5b [
$02,$04,$08,$10,$20,_ '// 5c
$00,$41,$41,$7f,$00,_ '// 5d
$04,$02,$01,$02,$04,_ '// 5e
$40,$40,$40,$40,$40,_ '// 5f
$00,$01,$02,$04,$00,_ '// 60
$20,$54,$54,$54,$78,_ '// 61 a
$7f,$48,$44,$44,$38,_ '// 62 b
$38,$44,$44,$44,$20,_ '// 63 c
$38,$44,$44,$48,$7f,_ '// 64 d
$38,$54,$54,$54,$18,_ '// 65 e
$08,$7e,$09,$01,$02,_ '// 66 f
$0c,$52,$52,$52,$3e,_ '// 67 g
$7f,$08,$04,$04,$78,_ '// 68 h
$00,$44,$7d,$40,$00,_ '// 69 i
$20,$40,$44,$3d,$00,_ '// 6a j
$7f,$10,$28,$44,$00,_ '// 6b k
$00,$41,$7f,$40,$00,_ '// 6c l
$7c,$04,$18,$04,$78,_ '// 6d m
$7c,$08,$04,$04,$78,_ '// 6e n
$38,$44,$44,$44,$38,_ '// 6f o
$7c,$14,$14,$14,$08,_ '// 70 p
$08,$14,$14,$18,$7c,_ '// 71 q
$7c,$08,$04,$04,$08,_ '// 72 r
$48,$54,$54,$54,$20,_ '// 73 s
$04,$3f,$44,$40,$20,_ '// 74 t
$3c,$40,$40,$20,$7c,_ '// 75 u
$1c,$20,$40,$20,$1c,_ '// 76 v
$3c,$40,$30,$40,$3c,_ '// 77 w
$44,$28,$10,$28,$44,_ '// 78 x
$0c,$50,$50,$50,$3c,_ '// 79 y
$44,$64,$54,$4c,$44,_ '// 7a z
$00,$08,$36,$41,$00,_ '// 7b
$00,$00,$7f,$00,$00,_ '// 7c
$00,$41,$36,$08,$00,_ '// 7d
$10,$08,$08,$10,$08,_ '// 7e
$78,$46,$41,$46,$78], temp ' // 7f
chardata[char_row + 1] = temp
Return
'************************************************* *****************************
The following macro does the work.
ASM ;printstr2 to color LCD macro, '@ printstr2 x,y, "string2 to lcd at x,y"
printstr2 macro x2, y2, str2
local thestring2, overstr2
bra overstr2
thestring2
data str2,0
overstr2
MOVE?CB x2, _LCDx
MOVE?CB y2, _Row
MOVE?CW thestring2, _addr
L?CALL _stringout2
endm
ENDASM
You call the macro in your application with this
@ printstr2 25,20, "SSD2119 Controller"
This tells the macro to place the text at coordinates X =25, Y =20 and the text follows.
You will need to declare a number of variables
(see full program)
And filaly the sub that puts the text on the screen, I modified the original code to generate text in different sizes by setting the var "big" to; big =0 is 5x7 text, "big=1" is 10x14 text and "big=2" is 20x24 text.
'************************************************* ******************************
' Text
'************************************************* ******************************
stringout2:
lcdy = row
Readcode addr, char :
If char = 0 then return
gosub putclcdtext :
addr = addr + 1 :
lcdx = lcdx + 1 :
lcdy = row
goto stringout2
putclcdtext:
if char < 20 then return
if char > $7f then return
for char_row = 0 to 4
if char < $50 then
charpos = (((char & $ff)- $20)*5)
gosub table1
endif
if char > $4f then
charpos = (((char & $ff)- $50)*5)
gosub table2
endif
next char_row
if big = 0 then ' Normal 5x7 font
for j = 0 to 7 ' data bits 0 - 7
cmd = $004E : gosub lcd_write_CMD : dat = lcdx : gosub lcd_write_dat ' RAM Addsress counter set X
cmd = $004F : gosub lcd_write_CMD : dat = lcdy : gosub lcd_write_dat ' RAM Addsress counter set Y
for k = 1 to 5
dat = fcolor
temp = chardata[k]
if temp.0[j] = 0 then
dat = bcolor
endif
cmd = $0022 : gosub lcd_write_CMD
gosub lcd_write_dat
next k
dat = bcolor
gosub lcd_write_dat
lcdy = lcdy + 1
next j
lcdx = lcdx + 6
elseif big = 1 then ' big 10x14 font
for j = 0 to 7 ' data bits 0 - 7
for n = 0 to 1
cmd = $004E : gosub lcd_write_CMD : dat = lcdx : gosub lcd_write_dat ' RAM Addsress counter set X
cmd = $004F : gosub lcd_write_CMD : dat = lcdy : gosub lcd_write_dat ' RAM Addsress counter set Y
for k = 1 to 5
for m = 0 to 1
dat = fcolor
temp = chardata[k]
if temp.0[j] = 0 then
dat = bcolor
endif
cmd = $0022 : gosub lcd_write_CMD
gosub lcd_write_dat
next m
next k
dat = bcolor
gosub lcd_write_dat
lcdy = lcdy + 1
next n
next j
lcdx = lcdx + 10 '20X24
elseif big = 2 then
for j = 0 to 7 ' data bits 0 - 7
for n = 0 to 3
cmd = $004E : gosub lcd_write_CMD : dat = lcdx : gosub lcd_write_dat ' RAM Addsress counter set X
cmd = $004F : gosub lcd_write_CMD : dat = lcdy : gosub lcd_write_dat ' RAM Addsress counter set Y
for k = 1 to 5
for m = 0 to 3
dat = fcolor
temp = chardata[k]
if temp.0[j] = 0 then
dat = bcolor
endif
cmd = $0022 : gosub lcd_write_CMD
gosub lcd_write_dat
next m
next k
dat = bcolor
gosub lcd_write_dat
lcdy = lcdy + 1
next n
next j
lcdx = lcdx + 24
endif
return
Now you should be able to do the famous "Hello World" on the GLCD
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.