mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-28 15:12:19 +03:00
Progress of renew of class
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
#include "BufferExecute.h"
|
||||
#include "items/OutputTextClass.h"
|
||||
//===============================================Модуль вывода текста============================================
|
||||
//output-text;id;anydata;Вывод;Сигнализация;order;st[Обнаружено.движение]
|
||||
//===============================================================================================================
|
||||
OutputTextClass myOutputText;
|
||||
void textOut() {
|
||||
myOutputText.update();
|
||||
String key = myOutputText.gkey();
|
||||
sCmd.addCommand(key.c_str(), textOutSet);
|
||||
myOutputText.OutputModuleStateSetDefault();
|
||||
myOutputText.clear();
|
||||
}
|
||||
|
||||
void textOutSet() {
|
||||
String key = sCmd.order();
|
||||
String state = sCmd.next();
|
||||
myOutputText.OutputModuleChange(key, state);
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
#include "BufferExecute.h"
|
||||
#include "items/PwmOutClass.h"
|
||||
//==========================================Модуль управления ШИМ===================================================
|
||||
//pwm-out volume range Кнопки Свет 1 pin[12] st[500]
|
||||
//==================================================================================================================
|
||||
PwmOutClass myPwmOut;
|
||||
void pwmOut() {
|
||||
myPwmOut.update();
|
||||
String key = myPwmOut.gkey();
|
||||
String pin = myPwmOut.gpin();
|
||||
String inv = myPwmOut.ginv();
|
||||
sCmd.addCommand(key.c_str(), pwmOutSet);
|
||||
jsonWriteStr(configOptionJson, key + "_pin", pin);
|
||||
myPwmOut.pwmModeSet();
|
||||
myPwmOut.pwmStateSetDefault();
|
||||
myPwmOut.clear();
|
||||
}
|
||||
|
||||
void pwmOutSet() {
|
||||
String key = sCmd.order();
|
||||
String state = sCmd.next();
|
||||
String pin = jsonReadStr(configOptionJson, key + "_pin");
|
||||
myPwmOut.pwmChange(key, pin, state);
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
#include "items/vButtonOut.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
#include "BufferExecute.h"
|
||||
//this class save date to flash
|
||||
|
||||
#include <Arduino.h>
|
||||
//this class save data to flash
|
||||
ButtonOut::ButtonOut(unsigned int pin, boolean inv, String key) {
|
||||
_pin = pin;
|
||||
_inv = inv;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "items/vInput.h"
|
||||
#include "items/vInOutput.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "Global.h"
|
||||
#include "BufferExecute.h"
|
||||
//this class save date to flash
|
||||
Input::Input(String key, String widget) {
|
||||
InOutput::InOutput(String key, String widget) {
|
||||
_key = key;
|
||||
String value = jsonReadStr(configStoreJson, key);
|
||||
|
||||
@@ -21,43 +21,43 @@ Input::Input(String key, String widget) {
|
||||
|
||||
this->execute(value);
|
||||
}
|
||||
Input::~Input() {}
|
||||
InOutput::~InOutput() {}
|
||||
|
||||
void Input::execute(String value) {
|
||||
void InOutput::execute(String value) {
|
||||
eventGen2(_key, value);
|
||||
jsonWriteStr(configStoreJson, _key, value);
|
||||
saveStore();
|
||||
publishStatus(_key, value);
|
||||
}
|
||||
|
||||
MyInputVector* myInput = nullptr;
|
||||
MyInOutputVector* myInOutput = nullptr;
|
||||
|
||||
void input() {
|
||||
void inOutput() {
|
||||
myLineParsing.update();
|
||||
String widget = myLineParsing.gfile();
|
||||
String key = myLineParsing.gkey();
|
||||
myLineParsing.clear();
|
||||
|
||||
input_EnterCounter++;
|
||||
addKey(key, input_KeyList, input_EnterCounter);
|
||||
inOutput_EnterCounter++;
|
||||
addKey(key, inOutput_KeyList, inOutput_EnterCounter);
|
||||
|
||||
static bool firstTime = true;
|
||||
if (firstTime) myInput = new MyInputVector();
|
||||
if (firstTime) myInOutput = new MyInOutputVector();
|
||||
firstTime = false;
|
||||
myInput->push_back(Input(key, widget));
|
||||
myInOutput->push_back(InOutput(key, widget));
|
||||
|
||||
sCmd.addCommand(key.c_str(), inputExecute);
|
||||
sCmd.addCommand(key.c_str(), inOutputExecute);
|
||||
}
|
||||
|
||||
void inputExecute() {
|
||||
void inOutputExecute() {
|
||||
String key = sCmd.order();
|
||||
String value = sCmd.next();
|
||||
|
||||
int number = getKeyNum(key, input_KeyList);
|
||||
int number = getKeyNum(key, inOutput_KeyList);
|
||||
|
||||
if (myInput != nullptr) {
|
||||
if (myInOutput != nullptr) {
|
||||
if (number != -1) {
|
||||
myInput->at(number).execute(value);
|
||||
myInOutput->at(number).execute(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
55
src/items/vPwmOut.cpp
Normal file
55
src/items/vPwmOut.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#include "items/vPwmOut.h"
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
#include "BufferExecute.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
//this class save data to flash
|
||||
PwmOut::PwmOut(unsigned int pin, String key) {
|
||||
_pin = pin;
|
||||
_key = key;
|
||||
pinMode(_pin, OUTPUT);
|
||||
int state = jsonReadInt(configStoreJson, key);
|
||||
this->execute(String(state));
|
||||
}
|
||||
PwmOut::~PwmOut() {}
|
||||
|
||||
void PwmOut::execute(String state) {
|
||||
analogWrite(_pin, state.toInt());
|
||||
eventGen2(_key, state);
|
||||
jsonWriteInt(configStoreJson, _key, state.toInt());
|
||||
saveStore();
|
||||
publishStatus(_key, state);
|
||||
}
|
||||
|
||||
MyPwmOutVector* myPwmOut = nullptr;
|
||||
|
||||
void pwmOut() {
|
||||
myLineParsing.update();
|
||||
String key = myLineParsing.gkey();
|
||||
String pin = myLineParsing.gpin();
|
||||
myLineParsing.clear();
|
||||
|
||||
pwmOut_EnterCounter++;
|
||||
addKey(key, pwmOut_KeyList, pwmOut_EnterCounter);
|
||||
|
||||
static bool firstTime = true;
|
||||
if (firstTime) myPwmOut = new MyPwmOutVector();
|
||||
firstTime = false;
|
||||
myPwmOut->push_back(PwmOut(pin.toInt(), key));
|
||||
|
||||
sCmd.addCommand(key.c_str(), pwmOutExecute);
|
||||
}
|
||||
|
||||
void pwmOutExecute() {
|
||||
String key = sCmd.order();
|
||||
String state = sCmd.next();
|
||||
|
||||
int number = getKeyNum(key, pwmOut_KeyList);
|
||||
|
||||
if (myPwmOut != nullptr) {
|
||||
if (number != -1) {
|
||||
myPwmOut->at(number).execute(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user