From 0a473173f8365380286d9ceb83aaf51e602cb005 Mon Sep 17 00:00:00 2001 From: Empire Date: Tue, 20 Oct 2020 22:52:03 +0200 Subject: [PATCH] reduced settings --- esp32/include/HomieConfiguration.h | 3 +-- esp32/include/HomieTypes.h | 1 - esp32/include/PlantCtrl.h | 2 +- esp32/platformio.ini | 1 + esp32/src/PlantCtrl.cpp | 4 ---- esp32/src/main.cpp | 2 -- 6 files changed, 3 insertions(+), 10 deletions(-) diff --git a/esp32/include/HomieConfiguration.h b/esp32/include/HomieConfiguration.h index c0d42b4..510dd47 100644 --- a/esp32/include/HomieConfiguration.h +++ b/esp32/include/HomieConfiguration.h @@ -51,12 +51,11 @@ HomieSetting waterLevelVol("waterVolume", "(ml) between minimum and maximu #define GENERATE_PLANT(plant, strplant) \ HomieSetting mSensorDry##plant = HomieSetting("moistdry" strplant, "Plant " strplant "- Moist sensor dry threshold"); \ - HomieSetting mSensorWet##plant = HomieSetting("moistwet" strplant, "Plant" strplant " - Moist sensor wet threshold"); \ HomieSetting mPumpAllowedHourRangeStart##plant = HomieSetting("rangehourstart" strplant, "Plant" strplant " - Range pump allowed hour start (0-23)"); \ HomieSetting mPumpAllowedHourRangeEnd##plant = HomieSetting("rangehourend" strplant, "Plant" strplant " - Range pump allowed hour end (0-23)"); \ HomieSetting mPumpOnlyWhenLowLight##plant = HomieSetting("onlyWhenLowLightZ" strplant, "Plant" strplant " - Enable the Pump only, when there is light but not enought to charge battery"); \ HomieSetting mPumpCooldownInHours##plant = HomieSetting("cooldownpump" strplant, "Plant" strplant " - How long to wait until the pump is activated again (minutes)"); \ - PlantSettings_t mSetting##plant = { &mSensorDry##plant, &mSensorWet##plant, &mPumpAllowedHourRangeStart##plant, &mPumpAllowedHourRangeEnd##plant, &mPumpOnlyWhenLowLight##plant, &mPumpCooldownInHours##plant }; + PlantSettings_t mSetting##plant = { &mSensorDry##plant, &mPumpAllowedHourRangeStart##plant, &mPumpAllowedHourRangeEnd##plant, &mPumpOnlyWhenLowLight##plant, &mPumpCooldownInHours##plant }; GENERATE_PLANT(0, "0"); GENERATE_PLANT(1, "1"); diff --git a/esp32/include/HomieTypes.h b/esp32/include/HomieTypes.h index 56c2e77..28c9d59 100644 --- a/esp32/include/HomieTypes.h +++ b/esp32/include/HomieTypes.h @@ -17,7 +17,6 @@ typedef struct PlantSettings_t { HomieSetting* pSensorDry; - HomieSetting* pSensorWet; HomieSetting* pPumpAllowedHourRangeStart; HomieSetting* pPumpAllowedHourRangeEnd; HomieSetting* pPumpOnlyWhenLowLight; diff --git a/esp32/include/PlantCtrl.h b/esp32/include/PlantCtrl.h index 6b61642..41f735a 100644 --- a/esp32/include/PlantCtrl.h +++ b/esp32/include/PlantCtrl.h @@ -76,7 +76,7 @@ public: * @return false */ bool isPumpRequired() { - return (this->mSetting->pSensorWet != NULL) && (this->mValue < this->mSetting->pSensorWet->get()); + return (this->mSetting->pSensorDry != NULL) && (this->mValue < this->mSetting->pSensorDry->get()); } HomieInternals::SendingPromise& setProperty(const String& property) const { diff --git a/esp32/platformio.ini b/esp32/platformio.ini index 1acddd6..64488d0 100644 --- a/esp32/platformio.ini +++ b/esp32/platformio.ini @@ -13,6 +13,7 @@ platform = espressif32 board = esp32doit-devkit-v1 framework = arduino build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY +board_build.partitions = default3.csv ; the latest development brankitchen-lightch (convention V3.0.x) lib_deps = ArduinoJson@6.16.1 diff --git a/esp32/src/PlantCtrl.cpp b/esp32/src/PlantCtrl.cpp index b3eabdd..7290ae8 100644 --- a/esp32/src/PlantCtrl.cpp +++ b/esp32/src/PlantCtrl.cpp @@ -24,10 +24,6 @@ void Plant::init(void) { this->mSetting->pSensorDry->setValidator([] (long candidate) { return (((candidate >= 0) && (candidate <= 4095) ) || candidate == DEACTIVATED_PLANT); }); - this->mSetting->pSensorWet->setDefaultValue(0); - this->mSetting->pSensorWet->setValidator([] (long candidate) { - return ((candidate >= 0) && (candidate <= 4095) ); - }); this->mSetting->pPumpAllowedHourRangeStart->setDefaultValue(8); // start at 8:00 this->mSetting->pPumpAllowedHourRangeStart->setValidator([] (long candidate) { return ((candidate >= 0) && (candidate <= 23) ); diff --git a/esp32/src/main.cpp b/esp32/src/main.cpp index 979ee4c..0c8d54d 100644 --- a/esp32/src/main.cpp +++ b/esp32/src/main.cpp @@ -415,7 +415,6 @@ bool switchGeneralPumpHandler(const int pump, const HomieRange& range, const Str */ bool aliveHandler(const HomieRange& range, const String& value) { if (range.isRange) return false; // only one controller is present - if (value.equals("ON") || value.equals("On") || value.equals("1")) { mode3Active=true; } else { @@ -605,7 +604,6 @@ bool mode1(){ void mode2(){ Serial.println("m2"); - systemInit(); /* Jump into Mode 3, if not configured */