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