EmonGLCD+++++ GLCD_ST7565.h - with an mega 2560 / adafruit st7565

Hi all
I'm trying to use a arduino mega 2560 with an adafruit st7565 (http://www.ladyada.net/learn/lcd/st7565.html)

But im still a bit of green to ardunios and seem to be stuck, 

 

Anyway I'm having problems getting it working.. I Think i have the pins connected correctly as i can get the adafruit demo working and The GLCD-Demo works from jeelib but that has the line

ST7565 glcd(14, 4, 17, 7);

but the demos from GLCD_ST7565 dont seem to do anything.. And don't seem to need to reference any pins. They seem to be hard coded as

#define PIN_SID 14
#define PIN_SCLK 4
#define PIN_A0 17
#define PIN_RST 7

Unfortunately I would like to use the GLCD_ST7565 library as I'm trying to add more pages to the emonGLCD and running out of RAM so thought this would work..  (Iv got lots of jeenodes round the house getting data like humidity, CO2, Temps of rooms, Rads, In /out of boiler etc)

SID = Digital14 (Analog0) So Mega Digital14?
SCLK = Digital4
RS /A0 = Digital17 (Analog3) So Mega Digital17?
RST = Digital7
/CS = GND

Or am i completely wrong.. Any help would be great.. I think its to do with using ports not pins but as i said im new to this..

The top trace is using the ST7565.h library the bottom with the GLCD_ST7565.h lib

channel
0 SID Pin D14
1 A0/RS Pin D17
2 SCLK Pin D4
3 RST Pin D7

please see attached for logic trace.

Thanks
Rob

shadows's picture

Re: EmonGLCD+++++ GLCD_ST7565.h - with an mega 2560 / adafruit st7565

Hello Rob

On a mega 2560 analog0 is digital 54 and analog3 is digital 57

/Mark

robw's picture

Re: EmonGLCD+++++ GLCD_ST7565.h - with an mega 2560 / adafruit st7565

Thanks Mark..

What I'm after is the library is meant for the 328 chios and references 

#define PIN_SID 14
#define PIN_SCLK 4
#define PIN_A0 17
#define PIN_RST 7

So i think i should connect it like this.. 

SID = Digital14 (Analog0) So Mega Digital14?
SCLK = Digital4
RS /A0 = Digital17 (Analog3) So Mega Digital17?
RST = Digital7
/CS = GND

But I'm getting nothing.. But I'm not sure if when they say d14/a0 this really does map to the megas D14 pin or something else. like something in the main library.

Thanks.

shadows's picture

Re: EmonGLCD+++++ GLCD_ST7565.h - with an mega 2560 / adafruit st7565

Hi Rob

I've tried to edit GLCD_ST7565.cpp to

#define PIN_SID  54
#define PIN_SCLK 4
#define PIN_A0   57
#define PIN_RST  7

and tested it with my mega 2560 -- nothing

I have also tried with

#define PIN_SID  6
#define PIN_SCLK 4
#define PIN_A0   5
#define PIN_RST  7

and moved the wires to digital 6 and 5

nothing :-(

/Mark

 

 

robw's picture

Re: EmonGLCD+++++ GLCD_ST7565.h - with an mega 2560 / adafruit st7565

Thanks Mark..

Iv also tried the same 9,8,7,6 Pins and it fails :-(..  Its weird that the adafruit does work but the jeelabs one does not..

adafruit version can be found http://www.ladyada.net/learn/lcd/st7565.html

shadows's picture

Re: EmonGLCD+++++ GLCD_ST7565.h - with an mega 2560 / adafruit st7565

I can also get adafruit to work.

It may be that jeelabs using instructions found in mega328 but not in mega2560 ?

You must have a good Sunday :-)

robw's picture

Re: EmonGLCD+++++ GLCD_ST7565.h - with an mega 2560 / adafruit st7565

Found the answer

You need to uncomment the line

// Switch from fast direct bit flipping to slower Arduino bit writes.
#define slowSPI

in the GLCD_ST7565.cpp file  (sorry don't know line number as iv added to this file But its near the top..)

Now got the emonGLCD code running on an Ardunio Mega 2560.

Time to add some more pages to the GLCD.

shadows's picture

Re: EmonGLCD+++++ GLCD_ST7565.h - with an mega 2560 / adafruit st7565

Hi Rob

Nice to see you crack the code :-)

/Mark

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.