altoslib: Missed a couple of easy mini voltage API changes
[fw/altos] / src / core / ao_log_telem.c
index 193c11f300826ba99bda40e8c232a7efda83d111..095aca371d0227b0851a143b8e567ef4a6e6a261 100644 (file)
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  */
 
-#include "ao.h"
+#include <ao.h>
+#include <ao_flight.h>
+#include <ao_sample.h>
 
 __code uint8_t ao_log_format = AO_LOG_FORMAT_TELEMETRY;
 
 static __data uint8_t                  ao_log_monitor_pos;
 __pdata enum ao_flight_state           ao_flight_state;
-__pdata int16_t                                ao_max_height;  /* max of ao_height */
+__xdata int16_t                                ao_max_height;  /* max of ao_height */
 __pdata int16_t                                sense_d, sense_m;
+__pdata uint8_t                                ao_igniter_present;
 
 static void
 ao_log_telem_track() {
@@ -30,10 +33,15 @@ ao_log_telem_track() {
                switch (ao_log_single_write_data.telemetry.generic.type) {
                case AO_TELEMETRY_SENSOR_TELEMETRUM:
                case AO_TELEMETRY_SENSOR_TELEMINI:
-                       sense_d = ao_log_single_write_data.telemetry.sensor.sense_d;
-                       sense_m = ao_log_single_write_data.telemetry.sensor.sense_m;
                        /* fall through ... */
                case AO_TELEMETRY_SENSOR_TELENANO:
+                       if (ao_log_single_write_data.telemetry.generic.type == AO_TELEMETRY_SENSOR_TELENANO) {
+                               ao_igniter_present = 0;
+                       } else {
+                               sense_d = ao_log_single_write_data.telemetry.sensor.sense_d;
+                               sense_m = ao_log_single_write_data.telemetry.sensor.sense_m;
+                               ao_igniter_present = 1;
+                       }
                        if (ao_log_single_write_data.telemetry.sensor.height > ao_max_height) {
                                ao_max_height = ao_log_single_write_data.telemetry.sensor.height;
                        }
@@ -84,6 +92,8 @@ ao_log_single(void)
        ao_log_running = 1;
        ao_log_single_restart();
        ao_flight_state = ao_flight_startup;
+       ao_monitor_set(sizeof(struct ao_telemetry_generic));
+
        for (;;) {
                while (!ao_log_running)
                        ao_sleep(&ao_log_running);
@@ -92,9 +102,9 @@ ao_log_single(void)
                while (ao_log_running) {
                        /* Write samples to EEPROM */
                        while (ao_log_monitor_pos != ao_monitor_head) {
-                               memcpy(&ao_log_single_write_data.telemetry,
-                                      &ao_monitor_ring[ao_log_monitor_pos],
-                                      AO_LOG_SINGLE_SIZE);
+                               ao_xmemcpy(&ao_log_single_write_data.telemetry,
+                                          &ao_monitor_ring[ao_log_monitor_pos],
+                                          AO_LOG_SINGLE_SIZE);
                                ao_log_single_write();
                                ao_log_monitor_pos = ao_monitor_ring_next(ao_log_monitor_pos);
                                ao_log_telem_track();