前段时间买了这款CORE-ESP32-C3开发板,相比ESP8266主频高不少,多了蓝牙功能。最近尝试用这块开发板驱动手上st7735芯片的tft屏幕,记录一下过程:

1.配置好platformio环境:选择开发板型号为airm2m_core_esp32c3,Arduino开发框架。

2.添加TFT_eSPI库:用来驱动屏幕的,添加完成后打开.pio\libdeps\airm2m_core_esp32c3\TFT_eSPI目录下的User_Setup.h

主要改以下地方:

#define TFT_WIDTH  128
#define TFT_HEIGHT 160
#define ST7735_GREENTAB2
#define TFT_INVERSION_OFF
#define TFT_BACKLIGHT_ON HIGH
#define TFT_MOSI 3 // In some display driver board, it might be written as "SDA" and so on.
#define TFT_SCLK 2
#define TFT_CS   7  // Chip select control pin
#define TFT_DC   6  // Data Command control pin
#define TFT_RST  10  // Reset pin (could connect to Arduino RESET pin)
#define SPI_FREQUENCY  27000000 //太高会出问题

测试程序:

#include <TFT_eSPI.h> // Graphics and font library for ST7735 driver chip
#include <SPI.h>TFT_eSPI tft = TFT_eSPI(); // Invoke library, pins defined in User_Setup.huint32_t targetTime = 0; // for next 1 second timeoutbyte omm = 99;
bool initial = 1;
byte xcolon = 0;
unsigned int colour = 0;static uint8_t conv2d(const char *p)
{uint8_t v = 0;if ('0' <= *p && *p <= '9')v = *p - '0';return 10 * v + *++p - '0';
}uint8_t hh = conv2d(__TIME__), mm = conv2d(__TIME__ + 3), ss = conv2d(__TIME__ + 6); // Get H, M, S from compile timevoid setup(void)
{tft.init();tft.setRotation(1);tft.fillScreen(TFT_BLACK);tft.setTextColor(TFT_YELLOW, TFT_BLACK); // Note: the new fonts do not draw the background colourtargetTime = millis() + 1000;
}void loop()
{if (targetTime < millis()){targetTime = millis() + 1000;ss++; // Advance secondif (ss == 60){ss = 0;omm = mm;mm++; // Advance minuteif (mm > 59){mm = 0;hh++; // Advance hourif (hh > 23){hh = 0;}}}if (ss == 0 || initial){initial = 0;tft.setTextColor(TFT_GREEN, TFT_BLACK);tft.setCursor(8, 52);tft.print(__DATE__); // This uses the standard ADAFruit small fonttft.setTextColor(TFT_BLUE, TFT_BLACK);tft.drawCentreString("It is windy", 120, 48, 2); // Next size up font 2// tft.setTextColor(0xF81F, TFT_BLACK); // Pink// tft.drawCentreString("12.34",80,100,6); // Large font 6 only contains characters [space] 0 1 2 3 4 5 6 7 8 9 . : a p m}// Update digital timebyte xpos = 6;byte ypos = 0;if (omm != mm){ // Only redraw every minute to minimise flicker// Uncomment ONE of the next 2 lines, using the ghost image demonstrates text overlay as time is drawn over ittft.setTextColor(0x39C4, TFT_BLACK); // Leave a 7 segment ghost image, comment out next line!// tft.setTextColor(TFT_BLACK, TFT_BLACK); // Set font colour to black to wipe image//  Font 7 is to show a pseudo 7 segment display.//  Font 7 only contains characters [space] 0 1 2 3 4 5 6 7 8 9 0 : .tft.drawString("88:88", xpos, ypos, 7); // Overwrite the text to clear ittft.setTextColor(0xFBE0);               // Orangeomm = mm;if (hh < 10)xpos += tft.drawChar('0', xpos, ypos, 7);xpos += tft.drawNumber(hh, xpos, ypos, 7);xcolon = xpos;xpos += tft.drawChar(':', xpos, ypos, 7);if (mm < 10)xpos += tft.drawChar('0', xpos, ypos, 7);tft.drawNumber(mm, xpos, ypos, 7);}if (ss % 2){ // Flash the colontft.setTextColor(0x39C4, TFT_BLACK);xpos += tft.drawChar(':', xcolon, ypos, 7);tft.setTextColor(0xFBE0, TFT_BLACK);}else{tft.drawChar(':', xcolon, ypos, 7);colour = random(0xFFFF);// Erase the old text with a rectangle, the disadvantage of this method is increased display flickertft.fillRect(0, 64, 160, 20, TFT_BLACK);tft.setTextColor(colour);tft.drawRightString("Colour", 75, 64, 4); // Right justified string drawing to x position 75String scolour = String(colour, HEX);scolour.toUpperCase();char buffer[20];scolour.toCharArray(buffer, 20);tft.drawString(buffer, 82, 64, 4);}}
}

烧录,观察屏幕是否正常显示,如果显示不正常可修改User_setup.h里的配置

Luat合宙ESP32C3教程-点亮ST7735驱动1.8寸TFT液晶屏相关推荐

  1. 合宙ESP32C3 Arduino 初探教程

    合宙ESP32C3 Arduino 初探教程 以为买回来一插上typeC接口就能通过Arduino IDE来个点灯,没想到:1.找不到对应的ESPC3型号,选择其他的点击烧录识别出问题. 到手回来没有 ...

  2. 合宙 ESP32C3 使用micropython 驱动配套0.96寸 TFT ST7735 屏幕显示色块和文字

    合宙的esp32c3 开发板配套了0.96寸屏幕驱动板,可直接使用如下链接的代码.注意替换对应的pin脚和st7735.py文件 1. 想显示色块参考如下链接: 链接: 合宙esp32c3+合宙air ...

  3. 合宙ESP32C3 更换Flash调整lua固件教程分享

    合宙ESP32C3 更换Flash调整lua固件教程分享 合宙官方的固件编译指南:https://wiki.luatos.com/develop/compile/ESP32C3.html 合宙给出的更 ...

  4. 005.Python制作客户端截屏通过合宙ESP32-C3投屏到0.96OLED

    Python制作客户端截屏通过ESP32-C3投屏到0.96'OLED 一.实现原理 Python对屏幕进行截屏,并进行数据处理 Python与ESP32-C3通过WIFI建立tcp连接 Python ...

  5. 【合宙ESP32C3】MPU6500六轴姿态传感器

    网上好多教程都是MPU6050的,看到有些网友说其实两款传感器读写都差不多,但是对于我这种小小白,只想先用例程上手,读出数据,其他的再慢慢来. 这里提供了一种简单上手的方法: [MPU6500文档]: ...

  6. 实惠的Arduino开发板——合宙ESP32C3

    目录 1.0 ESP32C3单片机 2.0 使用方法: 3.0 其他注意事项: 4. 小结 esp32长期以来都是最具性价比的开发板,特别在当今的缺芯潮下,很多MCU价格已经上天,但esp32系列仍然 ...

  7. 合宙ESP32C3基于Arduino IDE框架下配置分区表

    合宙ESP32C3基于Arduino IDE框架下配置分区表 关于VSCode PIO配置分区表可以参考示例文章<合宙ESP32C3基于VSCode PIO开发初探教程> 有关Arduin ...

  8. 合宙 ESP32C3 烧录 Micropython 后连接端口报错

    合宙esp32c3 开发板烧录micropython 后连接VScode 或 Thonny报错: Device is busy or does not respond. 1. 原因: 烧录的micro ...

  9. Arduino IDE搭建合宙ESP32C3开发环境(最简单) 附跑马灯代码

    Arduino IDE搭建合宙ESP32C3开发环境(最简单) 附跑马灯代码 一.安装Arduino IDE 二.搭建合宙简约版ESP32C3开发环境 1.产品示例&管脚定义&原理图 ...

  10. 基于Lua框架下的合宙ESP32C3+1.5‘’Eink墨水屏天气时钟+OLED开源项目分享

    基于Lua框架下的合宙ESP32C3+1.5''Eink墨水屏天气时钟+OLED项目分享

最新文章

  1. python实现excel数据透视表_用python建立excel的数据透视表
  2. 在Linux中如何禁止用户登录
  3. Spark源码阅读03-Spark存储原理之存储分析
  4. 计算机房装修对门的要求,防火门尺寸要求有哪些 防火门尺寸规范
  5. pep8 python 编码规范_Python合集之Python语法特点(三)
  6. Dapr微服务应用开发系列3:服务调用构件块
  7. 成都python数据分析师培训_python数据分析师
  8. XBRL 可扩展商业报告语言
  9. 计算机主页为什么打不开怎么办,主页被限制,打不开怎么办?
  10. 编译 java_如何编译java
  11. TCP粘包以及UDP丢包问题
  12. android ios9 rom,谁说安卓不如苹果?看Android7.0如何逆袭iOS9.3
  13. 洛谷 P1378 油滴扩展
  14. sklearn代码11 1-熵
  15. 免费网站数据抓取插件,可视化页面数据抓取插件
  16. Keystore介绍
  17. java用正则表达式判断字符串中是否仅包含英文字母、数字和汉字_灵思致远Leansmall的博客-CSDN博客_java判断字符串只包含数字字母
  18. 常用的企业管理软件有哪些?
  19. ffmpeg视频音频处理
  20. 软件设计是怎样炼成的(8)——用户感觉好才是真的好(用户体验设计)

热门文章

  1. Java 明文转密文
  2. 什么是智能DNS解析?
  3. 西数、希捷、DIY移动硬盘详细拆解,暴力解析
  4. 安装WPS后,word文件无法预览,无法右键新建的解决办法
  5. 生物医学数据统计分析-分类资料统计分析
  6. leaflet保存pm绘图geojson数据
  7. [USACO19FEB]Mowing Mischief
  8. Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) F. Beautiful fountains rows
  9. node.js使用 nodemailer 库发送邮件以及EREFUSED问题的出现
  10. 可见首发《模式识别与智能计算:MATLAB技术实现(第2版)》 百度网盘 下载 分享