Another GLCD example is at wav player with GLCD menu and slide show from SD card.
It features the SparksFun 128x128 color GLCD Nokia Knockoff for $14.95
Norm
Another GLCD example is at wav player with GLCD menu and slide show from SD card.
It features the SparksFun 128x128 color GLCD Nokia Knockoff for $14.95
Norm
@ DaveC, Thank you for confirming the fuses, and clearing up my confusion about 16,8bit vs 3,4 wire SPI. For some reason I had it in my head both interfaces (parallel & SPI) were active at the same time. Now the truth table makes more sense. The code posted is wonderful! At this point I need to either get a 18F4550, or decide on using something I already have. I will more then likely go with the 4550, just to be consistent with this thread. Once I have the use of this under my belt, then I will venture out and use others.
Have you found uP speed to be an issue? I like to use internal OSC when I can, but this will limit me to 32mHz in most cases. I see you are running at 48.
@Norm, That does look like a great GLCD. and the price is right on too. I didn't notice, does it have touch?
My end goal for this is HMI use. I have lots of stuff here at the shop that would benefit greatly from this.
Off to order some 4550's. It will be a few days before I get them, so I won't be playing till then.
When I find the datasheet, I will post it (or the link) here.
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
Bert
I use the 4550 for several reasons, 1. I have a lot of them, 2. I make a lot of USB devices for my flight simulator, 3. the speed of this chip is 48mhz.
This code can be ported to other devices. I have done SPI with this display but it is a lot slower.
Dave
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,
The following macro does the work.Code:'================= '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 '******************************************************************************
You call the macro in your application with thisCode: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
@ 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.
Now you should be able to do the famous "Hello World" on the GLCDCode:'******************************************************************************* ' 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
Bookmarks