当前位置:网站首页>esp12f + tft display picture problem
esp12f + tft display picture problem
2022-07-29 23:21:00 【おもいね】
问题描述
#include <TFT_eSPI.h>
#include <TJpg_Decoder.h>
When using these two libraries,Found the picture after showing though,但会强制esp8266复位,一直没找到原因,Tested one by one,发现TJpg_Decoder仅仅是一个tjpgImage decoding library,And can't display pictures in between,And the library provides a callback function,to call the function that displays the bitmap on the screen.
解决
注意这个函数
bool tft_output(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t *bitmap)
{
if (y >= tft.height())
return 0;
tft.pushImage(x, y, w, h, bitmap);
// Return 1 to decode next block
return 1;
}
在setupYou can add this callback function to the
下面就是全部代码:
Just replace the picture with your own to display a picture completely.
#include <Arduino.h>
#include <TFT_eSPI.h> // Include the graphics library (this includes the sprite functions)
#include <TJpg_Decoder.h>
#include<EEPROM.h>
TFT_eSPI tft = TFT_eSPI(); // Create object "tft"
TFT_eSprite img = TFT_eSprite(&tft); // Create Sprite object "img" with pointer to "tft" object
#include "../include/jpeg/jpeg1.h"
#define LCD_BC 5 // This is my hardware to adjust the backlightIO,Everyone can ignore it
// TFT屏幕输出函数
bool tft_output(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t *bitmap)
{
if (y >= tft.height())
return 0;
tft.pushImage(x, y, w, h, bitmap);
// Return 1 to decode next block
return 1;
}
void setup()
{
pinMode(LCD_BC,OUTPUT);// This is my hardware to adjust the backlightIO,Everyone can ignore it
analogWrite(LCD_BC,0);// This is my hardware to adjust the backlightIO,Everyone can ignore it
Serial.begin(115200);
tft.begin();
tft.fillScreen(TFT_BLUE);
// The jpeg image can be scaled by a factor of 1, 2, 4, or 8
TJpgDec.setJpgScale(1);
TJpgDec.setSwapBytes(true);
TJpgDec.setCallback(tft_output);
}
void loop()
{
// Time recorded for test purposes
uint32_t t = millis();
// Get the width and height in pixels of the jpeg if you wish
uint16_t w = 0, h = 0;
TJpgDec.getJpgSize(&w, &h, panda, sizeof(panda));
Serial.print("Width = "); Serial.print(w); Serial.print(", height = "); Serial.println(h);
// Draw the image, top left at 0,0
TJpgDec.drawJpg(0, 0, panda, sizeof(panda));
// How much time did rendering take (ESP8266 80MHz 473ms, 160MHz 266ms, ESP32 SPI 116ms)
t = millis() - t;
Serial.print(t); Serial.println(" ms");
// Wait before drawing again
delay(2000);
}
边栏推荐
- 【leetcode】剑指 Offer II 002. 二进制加法
- cached_network_image 多个图片卡顿崩溃
- Mysql内外连接
- Professor Lu Shouqun from COPU was invited to give a speech at ApacheCon Asia
- 华为14天-(3)内核开发
- 2022年最新甘肃建筑施工焊工(建筑特种作业)模拟题库及答案解析
- 什么是色选机(color sorter)?
- The Sandbox 与 Gravity 达成合作,将《RO仙境传说》带入元宇宙
- jenkins使用维护
- DNA修饰碳纳米管|DNA修饰单层二硫化钼|DNA修饰二硫化钨(注意事项)
猜你喜欢

MQTT over QUIC: The Next-Generation IoT Standard Protocol Brings New Impetus to Messaging Scenarios

Mysql内外连接

jenkins使用维护

html+css+php+mysql实现注册+登录+修改密码(附完整代码)

The second round of the real offer harvester~ How does the big factory inspect the candidates?(with detailed answer)

MySQL数据库进阶篇

MySQL面试题:用户金额充值面试题详解

线性表之顺序表(干货满满的分享来啦~内含顺序表全部函数代码~

嵌入式系统驱动初级【1】——内核模块上_编译方法

使用 Neuron 接入 Modbus TCP 及 Modbus RTU 协议设备
随机推荐
PLSQL Developer安装和配置
JetsonNano learning (6) Big pits and solutions that Jetson stepped on___Continuously updated
ah?Now the primary test recruitment requirements will be automated?
云计算1+X之openstack篇
互联网基石:TCP/IP四层模型,由浅入深直击原理!
华为14天-(3)内核开发
[leetcode] 82. Delete duplicate elements in sorted linked list II (medium)
Analysis of miscellaneous diseases such as DNS domain name hijacking in instant messaging mobile terminal development
通过 FileUploader 的初始化,了解 SAP UI5 应用的 StaticArea 初始化逻辑
嵌入式系统驱动初级【1】——内核模块上_编译方法
We launched a "developer lab"
SAP UI5 FileUploader 的隐藏 iframe 设计明细
Sort by a field in jsonArray
地狱挖掘者系列#1
流水线上的农民:我在工厂种蔬菜
真offer收割机 第二弹~大厂如何考察候选人?(附答案详解)
《MySQL DBA封神打怪之路》专栏学习大纲
i2c时序图的详细讲解[通俗易懂]
【leetcode】50. Pow(x, n)(中等)(快速幂)
超分之RVRT