Go Down

Topic: ST7565 GLCD Library Functions (Read 18808 times) previous topic - next topic

drrockandroll

I've looked all over but I have yet to find a good repository of just how to use the ST7565 library.  I'm using a ST7565 in a project and am having to do a lot of trial-and-error to figure out how to display what I want.  Is there a guide similar to the one for the GLCD library, found here: [/http://www.arduino.cc/playground/uploads/Code/GLCD_Documentation.pdfntation.pdf[/url]

drrockandroll

Sorry if my original post was short on details.  I have a lot of questions, some of which include:

-Is there a list of functions and their arguments?

-Why is glcd.**** used to call those functions?

-What do the glcd.display and glcd.clear functions do?  The glcd.clear function doesn't seem to actually clear the display.

-How do I draw a bitmap?

-What can I read to better answer these questions myself in the future?

bperrybap

#2
Jan 21, 2012, 06:01 am Last Edit: Jan 21, 2012, 06:05 am by bperrybap Reason: 1
dr,
I'm not the author of that library (I'm the author of the GLCD library).
It takes an immense amount of time and effort to document stuff like this. Most folks simply don't bother
much with this part of a project as many people don't seem to treat documentation as being equally
if not more important than the actual code.

I took a quick look at LadyAda's tutorial:
http://www.ladyada.net/learn/lcd/st7565.html
and Paul's Teensy site:
http://www.pjrc.com/teensy/td_libs_ST7565.html

From what I've seen, in order to see the functions and their arguments, you will have to actually
look at the source code.
Take a look at the library header file: ST7565.h
All the functions under the "public:" down to "private:"
are the API functions.

As to why you use "glcd.***" that is controlled by the
object name you select.

For example, if you look in the example code you will
see a few lines that look like:
Code: [Select]

// The setup() method runs once, when the sketch starts

ST7565 glcd(9, 8, 7, 6, 5);


You see that "glcd" there?
That is the name of the ST7565 library object.
Whatever name you use there is the object name and will be the prefix
to any function you call.
So if you were to change the name to "drrock"
by using this constructor:
Code: [Select]
ST7565 drrock(9, 8, 7, 6, 5);
Then all your functions would be
drrock.***
or something like drrock.clear(), drrock.display(), etc...

I had a brief look at the code and part of why you are not seeing results
is because of how they wrote their code. They use a local frame buffer that does
not automatically flush to the physical display.

What this means is that nothing you do will affect the way display looks until you
call display() to flush the local frame buffer to the physical display.

So when you call functions like clear(), setpixel(), drawcircle(), etc...
the local frame buffer is updated but you will not see any of those updates on the lcd
screen until you call display().

So have to call display() whenever you want to update the actual lcd display.

While having to manually do the framebuffer flushes by calling display() may seem awkward,
it can actually boost performance because the processor can do several updates to the local
the memory before having to push the frame buffer to the lcd.

Hope that helps get you started.

--- bill


olikraus

#3
Jan 21, 2012, 07:35 am Last Edit: Jan 21, 2012, 07:45 am by olikraus Reason: 1
Hi

What I see at the moment: There are several vendors for displays which fit into the Arduino World. All come with some software for the Arduino IDE. However the documentation for this "vendor software" often is, hmm, not so good. Sometimes I think that the hardware is sold with some software just to prove that the hardware is working.

Luckily there is this forum, where people not only try to give good answers, but also try to create a good documentation for their software (thinking of Bill's GLCD documentation for the KS0108 devices).

I try to do the same for the ST7565 devices. The first version of this ST7565 lib is here:
http://code.google.com/p/dogm128/
There is also a reference manual and examples here:
http://code.google.com/p/dogm128/wiki/cpp

I am currently working on a new, more general lib for ST7565 (and similar) devices:
http://code.google.com/p/u8glib/
While still beta, the ST7565 support should be fine. Additionally to the reference manual (http://code.google.com/p/u8glib/wiki/userreference) I started to write tutorials to discuss special parts of the library (http://code.google.com/p/u8glib/wiki/thelloworld).

Oliver

drrockandroll

bperrybap, thanks for the help.  I've got a better handle on how to work with this display after scrounging through the source code and making copious notes.  I still have a lot of questions, but I can at least see a way forward.

olikraus, I tried the dogm128 library before without success.  I changed the display type in dogm128.h to the ST7565 and the example programs compiled fine, but nothing was shown on the display.  In fact, if I ran a program that used the ST7565 library, then uploaded a program that used the dogm128 library, whatever was last on the display when running the ST7565-based program was frozen after uploading a dogm123-based program.  I gave up and switched back to using the ST7565 library, even though it lacks good documentation, because it at least worked without any fuss.  If you have any suggestions for what might get the dogm128 library to work, I'd love to hear them.  If it matters, I'm using an Arduino Uno with this ATMEGA328 chip and Arduino v1.0.  I downloaded dogm v1.13, which is Arduino 1.0-compatible.

I'll give the u8glib library a shot later this evening and post how it goes.

Thanks for your help everyone, I'm moving forward slowly but surely.

olikraus

Maybe you can give a more precise information which display you have.

Oliver

drrockandroll

Ok, so I figured out part of my problem with the libraries was improper wiring of the display.  If it's relevant, I'm using a CD4050BC to convert to 3.3V.

So, the ST7565 library uses the following pin assignments from the Arduino:

9 - SID (Serial Input Data)
8- SCLK (Serial Clock)
7 - RS/A0 (Data/Command Select)
6 - RST (Reset)
5 - CS (Chip Select)

The dogm library uses the following pin assignments:

13 - SCK (Serial Clock)
11 - MOSI (I'm not sure what this is--is the same as SID?)
10 - CS (Chip Select)
9 - A0 (Data/Command Select)

The u8glib library uses the following pin assignments:

13 - SCK (Serial Clock)
11 - SI(MOSI) (What made me assume that SID is the same as MOSI)
10 - CS (Chip Select)
? - A0 (I found some references to A0 in the code, but it wasn't clear what pin it should be, exactly)

I know I could change the pin assignments in the code, but I've just been rewiring the display to whatever each library requires.

So I've already established that the GLCD works properly and I can get it working with the ST7565 library.  I'd like to get it working with the other libraries since they have more functions that are relevant to what I want to do, but the display isn't doing anything when I connect it up and use those libraries.  The example programs for each library compiles properly, but nothing is displayed.  So I have a few questions:

What is MOSI?  I know it's master in/slave out, but what does it actually do?

Is MOSI the same as the "Serial Input Data"?  If not, what display connector should I be connecting to the expected MOSI pin on the Arduino?

Why don't the u8glib and dogm libraries require a reset pin?

Why doesn't the u8glib library explicitly state what pin is A0?

Any help is greatly appreciated.  I'm sure I'm doing something wrong in setting this display up for use with the dogm and u8glib libraries, I'm just not sure exactly where it is.

drrockandroll

Sorry Oliver, I was writing a reply as you were posting your question.

I'm using this ST7565 from Adafruit.  It differs slightly from the one on the page in that it has a 3-color LCD backlight, but otherwise appears identical.  The model on the back of the circuit board identifies it as TG12864H3-05A V1.0.  There's also a sticker identifying it as TG12864H3-04MA0 AD000294 2011.08.18.  I suspect the sticker was placed on it by Adafruit.

olikraus

Hi

There had been one person who contributed the Adafruit code for the dogm128 lib. I know that it once worked, but I do not own this device, so I am not able to maintain it. I only know, that it was different to the other displays with same controller.

The U8glib does not include the specific code for the Adafruit device. Maybe I can port the code from dogm128 to u8glib. But then I would need someone else to test it.

A0 pin:
It is always there, but often named different. Identical are:
RS: Register Select
DI: Data / Instruction

So A0, RS, DI are all the same.

Oliver

drrockandroll

Thanks for the advice Oliver.  I'd be glad to test code on the ST7565, if that's of any help.  Obviously I'm not of as much use as someone more experienced, but I'm willing to put for the the effort and learn as much as I can in the process.

olikraus

It seems that the Adafruit display is a TOPWAY LM6059 display.
I have added an experimental device to the u8glib: http://code.google.com/p/u8glib/downloads/list
So you could try the U8GLIB_LM6059() constructor with the Adafruit display. Please let me know if this works.

Thanks for testing!

Oliver

drrockandroll

Hi Oliver,

I got the ST7565 working using the dogm library, but still haven't had success with the u8glib library.

I've done a lot of troubleshooting to try to recreate the same configuration in which my display didn't work with the dogm library, including going back to other pin configurations and deleting/reinstalling the library, but haven't had any luck.  I think it's fair to say I hadn't configured something properly, but I just wish I could track down exactly what it was for others who may make the same mistakes in the future.  I know the hardware was configured properly since the display would work with the ST7565 library, but then wouldn't work with the dogm library.  Similarly, the uncommenting in the dogm128.h file is very straightforward, so I can't see how that would have contributed to the problem.

Realtime edit:  I think my problem may have been with the A0 pin definition.  It's not clear (to me, anyway) in the example code just what the A0 pin should be from a hardware standpoint.  Why is A0 shown as "read value" in the comments?

Ok, moving on...

Currently, my pin assignments are: 11-SID (MOSI), 13-SCK, 9-A0/RS, 6-RST, 10-CS

I uncommented line 54 (U8GLIB_LM6059) in the HelloWorld example program for the u8glib library.  When I upload the HelloWorld program with this modification, nothing is displayed.  If I then upload the dogm128 example program GraphicTest, it works as expected.

I'm not sure what I'm doing wrong, but would appreciate any guidance.

Also, would you like help in writing documentation for these libraries?  I'd like to do what I can so that noobs such as myself can better use them.  I may not be able to contribute a lot to debugging, but I think I can help out with this and will probably learn a lot in the process.

olikraus


Quote

Currently, my pin assignments are: 11-SID (MOSI), 13-SCK, 9-A0/RS, 6-RST, 10-CS

I uncommented line 54 (U8GLIB_LM6059) in the HelloWorld example program for the u8glib library.  When I upload the HelloWorld program with this modification, nothing is displayed.  If I then upload the dogm128 example program GraphicTest, it works as expected.


Did you also added the reset pin? Instead of
Code: [Select]
//U8GLIB_LM6059 u8g(13, 11, 10, 9);                    // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9

use
Code: [Select]
U8GLIB_LM6059 u8g(13, 11, 10, 9, 6);                    // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9

If the LM6059 device does not work, it might be also interesting to see if the LM6063 will show something on the display:
Code: [Select]
U8GLIB_LM6063 u8g(13, 11, 10, 9, 6);


I am glad that the dogm128 lib works.

Documentation: Will sent PM.

Oliver

drrockandroll

I hadn't added the reset pin, but it still is not working with the reset pin added.  Is there a reason the commented constructor calls don't include a reset pin assignment?

So to be clear, I have my display setup and working with the dogm128 library.  If I then switch to the examples using the u8glib library without changing any of the hardware, the u8glib example doesn't display anything.  This is the case for the U8GLIB_LM6059, U8GLIB_LM6063, and U8GLIB_DOGM128 constructors, all of which I tried with the (13, 11, 10, 9, 6) pin assignments.

olikraus

Hi

The Dogm128 lib remaps the pins to:
Code: [Select]
#define PIN_RST   6     // This is for the default Adafruit wiring scheme
#define PIN_SCK   8     // described in:
#define PIN_MOSI  9     // http://www.ladyada.net/learn/lcd/st7565.html
#define PIN_SS    5     // change these numbers to reflect your wiring.
#define PIN_A0_DEFAULT  7

This means, the constructor should be:
U8GLIB_LM6059(8, 9, 5, 7, 6)

As described in
http://code.google.com/p/u8glib/wiki/device
the reset pin is optional. For most of my displays, there is either no reset pin, or I constucted the reset via a cap and a resistor.

Hope, this helps

Oliver

Go Up