mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
analogsensor float->double #789
This commit is contained in:
@@ -35,10 +35,10 @@ class AnalogSensor {
|
||||
public:
|
||||
class Sensor {
|
||||
public:
|
||||
Sensor(const uint8_t gpio, const std::string & name, const float offset, const float factor, const uint8_t uom, const int8_t type);
|
||||
Sensor(const uint8_t gpio, const std::string & name, const double offset, const double factor, const uint8_t uom, const int8_t type);
|
||||
~Sensor() = default;
|
||||
|
||||
void set_offset(const float offset) {
|
||||
void set_offset(const double offset) {
|
||||
offset_ = offset;
|
||||
}
|
||||
|
||||
@@ -52,23 +52,23 @@ class AnalogSensor {
|
||||
return gpio_;
|
||||
}
|
||||
|
||||
float value() const {
|
||||
double value() const {
|
||||
return value_;
|
||||
}
|
||||
|
||||
void set_value(float value) {
|
||||
void set_value(const double value) {
|
||||
value_ = value;
|
||||
}
|
||||
|
||||
float factor() const {
|
||||
double factor() const {
|
||||
return factor_;
|
||||
}
|
||||
|
||||
void set_factor(float factor) {
|
||||
void set_factor(const double factor) {
|
||||
factor_ = factor;
|
||||
}
|
||||
|
||||
float offset() const {
|
||||
double offset() const {
|
||||
return offset_;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class AnalogSensor {
|
||||
return type_;
|
||||
}
|
||||
|
||||
void set_type(int8_t type) {
|
||||
void set_type(const int8_t type) {
|
||||
type_ = type;
|
||||
}
|
||||
|
||||
@@ -101,10 +101,10 @@ class AnalogSensor {
|
||||
private:
|
||||
uint8_t gpio_;
|
||||
std::string name_;
|
||||
float offset_;
|
||||
float factor_;
|
||||
double offset_;
|
||||
double factor_;
|
||||
uint8_t uom_;
|
||||
float value_; // float because of the factor is a float
|
||||
double value_; // double because of the factor is a double
|
||||
int8_t type_;
|
||||
};
|
||||
|
||||
@@ -157,7 +157,7 @@ class AnalogSensor {
|
||||
return sensors_.size();
|
||||
}
|
||||
|
||||
bool update(uint8_t gpio, const std::string & name, float offset, float factor, uint8_t uom, int8_t type);
|
||||
bool update(uint8_t gpio, const std::string & name, double offset, double factor, uint8_t uom, int8_t type);
|
||||
bool get_value_info(JsonObject & output, const char * cmd, const int8_t id) const;
|
||||
|
||||
#ifdef EMSESP_DEBUG
|
||||
|
||||
Reference in New Issue
Block a user