void
ao_ms5607_info(void)
{
+#if !HAS_MS5607_TASK
+ ao_ms5607_setup();
+#endif
printf ("ms5607 reserved: %u\n", ao_ms5607_prom.reserved);
printf ("ms5607 sens: %u\n", ao_ms5607_prom.sens);
printf ("ms5607 off: %u\n", ao_ms5607_prom.off);
struct ao_ms5607_value value;
#if !HAS_MS5607_TASK
- ao_ms5607_setup();
ao_ms5607_info();
ao_ms5607_sample(&ao_ms5607_current);
#endif
uint8_t ao_force_freq;
#endif
+#ifndef HAS_CONFIG_SAVE
+#define HAS_CONFIG_SAVE HAS_EEPROM
+#endif
+
#ifndef AO_CONFIG_DEFAULT_APRS_INTERVAL
#define AO_CONFIG_DEFAULT_APRS_INTERVAL 0
#endif
#define AO_CONFIG_DEFAULT_IGNITE_MODE AO_IGNITE_MODE_DUAL
#define AO_CONFIG_DEFAULT_PAD_ORIENTATION AO_PAD_ORIENTATION_ANTENNA_UP
#define AO_CONFIG_DEFAULT_PYRO_TIME AO_MS_TO_TICKS(50)
-#if HAS_EEPROM
+#if HAS_CONFIG_SAVE
#ifndef USE_INTERNAL_FLASH
#error Please define USE_INTERNAL_FLASH
#endif
#define AO_CONFIG_DEFAULT_APRS_SSID (ao_serial_number % 10)
#define AO_CONFIG_DEFAULT_RADIO_RATE AO_RADIO_RATE_38400
-#if HAS_EEPROM
+#if HAS_CONFIG_SAVE
static void
_ao_config_put(void)
{
if (ao_config_loaded)
return;
-#if HAS_EEPROM
+#if HAS_CONFIG_SAVE
/* Yes, I know ao_storage_read calls ao_storage_setup,
* but ao_storage_setup *also* sets ao_storage_config, which we
* need before calling ao_storage_read here
#endif
}
-#if FLIGHT_LOG_APPEND
+#if FLIGHT_LOG_APPEND && HAS_CONFIG_SAVE
void
ao_config_log_fix_append(void)
{
static void
ao_config_show(void);
-#if HAS_EEPROM
+#if HAS_CONFIG_SAVE
static void
ao_config_save(void);
#endif
#endif
{ "s\0Show",
ao_config_show, 0 },
-#if HAS_EEPROM
+#if HAS_CONFIG_SAVE
{ "w\0Write to eeprom",
ao_config_save, 0 },
#endif
#endif
}
-#if HAS_EEPROM
+#if HAS_CONFIG_SAVE
static void
ao_config_save(void)
{
#define AO_LOG_FORMAT_TELEMEGA_3 15 /* 32 byte typed telemega records with 32 bit gyro cal and mpu9250 */
#define AO_LOG_FORMAT_EASYMEGA_2 16 /* 32 byte typed telemega records with 32 bit gyro cal, mpu9250 rotated 90° and adxl375 */
#define AO_LOG_FORMAT_TELESTATIC 17 /* 32 byte typed telestatic records */
+#define AO_LOG_FORMAT_MICROPEAK2 18 /* 2-byte baro values with header */
#define AO_LOG_FORMAT_NONE 127 /* No log at all */
/* Return the flight number from the given log slot, 0 if none, -slot on failure */
#define AO_LOG_UNCOMMON 1
#endif
+#if AO_LOG_FORMAT == AO_LOG_FORMAT_MICROPEAK2
+#define AO_LOG_UNCOMMON 1
+#endif
+
#ifndef AO_LOG_UNCOMMON
extern ao_log_type ao_log_data;
ao_mutex.c \
ao_interrupt.c \
ao_cmd.c \
+ ao_config.c \
ao_task.c \
ao_data.c \
ao_boot_chain.c \
ao_micropeak(void)
{
ao_ms5607_setup();
- ao_storage_setup();
/* Give the person a second to get their finger out of the way */
ao_delay(AO_MS_TO_TICKS(1000));
printf("battery: %u\n", ao_battery_voltage());
}
+uint8_t
+ao_log_present(void)
+{
+ uint16_t n_samples;
+
+ ao_eeprom_read(N_SAMPLES_OFFSET, &n_samples, sizeof (n_samples));
+
+ return n_samples != 0xffff;
+}
+
+static void
+ao_log_list(void)
+{
+ if (ao_log_present())
+ printf ("flight %d start %x end %x\n",
+ 1,
+ 0, MAX_LOG_OFFSET >> 8);
+ printf ("done\n");
+}
+
+static void
+ao_log_delete(void)
+{
+ int16_t cmd_flight = 1;
+
+ ao_cmd_white();
+ if (ao_cmd_lex_c == '-') {
+ cmd_flight = -1;
+ ao_cmd_lex();
+ }
+ cmd_flight *= ao_cmd_decimal();
+ if (ao_cmd_status != ao_cmd_success)
+ return;
+
+ /* Look for the flight log matching the requested flight */
+ if (cmd_flight == 1 && ao_log_present()) {
+ uint32_t pos;
+ for (pos = 0; pos < ao_storage_log_max; pos += ao_storage_block)
+ ao_storage_erase(pos);
+ puts("Erased");
+ return;
+ }
+ printf("No such flight: %d\n", cmd_flight);
+}
+
static struct ao_cmds mp_cmd[] = {
+ { ao_log_list, "l\0List logs" },
+ { ao_log_delete, "d <flight-number>\0Delete flight" },
{ ao_show_bat, "b\0Show battery voltage" },
{ 0 }
};
ao_spi_init();
ao_exti_init();
+ ao_storage_setup();
+
ao_ms5607_init();
ao_storage_init();
ao_usb_init();
ao_cmd_init();
ao_cmd_register(mp_cmd);
+ ao_config_init();
}
ao_start_scheduler();
}
#define HAS_MS5607 1
#define HAS_MS5611 0
#define HAS_MS5607_TASK 0
-#define HAS_EEPROM 0
+#define HAS_EEPROM 1
+#define HAS_CONFIG_SAVE 0
#define HAS_BEEP 0
/* Logging */
#define SAMPLE_SLEEP AO_MS_TO_TICKS(100)
#define BOOST_DELAY AO_SEC_TO_TICKS(60)
#define AO_LOG_ID AO_LOG_ID_MICRO_PEAK2
+#define HAS_LOG 1
+#define AO_LOG_FORMAT AO_LOG_FORMAT_MICROPEAK2
+#define FLIGHT_LOG_APPEND 1
/* Kalman filter */
#define ao_eeprom_read(pos, ptr, size) ao_storage_read(pos, ptr, size)
#define ao_eeprom_write(pos, ptr, size) ao_storage_write(pos, ptr, size)
#define MAX_LOG_OFFSET ao_storage_total
+#define ao_storage_log_max ao_storage_total
extern uint32_t __flash__[];
extern uint32_t __flash_end__[];