深圳晶彩智能ESP32-3248S035R使用ArduinoGFX库实现SD卡JPEG格式图片显示

深圳晶彩智能ESP32-3248S035R介绍

深圳晶彩智能出品ESP32-3248S035R为3.5寸彩色屏采用分辨率480x320彩色液晶屏,驱动芯片是ST7796。板载乐鑫公司出品ESP-WROOM-32,Flash 4M。型号尾部“R”标识电阻膜的感压式触摸屏,驱动芯片是XPT2046。板载mini SD卡槽。

ArduinoGFX库介绍

Arduino_GFX是一个Arduino图形库。
目前支持GC9A01轮显、HX8347C、HX8347D、HX8352C、HX8357B、ILI9225、ILI9341、M5Stack、ILI9481、ILI9486、ILI9488、JBT6K71、R61529、SEPS525、SSD1283A、SSD1331、SSD1351、ST7735、ST7789、ST7796,具有软硬件SPI。ESP32还支持9位SPI、8位和16位并行接口。

欢迎到 Arduino_GFX wiki!

PlatformIO IDE使用的ArduinoGFX库地址

moononournation/GFX Library for Arduino

ESP32-3248S035R管脚分布

MOSIMISOCLKCSDCRST
ST7796121314152-1
XPT204612131433
SD2319185

platformIO.ini设置

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino

upload_speed = 921600
board_build.f_flash = 80000000L
board_build.flash_mode = dio
monitor_speed = 115200
;upload_port = COM3

board_build.mcu = esp32
upload_protocol = esptool
; change MCU frequency
board_build.f_cpu = 240000000L
lib_ldf_mode = deep
board_build.partitions = huge_app.csv

build_flags = -DCORE_DEBUG_LEVEL=3
    -DBOARD_HAS_PSRAM
    -mfix-esp32-psram-cache-issue    

lib_deps =  moononournation/GFX Library for Arduino@^1.4.6
            bitbank2/JPEGDEC@^1.4.2

使用ArduinoGFX库实现SD卡JPEG格式图片显示程序

#include <Arduino.h>
#include <Arduino_GFX_Library.h>

const char *jpeg[6] = {"/0.jpg", "/1.jpg", "/2.jpg", "/3.jpg", "/4.jpg","/5.jpg"};

#define GFX_BL 27 // default backlight pin, you may replace DF_GFX_BL to actual backlight pin

Arduino_DataBus *bus = new Arduino_ESP32SPI(2 /* DC */, 15 /* CS */, 14 /* SCK */, 13 /* MOSI */, 12 /* MISO */, HSPI /* spi_num */);
Arduino_GFX *gfx = new Arduino_ST7796(bus, -1 /* RST */, 3 /* rotation */, false /* IPS */,
                                      320 /* width */, 480 /* height */,
                                      0 /* col offset 1 */, 0 /* row offset 1 */);

#include <SD.h>

#define SD_MOSI 23
#define SD_MISO 19
#define SD_SCK 18
#define SD_CS 5

SPIClass SDSPI(VSPI);

#include "JpegFunc.h"

// pixel drawing callback
static int jpegDrawCallback(JPEGDRAW *pDraw)
{
  // Serial.printf("Draw pos = %d,%d. size = %d x %d\n", pDraw->x, pDraw->y, pDraw->iWidth, pDraw->iHeight);
  gfx->draw16bitBeRGBBitmap(pDraw->x, pDraw->y, pDraw->pPixels, pDraw->iWidth, pDraw->iHeight);
  return 1;
}

void setup()
{
  Serial.begin(115200);
  // Serial.setDebugOutput(true);
  // while(!Serial);
  Serial.println("Arduino_GFX JPEG Image Viewer example");

  // Init Display
  if (!gfx->begin())
  {
    Serial.println("gfx->begin() failed!");
  }
  gfx->fillScreen(BLACK);

  pinMode(GFX_BL, OUTPUT);
  digitalWrite(GFX_BL, HIGH);

  pinMode(5 /* CS */, OUTPUT);
  digitalWrite(5 /* CS */, HIGH);
  SDSPI.begin(SD_SCK, SD_MISO, SD_MOSI, SD_CS);
  // Initialise SD before TFT
  if (!SD.begin(SD_CS, SDSPI, 40000000))
  {
    Serial.println(F("ERROR: File System Mount Failed!"));
    gfx->println(F("ERROR: File System Mount Failed!"));
  }

  delay(5000);
}

void loop()
{
  int w = gfx->width();
  int h = gfx->height();
  
  for (int i = 0; i < 6; i++)
  {
    jpegDraw(jpeg[i], jpegDrawCallback, true /* useBigEndian */, 0, 0, w, h);       
    delay(5000);
    gfx->fillScreen(BLUE);
  }
}

项目上传地址:

https://gitlab.com/pdtopdog/jczn-esp32-3248s035r/-/tree/main/JCZN_35R_Arduino_GFX_SD_ImgViewerJpeg

  • 5
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值