add gpio pin or i2c address to output/sensor table if used

This commit is contained in:
Marcus 2024-11-17 06:54:13 +01:00
parent 156849782b
commit df6435f6e1
6 changed files with 41 additions and 5 deletions

View file

@ -134,7 +134,7 @@ void setup() {
Wifi_Init(); Wifi_Init();
Webserver_Init(); Webserver_Init();
Serial.printf(":: [SETUP] Usable Pins: %d\n", GPIOindex_length); Serial.printf(":: [SETUP] Usable Pins: %d\n", GPIOindex_length);
for(byte i = 0; i < GPIOindex_length; i++) { for(byte i = 1; i <= GPIOindex_length; i++) {
Serial.printf(":: [SETUP] Pin Index: %d, GPIO: %d, Notes: ", i, GPIOindex[i].gpio); Serial.printf(":: [SETUP] Pin Index: %d, GPIO: %d, Notes: ", i, GPIOindex[i].gpio);
Serial.println(GPIO_Index_note_descr[GPIOindex[i].note]); Serial.println(GPIO_Index_note_descr[GPIOindex[i].note]);
} }

View file

@ -63,7 +63,8 @@
// //
const byte GPIOindex_length = 21; const byte GPIOindex_length = 21;
// initialize pinIndex with all usable GPIOs // initialize pinIndex with all usable GPIOs
GPIO_Index GPIOindex[] = { { 0, FLASHMODE_LOW }, GPIO_Index GPIOindex[] = {{ 255, 255 },
{ 0, FLASHMODE_LOW },
{ 4 }, { 4 },
{ 5 }, { 5 },
{ 12, BOOTFAILS_HIGH }, { 12, BOOTFAILS_HIGH },

View file

@ -47,7 +47,8 @@
const byte GPIOindex_length = 6; const byte GPIOindex_length = 6;
// initialize pinIndex with all usable GPIOs // initialize pinIndex with all usable GPIOs
GPIO_Index GPIOindex[] = { { 0, BOOTFAILS_LOW }, GPIO_Index GPIOindex[] = {{ 255, 255 },
{ 0, BOOTFAILS_LOW },
{ 12 }, { 12 },
{ 13 }, { 13 },
{ 14 }, { 14 },

View file

@ -118,7 +118,7 @@ String Html_SelectOpt_GPIOindex(byte selectId = 255) {
String gpioIndex_html; String gpioIndex_html;
// iterate through through all available GPIOs in index // iterate through through all available GPIOs in index
for(byte i = 0; i < GPIOindex_length; i++) { for(byte i = 1; i <= GPIOindex_length; i++) {
bool gpioUsed = Check_GPIOindex_Used(i); bool gpioUsed = Check_GPIOindex_Used(i);
gpioIndex_html += "<option value='"; gpioIndex_html += "<option value='";

View file

@ -339,6 +339,28 @@ String Proc_WebPage_system_output(const String& var) {
output_tr_td += config.system.output.name[i]; output_tr_td += config.system.output.name[i];
output_tr_td += "</td><td>"; output_tr_td += "</td><td>";
output_tr_td += Output_Type_descr[config.system.output.type[i]]; output_tr_td += Output_Type_descr[config.system.output.type[i]];
if((config.system.output.type[i] == OUTPUT_TYPE_GPIO) || (config.system.output.type[i] == OUTPUT_TYPE_I2C)) {
output_tr_td += " (";
}
switch(config.system.output.type[i]) {
case OUTPUT_TYPE_GPIO:
output_tr_td += GPIOindex[config.system.output.gpio[i]].gpio;
break;
case OUTPUT_TYPE_I2C:
output_tr_td += config.system.output.i2c[i];
break;
default:
break;
}
if((config.system.output.type[i] == OUTPUT_TYPE_GPIO) || (config.system.output.type[i] == OUTPUT_TYPE_I2C)) {
output_tr_td += ")";
}
output_tr_td += "</td><td>"; output_tr_td += "</td><td>";
output_tr_td += Output_Device_descr[config.system.output.device[i]]; output_tr_td += Output_Device_descr[config.system.output.device[i]];
output_tr_td += "</td><td>"; output_tr_td += "</td><td>";
@ -805,6 +827,18 @@ String Proc_WebPage_system_sensor(const String& var) {
output_tr_td += config.system.sensor.name[i]; output_tr_td += config.system.sensor.name[i];
output_tr_td += "</td><td>"; output_tr_td += "</td><td>";
output_tr_td += SensorIndex[config.system.sensor.type[i]].name; output_tr_td += SensorIndex[config.system.sensor.type[i]].name;
if((config.system.sensor.i2c_address[i] != "") || (config.system.sensor.gpio[i] > 0)) {
output_tr_td += " (";
if(config.system.sensor.gpio[i] > 0) {
output_tr_td += GPIOindex[config.system.sensor.gpio[i]].gpio;
} else {
output_tr_td += config.system.sensor.i2c_address[i];
}
output_tr_td += ")";
}
output_tr_td += "</td><td>"; output_tr_td += "</td><td>";
// edit button // edit button

View file

@ -282,7 +282,7 @@ const char* Page_system_sensor_add_HTML PROGMEM = R"(%HEADER%
<u>I2C address</u>:<br> <u>I2C address</u>:<br>
<p>leave empty for default</p> <p>leave empty for default</p>
<input type='text' name='i2c_address' maxlength='5' value='%SENSOR_I2C_ADDRESS%' required><br> <input type='text' name='i2c_address' maxlength='5' value='%SENSOR_I2C_ADDRESS%' ><br>
<u>GPIO</u>:<br> <u>GPIO</u>:<br>
<select name='gpio'> <select name='gpio'>