mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-07-29 01:52:51 +00:00
calc_dew to helpers
This commit is contained in:
@@ -1033,4 +1033,17 @@ float Helpers::numericoperator2scalefactor(int8_t numeric_operator) {
|
|||||||
return -numeric_operator;
|
return -numeric_operator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int16_t Helpers::calc_dew(int16_t temp, uint8_t humi) {
|
||||||
|
if (humi == EMS_VALUE_UINT8_NOTSET || temp == EMS_VALUE_INT16_NOTSET) {
|
||||||
|
return EMS_VALUE_INT16_NOTSET;
|
||||||
|
}
|
||||||
|
const float k2 = 17.62;
|
||||||
|
const float k3 = 243.12;
|
||||||
|
const float t = (float)temp / 10;
|
||||||
|
const float h = (float)humi / 100;
|
||||||
|
int16_t dt = (10 * k3 * (((k2 * t) / (k3 + t)) + log(h)) / (((k2 * k3) / (k3 + t)) - log(h)));
|
||||||
|
return dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace emsesp
|
} // namespace emsesp
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ class Helpers {
|
|||||||
static uint8_t count_items(const char * const * list);
|
static uint8_t count_items(const char * const * list);
|
||||||
|
|
||||||
static const char * translated_word(const char * const * strings, const bool force_en = false);
|
static const char * translated_word(const char * const * strings, const bool force_en = false);
|
||||||
|
static int16_t calc_dew(int16_t temp, uint8_t hum);
|
||||||
|
|
||||||
#ifdef EMSESP_STANDALONE
|
#ifdef EMSESP_STANDALONE
|
||||||
static char * ultostr(char * ptr, uint32_t value, const uint8_t base);
|
static char * ultostr(char * ptr, uint32_t value, const uint8_t base);
|
||||||
|
|||||||
@@ -377,7 +377,7 @@ void Roomctrl::temperature(uint8_t addr, uint8_t dst, uint8_t hc) {
|
|||||||
|
|
||||||
// send telegram 0x047B only for RC100H
|
// send telegram 0x047B only for RC100H
|
||||||
void Roomctrl::humidity(uint8_t addr, uint8_t dst, uint8_t hc) {
|
void Roomctrl::humidity(uint8_t addr, uint8_t dst, uint8_t hc) {
|
||||||
int16_t dew = calc_dew(remotetemp_[hc], remotehum_[hc]);
|
int16_t dew = Helpers::calc_dew(remotetemp_[hc], remotehum_[hc]);
|
||||||
int8_t dew8 = EMS_VALUE_INT8_NOTSET;
|
int8_t dew8 = EMS_VALUE_INT8_NOTSET;
|
||||||
if (dew != EMS_VALUE_INT16_NOTSET) {
|
if (dew != EMS_VALUE_INT16_NOTSET) {
|
||||||
dew8 = static_cast<int8_t>((dew >= 0 ? dew + 5 : dew - 5) / 10);
|
dew8 = static_cast<int8_t>((dew >= 0 ? dew + 5 : dew - 5) / 10);
|
||||||
@@ -391,8 +391,8 @@ void Roomctrl::humidity(uint8_t addr, uint8_t dst, uint8_t hc) {
|
|||||||
data[5] = 0x7B + hc;
|
data[5] = 0x7B + hc;
|
||||||
data[6] = static_cast<uint8_t>(dew8);
|
data[6] = static_cast<uint8_t>(dew8);
|
||||||
data[7] = remotehum_[hc];
|
data[7] = remotehum_[hc];
|
||||||
data[8] = static_cast<uint8_t>(static_cast<uint16_t>(dew) >> 8);
|
data[8] = static_cast<uint8_t>(dew >> 8);
|
||||||
data[9] = static_cast<uint8_t>(static_cast<uint16_t>(dew) & 0xFF);
|
data[9] = static_cast<uint8_t>(dew & 0x00FF);
|
||||||
data[10] = EMSbus::calculate_crc(data, 10); // append CRC
|
data[10] = EMSbus::calculate_crc(data, 10); // append CRC
|
||||||
EMSuart::transmit(data, 11);
|
EMSuart::transmit(data, 11);
|
||||||
}
|
}
|
||||||
@@ -440,17 +440,4 @@ void Roomctrl::replyF7(uint8_t addr, uint8_t dst, uint8_t offset, uint8_t typehh
|
|||||||
EMSuart::transmit(data, 10);
|
EMSuart::transmit(data, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t Roomctrl::calc_dew(int16_t temp, uint8_t humi) {
|
|
||||||
if (humi == EMS_VALUE_UINT8_NOTSET || temp == EMS_VALUE_INT16_NOTSET) {
|
|
||||||
return EMS_VALUE_INT16_NOTSET;
|
|
||||||
}
|
|
||||||
const float k2 = 17.62;
|
|
||||||
const float k3 = 243.12;
|
|
||||||
const float t = (float)temp / 10;
|
|
||||||
const float h = (float)humi / 100;
|
|
||||||
int16_t dt = (10 * k3 * (((k2 * t) / (k3 + t)) + log(h)) / (((k2 * k3) / (k3 + t)) - log(h)));
|
|
||||||
return dt;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace emsesp
|
} // namespace emsesp
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ class Roomctrl {
|
|||||||
return (hc < 4 && remotetemp_[hc] != EMS_VALUE_INT16_NOTSET);
|
return (hc < 4 && remotetemp_[hc] != EMS_VALUE_INT16_NOTSET);
|
||||||
}
|
}
|
||||||
static void set_timeout(uint8_t t);
|
static void set_timeout(uint8_t t);
|
||||||
static int16_t calc_dew(int16_t temp, uint8_t hum);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr uint32_t SEND_INTERVAL = 15000; // 15 sec
|
static constexpr uint32_t SEND_INTERVAL = 15000; // 15 sec
|
||||||
|
|||||||
@@ -818,7 +818,8 @@ void Thermostat::process_RemoteHumidity(std::shared_ptr<const Telegram> telegram
|
|||||||
if (telegram->read_value(dew, 2)) {
|
if (telegram->read_value(dew, 2)) {
|
||||||
has_update(dewtemperature_, dew);
|
has_update(dewtemperature_, dew);
|
||||||
} else if (telegram->offset == 0 && telegram->message_length < 4) {
|
} else if (telegram->offset == 0 && telegram->message_length < 4) {
|
||||||
has_update(dewtemperature_, Roomctrl::calc_dew(tempsensor1_, humidity_));
|
dew = Helpers::calc_dew(tempsensor1_, humidity_);
|
||||||
|
has_update(dewtemperature_, dew);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user