KS0108 Graphics LCD code compile error

Hi I am Aashish. I have a Arduino Duemilanove w/ Atmega328 board, I wish to drive a graphical LCD with it.

I found the KS0108 Graphics LCD library on the arduino page Arduino Playground - GLCDks0108, I downloaded the version 2 of the library ( ks0108GLCD-v2.zip).

I picked up the Example GLCD sketch from the site itself.

#include <ks0108.h> // library header
#include <Arial14.h> // font definition for 14 point Arial font.
#include "SystemFont5x7.h" // system font
#include "ArduinoIcon.h" // bitmap

unsigned long startMillis;
unsigned int iter = 0;

void setup(){

GLCD.Init(NON_INVERTED); // initialise the library
GLCD.ClearScreen();
GLCD.DrawBitmap(ArduinoIcon, 32,0, BLACK); //draw the bitmap at the given x,y position
delay(3000);
GLCD.ClearScreen();
GLCD.SelectFont(System5x7); // select fixed width system font

}

void loop(){ // run over and over again

startMillis = millis();
while( millis() - startMillis < 1000){ // loop for one second
GLCD.DrawRect(0, 0, 64, 61, BLACK); // rectangle in left side of screen
GLCD.DrawRoundRect(68, 0, 58, 61, 5, BLACK); // rounded rectangle around text area
for(int i=0; i < 62; i += 4)
GLCD.DrawLine(1,1,63,i, BLACK); // draw lines from upper left down right side of rectangle
GLCD.DrawCircle(32,31,30,BLACK); // draw circle centered in the left side of screen
GLCD.FillRect(92,40,16,16, WHITE); // clear previous spinner position
GLCD.CursorTo(5,5); // locate curser for printing text
GLCD.PrintNumber(++iter); // print current iteration at the current cursor position
}
// display number of iterations in one second
GLCD.ClearScreen(); // clear the screen
GLCD.CursorTo(13,2); // positon cursor
GLCD.Puts("FPS= "); // print a text string
GLCD.PrintNumber(iter); // print a number
}

But, when I compiled the code it gave me errors as,
D:\Program Files\Arduino\libraries\ks0108\ks0108.cpp: In member function 'void ks0108::Init(boolean)':
D:\Program Files\Arduino\libraries\ks0108\ks0108.cpp:505: error: 'OUTPUT' was not declared in this scope
D:\Program Files\Arduino\libraries\ks0108\ks0108.cpp:505: error: 'pinMode' was not declared in this scope
D:\Program Files\Arduino\libraries\ks0108\ks0108.cpp:511: error: 'delay' was not declared in this scope

Is really the code wrong? because I expect it to be tested OK as I picked it up from the arduino site itself.
Or I was wrong it installing it or the lib, (I just copied the ks0108 folder to D:\Program Files\Arduino\libraries)

Please help me, I am In a great need of it.

Thanks in advance. Please help.

Try adding
#include <Arduino.h>

to ks0108.cpp

I wouldn't recommend using version 2. It is nearly 5 years old and does not work the more recent
versions of the IDE including Arduino 1.x
Use version 3, or switch to openGLCD
https://bitbucket.org/bperrybap/openglcd/wiki/Home

--- bill

Thanks a lot all of you for giving me fruitful suggestions. Yes :smiley: :smiley: the GLCD is now working with the version 3 of the glcd lib. (I have not tried the openGLCD yet),

But there are still some problems, the LCD is not displaying as expected with the code,

For example in my following test code :

  1. // include the library header

  2. #include <glcd.h>

  3. // include the Fonts

  4. #include <fonts/allFonts.h>

  5. unsigned int x0 = 64;

  6. unsigned int y0 = 0;

  7. void setup() {

  8. // Initialize the GLCD

  9. GLCD.Init();

  10. // Select the font for the default text area

  11. GLCD.SelectFont(System5x7);

  12. }

  13. void loop() {

  14. GLCD.CursorTo(11, 4);

  15. GLCD.print("Aashish");

  16. // print the number of seconds since reset:

  17. GLCD.CursorTo(11, 7);

  18. GLCD.print(millis()/1000);

  19. GLCD.SetDot(64, 0, BLACK);

  20. GLCD.DrawCircle(x0+10, 10, 10, BLACK);

  21. GLCD.DrawLine(x0+0,25,x0+63,25,BLACK);

  22. GLCD.DrawLine(0,25, 63,25,BLACK);

  23. }

If I write 19. GLCD.SetDot(0, 0, BLACK); the LCD sets the dot at some where middle, may be at (64, 0) and not at true (0,0) location. I managed it to come from left start by shifting it 19. GLCD.SetDot(64, 0, BLACK);
Same is happening to the text : 14. GLCD.CursorTo(0, 4); 15. GLCD.print("Aashish"); ----- the text is not printing at true (0,0) location, but at some where middle. I managed it to come from left start by shifting it 14. GLCD.CursorTo(14, 4);

Also if I write 21.GLCD.DrawLine(x0+0,25,x0+63,25,BLACK); // x0=64 as to managed it to come from left start (the above problem) the line only covers the first half of the screen, and not the full horizontal screen, I managed it to draw in two parts (for two halves) as,
21.GLCD.DrawLine(x0+0,25,x0+63,25,BLACK); // first half
22.GLCD.DrawLine(0,25, 63,25,BLACK); // second half

But this is not the way !!

It seems the screen is not continuous but divided into two parts, and code first works on the second half.

How do I fix it ?? Please help.

Please help me, I am In a great need of it.

Thanks in advance. Please help.

I don't provide support for the glcd library anymore as I have moved on to openGLCD which I actively support.
The glcd library does include lots of documentation and a diagnostic sketch for debugging issues.
I would suggest starting there.
Run the diagnostic sketch, and read the included html documentation for how to resolve issues.

If you are working on an open source project, then I'd recommend using openGLCD instead of GLCDv3.
(openGLCD is licensed GPL v3)
You can read further about openGLCD on the repository page referenced above.
If you are using openGLCD and have issues, I'll be happy to help you track them down.

--- bill