I have an ESP32 connected to two displays:
- 1.28" round color display 240x240 pixel using GC9A01 driver for which I'm using TFT_eSPI library.
- 2.08" 256x64 monochrome display using SH1122 driver for which I'm using the U8G2 library.
I have managed to work with two 1.28" round displays but now I'm trying with 2 different type of displays and it doesn't work.
Code
#include <Arduino.h>
#include <U8g2lib.h>
#include "SPI.h"
#include <TFT_eSPI.h>
#include "NotoSansBold15.h"
U8G2_SH1122_256X64_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=SCL=*/ 18, /* data=SDA=*/ 23, /* cs=*/ 32, /* dc=*/ 13, /* reset=*/ 4);
TFT_eSPI tft = TFT_eSPI();
#define roundTft 33 //roundTft 33 // CS pin for round TFT
#define squareTft 32 // CS pin for monochrome display
void setup(void) {
/*pinMode(squareTft, OUTPUT);
digitalWrite(squareTft, LOW); // Activate monochrome display
u8g2.begin();
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_t0_17_mf);
u8g2.setCursor(00,10);
u8g2.print("Hello World");
u8g2.sendBuffer();
digitalWrite(squareTft, HIGH); // Deactivate monochrome display
delay(1000);
*/
pinMode(roundTft, OUTPUT);
tft.begin();
digitalWrite(roundTft, LOW); // Activate round TFT
tft.setTextColor(TFT_WHITE, TFT_BLACK, true);
tft.loadFont(NotoSansBold15);
tft.fillScreen(TFT_BLACK);
tft.setCursor(30, 40);
tft.print("Hello Round TFT");
delay(1000);
digitalWrite(roundTft, HIGH); // Deactivate round TFT
}
void loop(void) {
}
If I run the code as is, the round display will work
If I uncomment the first part and comment the second one, the monochrome display will work.
If I leave the code as is and I uncomment even just the line: pinMode(squareTft, OUTPUT);
The round display will not display anything.
How can I solve this?