Add option to beep max height in feet rather than just meters
[fw/altos] / src / kernel / ao_report.c
index 831ba874cc3656d312aca76ff2409cbb03e8a7fa..977cea854ff1f014e0927a25530b34988e2682a8 100644 (file)
@@ -149,7 +149,7 @@ ao_report_digit(uint8_t digit)
 }
 
 static void
-ao_report_number(int16_t n)
+ao_report_number(int32_t n)
 {
        uint8_t digits[10];
        uint8_t ndigits, i;
@@ -158,7 +158,7 @@ ao_report_number(int16_t n)
                n = 0;
        ndigits = 0;
        do {
-               digits[ndigits++] = n % 10;
+               digits[ndigits++] = (uint8_t) (n % 10);
                n /= 10;
        } while (n);
 
@@ -171,7 +171,14 @@ ao_report_number(int16_t n)
 static void
 ao_report_altitude(void)
 {
-       ao_report_number(ao_max_height);
+       alt_t max_h = ao_max_height;
+       if (ao_config.report_feet) {
+               max_h = max_h * 39 / 12;
+               /* report a leading zero to distinguish */
+               if (max_h)
+                       ao_report_digit(0);
+       }
+       ao_report_number(max_h);
 }
 
 #if HAS_BATTERY_REPORT
@@ -200,8 +207,8 @@ ao_report_igniter_ready(enum ao_igniter igniter)
 uint8_t
 ao_report_igniter(void)
 {
-       return (ao_report_igniter_ready(ao_igniter_drogue) |
-                    (ao_report_igniter_ready(ao_igniter_main) << 1));
+       return (uint8_t) (ao_report_igniter_ready(ao_igniter_drogue) |
+                         (ao_report_igniter_ready(ao_igniter_main) << 1));
 }
 #endif