altos: Tim Van Milligan suggestion for µP -- delay before showing last flight
[fw/altos] / src / micropeak / ao_micropeak.c
index 1d11300e887040d8d834d124ccabf15f7df56d7b..8ae26ec110b71458c65dfae59fedc09302cd0d8c 100644 (file)
@@ -48,7 +48,10 @@ ao_pa_get(void)
 #define GROUND_AVG             (1 << GROUND_AVG_SHIFT)
 
 /* Pressure change (in Pa) to detect boost */
-#define BOOST_DETECT           48      /* 4m at sea level, 4.8m at 2000m */
+#define BOOST_DETECT           120     /* 10m at sea level, 12m at 2000m */
+
+/* Wait after power on before doing anything to give the user time to assemble the rocket */
+#define BOOST_DELAY            AO_SEC_TO_TICKS(30)
 
 /* Pressure change (in Pa) to detect landing */
 #define LAND_DETECT            12      /* 1m at sea level, 1.2m at 2000m */
@@ -107,6 +110,8 @@ main(void)
 #endif
        ao_restore_flight();
        ao_compute_height();
+       /* Give the person a second to get their finger out of the way */
+       ao_delay(AO_MS_TO_TICKS(1000));
        ao_report_altitude();
        
        ao_spi_init();
@@ -121,6 +126,7 @@ main(void)
                ao_log_micro_dump();
 #endif 
 
+       ao_delay(BOOST_DELAY);
        /* Wait for motion, averaging values to get ground pressure */
        time = ao_time();
        ao_pa_get();
@@ -129,15 +135,13 @@ main(void)
        for (;;) {
                time += SAMPLE_SLEEP;
                if (sample_count == 0)
-                       ao_led_on(AO_LED_BLUE);
+                       ao_led_on(AO_LED_REPORT);
                ao_delay_until(time);
                ao_pa_get();
                if (sample_count == 0)
-                       ao_led_off(AO_LED_BLUE);
+                       ao_led_off(AO_LED_REPORT);
                pa_avg = pa_avg - (pa_avg >> FILTER_SHIFT) + pa;
                pa_diff = pa_ground - pa_avg;
-               if (pa_diff < 0)
-                       pa_diff = -pa_diff;
 
                /* Check for a significant pressure change */
                if (pa_diff > (BOOST_DETECT << FILTER_SHIFT))
@@ -170,10 +174,10 @@ main(void)
                time += SAMPLE_SLEEP;
                ao_delay_until(time);
                if ((sample_count & 3) == 0)
-                       ao_led_on(AO_LED_BLUE);
+                       ao_led_on(AO_LED_REPORT);
                ao_pa_get();
                if ((sample_count & 3) == 0)
-                       ao_led_off(AO_LED_BLUE);
+                       ao_led_off(AO_LED_REPORT);
 #if HAS_EEPROM
                ao_log_micro_data(AO_LOG_MICRO_DATA | pa);
 #endif