Pages: [1]   Go Down
Author Topic: How to configure Mega 2560 with lcd 128x64 ?  (Read 4581 times)
0 Members and 1 Guest are viewing this topic.
Brussels - Belgium
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Hello world
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I am a beginner in the Arduino world. smiley-small
I have an Arduino Mega 2560 with lcd sg12864j4 (128x64), but I have no idea how to wire and configure.
I tried different wiring and configurations but nothing work.

Can you explain me how to do?

Thank you  smiley-grin

Oliver
Logged

Greenville, IL
Offline Offline
Edison Member
*
Karma: 15
Posts: 1328
Warning Novice on board! 0 to 1 chance of errors!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


  Have you looked at this example? Read through it and see if your unit is listed. It covers many GLCD types and many Arduino board types.

http://www.arduino.cc/playground/Code/GLCDks0108
Logged


Brussels - Belgium
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Hello world
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, it is apparently a Pinout B Panel (Digitron SG12864J4 is listed)

Here is my wiring, following the table:


Is this correct?
Also, I am unable to configure the config files correctly.

This is the pin configuration of the lcd:
http://www.digitron.com.hk/sg12864j.htm





Logged

Greenville, IL
Offline Offline
Edison Member
*
Karma: 15
Posts: 1328
Warning Novice on board! 0 to 1 chance of errors!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


  From what I can see, your wiring looks like it could be correct but, that is a lot to look at in a picture.

Quote
Also, I am unable to configure the config files correctly.

Did you download and place the KS0108 Graphics LCD library in your library folder?

 If your code is not working or compiling show it to us using the "#" button next to the quote button.
Logged


Brussels - Belgium
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Hello world
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I have put the library ks0108 in the folder libraries.
When I try to run the example "GLCDexample.pde" it displays this message:

Code:
C:\Users\Admin\Downloads\arduino-1.0-windows\arduino-1.0\libraries\ks0108\ks0108.cpp:33:67: error: wiring.h: No such file or directory
C:\Users\Admin\arduino-1.0-windows\arduino-1.0\libraries\ks0108\ks0108.cpp: In member function 'void ks0108::Init(boolean)':
C:\Users\Admin\arduino-1.0-windows\arduino-1.0\libraries\ks0108\ks0108.cpp:505: error: 'OUTPUT' was not declared in this scope
C:\Users\Admin\arduino-1.0-windows\arduino-1.0\libraries\ks0108\ks0108.cpp:505: error: 'pinMode' was not declared in this scope
C:\Users\Admin\arduino-1.0-windows\arduino-1.0\libraries\ks0108\ks0108.cpp:511: error: 'delay' was not declared in this scope

I refer to this page:
http://www.arduino.cc/playground/Code/GLCDks0108
My lcd panel Digitron SG12864J4 is referenced as Pinout B panel

But it is written that the file "ks0108_mega.h" is compatible with the controller ATmega1280. What about my Mega 2560?
And the file Ks0108.h does not appear in the same manner:

Code:
/*
  ks0108.h - Arduino library support for ks0108 and compatable graphic LCDs
  Copyright (c)2008 Michael Margolis All right reserved
  mailto:memargolis@hotmail.com?subject=KS0108_Library

  The high level functions of this library are based on version 1.1 of ks0108 graphics routines
  written and copyright by Fabian Maximilian Thiele. His sitelink is dead but
  you can obtain a copy of his original work here:
  http://www.scienceprog.com/wp-content/uploads/2007/07/glcd_ks0108.zip

  Code changes include conversion to an Arduino C++ library, rewriting the low level routines
  to read busy status flag and support a wider range of displays, adding more flexibility
  in port addressing and improvements in I/O speed. The interface has been made more Arduino friendly
  and some convenience functions added.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

  Version:   1.0  - May  8 2008  - initial release
  Version:   1.0a - Sep  1 2008  - simplified command pin defines 
  Version:   1.0b - Sep 18 2008  - replaced <wiring.h> with boolean typedef for rel 0012 
  Version:   1.1  - Nov  7 2008  - restructured low level code to adapt to panel speed
                                 - moved chip and panel configuration into seperate header files   
     - added fixed width system font
  Version:   2   - May 26 2009   - second release
                                 - added support for Mega and Sanguino, improved panel speed tolerance, added bitmap support
     
*/

#include <inttypes.h>
typedef uint8_t boolean;
typedef uint8_t byte;
#include <avr/pgmspace.h>

#ifndef KS0108_H
#define KS0108_H

#define GLCD_VERSION 2 // software version of this library

// Chip specific includes
#if defined(__AVR_ATmega1280__)
#include "ks0108_Mega.h"  // include this for the Arduino Mega other ATmega1280 boards
#elif defined (__AVR_ATmega644__)  // TODO - check this define
#include "ks0108_Sanguino.h"   // include this for Sanguino or ATmega644 boards
#else
#include "ks0108_Arduino.h"  // include this for the Arduino or other ATmega168 boards
#endif

#include "ks0108_Panel.h"      // this contains LCD panel specific configuration


// macros for pasting port defines
#define GLUE(a, b)     a##b
#define PORT(x)        GLUE(PORT, x)
#define PIN(x)         GLUE(PIN, x)
#define DDR(x)         GLUE(DDR, x)

// paste together the port definitions if using nibbles
#define LCD_DATA_IN_LOW PIN(LCD_DATA_LOW_NBL) // Data I/O Register, low nibble
#define LCD_DATA_OUT_LOW PORT(LCD_DATA_LOW_NBL)  // Data Output Register - low nibble
#define LCD_DATA_DIR_LOW DDR(LCD_DATA_LOW_NBL) // Data Direction Register for Data Port, low nibble

#define LCD_DATA_IN_HIGH PIN(LCD_DATA_HIGH_NBL) // Data Input Register  high nibble
#define LCD_DATA_OUT_HIGH PORT(LCD_DATA_HIGH_NBL) // Data Output Register - high nibble
#define LCD_DATA_DIR_HIGH DDR(LCD_DATA_HIGH_NBL) // Data Direction Register for Data Port, high nibble

#define lcdDataOut(_val_) LCD_DATA_OUT(_val_)
#define lcdDataDir(_val_) LCD_DATA_DIR(_val_)

// macros to handle data output
#ifdef LCD_DATA_NIBBLES  // data is split over two ports
#define LCD_DATA_OUT(_val_) \
    LCD_DATA_OUT_LOW =  (LCD_DATA_OUT_LOW & 0xF0)| (_val_ & 0x0F); LCD_DATA_OUT_HIGH = (LCD_DATA_OUT_HIGH & 0x0F)| (_val_ & 0xF0);

#define LCD_DATA_DIR(_val_)\
    LCD_DATA_DIR_LOW =  (LCD_DATA_DIR_LOW & 0xF0)| (_val_ & 0x0F); LCD_DATA_DIR_HIGH = (LCD_DATA_DIR_HIGH & 0x0F)| (_val_ & 0xF0);
#else  // all data on same port (low equals high)
#define LCD_DATA_OUT(_val_) LCD_DATA_OUT_LOW = (_val_);
#define LCD_DATA_DIR(_val_) LCD_DATA_DIR_LOW = (_val_);
#endif


// Commands
#ifdef HD44102
#define LCD_ON 0x39
#define LCD_OFF 0x38
#define LCD_DISP_START 0x3E   // Display start page 0
#else
#define LCD_ON 0x3F
#define LCD_OFF 0x3E
#define LCD_DISP_START 0xC0
#endif

#define LCD_SET_ADD 0x40
#define LCD_SET_PAGE 0xB8

#define LCD_BUSY_FLAG 0x80

// Colors
#define BLACK 0xFF
#define WHITE 0x00

// useful user contants
#define NON_INVERTED false
#define INVERTED     true

// Font Indices
#define FONT_LENGTH 0
#define FONT_FIXED_WIDTH 2
#define FONT_HEIGHT 3
#define FONT_FIRST_CHAR 4
#define FONT_CHAR_COUNT 5
#define FONT_WIDTH_TABLE 6


// Uncomment for slow drawing
// #define DEBUG

typedef struct {
uint8_t x;
uint8_t y;
uint8_t page;
} lcdCoord;

typedef uint8_t (*FontCallback)(const uint8_t*);

uint8_t ReadPgmData(const uint8_t* ptr); //Standard Read Callback

#define DrawVertLine(x, y, length, color) FillRect(x, y, 0, length, color)
#define DrawHoriLine(x, y, length, color) FillRect(x, y, length, 0, color)
#define DrawCircle(xCenter, yCenter, radius, color) DrawRoundRect(xCenter-radius, yCenter-radius, 2*radius, 2*radius, radius, color)
#define ClearScreenX() FillRect(0, 0, (DISPLAY_WIDTH-1), (DISPLAY_HEIGHT-1), WHITE)
#define ClearSysTextLine(_line) FillRect(0, (line*8), (DISPLAY_WIDTH-1), ((line*8)+ 7), WHITE )

class ks0108  // shell class for ks0108 glcd code
{
  private:
    lcdCoord Coord;
    boolean Inverted;
    FontCallback     FontRead;
    uint8_t FontColor;
    const uint8_t* Font;
uint8_t ReadData(void);
uint8_t DoReadData(uint8_t first);
void WriteCommand(uint8_t cmd, uint8_t chip);
void WriteData(uint8_t data); // experts can make this public but the functionality is not documented
inline void Enable(void);
inline void SelectChip(uint8_t chip);
void WaitReady( uint8_t chip);
  public:
    ks0108();
// Control functions
void Init(boolean invert);
    void GotoXY(uint8_t x, uint8_t y);
// Graphic Functions
void ClearPage(uint8_t page, uint8_t color);
void ClearScreen(uint8_t color = WHITE);
    void DrawLine(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t color);
    void DrawRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color);
void DrawRoundRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t radius, uint8_t color);
    void FillRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color);
    void InvertRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height);
    void SetInverted(boolean invert);
    void SetDot(uint8_t x, uint8_t y, uint8_t color);
void DrawBitmap(const uint8_t * bitmap, uint8_t x, uint8_t y, uint8_t color);

    // Font Functions
    void SelectFont(const uint8_t* font, uint8_t color=BLACK, FontCallback callback=ReadPgmData); // defualt arguments added, callback now last arg
    int PutChar(char c);
    void Puts(char* str);
    void Puts_P(PGM_P str);
void PrintNumber(long n);
void CursorTo( uint8_t x, uint8_t y); // 0 based coordinates for fixed width fonts (i.e. systemFont5x7)

    uint8_t CharWidth(char c);
    uint16_t StringWidth(char* str);
    uint16_t StringWidth_P(PGM_P str);
};

extern ks0108 GLCD;   
#endif

How to configure this? :
#define CSEL1   14 (Analog pin 0)
 #define CSEL2   15 (Analog pin 1)
 #define R_W     16 (Analog pin 2)
 #define D_I     17 (Analog pin 3)
 #define EN      18 (Analog pin 4)



Logged

Greenville, IL
Offline Offline
Edison Member
*
Karma: 15
Posts: 1328
Warning Novice on board! 0 to 1 chance of errors!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


 The only difference between the Mega1280 and 2560 is the flash memory is bigger on the 2560.

 Change this part of the code
Code:
// Chip specific includes
#if defined(__AVR_ATmega1280__)
#include "ks0108_Mega.h"  // include this for the Arduino Mega other ATmega1280 boards
to this:
Code:
// Chip specific includes
#if defined(__AVR_ATmega2560__)
#include "ks0108_Mega.h"  // include this for the Arduino Mega other ATmega1280 boards


 The Arduino 1.0 IDE has a few things that do not work with previous libraries and did not want to compile the code because of the same errors that you got.
However, if you download Arduino 0023 at http://arduino.cc/en/Main/Software, then install the library in that IDE you can get the code to compile.

I used the table and found the pin assignments for your #define questions.

 #define CSEL1   33
 #define CSEL2   34
 #define R_W     35
 #define D_I       36
 #define EN        37

I then took your code to the Arduino 0023 and added "minimum" void setup and void main. It compiles now. You will need more work to get any screen display with just that though. All of the code you posted is functions and macros for making objects on the screen. You define those things in the first part of the sketch and then you use them in the main part of the code.

Code:
/*
  ks0108.h - Arduino library support for ks0108 and compatable graphic LCDs
  Copyright (c)2008 Michael Margolis All right reserved
  mailto:memargolis@hotmail.com?subject=KS0108_Library

  The high level functions of this library are based on version 1.1 of ks0108 graphics routines
  written and copyright by Fabian Maximilian Thiele. His sitelink is dead but
  you can obtain a copy of his original work here:
  http://www.scienceprog.com/wp-content/uploads/2007/07/glcd_ks0108.zip

  Code changes include conversion to an Arduino C++ library, rewriting the low level routines
  to read busy status flag and support a wider range of displays, adding more flexibility
  in port addressing and improvements in I/O speed. The interface has been made more Arduino friendly
  and some convenience functions added.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

  Version:   1.0  - May  8 2008  - initial release
  Version:   1.0a - Sep  1 2008  - simplified command pin defines 
  Version:   1.0b - Sep 18 2008  - replaced <wiring.h> with boolean typedef for rel 0012 
  Version:   1.1  - Nov  7 2008  - restructured low level code to adapt to panel speed
                                 - moved chip and panel configuration into seperate header files   
     - added fixed width system font
  Version:   2   - May 26 2009   - second release
                                 - added support for Mega and Sanguino, improved panel speed tolerance, added bitmap support
     
*/

#include <inttypes.h>
typedef uint8_t boolean;
typedef uint8_t byte;
#include <avr/pgmspace.h>

#ifndef KS0108_H
#define KS0108_H

#define GLCD_VERSION 2 // software version of this library

// Chip specific includes
#if defined(__AVR_ATmega2560__)
#include "ks0108_Mega.h"  // include this for the Arduino Mega other ATmega1280 boards
#elif defined (__AVR_ATmega644__)  // TODO - check this define
#include "ks0108_Sanguino.h"   // include this for Sanguino or ATmega644 boards
#else
#include "ks0108_Arduino.h"  // include this for the Arduino or other ATmega168 boards
#endif

#include "ks0108_Panel.h"      // this contains LCD panel specific configuration


// macros for pasting port defines
#define GLUE(a, b)     a##b
#define PORT(x)        GLUE(PORT, x)
#define PIN(x)         GLUE(PIN, x)
#define DDR(x)         GLUE(DDR, x)

// paste together the port definitions if using nibbles
#define LCD_DATA_IN_LOW PIN(LCD_DATA_LOW_NBL) // Data I/O Register, low nibble
#define LCD_DATA_OUT_LOW PORT(LCD_DATA_LOW_NBL)  // Data Output Register - low nibble
#define LCD_DATA_DIR_LOW DDR(LCD_DATA_LOW_NBL) // Data Direction Register for Data Port, low nibble

#define LCD_DATA_IN_HIGH PIN(LCD_DATA_HIGH_NBL) // Data Input Register  high nibble
#define LCD_DATA_OUT_HIGH PORT(LCD_DATA_HIGH_NBL) // Data Output Register - high nibble
#define LCD_DATA_DIR_HIGH DDR(LCD_DATA_HIGH_NBL) // Data Direction Register for Data Port, high nibble

#define lcdDataOut(_val_) LCD_DATA_OUT(_val_)
#define lcdDataDir(_val_) LCD_DATA_DIR(_val_)

// macros to handle data output
#ifdef LCD_DATA_NIBBLES  // data is split over two ports
#define LCD_DATA_OUT(_val_) \
    LCD_DATA_OUT_LOW =  (LCD_DATA_OUT_LOW & 0xF0)| (_val_ & 0x0F); LCD_DATA_OUT_HIGH = (LCD_DATA_OUT_HIGH & 0x0F)| (_val_ & 0xF0);

#define LCD_DATA_DIR(_val_)\
    LCD_DATA_DIR_LOW =  (LCD_DATA_DIR_LOW & 0xF0)| (_val_ & 0x0F); LCD_DATA_DIR_HIGH = (LCD_DATA_DIR_HIGH & 0x0F)| (_val_ & 0xF0);
#else  // all data on same port (low equals high)
#define LCD_DATA_OUT(_val_) LCD_DATA_OUT_LOW = (_val_);
#define LCD_DATA_DIR(_val_) LCD_DATA_DIR_LOW = (_val_);
#endif


// Commands
#ifdef HD44102
#define LCD_ON 0x39
#define LCD_OFF 0x38
#define LCD_DISP_START 0x3E   // Display start page 0
#else
#define LCD_ON 0x3F
#define LCD_OFF 0x3E
#define LCD_DISP_START 0xC0
#endif

#define LCD_SET_ADD 0x40
#define LCD_SET_PAGE 0xB8

#define LCD_BUSY_FLAG 0x80

// Colors
#define BLACK 0xFF
#define WHITE 0x00

// useful user contants
#define NON_INVERTED false
#define INVERTED     true

// Font Indices
#define FONT_LENGTH 0
#define FONT_FIXED_WIDTH 2
#define FONT_HEIGHT 3
#define FONT_FIRST_CHAR 4
#define FONT_CHAR_COUNT 5
#define FONT_WIDTH_TABLE 6


// Uncomment for slow drawing
// #define DEBUG

typedef struct {
uint8_t x;
uint8_t y;
uint8_t page;
} lcdCoord;

typedef uint8_t (*FontCallback)(const uint8_t*);

uint8_t ReadPgmData(const uint8_t* ptr); //Standard Read Callback

#define DrawVertLine(x, y, length, color) FillRect(x, y, 0, length, color)
#define DrawHoriLine(x, y, length, color) FillRect(x, y, length, 0, color)
#define DrawCircle(xCenter, yCenter, radius, color) DrawRoundRect(xCenter-radius, yCenter-radius, 2*radius, 2*radius, radius, color)
#define ClearScreenX() FillRect(0, 0, (DISPLAY_WIDTH-1), (DISPLAY_HEIGHT-1), WHITE)
#define ClearSysTextLine(_line) FillRect(0, (line*8), (DISPLAY_WIDTH-1), ((line*8)+ 7), WHITE )

class ks0108  // shell class for ks0108 glcd code
{
  private:
    lcdCoord Coord;
    boolean Inverted;
    FontCallback     FontRead;
    uint8_t FontColor;
    const uint8_t* Font;
uint8_t ReadData(void);
uint8_t DoReadData(uint8_t first);
void WriteCommand(uint8_t cmd, uint8_t chip);
void WriteData(uint8_t data); // experts can make this public but the functionality is not documented
inline void Enable(void);
inline void SelectChip(uint8_t chip);
void WaitReady( uint8_t chip);
  public:
    ks0108();
// Control functions
void Init(boolean invert);
    void GotoXY(uint8_t x, uint8_t y);
// Graphic Functions
void ClearPage(uint8_t page, uint8_t color);
void ClearScreen(uint8_t color = WHITE);
    void DrawLine(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t color);
    void DrawRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color);
void DrawRoundRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t radius, uint8_t color);
    void FillRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color);
    void InvertRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height);
    void SetInverted(boolean invert);
    void SetDot(uint8_t x, uint8_t y, uint8_t color);
void DrawBitmap(const uint8_t * bitmap, uint8_t x, uint8_t y, uint8_t color);

    // Font Functions
    void SelectFont(const uint8_t* font, uint8_t color=BLACK, FontCallback callback=ReadPgmData); // defualt arguments added, callback now last arg
    int PutChar(char c);
    void Puts(char* str);
    void Puts_P(PGM_P str);
void PrintNumber(long n);
void CursorTo( uint8_t x, uint8_t y); // 0 based coordinates for fixed width fonts (i.e. systemFont5x7)

    uint8_t CharWidth(char c);
    uint16_t StringWidth(char* str);
    uint16_t StringWidth_P(PGM_P str);
};

extern ks0108 GLCD;   
#endif

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:
 
}
Logged


Greenville, IL
Offline Offline
Edison Member
*
Karma: 15
Posts: 1328
Warning Novice on board! 0 to 1 chance of errors!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


 Here is an example code to get you something to show progress.

Code:
/*
 * ks0108 GLCDexample
 * (example sketch from original ks0108 library)
 *
 * 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 <glcd.h>
#include "fonts/Arial14.h"         // proportional font
#include "fonts/SystemFont5x7.h"   // system font
#include "bitmaps/ArduinoIcon.h"     // bitmap
//#include "include/glcd_Deprecated.h"

/*
 * Check for small displays as this code was written
 * before small displays were supported.
 */
#if DISPLAY_HEIGHT < 64
#error ks0108 example requires a display at least 64 pixels tall
#endif
#if DISPLAY_WIDTH < 128
#error ks0108 example requires a display at least 128 pixels wide
#endif

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

void setup(){
  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
}
Logged


Brussels - Belgium
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Hello world
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok thanks!

Now it works with the version 0023.
I tried the Arduino version 1.0 with the GLCD library v3 but I am unable to configure it
Logged

UK
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys!
Sorry to resurrect/hijack the this thread. It looks like I have exactly the same kit as the fellow here. I've not been able to make anything appear on the screen. Strangely enough, adjusting the contrast knob doesn't do anything to the screen either. The pixels remain the same shade.

I have checked the wiring and am satisfied that the connections have been made and the wires are going to the right places.

I'm using the 0023 version of the Arduino software with the GLCD library and have uploaded the example program. I have made the change from
#if defined(__AVR_ATmega1280__)
to
#if defined(__AVR_ATmega2560__)
in the code.

Is it possible that my LCD screen is faulty? What are the other things I can look into to try and crack this?

Thanks for any help!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

having the same problem as pyro-dragon.
I managed to compile and upload cyclegadgets code using IDE 0023. But screen stays black/dark.

Also, I changed in ks0108.h:
This: #if defined(__AVR_ATmega1280__)
To this: #if defined(__AVR_ATmega2560__)


Since I got GLCDexample.pde to work and uploaded it, it shouldn't be that hard to get the display to work.
Maybe my wireing is wrong :/




Also I left the table in ks0108_Mega.h untouched:
 #define CSEL1   33
 #define CSEL2   34
 #define R_W     35
 #define D_I       36
 #define EN        37

any ideas?
thx


Erm, I think I know what it is, I didn't notice that horizontal-cap in the middle of the board ^^
Have to check on that later.

OMG, yes that was it. How embarrassing ^^
« Last Edit: March 06, 2012, 11:00:10 am by rancor187 » Logged

Pages: [1]   Go Up
Jump to: