Add dropdowns for pins (part 1 of 2)

Set for Audioreactive and 4linedisplay usermods

Prepare for globals (part2):
Rename SDA to SDApin etc
This commit is contained in:
Ewoud
2022-12-23 17:21:35 +01:00
parent e6bd66d35d
commit 5c161db062
6 changed files with 298 additions and 234 deletions

View File

@@ -508,8 +508,8 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
if (!requestJSONBufferLock(5)) return;
// global I2C & SPI pins
int8_t hw_sda_pin = !request->arg(F("SDA")).length() ? -1 : (int)request->arg(F("SDA")).toInt();
int8_t hw_scl_pin = !request->arg(F("SCL")).length() ? -1 : (int)request->arg(F("SCL")).toInt();
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();
#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 +531,9 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
i2c_sda = -1;
i2c_scl = -1;
}
int8_t hw_mosi_pin = !request->arg(F("MOSI")).length() ? -1 : (int)request->arg(F("MOSI")).toInt();
int8_t hw_miso_pin = !request->arg(F("MISO")).length() ? -1 : (int)request->arg(F("MISO")).toInt();
int8_t hw_sclk_pin = !request->arg(F("SCLK")).length() ? -1 : (int)request->arg(F("SCLK")).toInt();
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;