Improve sensor log readability and minor naming fixes

This commit is contained in:
2024-09-23 03:36:25 +02:00
parent 501d5ea237
commit e6c5a46ff9

View File

@@ -28,7 +28,7 @@ enum state_e
static enum state_e state;
static float temp, temp_target;
static float dewp, dewp_target;
static float relh;
static float rhum;
static int Init(void);
static void Update(void);
@@ -87,7 +87,7 @@ static int Init(void)
if (MEM_Read(&mem) == 0) {
Info("Found persistent configuration in EEPROM!");
Info("Using targets TEMP='%.2fC', DEWP='%.2fC'.",
Info("Using targets TEMP=%.2fC, DEWP=%.2fC.",
mem.temp, mem.dewp);
temp_target = mem.temp;
@@ -176,10 +176,9 @@ static void SetTarget(float t, float td)
mem_block_t mem;
Print("\r\n");
Info("=======================================");
Info("Setting temperature target to '%.2fC'.", t);
Info("Setting dewpoint target to '%.2fC'.", td);
Info("=======================================");
Info("Updating target configuration:");
Info("Setting temperature to %.2fC.", t);
Info("Setting new dewpoint to %.2fC.", td);
if (MEM_Read(&mem) == 0) {
if (t == mem.temp && td == mem.dewp) {
@@ -201,7 +200,7 @@ static void SetTarget(float t, float td)
static void GetSensorState(void)
{
word raw;
float t[6], rh[3], dp[3];
float t[6], rh[3], td[3];
Print("\r\n");
Info("Reading sensor values...");
@@ -224,18 +223,19 @@ static void GetSensorState(void)
raw = I2C_ADS1115_ReadRaw(ADS03);
t[5] = SteinhartHart(Resistance(raw));
dp[0] = Dewpoint(t[0], rh[0]);
dp[1] = Dewpoint(t[1], rh[1]);
dp[2] = Dewpoint(t[2], rh[2]);
td[0] = Dewpoint(t[0], rh[0]);
td[1] = Dewpoint(t[1], rh[1]);
td[2] = Dewpoint(t[2], rh[2]);
temp = (t[0] + t[1] + t[2]) / 3;
relh = (rh[0] + rh[1] + rh[2]) / 3;
dewp = Dewpoint(temp, relh);
rhum = (rh[0] + rh[1] + rh[2]) / 3;
dewp = Dewpoint(temp, rhum);
Info("T1=%.2fC, RH1=%.2f%%, NT1=%.2fC, DP1=%.2fC", t[0], rh[0], t[3], dp[0]);
Info("T2=%.2fC, RH2=%.2f%%, NT2=%.2fC, DP2=%.2fC", t[1], rh[1], t[4], dp[1]);
Info("T3=%.2fC, RH3=%.2f%%, NT3=%.2fC, DP3=%.2fC", t[2], rh[2], t[5], dp[2]);
Info("T_AVG=%.2fC, RH_AVG=%.2f%%, DP_AVG=%.2fC", temp, relh, dewp);
Info("T1=%.2fC, TD1=%.2fC, RH1=%.2f%%, NT1=%.2fC", t[0], td[0], rh[0], t[3]);
Info("T2=%.2fC, TD2=%.2fC, RH2=%.2f%%, NT2=%.2fC", t[1], td[1], rh[1], t[4]);
Info("T3=%.2fC, TD3=%.2fC, RH3=%.2f%%, NT3=%.2fC", t[2], td[2], rh[2], t[5]);
Info("T_AVG=%.2fC, TD_AVG=%.2fC, RH_AVG=%.2f%%", temp, dewp, rhum);
Info("T_TAR=%.2fC, TD_TAR=%.2fC", temp_target, dewp_target);
}
int main(void)