mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 03:49:13 +03:00
Исключаем поддержку параллельного подключения LCD2004 и наводим порядок с библиотеками.
This commit is contained in:
@@ -38,5 +38,5 @@
|
|||||||
0;sensor;anyid;anydata;Сенсоры;Параметр;1;c[1];int[10];type[HDC1080_hum];addr[0x76]*
|
0;sensor;anyid;anydata;Сенсоры;Параметр;1;c[1];int[10];type[HDC1080_hum];addr[0x76]*
|
||||||
0;sensor;anyid;anydata;Сенсоры;Параметр;1;c[1];int[10];type[AHTX0_temp];addr[0x76]
|
0;sensor;anyid;anydata;Сенсоры;Параметр;1;c[1];int[10];type[AHTX0_temp];addr[0x76]
|
||||||
0;sensor;anyid;anydata;Сенсоры;Параметр;1;c[1];int[10];type[AHTX0_hum];addr[0x76]*
|
0;sensor;anyid;anydata;Сенсоры;Параметр;1;c[1];int[10];type[AHTX0_hum];addr[0x76]*
|
||||||
0;LCD2004;lcdid;anydata;Вывод;IP;1;addr[0х27];k[16,2];int[10];c[0,0];val[ip]*
|
0;LCD2004;lcdid;anydata;Вывод;IP;1;addr[0x27];k[16,2];int[10];c[0,0];val[ip]*
|
||||||
0;sensor;anyid;anydata;Сенсоры;Параметр;1;c[1];int[10];type[type1];addr[0x76]*
|
0;sensor;anyid;anydata;Сенсоры;Параметр;1;c[1];int[10];type[type1];addr[0x76]*
|
||||||
Binary file not shown.
@@ -4,7 +4,7 @@
|
|||||||
#include <OneWire.h>
|
#include <OneWire.h>
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "LiquidCrystal_I2C.h"
|
#include "LiquidCrystal_I2C.h"
|
||||||
#include "LiquidCrystal.h"
|
|
||||||
|
|
||||||
class SensorLCD2004;
|
class SensorLCD2004;
|
||||||
|
|
||||||
@@ -17,6 +17,8 @@ class SensorLCD2004 {
|
|||||||
|
|
||||||
void loop();
|
void loop();
|
||||||
void writeLCD2004();
|
void writeLCD2004();
|
||||||
|
void execute(String command);
|
||||||
|
String _key;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned long currentMillis;
|
unsigned long currentMillis;
|
||||||
@@ -27,8 +29,8 @@ class SensorLCD2004 {
|
|||||||
unsigned int _x;
|
unsigned int _x;
|
||||||
unsigned int _y;
|
unsigned int _y;
|
||||||
String _val;
|
String _val;
|
||||||
String _key;
|
|
||||||
String _descr;
|
String _descr;
|
||||||
|
int _prevStrSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern MySensorLCD2004Vector* mySensorLCD20042;
|
extern MySensorLCD2004Vector* mySensorLCD20042;
|
||||||
|
|||||||
@@ -43,9 +43,8 @@ lib_deps =
|
|||||||
robtillaart/SHT2x@^0.1.1
|
robtillaart/SHT2x@^0.1.1
|
||||||
ClosedCube HDC1080
|
ClosedCube HDC1080
|
||||||
Adafruit AHTX0
|
Adafruit AHTX0
|
||||||
LiquidCrystal_I2C
|
|
||||||
BH1750
|
BH1750
|
||||||
fmalpartida/LiquidCrystal@^1.5.0
|
marcoschwartz/LiquidCrystal_I2C@^1.1.4
|
||||||
monitor_filters = esp8266_exception_decoder
|
monitor_filters = esp8266_exception_decoder
|
||||||
upload_speed = 921600
|
upload_speed = 921600
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
@@ -72,9 +71,8 @@ lib_deps =
|
|||||||
robtillaart/SHT2x@^0.1.1
|
robtillaart/SHT2x@^0.1.1
|
||||||
ClosedCube HDC1080
|
ClosedCube HDC1080
|
||||||
Adafruit AHTX0
|
Adafruit AHTX0
|
||||||
LiquidCrystal_I2C
|
|
||||||
BH1750
|
BH1750
|
||||||
fmalpartida/LiquidCrystal@^1.5.0
|
marcoschwartz/LiquidCrystal_I2C@^1.1.4
|
||||||
monitor_filters = esp8266_exception_decoder
|
monitor_filters = esp8266_exception_decoder
|
||||||
upload_speed = 921600
|
upload_speed = 921600
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
@@ -92,7 +90,7 @@ lib_deps =
|
|||||||
ESPAsyncUDP
|
ESPAsyncUDP
|
||||||
CTBot @2.1.6
|
CTBot @2.1.6
|
||||||
MySensors @2.3.2
|
MySensors @2.3.2
|
||||||
fmalpartida/LiquidCrystal@^1.5.0
|
marcoschwartz/LiquidCrystal_I2C@^1.1.4
|
||||||
monitor_filters = esp8266_exception_decoder
|
monitor_filters = esp8266_exception_decoder
|
||||||
upload_speed = 921600
|
upload_speed = 921600
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
@@ -120,9 +118,8 @@ lib_deps =
|
|||||||
robtillaart/SHT2x@^0.1.1
|
robtillaart/SHT2x@^0.1.1
|
||||||
ClosedCube HDC1080
|
ClosedCube HDC1080
|
||||||
Adafruit AHTX0
|
Adafruit AHTX0
|
||||||
LiquidCrystal_I2C
|
|
||||||
BH1750
|
BH1750
|
||||||
fmalpartida/LiquidCrystal@^1.5.0
|
marcoschwartz/LiquidCrystal_I2C@^1.1.4
|
||||||
monitor_filters = esp32_exception_decoder
|
monitor_filters = esp32_exception_decoder
|
||||||
upload_speed = 921600
|
upload_speed = 921600
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
@@ -143,6 +140,7 @@ lib_deps =
|
|||||||
ESP32Servo
|
ESP32Servo
|
||||||
MySensors @2.3.2
|
MySensors @2.3.2
|
||||||
fmalpartida/LiquidCrystal@^1.5.0
|
fmalpartida/LiquidCrystal@^1.5.0
|
||||||
|
marcoschwartz/LiquidCrystal_I2C@^1.1.4
|
||||||
monitor_filters = esp32_exception_decoder
|
monitor_filters = esp32_exception_decoder
|
||||||
upload_speed = 921600
|
upload_speed = 921600
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
|
|||||||
@@ -24,6 +24,10 @@
|
|||||||
#include "items/vSensorUltrasonic.h"
|
#include "items/vSensorUltrasonic.h"
|
||||||
#include "items/vSensorUptime.h"
|
#include "items/vSensorUptime.h"
|
||||||
|
|
||||||
|
#ifdef EnableSensorLCD2004
|
||||||
|
extern LiquidCrystal_I2C *LCDI2C;
|
||||||
|
#endif
|
||||||
|
|
||||||
void loadConfig() {
|
void loadConfig() {
|
||||||
configSetupJson = readFile("config.json", 4096);
|
configSetupJson = readFile("config.json", 4096);
|
||||||
configSetupJson.replace("\r\n", "");
|
configSetupJson.replace("\r\n", "");
|
||||||
@@ -172,7 +176,9 @@ void clearVectors() {
|
|||||||
#endif
|
#endif
|
||||||
#ifdef EnableSensorLCD2004
|
#ifdef EnableSensorLCD2004
|
||||||
if (mySensorLCD20042 != nullptr) {
|
if (mySensorLCD20042 != nullptr) {
|
||||||
|
if(LCDI2C != nullptr) LCDI2C->clear();
|
||||||
mySensorLCD20042->clear();
|
mySensorLCD20042->clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef EnableSensorUltrasonic
|
#ifdef EnableSensorUltrasonic
|
||||||
|
|||||||
@@ -9,8 +9,6 @@
|
|||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
|
||||||
LiquidCrystal *LCDLPT;
|
|
||||||
LiquidCrystal_I2C *LCDI2C;
|
LiquidCrystal_I2C *LCDI2C;
|
||||||
|
|
||||||
SensorLCD2004::SensorLCD2004(String key, unsigned long interval, unsigned int x, unsigned int y, String val, String descr) {
|
SensorLCD2004::SensorLCD2004(String key, unsigned long interval, unsigned int x, unsigned int y, String val, String descr) {
|
||||||
@@ -20,11 +18,18 @@ SensorLCD2004::SensorLCD2004(String key, unsigned long interval, unsigned int x,
|
|||||||
_y = y;
|
_y = y;
|
||||||
_val = val;
|
_val = val;
|
||||||
_descr = descr;
|
_descr = descr;
|
||||||
|
_prevStrSize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SensorLCD2004::~SensorLCD2004() {}
|
SensorLCD2004::~SensorLCD2004() {}
|
||||||
|
|
||||||
|
void SensorLCD2004::execute(String command) {
|
||||||
|
//if (command == "back")
|
||||||
|
|
||||||
|
String par = sCmd.next();
|
||||||
|
//SerialPrint("I", "execute", command + " " + par);
|
||||||
|
}
|
||||||
|
|
||||||
void SensorLCD2004::loop() {
|
void SensorLCD2004::loop() {
|
||||||
currentMillis = millis();
|
currentMillis = millis();
|
||||||
difference = currentMillis - prevMillis;
|
difference = currentMillis - prevMillis;
|
||||||
@@ -35,34 +40,36 @@ void SensorLCD2004::loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SensorLCD2004::writeLCD2004() {
|
void SensorLCD2004::writeLCD2004() {
|
||||||
String tmpStr;
|
if (LCDI2C != nullptr) {
|
||||||
tmpStr = getValue(_val);
|
String tmpStr = "";
|
||||||
if (tmpStr == "no value") tmpStr = _val;
|
for(int i=0; i<_prevStrSize; i++) tmpStr += " ";
|
||||||
|
|
||||||
if (_descr != "none") tmpStr = _descr + " " + tmpStr;
|
|
||||||
|
|
||||||
if(LCDI2C != nullptr) {
|
|
||||||
LCDI2C->setCursor(_x, _y);
|
LCDI2C->setCursor(_x, _y);
|
||||||
LCDI2C->print(tmpStr);
|
LCDI2C->print(tmpStr);
|
||||||
}
|
|
||||||
|
|
||||||
if(LCDLPT != nullptr) {
|
tmpStr = getValue(_val);
|
||||||
LCDLPT->setCursor(_x, _y);
|
if (tmpStr == "no value") tmpStr = _val;
|
||||||
LCDLPT->print(tmpStr);
|
if (_descr != "none") tmpStr = _descr + " " + tmpStr;
|
||||||
}
|
LCDI2C->setCursor(_x, _y);
|
||||||
|
LCDI2C->print(tmpStr);
|
||||||
|
|
||||||
//eventGen2(_key, String(_val));
|
_prevStrSize = tmpStr.length();
|
||||||
//jsonWriteStr(configLiveJson, _key, String(_val));
|
}
|
||||||
//publishStatus(_key, String(_val));
|
|
||||||
SerialPrint("I", "Sensor", "'" + _key + "' data2: " + String(tmpStr));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MySensorLCD2004Vector* mySensorLCD20042 = nullptr;
|
MySensorLCD2004Vector* mySensorLCD20042 = nullptr;
|
||||||
|
|
||||||
|
void lcd2004Execute() {
|
||||||
|
String key = sCmd.order();
|
||||||
|
String command = sCmd.next();
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < mySensorLCD20042->size(); i++) {
|
||||||
|
if (mySensorLCD20042->at(i)._key == key) mySensorLCD20042->at(i).execute(command);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void lcd2004() {
|
void lcd2004() {
|
||||||
myLineParsing.update();
|
myLineParsing.update();
|
||||||
String key = myLineParsing.gkey();
|
String key = myLineParsing.gkey();
|
||||||
String pin = myLineParsing.gpin();
|
|
||||||
String addr = myLineParsing.gaddr();
|
String addr = myLineParsing.gaddr();
|
||||||
String interval = myLineParsing.gint();
|
String interval = myLineParsing.gint();
|
||||||
String c = myLineParsing.gc();
|
String c = myLineParsing.gc();
|
||||||
@@ -73,35 +80,15 @@ void lcd2004() {
|
|||||||
|
|
||||||
int x = selectFromMarkerToMarker(c, ",", 0).toInt();
|
int x = selectFromMarkerToMarker(c, ",", 0).toInt();
|
||||||
int y = selectFromMarkerToMarker(c, ",", 1).toInt();
|
int y = selectFromMarkerToMarker(c, ",", 1).toInt();
|
||||||
int w = selectFromMarkerToMarker(k, ",", 1).toInt(); //количество столбцов
|
int w = selectFromMarkerToMarker(k, ",", 0).toInt(); //количество столбцов
|
||||||
int h = selectFromMarkerToMarker(k, ",", 1).toInt(); //количество строк
|
int h = selectFromMarkerToMarker(k, ",", 1).toInt(); //количество строк
|
||||||
|
|
||||||
if (LCDI2C == nullptr && LCDLPT == nullptr) { //инициализации экрана еще не было
|
if (LCDI2C == nullptr) { //инициализации экрана еще не было
|
||||||
if (addr == "") {
|
LCDI2C = new LiquidCrystal_I2C(hexStringToUint8(addr), w, h);//hexStringToUint8(addr), w, h);
|
||||||
int pin1 = selectFromMarkerToMarker(pin, ",", 0).toInt();
|
if(LCDI2C != nullptr) {
|
||||||
int pin2 = selectFromMarkerToMarker(pin, ",", 1).toInt();
|
LCDI2C->init();
|
||||||
int pin3 = selectFromMarkerToMarker(pin, ",", 2).toInt();
|
LCDI2C->backlight();
|
||||||
int pin4 = selectFromMarkerToMarker(pin, ",", 3).toInt();
|
}
|
||||||
int pin5 = selectFromMarkerToMarker(pin, ",", 4).toInt();
|
|
||||||
int pin6 = selectFromMarkerToMarker(pin, ",", 5).toInt();
|
|
||||||
int pin7 = selectFromMarkerToMarker(pin, ",", 6).toInt();
|
|
||||||
int pin8 = selectFromMarkerToMarker(pin, ",", 7).toInt();
|
|
||||||
int pin9 = selectFromMarkerToMarker(pin, ",", 8).toInt();
|
|
||||||
int pin10 = selectFromMarkerToMarker(pin, ",", 9).toInt();
|
|
||||||
if (pin7) {
|
|
||||||
LCDLPT = new LiquidCrystal(pin1, pin2, pin3, pin4, pin5, pin6, pin7, pin8, pin9, pin10);
|
|
||||||
} else {
|
|
||||||
LCDLPT = new LiquidCrystal(pin1, pin2, pin3, pin4, pin5, pin6);
|
|
||||||
}
|
|
||||||
if(LCDLPT != nullptr) LCDLPT->begin(w, h);
|
|
||||||
//val = (String)pin1 + " " + (String)pin2 + " " + (String)pin3 + " " + (String)pin4 + " " + (String)pin5 + " " + (String)pin6 + " " + (String)pin7 + " " + (String)pin8 + " " + (String)pin9 + " " + (String)pin10;
|
|
||||||
} else {
|
|
||||||
LCDI2C = new LiquidCrystal_I2C(hexStringToUint8(addr));
|
|
||||||
if(LCDI2C != nullptr) {
|
|
||||||
LCDI2C->begin(w, h);
|
|
||||||
LCDI2C->backlight();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -109,5 +96,8 @@ void lcd2004() {
|
|||||||
if (firstTime) mySensorLCD20042 = new MySensorLCD2004Vector();
|
if (firstTime) mySensorLCD20042 = new MySensorLCD2004Vector();
|
||||||
firstTime = false;
|
firstTime = false;
|
||||||
mySensorLCD20042->push_back(SensorLCD2004(key, interval.toInt(), x, y, val, descr));
|
mySensorLCD20042->push_back(SensorLCD2004(key, interval.toInt(), x, y, val, descr));
|
||||||
|
|
||||||
|
sCmd.addCommand(key.c_str(), lcd2004Execute);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user