|
爱科技、爱创意、爱折腾、爱极致,我们都是技术控
您需要 登录 才可以下载或查看,没有账号?立即注册
x
ESP8266直驱TFT屏幕显示JPEG图片,
8266开SPIFFS,直接把XX.jpg图片放在SPIFFS里,读取并显示在屏幕上,下一步,WEB网页直接上传图片,保存在SPIFFS,并更新显示在屏幕上
,
,
,
,
,
,
,
=========代码如下,=========
- //====================================================================================
- // Libraries
- //====================================================================================
- // Call up the SPIFFS FLASH filing system this is part of the ESP Core
- #define FS_NO_GLOBALS
- #include <FS.h>
- // JPEG decoder library
- #include <JPEGDecoder.h>
- // SPI library, built into IDE
- #include <SPI.h>
- // Call up the TFT library
- #include <TFT_eSPI.h> // Hardware-specific library for ESP8266
- // The TFT control pins are set in the User_Setup.h file <<<<<<<<<<<<<<<<< NOTE!
- // that can be found in the "src" folder of the library
- // Invoke TFT library
- TFT_eSPI tft = TFT_eSPI();
- //====================================================================================
- // Setup
- //====================================================================================
- void setup()
- {
- delay(10);
-
- Serial.begin(115200); // Used for messages and the C array generator
- delay(10);
- Serial.println("");
-
- Serial.println("NodeMCU decoder test!");
- SPIFFS.begin();
-
- Serial.println(" SPIFFS.begin(); !");
- Serial.println("");
-
- tft.begin();
- tft.setRotation(0); // 0 & 2 Portrait. 1 & 3 landscape
- tft.fillScreen(TFT_BLACK);
- if (!SPIFFS.begin())
- {
- Serial.println("SPIFFS initialisation failed!");
- while (1) yield(); // Stay here twiddling thumbs waiting
- }
- Serial.println("\r\nInitialisation done.");
- listFiles(); // Lists the files so you can see what is in the SPIFFS
-
- if (!SPIFFS.begin())
- {
- Serial.println("SPIFFS initialisation failed!,SPIFFS初始化失败 ");
- if (!SPIFFS.begin())
- {
- Serial.println("SPIFFS初始化失败22 ");
- while (1) yield(); // Stay here twiddling thumbs waiting //呆在这里,手忙脚乱地等着
- }
- }
- Serial.println("\r\nInitialisation done初始化完成.");
- listFiles(); // Lists the files so you can see what is in the SPIFFS //列出文件,以便查看SPIFFS中的内容
-
- }
- //====================================================================================
- // Loop
- //====================================================================================
- void loop()
- {
- // Note the / before the SPIFFS file name must be present, this means the file is in
- // the root directory of the SPIFFS, e.g. "/Tiger.jpg" for a file called "Tiger.jpg"
- tft.setRotation(0); // portrait
- tft.fillScreen(random(0xFFFF));
- drawJpeg("/BaboonL", 0, 16); //1
- delay(2000);
- tft.fillScreen(random(0xFFFF));
- drawJpeg("/BaboonP.jpg", 4, 0);//2
- delay(2000);
- tft.setRotation(1); // landscape
- //tft.fillScreen(random(0xFFFF));
- drawJpeg("/EagleEye.jpg", 0, 0);//3
- delay(2000);
- tft.fillScreen(TFT_BLACK);
- drawJpeg("/Mouse.jpg", 0, 4);//4
- delay(2000);
- /*****************
- tft.setRotation(0); // portrait
- tft.fillScreen(random(0xFFFF));
- drawJpeg("/EagleEye160.jpg", 0, 16);
- delay(2000);
- tft.fillScreen(random(0xFFFF));
- drawJpeg("/tiger160.jpg", 4, 0);
- delay(2000);
- tft.setRotation(1); // landscape
- //tft.fillScreen(random(0xFFFF));
- drawJpeg("/arduino160.jpg", 0, 0);
- delay(2000);
- tft.fillScreen(TFT_BLACK);
- drawJpeg("/Baboon160.jpg", 0, 4);
- delay(2000);
- tft.fillScreen(random(0xFFFF));
- drawJpeg("/Mouse160.jpg", 0, 11);
- delay(2000);
- ****************/
- //=============================
- // Create arrays from the jpeg images and send them to the serial port for copy and
- // pasting into a sketch (used to make arrays fot the TFT_FLASH_Jpeg sketch)
- //createArray("/EagleEye160.jpg");
- //createArray("/tiger160.jpg");
- //createArray("/Baboon160.jpg");
- //createArray("/Mouse160.jpg");
- //while(1) yield(); // Stay here
- }
- //====================================================================================
复制代码
|
打赏
-
查看全部打赏
|