Skip to content

Commit

Permalink
Added Arduino_GFX_HelloWorld example #24
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisxhe committed Mar 21, 2024
1 parent 41d1e1d commit aa22152
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 2 deletions.
61 changes: 61 additions & 0 deletions examples/Arduino_GFX_HelloWorld/Arduino_GFX_HelloWorld.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* @file Arduino_GFX_HelloWorld.ino
* @author Lewis He ([email protected])
* @license MIT
* @copyright Copyright (c) 2024 ShenZhen XinYuan Electronic Technology Co., Ltd
* @date 2024-03-21
*
*/
#include <Arduino.h>
#include <Arduino_GFX_Library.h> // 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);
}
}
5 changes: 3 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit aa22152

Please sign in to comment.