ESP32学习笔记-读取SD卡并显示到屏幕上

硬件

FireBeetle 2 ESP32-E 开发板

1.54" 240x240 IPS 广视角TFT显示屏

硬件接线

ESP32学习笔记-读取SD卡并显示到屏幕上_第1张图片

测试代码

//加载库
#include "Arduino.h"
#include "FS.h"
#include "SD.h"
#include "SPI.h"
#include "DFRobot_GDL.h"
 
//定义显示屏针脚
#define TFT_DC  D2
#define TFT_CS  D6
#define TFT_RST D3
#define TFT_BL  D13

//定义SD针脚
#define TFT_SD  D7

//配置显示屏
DFRobot_ST7789_240x240_HW_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST);
 
void setup()
{
  //开启串口
  Serial.begin(115200);
 
  //挂载SD卡
  MountSD();
 
  //路径
  String path = "/hello.txt";
  //内容
  String str = "hello world !";
  //写入(覆盖)
  writeTxt(SD,path,str);

  //读取
  String txt =  readTxt(SD,path);
  Serial.println( txt );

  //开启显示屏
  screen.begin();
  //屏幕背景颜色
  screen.f

你可能感兴趣的:(ESP32学习笔记,学习,笔记,ESP32)