mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
экран oled
This commit is contained in:
@@ -810,12 +810,31 @@
|
|||||||
"chatID": "",
|
"chatID": "",
|
||||||
"num": 53
|
"num": 53
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"header": "Экраны"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "54. OLED экран 128*64",
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "Oled128",
|
||||||
|
"id": "oled",
|
||||||
|
"widget": "",
|
||||||
|
"page": "",
|
||||||
|
"descr": "T",
|
||||||
|
"descr1": "C",
|
||||||
|
"int": 1,
|
||||||
|
"addr": "0x3C",
|
||||||
|
"coord": "0,10",
|
||||||
|
"id2show": "id датчика",
|
||||||
|
"shrift": "2",
|
||||||
|
"num": 54
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"header": "screens"
|
"header": "screens"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "54. LCD экран 2004",
|
"name": "55. LCD экран 2004",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Lcd2004",
|
"subtype": "Lcd2004",
|
||||||
"id": "Lcd",
|
"id": "Lcd",
|
||||||
@@ -828,10 +847,10 @@
|
|||||||
"id2show": "",
|
"id2show": "",
|
||||||
"prefix": "",
|
"prefix": "",
|
||||||
"postfix": "",
|
"postfix": "",
|
||||||
"num": 54
|
"num": 55
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "55. LCD экран 1602",
|
"name": "56. LCD экран 1602",
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Lcd2004",
|
"subtype": "Lcd2004",
|
||||||
"id": "Lcd",
|
"id": "Lcd",
|
||||||
@@ -844,11 +863,11 @@
|
|||||||
"id2show": "",
|
"id2show": "",
|
||||||
"prefix": "",
|
"prefix": "",
|
||||||
"postfix": "",
|
"postfix": "",
|
||||||
"num": 55
|
"num": 56
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"global": 0,
|
"global": 0,
|
||||||
"name": "56. 7 сегментный дисплей TM16XX",
|
"name": "57. 7 сегментный дисплей TM16XX",
|
||||||
"type": "Writing",
|
"type": "Writing",
|
||||||
"subtype": "TM16XX",
|
"subtype": "TM16XX",
|
||||||
"id": "tm",
|
"id": "tm",
|
||||||
@@ -864,6 +883,6 @@
|
|||||||
"intensity": "5",
|
"intensity": "5",
|
||||||
"on": "1",
|
"on": "1",
|
||||||
"id2show": "",
|
"id2show": "",
|
||||||
"num": 56
|
"num": 57
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -368,6 +368,12 @@
|
|||||||
"active": false
|
"active": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"Экраны": [
|
||||||
|
{
|
||||||
|
"path": "src/modules/display/Oled128",
|
||||||
|
"active": true
|
||||||
|
}
|
||||||
|
],
|
||||||
"screens": [
|
"screens": [
|
||||||
{
|
{
|
||||||
"path": "src/modules/display/DwinI",
|
"path": "src/modules/display/DwinI",
|
||||||
|
|||||||
@@ -368,6 +368,12 @@
|
|||||||
"active": false
|
"active": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"Экраны": [
|
||||||
|
{
|
||||||
|
"path": "src/modules/display/Oled128",
|
||||||
|
"active": true
|
||||||
|
}
|
||||||
|
],
|
||||||
"screens": [
|
"screens": [
|
||||||
{
|
{
|
||||||
"path": "src/modules/display/DwinI",
|
"path": "src/modules/display/DwinI",
|
||||||
|
|||||||
@@ -410,6 +410,7 @@ lib_deps =
|
|||||||
adafruit/Adafruit BusIO @ ^1.13.2
|
adafruit/Adafruit BusIO @ ^1.13.2
|
||||||
dfrobot/DFRobotDFPlayerMini @ ^1.0.5
|
dfrobot/DFRobotDFPlayerMini @ ^1.0.5
|
||||||
adafruit/Adafruit BusIO @ ^1.13.2
|
adafruit/Adafruit BusIO @ ^1.13.2
|
||||||
|
gyverlibs/GyverOLED @ 1.4
|
||||||
https://github.com/robotclass/RobotClass_LiquidCrystal_I2C
|
https://github.com/robotclass/RobotClass_LiquidCrystal_I2C
|
||||||
marcoschwartz/LiquidCrystal_I2C@^1.1.4
|
marcoschwartz/LiquidCrystal_I2C@^1.1.4
|
||||||
https://github.com/maxint-rd/TM16xx
|
https://github.com/maxint-rd/TM16xx
|
||||||
@@ -449,6 +450,7 @@ build_src_filter =
|
|||||||
+<modules/exec/Pcf8574>
|
+<modules/exec/Pcf8574>
|
||||||
+<modules/exec/Pwm8266>
|
+<modules/exec/Pwm8266>
|
||||||
+<modules/exec/TelegramLT>
|
+<modules/exec/TelegramLT>
|
||||||
|
+<modules/display/Oled128>
|
||||||
+<modules/display/Lcd2004>
|
+<modules/display/Lcd2004>
|
||||||
+<modules/display/TM16XX>
|
+<modules/display/TM16XX>
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ void* getAPI_Multitouch(String subtype, String params);
|
|||||||
void* getAPI_Pcf8574(String subtype, String params);
|
void* getAPI_Pcf8574(String subtype, String params);
|
||||||
void* getAPI_Pwm8266(String subtype, String params);
|
void* getAPI_Pwm8266(String subtype, String params);
|
||||||
void* getAPI_TelegramLT(String subtype, String params);
|
void* getAPI_TelegramLT(String subtype, String params);
|
||||||
|
void* getAPI_Oled128(String subtype, String params);
|
||||||
void* getAPI_Lcd2004(String subtype, String params);
|
void* getAPI_Lcd2004(String subtype, String params);
|
||||||
void* getAPI_TM16XX(String subtype, String params);
|
void* getAPI_TM16XX(String subtype, String params);
|
||||||
|
|
||||||
@@ -73,6 +74,7 @@ if ((tmpAPI = getAPI_Multitouch(subtype, params)) != nullptr) return tmpAPI;
|
|||||||
if ((tmpAPI = getAPI_Pcf8574(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_Pcf8574(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_Pwm8266(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_Pwm8266(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_TelegramLT(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_TelegramLT(subtype, params)) != nullptr) return tmpAPI;
|
||||||
|
if ((tmpAPI = getAPI_Oled128(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_Lcd2004(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_Lcd2004(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_TM16XX(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_TM16XX(subtype, params)) != nullptr) return tmpAPI;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|||||||
199
src/modules/display/Oled128/Oled128.cpp
Normal file
199
src/modules/display/Oled128/Oled128.cpp
Normal file
@@ -0,0 +1,199 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#include "Global.h"
|
||||||
|
#include "classes/IoTItem.h"
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <GyverOLED.h>
|
||||||
|
//GyverOLED<SSD1306_128x32, OLED_BUFFER> oled;
|
||||||
|
//GyverOLED<SSD1306_128x32, OLED_NO_BUFFER> oled;
|
||||||
|
//GyverOLED<SSD1306_128x64, OLED_BUFFER> oled;
|
||||||
|
//GyverOLED<SSD1306_128x64, OLED_NO_BUFFER> oled;
|
||||||
|
//GyverOLED<SSD1306_128x64, OLED_BUFFER, OLED_SPI, 8, 7, 6> oled;
|
||||||
|
GyverOLED<SSH1106_128x64> oled;
|
||||||
|
|
||||||
|
|
||||||
|
class Oled128 : public IoTItem {
|
||||||
|
private:
|
||||||
|
unsigned int _x;
|
||||||
|
unsigned int _y;
|
||||||
|
|
||||||
|
unsigned int _k;
|
||||||
|
|
||||||
|
int _shrift;
|
||||||
|
|
||||||
|
String _id2show;
|
||||||
|
String _descr;
|
||||||
|
String _descr1;
|
||||||
|
|
||||||
|
int _prevStrSize;
|
||||||
|
|
||||||
|
bool _isShow = true; // экран показывает
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
Oled128(String parameters) : IoTItem(parameters) {
|
||||||
|
|
||||||
|
String addr, size, xy, k ;
|
||||||
|
_prevStrSize = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
jsonRead(parameters, "addr", addr);
|
||||||
|
if (addr == "") {
|
||||||
|
//scanI2C();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
jsonRead(parameters, "coord", xy);
|
||||||
|
_x = selectFromMarkerToMarker(xy, ",", 0).toInt();
|
||||||
|
_y = selectFromMarkerToMarker(xy, ",", 1).toInt();
|
||||||
|
|
||||||
|
jsonRead(parameters, "descr", _descr);
|
||||||
|
jsonRead(parameters, "id2show", _id2show);
|
||||||
|
jsonRead(parameters, "descr1", _descr1);
|
||||||
|
//jsonRead(parameters, "scale", _k);
|
||||||
|
jsonRead(parameters, "shrift", _shrift);
|
||||||
|
|
||||||
|
// Wire.begin(2,0); // Инициализация шины I2C для модуля E01
|
||||||
|
|
||||||
|
oled.init(); // инициализация экрана
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void doByInterval() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
printBlankStr(_prevStrSize);
|
||||||
|
|
||||||
|
|
||||||
|
String tmpStr = "";
|
||||||
|
|
||||||
|
//if (_descr != "none") tmpStr = _descr + " " + getItemValue(_id2show);
|
||||||
|
if (_descr != "none") tmpStr = _descr + " " + getItemValue(_id2show) + " " + _descr1;
|
||||||
|
else tmpStr = getItemValue(_id2show);
|
||||||
|
|
||||||
|
//oled.setScale(2);
|
||||||
|
|
||||||
|
oled.setScale(_shrift);
|
||||||
|
|
||||||
|
oled.setCursorXY(_x, _y);
|
||||||
|
|
||||||
|
oled.print(tmpStr);
|
||||||
|
|
||||||
|
oled.update();
|
||||||
|
|
||||||
|
_prevStrSize = tmpStr.length();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
IoTValue execute(String command, std::vector<IoTValue> ¶m) { // будет возможным использовать, когда сценарии запустятся
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (command == "scroll") {
|
||||||
|
String tmpStr = "";
|
||||||
|
oled.clear();
|
||||||
|
uint32_t tmr = millis();
|
||||||
|
oled.autoPrintln(false);
|
||||||
|
int val = 128;
|
||||||
|
for (;;) {
|
||||||
|
//oled.clear(); // ЗАКОММЕНТИРУЙ, ЕСЛИ ВКЛЮЧЕН БУФЕР
|
||||||
|
//oled.setScale(2);
|
||||||
|
|
||||||
|
oled.setScale(_shrift);
|
||||||
|
|
||||||
|
oled.setCursor(val, _y);
|
||||||
|
|
||||||
|
|
||||||
|
oled.print(tmpStr);
|
||||||
|
oled.update();
|
||||||
|
val--;
|
||||||
|
if (millis() - tmr > 5000);// return;
|
||||||
|
|
||||||
|
|
||||||
|
_isShow = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (command == "stopscroll") {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
_isShow = true;
|
||||||
|
// display->backlight();
|
||||||
|
// else if (command == "noDisplay") {
|
||||||
|
// display->noDisplay();
|
||||||
|
// _isShow = false;
|
||||||
|
}
|
||||||
|
else if (command == "display") {
|
||||||
|
// display.display();
|
||||||
|
_isShow = true;
|
||||||
|
} else if (command == "toggle") {
|
||||||
|
if (_isShow) {
|
||||||
|
// display->noDisplay();
|
||||||
|
_isShow = false;
|
||||||
|
} else {
|
||||||
|
// display.display();
|
||||||
|
_isShow = true;
|
||||||
|
}
|
||||||
|
} else if (command == "x") {
|
||||||
|
if (param.size()) {
|
||||||
|
_x = param[0].valD;
|
||||||
|
}
|
||||||
|
} else if (command == "y") {
|
||||||
|
if (param.size()) {
|
||||||
|
_y = param[0].valD;
|
||||||
|
}
|
||||||
|
} else if (command == "descr") {
|
||||||
|
if (param.size()) {
|
||||||
|
_descr = param[0].valS;
|
||||||
|
}
|
||||||
|
} else if (command == "descr1") {
|
||||||
|
if (param.size()) {
|
||||||
|
_descr1 = param[0].valS;
|
||||||
|
}
|
||||||
|
} else if (command == "id2show") {
|
||||||
|
if (param.size()) {
|
||||||
|
_id2show = param[0].valS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
doByInterval();
|
||||||
|
return {};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//печать пустой строки нужной длинны для затирания предыдущего значения на экране
|
||||||
|
void printBlankStr(int strSize) {
|
||||||
|
String tmpStr = "";
|
||||||
|
for (int i = 0; i < strSize; i++) tmpStr += " ";
|
||||||
|
|
||||||
|
// oled.setScale(2);
|
||||||
|
|
||||||
|
oled.setScale(_shrift);
|
||||||
|
|
||||||
|
oled.setCursorXY(_x, _y);
|
||||||
|
|
||||||
|
oled.print(tmpStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
~Oled128(){};
|
||||||
|
};
|
||||||
|
|
||||||
|
void *getAPI_Oled128(String subtype, String param) {
|
||||||
|
if (subtype == F("Oled128")) {
|
||||||
|
return new Oled128(param);
|
||||||
|
} else {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
86
src/modules/display/Oled128/modinfo.json
Normal file
86
src/modules/display/Oled128/modinfo.json
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
{
|
||||||
|
"menuSection": "Экраны",
|
||||||
|
"configItem": [
|
||||||
|
{
|
||||||
|
"name": "OLED экран 128*64",
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "Oled128",
|
||||||
|
"id": "oled",
|
||||||
|
"widget": "",
|
||||||
|
"page": "",
|
||||||
|
"descr": "T",
|
||||||
|
"descr1": "C",
|
||||||
|
"int": 1,
|
||||||
|
"addr": "0x3C",
|
||||||
|
"coord": "0,10",
|
||||||
|
"id2show": "id датчика",
|
||||||
|
"shrift": "2"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"about": {
|
||||||
|
"authorName": "Serghei Crasnicov",
|
||||||
|
"authorContact": "https://t.me/Serghei63",
|
||||||
|
"authorGit": "https://github.com/Serghei63",
|
||||||
|
"specialThanks": "Ilya Belyakov @Biveraxe",
|
||||||
|
"moduleName": "Oled128",
|
||||||
|
"moduleVersion": "1.0",
|
||||||
|
"moduleDesc": "Позволяет выводить на матричные Oled экраны по указанным позициям значения других элементов конфигурации.",
|
||||||
|
"usedRam": 15,
|
||||||
|
"propInfo": {
|
||||||
|
"int": "Период времени в секундах обновления информации на экране по конкретному элементу.",
|
||||||
|
"addr": "Адрес устройства на шине, обычно 0x3c.",
|
||||||
|
"coord": "Координата позиции для вывода данных элемента конфигурации.",
|
||||||
|
"id2show": "id элемента конфигурации.",
|
||||||
|
"shrift": "Шрифт текста от 1 до 4 "
|
||||||
|
},
|
||||||
|
"funcInfo": [
|
||||||
|
{
|
||||||
|
"name": "x",
|
||||||
|
"descr": "Устанавливает первую координату",
|
||||||
|
"params": [
|
||||||
|
"Номер строки первого символа"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "y",
|
||||||
|
"descr": "Устанавливает вторую координату",
|
||||||
|
"params": [
|
||||||
|
"Номер столбца первого символа"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "descr",
|
||||||
|
"descr": "Задает приставку слева от значения, если none значит пусто",
|
||||||
|
"params": [
|
||||||
|
"Строка"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "descr1",
|
||||||
|
"descr": "Задает приставку справа от значения. Если descr none , то не выводится",
|
||||||
|
"params": [
|
||||||
|
"Строка"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "id2show",
|
||||||
|
"descr": "Задает ИД элемента, значение которого хотим отображать на экране",
|
||||||
|
"params": [
|
||||||
|
"Имя элемента конфигурации"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"defActive": true,
|
||||||
|
"usedLibs": {
|
||||||
|
"esp32_4mb": [
|
||||||
|
"gyverlibs/GyverOLED @ 1.4"
|
||||||
|
],
|
||||||
|
"esp32_16mb": [
|
||||||
|
"gyverlibs/GyverOLED @ 1.4"
|
||||||
|
],
|
||||||
|
"esp8266_4mb": [
|
||||||
|
"gyverlibs/GyverOLED @ 1.4"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user