Skip to content

Commit

Permalink
Merge pull request #26 from vi7/fix_rh_handler
Browse files Browse the repository at this point in the history
Fix temp and RH handlers
  • Loading branch information
vi7 authored Nov 27, 2021
2 parents 4d2ee12 + 06173f3 commit 81c38e0
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion include/grower_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#ifndef GROWER_VERSION_H
#define GROWER_VERSION_H

const char GROWER_VERSION[] = "0.8.0";
const char GROWER_VERSION[] = "0.8.2";
// Example version with appended build version (autoincrementing part):
// const char VERSION[] = "0.4.0-230498"

Expand Down
4 changes: 2 additions & 2 deletions src/DHTDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void DHTDevice::tempDataHandler(Device* device, uint8_t MAX_TEMP, uint8_t TEMP_H
Serial.printf((char*)F("DHT: Failed to read temperature! Device status: %s\n"), dht.getStatusString());
return;
}
PowerManager::autoPower(&device->isAutoPowerOn, &device->isPowerOn, &temp, MAX_TEMP, TEMP_HYSTERESIS, this->_pin);
PowerManager::autoPower(&device->isAutoPowerOn, &device->isPowerOn, &temp, MAX_TEMP, TEMP_HYSTERESIS, &device->_pin);
}

void DHTDevice::rhDataHandler(Device* device, uint8_t MAX_RH, uint8_t RH_HYSTERESIS) {
Expand All @@ -31,7 +31,7 @@ void DHTDevice::rhDataHandler(Device* device, uint8_t MAX_RH, uint8_t RH_HYSTERE
Serial.printf((char*)F("DHT: Failed to read humidity! Device status: %s\n"), dht.getStatusString());
return;
}
PowerManager::autoPower(&device->isAutoPowerOn, &device->isPowerOn, &rH, MAX_RH, RH_HYSTERESIS, this->_pin);
PowerManager::autoPower(&device->isAutoPowerOn, &device->isPowerOn, &rH, MAX_RH, RH_HYSTERESIS, &device->_pin);
}

String DHTDevice::status() {
Expand Down
4 changes: 2 additions & 2 deletions src/HTU2xDDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void HTU2xDDevice::tempDataHandler(Device* device, uint8_t MAX_TEMP, uint8_t TEM
htu2xD->setResolution(HUMD_12BIT_TEMP_14BIT); //humidity 12-bit, temperature 14-bit
return;
}
PowerManager::autoPower(&device->isAutoPowerOn, &device->isPowerOn, &temp, MAX_TEMP, TEMP_HYSTERESIS, this->_pin);
PowerManager::autoPower(&device->isAutoPowerOn, &device->isPowerOn, &temp, MAX_TEMP, TEMP_HYSTERESIS, &device->_pin);
// TODO: add delay(500) as in the HTU2xD_SHT2x_Si70xx lib example?
}

Expand All @@ -29,7 +29,7 @@ void HTU2xDDevice::rhDataHandler(Device* device, uint8_t MAX_RH, uint8_t RH_HYST
Serial.printf((char*)F("%s: Failed to read humidity! CRC8 or communication error occurred\n"), HTU2XD_NAME);
return;
}
PowerManager::autoPower(&device->isAutoPowerOn, &device->isPowerOn, &rH, MAX_RH, RH_HYSTERESIS, this->_pin);
PowerManager::autoPower(&device->isAutoPowerOn, &device->isPowerOn, &rH, MAX_RH, RH_HYSTERESIS, &device->_pin);
}

String HTU2xDDevice::status() {
Expand Down
8 changes: 4 additions & 4 deletions src/PowerManager.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/**
* PowerManager.cpp
*/
*/


#include "PowerManager.h"

void PowerManager::autoPower(bool *autoControl, bool *currentState, float *currVal, float maxVal, float valHyst, uint8_t pin) {
void PowerManager::autoPower(bool *autoControl, bool *currentState, float *currVal, float maxVal, float valHyst, uint8_t *pin) {
if (!*autoControl) return;
if (*currVal >= maxVal && *currentState) {
*currentState = manualPowerOff(pin);
*currentState = manualPowerOff(*pin);
}
else if (*currVal < maxVal - valHyst && !*currentState) {
*currentState = manualPowerOn(pin);
*currentState = manualPowerOn(*pin);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/PowerManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class PowerManager {
public:
static void autoPower(bool *autoControl, bool *isOn, float *currVal, float maxVal, float valHyst, uint8_t pin);
static void autoPower(bool *autoControl, bool *isOn, float *currVal, float maxVal, float valHyst, uint8_t *pin);
static bool manualPowerOn(uint8_t pin);
static bool manualPowerOff(uint8_t pin);

Expand Down
6 changes: 3 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ const uint8_t TEMP_HYSTERESIS = 10;
// Recommended RH values:
// - vegetative - 60%
// - flowering - 50%
const uint8_t MAX_RH = 60;
const uint8_t RH_HYSTERESIS = 10;
const uint8_t MAX_RH = 50;
const uint8_t RH_HYSTERESIS = 15;
// lamp check interval in seconds
const uint8_t LIGHT_CHECK_INTERVAL = 1;
const uint8_t LIGHT_CHECK_INTERVAL = 10;

SimpleTimer timer;
WebServer server(80);
Expand Down
36 changes: 18 additions & 18 deletions src/schedules.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ const schedule LAMP_ON_SCHEDULE = {
0, // sec
0, // min
22, // hour
8, // day
3, // month
2020, // year
27, // day
11, // month
2021, // year
1, // interval in days
};

const schedule LAMP_OFF_SCHEDULE = {
0, // sec
0, // min
18, // hour
8, // day
3, // month
2020, // year
27, // day
11, // month
2021, // year
1, // interval in days
};

Expand All @@ -35,19 +35,19 @@ const schedule FAN_ON_SCHEDULE = {
0, // sec
1, // min
22, // hour
8, // day
3, // month
2020, // year
27, // day
11, // month
2021, // year
1, // interval in days
};

const schedule FAN_OFF_SCHEDULE = {
0, // sec
1, // min
18, // hour
8, // day
3, // month
2020, // year
27, // day
11, // month
2021, // year
1, // interval in days
};

Expand All @@ -56,19 +56,19 @@ const schedule HUM_ON_SCHEDULE = {
0, // sec
2, // min
22, // hour
8, // day
3, // month
2020, // year
27, // day
11, // month
2021, // year
1, // interval in days
};

const schedule HUM_OFF_SCHEDULE = {
0, // sec
2, // min
18, // hour
8, // day
3, // month
2020, // year
27, // day
11, // month
2021, // year
1, // interval in days
};

Expand Down

0 comments on commit 81c38e0

Please sign in to comment.