mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
Добавляем поддержку управления lCD2004 из сценария
This commit is contained in:
@@ -23,10 +23,34 @@ SensorLCD2004::SensorLCD2004(String key, unsigned long interval, unsigned int x,
|
||||
|
||||
SensorLCD2004::~SensorLCD2004() {}
|
||||
|
||||
//печать пустой строки нужной длинны для затирания предыдущего значения на экране
|
||||
void printBlankStr(int x, int y, int strSize){
|
||||
String tmpStr = "";
|
||||
for(int i=0; i<strSize; i++) tmpStr += " ";
|
||||
LCDI2C->setCursor(x, y);
|
||||
LCDI2C->print(tmpStr);
|
||||
}
|
||||
|
||||
void SensorLCD2004::execute(String command) {
|
||||
//if (command == "back")
|
||||
if (command == "noBacklight") LCDI2C->noBacklight();
|
||||
else if (command == "backlight") LCDI2C->backlight();
|
||||
else if (command == "noDisplay") LCDI2C->noDisplay();
|
||||
else if (command == "display") LCDI2C->display();
|
||||
else if (command == "x") {
|
||||
printBlankStr(_x, _y, _prevStrSize);
|
||||
String par = sCmd.next();
|
||||
_x = par.toInt();
|
||||
}
|
||||
else if (command == "y") {
|
||||
String par = sCmd.next();
|
||||
_y = par.toInt();
|
||||
}
|
||||
else { //не команда, значит данные (параметры - x и y)
|
||||
|
||||
}
|
||||
|
||||
writeLCD2004();
|
||||
|
||||
String par = sCmd.next();
|
||||
//SerialPrint("I", "execute", command + " " + par);
|
||||
}
|
||||
|
||||
@@ -41,12 +65,9 @@ void SensorLCD2004::loop() {
|
||||
|
||||
void SensorLCD2004::writeLCD2004() {
|
||||
if (LCDI2C != nullptr) {
|
||||
String tmpStr = "";
|
||||
for(int i=0; i<_prevStrSize; i++) tmpStr += " ";
|
||||
LCDI2C->setCursor(_x, _y);
|
||||
LCDI2C->print(tmpStr);
|
||||
printBlankStr(_x, _y, _prevStrSize);
|
||||
|
||||
tmpStr = getValue(_val);
|
||||
String tmpStr = getValue(_val);
|
||||
if (tmpStr == "no value") tmpStr = _val;
|
||||
if (_descr != "none") tmpStr = _descr + " " + tmpStr;
|
||||
LCDI2C->setCursor(_x, _y);
|
||||
|
||||
Reference in New Issue
Block a user