aboutsummaryrefslogtreecommitdiff
path: root/shared/util.h
diff options
context:
space:
mode:
authorUnavailableDev <69792062+UnavailableDev@users.noreply.github.com>2022-10-30 17:42:03 +0100
committerGitHub <noreply@github.com>2022-10-30 17:42:03 +0100
commitb82a9c44d0112f5433c4482e2e5802969515ce7d (patch)
tree907451385d246dc61b513f3a27043f32b058268a /shared/util.h
parent84341bc53bca3da581ba59f66bf4174420c83d3a (diff)
parentfc95a016d13c1510a024888c1b87bbfe1a7f7601 (diff)
Merge branch 'dev' into qt-settings
Diffstat (limited to 'shared/util.h')
-rw-r--r--shared/util.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/shared/util.h b/shared/util.h
index 94a3dfe..1bee487 100644
--- a/shared/util.h
+++ b/shared/util.h
@@ -1,6 +1,23 @@
#pragma once
+#include <stdint.h>
+
#define WS_MIN(a, b) (((a) < (b)) ? (a) : (b))
#define WS_MAX(a, b) (((a) > (b)) ? (a) : (b))
+/** @brief take the log base 16 of `x` */
unsigned int ws_log16(unsigned int x);
+
+/** @brief convert 16-bit temperature value to uint8_t */
+uint8_t ws_sensor_tmp_to_8(uint16_t temperature);
+/** @brief convert 16-bit humidity value to uint8_t */
+uint8_t ws_sensor_hum_to_8(uint16_t humidity);
+/** @brief convert 16-bit atmospheric pressure value to uint8_t */
+uint8_t ws_sensor_atm_to_8(uint16_t atmospheric_pressure);
+
+/** @brief convert 8-bit temperature value back to float */
+float ws_sensor_tmp_to_f(uint8_t temperature);
+/** @brief convert 8-bit humidity value back to float */
+float ws_sensor_hum_to_f(uint8_t humidity);
+/** @brief convert 8-bit atmospheric pressure value back to float */
+float ws_sensor_atm_to_f(uint8_t atmospheric_pressure);