Files
IoTManager/include/Class/SensorConverting.h

34 lines
1003 B
C
Raw Normal View History

2020-08-28 03:25:13 +03:00
#pragma once
#include <Arduino.h>
#include "Class/LineParsing.h"
#include "Global.h"
class SensorConverting : public LineParsing {
public:
SensorConverting() : LineParsing(){};
2020-08-28 04:58:38 +03:00
int mapping(String key, int input) {
String map_ = jsonReadStr(configOptionJson, key + "_map");
if (map_ != "") {
map_.replace("map[", "");
map_.replace("]", "");
2020-08-28 03:58:54 +03:00
input = map(input,
2020-08-28 04:58:38 +03:00
selectFromMarkerToMarker(map_, ",", 0).toInt(),
selectFromMarkerToMarker(map_, ",", 1).toInt(),
selectFromMarkerToMarker(map_, ",", 2).toInt(),
selectFromMarkerToMarker(map_, ",", 3).toInt());
2020-08-28 03:58:54 +03:00
}
return input;
2020-08-28 03:25:13 +03:00
}
2020-08-28 04:58:38 +03:00
float correction(String key, float input) {
2020-08-28 03:58:54 +03:00
_c.replace("c[", "");
_c.replace("]", "");
float coef = _c.toFloat();
input = input * coef;
return input;
}
2020-08-28 03:25:13 +03:00
};
2020-08-28 03:58:54 +03:00
//extern SensorConverting* mySensorConverting;