3 Commits

Author SHA1 Message Date
Yurii
497dcdd854 Merge ee868b22ce into 8fa440810c 2025-03-05 02:29:04 +03:00
Yurii
8fa440810c refactor: status BLE sensors 2025-03-05 02:28:17 +03:00
Yurii
ee868b22ce chore: remove unused files 2025-03-04 21:31:44 +03:00
2 changed files with 6 additions and 68 deletions

View File

@@ -1,60 +0,0 @@
#include <Arduino.h>
#if defined(EQUITHERM_INTEGER)
// расчёты с целыми числами
typedef int datatype;
#else
// расчёты с float числами
typedef float datatype;
#endif
class Equitherm {
public:
datatype targetTemp = 0;
datatype indoorTemp = 0;
datatype outdoorTemp = 0;
float Kn = 0.0;
float Kk = 0.0;
float Kt = 0.0;
float Ke = 1.3;
Equitherm() = default;
// kn, kk, kt, Ke
Equitherm(float new_kn, float new_kk, float new_kt, float new_ke) {
Kn = new_kn;
Kk = new_kk;
Kt = new_kt;
Ke = new_ke;
}
// лимит выходной величины
void setLimits(unsigned short min_output, unsigned short max_output) {
_minOut = min_output;
_maxOut = max_output;
}
// возвращает новое значение при вызове
datatype getResult() {
datatype output = getResultN() + Kk + getResultT();
output = constrain(output, _minOut, _maxOut); // ограничиваем выход
return output;
}
private:
unsigned short _minOut = 20, _maxOut = 90;
datatype getResultN()
{
float tempDelta = targetTemp - outdoorTemp,
maxPoint = targetTemp - (_maxOut - targetTemp) / Kn,
sf = (_maxOut - targetTemp) / pow(targetTemp - maxPoint, 1.0 / Ke),
T_rad = targetTemp + sf * (tempDelta >= 0 ? pow(tempDelta, 1.0 / Ke) : -pow(-tempDelta, 1.0 / Ke));
return T_rad > _maxOut ? _maxOut : T_rad;
}
// Реакция на разницу с целевой температурой
datatype getResultT() {
return constrain((targetTemp - indoorTemp), -3, 3) * Kt;
}
};

View File

@@ -496,9 +496,8 @@ protected:
}
}
if (!rSensor.connected) {
rSensor.connected = true;
}
// Mark connected
Sensors::setConnectionStatusById(sensorId, true, true);
if (!this->bleLastSetDtTime[sensorId] || millis() - this->bleLastSetDtTime[sensorId] > this->bleSetDtInterval) {
struct tm ti;
@@ -521,7 +520,6 @@ protected:
this->bleLastSetDtTime[sensorId] = millis();
}
}
}
}
@@ -981,16 +979,16 @@ protected:
auto& rSensor = Sensors::results[sensorId];
if (rSensor.connected && !sSensor.enabled) {
rSensor.connected = false;
Sensors::setConnectionStatusById(sensorId, false, false);
} else if (rSensor.connected && sSensor.type == Sensors::Type::NOT_CONFIGURED) {
rSensor.connected = false;
Sensors::setConnectionStatusById(sensorId, false, false);
} else if (rSensor.connected && sSensor.purpose == Sensors::Purpose::NOT_CONFIGURED) {
rSensor.connected = false;
Sensors::setConnectionStatusById(sensorId, false, false);
} else if (sSensor.type != Sensors::Type::MANUAL && rSensor.connected && (millis() - rSensor.activityTime) > this->disconnectedTimeout) {
rSensor.connected = false;
Sensors::setConnectionStatusById(sensorId, false, false);
}/* else if (!rSensor.connected) {
rSensor.connected = true;