Do not reset pins if error but show error (wip, bh1750, fld, global)

Usermod bh1750: only save pins if not equal to global
Usermod fld: add errorMessage, do not reset type and enabled but errormessage instead, show global depending in spi or i2c
cfg.cpp and set.cpp: do not reset global i2c or spi if error
This commit is contained in:
Ewoud
2023-01-07 16:49:10 +01:00
parent ab22beb0c3
commit b8437c51c5
7 changed files with 279 additions and 267 deletions

View File

@@ -549,8 +549,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
DEBUG_PRINTLN(F("Could not allocate I2C pins."));
uint8_t i2c[2] = { static_cast<uint8_t>(i2c_scl), static_cast<uint8_t>(i2c_sda) };
pinManager.deallocateMultiplePins(i2c, 2, PinOwner::HW_I2C); // just in case deallocation of old pins
i2c_sda = -1;
i2c_scl = -1;
Serial.printf("pinmgr not success i2c %d %d\n", i2c_sda, i2c_scl);
}
#ifdef ESP8266
@@ -576,9 +575,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
DEBUG_PRINTLN(F("Could not allocate SPI pins."));
uint8_t spi[3] = { static_cast<uint8_t>(spi_mosi), static_cast<uint8_t>(spi_miso), static_cast<uint8_t>(spi_sclk) };
pinManager.deallocateMultiplePins(spi, 3, PinOwner::HW_SPI); // just in case deallocation of old pins
spi_mosi = -1;
spi_miso = -1;
spi_sclk = -1;
Serial.printf("pinmgr not success spi %d %d %d\n", spi_mosi, spi_miso, spi_sclk);
}
JsonObject um = doc.createNestedObject("um");