I bought some 7" 800x480 tft displays with built in esp32s. (i bought the model without touch screen)
The screen looks great and I was excited to have a cheap way to display some messages all enclosed in one board, but the sample code that comes with the screen is defining things in a way that is confusing me. (I tend to only use screens with libraries/or simple i2c interfaces). I cannot figure out how to move it to an adafruit library so I can use custom (really large) fonts that would look nice at a reasonable size on the 7" screen.
Can somebody please step through this code and help break down what it is doing? Or give me some tips for how to display large custom fonts (already converted to .h) on this display? Thanks!
#include <Arduino_GFX_Library.h>
// is the following defining the pins the esp32 is using to talk to the panel? How would i define this in another library?
#define TFT_BL 2
Arduino_ESP32RGBPanel *bus = new Arduino_ESP32RGBPanel(
// if i include this in other code i get errors about *bus
GFX_NOT_DEFINED /* CS */, GFX_NOT_DEFINED /* SCK */, GFX_NOT_DEFINED /* SDA */,
41 /* DE */, 40 /* VSYNC */, 39 /* HSYNC */, 42 /* PCLK */,
14 /* R0 */, 21 /* R1 */, 47 /* R2 */, 48 /* R3 */, 45 /* R4 */,
9 /* G0 */, 46 /* G1 */, 3 /* G2 */, 8 /* G3 */, 16 /* G4 */, 1 /* G5 */,
15 /* B0 */, 7 /* B1 */, 6 /* B2 */, 5 /* B3 */, 4 /* B4 */
);
Arduino_RPi_DPI_RGBPanel *gfx = new Arduino_RPi_DPI_RGBPanel(
bus,
800 /* width */, 0 /* hsync_polarity */, 210 /* hsync_front_porch */, 30 /* hsync_pulse_width */, 16 /* hsync_back_porch */,
480 /* height */, 0 /* vsync_polarity */, 22 /* vsync_front_porch */, 13 /* vsync_pulse_width */, 10 /* vsync_back_porch */,
1 /* pclk_active_neg */, 16000000 /* prefer_speed */, true /* auto_flush */);
int32_t w, h, n, n1, cx, cy, cx1, cy1, cn, cn1;
uint8_t tsa, tsb, tsc, ds;
void setup()
{
gfx->begin(); // why is this "->" rather than gfx.begin?
// gfx->begin(80000000); /* specify data bus speed */
w = gfx->width();
h = gfx->height();
n = min(w, h);
n1 = n - 1;
cx = w / 2;
cy = h / 2;
cx1 = cx - 1;
cy1 = cy - 1;
cn = min(cx1, cy1);
cn1 = cn - 1;
tsa = ((w <= 176) || (h <= 160)) ? 1 : (((w <= 240) || (h <= 240)) ? 2 : 3); // text size A
tsb = ((w <= 240) || (h <= 220)) ? 1 : 2; // text size B
tsc = ((w <= 220) || (h <= 220)) ? 1 : 2; // text size C
ds = (w <= 160) ? 9 : 12; // digit size
#ifdef TFT_BL
pinMode(TFT_BL, OUTPUT);
digitalWrite(TFT_BL, HIGH);
#endif
}
void loop(void)
{
gfx->setCursor(0, 0);
//what is the significance of the "->"? (I've only ever seen tft.setcursor or gfx.setcursor)
gfx->setTextSize(9);
gfx->setTextColor(MAGENTA);
gfx->println(F("This prints to the screen, but obviously all blocky"));
}