mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
Merge branch 'ver4dev' of https://github.com/IoTManagerProject/IoTManager into ver4dev
This commit is contained in:
@@ -44,6 +44,7 @@ class IoTItem {
|
|||||||
virtual IoTGpio* getGpioDriver();
|
virtual IoTGpio* getGpioDriver();
|
||||||
virtual void setValue(IoTValue Value);
|
virtual void setValue(IoTValue Value);
|
||||||
virtual void setValue(String valStr);
|
virtual void setValue(String valStr);
|
||||||
|
String getRoundValue();
|
||||||
|
|
||||||
//методы для графиков
|
//методы для графиков
|
||||||
virtual void publishValue();
|
virtual void publishValue();
|
||||||
|
|||||||
@@ -52,20 +52,7 @@ void IoTItem::loop() {
|
|||||||
//получить
|
//получить
|
||||||
String IoTItem::getValue() {
|
String IoTItem::getValue() {
|
||||||
if (value.isDecimal) {
|
if (value.isDecimal) {
|
||||||
if (_multiply) value.valD = value.valD * _multiply;
|
return getRoundValue();
|
||||||
if (_plus) value.valD = value.valD + _plus;
|
|
||||||
if (_round >= 0 && _round <= 6) {
|
|
||||||
int sot = _round ? pow(10, (int)_round) : 1;
|
|
||||||
value.valD = round(value.valD * sot) / sot;
|
|
||||||
}
|
|
||||||
if (_map1 != _map2) value.valD = map(value.valD, _map1, _map2, _map3, _map4);
|
|
||||||
|
|
||||||
if (_round >= 0 && _round <= 6) {
|
|
||||||
char buf[15];
|
|
||||||
sprintf(buf, ("%1." + (String)_round + "f").c_str(), value.valD);
|
|
||||||
return value.valS = buf;
|
|
||||||
} else
|
|
||||||
return (String)value.valD;
|
|
||||||
} else
|
} else
|
||||||
return value.valS;
|
return value.valS;
|
||||||
}
|
}
|
||||||
@@ -114,9 +101,27 @@ void IoTItem::regEvent(String value, String consoleInfo = "") {
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String IoTItem::getRoundValue() {
|
||||||
|
if (_round >= 0 && _round <= 6) {
|
||||||
|
int sot = _round ? pow(10, (int)_round) : 1;
|
||||||
|
value.valD = round(value.valD * sot) / sot;
|
||||||
|
|
||||||
|
char buf[15];
|
||||||
|
sprintf(buf, ("%1." + (String)_round + "f").c_str(), value.valD);
|
||||||
|
return (String)buf;
|
||||||
|
} else {
|
||||||
|
return (String)value.valD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void IoTItem::regEvent(float regvalue, String consoleInfo = "") {
|
void IoTItem::regEvent(float regvalue, String consoleInfo = "") {
|
||||||
value.valD = regvalue;
|
value.valD = regvalue;
|
||||||
regEvent(getValue(), consoleInfo);
|
|
||||||
|
if (_multiply) value.valD = value.valD * _multiply;
|
||||||
|
if (_plus) value.valD = value.valD + _plus;
|
||||||
|
if (_map1 != _map2) value.valD = map(value.valD, _map1, _map2, _map3, _map4);
|
||||||
|
|
||||||
|
regEvent(getRoundValue(), consoleInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IoTItem::doByInterval() {}
|
void IoTItem::doByInterval() {}
|
||||||
|
|||||||
@@ -36,9 +36,11 @@ class Lcd2004 : public IoTItem {
|
|||||||
LCDI2C = new LiquidCrystal_I2C(hexStringToUint8(addr), w, h);
|
LCDI2C = new LiquidCrystal_I2C(hexStringToUint8(addr), w, h);
|
||||||
if (LCDI2C != nullptr) {
|
if (LCDI2C != nullptr) {
|
||||||
LCDI2C->init();
|
LCDI2C->init();
|
||||||
LCDI2C->backlight();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LCDI2C->clear();
|
||||||
|
LCDI2C->backlight();
|
||||||
|
|
||||||
jsonRead(parameters, "coord", xy);
|
jsonRead(parameters, "coord", xy);
|
||||||
_x = selectFromMarkerToMarker(xy, ",", 0).toInt();
|
_x = selectFromMarkerToMarker(xy, ",", 0).toInt();
|
||||||
@@ -52,14 +54,13 @@ class Lcd2004 : public IoTItem {
|
|||||||
if (LCDI2C != nullptr) {
|
if (LCDI2C != nullptr) {
|
||||||
printBlankStr(_prevStrSize);
|
printBlankStr(_prevStrSize);
|
||||||
|
|
||||||
String tmpStr = "";
|
String tmpStr = getItemValue(_id2show);
|
||||||
if (_descr != "none") tmpStr = _descr + " " + getItemValue(_id2show);
|
if (_descr != "none") tmpStr = _descr + " " + tmpStr;
|
||||||
else tmpStr = getItemValue(_id2show);
|
|
||||||
LCDI2C->setCursor(_x, _y);
|
LCDI2C->setCursor(_x, _y);
|
||||||
LCDI2C->print(tmpStr);
|
LCDI2C->print(tmpStr);
|
||||||
|
|
||||||
//LCDI2C->print("Helloy,Manager 404 !");
|
//LCDI2C->print("Helloy,Manager 404 !");
|
||||||
|
//Serial.printf("ffff %s\n", _id2show);
|
||||||
_prevStrSize = tmpStr.length();
|
_prevStrSize = tmpStr.length();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -113,7 +114,10 @@ class Lcd2004 : public IoTItem {
|
|||||||
LCDI2C->print(tmpStr);
|
LCDI2C->print(tmpStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
~Lcd2004(){};
|
~Lcd2004(){
|
||||||
|
if (LCDI2C) delete LCDI2C;
|
||||||
|
LCDI2C = nullptr;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
void *getAPI_Lcd2004(String subtype, String param) {
|
void *getAPI_Lcd2004(String subtype, String param) {
|
||||||
|
|||||||
Reference in New Issue
Block a user