mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 20:09:14 +03:00
not working version
This commit is contained in:
@@ -1,17 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#include "Class/LineParsing.h"
|
#include "Class/LineParsing.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
class Switch : public LineParsing {
|
class ButtonInClass : public LineParsing {
|
||||||
protected:
|
protected:
|
||||||
int numberEntering = 0;
|
int numberEntering = 0;
|
||||||
int state = _state.toInt();
|
int state = _state.toInt();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Switch() : LineParsing(){};
|
ButtonInClass() : LineParsing(){};
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
if (_pin != "") {
|
if (_pin != "") {
|
||||||
@@ -53,4 +51,4 @@ class Switch : public LineParsing {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Switch* mySwitch;
|
extern ButtonInClass* myButtonIn;
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "Class/LineParsing.h"
|
#include "Class/LineParsing.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
class Button1 : public LineParsing {
|
class ButtonOutClass : public LineParsing {
|
||||||
public:
|
public:
|
||||||
Button1() : LineParsing(){};
|
ButtonOutClass() : LineParsing(){};
|
||||||
|
|
||||||
void pinModeSet() {
|
void pinModeSet() {
|
||||||
if (_pin != "") {
|
if (_pin != "") {
|
||||||
@@ -40,4 +39,4 @@ class Button1 : public LineParsing {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Button1* myButton;
|
extern ButtonOutClass* myButtonOut;
|
||||||
@@ -1,13 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#include "Class/LineParsing.h"
|
#include "Class/LineParsing.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
class Input : public LineParsing {
|
class InputClass : public LineParsing {
|
||||||
public:
|
public:
|
||||||
Input() : LineParsing(){};
|
InputClass() : LineParsing(){};
|
||||||
|
|
||||||
void inputSetDefaultFloat() {
|
void inputSetDefaultFloat() {
|
||||||
inputSetFloat(_key, _state);
|
inputSetFloat(_key, _state);
|
||||||
@@ -30,4 +28,4 @@ class Input : public LineParsing {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Input* myInput;
|
extern InputClass* myInput;
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "Class/LineParsing.h"
|
#include "Class/LineParsing.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
class OutputModule : public LineParsing {
|
class OutputTextClass : public LineParsing {
|
||||||
public:
|
public:
|
||||||
OutputModule() : LineParsing(){};
|
OutputTextClass() : LineParsing(){};
|
||||||
|
|
||||||
void OutputModuleStateSetDefault() {
|
void OutputModuleStateSetDefault() {
|
||||||
if (_state != "") {
|
if (_state != "") {
|
||||||
@@ -21,4 +20,4 @@ class OutputModule : public LineParsing {
|
|||||||
MqttClient::publishStatus(key, state);
|
MqttClient::publishStatus(key, state);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
extern OutputModule* myText;
|
extern OutputTextClass* myOutputText;
|
||||||
@@ -1,13 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#include "Class/LineParsing.h"
|
#include "Class/LineParsing.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
class Pwm : public LineParsing {
|
class PwmOutClass : public LineParsing {
|
||||||
public:
|
public:
|
||||||
Pwm() : LineParsing(){};
|
PwmOutClass() : LineParsing(){};
|
||||||
|
|
||||||
void pwmModeSet() {
|
void pwmModeSet() {
|
||||||
if (_pin != "") {
|
if (_pin != "") {
|
||||||
@@ -30,4 +28,4 @@ class Pwm : public LineParsing {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Pwm* myPwm;
|
extern PwmOutClass* myPwmOut;
|
||||||
@@ -1,35 +1,32 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "Class/LineParsing.h"
|
#include "Class/LineParsing.h"
|
||||||
#include "Class/SensorConverting.h"
|
#include "items/SensorConvertingClass.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
class SensorAnalog : public SensorConverting {
|
class SensorAnalogClass : public SensorConvertingClass {
|
||||||
public:
|
public:
|
||||||
SensorAnalog() : SensorConverting(){};
|
SensorAnalogClass() : SensorConvertingClass(){};
|
||||||
|
|
||||||
void SensorAnalogInit(String key) {
|
|
||||||
}
|
|
||||||
|
|
||||||
int SensorAnalogRead(String key, String pin) {
|
int SensorAnalogRead(String key, String pin) {
|
||||||
|
|
||||||
int pinInt = pin.toInt();
|
int pinInt = pin.toInt();
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
value = analogRead(pinInt);
|
value = analogRead(pinInt);
|
||||||
#endif
|
#endif
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
pinInt = pinInt;
|
|
||||||
value = analogRead(A0);
|
value = analogRead(A0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
value = this->mapping(key, value);
|
value = this->mapping(key, value);
|
||||||
float valueFl = this->correction(key, value);
|
float valueFl = this->correction(key, value);
|
||||||
|
|
||||||
eventGen(key, "");
|
eventGen(key, "");
|
||||||
jsonWriteStr(configLiveJson, key, String(valueFl));
|
jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||||
MqttClient::publishStatus(key, String(valueFl));
|
MqttClient::publishStatus(key, String(valueFl));
|
||||||
|
|
||||||
Serial.println("[I] sensor '" + key + "' data: " + String(valueFl));
|
Serial.println("[I] sensor '" + key + "' data: " + String(valueFl));
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
extern SensorAnalog* mySensorAnalog;
|
extern SensorAnalogClass* mySensorAnalog;
|
||||||
@@ -5,9 +5,9 @@
|
|||||||
#include "Class/LineParsing.h"
|
#include "Class/LineParsing.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
class SensorConverting : public LineParsing {
|
class SensorConvertingClass : public LineParsing {
|
||||||
public:
|
public:
|
||||||
SensorConverting() : LineParsing(){};
|
SensorConvertingClass() : LineParsing(){};
|
||||||
|
|
||||||
int mapping(String key, int input) {
|
int mapping(String key, int input) {
|
||||||
String map_ = jsonReadStr(configOptionJson, key + "_map");
|
String map_ = jsonReadStr(configOptionJson, key + "_map");
|
||||||
34
include/items/SensorUltrasonicClass.h
Normal file
34
include/items/SensorUltrasonicClass.h
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
#include "Class/LineParsing.h"
|
||||||
|
#include "items/SensorConvertingClass.h"
|
||||||
|
#include "Global.h"
|
||||||
|
|
||||||
|
class SensorUltrasonic : public SensorConvertingClass {
|
||||||
|
public:
|
||||||
|
SensorUltrasonic() : SensorConvertingClass(){};
|
||||||
|
|
||||||
|
int SensorUltrasonicRead(String key, String pin) {
|
||||||
|
int trig = selectFromMarkerToMarker(pin, ",", 0).toInt();
|
||||||
|
int echo = selectFromMarkerToMarker(pin, ",", 1).toInt();
|
||||||
|
int value;
|
||||||
|
|
||||||
|
digitalWrite(trig, LOW);
|
||||||
|
delayMicroseconds(2);
|
||||||
|
digitalWrite(trig, HIGH);
|
||||||
|
delayMicroseconds(10);
|
||||||
|
digitalWrite(trig, LOW);
|
||||||
|
long duration_ = pulseIn(echo, HIGH, 30000); // 3000 µs = 50cm // 30000 µs = 5 m
|
||||||
|
value = duration_ / 29 / 2;
|
||||||
|
|
||||||
|
value = this->mapping(key, value);
|
||||||
|
float valueFl = this->correction(key, value);
|
||||||
|
eventGen(key, "");
|
||||||
|
jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||||
|
MqttClient::publishStatus(key, String(valueFl));
|
||||||
|
Serial.println("[I] sensor '" + key + "' data: " + String(valueFl));
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
extern SensorUltrasonic* mySensorUltrasonic;
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
#include "Class/Button.h"
|
|
||||||
Button1* myButton;
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
#include "Class/Input.h"
|
|
||||||
Input* myInput;
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
#include "Class/LineParsing.h"
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
#include "Class/OutputModule.h"
|
|
||||||
OutputModule* myText;
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
#include "Class/Pwm.h"
|
|
||||||
Pwm* myPwm;
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
#include "Class/SensorAnalog.h"
|
|
||||||
SensorAnalog* mySensorAnalog;
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
#include "Class/Switch.h"
|
|
||||||
Switch* mySwitch;
|
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
#include "Class/SensorAnalog.h"
|
|
||||||
#include "Cmd.h"
|
#include "Cmd.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,22 @@
|
|||||||
#include "items/itemsGlobal.h"
|
#include "items/itemsGlobal.h"
|
||||||
#include "Class/Switch.h"
|
#include "items/ButtonInClass.h"
|
||||||
//==========================================Модуль физических кнопок========================================
|
//==========================================Модуль физических кнопок========================================
|
||||||
//button-in switch1 toggle Кнопки Свет 1 pin[2] db[20]
|
//button-in switch1 toggle Кнопки Свет 1 pin[2] db[20]
|
||||||
//==========================================================================================================
|
//==========================================================================================================
|
||||||
|
ButtonInClass* myButtonIn;
|
||||||
void buttonIn() {
|
void buttonIn() {
|
||||||
mySwitch = new Switch();
|
myButtonIn = new ButtonInClass();
|
||||||
mySwitch->update();
|
myButtonIn->update();
|
||||||
String key = mySwitch->gkey();
|
String key = myButtonIn->gkey();
|
||||||
String pin = mySwitch->gpin();
|
String pin = myButtonIn->gpin();
|
||||||
sCmd.addCommand(key.c_str(), buttonInSet);
|
sCmd.addCommand(key.c_str(), buttonInSet);
|
||||||
mySwitch->init();
|
myButtonIn->init();
|
||||||
mySwitch->switchStateSetDefault();
|
myButtonIn->switchStateSetDefault();
|
||||||
mySwitch->clear();
|
myButtonIn->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void buttonInSet() {
|
void buttonInSet() {
|
||||||
String key = sCmd.order();
|
String key = sCmd.order();
|
||||||
String state = sCmd.next();
|
String state = sCmd.next();
|
||||||
mySwitch->switchChangeVirtual(key, state);
|
myButtonIn->switchChangeVirtual(key, state);
|
||||||
}
|
}
|
||||||
@@ -1,21 +1,22 @@
|
|||||||
#include "items/itemsGlobal.h"
|
#include "items/itemsGlobal.h"
|
||||||
#include "Class/Button.h"
|
#include "items/ButtonOutClass.h"
|
||||||
//==========================================Модуль кнопок===================================================
|
//==========================================Модуль кнопок===================================================
|
||||||
//button-out light toggle Кнопки Свет 1 pin[12] inv[1] st[1]
|
//button-out light toggle Кнопки Свет 1 pin[12] inv[1] st[1]
|
||||||
//==========================================================================================================
|
//==========================================================================================================
|
||||||
|
ButtonOutClass* myButtonOut;
|
||||||
void buttonOut() {
|
void buttonOut() {
|
||||||
myButton = new Button1();
|
myButtonOut = new ButtonOutClass();
|
||||||
myButton->update();
|
myButtonOut->update();
|
||||||
String key = myButton->gkey();
|
String key = myButtonOut->gkey();
|
||||||
String pin = myButton->gpin();
|
String pin = myButtonOut->gpin();
|
||||||
String inv = myButton->ginv();
|
String inv = myButtonOut->ginv();
|
||||||
sCmd.addCommand(key.c_str(), buttonOutSet);
|
sCmd.addCommand(key.c_str(), buttonOutSet);
|
||||||
jsonWriteStr(configOptionJson, key + "_pin", pin);
|
jsonWriteStr(configOptionJson, key + "_pin", pin);
|
||||||
jsonWriteStr(configOptionJson, key + "_inv", inv);
|
jsonWriteStr(configOptionJson, key + "_inv", inv);
|
||||||
myButton->pinModeSet();
|
myButtonOut->pinModeSet();
|
||||||
myButton->pinStateSetDefault();
|
myButtonOut->pinStateSetDefault();
|
||||||
myButton->pinStateSetInvDefault();
|
myButtonOut->pinStateSetInvDefault();
|
||||||
myButton->clear();
|
myButtonOut->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void buttonOutSet() {
|
void buttonOutSet() {
|
||||||
@@ -24,8 +25,8 @@ void buttonOutSet() {
|
|||||||
String pin = jsonReadStr(configOptionJson, key + "_pin");
|
String pin = jsonReadStr(configOptionJson, key + "_pin");
|
||||||
String inv = jsonReadStr(configOptionJson, key + "_inv");
|
String inv = jsonReadStr(configOptionJson, key + "_inv");
|
||||||
if (inv == "") {
|
if (inv == "") {
|
||||||
myButton->pinChange(key, pin, state, true);
|
myButtonOut->pinChange(key, pin, state, true);
|
||||||
} else {
|
} else {
|
||||||
myButton->pinChange(key, pin, state, false);
|
myButtonOut->pinChange(key, pin, state, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,19 +1,20 @@
|
|||||||
#include "items/itemsGlobal.h"
|
#include "items/itemsGlobal.h"
|
||||||
#include "Class/Input.h"
|
#include "items/InputClass.h"
|
||||||
//==========================================Модуль ввода цифровых значений==================================
|
//==========================================Модуль ввода цифровых значений==================================
|
||||||
//input-digit digit1 inputDigit Ввод Введите.цифру 4 st[60]
|
//input-digit digit1 inputDigit Ввод Введите.цифру 4 st[60]
|
||||||
//==========================================================================================================
|
//==========================================================================================================
|
||||||
|
InputClass* myInputDigit;
|
||||||
void inputDigit() {
|
void inputDigit() {
|
||||||
myInput = new Input();
|
myInputDigit = new InputClass();
|
||||||
myInput->update();
|
myInputDigit->update();
|
||||||
String key = myInput->gkey();
|
String key = myInputDigit->gkey();
|
||||||
sCmd.addCommand(key.c_str(), inputDigitSet);
|
sCmd.addCommand(key.c_str(), inputDigitSet);
|
||||||
myInput->inputSetDefaultFloat();
|
myInputDigit->inputSetDefaultFloat();
|
||||||
myInput->clear();
|
myInputDigit->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void inputDigitSet() {
|
void inputDigitSet() {
|
||||||
String key = sCmd.order();
|
String key = sCmd.order();
|
||||||
String state = sCmd.next();
|
String state = sCmd.next();
|
||||||
myInput->inputSetFloat(key, state);
|
myInputDigit->inputSetFloat(key, state);
|
||||||
}
|
}
|
||||||
@@ -1,21 +1,22 @@
|
|||||||
#include "items/itemsGlobal.h"
|
#include "items/itemsGlobal.h"
|
||||||
#include "Class/Input.h"
|
#include "items/InputClass.h"
|
||||||
//==========================================Модуль ввода времени============================================
|
//==========================================Модуль ввода времени============================================
|
||||||
//input-time time1 inputTime Ввод Введите.время 4 st[10-00-00]
|
//input-time time1 inputTime Ввод Введите.время 4 st[10-00-00]
|
||||||
//==========================================================================================================
|
//==========================================================================================================
|
||||||
|
InputClass* myInputTime;
|
||||||
void inputTime() {
|
void inputTime() {
|
||||||
myInput = new Input();
|
myInputTime = new InputClass();
|
||||||
myInput->update();
|
myInputTime->update();
|
||||||
String key = myInput->gkey();
|
String key = myInputTime->gkey();
|
||||||
sCmd.addCommand(key.c_str(), inputTimeSet);
|
sCmd.addCommand(key.c_str(), inputTimeSet);
|
||||||
myInput->inputSetDefaultStr();
|
myInputTime->inputSetDefaultStr();
|
||||||
myInput->clear();
|
myInputTime->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void inputTimeSet() {
|
void inputTimeSet() {
|
||||||
String key = sCmd.order();
|
String key = sCmd.order();
|
||||||
String state = sCmd.next();
|
String state = sCmd.next();
|
||||||
myInput->inputSetStr(key, state);
|
myInputTime->inputSetStr(key, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_time_init() {
|
void handle_time_init() {
|
||||||
@@ -1,19 +1,20 @@
|
|||||||
#include "items/itemsGlobal.h"
|
#include "items/itemsGlobal.h"
|
||||||
#include "Class/OutputModule.h"
|
#include "items/OutputTextClass.h"
|
||||||
//===============================================Модуль вывода текста============================================
|
//===============================================Модуль вывода текста============================================
|
||||||
//output-text;id;anydata;Вывод;Сигнализация;order;st[Обнаружено.движение]
|
//output-text;id;anydata;Вывод;Сигнализация;order;st[Обнаружено.движение]
|
||||||
//===============================================================================================================
|
//===============================================================================================================
|
||||||
|
OutputTextClass* myOutputText;
|
||||||
void textOut() {
|
void textOut() {
|
||||||
myText = new OutputModule();
|
myOutputText = new OutputTextClass();
|
||||||
myText->update();
|
myOutputText->update();
|
||||||
String key = myText->gkey();
|
String key = myOutputText->gkey();
|
||||||
sCmd.addCommand(key.c_str(), textOutSet);
|
sCmd.addCommand(key.c_str(), textOutSet);
|
||||||
myText->OutputModuleStateSetDefault();
|
myOutputText->OutputModuleStateSetDefault();
|
||||||
myText->clear();
|
myOutputText->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void textOutSet() {
|
void textOutSet() {
|
||||||
String key = sCmd.order();
|
String key = sCmd.order();
|
||||||
String state = sCmd.next();
|
String state = sCmd.next();
|
||||||
myText->OutputModuleChange(key, state);
|
myOutputText->OutputModuleChange(key, state);
|
||||||
}
|
}
|
||||||
@@ -1,24 +1,25 @@
|
|||||||
#include "items/itemsGlobal.h"
|
#include "items/itemsGlobal.h"
|
||||||
#include "Class/Pwm.h"
|
#include "items/PwmOutClass.h"
|
||||||
//==========================================Модуль управления ШИМ===================================================
|
//==========================================Модуль управления ШИМ===================================================
|
||||||
//pwm-out volume range Кнопки Свет 1 pin[12] st[500]
|
//pwm-out volume range Кнопки Свет 1 pin[12] st[500]
|
||||||
//==================================================================================================================
|
//==================================================================================================================
|
||||||
|
PwmOutClass* myPwmOut;
|
||||||
void pwmOut() {
|
void pwmOut() {
|
||||||
myPwm = new Pwm();
|
myPwmOut = new PwmOutClass();
|
||||||
myPwm->update();
|
myPwmOut->update();
|
||||||
String key = myPwm->gkey();
|
String key = myPwmOut->gkey();
|
||||||
String pin = myPwm->gpin();
|
String pin = myPwmOut->gpin();
|
||||||
String inv = myPwm->ginv();
|
String inv = myPwmOut->ginv();
|
||||||
sCmd.addCommand(key.c_str(), pwmOutSet);
|
sCmd.addCommand(key.c_str(), pwmOutSet);
|
||||||
jsonWriteStr(configOptionJson, key + "_pin", pin);
|
jsonWriteStr(configOptionJson, key + "_pin", pin);
|
||||||
myPwm->pwmModeSet();
|
myPwmOut->pwmModeSet();
|
||||||
myPwm->pwmStateSetDefault();
|
myPwmOut->pwmStateSetDefault();
|
||||||
myPwm->clear();
|
myPwmOut->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void pwmOutSet() {
|
void pwmOutSet() {
|
||||||
String key = sCmd.order();
|
String key = sCmd.order();
|
||||||
String state = sCmd.next();
|
String state = sCmd.next();
|
||||||
String pin = jsonReadStr(configOptionJson, key + "_pin");
|
String pin = jsonReadStr(configOptionJson, key + "_pin");
|
||||||
myPwm->pwmChange(key, pin, state);
|
myPwmOut->pwmChange(key, pin, state);
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
#include "items/itemsGlobal.h"
|
#include "items/itemsGlobal.h"
|
||||||
#include "Class/SensorAnalog.h"
|
#include "items/SensorAnalogClass.h"
|
||||||
#ifdef ANALOG_ENABLED
|
#ifdef ANALOG_ENABLED
|
||||||
//==============================================Модуль аналогового сенсора===========================================================================================
|
//==============================================Модуль аналогового сенсора===========================================================================================
|
||||||
//analog-adc;id;anydata;Сенсоры;Аналоговый;order;pin-adc;map[1,1024,1,100];c[1]
|
//analog-adc;id;anydata;Сенсоры;Аналоговый;order;pin-adc;map[1,1024,1,100];c[1]
|
||||||
//===================================================================================================================================================================
|
//===================================================================================================================================================================
|
||||||
|
SensorAnalogClass* mySensorAnalog;
|
||||||
void analogAdc() {
|
void analogAdc() {
|
||||||
mySensorAnalog = new SensorAnalog();
|
mySensorAnalog = new SensorAnalogClass();
|
||||||
mySensorAnalog->update();
|
mySensorAnalog->update();
|
||||||
String key = mySensorAnalog->gkey();
|
String key = mySensorAnalog->gkey();
|
||||||
String pin = mySensorAnalog->gpin();
|
String pin = mySensorAnalog->gpin();
|
||||||
@@ -1,20 +1,35 @@
|
|||||||
#include "items/itemsGlobal.h"
|
#include "items/itemsGlobal.h"
|
||||||
#include "Class/SensorAnalog.h"
|
#include "items/SensorUltrasonicClass.h"
|
||||||
#ifdef LEVEL_ENABLED
|
//#ifdef LEVEL_ENABLED
|
||||||
//=========================================Модуль ультрозвукового дальномера==================================================================
|
//=========================================Модуль ультрозвукового дальномера==================================================================
|
||||||
//ultrasonic-cm;id;anydata;Сенсоры;Расстояние;order;pin;map[1,100,1,100];c[1]
|
//ultrasonic-cm;id;anydata;Сенсоры;Расстояние;order;pin[12,13];map[1,100,1,100];c[1]
|
||||||
//=========================================================================================================================================
|
//=========================================================================================================================================
|
||||||
void ultrasonicCm() {
|
void ultrasonicCm() {
|
||||||
|
mySensorUltrasonic = new SensorUltrasonic();
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ultrasonicReading() {
|
void ultrasonicReading() {
|
||||||
|
String key = sCmd.order();
|
||||||
|
String trig = jsonReadStr(configOptionJson, key + "_trig");
|
||||||
|
String echo = jsonReadStr(configOptionJson, key + "_echo");
|
||||||
|
String pin = trig + "," + echo;
|
||||||
|
mySensorUltrasonic->SensorUltrasonicRead(key, pin);
|
||||||
}
|
}
|
||||||
|
//#endif
|
||||||
|
|
||||||
void levelPr() {
|
//void levelPr() {
|
||||||
// String value_name = sCmd.next();
|
// String value_name = sCmd.next();
|
||||||
// String trig = sCmd.next();
|
// String trig = sCmd.next();
|
||||||
// String echo = sCmd.next();
|
// String echo = sCmd.next();
|
||||||
@@ -33,7 +48,7 @@ void levelPr() {
|
|||||||
// pinMode(echo.toInt(), INPUT);
|
// pinMode(echo.toInt(), INPUT);
|
||||||
// createWidgetByType(widget_name, page_name, page_number, type, value_name);
|
// createWidgetByType(widget_name, page_name, page_number, type, value_name);
|
||||||
// sensors_reading_map[0] = 1;
|
// sensors_reading_map[0] = 1;
|
||||||
}
|
//}
|
||||||
////ultrasonicCm cm 14 12 Дистанция,#см Датчики fillgauge 1
|
////ultrasonicCm cm 14 12 Дистанция,#см Датчики fillgauge 1
|
||||||
//void ultrasonicCm() {
|
//void ultrasonicCm() {
|
||||||
// String value_name = sCmd.next();
|
// String value_name = sCmd.next();
|
||||||
@@ -54,20 +69,13 @@ void levelPr() {
|
|||||||
// sensors_reading_map[0] = 1;
|
// sensors_reading_map[0] = 1;
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
void ultrasonic_reading() {
|
//void ultrasonic_reading() {
|
||||||
// long duration_;
|
// long duration_;
|
||||||
// int distance_cm;
|
// int distance_cm;
|
||||||
// int level;
|
// int level;
|
||||||
// static int counter;
|
// static int counter;
|
||||||
// int trig = jsonReadInt(configOptionJson, "trig");
|
// int trig = jsonReadInt(configOptionJson, "trig");
|
||||||
// int echo = jsonReadInt(configOptionJson, "echo");
|
// 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); //отсечение промахов медианным фильтром
|
// distance_cm = medianFilter.filtered(distance_cm); //отсечение промахов медианным фильтром
|
||||||
// counter++;
|
// counter++;
|
||||||
// if (counter > TANK_LEVEL_SAMPLES) {
|
// if (counter > TANK_LEVEL_SAMPLES) {
|
||||||
@@ -90,5 +98,5 @@ void ultrasonic_reading() {
|
|||||||
//
|
//
|
||||||
// Serial.println("[I] sensor '" + ultrasonicCm_value_name + "' data: " + String(distance_cm));
|
// Serial.println("[I] sensor '" + ultrasonicCm_value_name + "' data: " + String(distance_cm));
|
||||||
// }
|
// }
|
||||||
}
|
//}
|
||||||
#endif
|
//
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
#include "Class/CallBackTest.h"
|
#include "Class/CallBackTest.h"
|
||||||
#include "Class/NotAsinc.h"
|
#include "Class/NotAsinc.h"
|
||||||
#include "Class/ScenarioClass.h"
|
#include "Class/ScenarioClass.h"
|
||||||
#include "Class/Switch.h"
|
#include "items/ButtonInClass.h"
|
||||||
#include "Cmd.h"
|
#include "Cmd.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "Init.h"
|
#include "Init.h"
|
||||||
@@ -101,7 +101,7 @@ void loop() {
|
|||||||
#endif
|
#endif
|
||||||
timeNow->loop();
|
timeNow->loop();
|
||||||
MqttClient::loop();
|
MqttClient::loop();
|
||||||
mySwitch->loop();
|
myButtonIn->loop();
|
||||||
myScenario->loop();
|
myScenario->loop();
|
||||||
//loopScenario();
|
//loopScenario();
|
||||||
loopCmd();
|
loopCmd();
|
||||||
|
|||||||
Reference in New Issue
Block a user