put GPIO_Index.note description into char const

This commit is contained in:
Marcus 2024-10-26 18:05:10 +02:00
parent c8247268cc
commit a983129085
2 changed files with 34 additions and 20 deletions

View file

@ -63,6 +63,8 @@
* 5 - NO_PWM: No PWM output
* 6 - PWM_BOOT: PWM at boot time
*/
const byte GPIO_Index_len = 6;
const byte BOOTFAILS_LOW = 1;
const byte BOOTFAILS_HIGH = 2;
const byte FLASHMODE_LOW = 3;
@ -70,6 +72,25 @@ const byte INPUT_ONLY = 4;
const byte NO_PWM = 5;
const byte HIGH_BOOT = 6;
char BOOTFAILS_LOW_descr[] = "BF_LOW";
char BOOTFAILS_HIGH_descr[] = "BF_HIGH";
char FLASMODE_LOW_descr[] = "FM_LOW";
char INPUT_ONLY_descr[] = "IN_ONLY";
char NO_PWM_descr[] = "NO_PWM";
char HIGH_BOOT_descr[] = "B_HIGH";
const char * GPIO_Index_note[] = {
NULL, // 0 - no note
BOOTFAILS_LOW_descr, // 1
BOOTFAILS_HIGH_descr, // 2
FLASMODE_LOW_descr, // 3
INPUT_ONLY_descr, // 4
NO_PWM_descr, // 5
HIGH_BOOT_descr, // 6
};
const byte OUTPUT_TYPE_GPIO = 1;
const byte OUTPUT_TYPE_I2C = 2;
const byte OUTPUT_TYPE_WEB = 3;

View file

@ -369,37 +369,30 @@ String Proc_WebPage_system_output_add(const String& var) {
} else if(var == "GPIO_INDEX") {
String gpioIndex_html;
// iterate through through all available GPIOs in index
for(byte i = 0; i < GPIOindex_length; i++) {
gpioIndex_html += "<option value='";
gpioIndex_html += i;
gpioIndex_html += "'";
// set disabled option of gpio is already in use
if(Check_GPIOindex_Used(i) == true) {
// set disabled option for gpio which are already in use or incompatible
if((Check_GPIOindex_Used(i) == true) || (GPIOindex[i].note == INPUT_ONLY)) {
gpioIndex_html += " disabled";
}
gpioIndex_html += ">GPIO ";
gpioIndex_html += GPIOindex[i].gpio;
//add gpio note if there is some
if(GPIOindex[i].note > 0) {
switch(GPIOindex[i].note) {
case BOOTFAILS_LOW: gpioIndex_html += " BFL"; break;
case BOOTFAILS_HIGH: gpioIndex_html += " BFH"; break;
case FLASHMODE_LOW: gpioIndex_html += " FML"; break;
case INPUT_ONLY: gpioIndex_html += " INO"; break;
case NO_PWM: gpioIndex_html += " NPWM"; break;
case HIGH_BOOT: gpioIndex_html += " HB"; break;
default: break;
}
}
// add USED if gpio is already in use
if(Check_GPIOindex_Used(i) == true) {
gpioIndex_html += " USED";
//if(GPIOindex[i].note > 0) {
gpioIndex_html += " ";
gpioIndex_html += GPIO_Index_note[GPIOindex[i].note];
// disable output incompatible gpio
if(GPIOindex[i].note == INPUT_ONLY) {
gpioIndex_html += " (N/A)";
// add USED if gpio is already in use
} else if(Check_GPIOindex_Used(i) == true) {
gpioIndex_html += " (used)";
}
gpioIndex_html += "</option>";
}
return gpioIndex_html;
} else {