static final int AO_LOG_GPS_ALT = 'H';
static final int AO_LOG_GPS_SAT = 'V';
static final int AO_LOG_GPS_DATE = 'Y';
- static final int AO_LOG_HEIGHT = 'h';
+ static final int AO_LOG_PRESSURE = 'P';
/* Added for header fields in eeprom files */
static final int AO_LOG_CONFIG_VERSION = 1000;
double battery_voltage();
double drogue_voltage();
double main_voltage();
+ boolean has_accel();
}
public double battery_voltage() { return record.battery_voltage(); }
public double drogue_voltage() { return record.drogue_voltage(); }
public double main_voltage() { return record.main_voltage(); }
+ public boolean has_accel() { return has_accel; }
};
}
} else {
if (v != 0xffff)
any_valid = true;
- r = new AltosEepromRecord(Altos.AO_LOG_HEIGHT, tiny_tick, v, 0);
+
+ r = new AltosEepromRecord(Altos.AO_LOG_PRESSURE, tiny_tick, 0, v);
/*
* The flight software records ascent data every 100ms, and descent
eeprom.seen |= seen_sensor;
has_accel = true;
break;
- case Altos.AO_LOG_HEIGHT:
- state.height = (short) record.a;
+ case Altos.AO_LOG_PRESSURE:
+ state.pres = record.b;
+ state.flight_pres = state.pres;
+ if (eeprom.n_pad_samples == 0) {
+ eeprom.n_pad_samples++;
+ state.ground_pres = state.pres;
+ }
eeprom.seen |= seen_sensor;
break;
case Altos.AO_LOG_TEMP_VOLT:
AltosGraphTime.Element speed =
new AltosGraphTime.TimeSeries("Speed (m/s)", "Vertical Speed", green) {
public void gotTimeData(double time, AltosDataPoint d) {
- if (d.state() < Altos.ao_flight_drogue) {
+ if (d.state() < Altos.ao_flight_drogue && d.has_accel()) {
series.add(time, d.accel_speed());
} else {
series.add(time, d.baro_speed());
void
ao_log(void)
{
- uint16_t time;
- int16_t delay;
+ uint16_t last_time;
+ uint16_t now;
enum ao_flight_state ao_log_tiny_state;
+ int32_t sum;
+ int16_t count;
+ uint8_t ao_log_adc;
ao_storage_setup();
while (!ao_log_running)
ao_sleep(&ao_log_running);
- time = ao_time();
ao_log_tiny_data(ao_flight_number);
+ ao_log_tiny_data(ao_ground_pres);
+ sum = 0;
+ count = 0;
+ ao_log_adc = ao_sample_adc;
+ last_time = ao_time();
for (;;) {
+ ao_sleep(DATA_TO_XDATA(&ao_sample_adc));
+ while (ao_log_adc != ao_sample_adc) {
+ sum += ao_adc_ring[ao_log_adc].pres;
+ count++;
+ ao_log_adc = ao_adc_ring_next(ao_log_adc);
+ }
if (ao_flight_state != ao_log_tiny_state) {
ao_log_tiny_data(ao_flight_state | 0x8000);
ao_log_tiny_state = ao_flight_state;
if (ao_log_tiny_state == ao_flight_landed)
ao_log_stop();
}
- ao_log_tiny_data(ao_height);
- time += ao_log_tiny_interval;
- delay = time - ao_time();
- if (delay > 0)
- ao_delay(delay);
/* Stop logging when told to */
- while (!ao_log_running)
- ao_sleep(&ao_log_running);
+ if (!ao_log_running)
+ ao_exit();
+ now = ao_time();
+ if ((int16_t) (now - (last_time + ao_log_tiny_interval)) >= 0 && count) {
+ ao_log_tiny_data(sum / count);
+ sum = 0;
+ count = 0;
+ last_time = now;
+ }
}
}