Refactor global pins settings using dropdowns and add to rotary_encoder

- replace rOption by  xOption (extend option) to show default value (⎌)
- Usermod rotary_encoder: add appendConfigData function and show help and default functions
- Settings.htm: Move Usermods(pins) below the usermods

Settings_um.htm
- remove SDAPin etc
- comment check(0,k) as not used anymore
- add xOption
- add generated global pin fields (using addField) in ldS
- remove hard coded global pin fields

set.cpp: set i2c_sda etc using new generated fields
xml.cpp: set generated fields values using i2c_sda etc and show defaults
This commit is contained in:
Ewoud
2023-01-04 12:17:14 +01:00
parent 0571aa92f2
commit 23663a46f9
9 changed files with 379 additions and 394 deletions

View File

@@ -508,8 +508,29 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
if (!requestJSONBufferLock(5)) return;
// global I2C & SPI pins
int8_t hw_sda_pin = !request->arg(F("SDApin")).length() ? -1 : (int)request->arg(F("SDApin")).toInt();
int8_t hw_scl_pin = !request->arg(F("SCLpin")).length() ? -1 : (int)request->arg(F("SCLpin")).toInt();
int8_t hw_sda_pin = -1;//!request->arg(F("SDApin")).length() ? -1 : (int)request->arg(F("SDApin")).toInt();
int8_t hw_scl_pin = -1;//!request->arg(F("SCLpin")).length() ? -1 : (int)request->arg(F("SCLpin")).toInt();
int8_t hw_mosi_pin = -1;//!request->arg(F("MOSIpin")).length() ? -1 : (int)request->arg(F("MOSIpin")).toInt();
int8_t hw_miso_pin = -1;//!request->arg(F("MISOpin")).length() ? -1 : (int)request->arg(F("MISOpin")).toInt();
int8_t hw_sclk_pin = -1;//!request->arg(F("SCLKpin")).length() ? -1 : (int)request->arg(F("SCLKpin")).toInt();
//WLEDMM: :pin values have 2 occurrences: the type and the value, we need the value
int paramsNr = request->params();
AsyncWebParameter* p_prev = nullptr;
for (int i=0;i<paramsNr;i++) {
AsyncWebParameter* p = request->getParam(i);
if (p_prev != nullptr && p->name() == p_prev->name())
{
if (p->name() == "SDA2:pin") hw_sda_pin = p->value().toInt();
if (p->name() == "SCL2:pin") hw_scl_pin = p->value().toInt();
if (p->name() == "MOSI2:pin") hw_mosi_pin = p->value().toInt();
if (p->name() == "MISO2:pin") hw_miso_pin = p->value().toInt();
if (p->name() == "SCLK2:pin") hw_sclk_pin = p->value().toInt();
}
p_prev = p;
}
#ifdef ESP8266
// cannot change pins on ESP8266
if (hw_sda_pin >= 0 && hw_sda_pin != HW_PIN_SDA) hw_sda_pin = HW_PIN_SDA;
@@ -531,9 +552,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
i2c_sda = -1;
i2c_scl = -1;
}
int8_t hw_mosi_pin = !request->arg(F("MOSIpin")).length() ? -1 : (int)request->arg(F("MOSIpin")).toInt();
int8_t hw_miso_pin = !request->arg(F("MISOpin")).length() ? -1 : (int)request->arg(F("MISOpin")).toInt();
int8_t hw_sclk_pin = !request->arg(F("SCLKpin")).length() ? -1 : (int)request->arg(F("SCLKpin")).toInt();
#ifdef ESP8266
// cannot change pins on ESP8266
if (hw_mosi_pin >= 0 && hw_mosi_pin != HW_PIN_DATASPI) hw_mosi_pin = HW_PIN_DATASPI;