diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/ao_gps_report_mega.c | 1 | ||||
-rw-r--r-- | src/core/ao_telemetry.c | 3 | ||||
-rw-r--r-- | src/drivers/ao_log_fat.c | 74 | ||||
-rw-r--r-- | src/telegps-v0.1/Makefile | 5 | ||||
-rw-r--r-- | src/telegps-v0.1/ao_telegps.c | 9 |
5 files changed, 90 insertions, 2 deletions
diff --git a/src/core/ao_gps_report_mega.c b/src/core/ao_gps_report_mega.c index 47891cab..e3af4307 100644 --- a/src/core/ao_gps_report_mega.c +++ b/src/core/ao_gps_report_mega.c @@ -16,6 +16,7 @@ */ #include "ao.h" +#include "ao_log.h" void ao_gps_report_mega(void) diff --git a/src/core/ao_telemetry.c b/src/core/ao_telemetry.c index 8d440e15..3aa315c7 100644 --- a/src/core/ao_telemetry.c +++ b/src/core/ao_telemetry.c @@ -16,6 +16,7 @@ */ #include "ao.h" +#include "ao_log.h" #include "ao_product.h" static __pdata uint16_t ao_telemetry_interval; @@ -306,12 +307,14 @@ ao_telemetry(void) #ifdef AO_SEND_ALL_BARO ao_send_baro(); #endif +#if HAS_FLIGHT #ifdef AO_SEND_MEGA ao_send_mega_sensor(); ao_send_mega_data(); #else ao_send_sensor(); #endif +#endif #if HAS_COMPANION if (ao_companion_running) diff --git a/src/drivers/ao_log_fat.c b/src/drivers/ao_log_fat.c new file mode 100644 index 00000000..684148b7 --- /dev/null +++ b/src/drivers/ao_log_fat.c @@ -0,0 +1,74 @@ +/* + * Copyright © 2013 Keith Packard <keithp@keithp.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#include "ao.h" +#include "ao_log.h" +#include "ao_fat.h" + +static uint8_t log_year, log_month, log_day; +static uint8_t log_running; +static uint8_t log_mutex; + +static void +ao_log_open(void) +{ + char name[12]; + + sprintf(name,"%04d%02d%02dLOG", 2000 + log_year, log_month, log_day); + if (ao_fat_open(name, AO_FAT_OPEN_WRITE) == AO_FAT_SUCCESS) + log_running = 1; +} + +static void +ao_log_close(void) +{ + log_running = 0; + ao_fat_close(); +} + +uint8_t +ao_log_full(void) +{ + return ao_fat_full(); +} + +uint8_t +ao_log_mega(struct ao_log_mega *log) +{ + uint8_t wrote = 0; + ao_mutex_get(&log_mutex); + if (log->type == AO_LOG_GPS_TIME) { + if (log_running && + (log_year != log->u.gps.year || + log_month != log->u.gps.month || + log_day != log->u.gps.day)) { + ao_log_close(); + } + if (!log_running) { + log_year = log->u.gps.year; + log_month = log->u.gps.month; + log_day = log->u.gps.day; + ao_log_open(); + } + } + if (log_running) { + wrote = ao_fat_write(log, sizeof (*log)) == AO_FAT_SUCCESS; + ao_fat_sync(); + } + ao_mutex_put(&log_mutex); + return wrote; +} diff --git a/src/telegps-v0.1/Makefile b/src/telegps-v0.1/Makefile index ae36c9fd..8e610db7 100644 --- a/src/telegps-v0.1/Makefile +++ b/src/telegps-v0.1/Makefile @@ -55,7 +55,10 @@ ALTOS_SRC = \ ao_eeprom_stm.c \ ao_sdcard.c \ ao_bufio.c \ - ao_fat.c + ao_fat.c \ + ao_log_fat.c \ + ao_gps_report_mega.c \ + ao_telemetry.c PRODUCT=TeleGPS-v0.1 PRODUCT_DEF=-DTELEGPS diff --git a/src/telegps-v0.1/ao_telegps.c b/src/telegps-v0.1/ao_telegps.c index 2f1f38f2..91796c21 100644 --- a/src/telegps-v0.1/ao_telegps.c +++ b/src/telegps-v0.1/ao_telegps.c @@ -19,6 +19,8 @@ #include <ao_exti.h> #include <ao_fat.h> +uint16_t ao_flight_number = 1; + int main(void) { @@ -47,9 +49,14 @@ main(void) ao_usb_init(); ao_radio_init(); + ao_fat_init(); + ao_gps_init(); + ao_gps_report_mega_init(); - ao_fat_init(); + ao_telemetry_init(); + ao_telemetry_set_interval(AO_SEC_TO_TICKS(1)); + ao_rdf_set(1); ao_config_init(); |