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

@@ -414,6 +414,10 @@
"path": "src/modules/display/Oled128", "path": "src/modules/display/Oled128",
"active": false "active": false
}, },
{
"path": "src/modules/display/Oled64",
"active": true
},
{ {
"path": "src/modules/display/Smi2_m", "path": "src/modules/display/Smi2_m",
"active": true "active": true

View File

@@ -232,7 +232,7 @@
}, },
{ {
"path": "src/modules/exec/HttpGet", "path": "src/modules/exec/HttpGet",
"active": false "active": true
}, },
{ {
"path": "src/modules/exec/IoTServo", "path": "src/modules/exec/IoTServo",
@@ -316,6 +316,10 @@
"path": "src/modules/display/Oled128", "path": "src/modules/display/Oled128",
"active": false "active": false
}, },
{
"path": "src/modules/display/Oled64",
"active": true
},
{ {
"path": "src/modules/display/Smi2_m", "path": "src/modules/display/Smi2_m",
"active": true "active": true

View File

@@ -730,7 +730,20 @@
}, },
{ {
"global": 0, "global": 0,
"name": "48. Сервопривод", "name": "48. HttpGet",
"type": "Writing",
"subtype": "HttpGet",
"id": "http",
"widget": "",
"page": "",
"descr": "",
"token": "",
"chatID": "",
"num": 48
},
{
"global": 0,
"name": "49. Сервопривод",
"type": "Writing", "type": "Writing",
"subtype": "IoTServo", "subtype": "IoTServo",
"id": "servo", "id": "servo",
@@ -741,11 +754,11 @@
"pin": 12, "pin": 12,
"apin": -1, "apin": -1,
"amap": "0, 4096, 0, 180", "amap": "0, 4096, 0, 180",
"num": 48 "num": 49
}, },
{ {
"global": 0, "global": 0,
"name": "49. Расширитель портов Mcp23017", "name": "50. Расширитель портов Mcp23017",
"type": "Reading", "type": "Reading",
"subtype": "Mcp23017", "subtype": "Mcp23017",
"id": "Mcp", "id": "Mcp",
@@ -755,11 +768,11 @@
"int": "0", "int": "0",
"addr": "0x20", "addr": "0x20",
"index": 1, "index": 1,
"num": 49 "num": 50
}, },
{ {
"global": 0, "global": 0,
"name": "50. MP3 плеер", "name": "51. MP3 плеер",
"type": "Reading", "type": "Reading",
"subtype": "Mp3", "subtype": "Mp3",
"id": "mp3", "id": "mp3",
@@ -769,11 +782,11 @@
"int": 1, "int": 1,
"pins": "14,12", "pins": "14,12",
"volume": 20, "volume": 20,
"num": 50 "num": 51
}, },
{ {
"global": 0, "global": 0,
"name": "51. Сенсорная кнопка", "name": "52. Сенсорная кнопка",
"type": "Writing", "type": "Writing",
"subtype": "Multitouch", "subtype": "Multitouch",
"id": "impulse", "id": "impulse",
@@ -787,11 +800,11 @@
"pinMode": "INPUT", "pinMode": "INPUT",
"debounceDelay": 50, "debounceDelay": 50,
"PWMDelay": 500, "PWMDelay": 500,
"num": 51 "num": 52
}, },
{ {
"global": 0, "global": 0,
"name": "52. Расширитель портов Pcf8574", "name": "53. Расширитель портов Pcf8574",
"type": "Reading", "type": "Reading",
"subtype": "Pcf8574", "subtype": "Pcf8574",
"id": "Pcf", "id": "Pcf",
@@ -801,11 +814,11 @@
"int": "0", "int": "0",
"addr": "0x20", "addr": "0x20",
"index": 1, "index": 1,
"num": 52 "num": 53
}, },
{ {
"global": 0, "global": 0,
"name": "53. PWM ESP8266", "name": "54. PWM ESP8266",
"type": "Writing", "type": "Writing",
"subtype": "Pwm8266", "subtype": "Pwm8266",
"id": "pwm", "id": "pwm",
@@ -817,11 +830,11 @@
"freq": 5000, "freq": 5000,
"val": 0, "val": 0,
"apin": -1, "apin": -1,
"num": 53 "num": 54
}, },
{ {
"global": 0, "global": 0,
"name": "54. Телеграм-Лайт", "name": "55. Телеграм-Лайт",
"type": "Writing", "type": "Writing",
"subtype": "TelegramLT", "subtype": "TelegramLT",
"id": "tg", "id": "tg",
@@ -830,14 +843,14 @@
"descr": "", "descr": "",
"token": "", "token": "",
"chatID": "", "chatID": "",
"num": 54 "num": 55
}, },
{ {
"header": "screens" "header": "screens"
}, },
{ {
"global": 0, "global": 0,
"name": "55. LCD экран 2004", "name": "56. LCD экран 2004",
"type": "Reading", "type": "Reading",
"subtype": "Lcd2004", "subtype": "Lcd2004",
"id": "Lcd", "id": "Lcd",
@@ -850,10 +863,10 @@
"id2show": "", "id2show": "",
"prefix": "", "prefix": "",
"postfix": "", "postfix": "",
"num": 55 "num": 56
}, },
{ {
"name": "56. LCD экран 1602", "name": "57. LCD экран 1602",
"type": "Reading", "type": "Reading",
"subtype": "Lcd2004", "subtype": "Lcd2004",
"id": "Lcd", "id": "Lcd",
@@ -866,11 +879,28 @@
"id2show": "", "id2show": "",
"prefix": "", "prefix": "",
"postfix": "", "postfix": "",
"num": 56 "num": 57
}, },
{ {
"global": 0, "global": 0,
"name": "57. 7 сегментный дисплей TM16XX", "name": "58. OLED экран 64 8266",
"type": "Reading",
"subtype": "Oled64",
"id": "Oled",
"widget": "inputTxt",
"page": "screens",
"descr": "OLED Экран",
"addr": "0x3C",
"coord": "0,0",
"size": "1",
"id2show": "",
"prefix": "",
"postfix": "",
"num": 58
},
{
"global": 0,
"name": "59. 7 сегментный дисплей TM16XX",
"type": "Writing", "type": "Writing",
"subtype": "TM16XX", "subtype": "TM16XX",
"id": "tm", "id": "tm",
@@ -886,6 +916,6 @@
"intensity": "5", "intensity": "5",
"on": "1", "on": "1",
"id2show": "", "id2show": "",
"num": 57 "num": 59
} }
] ]

View File

@@ -330,7 +330,7 @@
}, },
{ {
"path": "src/modules/exec/HttpGet", "path": "src/modules/exec/HttpGet",
"active": false "active": true
}, },
{ {
"path": "src/modules/exec/IoTServo", "path": "src/modules/exec/IoTServo",
@@ -414,6 +414,10 @@
"path": "src/modules/display/Oled128", "path": "src/modules/display/Oled128",
"active": false "active": false
}, },
{
"path": "src/modules/display/Oled64",
"active": true
},
{ {
"path": "src/modules/display/Smi2_m", "path": "src/modules/display/Smi2_m",
"active": true "active": true

View File

@@ -480,6 +480,8 @@ lib_deps =
adafruit/Adafruit BusIO @ ^1.13.2 adafruit/Adafruit BusIO @ ^1.13.2
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/stblassitude/Adafruit_SSD1306_Wemos_OLED
https://github.com/adafruit/Adafruit-GFX-Library
https://github.com/maxint-rd/TM16xx https://github.com/maxint-rd/TM16xx
adafruit/Adafruit GFX Library @ ^1.11.5 adafruit/Adafruit GFX Library @ ^1.11.5
adafruit/Adafruit BusIO @ ^1.13.2 adafruit/Adafruit BusIO @ ^1.13.2
@@ -512,6 +514,7 @@ build_src_filter =
+<modules/exec/ButtonOut> +<modules/exec/ButtonOut>
+<modules/exec/Buzzer> +<modules/exec/Buzzer>
+<modules/exec/Enconder> +<modules/exec/Enconder>
+<modules/exec/HttpGet>
+<modules/exec/IoTServo> +<modules/exec/IoTServo>
+<modules/exec/Mcp23017> +<modules/exec/Mcp23017>
+<modules/exec/Mp3> +<modules/exec/Mp3>
@@ -520,6 +523,7 @@ build_src_filter =
+<modules/exec/Pwm8266> +<modules/exec/Pwm8266>
+<modules/exec/TelegramLT> +<modules/exec/TelegramLT>
+<modules/display/Lcd2004> +<modules/display/Lcd2004>
+<modules/display/Oled64>
+<modules/display/TM16XX> +<modules/display/TM16XX>
[env:esp32_4mb_fromitems] [env:esp32_4mb_fromitems]
@@ -541,12 +545,16 @@ lib_deps =
adafruit/Adafruit BusIO @ ^1.13.2 adafruit/Adafruit BusIO @ ^1.13.2
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/stblassitude/Adafruit_SSD1306_Wemos_OLED
https://github.com/adafruit/Adafruit-GFX-Library
https://github.com/maxint-rd/TM16xx https://github.com/maxint-rd/TM16xx
adafruit/Adafruit GFX Library @ ^1.11.5 adafruit/Adafruit GFX Library @ ^1.11.5
adafruit/Adafruit BusIO @ ^1.13.2
build_src_filter = build_src_filter =
+<modules/virtual/Cron> +<modules/virtual/Cron>
+<modules/virtual/Loging> +<modules/virtual/Loging>
+<modules/virtual/LogingDaily> +<modules/virtual/LogingDaily>
+<modules/virtual/owmWeather>
+<modules/virtual/Timer> +<modules/virtual/Timer>
+<modules/virtual/Variable> +<modules/virtual/Variable>
+<modules/virtual/VariableColor> +<modules/virtual/VariableColor>
@@ -578,6 +586,7 @@ build_src_filter =
+<modules/exec/Pwm32> +<modules/exec/Pwm32>
+<modules/exec/TelegramLT> +<modules/exec/TelegramLT>
+<modules/display/Lcd2004> +<modules/display/Lcd2004>
+<modules/display/Oled648266/Oled648266>
+<modules/display/Smi2_m> +<modules/display/Smi2_m>
+<modules/display/TM16XX> +<modules/display/TM16XX>

View File

@@ -28,6 +28,7 @@ void* getAPI_ButtonIn(String subtype, String params);
void* getAPI_ButtonOut(String subtype, String params); void* getAPI_ButtonOut(String subtype, String params);
void* getAPI_Buzzer(String subtype, String params); void* getAPI_Buzzer(String subtype, String params);
void* getAPI_Encoder(String subtype, String params); void* getAPI_Encoder(String subtype, String params);
void* getAPI_HttpGet(String subtype, String params);
void* getAPI_IoTServo(String subtype, String params); void* getAPI_IoTServo(String subtype, String params);
void* getAPI_Mcp23017(String subtype, String params); void* getAPI_Mcp23017(String subtype, String params);
void* getAPI_Mp3(String subtype, String params); void* getAPI_Mp3(String subtype, String params);
@@ -36,6 +37,7 @@ 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_Lcd2004(String subtype, String params); void* getAPI_Lcd2004(String subtype, String params);
void* getAPI_Oled64(String subtype, String params);
void* getAPI_TM16XX(String subtype, String params); void* getAPI_TM16XX(String subtype, String params);
void* getAPI(String subtype, String params) { void* getAPI(String subtype, String params) {
@@ -68,6 +70,7 @@ if ((tmpAPI = getAPI_ButtonIn(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_ButtonOut(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_ButtonOut(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Buzzer(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Buzzer(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Encoder(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Encoder(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_HttpGet(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_IoTServo(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_IoTServo(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Mcp23017(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Mcp23017(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Mp3(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Mp3(subtype, params)) != nullptr) return tmpAPI;
@@ -76,6 +79,7 @@ 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_Lcd2004(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Lcd2004(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Oled64(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;
} }

View File

@@ -66,7 +66,10 @@ class Lcd2004 : public IoTItem {
} }
void onRegEvent(IoTItem* eventItem) { void onRegEvent(IoTItem* eventItem) {
if (LCDI2C == nullptr) { scanI2C(); return;} if (LCDI2C == nullptr) {
scanI2C();
return;
}
if (!eventItem || _id2show == "") return; if (!eventItem || _id2show == "") return;
if (_id2show == eventItem->getID()) { if (_id2show == eventItem->getID()) {

View File

@@ -0,0 +1,137 @@
#include "Global.h"
#include "classes/IoTItem.h"
#include <map>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 0
Adafruit_SSD1306 display(OLED_RESET);
class Oled64 : public IoTItem {
private:
unsigned int _x;
unsigned int _y;
String _id2show, _prefix = "", _postfix = "";
String _size = "1";
String _addr;
int _prevStrSize;
bool _isShow = true;
public:
Oled64(String parameters) : IoTItem(parameters) {
String size, xy;
_prevStrSize = 0;
jsonRead(parameters, "addr", _addr);
if (_addr == "") {
scanI2C();
return;
}
display.begin(SSD1306_SWITCHCAPVCC, hexStringToUint8(_addr));
display.display();
display.clearDisplay();
jsonRead(parameters, "coord", xy);
_x = selectFromMarkerToMarker(xy, ",", 0).toInt();
_y = selectFromMarkerToMarker(xy, ",", 1).toInt();
jsonRead(parameters, "id2show", _id2show);
jsonRead(parameters, "prefix", _prefix);
jsonRead(parameters, "postfix", _postfix);
jsonRead(parameters, "size", _size);
}
void drawItem(IoTItem *item) {
Serial.println("drawItem");
String tmpStr = _prefix;
tmpStr += item->getValue();
tmpStr += _postfix;
display.setRotation(0);
display.setCursor(_x, _y);
display.setTextColor(WHITE, BLACK);
display.setTextSize(_size.toInt());
printBlankStr(_prevStrSize);
display.setCursor(_x, _y);
display.print(tmpStr);
_prevStrSize = tmpStr.length();
display.display();
_prevStrSize = tmpStr.length();
}
void setValue(const IoTValue &Value, bool genEvent = true) {
value = Value;
drawItem(this);
IoTItem::setValue(Value, genEvent);
}
void onRegEvent(IoTItem *eventItem) {
if (!eventItem || _id2show == "") return;
if (_id2show == eventItem->getID()) {
setValue(eventItem->value, false);
}
}
IoTValue execute(String command, std::vector<IoTValue> &param) {
if (command == "display") {
_isShow = true;
} else if (command == "noDisplay") {
_isShow = false;
} 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 == "prefix") {
if (param.size()) {
_prefix = param[0].valS;
}
} else if (command == "postfix") {
if (param.size()) {
_postfix = 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 += " ";
display.setCursor(_x, _y);
display.print(tmpStr);
}
~Oled64(){};
};
void *getAPI_Oled64(String subtype, String param) {
if (subtype == F("Oled64")) {
return new Oled64(param);
} else {
return nullptr;
}
}

View File

@@ -0,0 +1,99 @@
{
"menuSection": "screens",
"configItem": [
{
"global": 0,
"name": "OLED экран 64 8266",
"type": "Reading",
"subtype": "Oled64",
"id": "Oled",
"widget": "inputTxt",
"page": "screens",
"descr": "OLED Экран",
"addr": "0x3C",
"coord": "0,0",
"size": "1",
"id2show": "",
"prefix": "",
"postfix": ""
}
],
"about": {
"authorName": "Serghei Crasnicov",
"authorContact": "https://t.me/Serghei63",
"authorGit": "https://github.com/Serghei63",
"specialThanks": "Valentin Khandriga @Valiuhaaa",
"moduleName": "Oled64",
"moduleVersion": "1.0",
"usedRam": {
"esp32_4mb": 15,
"esp8266_4mb": 15
},
"title": "Модуль отображения на экранах OLED 64*48",
"moduleDesc": "Позволяет выводить на OLED экраны по указанным позициям значения других элементов конфигурации.",
"propInfo": {
"int": "Период времени в секундах обновления информации на экране по конкретному элементу.",
"addr": "Адрес устройства на шине, обычно 0x3C.",
"size": "Размерность шрифта экрана.",
"coord": "Координата позиции для вывода данных элемента конфигурации.",
"id2show": "id элемента конфигурации.",
"size": "Размер шрифта. Допускается 1 , 2, 3, 4"
},
"funcInfo": [
{
"name": "x",
"descr": "Устанавливает первую координату",
"params": [
"Номер строки первого символа"
]
},
{
"name": "y",
"descr": "Устанавливает вторую координату",
"params": [
"Номер столбца первого символа"
]
},
{
"name": "descr",
"descr": "Задает приставку слева от значения",
"params": [
"Строка"
]
},
{
"name": "descr1",
"descr1": "Задает приставку справа от значения",
"params": [
"Строка"
]
},
{
"name": "id2show",
"descr": "Задает ИД элемента, значение которого хотим отображать на экране",
"params": [
"Имя элемента конфигурации"
]
}
]
},
"defActive": true,
"usedLibs": {
"esp32_4mb": [
"https://github.com/stblassitude/Adafruit_SSD1306_Wemos_OLED",
"https://github.com/adafruit/Adafruit-GFX-Library"
],
"esp8266_4mb": [
"https://github.com/stblassitude/Adafruit_SSD1306_Wemos_OLED",
"https://github.com/adafruit/Adafruit-GFX-Library"
],
"esp8266_1mb": [
"https://github.com/stblassitude/Adafruit_SSD1306_Wemos_OLED",
"https://github.com/adafruit/Adafruit-GFX-Library"
],
"esp8266_1mb_ota": [
"https://github.com/stblassitude/Adafruit_SSD1306_Wemos_OLED",
"https://github.com/adafruit/Adafruit-GFX-Library"
]
}
}