Go Down

Topic: GLCD library version 3 (Read 82 times) previous topic - next topic

bperrybap


I was able to get a 192x64 display working with your code that you do not have listed in the docs.  What is the best way for me to send you the setup info so it can get added into the documentation?

There is a 192x64 configuration file that ships with the library. Did you have to modify that?
If so, it would be useful to get the changes that you made.

There are some specific modules mentioned on the ks0108 playground wiki page including some 192x64 displays.
You can modify the wiki page to include information about your specific display.
http://playground.arduino.cc/Code/GLCDks0108

--- bill

Tudeskie

I went to the wiki but it seemed outdated vs. the PDF included in the google code page, but I will update the info there too.

I did have to modify the 192x64 config file.  I will list everything below for future reference.

The Graphic LCD I was working with was a Digitron SG19264A.

The pinout of the LCD is:






















Pin NO.  Symbol  LEVEL  Function 
VSS  0V  GND 
VDD  5V  Supply Power for logic 
V0  - LCD voltage adjustment pin 
D/I  H/L  Data or Instruction select. 
R/W  H/L  Read or Write 
H/L  Read /Write enable signal. 
DB0  H/L  DATA BUS 
DB1  H/L  DATA BUS 
DB2  H/L  DATA BUS 
10  DB3  H/L  DATA BUS 
11 DB4  H/L  DATA BUS 
12  DB5  H/L  DATA BUS 
13  DB6  H/L  DATA BUS 
14  DB7  H/L  DATA BUS 
15  /CS1  H/L  Chip selection   ( Left ).    "L" active 
16  /RST  H/L  Reset signal. 
17  /CS2  H/L  Chip selection ( Middle ).    "L" active 
18  /CS3  H/L  Chip selection ( Right ).    "L" active 
19  VEE  - LCD voltage 
20  BLA  5.0V  Supply Power for LED light 


Here is how to connect it up to an Arduino:

























Digitron
SG19264A
Arduino pins  Function  Panel D Comments 
5V  +5 volts  2 one side of contrast pot
Gnd  GND  1
n/a  Contrast in  3 Wiper of contrast pot 
8 D0  7
9 D1  8
10 D2  9
11 D3  10
4 D4  11
5 D5  12
6 D6  13
7 D7  14
14 (alog 0)  CSEL1  15 Chip 1 select 
15 (alog 1)  CSEL2  16 Chip 2 select 
Reset  Reset  18 Connect to reset 
16 (alog 2)  R_W  5 Read/write 
17 (alog 3)  D_I  4 Data/Instruction (RS) 
18 (alog 4)  EN  6 Enable 
n/a  Contrast out  19 10k or 20k preset , one side of contrast pot
n/a  Backlight +5  20 See datasheet 
Gnd 
3 CSEL318


The chip select pins on this LCD are inverted so I had to modify the code as follows:
in /config/ks0108-192x64_Panel.h
modify the number of chip select pins
Code: [Select]
#define NBR_CHIP_SELECT_PINS   3

Invert the chipselect pin outputs
Code: [Select]

/*
* Defines for Three Chip panels using three select pins
*/
#elif (NBR_CHIP_SELECT_PINS == 3 && glcd_CHIP_COUNT == 3) 
#define glcd_CHIP0  glcdCSEL1,HIGH, glcdCSEL2,HIGH,  glcdCSEL3,LOW
#define glcd_CHIP1  glcdCSEL1,HIGH,  glcdCSEL2,LOW, glcdCSEL3,HIGH
#define glcd_CHIP2  glcdCSEL1,LOW,  glcdCSEL2,HIGH,  glcdCSEL3,HIGH


I actually had to swap CS1 and CS3 wires on my board because it was displaying right to left instead of left to right, but I think it was an error I introduced myself while I was trying to get this LCD to work.  Just FYI.

AlhafizAbdullah

Hi...

I'm using Graphic LCD 128x64 for my Final Year Project. And Arduino Leonardo as mcu.
Here's the code i use:

Code: [Select]
/*
* GLCDexample
*
* Basic test code for the Arduino KS0108 GLCD library.
* This code exercises a range of graphic functions supported
* by the library and is an example of its use.
* It also gives an indication of performance, showing the
*  number of frames drawn per second. 
*/

#include <ks0108.h>
#include "Arial14.h"         // proportional font
#include "SystemFont5x7.h"   // system font
#include "ArduinoIcon.h"     // bitmap

unsigned long startMillis;
unsigned int loops = 0;
unsigned int iter = 0;

void setup(){
  delay(500);                // allow time for LCD to reset
  GLCD.Init(NON_INVERTED);   // initialise the library, non inverted writes pixels onto a clear screen
  GLCD.ClearScreen(); 
  GLCD.DrawBitmap(ArduinoIcon, 32,0, BLACK); //draw the bitmap at the given x,y position
  GLCD.SelectFont(System5x7); // switch to fixed width system font
  countdown(5);
  GLCD.ClearScreen();
  introScreen();              // show some intro stuff
  GLCD.ClearScreen();
}

void introScreen(){
  GLCD.SelectFont(Arial_14); // you can also make your own fonts, see playground for details   
  GLCD.GotoXY(20, 2);
  GLCD.Puts("GLCD  version  ");
  GLCD.PrintNumber(GLCD_VERSION);
  GLCD.DrawRoundRect(16,0,99,18, 5, BLACK);  // rounded rectangle around text area   
  GLCD.SelectFont(System5x7); // switch to fixed width system font
  showCharacters();
  countdown(5);
}

void showCharacters(){
  byte line = 3; // start on the fourth line
  for(byte c = 32; c <=127; c++){
     if( (c-32) % 20 == 0)
         GLCD.CursorTo(1,line++);  // CursorTo is used for fixed width system font
     GLCD.PutChar(c);   
  }   
}

void drawSpinner(byte pos, byte x, byte y) {   
  // this draws an object that appears to spin
  switch(pos % 8) {
  case 0 : GLCD.DrawLine( x, y-8, x, y+8, BLACK); break;
  case 1 : GLCD.DrawLine( x+3, y-7, x-3, y+7, BLACK);  break;
  case 2 : GLCD.DrawLine( x+6, y-6, x-6, y+6, BLACK);  break;
  case 3 : GLCD.DrawLine( x+7, y-3, x-7, y+3, BLACK);  break;
  case 4 : GLCD.DrawLine( x+8, y, x-8, y, BLACK);  break;
  case 5 : GLCD.DrawLine( x+7, y+3, x-7, y-3, BLACK);  break;
  case 6 : GLCD.DrawLine( x+6, y+6, x-6, y-6, BLACK);  break;
  case 7 : GLCD.DrawLine( x+3, y+7, x-3, y-7, BLACK);  break;
  }
}

void countdown(int count){
    while(count--){  // do countdown 
     GLCD.CursorTo(0,1);   // first column, second row (offset is from 0)
     GLCD.PutChar(count + '0');
     delay(1000); 
  } 
}

void  loop(){   // run over and over again
  iter = 0;
  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 
    drawSpinner(loops++,100,48);       // draw new spinner position
    //GLCD.FillRect(24,txtLINE3,14,14, WHITE);  // clear text area that will be drawn below
    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(14,2);              // positon cursor 
  GLCD.Puts("FPS= ");               // print a text string
  GLCD.PrintNumber(iter);           // print a number
}


whenever I try to compile the above code, it give 'Error Compiling' msg state that:

Quote
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp: In member function 'void ks0108::Init(boolean)':
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp:505: error: 'OUTPUT' was not declared in this scope
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp:505: error: 'pinMode' was not declared in this scope
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp:511: error: 'delay' was not declared in this scope
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp:513: error: 'LOW' was not declared in this scope
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp:513: error: 'digitalWrite' was not declared in this scope
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp: In member function 'void ks0108::SelectChip(uint8_t)':
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp:536: error: 'HIGH' was not declared in this scope
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp:536: error: 'digitalWrite' was not declared in this scope
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp:538: error: 'LOW' was not declared in this scope
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp:538: error: 'digitalWrite' was not declared in this scope
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp:541: error: 'HIGH' was not declared in this scope
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp:541: error: 'digitalWrite' was not declared in this scope
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp:543: error: 'LOW' was not declared in this scope
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp:543: error: 'digitalWrite' was not declared in this scope
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp: In member function 'void ks0108::WaitReady(uint8_t)':
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp:552: error: 'LOW' was not declared in this scope
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp:552: error: 'digitalWrite' was not declared in this scope
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp:553: error: 'HIGH' was not declared in this scope
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp: In member function 'void ks0108::Enable()':
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp:565: error: 'HIGH' was not declared in this scope
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp:565: error: 'digitalWrite' was not declared in this scope
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp:567: error: 'LOW' was not declared in this scope
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp: In member function 'uint8_t ks0108::DoReadData(uint8_t)':
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp:582: error: 'HIGH' was not declared in this scope
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp:582: error: 'digitalWrite' was not declared in this scope
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp:593: error: 'LOW' was not declared in this scope
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp: In member function 'void ks0108::WriteCommand(uint8_t, uint8_t)':
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp:612: error: 'LOW' was not declared in this scope
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp:612: error: 'digitalWrite' was not declared in this scope
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp: In member function 'void ks0108::WriteData(uint8_t)':
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp:648: error: 'HIGH' was not declared in this scope
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp:648: error: 'digitalWrite' was not declared in this scope
C:\Users\AlHaFiZ AbDulLah\Documents\Arduino\libraries\ks0108\ks0108.cpp:649: error: 'LOW' was not declared in this scope


Anyone please help me with this problem..

bperrybap

You need to get the updated library and the patch for leonardo:
http://playground.arduino.cc/Code/GLCDks0108

--- bill

AlhafizAbdullah

Already download and install the library to the library directory, but still, can't compile.

Go Up