From a548518b9cf37d256adf6c039ad0c9c32baf9f4c Mon Sep 17 00:00:00 2001 From: Leon Krieg Date: Thu, 19 Sep 2024 20:28:06 +0200 Subject: [PATCH] Ensure math functions are named consistently --- src/common/math.c | 12 +++++------- src/common/math.h | 6 +++--- src/main.c | 6 +++--- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/common/math.c b/src/common/math.c index 5473b2d..a1743ab 100644 --- a/src/common/math.c +++ b/src/common/math.c @@ -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; diff --git a/src/common/math.h b/src/common/math.h index c3a195e..43f09ff 100644 --- a/src/common/math.h +++ b/src/common/math.h @@ -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 diff --git a/src/main.c b/src/main.c index 624966a..879a41c 100644 --- a/src/main.c +++ b/src/main.c @@ -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]);