KS0108

This driver has been tested on a GDM12864H from Sparkfun Electronics.

Font functions

#include "mbed.h"
#include "KS0108.h"  


#include "Arial12.h"
#include "Arial14.h"
#include "Comic24.h"
#include "vivaldi16.h"


KS0108  display(p13,p12, p14, p11, p21, p22, p30, p29, p28, p27, p26, p25, p24, p23); 

int main() {                            
    

    while(1) {

    display.ClearScreen();    

    display.GotoXY(5,0);           
    display.SelectFont(Arial12,BLACK,ReadData);
    display.PrintNumber(1);
    display.PrintChar('m');    
    
    display.GotoXY(5,16);
    display.PrintString("arial Font test");            
    wait(3);
    
    display.GotoXY(2,32);           
    display.SelectFont(vivaldi16,BLACK,ReadData);
    display.PrintString("Vivaldi font");    
    wait(3);
    }

}

Graphic functions

#include "mbed.h"
#include "KS0108.h"        
#include "image.h"
    
KS0108 display (p13,p12, p14, p11, p21, p22, p30, p29, p28, p27, p26, p25, p24, p23);                        
void testlib(int i);

int main() {

    display.ClearScreen();     
    display.RoundRectangle(0,0,127,63,3,BLACK);
    
    while(1){          
       
          display.HLine(20,70,30,BLACK);
          display.HLineShort(30,20,50,BLACK);
          display.VLine(20,40,30,BLACK);
          display.VLineShort(70,5,50,BLACK);
          display.SlantyLine(5,8,20,30,BLACK);
          display.DegreeLine(15,30,30,6,20,BLACK); 
          display.FullRectangle(10,30,15,34,BLACK);
          display.EmptyRectangle(5,5,50,59,BLACK);
          display.RoundRectangle(30,20,80,35,7,BLACK);    
          wait(2);
        display.ClearScreen();
       
    }

}

KS0108 library





6 comments:

03 May 2011

Looking at some of your font files, I noticed that although you describe the font elements mainly as uint8_t's, you actually define the fonts as static unsigned int arrays. I suspect they are taking 4 times as much space as you intended!

04 May 2011

Hi, yes that's true. I tried to change as little as possible from the generated font files. mbed has plenty of memory so that should not be a problem for one or two font files.

There is still a problem when you try to use them on coordinates that are not divided by 8. I guess i have to rewrite the whole PrintString() function. Also on a future revision the SelectFont function should be re-written to take only the font name and color. There are plenty on things to improve on, frame buffers come to mind. Most of what i did is a direct port of the arduino lib with some additional functions. Feel free to improve on anything you can think of.

01 Sep 2011

Hi Dimiter,

My name is Ivan and I'm from Argentine.

I have problem to initialize Glcd. I have a WG12864-TMI-V#N of Winstar. GLcd never starts to work. About your experience where do you think it could be the problem?

In your program I don't find initializing routine of GLCD, could you let me know where it is, please?

Thanks in advance and sorry with my english. Ivan

02 Sep 2011

Not sure mate , as noted above it has been tested only on one piece of hardware. The initializing routine is the constructor. If the pin-out is different then you'll have to refer to your datasheet for hints. You can fiddle with the timing if you're sure that it's based on a KS0108 driver, otherwise your best bet is to re-write the control functions from scratch.

30 May 2012

I'm using a HQM1286404 from JE-AN. Lots of trouble. Finding a datasheet for the unusual pin setting was difficult but found it. It has two KS0108 controllers. Had to invert CS1 & CS2 with an 74HC00. (changing all the zeros and ones 0->1 and 1->0 in KS0108::SelectSide(unsigned char side) also works. Putting a whole BMP on the screen is OK. This works fine. Tested fonts and works also. Problems come when drawing lines. Tested with FullRectangle(0,0,10,10,BLACK); and the screen hangs. Testing with (1,1,10,10,BLACK) works so I tested (1,1,126,10,BLACK) which works also. When I put in (1,1,127,10,BLACK) or (1,15,10,10,BLACK) the screen hangs also. So the x must be between 1 and 126 and the y between 1 and 14 ????? Every pixel goes through SetPixel(x,y)

What can be wrong?

31 May 2012

Update. Using another display gives no problems. I think it is a timing problem or maybe the 3.3V is critical for this old type LCD. Sometimes it works sometimes it doesn't