mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-28 07:02:17 +03:00
ButtonOut changed (not working version)
This commit is contained in:
64
src/items/ButtonOut.cpp
Normal file
64
src/items/ButtonOut.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
#include "items/ButtonOut.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
#include "BufferExecute.h"
|
||||
|
||||
ButtonOut::ButtonOut(unsigned int pin, boolean inv, String key) {
|
||||
_pin = pin;
|
||||
_inv = inv;
|
||||
_key = key;
|
||||
}
|
||||
ButtonOut::~ButtonOut() {}
|
||||
|
||||
void ButtonOut::init() {
|
||||
pinMode(_pin, OUTPUT);
|
||||
}
|
||||
|
||||
void ButtonOut::execute(String state) {
|
||||
//if (_inv) {
|
||||
// digitalWrite(_pin, !state.toInt());
|
||||
//}
|
||||
//else {
|
||||
digitalWrite(_pin, state.toInt());
|
||||
//}
|
||||
eventGen2(_key, state);
|
||||
jsonWriteInt(configLiveJson, _key, state.toInt());
|
||||
publishStatus(_key, state);
|
||||
}
|
||||
|
||||
MyButtonOutVector* myButtonOut = nullptr;
|
||||
|
||||
void buttonOut() {
|
||||
myLineParsing.update();
|
||||
String key = myLineParsing.gkey();
|
||||
String pin = myLineParsing.gpin();
|
||||
String inv = myLineParsing.ginv();
|
||||
myLineParsing.clear();
|
||||
|
||||
buttonOut_EnterCounter++;
|
||||
addKey(key, buttonOut_KeyList, buttonOut_EnterCounter);
|
||||
|
||||
static bool firstTime = true;
|
||||
if (firstTime) myButtonOut = new MyButtonOutVector();
|
||||
firstTime = false;
|
||||
myButtonOut->push_back(ButtonOut(pin.toInt(), inv.toInt(), key));
|
||||
|
||||
sCmd.addCommand(key.c_str(), buttonOutExecute);
|
||||
}
|
||||
|
||||
void buttonOutExecute() {
|
||||
String key = sCmd.order();
|
||||
String state = sCmd.next();
|
||||
|
||||
int number = getKeyNum(key, buttonOut_KeyList);
|
||||
|
||||
if (myButtonOut != nullptr) {
|
||||
if (number != -1) {
|
||||
myButtonOut->at(number).execute(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
#include "items/ButtonOutClass.h"
|
||||
|
||||
#include "BufferExecute.h"
|
||||
//==========================================Модуль кнопок===================================================
|
||||
//button-out light toggle Кнопки Свет 1 pin[12] inv[1] st[1]
|
||||
//==========================================================================================================
|
||||
ButtonOutClass myButtonOut;
|
||||
void buttonOut() {
|
||||
myButtonOut.update();
|
||||
String key = myButtonOut.gkey();
|
||||
String pin = myButtonOut.gpin();
|
||||
String inv = myButtonOut.ginv();
|
||||
sCmd.addCommand(key.c_str(), buttonOutSet);
|
||||
myButtonOut.init();
|
||||
myButtonOut.pinStateSetDefault();
|
||||
myButtonOut.clear();
|
||||
}
|
||||
|
||||
void buttonOutSet() {
|
||||
String key = sCmd.order();
|
||||
String state = sCmd.next();
|
||||
myButtonOut.pinChange(key, state);
|
||||
}
|
||||
//#include "items/ButtonOutClass.h"
|
||||
//
|
||||
//#include "BufferExecute.h"
|
||||
////==========================================Модуль кнопок===================================================
|
||||
////button-out light toggle Кнопки Свет 1 pin[12] inv[1] st[1]
|
||||
////==========================================================================================================
|
||||
//ButtonOutClass myButtonOut;
|
||||
//void buttonOut() {
|
||||
// myButtonOut.update();
|
||||
// String key = myButtonOut.gkey();
|
||||
// String pin = myButtonOut.gpin();
|
||||
// String inv = myButtonOut.ginv();
|
||||
// sCmd.addCommand(key.c_str(), buttonOutSet);
|
||||
// myButtonOut.init();
|
||||
// myButtonOut.pinStateSetDefault();
|
||||
// myButtonOut.clear();
|
||||
//}
|
||||
//
|
||||
//void buttonOutSet() {
|
||||
// String key = sCmd.order();
|
||||
// String state = sCmd.next();
|
||||
// myButtonOut.pinChange(key, state);
|
||||
//}
|
||||
|
||||
@@ -44,8 +44,8 @@ void impuls() {
|
||||
String pin = myLineParsing.gpin();
|
||||
myLineParsing.clear();
|
||||
|
||||
impulsEnterCounter++;
|
||||
addKey(key, impulsKeyList, impulsEnterCounter);
|
||||
impuls_EnterCounter++;
|
||||
addKey(key, impuls_KeyList, impuls_EnterCounter);
|
||||
|
||||
static bool firstTime = true;
|
||||
if (firstTime) myImpulsOut = new MyImpulsOutVector();
|
||||
@@ -60,7 +60,7 @@ void impulsExecute() {
|
||||
String impulsPeriod = sCmd.next();
|
||||
String impulsCount = sCmd.next();
|
||||
|
||||
int number = getKeyNum(key, impulsKeyList);
|
||||
int number = getKeyNum(key, impuls_KeyList);
|
||||
|
||||
if (myImpulsOut != nullptr) {
|
||||
if (number != -1) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "items/LoggingClass.h"
|
||||
#include "items/Logging.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
Reference in New Issue
Block a user