mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 11:59:12 +03:00
not working version
This commit is contained in:
@@ -6,9 +6,11 @@
|
|||||||
#include "Class/SensorConverting.h"
|
#include "Class/SensorConverting.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
class SensorAnalog : public LineParsing public SensorConverting {
|
class SensorAnalog : public LineParsing,
|
||||||
|
public SensorConverting {
|
||||||
public:
|
public:
|
||||||
SensorAnalog() : LineParsing(){};
|
SensorAnalog() : LineParsing(),
|
||||||
|
SensorConverting(){};
|
||||||
|
|
||||||
void SensorAnalogInit() {
|
void SensorAnalogInit() {
|
||||||
//if (_pin != "") {
|
//if (_pin != "") {
|
||||||
@@ -26,12 +28,15 @@ class SensorAnalog : public LineParsing public SensorConverting {
|
|||||||
pinInt = pinInt;
|
pinInt = pinInt;
|
||||||
value = analogRead(A0);
|
value = analogRead(A0);
|
||||||
#endif
|
#endif
|
||||||
|
float valueFl;
|
||||||
|
//float valueFl = this->mapping(value);
|
||||||
|
// valueFl = this->correction(valueFl);
|
||||||
|
|
||||||
eventGen(key, "");
|
eventGen(key, "");
|
||||||
jsonWriteInt(configLiveJson, key, value);
|
jsonWriteFloat(configLiveJson, key, valueFl);
|
||||||
MqttClient::publishStatus(key, String(value));
|
MqttClient::publishStatus(key, String(valueFl));
|
||||||
|
|
||||||
Serial.println("[I] sensor '" + key + "' data: " + String(value));
|
Serial.println("[I] sensor '" + key + "' data: " + String(valueFl));
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,12 +9,25 @@ class SensorConverting : public LineParsing {
|
|||||||
public:
|
public:
|
||||||
SensorConverting() : LineParsing(){};
|
SensorConverting() : LineParsing(){};
|
||||||
|
|
||||||
void SensorConvertingInit() {
|
int mapping(int input) {
|
||||||
|
if (_map != "") {
|
||||||
|
_map.replace("map[", "");
|
||||||
|
_map.replace("]", "");
|
||||||
|
input = map(input,
|
||||||
|
selectFromMarkerToMarker(_map, ",", 0).toInt(),
|
||||||
|
selectFromMarkerToMarker(_map, ",", 1).toInt(),
|
||||||
|
selectFromMarkerToMarker(_map, ",", 2).toInt(),
|
||||||
|
selectFromMarkerToMarker(_map, ",", 3).toInt());
|
||||||
|
}
|
||||||
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float correction(float input) {
|
||||||
|
_c.replace("c[", "");
|
||||||
|
_c.replace("]", "");
|
||||||
|
float coef = _c.toFloat();
|
||||||
|
input = input * coef;
|
||||||
|
return input;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
extern SensorConverting* mySensorConverting;
|
//extern SensorConverting* mySensorConverting;
|
||||||
Reference in New Issue
Block a user