Prepare HelloWorld for Waveshare ESP32-S3-Touch-AMOLED-2.16, in Arduino framework.

Prepare libraries to run HelloWorld on Waveshare ESP32-S3-Touch-AMOLED-2.16, in Arduino framework.





Notice:
About display resolution: currently, both LCD_WIDTH and LCD_HEIGHT in libraries//Mylibrary/pin_config.h are set 466, have to set it 480 to match the actual resolution.





The following exercise define LCD connection in code, so no need to #include "pin_config.h".

S3_CO5300_basictest.ino
/* 
Exercise run on ESP32-S3-Touch-AMOLED-2.16
https://coxxect.blogspot.com/2026/05/prepare-helloworld-for-waveshare-esp32.html

Remark about "USB CDC On Boot" option for Serial.print()
For Waveshare ESP32-S3-Touch-AMOLED-2.16 with a  single USB port only, 
select USB CDC On Boot: "Enabled".
Otherwise, you cannot see the output by Serial.print().
*/

#include <Arduino.h>
#include "Arduino_GFX_Library.h"

// ===
#define LCD_SDIO0 4
#define LCD_SDIO1 5
#define LCD_SDIO2 6
#define LCD_SDIO3 7
#define LCD_SCLK  38
#define LCD_RESET  2
#define LCD_CS 12
#define LCD_WIDTH 480
#define LCD_HEIGHT 480
// ===

Arduino_DataBus *bus = new Arduino_ESP32QSPI(
  LCD_CS /* CS */, LCD_SCLK /* SCK */, LCD_SDIO0 /* SDIO0 */, LCD_SDIO1 /* SDIO1 */,
  LCD_SDIO2 /* SDIO2 */, LCD_SDIO3 /* SDIO3 */);

Arduino_CO5300 *gfx = new Arduino_CO5300(
  bus, LCD_RESET /* RST */, 0 /* rotation */, LCD_WIDTH /* width */, LCD_HEIGHT /* height */, 0, 0, 0, 0);

void setup(void) {
  delay(2000);
  Serial.begin(115200);
  delay(1000);

  Serial.println("\n====================================");
  Serial.println("Arduino_GFX Hello World example");
  Serial.println("Waveshare ESP32-S3-Touch-AMOLED-2.16");
  Serial.println("====================================");

  // Init Display
  if (!gfx->begin()) {
    Serial.println("gfx->begin() failed!");
  }
  bus->writeC8D8(0x36, 0xA0);

  gfx->fillScreen(RGB565_BLACK);

  gfx->setBrightness(150);

  gfx->setTextColor(RGB565_WHITE);
  gfx->setTextSize(4 /* x scale */, 4 /* y scale */, 2 /* pixel_margin */);

  //===
  const char *msg = "Hello";
  int16_t x1, y1;       // top-left corner of bounding box
  uint16_t w, h;        // width and height of text
  
  // Measure the text with current font/size
  gfx->getTextBounds(msg, 0, 0, &x1, &y1, &w, &h);
  
  // Compute centered X position
  int16_t x = (gfx->width() - w) / 2;
  int16_t y = 50;  // vertical position you want

  gfx->setCursor(x, y);
  gfx->println(msg);
  //===

  gfx->setTextSize(2 /* x scale */, 2 /* y scale */, 2 /* pixel_margin */);
  gfx->println("\n Waveshare ESP32-S3-Touch-AMOLED-2.16");
  gfx->println();

  gfx->setTextSize(3 /* x scale */, 3 /* y scale */, 6 /* pixel_margin */);
  // Get Chip and version
  Serial.printf("Chip model: %s\n", ESP.getChipModel());
  Serial.printf("Chip revision: %d\n", ESP.getChipRevision());
  gfx->printf(" Chip model: %s\n", ESP.getChipModel());
  gfx->printf(" Chip revision: %d\n", ESP.getChipRevision());

  // Get ESP-IDF Version
  // This returns the version of the SDK the core was built on (e.g., "v5.1.0")
  Serial.print("ESP-IDF Version: ");
  Serial.println(esp_get_idf_version());
  gfx->print(" ESP-IDF Version: ");
  gfx->println(esp_get_idf_version());

  delay(5000);  // 5 seconds
}

#define num_of_color 5
int color[num_of_color] = {RGB565_RED, RGB565_GREEN, RGB565_BLUE, RGB565_WHITE, RGB565_BLACK};
String color_name[num_of_color] = {"RED", "GREEN", "BLUE", "WHITE", "BLACK"};
int color_index = 0;

void loop() {

  unsigned long startTime, stopTime;
  //
  startTime = millis();
  gfx->fillScreen(color[color_index]);

  gfx->setTextColor(color[color_index]^0xFFFF);
  gfx->setCursor(100, 100);
  gfx->setTextSize(5 /* x scale */, 5 /* y scale */, 5 /* pixel_margin */);
  gfx->println(color_name[color_index]);
  stopTime = millis();

  gfx->setCursor(100, 160);
  gfx->setTextSize(2 /* x scale */, 2 /* y scale */, 2 /* pixel_margin */);
  gfx->printf("Arduino_ESP32QSPI");

  gfx->setCursor(100, 210);
  gfx->setTextSize(3 /* x scale */, 3 /* y scale */, 3 /* pixel_margin */);
  gfx->printf("%i ms", stopTime-startTime);

  color_index++;
  if (color_index==num_of_color){
    color_index = 0;
  }

  delay(3000);
}

Next:
Dynamic WiFi Image Gallery run on Waveshare ESP32-S3-Touch-AMOLED-2.16


Comments

Popular posts from this blog

480x320 TFT/ILI9488 SPI wih EP32C3 (arduino-esp32) using Arduino_GFX Library

Drive ST7796 SPI TFT with XPT2046 Touch on ESP32-C3-DevKitM-1 (arduino-esp32), using TFT_eSPI.