ESP8266 点亮 GC9A01显示屏 Hello word

在网上找了很多资料都是关于ESP32连接GC9A01显示屏的文章,但是始终无法找到关于ESP8266设备连接GC9A01显示屏的文章,但是我认为竟然是显示屏那肯定是可以点亮的,故此在被折磨了半天后终于也是将GV9A01设备点亮了,那么小插曲看完了,我们进入正题

一、先看效果

二、关于ESP8266与GC9A01连线的方式

首先我的GC9A01设备是7针脚的,它的针脚分别是:

RST ---> D4
CS  ---> D8
DC  ---> D2
SDA ---> D7
SCL ---> D5
GND ---> G
VCC ---> D1
三、安装驱动 Arduino_GFX

https://github.com/moononournation/Arduino_GFX

无法访问可使用链接下载

https://github.com/moononournation/Arduino_GFX/archive/refs/heads/master.zip

下载好该库后,放置到Arduino的library目录下,如下图所示。这是Arduino的库的默认路径

(C:\Users\Admin\Documents\Arduino\libraries)

2.Arduino GFX库测试

Arduino 的library目录,这个路径内的项目文件都是只读的,不便于我们直接打开内部的示例项目烧录和测试。

将Arduino GFX库内的example文件夹内的HelloWorld文件夹复制到其他路径下,我是复制到了桌面上的smart_screen_001文件夹内,然后打开项目工程HelloWorld.ino文件。

修改其中的一处代码

具体全部代码:

/*******************************************************************************
 * 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_GC9A01(bus, 2 /* RST */, 0 /* rotation */, true /* 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
}

至此将数据导入ESP8266就可以点亮了

课后

首先是接线方面,我如何知道它的接线方式的,在作者的第12行代码中有解释:

* ESP8266 various dev board   : CS: 15, DC:  4, RST:  2, BL:  5, SCK: 14, MOSI: 13, MISO: 12

对于ESP8266的接线方式,其中BL(背景灯光)我自认为可以对应VCC(电流),而在网上咨询的MOSI其实和SDA是相同的,SCK和SCL相同,故此我的接线才是原文中显示的这样,期间的针脚则参考ESP8266开发版的资料

图出处:Willliam_william-CSDN博客

本文参考:Arduino+ESP32 之 驱动GC9A01圆形LCD(一),基于Arduino_GFX库 - 一匹夫 - 博客园 (cnblogs.com)

本文使用库: Arduino_GFX

库地址: https://github.com/moononournation/Arduino_GFX

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值