altosui: Add config and pyro tabs to graph widget
[fw/altos] / src / kernel / ao_pyro.c
index ee94eca35c5c22c461cc576b3bf04cd7a4fadd8b..4c69b82a349c340e4831b42375f5d5f58417425d 100644 (file)
@@ -45,14 +45,8 @@ ao_pyro_status(uint8_t p)
                ao_data_get(&packet);
                );
 
-       value = (AO_IGNITER_CLOSED>>1);
        value = AO_SENSE_PYRO(&packet, p);
-       if (value < AO_IGNITER_OPEN)
-               return ao_igniter_open;
-       else if (value > AO_IGNITER_CLOSED)
-               return ao_igniter_ready;
-       else
-               return ao_igniter_unknown;
+       return ao_igniter_check(value, AO_SENSE_PBATT(&packet));
 }
 
 void
@@ -303,7 +297,18 @@ ao_pyro_check(void)
                                if (delay < 0)
                                        delay = 0;
                                delay_done = ao_time() + (AO_TICK_TYPE) delay;
-                               if (!delay_done)
+
+                               /*
+                                * delay_done is the time at which the
+                                * delay ends, but it is also used as
+                                * an indication that a delay is
+                                * active -- non-zero values indicate
+                                * an active delay. This code ensures
+                                * the value is non-zero, which might
+                                * introduce an additional tick
+                                * of delay.
+                                */
+                               if (delay_done == 0)
                                        delay_done = 1;
                                pyro_delay_done[p] = delay_done;
                        }
@@ -312,7 +317,7 @@ ao_pyro_check(void)
                /* Check to see if we're just waiting for
                 * the delay to expire
                 */
-               if (pyro_delay_done[p]) {
+               if (pyro_delay_done[p] != 0) {
 
                        /* Check to make sure the required conditions
                         * remain valid. If not, inhibit the channel
@@ -679,9 +684,11 @@ ao_pyro_update_version(void)
 
                        for (v = 0; v < NUM_PYRO_VALUES; v++)
                        {
-                               value = ao_pyro_get_1_24(&pyro_1_24[p], ao_pyro_values[v].flag);
-                               ao_pyro_put(&tmp, ao_pyro_values[v].offset,
-                                           ao_pyro_size(ao_pyro_values[v].flag), value);
+                               if (ao_pyro_values[v].offset != NO_VALUE) {
+                                       value = ao_pyro_get_1_24(&pyro_1_24[p], ao_pyro_values[v].flag);
+                                       ao_pyro_put(&tmp, ao_pyro_values[v].offset,
+                                                   ao_pyro_size(ao_pyro_values[v].flag), value);
+                               }
                        }
                        memcpy(&pyro_1_25[p], &tmp, sizeof(tmp));
                }