mirror of
https://github.com/easychen/pushdeer.git
synced 2025-01-10 15:05:27 +08:00
添加了文件系统初始化的说明,程序兼容ESP32
This commit is contained in:
parent
bb1025e1ef
commit
6db248e2b8
@ -237,6 +237,22 @@ docker-compose -f docker-compose.self-hosted.yml up --build -d
|
||||
|
||||
这些操作完成后再编译就会发现屏幕正常显示了。如果显示不正常(比如图片颜色、大小不对等),这有可能是因为你用的屏幕硬件规格和我们这里的不同,可以参照注释尝试修改那些配置项。
|
||||
|
||||
## 初始化SPIFFS文件系统
|
||||
|
||||
如果遇到图片显示不出来),串口提示`SPIFFS: mount failed`,这是因为文件系统没有初始化。
|
||||
|
||||
你可以下载一个arduino插件来解决这个问题:
|
||||
|
||||
- [ESP8266](https://github.com/esp8266/arduino-esp8266fs-plugin)
|
||||
- [ESP32](https://github.com/me-no-dev/arduino-esp32fs-plugin)
|
||||
|
||||
下载后按项目页面提示放到对应的目录,重启arduino IDE就可以从下边菜单中看到多出来的选项:
|
||||
|
||||
![](image/2022-02-18-19-18-55.png)
|
||||
|
||||
点击它就会自动创建文件系统,以后就不会再遇到错误提示了。
|
||||
|
||||
|
||||
## 通过 PushDeer 推送信息到设备
|
||||
|
||||
当程序烧录完成,设备会初始化并自动连接服务器。如果没有初始化,可以按开发板上的reset进行重置。如果在烧录过程中串口无法连接开发板,也请按reset。
|
||||
|
BIN
iot/deeresp/data/deer.jpg
Normal file
BIN
iot/deeresp/data/deer.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.8 KiB |
BIN
iot/deeresp/data/wifi.jpg
Normal file
BIN
iot/deeresp/data/wifi.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
@ -10,7 +10,7 @@
|
||||
// ====== 以下不用修改 ===============
|
||||
#define MQTT_CLIENT_NAME "DeerEsp"
|
||||
#define DOWNLOADED_IMG "/download.jpg"
|
||||
#define BEEP_PIN D8
|
||||
|
||||
|
||||
#include <EspMQTTClient.h>
|
||||
|
||||
@ -30,8 +30,13 @@ TFT_eSPI tft = TFT_eSPI();
|
||||
|
||||
#ifdef ESP8266
|
||||
#include <ESP8266HTTPClient.h>
|
||||
#define BEEP_PIN D8
|
||||
#define IMG_SCALE 2
|
||||
#define TXT_SCALE 2
|
||||
#else
|
||||
#include "SPIFFS.h" // Required for ESP32 only
|
||||
#define IMG_SCALE 1
|
||||
#define TXT_SCALE 4
|
||||
#include <HTTPClient.h>
|
||||
#endif
|
||||
|
||||
@ -43,7 +48,7 @@ void setup() {
|
||||
|
||||
tft.begin();
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
tft.setTextColor(0xFFFF,0x0000);tft.setCursor(0, 0, 1);tft.setTextSize(2);tft.println("Init ...");
|
||||
tft.setTextColor(0xFFFF,0x0000);tft.setCursor(0, 0, 1);tft.setTextSize(TXT_SCALE);tft.println("Init ...");
|
||||
Serial.println("tft init");
|
||||
|
||||
if (!SPIFFS.begin()) {
|
||||
@ -52,7 +57,7 @@ void setup() {
|
||||
}
|
||||
Serial.println("SPIFFS init");
|
||||
|
||||
TJpgDec.setJpgScale(2);
|
||||
TJpgDec.setJpgScale(IMG_SCALE);
|
||||
TJpgDec.setSwapBytes(true);
|
||||
TJpgDec.setCallback(tft_output);
|
||||
|
||||
@ -72,12 +77,14 @@ void onConnectionEstablished()
|
||||
if (SPIFFS.exists(DOWNLOADED_IMG) == true) TJpgDec.drawFsJpg(0, 0, DOWNLOADED_IMG);
|
||||
else tft.fillScreen( TFT_BLACK );
|
||||
|
||||
#ifdef BEEP_PIN
|
||||
if(payload.indexOf("♪") >= 0) tone(BEEP_PIN, 1000, 100);
|
||||
#endif
|
||||
|
||||
tft.loadFont(cubic_11);
|
||||
|
||||
if( payload.length() > 80 ) tft.setTextSize(1);
|
||||
else tft.setTextSize(2);
|
||||
if( payload.length() > 80 ) tft.setTextSize(TXT_SCALE/2);
|
||||
else tft.setTextSize(TXT_SCALE);
|
||||
|
||||
char *found;
|
||||
short line = 0;
|
||||
|
BIN
iot/image/2022-02-18-19-18-55.png
Normal file
BIN
iot/image/2022-02-18-19-18-55.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 189 KiB |
Loading…
Reference in New Issue
Block a user