mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
switch in progress
This commit is contained in:
@@ -18,6 +18,7 @@ class LineParsing {
|
||||
String _c;
|
||||
String _inv;
|
||||
String _state;
|
||||
String _db;
|
||||
|
||||
public:
|
||||
LineParsing() :
|
||||
@@ -33,7 +34,8 @@ class LineParsing {
|
||||
_map{""},
|
||||
_c{""},
|
||||
_inv{""},
|
||||
_state{""}
|
||||
_state{""},
|
||||
_db{""}
|
||||
|
||||
{};
|
||||
|
||||
@@ -61,6 +63,9 @@ class LineParsing {
|
||||
if (arg.indexOf("st[") != -1) {
|
||||
_state = extractInner(arg);
|
||||
}
|
||||
if (arg.indexOf("db[") != -1) {
|
||||
_db = extractInner(arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
createWidgetClass(_descr, _page, _order, _file, _key);
|
||||
@@ -107,6 +112,7 @@ class LineParsing {
|
||||
_c = "";
|
||||
_inv = "";
|
||||
_state = "";
|
||||
_db = "";
|
||||
}
|
||||
|
||||
String extractInnerDigit(String str) {
|
||||
|
||||
43
include/Class/Switch.h
Normal file
43
include/Class/Switch.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
|
||||
class Switch : public LineParsing {
|
||||
public:
|
||||
Switch() : LineParsing(){};
|
||||
|
||||
void switchModeSet() {
|
||||
if (_pin != "") {
|
||||
pinMode(_pin.toInt(), INPUT);
|
||||
}
|
||||
}
|
||||
|
||||
void switchStateSetDefault() {
|
||||
if (_inv == "" && _state != "") {
|
||||
switchChange(_key, _pin, _state, true);
|
||||
}
|
||||
}
|
||||
|
||||
void switchStateSetInvDefault() {
|
||||
if (_inv != "" && _state != "") {
|
||||
switchChange(_key, _pin, _state, false);
|
||||
}
|
||||
}
|
||||
|
||||
void switchChange(String key, String pin, String state, bool rev) {
|
||||
int pinInt = pin.toInt();
|
||||
int stateInt;
|
||||
if (rev) {
|
||||
digitalWrite(pinInt, state.toInt());
|
||||
} else {
|
||||
digitalWrite(pinInt, !state.toInt());
|
||||
}
|
||||
eventGen(key, "");
|
||||
jsonWriteInt(configLiveJson, key, state.toInt());
|
||||
MqttClient::publishStatus(key, state);
|
||||
}
|
||||
};
|
||||
|
||||
extern Switch* mySwitch;
|
||||
@@ -156,8 +156,9 @@ void pwmSet() {
|
||||
myPwm->pwmChange(key, pin, state);
|
||||
}
|
||||
|
||||
//==================================================================================================================
|
||||
//==========================================Модуль физической кнопки================================================
|
||||
//==========================================Модуль физических кнопок========================================
|
||||
//switch in switch1 toggle Кнопки Свет 1 pin[2] inv[1] db[20]
|
||||
//==========================================================================================================
|
||||
void switch_() {
|
||||
int number = String(sCmd.next()).toInt();
|
||||
int pin = String(sCmd.next()).toInt();
|
||||
|
||||
Reference in New Issue
Block a user