mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
devide into files
This commit is contained in:
@@ -1,39 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <Arduino.h>
|
|
||||||
|
|
||||||
extern void cmd_init();
|
extern void cmd_init();
|
||||||
|
#include <Arduino.h>
|
||||||
extern void buttonOut();
|
|
||||||
extern void buttonOutSet();
|
|
||||||
|
|
||||||
extern void pwmOut();
|
|
||||||
extern void pwmOutSet();
|
|
||||||
|
|
||||||
extern void buttonIn();
|
|
||||||
extern void buttonInSet();
|
|
||||||
|
|
||||||
extern void inputDigit();
|
|
||||||
extern void inputDigitSet();
|
|
||||||
|
|
||||||
extern void inputTime();
|
|
||||||
extern void inputTimeSet();
|
|
||||||
|
|
||||||
extern void textOut();
|
|
||||||
extern void textOutSet();
|
|
||||||
|
|
||||||
extern void analogAdc();
|
|
||||||
extern void analogReading();
|
|
||||||
|
|
||||||
extern void ultrasonicCm();
|
|
||||||
extern void ultrasonicReading();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern void sensorsInit();
|
extern void sensorsInit();
|
||||||
|
|
||||||
@@ -41,7 +8,6 @@ extern void levelPr();
|
|||||||
extern void ultrasonicCm();
|
extern void ultrasonicCm();
|
||||||
extern void ultrasonic_reading();
|
extern void ultrasonic_reading();
|
||||||
|
|
||||||
|
|
||||||
extern void analog_reading1();
|
extern void analog_reading1();
|
||||||
extern void analog_reading2();
|
extern void analog_reading2();
|
||||||
extern void dallas_reading();
|
extern void dallas_reading();
|
||||||
@@ -83,7 +49,6 @@ extern void serialBegin();
|
|||||||
extern void serialWrite();
|
extern void serialWrite();
|
||||||
extern void logging();
|
extern void logging();
|
||||||
|
|
||||||
|
|
||||||
extern void button();
|
extern void button();
|
||||||
extern void timeSet();
|
extern void timeSet();
|
||||||
|
|
||||||
|
|||||||
25
include/items/itemsGlobal.h
Normal file
25
include/items/itemsGlobal.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
extern void buttonOut();
|
||||||
|
extern void buttonOutSet();
|
||||||
|
|
||||||
|
extern void pwmOut();
|
||||||
|
extern void pwmOutSet();
|
||||||
|
|
||||||
|
extern void buttonIn();
|
||||||
|
extern void buttonInSet();
|
||||||
|
|
||||||
|
extern void inputDigit();
|
||||||
|
extern void inputDigitSet();
|
||||||
|
|
||||||
|
extern void inputTime();
|
||||||
|
extern void inputTimeSet();
|
||||||
|
|
||||||
|
extern void textOut();
|
||||||
|
extern void textOutSet();
|
||||||
|
|
||||||
|
extern void analogAdc();
|
||||||
|
extern void analogReading();
|
||||||
|
|
||||||
|
extern void ultrasonicCm();
|
||||||
|
extern void ultrasonicReading();
|
||||||
135
src/Cmd.cpp
135
src/Cmd.cpp
@@ -1,12 +1,7 @@
|
|||||||
#include "Cmd.h"
|
#include "Cmd.h"
|
||||||
|
|
||||||
#include "Class/Button.h"
|
#include "items/itemsGlobal.h"
|
||||||
#include "Class/Input.h"
|
//#include "Class/LineParsing.h"
|
||||||
#include "Class/LineParsing.h"
|
|
||||||
#include "Class/OutputModule.h"
|
|
||||||
#include "Class/Pwm.h"
|
|
||||||
#include "Class/Switch.h"
|
|
||||||
//-----------------------------
|
|
||||||
#include "Class/NotAsinc.h"
|
#include "Class/NotAsinc.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "Module/Terminal.h"
|
#include "Module/Terminal.h"
|
||||||
@@ -110,142 +105,16 @@ void cmd_init() {
|
|||||||
handle_time_init();
|
handle_time_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================Модуль кнопок===================================================
|
|
||||||
//button-out light toggle Кнопки Свет 1 pin[12] inv[1] st[1]
|
|
||||||
//==========================================================================================================
|
|
||||||
void buttonOut() {
|
|
||||||
myButton = new Button1();
|
|
||||||
myButton->update();
|
|
||||||
String key = myButton->gkey();
|
|
||||||
String pin = myButton->gpin();
|
|
||||||
String inv = myButton->ginv();
|
|
||||||
sCmd.addCommand(key.c_str(), buttonOutSet);
|
|
||||||
jsonWriteStr(configOptionJson, key + "_pin", pin);
|
|
||||||
jsonWriteStr(configOptionJson, key + "_inv", inv);
|
|
||||||
myButton->pinModeSet();
|
|
||||||
myButton->pinStateSetDefault();
|
|
||||||
myButton->pinStateSetInvDefault();
|
|
||||||
myButton->clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void buttonOutSet() {
|
|
||||||
String key = sCmd.order();
|
|
||||||
String state = sCmd.next();
|
|
||||||
String pin = jsonReadStr(configOptionJson, key + "_pin");
|
|
||||||
String inv = jsonReadStr(configOptionJson, key + "_inv");
|
|
||||||
if (inv == "") {
|
|
||||||
myButton->pinChange(key, pin, state, true);
|
|
||||||
} else {
|
|
||||||
myButton->pinChange(key, pin, state, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================Модуль управления ШИМ===================================================
|
|
||||||
//pwm-out volume range Кнопки Свет 1 pin[12] st[500]
|
|
||||||
//==================================================================================================================
|
|
||||||
void pwmOut() {
|
|
||||||
myPwm = new Pwm();
|
|
||||||
myPwm->update();
|
|
||||||
String key = myPwm->gkey();
|
|
||||||
String pin = myPwm->gpin();
|
|
||||||
String inv = myPwm->ginv();
|
|
||||||
sCmd.addCommand(key.c_str(), pwmOutSet);
|
|
||||||
jsonWriteStr(configOptionJson, key + "_pin", pin);
|
|
||||||
myPwm->pwmModeSet();
|
|
||||||
myPwm->pwmStateSetDefault();
|
|
||||||
myPwm->clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void pwmOutSet() {
|
|
||||||
String key = sCmd.order();
|
|
||||||
String state = sCmd.next();
|
|
||||||
String pin = jsonReadStr(configOptionJson, key + "_pin");
|
|
||||||
myPwm->pwmChange(key, pin, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================Модуль физических кнопок========================================
|
|
||||||
//button-in switch1 toggle Кнопки Свет 1 pin[2] db[20]
|
|
||||||
//==========================================================================================================
|
|
||||||
void buttonIn() {
|
|
||||||
mySwitch = new Switch();
|
|
||||||
mySwitch->update();
|
|
||||||
String key = mySwitch->gkey();
|
|
||||||
String pin = mySwitch->gpin();
|
|
||||||
sCmd.addCommand(key.c_str(), buttonInSet);
|
|
||||||
mySwitch->init();
|
|
||||||
mySwitch->switchStateSetDefault();
|
|
||||||
mySwitch->clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void buttonInSet() {
|
|
||||||
String key = sCmd.order();
|
|
||||||
String state = sCmd.next();
|
|
||||||
mySwitch->switchChangeVirtual(key, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================Модуль ввода цифровых значений==================================
|
|
||||||
//input-digit digit1 inputDigit Ввод Введите.цифру 4 st[60]
|
|
||||||
//==========================================================================================================
|
|
||||||
void inputDigit() {
|
|
||||||
myInput = new Input();
|
|
||||||
myInput->update();
|
|
||||||
String key = myInput->gkey();
|
|
||||||
sCmd.addCommand(key.c_str(), inputDigitSet);
|
|
||||||
myInput->inputSetDefaultFloat();
|
|
||||||
myInput->clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void inputDigitSet() {
|
|
||||||
String key = sCmd.order();
|
|
||||||
String state = sCmd.next();
|
|
||||||
myInput->inputSetFloat(key, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================Модуль ввода времени============================================
|
|
||||||
//input-time time1 inputTime Ввод Введите.время 4 st[10-00-00]
|
|
||||||
//==========================================================================================================
|
|
||||||
void inputTime() {
|
|
||||||
myInput = new Input();
|
|
||||||
myInput->update();
|
|
||||||
String key = myInput->gkey();
|
|
||||||
sCmd.addCommand(key.c_str(), inputTimeSet);
|
|
||||||
myInput->inputSetDefaultStr();
|
|
||||||
myInput->clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void inputTimeSet() {
|
|
||||||
String key = sCmd.order();
|
|
||||||
String state = sCmd.next();
|
|
||||||
myInput->inputSetStr(key, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
void handle_time_init() {
|
|
||||||
ts.add(
|
|
||||||
TIME, 1000, [&](void *) {
|
|
||||||
jsonWriteStr(configLiveJson, "time", timeNow->getTime());
|
|
||||||
jsonWriteStr(configLiveJson, "timenow", timeNow->getTimeJson());
|
|
||||||
//eventGen("timenow", "");
|
|
||||||
},
|
|
||||||
nullptr, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//===============================================Модуль вывода текста============================================
|
|
||||||
//output-text;id;anydata;Вывод;Сигнализация;order;st[Обнаружено.движение]
|
|
||||||
//===============================================================================================================
|
|
||||||
void textOut() {
|
|
||||||
myText = new OutputModule();
|
|
||||||
myText->update();
|
|
||||||
String key = myText->gkey();
|
|
||||||
sCmd.addCommand(key.c_str(), textOutSet);
|
|
||||||
myText->OutputModuleStateSetDefault();
|
|
||||||
myText->clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void textOutSet() {
|
|
||||||
String key = sCmd.order();
|
|
||||||
String state = sCmd.next();
|
|
||||||
myText->OutputModuleChange(key, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
//void text() {
|
//void text() {
|
||||||
// String number = sCmd.next();
|
// String number = sCmd.next();
|
||||||
|
|||||||
113
src/Sensors.cpp
113
src/Sensors.cpp
@@ -32,122 +32,9 @@ void sensorsInit() {
|
|||||||
nullptr, true);
|
nullptr, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ANALOG_ENABLED
|
|
||||||
//==============================================Модуль аналогового сенсора===========================================================================================
|
|
||||||
//analog-adc;id;anydata;Сенсоры;Аналоговый;order;pin-adc;map[1,1024,1,100];c[1]
|
|
||||||
//===================================================================================================================================================================
|
|
||||||
void analogAdc() {
|
|
||||||
mySensorAnalog = new SensorAnalog();
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
void analogReading() {
|
|
||||||
String key = sCmd.order();
|
|
||||||
String pin = jsonReadStr(configOptionJson, key + "_pin");
|
|
||||||
mySensorAnalog->SensorAnalogRead(key, pin);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef LEVEL_ENABLED
|
|
||||||
//=========================================Модуль ультрозвукового дальномера==================================================================
|
|
||||||
//ultrasonic-cm;id;anydata;Сенсоры;Расстояние;order;pin;map[1,100,1,100];c[1]
|
|
||||||
//=========================================================================================================================================
|
|
||||||
void ultrasonicCm() {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void ultrasonicReading() {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void levelPr() {
|
|
||||||
// String value_name = sCmd.next();
|
|
||||||
// String trig = sCmd.next();
|
|
||||||
// String echo = sCmd.next();
|
|
||||||
// String widget_name = sCmd.next();
|
|
||||||
// String page_name = sCmd.next();
|
|
||||||
// String type = sCmd.next();
|
|
||||||
// String empty_level = sCmd.next();
|
|
||||||
// String full_level = sCmd.next();
|
|
||||||
// String page_number = sCmd.next();
|
|
||||||
// levelPr_value_name = value_name;
|
|
||||||
// jsonWriteStr(configOptionJson, "e_lev", empty_level);
|
|
||||||
// jsonWriteStr(configOptionJson, "f_lev", full_level);
|
|
||||||
// jsonWriteStr(configOptionJson, "trig", trig);
|
|
||||||
// jsonWriteStr(configOptionJson, "echo", echo);
|
|
||||||
// pinMode(trig.toInt(), OUTPUT);
|
|
||||||
// pinMode(echo.toInt(), INPUT);
|
|
||||||
// createWidgetByType(widget_name, page_name, page_number, type, value_name);
|
|
||||||
// sensors_reading_map[0] = 1;
|
|
||||||
}
|
|
||||||
////ultrasonicCm cm 14 12 Дистанция,#см Датчики fillgauge 1
|
|
||||||
//void ultrasonicCm() {
|
|
||||||
// String value_name = sCmd.next();
|
|
||||||
// String trig = sCmd.next();
|
|
||||||
// String echo = sCmd.next();
|
|
||||||
// String widget_name = sCmd.next();
|
|
||||||
// String page_name = sCmd.next();
|
|
||||||
// String type = sCmd.next();
|
|
||||||
// String empty_level = sCmd.next();
|
|
||||||
// String full_level = sCmd.next();
|
|
||||||
// String page_number = sCmd.next();
|
|
||||||
// ultrasonicCm_value_name = value_name;
|
|
||||||
// jsonWriteStr(configOptionJson, "trig", trig);
|
|
||||||
// jsonWriteStr(configOptionJson, "echo", echo);
|
|
||||||
// pinMode(trig.toInt(), OUTPUT);
|
|
||||||
// pinMode(echo.toInt(), INPUT);
|
|
||||||
// createWidgetByType(widget_name, page_name, page_number, type, value_name);
|
|
||||||
// sensors_reading_map[0] = 1;
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
void ultrasonic_reading() {
|
|
||||||
// long duration_;
|
|
||||||
// int distance_cm;
|
|
||||||
// int level;
|
|
||||||
// static int counter;
|
|
||||||
// int trig = jsonReadInt(configOptionJson, "trig");
|
|
||||||
// int echo = jsonReadInt(configOptionJson, "echo");
|
|
||||||
// digitalWrite(trig, LOW);
|
|
||||||
// delayMicroseconds(2);
|
|
||||||
// digitalWrite(trig, HIGH);
|
|
||||||
// delayMicroseconds(10);
|
|
||||||
// digitalWrite(trig, LOW);
|
|
||||||
// duration_ = pulseIn(echo, HIGH, 30000); // 3000 µs = 50cm // 30000 µs = 5 m
|
|
||||||
// distance_cm = duration_ / 29 / 2;
|
|
||||||
// distance_cm = medianFilter.filtered(distance_cm); //отсечение промахов медианным фильтром
|
|
||||||
// counter++;
|
|
||||||
// if (counter > TANK_LEVEL_SAMPLES) {
|
|
||||||
// counter = 0;
|
|
||||||
// level = map(distance_cm,
|
|
||||||
// jsonReadInt(configOptionJson, "e_lev"),
|
|
||||||
// jsonReadInt(configOptionJson, "f_lev"), 0, 100);
|
|
||||||
//
|
|
||||||
// jsonWriteInt(configLiveJson, levelPr_value_name, level);
|
|
||||||
// eventGen(levelPr_value_name, "");
|
|
||||||
//
|
|
||||||
// MqttClient::publishStatus(levelPr_value_name, String(level));
|
|
||||||
//
|
|
||||||
// Serial.println("[I] sensor '" + levelPr_value_name + "' data: " + String(level));
|
|
||||||
//
|
|
||||||
// jsonWriteInt(configLiveJson, ultrasonicCm_value_name, distance_cm);
|
|
||||||
// eventGen(ultrasonicCm_value_name, "");
|
|
||||||
//
|
|
||||||
// MqttClient::publishStatus(ultrasonicCm_value_name, String(distance_cm));
|
|
||||||
//
|
|
||||||
// Serial.println("[I] sensor '" + ultrasonicCm_value_name + "' data: " + String(distance_cm));
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
//=========================================================================================================================================
|
//=========================================================================================================================================
|
||||||
//=========================================Модуль температурного сенсора ds18b20===========================================================
|
//=========================================Модуль температурного сенсора ds18b20===========================================================
|
||||||
#ifdef DALLAS_ENABLED
|
#ifdef DALLAS_ENABLED
|
||||||
|
|||||||
21
src/items/mButtonIn.cpp
Normal file
21
src/items/mButtonIn.cpp
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#include "items/itemsGlobal.h"
|
||||||
|
#include "Class/Switch.h"
|
||||||
|
//==========================================Модуль физических кнопок========================================
|
||||||
|
//button-in switch1 toggle Кнопки Свет 1 pin[2] db[20]
|
||||||
|
//==========================================================================================================
|
||||||
|
void buttonIn() {
|
||||||
|
mySwitch = new Switch();
|
||||||
|
mySwitch->update();
|
||||||
|
String key = mySwitch->gkey();
|
||||||
|
String pin = mySwitch->gpin();
|
||||||
|
sCmd.addCommand(key.c_str(), buttonInSet);
|
||||||
|
mySwitch->init();
|
||||||
|
mySwitch->switchStateSetDefault();
|
||||||
|
mySwitch->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void buttonInSet() {
|
||||||
|
String key = sCmd.order();
|
||||||
|
String state = sCmd.next();
|
||||||
|
mySwitch->switchChangeVirtual(key, state);
|
||||||
|
}
|
||||||
31
src/items/mButtonOut.cpp
Normal file
31
src/items/mButtonOut.cpp
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#include "items/itemsGlobal.h"
|
||||||
|
#include "Class/Button.h"
|
||||||
|
//==========================================Модуль кнопок===================================================
|
||||||
|
//button-out light toggle Кнопки Свет 1 pin[12] inv[1] st[1]
|
||||||
|
//==========================================================================================================
|
||||||
|
void buttonOut() {
|
||||||
|
myButton = new Button1();
|
||||||
|
myButton->update();
|
||||||
|
String key = myButton->gkey();
|
||||||
|
String pin = myButton->gpin();
|
||||||
|
String inv = myButton->ginv();
|
||||||
|
sCmd.addCommand(key.c_str(), buttonOutSet);
|
||||||
|
jsonWriteStr(configOptionJson, key + "_pin", pin);
|
||||||
|
jsonWriteStr(configOptionJson, key + "_inv", inv);
|
||||||
|
myButton->pinModeSet();
|
||||||
|
myButton->pinStateSetDefault();
|
||||||
|
myButton->pinStateSetInvDefault();
|
||||||
|
myButton->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void buttonOutSet() {
|
||||||
|
String key = sCmd.order();
|
||||||
|
String state = sCmd.next();
|
||||||
|
String pin = jsonReadStr(configOptionJson, key + "_pin");
|
||||||
|
String inv = jsonReadStr(configOptionJson, key + "_inv");
|
||||||
|
if (inv == "") {
|
||||||
|
myButton->pinChange(key, pin, state, true);
|
||||||
|
} else {
|
||||||
|
myButton->pinChange(key, pin, state, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
19
src/items/mInputDigit.cpp
Normal file
19
src/items/mInputDigit.cpp
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#include "items/itemsGlobal.h"
|
||||||
|
#include "Class/Input.h"
|
||||||
|
//==========================================Модуль ввода цифровых значений==================================
|
||||||
|
//input-digit digit1 inputDigit Ввод Введите.цифру 4 st[60]
|
||||||
|
//==========================================================================================================
|
||||||
|
void inputDigit() {
|
||||||
|
myInput = new Input();
|
||||||
|
myInput->update();
|
||||||
|
String key = myInput->gkey();
|
||||||
|
sCmd.addCommand(key.c_str(), inputDigitSet);
|
||||||
|
myInput->inputSetDefaultFloat();
|
||||||
|
myInput->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void inputDigitSet() {
|
||||||
|
String key = sCmd.order();
|
||||||
|
String state = sCmd.next();
|
||||||
|
myInput->inputSetFloat(key, state);
|
||||||
|
}
|
||||||
29
src/items/mInputTime.cpp
Normal file
29
src/items/mInputTime.cpp
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#include "items/itemsGlobal.h"
|
||||||
|
#include "Class/Input.h"
|
||||||
|
//==========================================Модуль ввода времени============================================
|
||||||
|
//input-time time1 inputTime Ввод Введите.время 4 st[10-00-00]
|
||||||
|
//==========================================================================================================
|
||||||
|
void inputTime() {
|
||||||
|
myInput = new Input();
|
||||||
|
myInput->update();
|
||||||
|
String key = myInput->gkey();
|
||||||
|
sCmd.addCommand(key.c_str(), inputTimeSet);
|
||||||
|
myInput->inputSetDefaultStr();
|
||||||
|
myInput->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void inputTimeSet() {
|
||||||
|
String key = sCmd.order();
|
||||||
|
String state = sCmd.next();
|
||||||
|
myInput->inputSetStr(key, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void handle_time_init() {
|
||||||
|
ts.add(
|
||||||
|
TIME, 1000, [&](void *) {
|
||||||
|
jsonWriteStr(configLiveJson, "time", timeNow->getTime());
|
||||||
|
jsonWriteStr(configLiveJson, "timenow", timeNow->getTimeJson());
|
||||||
|
//eventGen("timenow", "");
|
||||||
|
},
|
||||||
|
nullptr, true);
|
||||||
|
}
|
||||||
19
src/items/mOutputText.cpp
Normal file
19
src/items/mOutputText.cpp
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#include "items/itemsGlobal.h"
|
||||||
|
#include "Class/OutputModule.h"
|
||||||
|
//===============================================Модуль вывода текста============================================
|
||||||
|
//output-text;id;anydata;Вывод;Сигнализация;order;st[Обнаружено.движение]
|
||||||
|
//===============================================================================================================
|
||||||
|
void textOut() {
|
||||||
|
myText = new OutputModule();
|
||||||
|
myText->update();
|
||||||
|
String key = myText->gkey();
|
||||||
|
sCmd.addCommand(key.c_str(), textOutSet);
|
||||||
|
myText->OutputModuleStateSetDefault();
|
||||||
|
myText->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void textOutSet() {
|
||||||
|
String key = sCmd.order();
|
||||||
|
String state = sCmd.next();
|
||||||
|
myText->OutputModuleChange(key, state);
|
||||||
|
}
|
||||||
24
src/items/mPwmOut.cpp
Normal file
24
src/items/mPwmOut.cpp
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#include "items/itemsGlobal.h"
|
||||||
|
#include "Class/Pwm.h"
|
||||||
|
//==========================================Модуль управления ШИМ===================================================
|
||||||
|
//pwm-out volume range Кнопки Свет 1 pin[12] st[500]
|
||||||
|
//==================================================================================================================
|
||||||
|
void pwmOut() {
|
||||||
|
myPwm = new Pwm();
|
||||||
|
myPwm->update();
|
||||||
|
String key = myPwm->gkey();
|
||||||
|
String pin = myPwm->gpin();
|
||||||
|
String inv = myPwm->ginv();
|
||||||
|
sCmd.addCommand(key.c_str(), pwmOutSet);
|
||||||
|
jsonWriteStr(configOptionJson, key + "_pin", pin);
|
||||||
|
myPwm->pwmModeSet();
|
||||||
|
myPwm->pwmStateSetDefault();
|
||||||
|
myPwm->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void pwmOutSet() {
|
||||||
|
String key = sCmd.order();
|
||||||
|
String state = sCmd.next();
|
||||||
|
String pin = jsonReadStr(configOptionJson, key + "_pin");
|
||||||
|
myPwm->pwmChange(key, pin, state);
|
||||||
|
}
|
||||||
25
src/items/sAnalog.cpp
Normal file
25
src/items/sAnalog.cpp
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#include "items/itemsGlobal.h"
|
||||||
|
#include "Class/SensorAnalog.h"
|
||||||
|
#ifdef ANALOG_ENABLED
|
||||||
|
//==============================================Модуль аналогового сенсора===========================================================================================
|
||||||
|
//analog-adc;id;anydata;Сенсоры;Аналоговый;order;pin-adc;map[1,1024,1,100];c[1]
|
||||||
|
//===================================================================================================================================================================
|
||||||
|
void analogAdc() {
|
||||||
|
mySensorAnalog = new SensorAnalog();
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
void analogReading() {
|
||||||
|
String key = sCmd.order();
|
||||||
|
String pin = jsonReadStr(configOptionJson, key + "_pin");
|
||||||
|
mySensorAnalog->SensorAnalogRead(key, pin);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
94
src/items/sUltrasonic.cpp
Normal file
94
src/items/sUltrasonic.cpp
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
#include "items/itemsGlobal.h"
|
||||||
|
#include "Class/SensorAnalog.h"
|
||||||
|
#ifdef LEVEL_ENABLED
|
||||||
|
//=========================================Модуль ультрозвукового дальномера==================================================================
|
||||||
|
//ultrasonic-cm;id;anydata;Сенсоры;Расстояние;order;pin;map[1,100,1,100];c[1]
|
||||||
|
//=========================================================================================================================================
|
||||||
|
void ultrasonicCm() {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ultrasonicReading() {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void levelPr() {
|
||||||
|
// String value_name = sCmd.next();
|
||||||
|
// String trig = sCmd.next();
|
||||||
|
// String echo = sCmd.next();
|
||||||
|
// String widget_name = sCmd.next();
|
||||||
|
// String page_name = sCmd.next();
|
||||||
|
// String type = sCmd.next();
|
||||||
|
// String empty_level = sCmd.next();
|
||||||
|
// String full_level = sCmd.next();
|
||||||
|
// String page_number = sCmd.next();
|
||||||
|
// levelPr_value_name = value_name;
|
||||||
|
// jsonWriteStr(configOptionJson, "e_lev", empty_level);
|
||||||
|
// jsonWriteStr(configOptionJson, "f_lev", full_level);
|
||||||
|
// jsonWriteStr(configOptionJson, "trig", trig);
|
||||||
|
// jsonWriteStr(configOptionJson, "echo", echo);
|
||||||
|
// pinMode(trig.toInt(), OUTPUT);
|
||||||
|
// pinMode(echo.toInt(), INPUT);
|
||||||
|
// createWidgetByType(widget_name, page_name, page_number, type, value_name);
|
||||||
|
// sensors_reading_map[0] = 1;
|
||||||
|
}
|
||||||
|
////ultrasonicCm cm 14 12 Дистанция,#см Датчики fillgauge 1
|
||||||
|
//void ultrasonicCm() {
|
||||||
|
// String value_name = sCmd.next();
|
||||||
|
// String trig = sCmd.next();
|
||||||
|
// String echo = sCmd.next();
|
||||||
|
// String widget_name = sCmd.next();
|
||||||
|
// String page_name = sCmd.next();
|
||||||
|
// String type = sCmd.next();
|
||||||
|
// String empty_level = sCmd.next();
|
||||||
|
// String full_level = sCmd.next();
|
||||||
|
// String page_number = sCmd.next();
|
||||||
|
// ultrasonicCm_value_name = value_name;
|
||||||
|
// jsonWriteStr(configOptionJson, "trig", trig);
|
||||||
|
// jsonWriteStr(configOptionJson, "echo", echo);
|
||||||
|
// pinMode(trig.toInt(), OUTPUT);
|
||||||
|
// pinMode(echo.toInt(), INPUT);
|
||||||
|
// createWidgetByType(widget_name, page_name, page_number, type, value_name);
|
||||||
|
// sensors_reading_map[0] = 1;
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
void ultrasonic_reading() {
|
||||||
|
// long duration_;
|
||||||
|
// int distance_cm;
|
||||||
|
// int level;
|
||||||
|
// static int counter;
|
||||||
|
// int trig = jsonReadInt(configOptionJson, "trig");
|
||||||
|
// int echo = jsonReadInt(configOptionJson, "echo");
|
||||||
|
// digitalWrite(trig, LOW);
|
||||||
|
// delayMicroseconds(2);
|
||||||
|
// digitalWrite(trig, HIGH);
|
||||||
|
// delayMicroseconds(10);
|
||||||
|
// digitalWrite(trig, LOW);
|
||||||
|
// duration_ = pulseIn(echo, HIGH, 30000); // 3000 µs = 50cm // 30000 µs = 5 m
|
||||||
|
// distance_cm = duration_ / 29 / 2;
|
||||||
|
// distance_cm = medianFilter.filtered(distance_cm); //отсечение промахов медианным фильтром
|
||||||
|
// counter++;
|
||||||
|
// if (counter > TANK_LEVEL_SAMPLES) {
|
||||||
|
// counter = 0;
|
||||||
|
// level = map(distance_cm,
|
||||||
|
// jsonReadInt(configOptionJson, "e_lev"),
|
||||||
|
// jsonReadInt(configOptionJson, "f_lev"), 0, 100);
|
||||||
|
//
|
||||||
|
// jsonWriteInt(configLiveJson, levelPr_value_name, level);
|
||||||
|
// eventGen(levelPr_value_name, "");
|
||||||
|
//
|
||||||
|
// MqttClient::publishStatus(levelPr_value_name, String(level));
|
||||||
|
//
|
||||||
|
// Serial.println("[I] sensor '" + levelPr_value_name + "' data: " + String(level));
|
||||||
|
//
|
||||||
|
// jsonWriteInt(configLiveJson, ultrasonicCm_value_name, distance_cm);
|
||||||
|
// eventGen(ultrasonicCm_value_name, "");
|
||||||
|
//
|
||||||
|
// MqttClient::publishStatus(ultrasonicCm_value_name, String(distance_cm));
|
||||||
|
//
|
||||||
|
// Serial.println("[I] sensor '" + ultrasonicCm_value_name + "' data: " + String(distance_cm));
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user