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 * 5 - NO_PWM: No PWM output
* 6 - PWM_BOOT: PWM at boot time * 6 - PWM_BOOT: PWM at boot time
*/ */
const byte GPIO_Index_len = 6;
const byte BOOTFAILS_LOW = 1; const byte BOOTFAILS_LOW = 1;
const byte BOOTFAILS_HIGH = 2; const byte BOOTFAILS_HIGH = 2;
const byte FLASHMODE_LOW = 3; const byte FLASHMODE_LOW = 3;
@ -70,6 +72,25 @@ const byte INPUT_ONLY = 4;
const byte NO_PWM = 5; const byte NO_PWM = 5;
const byte HIGH_BOOT = 6; 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_GPIO = 1;
const byte OUTPUT_TYPE_I2C = 2; const byte OUTPUT_TYPE_I2C = 2;
const byte OUTPUT_TYPE_WEB = 3; 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") { } else if(var == "GPIO_INDEX") {
String gpioIndex_html; String gpioIndex_html;
// iterate through through all available GPIOs in index
for(byte i = 0; i < GPIOindex_length; i++) { for(byte i = 0; i < GPIOindex_length; i++) {
gpioIndex_html += "<option value='"; gpioIndex_html += "<option value='";
gpioIndex_html += i; gpioIndex_html += i;
gpioIndex_html += "'"; gpioIndex_html += "'";
// set disabled option of gpio is already in use // set disabled option for gpio which are already in use or incompatible
if(Check_GPIOindex_Used(i) == true) { if((Check_GPIOindex_Used(i) == true) || (GPIOindex[i].note == INPUT_ONLY)) {
gpioIndex_html += " disabled"; gpioIndex_html += " disabled";
} }
gpioIndex_html += ">GPIO "; gpioIndex_html += ">GPIO ";
gpioIndex_html += GPIOindex[i].gpio; gpioIndex_html += GPIOindex[i].gpio;
//add gpio note if there is some //add gpio note if there is some
if(GPIOindex[i].note > 0) { //if(GPIOindex[i].note > 0) {
switch(GPIOindex[i].note) { gpioIndex_html += " ";
case BOOTFAILS_LOW: gpioIndex_html += " BFL"; break; gpioIndex_html += GPIO_Index_note[GPIOindex[i].note];
case BOOTFAILS_HIGH: gpioIndex_html += " BFH"; break;
case FLASHMODE_LOW: gpioIndex_html += " FML"; break; // disable output incompatible gpio
case INPUT_ONLY: gpioIndex_html += " INO"; break; if(GPIOindex[i].note == INPUT_ONLY) {
case NO_PWM: gpioIndex_html += " NPWM"; break; gpioIndex_html += " (N/A)";
case HIGH_BOOT: gpioIndex_html += " HB"; break; // add USED if gpio is already in use
default: break; } else if(Check_GPIOindex_Used(i) == true) {
} gpioIndex_html += " (used)";
}
// add USED if gpio is already in use
if(Check_GPIOindex_Used(i) == true) {
gpioIndex_html += " USED";
} }
gpioIndex_html += "</option>"; gpioIndex_html += "</option>";
} }
return gpioIndex_html; return gpioIndex_html;
} else { } else {