mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 14:12:16 +03:00
working version with optimization
This commit is contained in:
7
.vscode/extensions.json
vendored
Normal file
7
.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||
// for the documentation about the extensions.json format
|
||||
"recommendations": [
|
||||
"platformio.platformio-ide"
|
||||
]
|
||||
}
|
||||
@@ -51,4 +51,4 @@ class ButtonInClass : public LineParsing {
|
||||
}
|
||||
};
|
||||
|
||||
extern ButtonInClass* myButtonIn;
|
||||
extern ButtonInClass myButtonIn;
|
||||
@@ -39,4 +39,4 @@ class ButtonOutClass : public LineParsing {
|
||||
}
|
||||
};
|
||||
|
||||
extern ButtonOutClass* myButtonOut;
|
||||
extern ButtonOutClass myButtonOut;
|
||||
@@ -28,4 +28,4 @@ class InputClass : public LineParsing {
|
||||
}
|
||||
};
|
||||
|
||||
extern InputClass* myInput;
|
||||
extern InputClass myInput;
|
||||
@@ -20,4 +20,4 @@ class OutputTextClass : public LineParsing {
|
||||
MqttClient::publishStatus(key, state);
|
||||
}
|
||||
};
|
||||
extern OutputTextClass* myOutputText;
|
||||
extern OutputTextClass myOutputText;
|
||||
@@ -28,4 +28,4 @@ class PwmOutClass : public LineParsing {
|
||||
}
|
||||
};
|
||||
|
||||
extern PwmOutClass* myPwmOut;
|
||||
extern PwmOutClass myPwmOut;
|
||||
@@ -29,4 +29,4 @@ class SensorAnalogClass : public SensorConvertingClass {
|
||||
return value;
|
||||
}
|
||||
};
|
||||
extern SensorAnalogClass* mySensorAnalog;
|
||||
extern SensorAnalogClass mySensorAnalog;
|
||||
@@ -31,4 +31,4 @@ class SensorUltrasonic : public SensorConvertingClass {
|
||||
return value;
|
||||
}
|
||||
};
|
||||
extern SensorUltrasonic* mySensorUltrasonic;
|
||||
extern SensorUltrasonic mySensorUltrasonic;
|
||||
@@ -3,20 +3,19 @@
|
||||
//==========================================Модуль физических кнопок========================================
|
||||
//button-in switch1 toggle Кнопки Свет 1 pin[2] db[20]
|
||||
//==========================================================================================================
|
||||
ButtonInClass* myButtonIn;
|
||||
ButtonInClass myButtonIn;
|
||||
void buttonIn() {
|
||||
myButtonIn = new ButtonInClass();
|
||||
myButtonIn->update();
|
||||
String key = myButtonIn->gkey();
|
||||
String pin = myButtonIn->gpin();
|
||||
myButtonIn.update();
|
||||
String key = myButtonIn.gkey();
|
||||
String pin = myButtonIn.gpin();
|
||||
sCmd.addCommand(key.c_str(), buttonInSet);
|
||||
myButtonIn->init();
|
||||
myButtonIn->switchStateSetDefault();
|
||||
myButtonIn->clear();
|
||||
myButtonIn.init();
|
||||
myButtonIn.switchStateSetDefault();
|
||||
myButtonIn.clear();
|
||||
}
|
||||
|
||||
void buttonInSet() {
|
||||
String key = sCmd.order();
|
||||
String state = sCmd.next();
|
||||
myButtonIn->switchChangeVirtual(key, state);
|
||||
myButtonIn.switchChangeVirtual(key, state);
|
||||
}
|
||||
@@ -3,20 +3,19 @@
|
||||
//==========================================Модуль кнопок===================================================
|
||||
//button-out light toggle Кнопки Свет 1 pin[12] inv[1] st[1]
|
||||
//==========================================================================================================
|
||||
ButtonOutClass* myButtonOut;
|
||||
ButtonOutClass myButtonOut;
|
||||
void buttonOut() {
|
||||
myButtonOut = new ButtonOutClass();
|
||||
myButtonOut->update();
|
||||
String key = myButtonOut->gkey();
|
||||
String pin = myButtonOut->gpin();
|
||||
String inv = myButtonOut->ginv();
|
||||
myButtonOut.update();
|
||||
String key = myButtonOut.gkey();
|
||||
String pin = myButtonOut.gpin();
|
||||
String inv = myButtonOut.ginv();
|
||||
sCmd.addCommand(key.c_str(), buttonOutSet);
|
||||
jsonWriteStr(configOptionJson, key + "_pin", pin);
|
||||
jsonWriteStr(configOptionJson, key + "_inv", inv);
|
||||
myButtonOut->pinModeSet();
|
||||
myButtonOut->pinStateSetDefault();
|
||||
myButtonOut->pinStateSetInvDefault();
|
||||
myButtonOut->clear();
|
||||
myButtonOut.pinModeSet();
|
||||
myButtonOut.pinStateSetDefault();
|
||||
myButtonOut.pinStateSetInvDefault();
|
||||
myButtonOut.clear();
|
||||
}
|
||||
|
||||
void buttonOutSet() {
|
||||
@@ -25,8 +24,8 @@ void buttonOutSet() {
|
||||
String pin = jsonReadStr(configOptionJson, key + "_pin");
|
||||
String inv = jsonReadStr(configOptionJson, key + "_inv");
|
||||
if (inv == "") {
|
||||
myButtonOut->pinChange(key, pin, state, true);
|
||||
myButtonOut.pinChange(key, pin, state, true);
|
||||
} else {
|
||||
myButtonOut->pinChange(key, pin, state, false);
|
||||
myButtonOut.pinChange(key, pin, state, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,18 +3,17 @@
|
||||
//==========================================Модуль ввода цифровых значений==================================
|
||||
//input-digit digit1 inputDigit Ввод Введите.цифру 4 st[60]
|
||||
//==========================================================================================================
|
||||
InputClass* myInputDigit;
|
||||
InputClass myInputDigit;
|
||||
void inputDigit() {
|
||||
myInputDigit = new InputClass();
|
||||
myInputDigit->update();
|
||||
String key = myInputDigit->gkey();
|
||||
myInputDigit.update();
|
||||
String key = myInputDigit.gkey();
|
||||
sCmd.addCommand(key.c_str(), inputDigitSet);
|
||||
myInputDigit->inputSetDefaultFloat();
|
||||
myInputDigit->clear();
|
||||
myInputDigit.inputSetDefaultFloat();
|
||||
myInputDigit.clear();
|
||||
}
|
||||
|
||||
void inputDigitSet() {
|
||||
String key = sCmd.order();
|
||||
String state = sCmd.next();
|
||||
myInputDigit->inputSetFloat(key, state);
|
||||
myInputDigit.inputSetFloat(key, state);
|
||||
}
|
||||
@@ -3,20 +3,19 @@
|
||||
//==========================================Модуль ввода времени============================================
|
||||
//input-time time1 inputTime Ввод Введите.время 4 st[10-00-00]
|
||||
//==========================================================================================================
|
||||
InputClass* myInputTime;
|
||||
InputClass myInputTime;
|
||||
void inputTime() {
|
||||
myInputTime = new InputClass();
|
||||
myInputTime->update();
|
||||
String key = myInputTime->gkey();
|
||||
myInputTime.update();
|
||||
String key = myInputTime.gkey();
|
||||
sCmd.addCommand(key.c_str(), inputTimeSet);
|
||||
myInputTime->inputSetDefaultStr();
|
||||
myInputTime->clear();
|
||||
myInputTime.inputSetDefaultStr();
|
||||
myInputTime.clear();
|
||||
}
|
||||
|
||||
void inputTimeSet() {
|
||||
String key = sCmd.order();
|
||||
String state = sCmd.next();
|
||||
myInputTime->inputSetStr(key, state);
|
||||
myInputTime.inputSetStr(key, state);
|
||||
}
|
||||
|
||||
void handle_time_init() {
|
||||
|
||||
@@ -3,18 +3,17 @@
|
||||
//===============================================Модуль вывода текста============================================
|
||||
//output-text;id;anydata;Вывод;Сигнализация;order;st[Обнаружено.движение]
|
||||
//===============================================================================================================
|
||||
OutputTextClass* myOutputText;
|
||||
OutputTextClass myOutputText;
|
||||
void textOut() {
|
||||
myOutputText = new OutputTextClass();
|
||||
myOutputText->update();
|
||||
String key = myOutputText->gkey();
|
||||
myOutputText.update();
|
||||
String key = myOutputText.gkey();
|
||||
sCmd.addCommand(key.c_str(), textOutSet);
|
||||
myOutputText->OutputModuleStateSetDefault();
|
||||
myOutputText->clear();
|
||||
myOutputText.OutputModuleStateSetDefault();
|
||||
myOutputText.clear();
|
||||
}
|
||||
|
||||
void textOutSet() {
|
||||
String key = sCmd.order();
|
||||
String state = sCmd.next();
|
||||
myOutputText->OutputModuleChange(key, state);
|
||||
myOutputText.OutputModuleChange(key, state);
|
||||
}
|
||||
@@ -3,23 +3,22 @@
|
||||
//==========================================Модуль управления ШИМ===================================================
|
||||
//pwm-out volume range Кнопки Свет 1 pin[12] st[500]
|
||||
//==================================================================================================================
|
||||
PwmOutClass* myPwmOut;
|
||||
PwmOutClass myPwmOut;
|
||||
void pwmOut() {
|
||||
myPwmOut = new PwmOutClass();
|
||||
myPwmOut->update();
|
||||
String key = myPwmOut->gkey();
|
||||
String pin = myPwmOut->gpin();
|
||||
String inv = myPwmOut->ginv();
|
||||
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();
|
||||
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);
|
||||
myPwmOut.pwmChange(key, pin, state);
|
||||
}
|
||||
@@ -4,23 +4,22 @@
|
||||
//==============================================Модуль аналогового сенсора===========================================================================================
|
||||
//analog-adc;id;anydata;Сенсоры;Аналоговый;order;pin-adc;map[1,1024,1,100];c[1]
|
||||
//===================================================================================================================================================================
|
||||
SensorAnalogClass* mySensorAnalog;
|
||||
SensorAnalogClass mySensorAnalog;
|
||||
void analogAdc() {
|
||||
mySensorAnalog = new SensorAnalogClass();
|
||||
mySensorAnalog->update();
|
||||
String key = mySensorAnalog->gkey();
|
||||
String pin = mySensorAnalog->gpin();
|
||||
mySensorAnalog.update();
|
||||
String key = mySensorAnalog.gkey();
|
||||
String pin = mySensorAnalog.gpin();
|
||||
sCmd.addCommand(key.c_str(), analogReading);
|
||||
sensorReadingMap += key + ",";
|
||||
jsonWriteStr(configOptionJson, key + "_pin", pin);
|
||||
jsonWriteStr(configOptionJson, key + "_map", mySensorAnalog->gmap());
|
||||
jsonWriteStr(configOptionJson, key + "_с", mySensorAnalog->gc());
|
||||
mySensorAnalog->clear();
|
||||
jsonWriteStr(configOptionJson, key + "_map", mySensorAnalog.gmap());
|
||||
jsonWriteStr(configOptionJson, key + "_с", mySensorAnalog.gc());
|
||||
mySensorAnalog.clear();
|
||||
}
|
||||
|
||||
void analogReading() {
|
||||
String key = sCmd.order();
|
||||
String pin = jsonReadStr(configOptionJson, key + "_pin");
|
||||
mySensorAnalog->SensorAnalogRead(key, pin);
|
||||
mySensorAnalog.SensorAnalogRead(key, pin);
|
||||
}
|
||||
#endif
|
||||
@@ -4,21 +4,20 @@
|
||||
//=========================================Модуль ультрозвукового дальномера==================================================================
|
||||
//ultrasonic-cm;id;anydata;Сенсоры;Расстояние;order;pin[12,13];map[1,100,1,100];c[1]
|
||||
//=========================================================================================================================================
|
||||
SensorUltrasonic* mySensorUltrasonic;
|
||||
SensorUltrasonic mySensorUltrasonic;
|
||||
void ultrasonicCm() {
|
||||
mySensorUltrasonic = new SensorUltrasonic();
|
||||
mySensorUltrasonic->update();
|
||||
String key = mySensorUltrasonic->gkey();
|
||||
String pin = mySensorUltrasonic->gpin();
|
||||
mySensorUltrasonic.update();
|
||||
String key = mySensorUltrasonic.gkey();
|
||||
String pin = mySensorUltrasonic.gpin();
|
||||
String trig = selectFromMarkerToMarker(pin, ",", 0);
|
||||
String echo = selectFromMarkerToMarker(pin, ",", 1);
|
||||
sCmd.addCommand(key.c_str(), ultrasonicReading);
|
||||
sensorReadingMap += key + ",";
|
||||
jsonWriteStr(configOptionJson, key + "_trig", trig);
|
||||
jsonWriteStr(configOptionJson, key + "_echo", echo);
|
||||
jsonWriteStr(configOptionJson, key + "_map", mySensorUltrasonic->gmap());
|
||||
jsonWriteStr(configOptionJson, key + "_с", mySensorUltrasonic->gc());
|
||||
mySensorUltrasonic->clear();
|
||||
jsonWriteStr(configOptionJson, key + "_map", mySensorUltrasonic.gmap());
|
||||
jsonWriteStr(configOptionJson, key + "_с", mySensorUltrasonic.gc());
|
||||
mySensorUltrasonic.clear();
|
||||
}
|
||||
|
||||
void ultrasonicReading() {
|
||||
@@ -26,7 +25,7 @@ void ultrasonicReading() {
|
||||
String trig = jsonReadStr(configOptionJson, key + "_trig");
|
||||
String echo = jsonReadStr(configOptionJson, key + "_echo");
|
||||
String pin = trig + "," + echo;
|
||||
mySensorUltrasonic->SensorUltrasonicRead(key, pin);
|
||||
mySensorUltrasonic.SensorUltrasonicRead(key, pin);
|
||||
}
|
||||
//#endif
|
||||
|
||||
|
||||
@@ -73,8 +73,8 @@ void setup() {
|
||||
udpInit();
|
||||
#endif
|
||||
|
||||
pm.info("Ssdp Init");
|
||||
SsdpInit();
|
||||
//pm.info("Ssdp Init");
|
||||
//SsdpInit();
|
||||
|
||||
ts.add(
|
||||
TEST, 1000 * 60, [&](void*) {
|
||||
@@ -101,9 +101,8 @@ void loop() {
|
||||
#endif
|
||||
timeNow->loop();
|
||||
MqttClient::loop();
|
||||
myButtonIn->loop();
|
||||
myButtonIn.loop();
|
||||
myScenario->loop();
|
||||
//loopScenario();
|
||||
loopCmd();
|
||||
loopSerial();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user