прошивка работает и для esp32

This commit is contained in:
Dmitry Borisenko
2021-12-23 17:48:01 +01:00
parent 7147e041b4
commit 44ccbe7ed7
7 changed files with 58 additions and 9 deletions

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"C_Cpp.clang_format_sortIncludes": false
}

View File

@@ -4,6 +4,14 @@
#define JSON_BUFFER_SIZE 4096 #define JSON_BUFFER_SIZE 4096
#ifdef esp8266_4mb
#define USE_LITTLEFS true
#endif
#ifdef esp32_4mb
#define USE_LITTLEFS false
#endif
//задачи таскера //задачи таскера
enum TimerTask_t { WIFI_SCAN, enum TimerTask_t { WIFI_SCAN,
WIFI_MQTT_CONNECTION_CHECK, WIFI_MQTT_CONNECTION_CHECK,

View File

@@ -1,13 +1,27 @@
#pragma once #pragma once
#include "Global.h" #include "Global.h"
#include "LittleFS.h"
#ifdef ESP32
#include <SPIFFS.h>
extern FS* filesystem;
#define FileFS SPIFFS
#define FS_NAME "SPIFFS"
#endif
#ifdef ESP8266
#if USE_LITTLEFS
#include "LittleFS.h"
extern FS LittleFS; extern FS LittleFS;
using littlefs_impl::LittleFSConfig; using littlefs_impl::LittleFSConfig;
extern FS* filesystem; extern FS* filesystem;
#define FileFS LittleFS #define FileFS LittleFS
#define FS_NAME "LittleFS" #define FS_NAME "LittleFS"
#else
extern FS* filesystem;
#define FileFS SPIFFS
#define FS_NAME "SPIFFS"
#endif
#endif
extern bool fileSystemInit(); extern bool fileSystemInit();
extern void globalVarsSync(); extern void globalVarsSync();

View File

@@ -3,10 +3,20 @@
//внешние глобальные директории //внешние глобальные директории
#include <Arduino.h> #include <Arduino.h>
#include <ArduinoJson.h> #include <ArduinoJson.h>
#include <TickerScheduler.h>
#ifdef ESP32
#include <WiFi.h>
#include <HTTPClient.h>
#include <HTTPUpdate.h>
#endif
#ifdef ESP8266
#include <ESP8266httpUpdate.h> #include <ESP8266httpUpdate.h>
#endif
#include <ESPAsyncWebServer.h> #include <ESPAsyncWebServer.h>
#include <FS.h> #include <FS.h>
#include <TickerScheduler.h>
//внутренние глобальные директории проекта //внутренние глобальные директории проекта
#include "Const.h" #include "Const.h"

View File

@@ -18,6 +18,9 @@ lib_deps_external =
bblanchon/ArduinoJson @6.18.0 bblanchon/ArduinoJson @6.18.0
me-no-dev/ESP Async WebServer me-no-dev/ESP Async WebServer
;lib_deps_internal =
[env:esp8266_4mb] [env:esp8266_4mb]
build_flags = -Desp8266_4mb="esp8266_4mb" build_flags = -Desp8266_4mb="esp8266_4mb"
framework = arduino framework = arduino
@@ -30,3 +33,14 @@ monitor_filters = esp8266_exception_decoder
upload_speed = 921600 upload_speed = 921600
monitor_speed = 115200 monitor_speed = 115200
board_build.filesystem = littlefs board_build.filesystem = littlefs
[env:esp32_4mb]
build_flags = -Desp32_4mb="esp32_4mb"
framework = arduino
board = esp32dev
platform = espressif32 @3.3.0
lib_deps =
${common_env_data.lib_deps_external}
monitor_filters = esp32_exception_decoder
upload_speed = 921600
monitor_speed = 115200

View File

@@ -10,14 +10,14 @@ bool fileSystemInit() {
} }
void globalVarsSync() { void globalVarsSync() {
settingsFlashJson = readFile("settings.json", 4096); settingsFlashJson = readFile(F("settings.json"), 4096);
settingsFlashJson.replace("\r\n", ""); settingsFlashJson.replace("\r\n", "");
} }
void saveSettingsFlashJson() { void saveSettingsFlashJson() {
writeFile(String("config.json"), settingsFlashJson); writeFile(F("settings.json"), settingsFlashJson);
} }
void saveParamsFlashJson() { void saveParamsFlashJson() {
writeFile(String("store.json"), paramsFlashJson); writeFile(F("params.json"), paramsFlashJson);
} }

View File

@@ -5,6 +5,6 @@ TickerScheduler ts(MYTEST + 1);
AsyncWebServer server(80); AsyncWebServer server(80);
//глобальные переменные //глобальные переменные
String settingsFlashJson = "{}"; //переменная в которой хранятся все настройки, находится в оперативной памяти только и синхронизированна с flash памятью String settingsFlashJson = "{}"; //переменная в которой хранятся все настройки, находится в оперативной памяти и синхронизированна с flash памятью
String paramsFlashJson = "{}"; //переменная в которой хранятся все параметры, находится в оперативной памяти только и синхронизированна с flash памятью String paramsFlashJson = "{}"; //переменная в которой хранятся все параметры, находится в оперативной памяти и синхронизированна с flash памятью
String paramsHeapJson = "{}"; //переменная в которой хранятся все параметры, находится в оперативной памяти только String paramsHeapJson = "{}"; //переменная в которой хранятся все параметры, находится в оперативной памяти только