Controller is runing again

This commit is contained in:
c3ma
2020-10-16 16:22:48 +02:00
parent a654b662e6
commit ce498bc7f8
5 changed files with 53 additions and 76 deletions

View File

@@ -55,6 +55,6 @@
#define SENSOR_SR04_ECHO 17 /**< GPIO 17 - Echo */
#define SENSOR_SR04_TRIG 23 /**< GPIO 23 - Trigger */
#define MAX_CONFIG_SETTING_ITEMS 30 /**< Parameter, that can be configured in Homie */
#define MAX_CONFIG_SETTING_ITEMS 50 /**< Parameter, that can be configured in Homie */
#endif

View File

@@ -11,7 +11,9 @@
#ifndef HOMIE_PLANT_CONFIG_H
#define HOMIE_PLANT_CONFIG_H
#include <Homie.h>
#include "HomieTypes.h"
#define MAX_PLANTS 7
/**
*********************************** Attributes *******************************
@@ -53,9 +55,17 @@ HomieSetting<long> waterLevelVol("waterVolume", "ml between minimum and maximum"
HomieSetting<long> mPumpAllowedHourRangeStart##plant = HomieSetting<long>("rangehourstart##plant", "Range pump allowed hour start"); \
HomieSetting<long> mPumpAllowedHourRangeEnd##plant = HomieSetting<long>("rangehourend##plant", "Range pump allowed hour end"); \
HomieSetting<bool> mPumpOnlyWhenLowLight##plant = HomieSetting<bool>("onlyWhenLowLightZ##plant", "Enable the Pump only, when there is light but not enought to charge battery"); \
HomieSetting<long> mPumpCooldownInHours##plant = HomieSetting<long>("cooldownpump##plant", "How long to wait until the pump is activated again");
HomieSetting<long> mPumpCooldownInHours##plant = HomieSetting<long>("cooldownpump##plant", "How long to wait until the pump is activated again"); \
PlantSettings_t mSetting##plant = { &mSensorDry##plant, &mSensorWet##plant, &mPumpAllowedHourRangeStart##plant, &mPumpAllowedHourRangeEnd##plant, &mPumpOnlyWhenLowLight##plant, &mPumpCooldownInHours##plant };
GENERATE_PLANT(0);
GENERATE_PLANT(1);
GENERATE_PLANT(2);
GENERATE_PLANT(3);
GENERATE_PLANT(4);
GENERATE_PLANT(5);
GENERATE_PLANT(6);
#endif /* HOMIE_PLANT_CONFIG_H */

View File

@@ -12,8 +12,7 @@
#ifndef PLANT_CTRL_H
#define PLANT_CTRL_H
#include <HomieSetting.hpp>
#include <SendingPromise.hpp>
#include "HomieTypes.h"
class Plant {
@@ -25,12 +24,7 @@ private:
int mAnalogValue=0; /**< moist sensor values, used for a calculation */
HomieNode *mPlant = NULL;
HomieSetting<long> *mSensorDry;
HomieSetting<long> *mSensorWet;
HomieSetting<long> *mPumpAllowedHourRangeStart;
HomieSetting<long> *mPumpAllowedHourRangeEnd;
HomieSetting<bool> *mPumpOnlyWhenLowLight;
HomieSetting<long> *mPumpCooldownInHours;
PlantSettings_t mSetting;
public:
@@ -41,7 +35,9 @@ public:
* @param pinPump Pin of the Pump to use
*/
Plant(int pinSensor, int pinPump,
int plantId);
int plantId,
HomieNode* plant,
PlantSettings_t* setting);
/**
* @brief Add a value, to be measured
@@ -81,7 +77,7 @@ public:
* @return false
*/
bool isPumpRequired() {
return (this->mSensorWet != NULL) && (this->mValue < this->mSensorWet->get());
return (this->mSetting.pSensorWet != NULL) && (this->mValue < this->mSetting.pSensorWet->get());
}
HomieInternals::SendingPromise& setProperty(const String& property) const {