Go Down

Topic: Library for those annoying 12864 LCD screens (Read 31012 times) previous topic - next topic


Hi guys, as some of you might know, there is no official library for the 12864 LCD screens If I am not mistaken, they come with an ST7920 chipset, which is cool when you want to display characters since it comes with a very easy interface for adding ASCII, but becomes insanely complicated when adding pixels for the sake of graphical development. Not only must you switch modes (that immediately presents you with a screen of random garbage, which YOU MUST clean up by passing 0x00 to every single pixel through the 8-bit interface), but you also have to deal with a complicated memory allocation system that relies on continous updating of the X and Y coordinates. Anyway, so far I created a library that initialises the screen, and then cleans it accordingly. As a result, direct access is possible. I only started working on this today, so if anyone else wants to get involved, please do! This is the first time I post in the Arduino forums, so i have no idea where to upload the code yet. I value any feedback, and welcome ideas.


Well, now that you've made your first post, you can post images and URLs... Im sure we'd all like to see more.  If you don't have a place for hosting images on your own, go see www.photobucket.com or the like.  If you want to post a library, see the http://arduino.cc/playground for a Wiki environment in which you can share your labors.


Excellent =D

As soon as I have something worth showing (e.g. at least a Bresenham algorithm for lines), Ill start posting right away. Cheers for that.


Does this help?
It's very general; draws line based on a function that draws a point, but at least it's fully fleshed out with all the possible quadrants and directions that it's possible to draw a line in (which is better than most Bresenham examples on the net.)  (I didn't write it; I found it!)


Thanks dude. This is what I have implemented so far:

Lines (Breseham)
Circles (Mid - Circle algorithm)
Filled Rectangles

I even made a simple animation of a square bouncing on the sides of the screen (pong style).
Next up is being able to draw bitmaps, and switching from gfx mode to ASCII mode.

I am away from home till Sunday, but I will upload at least the source code and some pictures as soon as I get back. Hopefully more people will get involved with the development of the library.

Thanks for the advice guys =D



I'm getting an LCD screen with the same chip, be interesting to see what I can make it do :)
It looks to me like the address it writes to auto-increments, so you can set the coordinates to the start of a line and then write the whole line, is this right?


Mar 10, 2009, 12:06 am Last Edit: Mar 10, 2009, 01:29 am by mak1980 Reason: 1
Yes, that is exactly how it works.
X coordinates increment, HOWEVER, they increment 8 pixels each time you enable.
Y coordinates never increment, which is the "norm" anyway.

Here is an example:
Assuming the following order:
{RS, RW, DB0, DB1, DB2, DB3, DB4, DB5, DB6, DB7}

0010000000 // SET Y COORDINATE to 0 (128 = first line)
0010000000 // SET X COORDINATE to 0 (128 = start)

1010100101 // Draw some pixels
Enable // Coordinate has moved 8 pixels now
1011111111 // Draw a full line of pixels
Enable // Coordinate has moved 8 pixels again

0010000001 // SET Y COORDINATE to 0 (129 = second line)
0010000000 // SET X COORDINATE to 0 (start)

Since I only came back today, I hope to upload the first version of the library by tomorrow.

Only thing I haven't implemented yet, is a way to enable the second part of the screen (second chip). It seems that it has some very stupid way of enabling the second screen (unlike most graphic LCDs that simply require you to enable CS2, rather than CS1). Once you reach the end of screen 1, it automatically puts you into screen 2. Thats sooooo annoying (although it probably isn't too hard to code).


OK, I'm ready to post the first version of the library. It comes with an example PONG game.
My only concern is that I have no experience working with wiki pages. Can someone help me create the page on the Arduino playground? Ill start uploading pictures in photobucket.

Thanks =D



Pong game



I have uploaded the code, and many examples to the Arduino Playground. Thanks for the support guys. Enjoy =D



Hi Marcus,
do you know if your library is compatible with ST7565 also?

I have got an LCD from POWERTIP code PE12864-004, it is driven by a ST7565,

thank you



I just got one of these screens for xmas from my GF :) it came with a demo board with a pre-programmed pic16f57 on.

it was from Sure electronics, the demo board displays an alternating checkerboard on the lcd.

screen is WG12864A.

i downloaded the library from the wiki, installed it, and uploaded the pong sketch to a 168 on a boarduino, but im getting nothing,, the wiring instructions on the wiki were confusing at best.
wiring pin3 up the same as i do with my 16x2 lcd's just gives me a blank screen. anyone got a schematic of wiring this type of LCD to an arduino properly?.. with less confusion :)

would be nice to play pong again XD


Dec 31, 2009, 10:47 am Last Edit: Dec 31, 2009, 12:19 pm by The_Bongmaster Reason: 1
i got things working on the other library (ks0108glcd)

thnx anyway XD

is there a pong game or any other sketch available for the other lib?


Hi Everyone,

Big thanks to Marcus and everyone for getting this screen up and running. I have got mine working.

I have two questions regarding this screen.

Is there any development on the fonts. I want to use this screen but I want to write to it in really terms and change the font size if possible.

Can some one explain the exact screen layout. It's quite hard to get my head round the exact grid that I can use to position things on the screen.

I might be in the wrong department though if this screen can not handle fonts and such. Should I switch to a KS0108?

Thanks again.


Go Up