【ESP32】实现使用esp32s3 使用st7789 并口屏幕驱动,进行tcp局域网投屏

基于clion ide和paltformio插件,在arduino框架下,实现投屏

常见的都是使用spi串口屏,但是为了提高刷新速度,这里希望通过使用并口屏实现屏幕的驱动。

完整程序代码如下:https://github.com/OULIHONG1999/esp32s3_tcp_screencpy.git
代码仓库连接

投屏软件界面展示

库文件

1. TFT_eSPI
2. TJpg_Decoder

其中主要是修改了User_Setup.h中的文件配置,并在main文件的setup()函数中,取消原来使用DMA方式的初始化,以及在绘制屏幕画面时,取消了DMA发送数据,绘制屏幕的方式

部分代码展示

  1. main.cpp文件
#include <Arduino.h>

#include <TFT_eSPI.h>
#include <SPI.h>
#include <WiFi.h>
#include <TJpg_Decoder.h>
#include <pgmspace.h>
#include <esp_lcd_panel_ops.h>

// 从32改为128,增加缓存,增加速度
uint16_t  PROGMEM dmaBuffer1[128 * 128]; // Toggle buffer for 32*32 MCU block, 1024bytes
uint16_t  PROGMEM dmaBuffer2[128 * 128]; // Toggle buffer for 32*32 MCU block, 1024bytes
uint16_t *dmaBufferPtr = dmaBuffer1;
bool dmaBufferSel = 0;

TFT_eSPI tft = TFT_eSPI();
TFT_eSprite clk = TFT_eSprite(&tft);
char *ssid = "CMCC-ABCD"; //填写你的wifi名字
char *password = "66668888"; //填写你的wifi密码
int httpPort = 8081; //设置监听端口
WiFiServer server; //初始化一个服务端对象
uint8_t buff[7000] PROGMEM = {
   0};//每一帧的临时缓存
uint8_t img_buff[50000] PROGMEM = {
   0};//用于存储tcp传过来的图片
uint16_t size_count = 0;//计算一帧的字节大小

bool tft_output(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t *bitmap) {
   
    if (y >= tft.height()) return 0;
    
    // Double buffering is used, the bitmap is copied to the buffer by pushImageDMA() the
    // bitmap can then be updated by the jpeg decoder while DMA is in progress
    if (dmaBufferSel) dmaBufferPtr = dmaBuffer2;
    else dmaBufferPtr = dmaBuffer1;
    dmaBufferSel = !dmaBufferSel; // Toggle buffer selection
    //  pushImageDMA() will clip the image block at screen boundaries before initiating DMA
//    tft.pushImageDMA(x, y, w, h, bitmap, dmaBufferPtr); // Initiate DMA - blocking only if last DMA is not complete // 不使用,注释掉
    tft.pushImage(x, y, w, h, bitmap); // 使用其他的绘制函数

    return 1;
}

byte loadNum = 6;

void loading(byte delayTime) {
   //启动动画
    clk.setColorDepth(8);
    
    clk.createSprite(200, 50
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值