mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 20:09:14 +03:00
SSD1306_128x64
This commit is contained in:
@@ -1,20 +1,15 @@
|
||||
|
||||
|
||||
#include "Global.h"
|
||||
#include "classes/IoTItem.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
|
||||
|
||||
#include <GyverOLED.h>
|
||||
|
||||
GyverOLED<SSD1306_128x64, OLED_BUFFER> oled;
|
||||
|
||||
// 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;
|
||||
|
||||
// GyverOLED<SSH1106_128x64> oled;
|
||||
|
||||
class Oled128 : public IoTItem {
|
||||
private:
|
||||
@@ -33,23 +28,17 @@ class Oled128 : public IoTItem {
|
||||
|
||||
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();
|
||||
@@ -63,21 +52,18 @@ class Oled128 : public IoTItem {
|
||||
// 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);
|
||||
if (_descr != "none")
|
||||
tmpStr = _descr + " " + getItemValue(_id2show) + " " + _descr1;
|
||||
else
|
||||
tmpStr = getItemValue(_id2show);
|
||||
|
||||
// oled.setScale(2);
|
||||
|
||||
@@ -90,14 +76,10 @@ class Oled128 : public IoTItem {
|
||||
oled.update();
|
||||
|
||||
_prevStrSize = tmpStr.length();
|
||||
|
||||
|
||||
}
|
||||
|
||||
IoTValue execute(String command, std::vector<IoTValue> ¶m) { // будет возможным использовать, когда сценарии запустятся
|
||||
|
||||
|
||||
|
||||
if (command == "scroll") {
|
||||
String tmpStr = "";
|
||||
oled.clear();
|
||||
@@ -112,12 +94,11 @@ class Oled128 : public IoTItem {
|
||||
|
||||
oled.setCursor(val, _y);
|
||||
|
||||
|
||||
oled.print(tmpStr);
|
||||
oled.update();
|
||||
val--;
|
||||
if (millis() - tmr > 5000);// return;
|
||||
|
||||
if (millis() - tmr > 5000)
|
||||
; // return;
|
||||
|
||||
_isShow = true;
|
||||
}
|
||||
@@ -125,16 +106,12 @@ class Oled128 : public IoTItem {
|
||||
}
|
||||
|
||||
else if (command == "stopscroll") {
|
||||
|
||||
|
||||
|
||||
_isShow = true;
|
||||
// display->backlight();
|
||||
// else if (command == "noDisplay") {
|
||||
// display->noDisplay();
|
||||
// _isShow = false;
|
||||
}
|
||||
else if (command == "display") {
|
||||
} else if (command == "display") {
|
||||
// display.display();
|
||||
_isShow = true;
|
||||
} else if (command == "toggle") {
|
||||
@@ -169,7 +146,6 @@ class Oled128 : public IoTItem {
|
||||
|
||||
doByInterval();
|
||||
return {};
|
||||
|
||||
}
|
||||
|
||||
// печать пустой строки нужной длинны для затирания предыдущего значения на экране
|
||||
@@ -186,7 +162,6 @@ class Oled128 : public IoTItem {
|
||||
oled.print(tmpStr);
|
||||
}
|
||||
|
||||
|
||||
~Oled128(){};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user