Hi, I bought the display from waveshare, exactly from this link
I don't know how to write a simple code that will display "Hello world". Only the code that displays 3 RGB stripes works.
/**
* | Supported ESP SoCs | ESP32-S3 |
* | ------------------ | -------- |
*
* | Supported LCD Controllers | ST7262 |
* | ------------------------- | ------ |
*
* # Single RGB LCD Example
*
* The example demonstrates how to develop different model LCDs with RGB (without 3-wire SPI) interface using standalone drivers and test them by displaying color bars.
*
* ## How to use
*
* 1. [Configure drivers](https://github.com/esp-arduino-libs/ESP32_Display_Panel#configuring-drivers) if needed.
* 2. Modify the macros in the example to match the parameters according to your hardware.
* 3. Navigate to the `Tools` menu in the Arduino IDE to choose a ESP board and configure its parameters, please refter to [Configuring Supported Development Boards](https://github.com/esp-arduino-libs/ESP32_Display_Panel#configuring-supported-development-boards)
* 4. Verify and upload the example to your ESP board.
*
* ## Serial Output
*
* ```
* ...
* RGB LCD example start
* Create RGB LCD bus
* Create LCD device
* Draw color bar from top left to bottom right, the order is B - G - R
* RGB LCD example end
* RGB refresh rate: 0
* RGB refresh rate: 0
* RGB refresh rate: 31
* RGB refresh rate: 31
* ...
* ```
*
* ## Troubleshooting
*
* Please check the [FAQ](https://github.com/esp-arduino-libs/ESP32_Display_Panel#faq) first to see if the same question exists. If not, please create a [Github issue](https://github.com/esp-arduino-libs/ESP32_Display_Panel/issues). We will get back to you as soon as possible.
*
*/
#include <Arduino.h>
#include <ESP_Panel_Library.h>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////// Please update the following configuration according to your LCD spec //////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Currently, the library supports the following RGB (without 3-wire SPI) LCDs:
* - ST7262
*/
#define EXAMPLE_LCD_NAME ST7262
#define EXAMPLE_LCD_WIDTH (800)
#define EXAMPLE_LCD_HEIGHT (480)
#define EXAMPLE_LCD_COLOR_BITS (24)
#define EXAMPLE_LCD_RGB_DATA_WIDTH (16)
#define EXAMPLE_LCD_RGB_TIMING_FREQ_HZ (16 * 1000 * 1000)
#define EXAMPLE_LCD_RGB_TIMING_HPW (4)
#define EXAMPLE_LCD_RGB_TIMING_HBP (8)
#define EXAMPLE_LCD_RGB_TIMING_HFP (8)
#define EXAMPLE_LCD_RGB_TIMING_VPW (4)
#define EXAMPLE_LCD_RGB_TIMING_VBP (8)
#define EXAMPLE_LCD_RGB_TIMING_VFP (8)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////// Please update the following configuration according to your board spec ////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define EXAMPLE_LCD_PIN_NUM_RGB_DISP (-1)
#define EXAMPLE_LCD_PIN_NUM_RGB_VSYNC (3)
#define EXAMPLE_LCD_PIN_NUM_RGB_HSYNC (46)
#define EXAMPLE_LCD_PIN_NUM_RGB_DE (5)
#define EXAMPLE_LCD_PIN_NUM_RGB_PCLK (7)
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA0 (14)
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA1 (38)
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA2 (18)
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA3 (17)
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA4 (10)
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA5 (39)
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA6 (0)
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA7 (45)
#if EXAMPLE_LCD_RGB_DATA_WIDTH > 8
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA8 (48)
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA9 (47)
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA10 (21)
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA11 (1)
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA12 (2)
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA13 (42)
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA14 (41)
#define EXAMPLE_LCD_PIN_NUM_RGB_DATA15 (40)
#endif
#define EXAMPLE_LCD_PIN_NUM_RST (-1)
#define EXAMPLE_LCD_PIN_NUM_BK_LIGHT (-1)
#define EXAMPLE_LCD_BK_LIGHT_ON_LEVEL (1)
#define EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL !EXAMPLE_LCD_BK_LIGHT_ON_LEVEL
/* Enable or disable printing RGB refresh rate */
#define EXAMPLE_ENABLE_PRINT_LCD_FPS (1)
#define _EXAMPLE_LCD_CLASS(name, ...) ESP_PanelLcd_##name(__VA_ARGS__)
#define EXAMPLE_LCD_CLASS(name, ...) _EXAMPLE_LCD_CLASS(name, ##__VA_ARGS__)
#if EXAMPLE_ENABLE_PRINT_LCD_FPS
#define EXAMPLE_LCD_FPS_COUNT_MAX (100)
DRAM_ATTR int frame_count = 0;
DRAM_ATTR int fps = 0;
DRAM_ATTR long start_time = 0;
IRAM_ATTR bool onVsyncEndCallback(void *user_data)
{
long frame_start_time = *(long *)user_data;
if (frame_start_time == 0) {
(*(long *)user_data) = millis();
return false;
}
frame_count++;
if (frame_count >= EXAMPLE_LCD_FPS_COUNT_MAX) {
fps = EXAMPLE_LCD_FPS_COUNT_MAX * 1000 / (millis() - frame_start_time);
frame_count = 0;
(*(long *)user_data) = millis();
}
return false;
}
#endif
void setup()
{
Serial.begin(115200);
Serial.println("RGB LCD example start");
#if EXAMPLE_LCD_PIN_NUM_BK_LIGHT >= 0
Serial.println("Initialize backlight control pin and turn it off");
ESP_PanelBacklight *backlight = new ESP_PanelBacklight(EXAMPLE_LCD_PIN_NUM_BK_LIGHT, EXAMPLE_LCD_BK_LIGHT_ON_LEVEL, true);
backlight->begin();
backlight->off();
#endif
Serial.println("Create RGB LCD bus");
#if EXAMPLE_LCD_RGB_DATA_WIDTH == 8
ESP_PanelBus_RGB *panel_bus = new ESP_PanelBus_RGB(EXAMPLE_LCD_WIDTH, EXAMPLE_LCD_HEIGHT,
EXAMPLE_LCD_PIN_NUM_RGB_DATA0, EXAMPLE_LCD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N_NUM_RGB_DE,
EXAMPLE_LCD_PIN_NUM_RGB_DISP);
#endif
panel_bus->configRgbTimingFreqHz(EXAMPLE_LCD_RGB_TIMING_FREQ_HZ);
panel_bus->configRgbTimingPorch(EXAMPLE_LCD_RGB_TIMING_HPW, EXAMPLE_LCD_RGB_TIMING_HBP, EXAMPLE_LCD_RGB_TIMING_HFP,
EXAMPLE_LCD_RGB_TIMING_VPW, EXAMPLE_LCD_RGB_TIMING_VBP, EXAMPLE_LCD_RGB_TIMING_VFP);
// panel_bus->configRgbBounceBufferSize(EXAMPLE_LCD_WIDTH * 10); // Set bounce buffer to avoid screen drift
panel_bus->begin();
Serial.println("Create LCD device");
ESP_PanelLcd *lcd = new EXAMPLE_LCD_CLASS(EXAMPLE_LCD_NAME, panel_bus, EXAMPLE_LCD_COLOR_BITS, EXAMPLE_LCD_PIN_NUM_RST);
lcd->init();
lcd->reset();
lcd->begin();
#if EXAMPLE_LCD_PIN_NUM_RGB_DISP >= 0
lcd->displayOn();
#endif
#if EXAMPLE_ENABLE_PRINT_LCD_FPS
lcd->attachRefreshFinishCallback(onVsyncEndCallback, (void *)&start_time);
#endif
Serial.println("Draw color bar from top left to bottom right, the order is B - G - R");
lcd->colorBarTest(EXAMPLE_LCD_WIDTH, EXAMPLE_LCD_HEIGHT);
#if EXAMPLE_LCD_PIN_NUM_BK_LIGHT >= 0
Serial.println("Turn on the backlight");
backlight->on();
#endif
Serial.println("RGB LCD example end");
}
void loop()
{
delay(1000);
#if EXAMPLE_ENABLE_PRINT_LCD_FPS
Serial.println("RGB refresh rate: " + String(fps));
#else
Serial.println("IDLE loop");
#endif
}
And I would like to do it using the GFX library, but I can't find information about it anywhere, please help.
I found the hello world code for the gfx library, but I don't know how to configure it to work properly
/*******************************************************************************
* Start of Arduino_GFX setting
*
* Arduino_GFX try to find the settings depends on selected board in Arduino IDE
* Or you can define the display dev kit not in the board list
* Defalult pin list for non display dev kit:
* Arduino Nano, Micro and more: CS: 9, DC: 8, RST: 7, BL: 6, SCK: 13, MOSI: 11, MISO: 12
* ESP32 various dev board : CS: 5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
* ESP32-C3 various dev board : CS: 7, DC: 2, RST: 1, BL: 3, SCK: 4, MOSI: 6, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 38, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S3 various dev board : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
* ESP8266 various dev board : CS: 15, DC: 4, RST: 2, BL: 5, SCK: 14, MOSI: 13, MISO: 12
* Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16
* RTL8720 BW16 old patch core : CS: 18, DC: 17, RST: 2, BL: 23, SCK: 19, MOSI: 21, MISO: 20
* RTL8720_BW16 Official core : CS: 9, DC: 8, RST: 6, BL: 3, SCK: 10, MOSI: 12, MISO: 11
* RTL8722 dev board : CS: 18, DC: 17, RST: 22, BL: 23, SCK: 13, MOSI: 11, MISO: 12
* RTL8722_mini dev board : CS: 12, DC: 14, RST: 15, BL: 13, SCK: 11, MOSI: 9, MISO: 10
* Seeeduino XIAO dev board : CS: 3, DC: 2, RST: 1, BL: 0, SCK: 8, MOSI: 10, MISO: 9
* Teensy 4.1 dev board : CS: 39, DC: 41, RST: 40, BL: 22, SCK: 13, MOSI: 11, MISO: 12
******************************************************************************/
#include <Arduino_GFX_Library.h>
#define GFX_BL DF_GFX_BL // default backlight pin, you may replace DF_GFX_BL to actual backlight pin
/* More dev device declaration: https://github.com/moononournation/Arduino_GFX/wiki/Dev-Device-Declaration */
#if defined(DISPLAY_DEV_KIT)
Arduino_GFX *gfx = create_default_Arduino_GFX();
#else /* !defined(DISPLAY_DEV_KIT) */
/* More data bus class: https://github.com/moononournation/Arduino_GFX/wiki/Data-Bus-Class */
Arduino_DataBus *bus = create_default_Arduino_DataBus();
/* More display class: https://github.com/moononournation/Arduino_GFX/wiki/Display-Class */
Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 0 /* rotation */, false /* IPS */);
#endif /* !defined(DISPLAY_DEV_KIT) */
/*******************************************************************************
* End of Arduino_GFX setting
******************************************************************************/
void setup(void)
{
Serial.begin(115200);
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX Hello World example");
#ifdef GFX_EXTRA_PRE_INIT
GFX_EXTRA_PRE_INIT();
#endif
// Init Display
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(BLACK);
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#endif
gfx->setCursor(10, 10);
gfx->setTextColor(RED);
gfx->println("Hello World!");
delay(5000); // 5 seconds
}
void loop()
{
gfx->setCursor(random(gfx->width()), random(gfx->height()));
gfx->setTextColor(random(0xffff), random(0xffff));
gfx->setTextSize(random(6) /* x scale */, random(6) /* y scale */, random(2) /* pixel_margin */);
gfx->println("Hello World!");
delay(1000); // 1 second
}