mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-27 06:32:19 +03:00
ButtonOut changed (not working version)
This commit is contained in:
@@ -9,9 +9,6 @@ extern void loopCmdExecute();
|
||||
extern void addKey(String& key, String& keyNumberTable, int number);
|
||||
extern int getKeyNum(String& key, String& keyNumberTable);
|
||||
|
||||
extern void buttonOut();
|
||||
extern void buttonOutSet();
|
||||
|
||||
extern void pwmOut();
|
||||
extern void pwmOutSet();
|
||||
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
#include "Cmd.h"
|
||||
#include "Global.h"
|
||||
|
||||
class Scenario {
|
||||
|
||||
public:
|
||||
|
||||
void loop() {
|
||||
|
||||
String allBlocks = scenario;
|
||||
allBlocks.replace("\r\n", "\n");
|
||||
allBlocks.replace("\r", "\n");
|
||||
allBlocks += "\n";
|
||||
|
||||
String incommingEvent = selectToMarker(eventBuf, ",");
|
||||
|
||||
while (allBlocks.length() > 1) {
|
||||
String oneBlock = selectToMarker(allBlocks, "end\n");
|
||||
String condition = selectToMarker(oneBlock, "\n");
|
||||
|
||||
String setEvent = selectFromMarkerToMarker(condition, " ", 0);
|
||||
String setEventSign = selectFromMarkerToMarker(condition, " ", 1);
|
||||
String setEventValue = selectFromMarkerToMarker(condition, " ", 2);
|
||||
if (!isDigitStr(setEventValue)) setEventValue = jsonReadStr(configLiveJson, setEventValue);
|
||||
|
||||
String incommingEventValue = jsonReadStr(configLiveJson, incommingEvent);
|
||||
|
||||
if (incommingEvent == setEvent) {
|
||||
|
||||
boolean flag = false;
|
||||
|
||||
if (setEventSign == "=") {
|
||||
flag = incommingEventValue == setEventValue;
|
||||
}
|
||||
else if (setEventSign == "!=") {
|
||||
flag = incommingEventValue != setEventValue;
|
||||
}
|
||||
else if (setEventSign == "<") {
|
||||
flag = incommingEventValue.toFloat() < setEventValue.toFloat();
|
||||
}
|
||||
else if (setEventSign == ">") {
|
||||
flag = incommingEventValue.toFloat() > setEventValue.toFloat();
|
||||
}
|
||||
else if (setEventSign == ">=") {
|
||||
flag = incommingEventValue.toFloat() >= setEventValue.toFloat();
|
||||
}
|
||||
else if (setEventSign == "<=") {
|
||||
flag = incommingEventValue.toFloat() <= setEventValue.toFloat();
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
//SerialPrint("I", "Scenario", "incomming Event Value: " + incommingEventValue);
|
||||
//SerialPrint("I", "Scenario", "set Event Value: " + setEventValue);
|
||||
|
||||
oneBlock = deleteBeforeDelimiter(oneBlock, "\n");
|
||||
oneBlock.replace("end", "");
|
||||
SerialPrint("I", "Scenario", condition + " set:\n" + oneBlock);
|
||||
spaceCmdExecute(oneBlock);
|
||||
}
|
||||
}
|
||||
allBlocks = deleteBeforeDelimiter(allBlocks, "end\n");
|
||||
}
|
||||
eventBuf = deleteBeforeDelimiter(eventBuf, ",");
|
||||
}
|
||||
};
|
||||
|
||||
extern Scenario* myScenario;
|
||||
@@ -105,7 +105,11 @@ enum ConfigType_t {
|
||||
CT_CONFIG,
|
||||
CT_SCENARIO
|
||||
};
|
||||
|
||||
//history
|
||||
//07.11.2020 (SSDP OFF, UDP OFF)
|
||||
//RAM: [===== ] 46.8% (used 38376 bytes from 81920 bytes)
|
||||
//Flash: [===== ] 54.2% (used 566004 bytes from 1044464 bytes)
|
||||
//Flash: [===== ] 54.2% (used 566004 bytes from 1044464 bytes)
|
||||
|
||||
//13.11.2020 (SSDP OFF, UDP OFF)
|
||||
//RAM: [===== ] 46.6% (used 38208 bytes from 81920 bytes)
|
||||
//Flash: [===== ] 54.2% (used 566388 bytes from 1044464 bytes)
|
||||
@@ -67,8 +67,13 @@ extern String itemsFile;
|
||||
extern String itemsLine;
|
||||
|
||||
//key lists and numbers
|
||||
extern String impulsKeyList;
|
||||
extern int impulsEnterCounter;
|
||||
//=========================================
|
||||
extern String impuls_KeyList;
|
||||
extern int impuls_EnterCounter;
|
||||
//=========================================
|
||||
extern String buttonOut_KeyList;
|
||||
extern int buttonOut_EnterCounter;
|
||||
//=========================================
|
||||
|
||||
// Sensors
|
||||
extern String sensorReadingMap10sec;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
extern String mqttPrefix;
|
||||
extern String mqttRootDevice;
|
||||
|
||||
void mqttInit();
|
||||
boolean mqttConnect();
|
||||
|
||||
32
include/items/ButtonOut.h
Normal file
32
include/items/ButtonOut.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "Global.h"
|
||||
|
||||
class ButtonOut;
|
||||
|
||||
typedef std::vector<ButtonOut> MyButtonOutVector;
|
||||
|
||||
class ButtonOut {
|
||||
public:
|
||||
|
||||
ButtonOut(unsigned int pin, boolean inv, String key);
|
||||
|
||||
~ButtonOut();
|
||||
|
||||
void init();
|
||||
void execute(String state);
|
||||
|
||||
private:
|
||||
|
||||
unsigned int _pin;
|
||||
boolean _inv;
|
||||
String _key;
|
||||
|
||||
void addNewDelOldData(const String filename, size_t maxPoints, String payload);
|
||||
};
|
||||
|
||||
extern MyButtonOutVector* myButtonOut;
|
||||
|
||||
extern void buttonOut();
|
||||
extern void buttonOutExecute();
|
||||
@@ -1,41 +1,41 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
|
||||
class ButtonOutClass : public LineParsing {
|
||||
public:
|
||||
ButtonOutClass() : LineParsing() {};
|
||||
|
||||
void init() {
|
||||
if (_pin != "") {
|
||||
pinMode(_pin.toInt(), OUTPUT);
|
||||
}
|
||||
jsonWriteStr(configOptionJson, _key + "_pin", _pin);
|
||||
jsonWriteStr(configOptionJson, _key + "_inv", _inv);
|
||||
}
|
||||
|
||||
void pinStateSetDefault() {
|
||||
pinChange(_key, _state);
|
||||
}
|
||||
|
||||
|
||||
void pinChange(String key, String state) {
|
||||
String pin = jsonReadStr(configOptionJson, key + "_pin");
|
||||
String inv = jsonReadStr(configOptionJson, key + "_inv");
|
||||
int pinInt = pin.toInt();
|
||||
|
||||
if (inv == "") {
|
||||
digitalWrite(pinInt, state.toInt());
|
||||
}
|
||||
else {
|
||||
digitalWrite(pinInt, !state.toInt());
|
||||
}
|
||||
eventGen2(key, state);
|
||||
jsonWriteInt(configLiveJson, key, state.toInt());
|
||||
publishStatus(key, state);
|
||||
}
|
||||
};
|
||||
|
||||
extern ButtonOutClass myButtonOut;
|
||||
//#pragma once
|
||||
//#include <Arduino.h>
|
||||
//
|
||||
//#include "Class/LineParsing.h"
|
||||
//#include "Global.h"
|
||||
//
|
||||
//class ButtonOutClass : public LineParsing {
|
||||
//public:
|
||||
// ButtonOutClass() : LineParsing() {};
|
||||
//
|
||||
// void init() {
|
||||
// if (_pin != "") {
|
||||
// pinMode(_pin.toInt(), OUTPUT);
|
||||
// }
|
||||
// jsonWriteStr(configOptionJson, _key + "_pin", _pin);
|
||||
// jsonWriteStr(configOptionJson, _key + "_inv", _inv);
|
||||
// }
|
||||
//
|
||||
// void pinStateSetDefault() {
|
||||
// pinChange(_key, _state);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// void pinChange(String key, String state) {
|
||||
// String pin = jsonReadStr(configOptionJson, key + "_pin");
|
||||
// String inv = jsonReadStr(configOptionJson, key + "_inv");
|
||||
// int pinInt = pin.toInt();
|
||||
//
|
||||
// if (inv == "") {
|
||||
// digitalWrite(pinInt, state.toInt());
|
||||
// }
|
||||
// else {
|
||||
// digitalWrite(pinInt, !state.toInt());
|
||||
// }
|
||||
// eventGen2(key, state);
|
||||
// jsonWriteInt(configLiveJson, key, state.toInt());
|
||||
// publishStatus(key, state);
|
||||
// }
|
||||
//};
|
||||
//
|
||||
//extern ButtonOutClass myButtonOut;
|
||||
Reference in New Issue
Block a user