mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
add test data and comments
This commit is contained in:
@@ -640,6 +640,7 @@ bool AnalogSensor::get_value_info(JsonObject output, const char * cmd, const int
|
|||||||
return true; // no sensors, return true
|
return true; // no sensors, return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// return all values if its an info and values command
|
||||||
if (!strcmp(cmd, F_(info)) || !strcmp(cmd, F_(values))) {
|
if (!strcmp(cmd, F_(info)) || !strcmp(cmd, F_(values))) {
|
||||||
for (const auto & sensor : sensors_) {
|
for (const auto & sensor : sensors_) {
|
||||||
output[sensor.name()] = sensor.value();
|
output[sensor.name()] = sensor.value();
|
||||||
@@ -647,6 +648,7 @@ bool AnalogSensor::get_value_info(JsonObject output, const char * cmd, const int
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// show all entity details of the command is entities
|
||||||
if (!strcmp(cmd, F_(entities))) {
|
if (!strcmp(cmd, F_(entities))) {
|
||||||
for (const auto & sensor : sensors_) {
|
for (const auto & sensor : sensors_) {
|
||||||
get_value_json(output[sensor.name()].to<JsonObject>(), sensor);
|
get_value_json(output[sensor.name()].to<JsonObject>(), sensor);
|
||||||
@@ -654,7 +656,7 @@ bool AnalogSensor::get_value_info(JsonObject output, const char * cmd, const int
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is for a specific sensor
|
// this is for a specific sensor, return the value
|
||||||
const char * attribute_s = Command::get_attribute(cmd);
|
const char * attribute_s = Command::get_attribute(cmd);
|
||||||
|
|
||||||
for (const auto & sensor : sensors_) {
|
for (const auto & sensor : sensors_) {
|
||||||
@@ -725,6 +727,7 @@ bool AnalogSensor::command_setvalue(const char * value, const int8_t gpio) {
|
|||||||
}
|
}
|
||||||
val = b ? 1 : 0;
|
val = b ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto & sensor : sensors_) {
|
for (auto & sensor : sensors_) {
|
||||||
if (sensor.gpio() == gpio) {
|
if (sensor.gpio() == gpio) {
|
||||||
double oldoffset = sensor.offset();
|
double oldoffset = sensor.offset();
|
||||||
@@ -791,6 +794,7 @@ bool AnalogSensor::command_setvalue(const char * value, const int8_t gpio) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -113,16 +113,16 @@ class AnalogSensor {
|
|||||||
~AnalogSensor() = default;
|
~AnalogSensor() = default;
|
||||||
|
|
||||||
enum AnalogType : int8_t {
|
enum AnalogType : int8_t {
|
||||||
NOTUSED, // 0 - disabled
|
NOTUSED = 0, // 0 = disabled
|
||||||
DIGITAL_IN,
|
DIGITAL_IN = 1,
|
||||||
COUNTER,
|
COUNTER = 2,
|
||||||
ADC,
|
ADC = 3,
|
||||||
TIMER,
|
TIMER = 4,
|
||||||
RATE,
|
RATE = 5,
|
||||||
DIGITAL_OUT,
|
DIGITAL_OUT = 6,
|
||||||
PWM_0,
|
PWM_0 = 7,
|
||||||
PWM_1,
|
PWM_1 = 8,
|
||||||
PWM_2
|
PWM_2 = 9
|
||||||
};
|
};
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
|
|||||||
Reference in New Issue
Block a user