summaryrefslogtreecommitdiff
path: root/aoview/aoview_convert.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2009-05-16 02:25:04 -0700
committerKeith Packard <keithp@keithp.com>2009-05-16 02:25:04 -0700
commit09771c644de54ae354e8f98af7ba74289b3c0fcc (patch)
treefb15f3b168a201fc4a789270dd18c391e44625d7 /aoview/aoview_convert.c
parent37250b00f6286aee4b3b28604f5d463db3079a89 (diff)
Add preliminary aoview codesn4-flight2sn4-flight1
AoView connects with TeleDongle to present telemetry information in a reasonable form. Right now, it just displays information to stdout, but it does have fancy dialogs for finding the USB devices. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'aoview/aoview_convert.c')
-rw-r--r--aoview/aoview_convert.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/aoview/aoview_convert.c b/aoview/aoview_convert.c
new file mode 100644
index 00000000..a4bf813d
--- /dev/null
+++ b/aoview/aoview_convert.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright © 2009 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#include "aoview.h"
+
+static int16_t altitude_table[2048] = {
+#include "../altitude.h"
+};
+
+int16_t
+aoview_pres_to_altitude(int16_t pres)
+{
+ pres = pres >> 4;
+ if (pres < 0) pres = 0;
+ if (pres > 2047) pres = 2047;
+ return altitude_table[pres];
+}
+
+int16_t
+aoview_altitude_to_pres(int16_t alt)
+{
+ int16_t pres;
+
+ for (pres = 0; pres < 2047; pres++)
+ if (altitude_table[pres] <= alt)
+ break;
+ return pres << 4;
+}