aboutsummaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/util.c b/util.c
new file mode 100644
index 0000000..794eea7
--- /dev/null
+++ b/util.c
@@ -0,0 +1,25 @@
+#include <math.h>
+#include <string.h>
+
+#include "util.h"
+
+float pressure_to_metres_asl(float real, float setting)
+{
+ return 44330.f*(1.f-pow(real/setting, 1/5.255));
+}
+
+void blank_to_eol(char *line, size_t len)
+{
+ size_t i = 0;
+ for (i = strlen(line); i < len - 1; i++) {
+ line[i] = ' ';
+ }
+ line[i] = '\0';
+}
+
+void split_float(float input, int *integer_part, float *float_part)
+{
+ *integer_part = (int)input;
+ *float_part = fabs(input - *integer_part);
+}
+