mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +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_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<SSD1306_128x64, OLED_BUFFER> oled;
|
||||
|
||||
// GyverOLED<SSD1306_128x32, OLED_BUFFER> oled;
|
||||
// GyverOLED<SSD1306_128x32, OLED_NO_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:
|
||||
@@ -28,28 +23,22 @@ class Oled128 : public IoTItem {
|
||||
String _id2show;
|
||||
String _descr;
|
||||
String _descr1;
|
||||
|
||||
|
||||
int _prevStrSize;
|
||||
|
||||
bool _isShow = true; // экран показывает
|
||||
|
||||
|
||||
bool _isShow = true; // экран показывает
|
||||
|
||||
public:
|
||||
Oled128(String parameters) : IoTItem(parameters) {
|
||||
|
||||
String addr, size, xy, k ;
|
||||
String addr, size, xy, k;
|
||||
_prevStrSize = 0;
|
||||
|
||||
|
||||
|
||||
jsonRead(parameters, "addr", addr);
|
||||
if (addr == "") {
|
||||
//scanI2C();
|
||||
// scanI2C();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
jsonRead(parameters, "coord", xy);
|
||||
_x = selectFromMarkerToMarker(xy, ",", 0).toInt();
|
||||
_y = selectFromMarkerToMarker(xy, ",", 1).toInt();
|
||||
@@ -57,92 +46,80 @@ class Oled128 : public IoTItem {
|
||||
jsonRead(parameters, "descr", _descr);
|
||||
jsonRead(parameters, "id2show", _id2show);
|
||||
jsonRead(parameters, "descr1", _descr1);
|
||||
//jsonRead(parameters, "scale", _k);
|
||||
// jsonRead(parameters, "scale", _k);
|
||||
jsonRead(parameters, "shrift", _shrift);
|
||||
|
||||
// Wire.begin(2,0); // Инициализация шины I2C для модуля E01
|
||||
|
||||
oled.init(); // инициализация экрана
|
||||
|
||||
oled.init(); // инициализация экрана
|
||||
}
|
||||
|
||||
void doByInterval() {
|
||||
printBlankStr(_prevStrSize);
|
||||
|
||||
|
||||
String tmpStr = "";
|
||||
|
||||
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);
|
||||
if (_descr != "none")
|
||||
tmpStr = _descr + " " + getItemValue(_id2show) + " " + _descr1;
|
||||
else
|
||||
tmpStr = getItemValue(_id2show);
|
||||
|
||||
//oled.setScale(2);
|
||||
// oled.setScale(2);
|
||||
|
||||
oled.setScale(_shrift);
|
||||
oled.setScale(_shrift);
|
||||
|
||||
oled.setCursorXY(_x, _y);
|
||||
oled.setCursorXY(_x, _y);
|
||||
|
||||
oled.print(tmpStr);
|
||||
oled.print(tmpStr);
|
||||
|
||||
oled.update();
|
||||
oled.update();
|
||||
|
||||
_prevStrSize = tmpStr.length();
|
||||
|
||||
|
||||
_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);
|
||||
String tmpStr = "";
|
||||
oled.clear();
|
||||
uint32_t tmr = millis();
|
||||
oled.autoPrintln(false);
|
||||
int val = 128;
|
||||
for (;;) {
|
||||
// oled.clear(); // ЗАКОММЕНТИРУЙ, ЕСЛИ ВКЛЮЧЕН БУФЕР
|
||||
// oled.setScale(2);
|
||||
|
||||
oled.setScale(_shrift);
|
||||
oled.setScale(_shrift);
|
||||
|
||||
oled.setCursor(val, _y);
|
||||
|
||||
oled.setCursor(val, _y);
|
||||
|
||||
oled.print(tmpStr);
|
||||
oled.print(tmpStr);
|
||||
oled.update();
|
||||
val--;
|
||||
if (millis() - tmr > 5000);// return;
|
||||
val--;
|
||||
if (millis() - tmr > 5000)
|
||||
; // return;
|
||||
|
||||
_isShow = true;
|
||||
}
|
||||
|
||||
_isShow = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
else if (command == "stopscroll") {
|
||||
|
||||
|
||||
|
||||
_isShow = true;
|
||||
// display->backlight();
|
||||
// else if (command == "noDisplay") {
|
||||
// display->noDisplay();
|
||||
// _isShow = false;
|
||||
}
|
||||
else if (command == "display") {
|
||||
// display.display();
|
||||
// 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();
|
||||
// display->noDisplay();
|
||||
_isShow = false;
|
||||
} else {
|
||||
// display.display();
|
||||
} else {
|
||||
// display.display();
|
||||
_isShow = true;
|
||||
}
|
||||
} else if (command == "x") {
|
||||
@@ -160,7 +137,7 @@ class Oled128 : public IoTItem {
|
||||
} else if (command == "descr1") {
|
||||
if (param.size()) {
|
||||
_descr1 = param[0].valS;
|
||||
}
|
||||
}
|
||||
} else if (command == "id2show") {
|
||||
if (param.size()) {
|
||||
_id2show = param[0].valS;
|
||||
@@ -169,24 +146,22 @@ class Oled128 : public IoTItem {
|
||||
|
||||
doByInterval();
|
||||
return {};
|
||||
|
||||
}
|
||||
|
||||
//печать пустой строки нужной длинны для затирания предыдущего значения на экране
|
||||
// печать пустой строки нужной длинны для затирания предыдущего значения на экране
|
||||
void printBlankStr(int strSize) {
|
||||
String tmpStr = "";
|
||||
for (int i = 0; i < strSize; i++) tmpStr += " ";
|
||||
|
||||
// oled.setScale(2);
|
||||
// oled.setScale(2);
|
||||
|
||||
oled.setScale(_shrift);
|
||||
oled.setScale(_shrift);
|
||||
|
||||
oled.setCursorXY(_x, _y);
|
||||
oled.setCursorXY(_x, _y);
|
||||
|
||||
oled.print(tmpStr);
|
||||
oled.print(tmpStr);
|
||||
}
|
||||
|
||||
|
||||
~Oled128(){};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user