ESP32驱动GC9A01 Arduino IDE测试代码

需要用到Arduino_GFX库,地址
https://github.com/moononournation/Arduino_GFX

#include <Arduino_GFX_Library.h>

//设置引脚
/*
 * RST:33
 * DC:27
 * SDA(MOSI):15
 * BLK:22
 * SCL(SCK):14
 * CS:5
 * GND:GND
 * VCC:3.3V
 */


#define SCLK    14  
#define MOSI    15  
#define TFT_CS   5
#define TFT_BLK 22
#define TFT_DC  27
#define TFT_RST 33

// 使用软SPI
// Arduino_DataBus *bus = new Arduino_SWSPI(TFT_DC, TFT_CS, 18 /* SCK */, 23 /* MOSI */, -1 /* MISO */);

// 使用硬 SPI
// Arduino_DataBus *bus = new Arduino_HWSPI(TFT_DC, TFT_CS);

// 自定义引脚
Arduino_DataBus *bus = new Arduino_HWSPI(TFT_DC, TFT_CS, SCLK, MOSI, MISO, true);

// 使用GC9A01 IPS LCD 240x240
Arduino_GC9A01 *gfx = new Arduino_GC9A01(bus, TFT_RST, 0 /* 屏幕方向 */, true /* IPS */);

void setup()
{
  gfx->begin();   //初始化LCD

  gfx->setTextSize(3);    //文字大小
  gfx->fillScreen(BLACK); //用黑色清屏
  gfx->setTextColor(RED); //文字顏色
  gfx->setCursor(30, 60); //文字显示坐标(x,y)
  gfx->print("GC9A01");   //要显示的文字内容
  gfx->setTextSize(2);
  gfx->setCursor(30, 100);
  gfx->setTextColor(WHITE);
  gfx->print("Hello World !");
  gfx->setCursor(30, 140);
  gfx->setTextColor(YELLOW);
  gfx->print("ESP32");
  gfx->setCursor(20, 160);
  gfx->setTextColor(BLUE);
  gfx->print("bilibili");
}

void loop()
{
  
}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容