add test data and comments

This commit is contained in:
proddy
2025-02-22 13:37:12 +01:00
parent 19572f313a
commit e484f11d12
2 changed files with 15 additions and 11 deletions

View File

@@ -640,6 +640,7 @@ bool AnalogSensor::get_value_info(JsonObject output, const char * cmd, const int
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))) {
for (const auto & sensor : sensors_) {
output[sensor.name()] = sensor.value();
@@ -647,6 +648,7 @@ bool AnalogSensor::get_value_info(JsonObject output, const char * cmd, const int
return true;
}
// show all entity details of the command is entities
if (!strcmp(cmd, F_(entities))) {
for (const auto & sensor : sensors_) {
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;
}
// this is for a specific sensor
// this is for a specific sensor, return the value
const char * attribute_s = Command::get_attribute(cmd);
for (const auto & sensor : sensors_) {
@@ -725,6 +727,7 @@ bool AnalogSensor::command_setvalue(const char * value, const int8_t gpio) {
}
val = b ? 1 : 0;
}
for (auto & sensor : sensors_) {
if (sensor.gpio() == gpio) {
double oldoffset = sensor.offset();
@@ -791,6 +794,7 @@ bool AnalogSensor::command_setvalue(const char * value, const int8_t gpio) {
return true;
}
}
return false;
}

View File

@@ -113,16 +113,16 @@ class AnalogSensor {
~AnalogSensor() = default;
enum AnalogType : int8_t {
NOTUSED, // 0 - disabled
DIGITAL_IN,
COUNTER,
ADC,
TIMER,
RATE,
DIGITAL_OUT,
PWM_0,
PWM_1,
PWM_2
NOTUSED = 0, // 0 = disabled
DIGITAL_IN = 1,
COUNTER = 2,
ADC = 3,
TIMER = 4,
RATE = 5,
DIGITAL_OUT = 6,
PWM_0 = 7,
PWM_1 = 8,
PWM_2 = 9
};
void start();