dashboard gauge settings add sensor selection
This commit is contained in:
parent
bfddc51644
commit
59f9ffe5d3
2 changed files with 57 additions and 27 deletions
include
|
@ -77,7 +77,7 @@ const char SENSOR_READ_TYPE_COLOR_BLUE_descr[] PROGMEM = {"Color blue"};
|
|||
const char SENSOR_READ_TYPE_COLOR_BLUE_unit[] PROGMEM = {""};
|
||||
|
||||
const byte SENSOR_READ_TYPE_PARTS_PER_MILLION = 13;
|
||||
const char SENSOR_READ_TYPE_PARTS_PER_MILLION_descr[] PROGMEM = {"Part per million"};
|
||||
const char SENSOR_READ_TYPE_PARTS_PER_MILLION_descr[] PROGMEM = {"Parts per million"};
|
||||
const char SENSOR_READ_TYPE_PARTS_PER_MILLION_unit[] PROGMEM = {"ppm"};
|
||||
|
||||
const byte SENSOR_READ_TYPE_TVOC = 14;
|
||||
|
|
|
@ -762,9 +762,10 @@ String Proc_WebPage_grow_water(const String& var) {
|
|||
for(byte j = 0; j < Max_Sensors; j++) {
|
||||
/* if sensor is configured */
|
||||
if(config.system.sensor.type[j] > 0) {
|
||||
/* we want to offer humidity, temperature, gas resistance */
|
||||
/* we want to offer calculated soil moisture */
|
||||
for(byte k = 0; k < Max_Sensors_Read; k++) {
|
||||
if(SensorIndex[config.system.sensor.type[j]].read[k] > 0) {
|
||||
/* if reading contains soil moisture or convert to raw to soilmoisture is set */
|
||||
if((SensorIndex[config.system.sensor.type[j]].read[k] == SENSOR_READ_TYPE_SOILMOISTURE) || ((SensorIndex[config.system.sensor.type[j]].read[k] == SENSOR_READ_TYPE_RAW) && (config.system.sensor.rawConvert[j][k] == SENSOR_CONVERT_RAW_TYPE_SOILMOISTURE))) {
|
||||
|
||||
html += F("<option value='");
|
||||
|
@ -1066,7 +1067,7 @@ String Proc_WebPage_grow_dashboard_gaugeAdd(const String& var) {
|
|||
} else if(Test_WebPage_grow_SUBNAV(var)) {
|
||||
return Proc_WebPage_grow_SUBNAV(var, WEB_GROW_SUBNAV_DASHBOARD);
|
||||
} else if(var == "ACTION") {
|
||||
return FPSTR(Common_HTML_ACTION_EDIT);
|
||||
return FPSTR(Common_HTML_ACTION_ADD);
|
||||
} else if(var == "GAUGE_ID") {
|
||||
return String(Give_Free_Dashboard_GaugeId());
|
||||
} else if(var == "SENSOR_ID") {
|
||||
|
@ -1075,6 +1076,56 @@ String Proc_WebPage_grow_dashboard_gaugeAdd(const String& var) {
|
|||
} else if(var == "READ_ID") {
|
||||
String html;
|
||||
return html;
|
||||
} else if(var == "SELECT_SENSOR_READ") {
|
||||
String html;
|
||||
for(byte i = 0; i < Max_Sensors; i++) {
|
||||
/* if sensor is configured */
|
||||
// if(config.system.sensor.type[i] > 0) {
|
||||
// /* we want to offer humidity, temperature, gas resistance */
|
||||
for(byte j = 0; j < Max_Sensors_Read; j++) {
|
||||
if(SensorIndex[config.system.sensor.type[i]].read[j] > 0) {
|
||||
//if((SensorIndex[config.system.sensor.type[i]].read[j] == SENSOR_READ_TYPE_TEMP) ||
|
||||
//(SensorIndex[config.system.sensor.type[i]].read[j] == SENSOR_READ_TYPE_HUMIDITY) ||
|
||||
//(SensorIndex[config.system.sensor.type[i]].read[j] == SENSOR_READ_TYPE_GAS_RESISTANCE)) {
|
||||
|
||||
html += F("<option value='");
|
||||
|
||||
/* put SensorId and ReadId into one colon sperated string. This we seperate later within javascript */
|
||||
html += i; // SensorId
|
||||
html += F(":");
|
||||
html += j; // ReadId
|
||||
|
||||
html += F("'");
|
||||
//if((config.grow.dashboard.gaugeSensor[i] == i) && (config.grow.air.controlRead[i] == j))
|
||||
//html += F(" selected");
|
||||
html += F(">");
|
||||
html += config.system.sensor.name[i];
|
||||
html += F(" - ");
|
||||
/* in case of converted RAW value, just offer the converted value */
|
||||
if((SensorIndex[config.system.sensor.type[i]].read[j] == SENSOR_READ_TYPE_RAW) && (config.system.sensor.rawConvert[i][j] > 0)) {
|
||||
html += FPSTR(Sensor_Convert_Raw_descr[config.system.sensor.rawConvert[i][j]]);
|
||||
} else {
|
||||
html += FPSTR(Sensor_Read_descr[SensorIndex[config.system.sensor.type[i]].read[j]]);
|
||||
}
|
||||
|
||||
html += F(" (");
|
||||
html += Sensor_getCalibratedValue(i, j);
|
||||
html += F(" ");
|
||||
/* put unit into string */
|
||||
String unit = FPSTR(Sensor_Read_unit[SensorIndex[config.system.sensor.type[i]].read[j]]);
|
||||
/* to be able to replace % sign, which is already used by ESPAsyncWebserver's template engine
|
||||
* with html code for it */
|
||||
html += F(" ");
|
||||
unit.replace(F("%"), F("%"));
|
||||
html += unit;
|
||||
html += F(")</option>");
|
||||
//count++;
|
||||
// }
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
return html;
|
||||
} else {
|
||||
return String();
|
||||
}
|
||||
|
@ -1096,37 +1147,16 @@ String Proc_WebPage_grow_dashboard_gaugeAdd_POST(const String& var) {
|
|||
|
||||
/* WebPage function */
|
||||
void WebPage_grow_dashboard_gaugeAdd(AsyncWebServerRequest *request) {
|
||||
const static char LogLoc[] PROGMEM = "[Webserver:grow:dashboard]";
|
||||
const static char LogLoc[] PROGMEM = "[Webserver:grow:dashboard:gaugeAdd]";
|
||||
|
||||
|
||||
/* Which kind of Request */
|
||||
if(request->method() == HTTP_POST) {
|
||||
|
||||
|
||||
if(request->hasParam("delete_gauge", true)) {
|
||||
byte gaugeId;
|
||||
|
||||
const AsyncWebParameter* param = request->getParam("delete_gauge", true);
|
||||
gaugeId = param->value().toInt();
|
||||
|
||||
// we ensure that every field is empty
|
||||
config.grow.dashboard.gaugeConfigured[gaugeId] = false;
|
||||
config.grow.dashboard.gaugeSensor[gaugeId] = 0;
|
||||
config.grow.dashboard.gaugeRead[gaugeId] = 0;
|
||||
|
||||
SaveConfig();
|
||||
Log.notice(F("%s config saved" CR), LogLoc);
|
||||
}
|
||||
|
||||
//request->send_P(200, TEXT_HTML, Page_grow_dashboard_HTML, Proc_WebPage_grow_dashboard_POST);
|
||||
|
||||
//SaveConfig();
|
||||
|
||||
|
||||
|
||||
request->send_P(200, TEXT_HTML, Page_grow_dashboard_HTML, Proc_WebPage_grow_dashboard_POST);
|
||||
request->send_P(200, TEXT_HTML, Page_grow_dashboard_gaugeAdd_HTML, Proc_WebPage_grow_dashboard_gaugeAdd_POST);
|
||||
|
||||
} else {
|
||||
request->send_P(200, TEXT_HTML, Page_grow_dashboard_HTML, Proc_WebPage_grow_dashboard);
|
||||
request->send_P(200, TEXT_HTML, Page_grow_dashboard_gaugeAdd_HTML, Proc_WebPage_grow_dashboard_gaugeAdd);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue