diff --git a/src/common.h b/src/common.h index f79b699..f1d0c78 100644 --- a/src/common.h +++ b/src/common.h @@ -1,6 +1,7 @@ #ifndef MAD_CORE_COMMON_H #define MAD_CORE_COMMON_H +#include "common/math.h" #include "common/types.h" #include "common/watchdog.h" diff --git a/src/common/math.c b/src/common/math.c new file mode 100644 index 0000000..be86f41 --- /dev/null +++ b/src/common/math.c @@ -0,0 +1,43 @@ +#include "common.h" + +// https://bmcnoldy.earth.miami.edu/Humidity.html +// https://onlinelibrary.wiley.com/doi/abs/10.1002/andp.18280890511 +// https://onlinelibrary.wiley.com/doi/abs/10.1002/andp.18441370202 + +// NOTE: EXP and LN are exponential and natural logarithm functions + +// Dewpoint TD +// 243.04*(LN(RH/100)+((17.625*T)/(243.04+T)))/ +// (17.625-LN(RH/100)-((17.625*T)/(243.04+T))) +float Dewp(float t, float rh) +{ + // TODO + UNUSED(tc); + UNUSED(rh); + + return 0.0f; +} + +// Temperature T +// 243.04*(((17.625*TD)/(243.04+TD))-LN(RH/100))/ +// (17.625+LN(RH/100)-((17.625*TD)/(243.04+TD))) +float Temp(float td, float rh) +{ + // TODO + UNUSED(dc); + UNUSED(rh); + + return 0.0f; +} + +// Relative Humidity RH +// 100*(EXP((17.625*TD)/(243.04+TD))/ +// EXP((17.625*T)/(243.04+T))) +float Rhum(float t, float td) +{ + // TODO + UNUSED(tc); + UNUSED(dc); + + return 0.0f; +} diff --git a/src/common/math.h b/src/common/math.h new file mode 100644 index 0000000..624dd03 --- /dev/null +++ b/src/common/math.h @@ -0,0 +1,8 @@ +#ifndef MAD_CORE_COMMON_MATH_H +#define MAD_CORE_COMMON_MATH_H + +float Dewp(float t, float rh); +float Temp(float td, float rh); +float Rhum(float t, float td); + +#endif // MAD_CORE_COMMON_MATH_H