TFT 屏幕的使用——ESP32学习笔记(番外)

零、前言

 

最近在搞tft屏幕,遇到了非常多的困难,这个笔记主要帮助的是和我一样比较小白的单片机初学者,在这里我用到的板子是ESP32,用的屏幕是单工SPI通信协议的一块屏幕。

 一、准备工作

在这里我们准备写入驱动程序,这块屏幕用到的驱动时ST7735,所以把不用的全部注释掉,具体的配置这里不再过多解释,关键是设置引脚的连接。

查阅乐鑫官方的文档我们就可以知道,那些引脚可以作为SDA(数据传输),CS(片选),SCK(时钟线),DC(指令选择引脚),注意,ESP32的6到11号引脚虽然可以传输数据,但是一般不用,因为这些引脚是要用于flash的数据传输的

// For ESP32 Dev board (only tested with GC9A01 display)
// The hardware SPI can be mapped to any pins
// #define TFT_MISO 19
// #define TFT_MOSI 21
// #define TFT_SCLK 22
// #define TFT_CS   5
// #define TFT_DC   25
// #define TFT_RST  26

#define TFT_MOSI 15 // In some display driver board, it might be written as "SDA" and so on.
#define TFT_SCLK 14
#define TFT_CS   5  // Chip select control pin
#define TFT_DC   25  // Data Command control pin
#define TFT_RST  26  // Reset pin (could connect to Arduino RESET pin)
#define TFT_BL   22  // LED back-light

//#define TOUCH_CS 21     // Chip select pin (T_CS) of touch screen

//#define TFT_WR 22    // Write strobe for modified Raspberry Pi TFT only

// For the M5Stack module use these #define lines
//#define TFT_MISO 19
//#define TFT_MOSI 23
//#define TFT_SCLK 18
//#define TFT_CS   14  // Chip select control pin
//#define TFT_DC   27  // Data Command control pin
//#define TFT_RST  33  // Reset pin (could connect to Arduino RESET pin)
//#define TFT_BL   32  // LED back-light (required for M5Stack)

 这里要注意,你使用的屏幕上面有哪几个引脚就选用哪种方法,把其他的不用的全部注释掉。然后ESP32可以连接屏幕的引脚组合非常多,接到那个引脚把后面的引脚改一下,就可以正常驱动了,再然后就是利用arduino或者plantformio进行编程,这里写一下常用的函数,做一个总结:

    tft.init();                                               //初始化
    tft.fillScreen(TFT_WHITE);                //屏幕颜色
    tft.setCursor(1, 10, 2);                        //设置起始坐标(10, 10),2 号字体
    tft.setTextColor(TFT_BLUE);             //设置文本颜色为白色
    tft.setTextSize(1);                               //设置文字的大小 (1~7)
    tft.println("Two roads diverged in a wood,and ");                  //显示文字
    tft.drawLine(10,50,118,50,TFT_WHITE);            //画线
    tft.drawPixel(70,70,TFT_RED);//画点
    tft.setTextColor(TFT_WHITE,TFT_BLUE);//设置文字颜色和背景颜色

参考文档:

esp32-wroom-32_datasheet_cn.pdf (espressif.com)(ESP32技术规格书)

  • 1
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

BAKUMAN#0704

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值