Ensure math functions are named consistently

This commit is contained in:
2024-09-19 20:28:06 +02:00
parent 560715fd0b
commit a548518b9c
3 changed files with 11 additions and 13 deletions

View File

@@ -37,11 +37,12 @@ float Resistance(int adc_raw)
return R1 / (5.0f / r2 - 1.0f);
}
// Resistance to temperature
float SteinhartHart(float res)
{
float logr, t;
// Convert resistance to temperature
// 25C = 10000 Ohms
// 100C = 6744 Ohms
@@ -51,8 +52,7 @@ float SteinhartHart(float res)
return t - 273.15f; // Kelvin to celsius
}
// Dewpoint TD
float Dewp(float t, float rh)
float Dewpoint(float t, float rh)
{
float a, b;
@@ -65,8 +65,7 @@ float Dewp(float t, float rh)
return TH2 * (a + b) / (TH3 - a - b);
}
// Temperature T
float Temp(float td, float rh)
float Temperature(float td, float rh)
{
float a, b;
@@ -79,8 +78,7 @@ float Temp(float td, float rh)
return TH2 * (b - a) / (TH3 + a - b);
}
// Relative Humidity RH
float Rhum(float t, float td)
float RelHumidity(float t, float td)
{
float a, b;

View File

@@ -4,8 +4,8 @@
float Resistance(int adc_raw);
float SteinhartHart(float res);
float Dewp(float t, float rh);
float Temp(float td, float rh);
float Rhum(float t, float td);
float Dewpoint(float t, float rh);
float Temperature(float td, float rh);
float RelHumidity(float t, float td);
#endif // MAD_CORE_COMMON_MATH_H

View File

@@ -134,9 +134,9 @@ static void Update(void)
raw = I2C_ADS1115_ReadRaw(ADS03);
t[5] = SteinhartHart(Resistance(raw));
dp[0] = Dewp(t[0], rh[0]);
dp[1] = Dewp(t[1], rh[1]);
dp[2] = Dewp(t[2], rh[2]);
dp[0] = Dewpoint(t[0], rh[0]);
dp[1] = Dewpoint(t[1], rh[1]);
dp[2] = Dewpoint(t[2], rh[2]);
Info("T1=%.2fC, RH1=%.2f%%, NT1=%.2fC, DEW1=%.2fC", t[0], rh[0], t[3], dp[0]);
Info("T2=%.2fC, RH2=%.2f%%, NT2=%.2fC, DEW2=%.2fC", t[1], rh[1], t[4], dp[1]);