Files
IoTManager/include/items/SensorConvertingClass.h
Dmitry Borisenko 93c6b05238 not working version
2020-09-03 01:12:43 +03:00

32 lines
946 B
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include <Arduino.h>
#include "Class/LineParsing.h"
#include "Global.h"
class SensorConvertingClass : public LineParsing {
public:
SensorConvertingClass() : LineParsing(){};
int mapping(String key, int input) {
String map_ = jsonReadStr(configOptionJson, key + "_map");
if (map_ != "") {
input = map(input,
selectFromMarkerToMarker(map_, ",", 0).toInt(),
selectFromMarkerToMarker(map_, ",", 1).toInt(),
selectFromMarkerToMarker(map_, ",", 2).toInt(),
selectFromMarkerToMarker(map_, ",", 3).toInt());
}
return input;
}
float correction(String key, float input) {
String corr = jsonReadStr(configOptionJson, key + "_с");
if (corr != "") {
float coef = corr.toFloat();
input = input * coef;
}
return input;
}
};