mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-28 07:02:17 +03:00
uart
This commit is contained in:
@@ -2,13 +2,15 @@
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
#include "BufferExecute.h"
|
||||
#include "SoftUART.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
//this class save data to flash
|
||||
ButtonOut::ButtonOut(String pin, boolean inv, String key) {
|
||||
ButtonOut::ButtonOut(String pin, boolean inv, String key, String type) {
|
||||
_pin = pin;
|
||||
_inv = inv;
|
||||
_key = key;
|
||||
_type = type;
|
||||
if (_pin != "") {
|
||||
pinMode(_pin.toInt(), OUTPUT);
|
||||
}
|
||||
@@ -18,6 +20,13 @@ ButtonOut::ButtonOut(String pin, boolean inv, String key) {
|
||||
ButtonOut::~ButtonOut() {}
|
||||
|
||||
void ButtonOut::execute(String state) {
|
||||
if (_type == "UART") {
|
||||
if (jsonReadBool(configSetupJson, "uart")) {
|
||||
if (myUART != nullptr) {
|
||||
myUART->print(_key + " " + state);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (state != "" && _pin != "") {
|
||||
if (state == "change") {
|
||||
state = String(!digitalRead(_pin.toInt()));
|
||||
@@ -45,6 +54,7 @@ void buttonOut() {
|
||||
String key = myLineParsing.gkey();
|
||||
String pin = myLineParsing.gpin();
|
||||
String inv = myLineParsing.ginv();
|
||||
String type = myLineParsing.gtype();
|
||||
|
||||
bool invb = false;
|
||||
if (inv.toInt() == 1) invb = true;
|
||||
@@ -57,7 +67,7 @@ void buttonOut() {
|
||||
static bool firstTime = true;
|
||||
if (firstTime) myButtonOut = new MyButtonOutVector();
|
||||
firstTime = false;
|
||||
myButtonOut->push_back(ButtonOut(pin, invb, key));
|
||||
myButtonOut->push_back(ButtonOut(pin, invb, key, type));
|
||||
|
||||
sCmd.addCommand(key.c_str(), buttonOutExecute);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "items/vInOutput.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
#include "BufferExecute.h"
|
||||
#include "Clock.h"
|
||||
|
||||
//this class save date to flash
|
||||
InOutput::InOutput(String key, String widget) {
|
||||
_key = key;
|
||||
@@ -12,7 +12,7 @@ InOutput::InOutput(String key, String widget) {
|
||||
|
||||
if (value == "") {
|
||||
if (widget.indexOf("Digit") != -1) {
|
||||
value = "52";
|
||||
value = "25";
|
||||
}
|
||||
if (widget.indexOf("Time") != -1) {
|
||||
value = "12:00";
|
||||
@@ -52,13 +52,18 @@ void inOutput() {
|
||||
void inOutputExecute() {
|
||||
String key = sCmd.order();
|
||||
String value = sCmd.next();
|
||||
//String type = sCmd.next();
|
||||
|
||||
|
||||
if (!isDigitStr(value)) { //если значение - текст
|
||||
if (value.indexOf(":") == -1) { //если этот текст не время
|
||||
String tmp = getValue(value);
|
||||
if(tmp != "no value") {
|
||||
value = tmp;
|
||||
value.replace("#"," ");
|
||||
String valueJson = getValue(value);
|
||||
if (valueJson != "no value") { //если это ключ переменной
|
||||
value = valueJson;
|
||||
}
|
||||
else { //если это просто текст
|
||||
value.replace("#", " ");
|
||||
value.replace("%date%", timeNow->getDateTimeDotFormated());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user