[PMSx003] Add proper defaults when creating new task or loading old conf

Added PWR pin, so settings need to be patched to set PWR SET pin to  -1 as default.
This commit is contained in:
TD-er
2021-10-15 16:40:23 +02:00
parent 72d0b4426a
commit 3312b7d61e
3 changed files with 28 additions and 1 deletions
+14
View File
@@ -145,6 +145,20 @@ boolean Plugin_053(uint8_t function, struct EventStruct *event, String& string)
break;
}
case PLUGIN_SET_DEFAULTS:
{
PLUGIN_053_RST_PIN = -1;
PLUGIN_053_PWR_PIN = -1;
PLUGIN_053_SENSOR_MODEL_SELECTOR = static_cast<int>(PMSx003_type::PMS1003_5003_7003);
PLUGIN_053_SEC_IGNORE_AFTER_WAKE = 0;
bitSet(PLUGIN_053_DATA_PROCESSING_FLAGS, PLUGIN_053_OVERSAMPLING_BIT);
success = true;
break;
}
case PLUGIN_WEBFORM_LOAD: {
addFormPinSelect(PinSelectPurpose::Generic_output, formatGpioName_output_optional(F("RST")), F("rstpin"), PLUGIN_053_RST_PIN);
addFormPinSelect(PinSelectPurpose::Generic_output, formatGpioName_output_optional(F("SET")), F("pwrpin"), PLUGIN_053_PWR_PIN);
+1 -1
View File
@@ -20,7 +20,7 @@
#endif // if defined(ESP32)
#define BUILD 20115 // git version e.g. "20103" can be read as "2.1.03" (stored in int16_t)
#define BUILD 20116 // git version e.g. "20103" can be read as "2.1.03" (stored in int16_t)
#ifndef BUILD_NOTES
#if defined(ESP8266)
# define BUILD_NOTES " - Mega"
+13
View File
@@ -282,12 +282,14 @@ String BuildFixes()
Settings.NumberExtraWiFiScans = 0;
}
if (Settings.Build < 20114) {
#ifdef USES_P003
// P003_Pulse was always using the pull-up, now it is a setting.
for (taskIndex_t taskIndex = 0; taskIndex < TASKS_MAX; ++taskIndex) {
if (Settings.TaskDeviceNumber[taskIndex] == 3) {
Settings.TaskDevicePin1PullUp[taskIndex] = true;
}
}
#endif
// Disable periodical scanning as it does cause lots of strange issues.
Settings.PeriodicalScanWiFi(false);
}
@@ -298,6 +300,17 @@ String BuildFixes()
Settings.SPI_MOSI_pin = -1;
}
}
#ifdef USES_P053
if (Settings.Build < 20116) {
// Added PWR button, init to "-none-"
for (taskIndex_t taskIndex = 0; taskIndex < TASKS_MAX; ++taskIndex) {
if (Settings.TaskDeviceNumber[taskIndex] == 53) {
Settings.TaskDevicePluginConfig[taskIndex][3] = -1;
}
}
}
#endif
Settings.Build = BUILD;
return SaveSettings();