mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
Var changes
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#define LED_PIN 2
|
||||
#define FLASH_4MB true
|
||||
|
||||
|
||||
#define MQTT_RECONNECT_INTERVAL 20000
|
||||
|
||||
#define TELEMETRY_UPDATE_INTERVAL 7200000
|
||||
@@ -29,6 +30,7 @@
|
||||
//#define WEBSOCKET_ENABLED
|
||||
//#define LAYOUT_IN_RAM
|
||||
//#define UDP_ENABLED
|
||||
//#define SSDP
|
||||
|
||||
/*
|
||||
* Sensor
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
* Libraries
|
||||
*/
|
||||
//===================Libraries===================================================================================================================================================
|
||||
#include <Arduino.h>
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
#include "ESP32.h"
|
||||
#include "ESP8266.h"
|
||||
//
|
||||
|
||||
#include "Consts.h"
|
||||
#include "Errors.h"
|
||||
#include "GyverFilters.h"
|
||||
@@ -23,8 +20,6 @@
|
||||
#include "Utils\PrintMessage.h"
|
||||
#include "Utils\WiFiUtils.h"
|
||||
|
||||
//=========ПОДКЛЮЧЕНИЕ ОБЩИХ БИБЛИОТЕК===============
|
||||
|
||||
#include <Adafruit_BME280.h>
|
||||
#include <Adafruit_BMP280.h>
|
||||
#include <Bounce2.h>
|
||||
@@ -45,31 +40,18 @@ extern AsyncWebSocket ws;
|
||||
#endif
|
||||
|
||||
extern Clock* timeNow;
|
||||
|
||||
extern TickerScheduler ts;
|
||||
|
||||
|
||||
|
||||
extern WiFiClient espClient;
|
||||
|
||||
extern PubSubClient mqtt;
|
||||
|
||||
extern StringCommand sCmd;
|
||||
|
||||
extern AsyncWebServer server;
|
||||
|
||||
extern DallasTemperature sensors;
|
||||
|
||||
extern OneWire *oneWire;
|
||||
|
||||
extern boolean but[NUM_BUTTONS];
|
||||
|
||||
extern Bounce* buttons;
|
||||
|
||||
/*
|
||||
* Global vars
|
||||
*/
|
||||
|
||||
//Global vars
|
||||
extern boolean just_load;
|
||||
|
||||
// Json
|
||||
@@ -80,82 +62,34 @@ extern String configOptionJson; //для трансфера
|
||||
// Mqtt
|
||||
extern String chipId;
|
||||
extern String prex;
|
||||
|
||||
extern String all_widgets;
|
||||
|
||||
extern String scenario;
|
||||
|
||||
//orders and events
|
||||
extern String orderBuf;
|
||||
extern String eventBuf;
|
||||
|
||||
extern String itemsFile;
|
||||
extern String itemsLine;
|
||||
|
||||
// Sensors
|
||||
extern String sensorReadingMap;
|
||||
|
||||
|
||||
|
||||
|
||||
extern String analog_value_names_list;
|
||||
extern int enter_to_analog_counter;
|
||||
|
||||
extern String dallas_value_name;
|
||||
extern int enter_to_dallas_counter;
|
||||
|
||||
extern String levelPr_value_name;
|
||||
extern String ultrasonicCm_value_name;
|
||||
|
||||
extern String dhtT_value_name;
|
||||
extern String dhtH_value_name;
|
||||
|
||||
extern String bmp280T_value_name;
|
||||
extern String bmp280P_value_name;
|
||||
|
||||
extern String bme280T_value_name;
|
||||
extern String bme280P_value_name;
|
||||
extern String bme280H_value_name;
|
||||
extern String bme280A_value_name;
|
||||
extern int8_t dallasEnterCounter;
|
||||
|
||||
extern String logging_value_names_list;
|
||||
extern int enter_to_logging_counter;
|
||||
|
||||
extern int scenario_line_status[40];
|
||||
|
||||
extern String lastVersion;
|
||||
|
||||
extern boolean checkUpdatesFlag;
|
||||
extern boolean updateFlag;
|
||||
extern boolean mqttParamsChanged;
|
||||
extern boolean udp_data_parse;
|
||||
extern boolean mqtt_send_settings_to_udp;
|
||||
extern boolean delElementFlag;
|
||||
extern boolean getJsonListFromCsvFlag;
|
||||
|
||||
extern String csvFile;
|
||||
extern int colum;
|
||||
|
||||
/*
|
||||
* Запрос на скарнирование шины
|
||||
*/
|
||||
//Запрос на скарнирование шины
|
||||
extern boolean busScanFlag;
|
||||
/*
|
||||
* Запрос на сканирование шины, указание какую
|
||||
*/
|
||||
extern BusScanner_t busToScan;
|
||||
|
||||
//Запрос на сканирование шины, указание какую
|
||||
extern BusScanner_t busToScan;
|
||||
extern boolean fsCheckFlag;
|
||||
|
||||
extern int sensors_reading_map[15];
|
||||
|
||||
/*
|
||||
* Global functions
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
//Global functions
|
||||
// Logging
|
||||
extern void logging();
|
||||
extern void deleteOldDate(String filename, size_t max_lines, String date_to_add);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#ifdef SSDP
|
||||
#include <Arduino.h>
|
||||
|
||||
extern void SsdpInit();
|
||||
extern String xmlNode(String tags, String data);
|
||||
extern String decToHex(uint32_t decValue, byte desiredStringLength);
|
||||
extern String decToHex(uint32_t decValue, byte desiredStringLength);
|
||||
#endif
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
|
||||
@@ -7,28 +8,25 @@ class ButtonOutClass : public LineParsing {
|
||||
public:
|
||||
ButtonOutClass() : LineParsing(){};
|
||||
|
||||
void pinModeSet() {
|
||||
void init() {
|
||||
if (_pin != "") {
|
||||
pinMode(_pin.toInt(), OUTPUT);
|
||||
}
|
||||
jsonWriteStr(configOptionJson, _key + "_pin", _pin);
|
||||
jsonWriteStr(configOptionJson, _key + "_inv", _inv);
|
||||
}
|
||||
|
||||
void pinStateSetDefault() {
|
||||
if (_inv == "" && _state != "") {
|
||||
pinChange(_key, _pin, _state, true);
|
||||
}
|
||||
pinChange(_key, _state);
|
||||
}
|
||||
|
||||
void pinStateSetInvDefault() {
|
||||
if (_inv != "" && _state != "") {
|
||||
pinChange(_key, _pin, _state, false);
|
||||
}
|
||||
}
|
||||
|
||||
void pinChange(String key, String pin, String state, bool rev) {
|
||||
void pinChange(String key, String state) {
|
||||
String pin = jsonReadStr(configOptionJson, key + "_pin");
|
||||
String inv = jsonReadStr(configOptionJson, key + "_inv");
|
||||
int pinInt = pin.toInt();
|
||||
int stateInt;
|
||||
if (rev) {
|
||||
|
||||
if (inv == "") {
|
||||
digitalWrite(pinInt, state.toInt());
|
||||
} else {
|
||||
digitalWrite(pinInt, !state.toInt());
|
||||
|
||||
46
include/items/SensorDallasClass.h
Normal file
46
include/items/SensorDallasClass.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
#include "items/SensorConvertingClass.h"
|
||||
|
||||
class SensorDallasClass : public SensorConvertingClass {
|
||||
public:
|
||||
SensorDallasClass() : SensorConvertingClass(){};
|
||||
|
||||
void SensorDallasInit() {
|
||||
oneWire = new OneWire((uint8_t)_pin.toInt());
|
||||
sensors.setOneWire(oneWire);
|
||||
sensors.begin();
|
||||
sensors.setResolution(48);
|
||||
|
||||
sensorReadingMap += _key + ",";
|
||||
dallasEnterCounter++;
|
||||
|
||||
jsonWriteInt(configOptionJson, _key + "_num", dallasEnterCounter);
|
||||
jsonWriteStr(configOptionJson, _key + "_map", _map);
|
||||
jsonWriteStr(configOptionJson, _key + "_с", _c);
|
||||
}
|
||||
|
||||
void SensorDallasRead(String key) {
|
||||
float value;
|
||||
byte num = sensors.getDS18Count();
|
||||
sensors.requestTemperatures();
|
||||
|
||||
int cnt = jsonReadInt(configOptionJson, key + "_num");
|
||||
|
||||
for (byte i = 0; i < num; i++) {
|
||||
if (i == cnt) {
|
||||
value = sensors.getTempCByIndex(i);
|
||||
//value = this->mapping(key, value);
|
||||
float valueFl = this->correction(key, value);
|
||||
eventGen(key, "");
|
||||
jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||
MqttClient::publishStatus(key, String(valueFl));
|
||||
Serial.println("[I] sensor '" + key + "' data: " + String(valueFl));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
extern SensorDallasClass mySensorDallas;
|
||||
@@ -2,16 +2,25 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "Class/LineParsing.h"
|
||||
#include "items/SensorConvertingClass.h"
|
||||
#include "Global.h"
|
||||
#include "items/SensorConvertingClass.h"
|
||||
|
||||
class SensorUltrasonic : public SensorConvertingClass {
|
||||
public:
|
||||
SensorUltrasonic() : SensorConvertingClass(){};
|
||||
void init() {
|
||||
sensorReadingMap += _key + ",";
|
||||
String trig = selectFromMarkerToMarker(_pin, ",", 0);
|
||||
String echo = selectFromMarkerToMarker(_pin, ",", 1);
|
||||
jsonWriteStr(configOptionJson, _key + "_trig", trig);
|
||||
jsonWriteStr(configOptionJson, _key + "_echo", echo);
|
||||
jsonWriteStr(configOptionJson, _key + "_map", _map);
|
||||
jsonWriteStr(configOptionJson, _key + "_с", _c);
|
||||
}
|
||||
|
||||
int SensorUltrasonicRead(String key, String pin) {
|
||||
int trig = selectFromMarkerToMarker(pin, ",", 0).toInt();
|
||||
int echo = selectFromMarkerToMarker(pin, ",", 1).toInt();
|
||||
void SensorUltrasonicRead(String key) {
|
||||
int trig = jsonReadStr(configOptionJson, key + "_trig").toInt();
|
||||
int echo = jsonReadStr(configOptionJson, key + "_echo").toInt();
|
||||
int value;
|
||||
|
||||
digitalWrite(trig, LOW);
|
||||
@@ -28,7 +37,6 @@ class SensorUltrasonic : public SensorConvertingClass {
|
||||
jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||
MqttClient::publishStatus(key, String(valueFl));
|
||||
Serial.println("[I] sensor '" + key + "' data: " + String(valueFl));
|
||||
return value;
|
||||
}
|
||||
};
|
||||
extern SensorUltrasonic mySensorUltrasonic;
|
||||
@@ -22,4 +22,7 @@ extern void analogAdc();
|
||||
extern void analogReading();
|
||||
|
||||
extern void ultrasonicCm();
|
||||
extern void ultrasonicReading();
|
||||
extern void ultrasonicReading();
|
||||
|
||||
extern void dallasTemp();
|
||||
extern void dallasReading();
|
||||
Reference in New Issue
Block a user