mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 11:59:12 +03:00
progress of sensors
This commit is contained in:
@@ -1 +1 @@
|
|||||||
analog-adc;id;anydata;Сенсоры;Аналоговый;order;pin[0];map[1,100,1,100];c[0]
|
analog-adc;id;anydata;Сенсоры;Аналоговый;order;pin-adc;map[1,100,1,100];c[0]
|
||||||
@@ -3,9 +3,10 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#include "Class/LineParsing.h"
|
#include "Class/LineParsing.h"
|
||||||
|
#include "Class/SensorConverting.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
class SensorAnalog : public LineParsing {
|
class SensorAnalog : public LineParsing public SensorConverting {
|
||||||
public:
|
public:
|
||||||
SensorAnalog() : LineParsing(){};
|
SensorAnalog() : LineParsing(){};
|
||||||
|
|
||||||
@@ -29,6 +30,8 @@ class SensorAnalog : public LineParsing {
|
|||||||
eventGen(key, "");
|
eventGen(key, "");
|
||||||
jsonWriteInt(configLiveJson, key, value);
|
jsonWriteInt(configLiveJson, key, value);
|
||||||
MqttClient::publishStatus(key, String(value));
|
MqttClient::publishStatus(key, String(value));
|
||||||
|
|
||||||
|
Serial.println("[I] sensor '" + key + "' data: " + String(value));
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
20
include/Class/SensorConverting.h
Normal file
20
include/Class/SensorConverting.h
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
#include "Class/LineParsing.h"
|
||||||
|
#include "Global.h"
|
||||||
|
|
||||||
|
class SensorConverting : public LineParsing {
|
||||||
|
public:
|
||||||
|
SensorConverting() : LineParsing(){};
|
||||||
|
|
||||||
|
void SensorConvertingInit() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
extern SensorConverting* mySensorConverting;
|
||||||
@@ -6,4 +6,5 @@
|
|||||||
extern void addItem(String name);
|
extern void addItem(String name);
|
||||||
extern void delAllItems();
|
extern void delAllItems();
|
||||||
extern uint8_t getNewElementNumber(String file);
|
extern uint8_t getNewElementNumber(String file);
|
||||||
extern uint8_t getFreePin();
|
extern uint8_t getFreePinAll();
|
||||||
|
extern uint8_t getFreePinAnalog();
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "ItemsList.h"
|
#include "ItemsList.h"
|
||||||
|
|
||||||
#include "Utils\StringUtils.h"
|
#include "Utils\StringUtils.h"
|
||||||
|
|
||||||
static const char* firstLine PROGMEM = "Тип элемента;Id;Виджет;Имя вкладки;Имя виджета;Позиция виджета";
|
static const char* firstLine PROGMEM = "Тип элемента;Id;Виджет;Имя вкладки;Имя виджета;Позиция виджета";
|
||||||
@@ -8,7 +9,11 @@ void addItem(String name) {
|
|||||||
name = deleteToMarkerLast(name, "-");
|
name = deleteToMarkerLast(name, "-");
|
||||||
item.replace("id", name + String(getNewElementNumber("id.txt")));
|
item.replace("id", name + String(getNewElementNumber("id.txt")));
|
||||||
item.replace("order", String(getNewElementNumber("order.txt")));
|
item.replace("order", String(getNewElementNumber("order.txt")));
|
||||||
item.replace("pin", "pin[" + String(getFreePin()) + "]");
|
if (item.indexOf("pin-adc") != -1) {
|
||||||
|
item.replace("pin-adc", "pin[" + String(getFreePinAnalog()) + "]");
|
||||||
|
} else if (item.indexOf("pin") != -1) {
|
||||||
|
item.replace("pin", "pin[" + String(getFreePinAll()) + "]");
|
||||||
|
}
|
||||||
item.replace("\r\n", "");
|
item.replace("\r\n", "");
|
||||||
item.replace("\r", "");
|
item.replace("\r", "");
|
||||||
item.replace("\n", "");
|
item.replace("\n", "");
|
||||||
@@ -31,13 +36,13 @@ uint8_t getNewElementNumber(String file) {
|
|||||||
return number;
|
return number;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getFreePin() {
|
uint8_t getFreePinAll() {
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
uint8_t pins[] = {0, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5};
|
uint8_t pins[] = {0, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5};
|
||||||
#endif
|
#endif
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
uint8_t pins[] = {0, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5};
|
uint8_t pins[] = {0, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5};
|
||||||
#endif
|
#endif
|
||||||
uint8_t array_sz = sizeof(pins) / sizeof(pins[0]);
|
uint8_t array_sz = sizeof(pins) / sizeof(pins[0]);
|
||||||
uint8_t i = getNewElementNumber("pins.txt");
|
uint8_t i = getNewElementNumber("pins.txt");
|
||||||
if (i < array_sz) {
|
if (i < array_sz) {
|
||||||
@@ -47,6 +52,12 @@ uint8_t getFreePin() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t getFreePinAnalog() {
|
||||||
|
#ifdef ESP8266
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
//void do_getJsonListFromCsv() {
|
//void do_getJsonListFromCsv() {
|
||||||
// if (getJsonListFromCsvFlag) {
|
// if (getJsonListFromCsvFlag) {
|
||||||
// getJsonListFromCsvFlag = false;
|
// getJsonListFromCsvFlag = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user