mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-27 06:32:19 +03:00
Интегрируем дисплэй TM1637 в ядро
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include "items/vSensorCcs811.h"
|
||||
#include "items/vSensorDallas.h"
|
||||
#include "items/vSensorLCD2004.h"
|
||||
#include "items/vSensorTM1637.h"
|
||||
#include "items/vSensorDht.h"
|
||||
#include "items/vSensorNode.h"
|
||||
#include "items/vSensorPzem.h"
|
||||
@@ -110,6 +111,10 @@ void csvCmdExecute(String& cmdStr) {
|
||||
} else if (order == F("LCD2004")) {
|
||||
#ifdef EnableSensorLCD2004
|
||||
sCmd.addCommand(order.c_str(), lcd2004);
|
||||
#endif
|
||||
} else if (order == F("TM1637")) {
|
||||
#ifdef EnableSensorTM1637
|
||||
sCmd.addCommand(order.c_str(), TM1637);
|
||||
#endif
|
||||
} else if (order == F("dht")) {
|
||||
#ifdef EnableSensorDht
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "items/vSensorCcs811.h"
|
||||
#include "items/vSensorDallas.h"
|
||||
#include "items/vSensorLCD2004.h"
|
||||
#include "items/vSensorTM1637.h"
|
||||
#include "items/vSensorDht.h"
|
||||
#include "items/vSensorNode.h"
|
||||
#include "items/vSensorPzem.h"
|
||||
@@ -177,8 +178,12 @@ void clearVectors() {
|
||||
#ifdef EnableSensorLCD2004
|
||||
if (mySensorLCD20042 != nullptr) {
|
||||
if(LCDI2C != nullptr) LCDI2C->clear();
|
||||
mySensorLCD20042->clear();
|
||||
|
||||
mySensorLCD20042->clear();
|
||||
}
|
||||
#endif
|
||||
#ifdef EnableSensorTM1637
|
||||
if (mySensorTM1637 != nullptr) {
|
||||
mySensorTM1637->clear();
|
||||
}
|
||||
#endif
|
||||
#ifdef EnableSensorUltrasonic
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
LiquidCrystal_I2C *LCDI2C2;
|
||||
//LiquidCrystal_I2C *LCDI2C2;
|
||||
|
||||
SensorTM1637::SensorTM1637(String key, unsigned long interval, unsigned int x, unsigned int y, String val, String descr) {
|
||||
_key = key;
|
||||
@@ -27,33 +27,33 @@ SensorTM1637::~SensorTM1637() {}
|
||||
void SensorTM1637::printBlankStr(int strSize){
|
||||
String tmpStr = "";
|
||||
for(int i=0; i<strSize; i++) tmpStr += " ";
|
||||
LCDI2C2->setCursor(_x, _y);
|
||||
LCDI2C2->print(tmpStr);
|
||||
//LCDI2C2->setCursor(_x, _y);
|
||||
//LCDI2C2->print(tmpStr);
|
||||
}
|
||||
|
||||
void SensorTM1637::execute(String command) {
|
||||
if (command == "noBacklight") LCDI2C2->noBacklight();
|
||||
else if (command == "backlight") LCDI2C2->backlight();
|
||||
else if (command == "noDisplay") LCDI2C2->noDisplay();
|
||||
else if (command == "display") LCDI2C2->display();
|
||||
else if (command == "x") {
|
||||
printBlankStr(_prevStrSize);
|
||||
String par = sCmd.next();
|
||||
_x = par.toInt();
|
||||
}
|
||||
else if (command == "y") {
|
||||
printBlankStr(_prevStrSize);
|
||||
String par = sCmd.next();
|
||||
_y = par.toInt();
|
||||
}
|
||||
else if (command == "descr") {
|
||||
printBlankStr(_prevStrSize);
|
||||
String par = sCmd.next();
|
||||
_descr = par;
|
||||
}
|
||||
else { //не команда, значит данные
|
||||
_val = command;
|
||||
}
|
||||
//if (command == "noBacklight") LCDI2C2->noBacklight();
|
||||
//else if (command == "backlight") LCDI2C2->backlight();
|
||||
//else if (command == "noDisplay") LCDI2C2->noDisplay();
|
||||
//else if (command == "display") LCDI2C2->display();
|
||||
//else if (command == "x") {
|
||||
// printBlankStr(_prevStrSize);
|
||||
// String par = sCmd.next();
|
||||
// _x = par.toInt();
|
||||
//}
|
||||
//else if (command == "y") {
|
||||
// printBlankStr(_prevStrSize);
|
||||
// String par = sCmd.next();
|
||||
// _y = par.toInt();
|
||||
//}
|
||||
//else if (command == "descr") {
|
||||
// printBlankStr(_prevStrSize);
|
||||
// String par = sCmd.next();
|
||||
// _descr = par;
|
||||
//}
|
||||
//else { //не команда, значит данные
|
||||
// _val = command;
|
||||
//}
|
||||
|
||||
writeTM1637();
|
||||
}
|
||||
@@ -68,27 +68,27 @@ void SensorTM1637::loop() {
|
||||
}
|
||||
|
||||
void SensorTM1637::writeTM1637() {
|
||||
if (LCDI2C2 != nullptr) {
|
||||
printBlankStr(_prevStrSize);
|
||||
// if (LCDI2C2 != nullptr) {
|
||||
// printBlankStr(_prevStrSize);
|
||||
|
||||
String tmpStr = getValue(_val);
|
||||
if (tmpStr == "no value") tmpStr = _val;
|
||||
if (_descr != "none") tmpStr = _descr + " " + tmpStr;
|
||||
LCDI2C2->setCursor(_x, _y);
|
||||
LCDI2C2->print(tmpStr);
|
||||
// String tmpStr = getValue(_val);
|
||||
// if (tmpStr == "no value") tmpStr = _val;
|
||||
// if (_descr != "none") tmpStr = _descr + " " + tmpStr;
|
||||
// LCDI2C2->setCursor(_x, _y);
|
||||
// LCDI2C2->print(tmpStr);
|
||||
|
||||
_prevStrSize = tmpStr.length();
|
||||
}
|
||||
// _prevStrSize = tmpStr.length();
|
||||
// }
|
||||
}
|
||||
|
||||
MySensorTM1637Vector* mySensorTM16372 = nullptr;
|
||||
MySensorTM1637Vector* mySensorTM1637 = nullptr;
|
||||
|
||||
void TM1637Execute() {
|
||||
String key = sCmd.order();
|
||||
String command = sCmd.next();
|
||||
|
||||
for (unsigned int i = 0; i < mySensorTM16372->size(); i++) {
|
||||
if (mySensorTM16372->at(i)._key == key) mySensorTM16372->at(i).execute(command);
|
||||
for (unsigned int i = 0; i < mySensorTM1637->size(); i++) {
|
||||
if (mySensorTM1637->at(i)._key == key) mySensorTM1637->at(i).execute(command);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,19 +108,19 @@ void TM1637() {
|
||||
int w = selectFromMarkerToMarker(k, ",", 0).toInt(); //количество столбцов
|
||||
int h = selectFromMarkerToMarker(k, ",", 1).toInt(); //количество строк
|
||||
|
||||
if (LCDI2C2 == nullptr) { //инициализации экрана еще не было
|
||||
LCDI2C2 = new LiquidCrystal_I2C(hexStringToUint8(addr), w, h);//hexStringToUint8(addr), w, h);
|
||||
if(LCDI2C2 != nullptr) {
|
||||
LCDI2C2->init();
|
||||
LCDI2C2->backlight();
|
||||
}
|
||||
}
|
||||
// if (LCDI2C2 == nullptr) { //инициализации экрана еще не было
|
||||
// //LCDI2C2 = new LiquidCrystal_I2C(hexStringToUint8(addr), w, h);//hexStringToUint8(addr), w, h);
|
||||
// if(LCDI2C2 != nullptr) {
|
||||
// LCDI2C2->init();
|
||||
// LCDI2C2->backlight();
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
static bool firstTime = true;
|
||||
if (firstTime) mySensorTM16372 = new MySensorTM1637Vector();
|
||||
if (firstTime) mySensorTM1637 = new MySensorTM1637Vector();
|
||||
firstTime = false;
|
||||
mySensorTM16372->push_back(SensorTM1637(key, interval.toInt(), x, y, val, descr));
|
||||
mySensorTM1637->push_back(SensorTM1637(key, interval.toInt(), x, y, val, descr));
|
||||
|
||||
sCmd.addCommand(key.c_str(), TM1637Execute);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
#include <SSDP.h>
|
||||
|
||||
#include "BufferExecute.h"
|
||||
@@ -30,6 +29,7 @@
|
||||
#include "items/vSensorCcs811.h"
|
||||
#include "items/vSensorDallas.h"
|
||||
#include "items/vSensorLCD2004.h"
|
||||
#include "items/vSensorTM1637.h"
|
||||
#include "items/vSensorDht.h"
|
||||
#include "items/vSensorNode.h"
|
||||
#include "items/vSensorPzem.h"
|
||||
@@ -161,6 +161,13 @@ void loop() {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef EnableSensorTM1637
|
||||
if (mySensorTM1637 != nullptr) {
|
||||
for (unsigned int i = 0; i < mySensorTM1637->size(); i++) {
|
||||
mySensorTM1637->at(i).loop();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef EnableSensorUltrasonic
|
||||
if (mySensorUltrasonic != nullptr) {
|
||||
for (unsigned int i = 0; i < mySensorUltrasonic->size(); i++) {
|
||||
|
||||
Reference in New Issue
Block a user