Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

display initialization problem #8

Open
copykatze opened this issue Jun 11, 2023 · 6 comments
Open

display initialization problem #8

copykatze opened this issue Jun 11, 2023 · 6 comments

Comments

@copykatze
Copy link

copykatze commented Jun 11, 2023

Sometimes the display does not initialize properly, it will only show some thin lines or a light grey background and it can't be written to by the program (apart from the display not showing anything the program works fine). Reseting the device by on/off or the reset button helps sometimes after a few tries, sometimes it seems to need "off-time", but I could not really figure out when it does not work and what gets it back on track. It is really unreliable like this. This happens on both of my T-keyboards.

What might cause this weirdness?

I found that when I enabled core debug level, at TFT_099.begin(); I get this log:

12:51:23.065 -> [   174][E][esp32-hal-gpio.c:102] __pinMode(): Invalid pin selected
12:51:23.097 -> [   174][E][esp32-hal-gpio.c:102] __pinMode(): Invalid pin selected
12:51:23.097 -> [   177][E][esp32-hal-gpio.c:102] __pinMode(): Invalid pin selected
12:51:23.195 -> [   283][E][esp32-hal-spi.c:227] spiAttachMISO(): SPI Does not have default pins on ESP32C3!

Could this be the cause of it? But those error messages will also be in the logs when it works. No idea how to debug this any further... :(

Any help appreciated, thanks and cheers!

@copykatze
Copy link
Author

copykatze commented Jun 11, 2023

In TFT_GC9D01N.hI found

#define TFT_MISO  -1
#define TFT_MOSI  10//21
#define TFT_SCLK  20//22
#define TFT_CS    -1//18  // Chip select control pin
#define TFT_DC    2  // Data Command control pin
#define TFT_RST   -1//27
#define TFT_BL    8//4

/*
#define TFT_MISO  -1
#define TFT_MOSI  21
#define TFT_SCLK  22
#define TFT_CS    18  // Chip select control pin
#define TFT_DC    2  // Data Command control pin
#define TFT_RST   27
#define TFT_BL    23//4
*/

It seems strange to me that TFT_MISO, TFT_CS and TFT_RST. are all defined -1 (does that mean "undefined?) and I wonder what that commented block of alternative definitions is all about... but on the other hand, this seems to align with the pinout description here.

@copykatze
Copy link
Author

Another observation: what seems to help is to power it on while connected to usb c power and then pressing the reset button. This method does not help without the device being plugged in.

So maybe the small battery does not provide enough power for the (tiny) display? But on the other side, the grey screen happens also while powering on when plugged in sometimes...

@alejovargas78
Copy link

Hello, I had the same problem, the solution is simple.

Open the library TFT_GC9D01N.cpp and disable the following lines

int TFT_GC9D01N_Class::begin()
{
pinMode(TFT_BL, OUTPUT);
pinMode(TFT_SCLK, OUTPUT);
//pinMode(TFT_MISO, OUTPUT);
pinMode(TFT_MOSI, OUTPUT);
pinMode(TFT_DC, OUTPUT);
//pinMode(TFT_CS, OUTPUT);
//pinMode(TFT_RST, OUTPUT);

Greetings from Bogota Col.

@copykatze
Copy link
Author

copykatze commented Jan 22, 2024

Thank you, @alejovargas78 !

Removing my previous reply, as it was completely unrelated (and created a separate issue for this)... When I failed to initialize the original display, I tried to attach a bigger one, which would even be better for my project. Now I will try the suggested approach to get the original display working reliable, which would also be great!

@copykatze
Copy link
Author

Unfortunately, I have the same result/problem with the adjustments in the library, still thanks for the suggestion!

@alejovargas78
Copy link

pinMode(TFT_MOSI, OUTPUT);
pinMode(TFT_DC, OUTPUT);
pinMode(TFT_BL, OUTPUT);
pinMode(TFT_SCLK, OUTPUT);
ledcSetup(1, 1000, 10);
ledcAttachPin(TFT_BL, 1);
ledcWrite(1, 0);
delay(100);

SPI.begin(TFT_SCLK, TFT_MISO, TFT_MOSI, TFT_CS);

int i = 2;
while (i--) {
    lcd_init();
    delay(200); /* code */
}
ledcWrite(1, 220);//开启背光

return 1;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants