X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=src%2Fmicropeak-v2.0%2Fao_micropeak.c;h=dd86ba1c70c2368fbbde98da38a7194bc79a8491;hp=7ba5cb950c240b0084cc22d3b0cb5f908471ee3e;hb=ee7a54b3215ffa1eb38f16a151c0740b14b60857;hpb=8ec178bbc3babb072b8d53975632cf6294626e98 diff --git a/src/micropeak-v2.0/ao_micropeak.c b/src/micropeak-v2.0/ao_micropeak.c index 7ba5cb95..dd86ba1c 100644 --- a/src/micropeak-v2.0/ao_micropeak.c +++ b/src/micropeak-v2.0/ao_micropeak.c @@ -171,16 +171,16 @@ static void 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)); - ao_pips(); - ao_log_micro_restore(); ao_compute_height(); ao_report_altitude(); + + ao_pips(); + ao_log_micro_dump(); #if BOOST_DELAY @@ -193,6 +193,7 @@ ao_micropeak(void) ao_compute_height(); ao_report_altitude(); + ao_sleep_mode(); ao_sleep(&ao_on_battery); } @@ -202,7 +203,54 @@ ao_show_bat(void) 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 \0Delete flight" }, { ao_show_bat, "b\0Show battery voltage" }, { 0 } }; @@ -266,6 +314,8 @@ main(void) ao_spi_init(); ao_exti_init(); + ao_storage_setup(); + ao_ms5607_init(); ao_storage_init(); @@ -277,6 +327,7 @@ main(void) ao_usb_init(); ao_cmd_init(); ao_cmd_register(mp_cmd); + ao_config_init(); } ao_start_scheduler(); }