1 Attachment(s)
Nokia COLOR LCD PicBasicPro 2.50a example code
Some basic example code for the Nokia Color LCDs found in a lot of cellphones.
Basic code, prints text, in up 256 colors (out of 4096 possible, and the controller/firmware is actually capable of 18 bit color, but I can't tell the difference), clear screen, a method for printing variables (bits, bytes, words, and longs), x/y plotting, etc.
The code with all of the neat graphic functions like circles, lines, boxes, waves, etc. will be here eventually.
Cut and paste this into eBay's search bar to find LCDs that are compatible with this code:
nokia -6620 -6230 -6061 -3220 -73* -n9* -52* -77* -6500 -57* -53* -88* -6101 -6126 -6265 -6680 -e6* -6288 -n7* -6133 -8600 -6300 -6230i -6010 -5610 -9300 -3310 -5110 -8810 -n8* -3250 -5500 -6111 -6280 -8850 -6120 -3360 -6360 -6600 -3230 -8210 -e90 -n93 -e5* -1110 -8910
Sparkfun also has these displays:
http://www.sparkfun.com/commerce/pro...roducts_id=569
And check out sparkfun for adapter boards to plug it in:
http://www.sparkfun.com/commerce/pro...roducts_id=600
And the connector if you want to plug it in yourself somehow: (also available at Digikey and Mouser, just have to search for it)
http://www.sparkfun.com/commerce/pro...roducts_id=570
Code is originally written for a PIC18F4620 running at 40Mhz. If the LCD is mounted close, and you're relatively sure the signal is strong, you can get rid of the extra sdata lines in the togglesclock block to make writing to the LCD much faster. I had to add the extra 'delay' because my LCD was connected to the PIC on a 6ft cable.
The font table requires a PIC with 1K of EEPROM (the basic font table will fit in 512 bytes, ASCII 0 thru 127), so the PIC choices are a bit limited in that respect. This font table is copied into RAM on startup so it can be easily modified if needed. Or I suppose a person could easily change the code to put the table into program memory easily enough and read it out from there.
Nokia GLCD code without the need for big RAM, font in eeprom
Just like the title says...
The 'font' stays in eeprom (need a PIC with a minimum of 512 bytes, otherwise characters will get dropped) and minimal ram is needed (37 bytes).
If you're tacking this program onto something else, pay attention to the variable names. Maybe go back and pre-pend them all with CGLCD or something to keep them from getting overwritten or overwriting something important to you...
Next up...the font goes into program memory instead of ram or eeprom. Should open up the code to practically every PIC out there with at 2K of program memory and more than 37 bytes of ram (most PICs except for the 10Fxxx and some of the 12F series)...
After that, the shape drawing routines, and maybe some 3D functions I've been playing with...
EDIT: Found a bug...pulled the code for now...will have new stuff up later tonight...
1 Attachment(s)
Nokia knock-off Color LCD code with the font in program memory
This time the font goes in program memory at the high end.
Pay attention to the notes in the code. You have to change a couple of values based on the PIC you are using, then you may have to do some math if you are using a bootloader, so you don't overwrite the bootloader with the font.
The basic code and the few examples I added take up 3,223 words along with 640 words (1280 bytes) for the font itself.
So, you now need a PIC with at least 4.4K free of program memory and 37 bytes of free ram. And if you cut the font down from 256 to 128 characters, only 3.8K of free program space is needed...even less if you cut the font down even farther.
I pre-pended all of the variable names with CLCD, so you shouldn't have a problem with variables overwriting each other unless you've got a variable that starts out with CLCD.
I wrote this code to run on a PIC18F4620 'cause that's about all I use these days and I'm fairly sure it'll run on any PIC18Fxxx(x) series, as long as the person using it changes the requisite registers as required (READ THE DATASHEET for the PIC!!!).
I'm not sure if it'll run on 'lesser' PICs, i.e. 16F, 16C...it should with a few changes. It may even run on a 12Fxxx series if the code is cut down to an absolute bare minimum, the font cut down to practically nothing...but there probably won't be any useful code space leftover. PIC10Fxxx types are definitely out of the question.
Enjoy... Graphics routines are in work and will be posted when I'm done with them...
Trying to Fit the Lib on a 16F877
Hi Skimask,
I just received my Color LCD and the breadboard from SparkFun.
I´m trying to convert your source code to run on a 16F877 (8 Kb, 368 byts of RAM, 256 bytes of EEPROM)
I´m doing that just because I can not find the 18F4620 here in Brazil.
So, I did some modifications as you suggested :
1) Changed de OSC to 10 (Mhz)
2) The line :
clcdENDFLASH con $FFFF 'IMPORTANT - change this value to the size of the PICs program space - 1
was changed to :
clcdENDFLASH con $1FFF 'IMPORTANT - change this value to the size of the PICs program space - 1
3) At the end of the code, the Org value was changed to org 0x1F60
4) Removed the 13 last lines used for the modified ASCII characters
But, when I try to compile, the PBP returns some strange error messages :
Warning[207] d:\teste_~1\nokia~2.asm 188 : Found Label after column 1. (bra)
Error[122] d:\teste_~1\nokia~2.asm 188 : Illegal opcode (clcdoverstr)
Message[303] d:\teste_~1\nokia~2.asm 190 : Program word too large. Truncated to core size (5465)
Message[303] d:\teste_~1\nokia~2.asm 190 : Program word too large. Truncated to core size (7374)
Message[303] d:\teste_~1\nokia~2.asm 190 : Program word too large. Truncated to core size (7472)
Message[303] d:\teste_~1\nokia~2.asm 190 : Program word too large. Truncated to core size (696E)
Message[303] d:\teste_~1\nokia~2.asm 190 : Program word too large. Truncated to core size (6723)
I don´t understand why the code doesn´t fit in my 877, since the same source compiled for the 18F4620 takes less than 3 Kb...
Do you have any idea or any tip to fit it on a 877 ?
Thank you !