Split thermistor functions into separate logical units and add TODO

This commit is contained in:
2024-09-19 19:54:28 +02:00
parent b3fda53036
commit 1f01f92291
5 changed files with 74 additions and 52 deletions

View File

@@ -110,8 +110,8 @@ static int Init(void)
static void Update(void)
{
float t[3], rh[3];
float adct[3];
float t[6], rh[3];
word raw;
Info("Reading sensor values...");
@@ -124,13 +124,18 @@ static void Update(void)
I2C_SetChannel(AHT03);
I2C_AHT20_Read(&t[2], &rh[2]);
adct[0] = I2C_ADS1115_ReadThermistor(ADS01);
adct[1] = I2C_ADS1115_ReadThermistor(ADS02);
adct[2] = I2C_ADS1115_ReadThermistor(ADS03);
raw = I2C_ADS1115_ReadRaw(ADS01);
t[3] = SteinhartHart(Resistance(raw));
Info("T1=%.2fC, RH1=%.2f%%, ADCT1=%.2fC", t[0], rh[0], adct[0]);
Info("T2=%.2fC, RH2=%.2f%%, ADCT2=%.2fC", t[1], rh[1], adct[1]);
Info("T3=%.2fC, RH3=%.2f%%, ADCT3=%.2fC", t[2], rh[2], adct[2]);
raw = I2C_ADS1115_ReadRaw(ADS02);
t[4] = SteinhartHart(Resistance(raw));
raw = I2C_ADS1115_ReadRaw(ADS03);
t[5] = SteinhartHart(Resistance(raw));
Info("T1=%.2fC, RH1=%.2f%%, NT1=%.2fC", t[0], rh[0], t[3]);
Info("T2=%.2fC, RH2=%.2f%%, NT2=%.2fC", t[1], rh[1], t[4]);
Info("T3=%.2fC, RH3=%.2f%%, NT3=%.2fC", t[2], rh[2], t[5]);
// TODO: Implement state machine
// TODO: Handle serial commands