Go Down

Topic: How to control 2 graphic LCDs with one Arduino (Read 9 times) previous topic - next topic

Raoul6391

Hello

I plan to control 2 graphic LCD (http://www.sparkfun.com/products/710) using the KS0108 Graphics LCD library  (http://www.arduino.cc/playground/Code/GLCDks0108).

The library assumes you use one port (A,B or C) to connect one LCD.

I would like to know what I should modify in the library to use 2 LCDs?
Do I need to duplicate the library changing all functions name to address LCD 1 or LCD 2 (e.g. GLCD.ClearScreen1() for LCD 1 and GLCD.ClearScreen2() for LCD 2) ? Or is there any more elegant way to do it?
So far I am a user of the existing libraries but didn't try myself to write oneā€¦
Thank you for your support.

Raoul.

Note: I am using a Mega 2560


floresta

This is easy to do with the character mode LCDs and the same technique may very well work with graphical LCDs.  Check out this thread from the old forum: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1265969050

Don

liudr

I have to complain that either ks0108 or glcd library (if they're not the same) is pretty big in SRAM so hope two instances will work. Essentially like what floresta pointed out (the post), if you can, instantiate two GLCDs and with same data lines but different CS1 and CS2.

Raoul6391

Hi
Thank you for your quick reply, I will try it but seems it should work.
Raoul.

Raoul6391

Hi again
I am trying to use 2 instances of the graphic library; the issue here is that the pin assignment is done in the header file ( that it is not the case for LiquidCrystal)...

"To change pin assignments you must modify the ks0108.h header file. Find the section in the file that begins:

/********************************************************/
/* Configuration for assigning LCD bits to Arduino Pins */
/********************************************************/

You will see the defines for the five command pins with their default pin assignments:

        Name    Arduino pin number
#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)"


Do you have any idea to workaround? Maybe adding a function to the library to assign the pins instead of doing it in the header file?

Thank you.
Raoul.


Go Up