Author Topic: Help NANO How to Drive GC9A01 LCD Display  (Read 2941 times)

0 Members and 2 Guests are viewing this topic.

Online daisizhouTopic starter

  • Frequent Contributor
  • **
  • Posts: 889
  • Country: cn
Help NANO How to Drive GC9A01 LCD Display
« on: December 12, 2023, 11:54:43 am »
I watched this video--->
https://dronebotworkshop.com/gc9a01/
According to the instructions on the website, I successfully connected Arduino nano and GC9A01, and successfully lit up the test circuit.
When I successfully installed in the ARDUINO IDE https://github.com/adafruit/adafruit_gc9a01a This driver library.
Try to reproduce the adafruit as shown in the video_ When driving the example circuit of gc9a01a, but the screen cannot be lit up.
I don't know why,Can anyone tell me why? thanks
daisizhou#sina.com #=@
 

Offline coromonadalix

  • Super Contributor
  • ***
  • Posts: 6595
  • Country: ca
Re: Help NANO How to Drive GC9A01 LCD Display
« Reply #1 on: December 12, 2023, 12:55:05 pm »
some example here  :

https://reference.arduino.cc/reference/en/libraries/adafruit-gc9a01a/

lots of comments in the ino code, and  put the included librairies  where they need to be ....


unless you select the wrong arduino pcb, clock settings etc ...  it should  work  if no errors in the pinouts

AND pls  don't forget  we are in english forums     your language in arduino is not understood ?
« Last Edit: December 12, 2023, 12:58:57 pm by coromonadalix »
 

Online daisizhouTopic starter

  • Frequent Contributor
  • **
  • Posts: 889
  • Country: cn
Re: Help NANO How to Drive GC9A01 LCD Display
« Reply #2 on: December 12, 2023, 01:10:20 pm »
Thank you for your reply.
My library installation location is correct,In the IDE software, the sample program has completed compilation and I see a prompt indicating successful upload.
But I don't know why GC9A01 just doesn't display the test program,I am referring to the testing example program for gc9a01
daisizhou#sina.com #=@
 

Offline darkspr1te

  • Frequent Contributor
  • **
  • Posts: 357
  • Country: zm
Re: Help NANO How to Drive GC9A01 LCD Display
« Reply #3 on: December 12, 2023, 02:32:40 pm »
I would check a couple of things , In your code it does not config the backlight pin but in the example online it does,


Code: [Select]

  tft.begin();


#if defined(TFT_BL)
  pinMode(TFT_BL, OUTPUT);
  digitalWrite(TFT_BL, HIGH); // Backlight on
#endif // end TFT_BL






Also you "may" have to specify the SPI port , in the lib code it shows a few ways to specify the pins and SPI port


Code: [Select]

 Adafruit_GC9A01A(int8_t _CS, int8_t _DC, int8_t _MOSI, int8_t _SCLK,
                   int8_t _RST = -1, int8_t _MISO = -1);
  Adafruit_GC9A01A(int8_t _CS, int8_t _DC, int8_t _RST = -1);
#if !defined(ESP8266)
  Adafruit_GC9A01A(SPIClass *spiClass, int8_t dc, int8_t cs = -1,
                   int8_t rst = -1);
#endif // end !ESP8266
  Adafruit_GC9A01A(tftBusWidth busWidth, int8_t d0, int8_t wr, int8_t dc,
                   int8_t cs = -1, int8_t rst = -1, int8_t rd = -1);


in the above code snippet the first Adatafruit_GC9A01A declare you include all the pins needed, in the second you only provide chip select, Data/Command and reset pins, third example you provide the spi port, chip select and data/command and reset pins. The last one is for models with 8/16 bit data bus so is different from SPI versions in that is has 8/16 additional wires for data and you provide the first pin of the GPIO port , eg GPIOB Pin0 and it will use pin0 up to pin 7 ,




hope that helps.
Also do check you are providing the correct value in the correct place as you will notice in the sample above sometimes is has (DC,CS) and other times it's (CS,DC) so try swapping those about too.






darkspr1te



 

Online daisizhouTopic starter

  • Frequent Contributor
  • **
  • Posts: 889
  • Country: cn
Re: Help NANO How to Drive GC9A01 LCD Display
« Reply #4 on: December 13, 2023, 12:07:13 am »
Thanks.
I directly connected the backlight pin to VCC-3.3V.

Please note that in the first test program, I successfully lit up the test circuit.So none of my pins have changed.
In the video, it was mentioned that during the testing of the "graphicstest" sample program, it was necessary to change pin DC9 to pin 7. I also made the same modifications, but the result still did not light up the screen
« Last Edit: December 13, 2023, 02:37:25 am by daisizhou »
daisizhou#sina.com #=@
 

Offline coromonadalix

  • Super Contributor
  • ***
  • Posts: 6595
  • Country: ca
Re: Help NANO How to Drive GC9A01 LCD Display
« Reply #5 on: December 13, 2023, 03:11:10 am »
i would avoid  the pin d13, its notorious to create some problems   

because it as normaly a led on it


take time to check the demo files and check your pinout vs your coding,  changing this and that doesn't help

because you have to change your code accordingly, and mistakes happens

take time and re-check
 

Offline darkspr1te

  • Frequent Contributor
  • **
  • Posts: 357
  • Country: zm
Re: Help NANO How to Drive GC9A01 LCD Display
« Reply #6 on: December 13, 2023, 05:38:43 am »
Can you clarify light up the screen?
If i take the wording right it's not Illuminating the display, or did you mean it's not displaying any graphics ?
If you switch back to the other library provided by waveshare does it work ?


There are often difference's in library's meaning that you cannot do a direct like for like copy paste when it comes to the parameters for any given call.  having ported many of adafruits libs i can say this even more , while they all come from adafruit there is sometimes a disconnect or difference in the way they need to setup and called between libraries.


Without having this lcd myself I can only guess here but the first few things i would do is first start with comparing the code in a general way ,
so for the lcd init routine i would actualy first start at the arduino's h/w setup , in waveshare it's in the file DEV_config.cpp  but i'll leave the exercise of finding that same lines in the adafruit library up to the reader.
in the dev_config file you will see the GPIO setup and the SPI setup , what mode it uses etc.


once you confirmed your hardware is setup correct by the software I would then move onto confirming the lcd commands for config are done too, for the waveshare it's in the file LCD_Driver , there is often  similar lcd's out there that even if you send these commands wrong you will still get "something" on the screen even if it's just random, that at least means your hardware setup is correct, the software control of hardware is correct but the actual init values need tuning.




So if you got absolutely nothing on the screen i would look at how the software configures the spi and gpio, if you get random display then i would look at the init routines.


The adafruit library i note as usual support bitbash, default spi and specified spi (for devices where you are connected on a different spi port) so I personally would try the bitbash method to confirm the lib even works,


example


Code: [Select]

/*
from Header file - for reference
Adafruit_GC9A01A(int8_t _CS, int8_t _DC, int8_t _MOSI, int8_t _SCLK,
                   int8_t _RST = -1, int8_t _MISO = -1);


*/




#define TFT_CS D10 // Chip select
#define TFT_DC D7 // Data/command mode
#define TFT_BL D6 // Backlight control
#define TFT_MOSI D11 // SPI Out
#define TFT_SCLK D13 //Clock out - note led should flash during operation here failure to do so means a issue
#define TFT_MISO 0 //pin not actually used in bit bash as we dont read from the screen
#define TFT_RST D8 // Reset




Adafruit_GC9A01A tft(TFT_CS, TFT_DC,TFT_MOSI,TFT_SCLK,TFT_RST,TFT_MISO);







the above code is all you need to change in the example , if all is good it should display your test code.


if the above works then chances are you need to specify the SPI port in your setup , this is actually something i recommend as habit as some board designs may have hardware onboard connected to the spi ports (a lot of wave share boards do this)  so you my wish to use a unpopulated spi port.



darkspr1te

« Last Edit: December 13, 2023, 05:54:48 am by darkspr1te »
 

Online daisizhouTopic starter

  • Frequent Contributor
  • **
  • Posts: 889
  • Country: cn
Re: Help NANO How to Drive GC9A01 LCD Display
« Reply #7 on: December 13, 2023, 06:26:20 am »
Thanks.
Firstly, my physical connection has not changed (referring to the nano and GC9A01 connection lines)
After I uploaded the following code, GC9A01 displayed normal, showing an analog clock pattern.
Similarly, I uploaded Adaafruit_ The "graphicstest" example program for GC9A01A has no display and the screen display is black.
My NANO and GC9A01 connections have always been in the same order as the image in the attachment

Unfortunately, I haven't been able to find Adaafruit yet_ GC9A01 has its GPIO and SPI settings,
As described in the video, I will include the code TFT within the sample program_ Change DC 9 to DC 7, keep everything else the same as the video
Code: [Select]
#include <GFX_Thaana.h>

#include <TFT.h>

#include <TFT_eSPI.h>
#include "fonts.h"
#include "time.h"
#include "RTClib.h"
RTC_DS3231 rtc;
TFT_eSPI tft = TFT_eSPI();
TFT_eSprite img = TFT_eSprite(&tft);
#define color1 TFT_WHITE
#define color2  0x8410
#define color3 0x5ACB
#define color4 0x15B3
#define color5 0x00A3
volatile int counter = 0;
float VALUE;
float lastValue=0;
double rad=0.01745;
float x[360];
float y[360];
float px[360];
float py[360];
float lx[360];
float ly[360];
int r=104;
int sx=120;
int sy=120;
String cc[12]={"45","40","35","30","25","20","15","10","05","0","55","50"};
String days[]={"SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY"};
int start[12];
int startP[60];
const int pwmFreq = 5000;
const int pwmResolution = 8;
const int pwmLedChannelTFT = 0;
int angle=0;
bool onOff=0;
bool debounce=0;
String h,m,s,d1,d2,m1,m2;
void setup() {
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
}
pinMode(2,OUTPUT);
pinMode(0,INPUT_PULLUP);
pinMode(35,INPUT_PULLUP);
pinMode(13,INPUT_PULLUP);
digitalWrite(2,0);
ledcSetup(pwmLedChannelTFT, pwmFreq, pwmResolution);
ledcAttachPin(5, pwmLedChannelTFT);
ledcWrite(pwmLedChannelTFT, 200);
tft.init();
tft.setSwapBytes(true);
tft.fillScreen(TFT_BLACK);
img.setSwapBytes(true);
img.createSprite(240, 240);
img.setTextDatum(4);
int b=0;
int b2=0;
for(int i=0;i<360;i++)
{
x[i]=(r*cos(rad*i))+sx;
y[i]=(r*sin(rad*i))+sy;
px[i]=((r-16)*cos(rad*i))+sx;
py[i]=((r-16)*sin(rad*i))+sy;
lx[i]=((r-26)*cos(rad*i))+sx;
ly[i]=((r-26)*sin(rad*i))+sy;
if(i%30==0){
start[b]=i;
b++;
}
if(i%6==0){
startP[b2]=i;
b2++;
}
}
}
int lastAngle=0;
float circle=100;
bool dir=0;
int rAngle=359;
void loop() {
rAngle=rAngle-2;
DateTime now = rtc.now();
angle=now.second()*6;
s=String(now.second());
m=String(now.minute());
h=String(now.hour());
if(m.toInt()<10)
m="0"+m;
if(h.toInt()<10)
h="0"+h;
if(s.toInt()<10)
s="0"+s;
if(now.day()>10)
{
d1=now.day()/10;
d2=now.day()%10;
}
else
{
d1="0";
d2=String(now.day());
}
if(now.month()>10)
{
m1=now.month()/10;
m2=now.month()%10;
}
else
{
m1="0";
m2=String(now.month());
}
if(angle>=360)
angle=0;
if(rAngle<=0)
rAngle=359;
if(dir==0)
circle=circle+0.5;
else
circle=circle-0.5;
if(circle>140)
dir=!dir;
if(circle<100)
dir=!dir;
if(angle>-1)
{
lastAngle=angle;
VALUE=((angle-270)/3.60)*-1;
if(VALUE<0)
VALUE=VALUE+100;
img.fillSprite(TFT_BLACK);
img.fillCircle(sx,sy,124,color5);
img.setTextColor(TFT_WHITE,color5);
img.drawString(days[now.dayOfTheWeek()],circle,120,2);
for(int i=0;i<12;i++)
if(start[i]+angle<360){
img.drawString(cc[i],x[start[i]+angle],y[start[i]+angle],2);
img.drawLine(px[start[i]+angle],py[start[i]+angle],lx[start[i]+angle],ly[start[i]+angle],color1);
}
else
{
img.drawString(cc[i],x[(start[i]+angle)-360],y[(start[i]+angle)-360],2);
img.drawLine(px[(start[i]+angle)-360],py[(start[i]+angle)-360],lx[(start[i]+angle)-360],ly[(start[i]+angle)-360],color1);
}
img.setFreeFont(&DSEG7_Modern_Bold_20);
img.drawString(s,sx,sy-36);
img.setFreeFont(&DSEG7_Classic_Regular_28);
img.drawString(h+":"+m,sx,sy+28);
img.setTextFont(0);
img.fillRect(70,86,12,20,color3);
img.fillRect(84,86,12,20,color3);
img.fillRect(150,86,12,20,color3);
img.fillRect(164,86,12,20,color3);
img.setTextColor(0x35D7,TFT_BLACK);
img.drawString("MONTH",84,78);
img.drawString("DAY",162,78);
img.setTextColor(TFT_ORANGE,TFT_BLACK);
img.drawString("VOLOS PROJECTS",120,174);
img.drawString("***",120,104);
img.setTextColor(TFT_WHITE,color3);
img.drawString(m1,77,96,2);
img.drawString(m2,91,96,2);
img.drawString(d1,157,96,2);
img.drawString(d2,171,96,2);
for(int i=0;i<60;i++)
if(startP[i]+angle<360)
img.fillCircle(px[startP[i]+angle],py[startP[i]+angle],1,color1);
else
img.fillCircle(px[(startP[i]+angle)-360],py[(startP[i]+angle)-360],1,color1);
img.fillTriangle(sx-1,sy-70,sx-5,sy-56,sx+4,sy-56,TFT_ORANGE);
img.fillCircle(px[rAngle],py[rAngle],6,TFT_RED);
img.pushSprite(0, 0);
}
}
« Last Edit: December 13, 2023, 06:42:13 am by daisizhou »
daisizhou#sina.com #=@
 

Offline coromonadalix

  • Super Contributor
  • ***
  • Posts: 6595
  • Country: ca
Re: Help NANO How to Drive GC9A01 LCD Display
« Reply #8 on: December 13, 2023, 11:42:03 am »
1st  you call your librairies 

second you call your pins definition

i think you need to understand the arduino world ?

and in the void setup   you add you fonts  graphics images  etc ...


your code sounds like you put everything in one place, hoping to make something working ?

here's an example of the adafruit code    with edited pinout to suit your given image

NOW
#define TFT_CS D10 // Chip select
#define TFT_DC D7 // Data/command
#define TFT_BL D8 // Backlight control        but should be a reset function  ???  i dont see "rst" calls ?

WAS
#define TFT_CS D1 // Chip select
#define TFT_DC D3 // Data/command
#define TFT_BL D6 // Backlight control         but should be a reset function  ???  i dont see "rst" calls ?

see  the changes

my guessing's  since i dont know this lcd
the reset pin must be defined ?  or not
the backlight pin must be defined  ?  or not
still miss the SCL and DIN assignments  ?

you have to comment out unneeded pinout assignment,   it is clearly written  in the ino code


other examples,  and you took some picture from them i think ....
https://eazytronic.com/gc9a01-with-arduino/
https://dronebotworkshop.com/gc9a01/
https://forum.arduino.cc/t/240x240-round-display-with-gc9a01-driver-undocumented-command/661217
https://www.waveshare.com/wiki/1.28inch_LCD_Module


and sadly  the way i see,   you have to check in the libraries for the pinouts ??  witch i don't find this practical
« Last Edit: December 13, 2023, 12:24:32 pm by coromonadalix »
 

Online daisizhouTopic starter

  • Frequent Contributor
  • **
  • Posts: 889
  • Country: cn
Re: Help NANO How to Drive GC9A01 LCD Display
« Reply #9 on: December 13, 2023, 01:27:51 pm »
OK,Please see my test video
https://youtu.be/qNkt5T2ulJU
I have never found the "Adatafruit_GC9A01A" documentation on these pins,Pin explanations, definitions, and how to connect them

In the video below, the author does not suggest reconnecting the pins


So, I don't know how to connect them correctly in "Adatafruit_GC9A01A".
daisizhou#sina.com #=@
 

Offline darkspr1te

  • Frequent Contributor
  • **
  • Posts: 357
  • Country: zm
Re: Help NANO How to Drive GC9A01 LCD Display
« Reply #10 on: December 13, 2023, 04:17:20 pm »
Did you try my example code above ?
can you connect RST to 3.3v and try the code ? if rst is not used or pulled low or floating could cause a issue, tying it to 3.3v eliminates this issues and you can move onto other issues.


To explain the pins in case you didnt know are as follows
DC = Data /Command, what this does is in one state any data you send on the MOSI/SPI out pin is either data to put on screen or in a memory registry affecting behavior or a command e.g CMD = 0x2 will soft reset lcd
RST = Reset, Tie to 3.3v as a test measure
MOSI = Master out Slave in , this is the data output from the mcu to the screen
MISO = Master In Slave Out , this is data from a device or screen, not used here
CS = Chip select, When this pin goes low the LCD knows you are talking to it, you can tie this to ground to test too in some case and the ship will always listen but can cause issues in some devices which use the change in chip select to do operations as well and not having that change will cause bad operation
CLK = Clock signal, The lcd samples the MOSI pin to see if it's high or low,


As far as documentation goes there is a lot out there but you need to search for it and in a lot of cases you have to learn about things like what SPI is to start to then understand how to read the .h and .cpp of the library to see how it's called in your code.


if you look in the Adafruit_GC9A01A.h in the git hub you will see at line 106 it states
Code: [Select]

 Adafruit_GC9A01A(int8_t _CS, int8_t _DC, int8_t _MOSI, int8_t _SCLK,
                   int8_t _RST = -1, int8_t _MISO = -1);


it is defining the "bitbash" version of sending data to the lcd,  this is often used because of no available spi port or quick testing. it means no on board mcu device to handle the lcd is setup other than the pins you pass to the code , in above example is says int8_t _CS , its integer 8 bit and the _CS is a reference used in the library but you must pass it the gpio pin number you have wired it too in this case CS is CHIP select,
now pin numbers in arduino ide come in more than one name but mean the same thing, so when you for example do



pinMode(2,OUTPUT);
or
pinMode(D0,OUTPUT);



if you want a REALY in depth of what the pins mean then i do advise you read the data sheet, even if you dont understand it it yet they do in time make sense the more you read them.
https://www.buydisplay.com/download/ic/GC9A01A.pdf


Now i noticed from your video you have the version that is labeled different to the pictures so the pins are as follows
BLK = BackLight 
CS = CS , Chip Select , Pin 10
DC =DC , Data/Command , Pin 7
RES = RST , Reset , pin 8 or Tie to 3.3v
SCL = CLK , Clock , Pin 13 - led pin - should flash
SDA = MOSI , Data out , pin 11



Code: [Select]
#define TFT_CS 10// Chip select
#define TFT_DC 7 // Data/command mode
#define TFT_BL D6 // Backlight control
#define TFT_MOSI 11 // SPI Out AKA SDA
#define TFT_SCLK 13 //Clock out AKA SCL  - note led should flash during operation here failure to do so means a issue
#define TFT_MISO -1 //pin not actually used in bit bash mode as we dont read from the screen
#define TFT_RST 8 // AKA RES ,Reset

Adafruit_GC9A01A tft(TFT_CS, TFT_DC,TFT_MOSI,TFT_SCLK,TFT_RST,TFT_MISO);




darkspr1te





 
The following users thanked this post: coromonadalix

Online daisizhouTopic starter

  • Frequent Contributor
  • **
  • Posts: 889
  • Country: cn
Re: Help NANO How to Drive GC9A01 LCD Display
« Reply #11 on: December 13, 2023, 11:50:51 pm »
Thanks.
I added your suggestion in the code, and now the display screen is showing normally. Thank you
daisizhou#sina.com #=@
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf