1 mb compiling version

This commit is contained in:
Dmitry Borisenko
2020-12-16 13:59:01 +01:00
parent 9934690d0a
commit 078c4389b5
28 changed files with 168 additions and 174 deletions

View File

@@ -11,6 +11,8 @@ extern void clockInit();
#include "sntp.h" #include "sntp.h"
#endif #endif
class Clock { class Clock {
private: private:
Time_t _time_local; Time_t _time_local;

View File

@@ -42,37 +42,19 @@
//#define SSDP_ENABLED //#define SSDP_ENABLED
//=========Sensors enable/disable================================================================================================================================= //=========Sensors enable/disable=================================================================================================================================
#define LEVEL_ENABLED #define SensorBme280Enabled
#define ANALOG_ENABLED #define SensorBmp280Enabled
#define DALLAS_ENABLED #define SensorDhtEnabled
#define DHT_ENABLED #define PwmOutEnable
#define BMP_ENABLED //#define SensorModbusEnabled
#define BME_ENABLED
//=========others=================================================================================================================================
//#define telegram
//#define uartEnable
//=========Gears enable/disable===================================================================================================================================
#define STEPPER_ENABLED
#define SERVO_ENABLED
//========Other enable/disable====================================================================================================================================
#define LOGGING_ENABLED
#define SERIAL_ENABLED
#define PUSH_ENABLED
struct Time_t {
uint8_t second;
uint8_t minute;
uint8_t hour;
uint8_t day_of_week;
uint8_t day_of_month;
uint8_t month;
uint16_t day_of_year;
uint16_t year;
unsigned long days;
unsigned long valid;
};
//================================================================================================================================================================ //================================================================================================================================================================
enum TimerTask_t { WIFI_SCAN, enum TimerTask_t { WIFI_SCAN,
WIFI_MQTT_CONNECTION_CHECK, WIFI_MQTT_CONNECTION_CHECK,

View File

@@ -1,8 +1,6 @@
#pragma once #pragma once
#include <ESPAsyncWebServer.h> #include <ESPAsyncWebServer.h>
//#include <FS.h> //#include <FS.h>
#ifdef ESP8266 #ifdef ESP8266
#include <LittleFS.h> #include <LittleFS.h>
#endif #endif

View File

@@ -1,9 +1,10 @@
#pragma once #pragma once
#ifdef uartEnable
#include "SoftwareSerial.h" #include "SoftwareSerial.h"
extern SoftwareSerial* myUART; extern SoftwareSerial* myUART;
extern void uartInit(); extern void uartInit();
extern void uartHandle(); extern void uartHandle();
extern void parse(String& incStr); extern void parse(String& incStr);
#endif

View File

@@ -1,4 +1,5 @@
#pragma once #pragma once
#ifdef telegram
#include "Global.h" #include "Global.h"
extern void sendTelegramMsg(); extern void sendTelegramMsg();
@@ -7,4 +8,5 @@ extern void handleTelegram();
extern bool isTelegramEnabled(); extern bool isTelegramEnabled();
extern bool isTelegramInputOn(); extern bool isTelegramInputOn();
extern void telegramMsgParse(String msg); extern void telegramMsgParse(String msg);
extern String returnListOfParams(); extern String returnListOfParams();
#endif

View File

@@ -1,9 +1,6 @@
#pragma once #pragma once
#include <Arduino.h> #include <Arduino.h>
//#include "FS.h" //#include "FS.h"
#ifdef ESP32 #ifdef ESP32
#include "LITTLEFS.h" #include "LITTLEFS.h"
#define LittleFS LITTLEFS #define LittleFS LITTLEFS

View File

@@ -1,11 +1,7 @@
#pragma once #pragma once
#include <Arduino.h> #include <Arduino.h>
#include "Consts.h" #include "Consts.h"
//#include "FS.h" //#include "FS.h"
#ifdef ESP32 #ifdef ESP32
#include "LITTLEFS.h" #include "LITTLEFS.h"
#define LittleFS LITTLEFS #define LittleFS LITTLEFS

View File

@@ -48,6 +48,22 @@ int getOffsetInMinutes(int timezone);
/* /*
* Разбивает время на составляющие * Разбивает время на составляющие
*/ */
struct Time_t {
uint8_t second;
uint8_t minute;
uint8_t hour;
uint8_t day_of_week;
uint8_t day_of_month;
uint8_t month;
uint16_t day_of_year;
uint16_t year;
unsigned long days;
unsigned long valid;
};
void breakEpochToTime(unsigned long epoch, Time_t& tm); void breakEpochToTime(unsigned long epoch, Time_t& tm);
void timeInit(); void timeInit();

View File

@@ -1,6 +1,7 @@
#pragma once #pragma once
#include "Consts.h"
#ifdef SensorBme280Enabled
#include <Arduino.h> #include <Arduino.h>
#include "Class/LineParsing.h" #include "Class/LineParsing.h"
#include "Global.h" #include "Global.h"
#include "items/SensorConvertingClass.h" #include "items/SensorConvertingClass.h"
@@ -52,4 +53,5 @@ class SensorBme280Class : public SensorConvertingClass {
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl)); SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
} }
}; };
extern SensorBme280Class mySensorBme280; extern SensorBme280Class mySensorBme280;
#endif

View File

@@ -1,6 +1,7 @@
#pragma once #pragma once
#include "Consts.h"
#ifdef SensorBmp280Enabled
#include <Arduino.h> #include <Arduino.h>
#include "Class/LineParsing.h" #include "Class/LineParsing.h"
#include "Global.h" #include "Global.h"
#include "items/SensorConvertingClass.h" #include "items/SensorConvertingClass.h"
@@ -45,4 +46,5 @@ class SensorBmp280Class : public SensorConvertingClass {
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl)); SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
} }
}; };
extern SensorBmp280Class mySensorBmp280; extern SensorBmp280Class mySensorBmp280;
#endif

View File

@@ -1,6 +1,7 @@
#pragma once #pragma once
#include "Consts.h"
#ifdef SensorDhtEnabled
#include <Arduino.h> #include <Arduino.h>
#include "Class/LineParsing.h" #include "Class/LineParsing.h"
#include "Global.h" #include "Global.h"
#include "items/SensorConvertingClass.h" #include "items/SensorConvertingClass.h"
@@ -75,4 +76,5 @@ class SensorDhtClass : public SensorConvertingClass {
} }
} }
}; };
extern SensorDhtClass mySensorDht; extern SensorDhtClass mySensorDht;
#endif

View File

@@ -1,9 +1,9 @@
#ifdef modbus
#pragma once #pragma once
#include "Consts.h"
#ifdef SensorModbusEnabled
#include <Arduino.h> #include <Arduino.h>
#include <ModbusMaster.h> #include <ModbusMaster.h>
#include <SoftwareSerial.h> #include <SoftwareSerial.h>
#include "Class/LineParsing.h" #include "Class/LineParsing.h"
#include "Global.h" #include "Global.h"
#include "items/SensorConvertingClass.h" #include "items/SensorConvertingClass.h"
@@ -82,4 +82,8 @@ class SensorModbusClass : public SensorConvertingClass {
} }
}; };
extern SensorModbusClass mySensorModbus; extern SensorModbusClass mySensorModbus;
extern void modbus();
extern void modbusReading();
#endif #endif

View File

@@ -1,6 +1,7 @@
#pragma once #pragma once
#include "Consts.h"
#ifdef PwmOutEnable
#include <Arduino.h> #include <Arduino.h>
#include "Global.h" #include "Global.h"
class PwmOut; class PwmOut;
@@ -27,3 +28,4 @@ extern MyPwmOutVector* myPwmOut;
extern void pwmOut(); extern void pwmOut();
extern void pwmOutExecute(); extern void pwmOutExecute();
#endif

View File

@@ -1,6 +1,6 @@
[platformio] [platformio]
default_envs = esp8266 default_envs = esp8266_01_1m
;============================================================================================================================================= ;=============================================================================================================================================
[common_env_data] [common_env_data]
lib_deps_external = lib_deps_external =
@@ -38,7 +38,8 @@ framework = arduino
;board = esp01_1m ;board = esp01_1m
;board = esp12e ;board = esp12e
board = nodemcuv2 board = nodemcuv2
board_build.ldscript = eagle.flash.1m256.ld ;board_build.ldscript = eagle.flash.1m256.ld
board_build.ldscript = eagle.flash.1m512.ld
platform = https://github.com/platformio/platform-espressif8266.git platform = https://github.com/platformio/platform-espressif8266.git
lib_deps = lib_deps =
${common_env_data.lib_deps_external} ${common_env_data.lib_deps_external}
@@ -47,12 +48,10 @@ lib_deps =
ESPAsyncUDP ESPAsyncUDP
EspSoftwareSerial EspSoftwareSerial
CTBot CTBot
SPIFFS
monitor_filters = esp8266_exception_decoder 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
board_build.filesystem = SPIFFS
;============================================================================================================================================= ;=============================================================================================================================================
[env:esp8266] [env:esp8266]
framework = arduino framework = arduino

View File

@@ -9,6 +9,7 @@
#include "items/vLogging.h" #include "items/vLogging.h"
#include "items/vImpulsOut.h" #include "items/vImpulsOut.h"
#include "items/vCountDown.h" #include "items/vCountDown.h"
#include "items/SensorModbusClass.h"
void loopCmdAdd(const String& cmdStr) { void loopCmdAdd(const String& cmdStr) {
orderBuf += cmdStr; orderBuf += cmdStr;
@@ -41,9 +42,11 @@ void csvCmdExecute(String& cmdStr) {
if (order == F("button-out")) { if (order == F("button-out")) {
sCmd.addCommand(order.c_str(), buttonOut); sCmd.addCommand(order.c_str(), buttonOut);
} }
#ifdef PwmOutEnable
else if (order == F("pwm-out")) { else if (order == F("pwm-out")) {
sCmd.addCommand(order.c_str(), pwmOut); sCmd.addCommand(order.c_str(), pwmOut);
} }
#endif
else if (order == F("button-in")) { else if (order == F("button-in")) {
sCmd.addCommand(order.c_str(), buttonIn); sCmd.addCommand(order.c_str(), buttonIn);
} }
@@ -59,12 +62,15 @@ void csvCmdExecute(String& cmdStr) {
else if (order == F("dallas-temp")) { else if (order == F("dallas-temp")) {
sCmd.addCommand(order.c_str(), dallas); sCmd.addCommand(order.c_str(), dallas);
} }
#ifdef SensorDhtEnabled
else if (order == F("dht-temp")) { else if (order == F("dht-temp")) {
sCmd.addCommand(order.c_str(), dhtTemp); sCmd.addCommand(order.c_str(), dhtTemp);
} }
else if (order == F("dht-hum")) { else if (order == F("dht-hum")) {
sCmd.addCommand(order.c_str(), dhtHum); sCmd.addCommand(order.c_str(), dhtHum);
} }
#endif
#ifdef SensorBme280Enabled
else if (order == F("bme280-temp")) { else if (order == F("bme280-temp")) {
sCmd.addCommand(order.c_str(), bme280Temp); sCmd.addCommand(order.c_str(), bme280Temp);
} }
@@ -74,15 +80,20 @@ void csvCmdExecute(String& cmdStr) {
else if (order == F("bme280-press")) { else if (order == F("bme280-press")) {
sCmd.addCommand(order.c_str(), bme280Press); sCmd.addCommand(order.c_str(), bme280Press);
} }
#endif
#ifdef SensorBmp280Enabled
else if (order == F("bmp280-temp")) { else if (order == F("bmp280-temp")) {
sCmd.addCommand(order.c_str(), bmp280Temp); sCmd.addCommand(order.c_str(), bmp280Temp);
} }
else if (order == F("bmp280-press")) { else if (order == F("bmp280-press")) {
sCmd.addCommand(order.c_str(), bmp280Press); sCmd.addCommand(order.c_str(), bmp280Press);
} }
#endif
#ifdef SensorModbusEnabled
else if (order == F("modbus")) { else if (order == F("modbus")) {
//sCmd.addCommand(order.c_str(), modbus); sCmd.addCommand(order.c_str(), modbus);
} }
#endif
else if (order == F("uptime")) { else if (order == F("uptime")) {
sCmd.addCommand(order.c_str(), sysUptime); sCmd.addCommand(order.c_str(), sysUptime);
} }

View File

@@ -76,11 +76,13 @@ void deviceInit() {
inOutput_KeyList = ""; inOutput_KeyList = "";
inOutput_EnterCounter = -1; inOutput_EnterCounter = -1;
//======clear pwm params======= //======clear pwm params=======
#ifdef PwmOutEnable
if (myPwmOut != nullptr) { if (myPwmOut != nullptr) {
myPwmOut->clear(); myPwmOut->clear();
} }
pwmOut_KeyList = ""; pwmOut_KeyList = "";
pwmOut_EnterCounter = -1; pwmOut_EnterCounter = -1;
#endif
//=================================== //===================================
if (myCountDown != nullptr) { if (myCountDown != nullptr) {
myCountDown->clear(); myCountDown->clear();

View File

@@ -19,34 +19,13 @@ void itemsListInit() {
}, },
nullptr); nullptr);
#ifdef FLASH_SIZE_1MB
myNotAsyncActions->add(
do_addItem, [&](void*) {
addItem(itemName);
itemName = "";
},
nullptr);
myNotAsyncActions->add(
do_addPreset, [&](void*) {
addPreset(presetName);
presetName = "";
},
nullptr);
#endif
SerialPrint("I", F("Items"), F("Items Init")); SerialPrint("I", F("Items"), F("Items Init"));
} }
void addItem(String name) { void addItem(String name) {
#ifdef FLASH_SIZE_1MB
String url = serverIP + F("/projects/iotmanager/config/items/") + name + ".txt";
String item = getURL(url);
Serial.println(url);
if (item == "error") return;
#endif
#ifndef FLASH_SIZE_1MB
String item = readFile("items/" + name + ".txt", 1024); String item = readFile("items/" + name + ".txt", 1024);
#endif
name = selectToMarker(name, "-"); name = selectToMarker(name, "-");
@@ -81,34 +60,16 @@ void addItem(String name) {
} }
void addPreset(String name) { void addPreset(String name) {
#ifdef FLASH_SIZE_1MB
String url = serverIP + F("/projects/iotmanager/config/presets/") + name + ".txt";
String preset = getURL(url);
Serial.println(url);
if (preset == "error") return;
#endif
#ifndef FLASH_SIZE_1MB
String preset = readFile("presets/" + name + ".txt", 4048); String preset = readFile("presets/" + name + ".txt", 4048);
#endif
addFile(DEVICE_CONFIG_FILE, "\n" + preset); addFile(DEVICE_CONFIG_FILE, "\n" + preset);
Serial.println(preset); Serial.println(preset);
name.replace(".c", ".s"); name.replace(".c", ".s");
#ifdef FLASH_SIZE_1MB
url = serverIP + F("/projects/iotmanager/config/presets/") + name + ".txt";
String scenario = getURL(url);
Serial.println(url);
if (scenario == "error") return;
#endif
#ifndef FLASH_SIZE_1MB
String scenario = readFile("presets/" + name + ".txt", 4048); String scenario = readFile("presets/" + name + ".txt", 4048);
#endif
removeFile(DEVICE_SCENARIO_FILE); removeFile(DEVICE_SCENARIO_FILE);
addFile(DEVICE_SCENARIO_FILE, scenario); addFile(DEVICE_SCENARIO_FILE, scenario);
loadScenario(); loadScenario();
Serial.println(scenario); Serial.println(scenario);

View File

@@ -124,10 +124,8 @@ void mqttCallback(char* topic, uint8_t* payload, size_t length) {
SerialPrint("I", "MQTT", "Full update"); SerialPrint("I", "MQTT", "Full update");
publishWidgets(); publishWidgets();
publishState(); publishState();
#ifdef LOGGING_ENABLED
choose_log_date_and_send();
#endif
choose_log_date_and_send();
} }
else if (topicStr.indexOf("control") != -1) { else if (topicStr.indexOf("control") != -1) {

View File

@@ -1,3 +1,4 @@
#ifdef uartEnable
#include "SoftUART.h" #include "SoftUART.h"
#include "Global.h" #include "Global.h"
@@ -8,7 +9,7 @@ HardwareSerial* myUART = nullptr;
#endif #endif
void uartInit() { void uartInit() {
if (!jsonReadBool(configSetupJson, "uart")) { if (!jsonReadBool(configSetupJson, "uartEnable")) {
return; return;
} }
if (!myUART) { if (!myUART) {
@@ -25,7 +26,7 @@ void uartInit() {
void uartHandle() { void uartHandle() {
if (myUART) { if (myUART) {
if (!jsonReadBool(configSetupJson, "uart")) { if (!jsonReadBool(configSetupJson, "uartEnable")) {
return; return;
} }
static String incStr; static String incStr;
@@ -50,4 +51,5 @@ void parse(String& incStr) {
orderBuf += incStr; orderBuf += incStr;
SerialPrint("I", "=>UART", incStr); SerialPrint("I", "=>UART", incStr);
} }
} }
#endif

View File

@@ -1,6 +1,5 @@
#ifdef telegram
#include "Telegram.h" #include "Telegram.h"
CTBot* myBot{ nullptr }; CTBot* myBot{ nullptr };
void telegramInit() { void telegramInit() {
@@ -119,4 +118,5 @@ String returnListOfParams() {
cmdStr = deleteBeforeDelimiter(cmdStr, "\n"); cmdStr = deleteBeforeDelimiter(cmdStr, "\n");
} }
return out; return out;
} }
#endif

View File

@@ -20,24 +20,12 @@ void web_init() {
server.on("/set", HTTP_GET, [](AsyncWebServerRequest* request) { server.on("/set", HTTP_GET, [](AsyncWebServerRequest* request) {
//==============================set.device.json==================================================================================================== //==============================set.device.json====================================================================================================
if (request->hasArg("addItem")) { if (request->hasArg("addItem")) {
#ifdef FLASH_SIZE_1MB
itemName = request->getParam("addItem")->value();
myNotAsyncActions->make(do_addItem);
#endif
#ifndef FLASH_SIZE_1MB
addItem(request->getParam("addItem")->value()); addItem(request->getParam("addItem")->value());
#endif
request->redirect("/?set.device"); request->redirect("/?set.device");
} }
if (request->hasArg("addPreset")) { if (request->hasArg("addPreset")) {
#ifdef FLASH_SIZE_1MB
presetName = request->getParam("addPreset")->value();
myNotAsyncActions->make(do_addPreset);
#endif
#ifndef FLASH_SIZE_1MB
addPreset(request->getParam("addPreset")->value()); addPreset(request->getParam("addPreset")->value());
#endif
jsonWriteStr(configSetupJson, "warning1", F("<div style='margin-top:10px;margin-bottom:10px;'><font color='black'><p style='border: 1px solid #DCDCDC; border-radius: 3px; background-color: #ffc7c7; padding: 10px;'>Требуется перезагрузка</p></font></div>")); jsonWriteStr(configSetupJson, "warning1", F("<div style='margin-top:10px;margin-bottom:10px;'><font color='black'><p style='border: 1px solid #DCDCDC; border-radius: 3px; background-color: #ffc7c7; padding: 10px;'>Требуется перезагрузка</p></font></div>"));
request->redirect("/?set.device"); request->redirect("/?set.device");
} }
@@ -109,12 +97,11 @@ void web_init() {
request->send(200); request->send(200);
} }
#ifdef LOGGING_ENABLED
if (request->hasArg("cleanlog")) { if (request->hasArg("cleanlog")) {
cleanLogAndData(); cleanLogAndData();
request->send(200); request->send(200);
} }
#endif
//==============================wifi settings============================================= //==============================wifi settings=============================================
if (request->hasArg("devname")) { if (request->hasArg("devname")) {
@@ -279,29 +266,37 @@ void web_init() {
myNotAsyncActions->make(do_BUSSCAN); myNotAsyncActions->make(do_BUSSCAN);
request->redirect("/?set.utilities"); request->redirect("/?set.utilities");
} }
if (request->hasArg("uart")) { if (request->hasArg("uartEnable")) {
bool value = request->getParam("uart")->value().toInt(); bool value = request->getParam("uartEnable")->value().toInt();
jsonWriteBool(configSetupJson, "uart", value); jsonWriteBool(configSetupJson, "uartEnable", value);
saveConfig(); saveConfig();
#ifdef uartEnable
uartInit(); uartInit();
#endif
request->send(200); request->send(200);
} }
if (request->hasArg("uartS")) { if (request->hasArg("uartS")) {
jsonWriteStr(configSetupJson, "uartS", request->getParam("uartS")->value()); jsonWriteStr(configSetupJson, "uartS", request->getParam("uartS")->value());
saveConfig(); saveConfig();
#ifdef uartEnable
uartInit(); uartInit();
#endif
request->send(200); request->send(200);
} }
if (request->hasArg("uartTX")) { if (request->hasArg("uartTX")) {
jsonWriteStr(configSetupJson, "uartTX", request->getParam("uartTX")->value()); jsonWriteStr(configSetupJson, "uartTX", request->getParam("uartTX")->value());
saveConfig(); saveConfig();
#ifdef uartEnable
uartInit(); uartInit();
#endif
request->send(200); request->send(200);
} }
if (request->hasArg("uartRX")) { if (request->hasArg("uartRX")) {
jsonWriteStr(configSetupJson, "uartRX", request->getParam("uartRX")->value()); jsonWriteStr(configSetupJson, "uartRX", request->getParam("uartRX")->value());
saveConfig(); saveConfig();
#ifdef uartEnable
uartInit(); uartInit();
#endif
request->send(200); request->send(200);
} }
@@ -335,26 +330,31 @@ void web_init() {
SerialPrint("I", "Update", "firmware version: " + String(lastVersion)); SerialPrint("I", "Update", "firmware version: " + String(lastVersion));
String msg = ""; String msg = "";
//if (FLASH_SIZE_1MB) { #ifdef FLASH_SIZE_1MB
// msg = F("Обновление невозможно, память устройства 1 мб"); if (FLASH_SIZE_1MB) {
//} msg = F("Обновление невозможно, память устройства 1 мб");
//else {
if (lastVersion == FIRMWARE_VERSION) {
msg = F("Актуальная версия прошивки уже установлена.");
} }
else if (lastVersion > FIRMWARE_VERSION) { else {
msg = F("Новая версия прошивки<a href=\"#\" class=\"btn btn-block btn-danger\" onclick=\"send_request(this, '/upgrade');setTimeout(function(){ location.href='/?set.device'; }, 90000);html('my-block','<span class=loader></span>Идет обновление прошивки, после обновления страница перезагрузится автоматически...')\">Установить</a>"); #endif
if (lastVersion == FIRMWARE_VERSION) {
msg = F("Актуальная версия прошивки уже установлена.");
}
else if (lastVersion > FIRMWARE_VERSION) {
msg = F("Новая версия прошивки<a href=\"#\" class=\"btn btn-block btn-danger\" onclick=\"send_request(this, '/upgrade');setTimeout(function(){ location.href='/?set.device'; }, 90000);html('my-block','<span class=loader></span>Идет обновление прошивки, после обновления страница перезагрузится автоматически...')\">Установить</a>");
}
else if (lastVersion == -1) {
msg = F("Cервер не найден. Попробуйте повторить позже...");
}
else if (lastVersion == -2) {
msg = F("Устройство не подключено к роутеру!");
}
else if (lastVersion < FIRMWARE_VERSION) {
msg = F("Ошибка версии. Попробуйте повторить позже...");
}
#ifdef FLASH_SIZE_1MB
} }
else if (lastVersion == -1) { #endif
msg = F("Cервер не найден. Попробуйте повторить позже...");
}
else if (lastVersion == -2) {
msg = F("Устройство не подключено к роутеру!");
}
else if (lastVersion < FIRMWARE_VERSION) {
msg = F("Ошибка версии. Попробуйте повторить позже...");
}
//}
// else if (lastVersion == "") { // else if (lastVersion == "") {
//msg = F("Нажмите на кнопку \"обновить прошивку\" повторно..."); //msg = F("Нажмите на кнопку \"обновить прошивку\" повторно...");

View File

@@ -1,7 +1,7 @@
#include "Consts.h"
#ifdef SensorBme280Enabled
#include "items/SensorBme280Class.h" #include "items/SensorBme280Class.h"
#include "BufferExecute.h" #include "BufferExecute.h"
//#ifdef SensorBme280Enabled
//=========================================Модуль ультрозвукового дальномера================================================================== //=========================================Модуль ультрозвукового дальномера==================================================================
//bme280-temp;id;anydata;Сенсоры;Температура;order;c[1] //bme280-temp;id;anydata;Сенсоры;Температура;order;c[1]
//bme280-hum;id;anydata;Сенсоры;Температура;order;c[1] //bme280-hum;id;anydata;Сенсоры;Температура;order;c[1]
@@ -44,4 +44,4 @@ void bme280ReadingPress() {
String key = sCmd.order(); String key = sCmd.order();
mySensorBme280.SensorBme280ReadPress(key); mySensorBme280.SensorBme280ReadPress(key);
} }
//#endif #endif

View File

@@ -1,7 +1,7 @@
#include "Consts.h"
#ifdef SensorBmp280Enabled
#include "items/SensorBmp280Class.h" #include "items/SensorBmp280Class.h"
#include "BufferExecute.h" #include "BufferExecute.h"
//#ifdef SensorBmp280Enabled
//=========================================Модуль ультрозвукового дальномера================================================================== //=========================================Модуль ультрозвукового дальномера==================================================================
//bmp280-temp;id;anydata;Сенсоры;Температура;order;c[1] //bmp280-temp;id;anydata;Сенсоры;Температура;order;c[1]
//bmp280-hum;id;anydata;Сенсоры;Температура;order;c[1] //bmp280-hum;id;anydata;Сенсоры;Температура;order;c[1]
@@ -32,4 +32,4 @@ void bmp280ReadingPress() {
String key = sCmd.order(); String key = sCmd.order();
mySensorBmp280.SensorBmp280ReadPress(key); mySensorBmp280.SensorBmp280ReadPress(key);
} }
//#endif #endif

View File

@@ -1,7 +1,7 @@
#include "Consts.h"
#ifdef SensorDhtEnabled
#include "items/SensorDhtClass.h" #include "items/SensorDhtClass.h"
#include "BufferExecute.h" #include "BufferExecute.h"
//#ifdef SensorDhtEnabled
//=========================================DHT Sensor================================================================== //=========================================DHT Sensor==================================================================
//dht-temp;id;anydata;Сенсоры;Температура;order;pin;type[dht11];c[1] //dht-temp;id;anydata;Сенсоры;Температура;order;pin;type[dht11];c[1]
//dht-hum;id;anydata;Сенсоры;Влажность;order;pin;type[dht11];c[1] //dht-hum;id;anydata;Сенсоры;Влажность;order;pin;type[dht11];c[1]
@@ -32,4 +32,4 @@ void dhtReadingHum() {
String key = sCmd.order(); String key = sCmd.order();
mySensorDht.SensorDhtReadHum(key); mySensorDht.SensorDhtReadHum(key);
} }
//#endif #endif

View File

@@ -1,23 +1,23 @@
//#include "items/SensorModbusClass.h" #include "Consts.h"
// #ifdef SensorModbusEnabled
//#include "BufferExecute.h" #include "items/SensorModbusClass.h"
////#ifdef SensorModbusEnabled #include "BufferExecute.h"
////=========================================Модуль modbus=================================================================================== //=========================================Модуль modbus===================================================================================
////modbus;id;anydata;Сенсоры;Температура;order;addr[1];regaddr[0];c[1] //modbus;id;anydata;Сенсоры;Температура;order;addr[1];regaddr[0];c[1]
////========================================================================================================================================= //=========================================================================================================================================
//SensorModbusClass mySensorModbus; SensorModbusClass mySensorModbus;
//
//void modbus() { void modbus() {
// mySensorModbus.update(); mySensorModbus.update();
// String key = mySensorModbus.gkey(); String key = mySensorModbus.gkey();
// sCmd.addCommand(key.c_str(), modbusReading); sCmd.addCommand(key.c_str(), modbusReading);
// mySensorModbus.SensorModbusInit(); mySensorModbus.SensorModbusInit();
// mySensorModbus.clear(); mySensorModbus.clear();
//} }
//void modbusReading() { void modbusReading() {
// String key = sCmd.order(); String key = sCmd.order();
// String addr = sCmd.next(); String addr = sCmd.next();
// String regaddr = sCmd.next(); String regaddr = sCmd.next();
// mySensorModbus.SensorModbusRead(key, addr.toInt(), regaddr.toInt()); mySensorModbus.SensorModbusRead(key, addr.toInt(), regaddr.toInt());
//} }
////#endif #endif

View File

@@ -21,12 +21,14 @@ ButtonOut::~ButtonOut() {}
void ButtonOut::execute(String state) { void ButtonOut::execute(String state) {
if (_type == "UART") { if (_type == "UART") {
if (jsonReadBool(configSetupJson, "uart")) { if (jsonReadBool(configSetupJson, "uartEnable")) {
#ifdef uartEnable
if (myUART) { if (myUART) {
String msg = _key + " " + state; String msg = _key + " " + state;
myUART->print(msg); myUART->print(msg);
SerialPrint("I", "<=UART", msg); SerialPrint("I", "<=UART", msg);
} }
#endif
} }
} }
if (state != "" && _pin != "") { if (state != "" && _pin != "") {

View File

@@ -1,9 +1,13 @@
#include "Consts.h"
#ifdef PwmOutEnable
#include "items/vPwmOut.h" #include "items/vPwmOut.h"
#include "Class/LineParsing.h" #include "Class/LineParsing.h"
#include "Global.h" #include "Global.h"
#include "BufferExecute.h" #include "BufferExecute.h"
#include <Arduino.h> #include <Arduino.h>
//this class save data to flash //this class save data to flash
PwmOut::PwmOut(unsigned int pin, String key) { PwmOut::PwmOut(unsigned int pin, String key) {
_pin = pin; _pin = pin;
@@ -52,4 +56,5 @@ void pwmOutExecute() {
myPwmOut->at(number).execute(state); myPwmOut->at(number).execute(state);
} }
} }
} }
#endif

View File

@@ -41,14 +41,18 @@ void setup() {
setChipId(); setChipId();
fileSystemInit(); fileSystemInit();
loadConfig(); loadConfig();
#ifdef uartEnable
uartInit(); uartInit();
#endif
clockInit(); clockInit();
timeInit(); timeInit();
sensorsInit(); //Will be remooved sensorsInit(); //Will be remooved
itemsListInit(); itemsListInit();
espInit(); espInit();
routerConnect(); routerConnect();
#ifdef telegram
telegramInit(); telegramInit();
#endif
uptime_init(); uptime_init();
upgradeInit(); upgradeInit();
HttpServer::init(); HttpServer::init();
@@ -91,9 +95,13 @@ void loop() {
myNotAsyncActions->loop(); myNotAsyncActions->loop();
ts.update(); ts.update();
#ifdef telegram
handleTelegram(); handleTelegram();
#endif
#ifdef uartEnable
uartHandle(); uartHandle();
#endif
if (myLogging != nullptr) { if (myLogging != nullptr) {
for (unsigned int i = 0; i < myLogging->size(); i++) { for (unsigned int i = 0; i < myLogging->size(); i++) {