add Oled64 module

This commit is contained in:
IoT Manager
2023-10-09 20:38:48 +02:00
parent 0d3e6ee829
commit 928b5a7d5c
9 changed files with 329 additions and 35 deletions

View File

@@ -2,7 +2,7 @@
#include "classes/IoTItem.h"
#include <RobotClass_LiquidCrystal_I2C.h>
RobotClass_LiquidCrystal_I2C *LCDI2C;
RobotClass_LiquidCrystal_I2C* LCDI2C;
class Lcd2004 : public IoTItem {
private:
@@ -12,7 +12,7 @@ class Lcd2004 : public IoTItem {
int _prevStrSize;
String _addr;
bool _isShow = true; // экран показывает
bool _isShow = true; // экран показывает
public:
Lcd2004(String parameters) : IoTItem(parameters) {
@@ -26,9 +26,9 @@ class Lcd2004 : public IoTItem {
}
jsonRead(parameters, "size", size);
int w = selectFromMarkerToMarker(size, ",", 0).toInt(); //количество столбцов
int h = selectFromMarkerToMarker(size, ",", 1).toInt(); //количество строк
if (LCDI2C == nullptr) { //инициализации экрана еще не было
int w = selectFromMarkerToMarker(size, ",", 0).toInt(); // количество столбцов
int h = selectFromMarkerToMarker(size, ",", 1).toInt(); // количество строк
if (LCDI2C == nullptr) { // инициализации экрана еще не было
LCDI2C = new RobotClass_LiquidCrystal_I2C(hexStringToUint8(_addr), w, h, CP_UTF8);
if (LCDI2C != nullptr) {
LCDI2C->init();
@@ -46,7 +46,7 @@ class Lcd2004 : public IoTItem {
jsonRead(parameters, "postfix", _postfix);
}
void drawItem(IoTItem* item) {
void drawItem(IoTItem* item) {
String tmpStr = _prefix;
tmpStr += item->getValue();
tmpStr += _postfix;
@@ -66,15 +66,18 @@ class Lcd2004 : public IoTItem {
}
void onRegEvent(IoTItem* eventItem) {
if (LCDI2C == nullptr) { scanI2C(); return;}
if (!eventItem || _id2show == "") return;
if (LCDI2C == nullptr) {
scanI2C();
return;
}
if (!eventItem || _id2show == "") return;
if (_id2show == eventItem->getID()) {
setValue(eventItem->value, false);
}
}
IoTValue execute(String command, std::vector<IoTValue> &param) {
IoTValue execute(String command, std::vector<IoTValue>& param) {
if (command == "noBacklight")
LCDI2C->noBacklight();
else if (command == "backlight")
@@ -89,7 +92,7 @@ class Lcd2004 : public IoTItem {
if (_isShow) {
LCDI2C->noDisplay();
_isShow = false;
} else {
} else {
LCDI2C->display();
_isShow = true;
}
@@ -119,7 +122,7 @@ class Lcd2004 : public IoTItem {
return {};
}
//печать пустой строки нужной длинны для затирания предыдущего значения на экране
// печать пустой строки нужной длинны для затирания предыдущего значения на экране
void printBlankStr(int strSize) {
String tmpStr = "";
for (int i = 0; i < strSize; i++) tmpStr += " ";
@@ -127,13 +130,13 @@ class Lcd2004 : public IoTItem {
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) {
if (subtype == F("Lcd2004")) {
return new Lcd2004(param);
} else {