From e97971137226928169f5c98ef6e282b7f331359e Mon Sep 17 00:00:00 2001 From: biver Date: Wed, 12 Jan 2022 10:51:28 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D1=8F?= =?UTF-8?q?=D0=B5=D0=BC=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=BA?= =?UTF-8?q?=D1=83=20=D1=83=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20lCD2004=20=D0=B8=D0=B7=20=D1=81=D1=86=D0=B5=D0=BD?= =?UTF-8?q?=D0=B0=D1=80=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/items/vSensorLCD2004.cpp | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/items/vSensorLCD2004.cpp b/src/items/vSensorLCD2004.cpp index dfb66eb6..afdf1f48 100644 --- a/src/items/vSensorLCD2004.cpp +++ b/src/items/vSensorLCD2004.cpp @@ -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; isetCursor(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);