From aa22152d8fc51df876dc5148772aac9ab2f46ab4 Mon Sep 17 00:00:00 2001 From: lewisxhe Date: Thu, 21 Mar 2024 14:21:51 +0800 Subject: [PATCH] Added Arduino_GFX_HelloWorld example https://github.com/Xinyuan-LilyGO/LilyGo-AMOLED-Series/issues/24 --- .../Arduino_GFX_HelloWorld.ino | 61 +++++++++++++++++++ platformio.ini | 5 +- 2 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 examples/Arduino_GFX_HelloWorld/Arduino_GFX_HelloWorld.ino diff --git a/examples/Arduino_GFX_HelloWorld/Arduino_GFX_HelloWorld.ino b/examples/Arduino_GFX_HelloWorld/Arduino_GFX_HelloWorld.ino new file mode 100644 index 0000000..b14bbb3 --- /dev/null +++ b/examples/Arduino_GFX_HelloWorld/Arduino_GFX_HelloWorld.ino @@ -0,0 +1,61 @@ +/** + * @file Arduino_GFX_HelloWorld.ino + * @author Lewis He (lewishe@outlook.com) + * @license MIT + * @copyright Copyright (c) 2024 ShenZhen XinYuan Electronic Technology Co., Ltd + * @date 2024-03-21 + * + */ +#include +#include // https://github.com/moononournation/Arduino_GFX.git + + +#define GFX_DEV_DEVICE LILYGO_T_DISPLAY_S3_AMOLED + +Arduino_DataBus *bus = new Arduino_ESP32QSPI( + 6 /* cs */, 47 /* sck */, 18 /* d0 */, 7 /* d1 */, 48 /* d2 */, 5 /* d3 */); +Arduino_GFX *gfx = new Arduino_RM67162(bus, 17 /* RST */, 0 /* rotation */); +Arduino_GFX *gfx2; + + +void setBrightness(uint8_t value) +{ + bus->beginWrite(); + bus->writeC8D8(0x51, value); + bus->endWrite(); +} + + +void setup() +{ + Serial.begin(115200); + + /** + * * The difference between the touch and non-touch versions is that the display + * * power supply of the touch version is controlled by IO38 + */ + pinMode(38, OUTPUT); + digitalWrite(38, OUTPUT); + + if (!gfx->begin()) { + Serial.println("gfx->begin() failed!"); + } + gfx2 = new Arduino_Canvas(240, 536, gfx, 0, 0); // for Sprites + gfx2->begin(GFX_SKIP_OUTPUT_BEGIN); // Added the GFX_SKIP_OUTPUT_BEGIN so the Canvas class doesn’t try and initialise the display + gfx2->fillScreen(BLACK); + gfx2->setCursor(80, 268); + gfx2->setTextColor(RED); + gfx2->setTextSize(2 /* x scale */, 2 /* y scale */, 1 /* pixel_margin */); + gfx2->println("Hello World!"); + gfx2->fillCircle(130, 130, 40, GREEN); + gfx2->flush(); + +} + +void loop() +{ + for (int i = 0; i < 255; i++) { + setBrightness(i); + delay(20); + } +} \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index b0108f5..bc4f73e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -31,14 +31,14 @@ default_envs = T-Display-AMOLED ;! The src_dir variable can only have one row ; Basic example -; src_dir = examples/Factory +src_dir = examples/Factory ; src_dir = examples/Touchpad ; src_dir = examples/Lvgl_Images ; src_dir = examples/TFT_eSPI_Sprite ; src_dir = examples/TFT_eSPI_Sprite_ArcFill ; src_dir = examples/TFT_eSPI_Sprite_RLE_Font ; src_dir = examples/TFT_eSPI_Sprite_graphicstest_small -src_dir = examples/AdjustBrightness +; src_dir = examples/AdjustBrightness ;! Extern SPI Example ; src_dir = examples/SPI_SDCard @@ -56,6 +56,7 @@ src_dir = examples/AdjustBrightness ; src_dir = examples/LVGL_Rotation ;!Requires T-Display-AMOLED-191-ArduinoGFX env ; src_dir = examples/Arduino_GFX_PDQgraphicstest +; src_dir = examples/Arduino_GFX_HelloWorld ;!QWIIC exampls ; src_dir = examples/QWIIC_GPS_Shield