2017-05-30 22:58:20 +00:00
# ifndef __TRACKING_H__
# define __TRACKING_H__
# include "ch.h"
# include "hal.h"
# include "ptime.h"
2017-09-11 04:45:19 +00:00
typedef enum {
GPS_LOCKED , // GPS is locked and could aquire a fix
GPS_LOSS , // GPS was switched on all time but it couln't aquire a fix
GPS_LOWBATT , // GPS was switched on but had to be switched off prematurely while the battery is almost empty (or is too cold)
GPS_LOG , // The tracker has been just switched on and the position has been taken from the log
GPS_OFF , // There is no active position thread so the GPS was never switched on (in oder to save power)
} gpsLock_t ;
2017-09-01 00:02:30 +00:00
2017-05-30 22:58:20 +00:00
typedef struct {
uint32_t id ; // Serial ID
ptime_t time ; // GPS time
// GPS
2017-09-11 04:45:19 +00:00
gpsLock_t gps_lock ; // 0: locked, 1: GPS loss, 2: low power (switched off), 3: taken from log, 4: GPS switch off permanently
2017-05-30 22:58:20 +00:00
int32_t gps_lat ; // Latitude in °*10^7
int32_t gps_lon ; // Longitude in °*10^7
2017-10-07 04:55:11 +00:00
uint16_t gps_alt ; // Altitude in meter
2017-05-30 22:58:20 +00:00
uint8_t gps_sats ; // Satellites used for solution
uint8_t gps_ttff ; // Time to first fix in seconds
// Voltage and current measurement
uint16_t adc_vsol ; // Current solar voltage in mV
uint16_t adc_vbat ; // Current battery voltage in mV
uint16_t adc_vusb ; // Current USB voltage in mV
int16_t adc_pbat ; // Average battery current (since last track point)
2017-09-01 00:02:30 +00:00
int16_t adc_rbat ; // Battery impedance
2017-05-30 22:58:20 +00:00
// BME280 (on board)
uint32_t air_press ; // Airpressure in Pa*10 (in 0.1Pa)
uint16_t air_hum ; // Rel. humidity in %*10 (in 0.1%)
int16_t air_temp ; // Temperature in degC*100 (in 0.01°C)
2017-09-11 04:45:19 +00:00
2017-10-07 04:55:11 +00:00
uint8_t id_image ; // Last image ID (this is important because it will set the image counter at reset so the last image wont get overwritten with the same image ID)
2017-05-30 22:58:20 +00:00
} trackPoint_t ;
void waitForNewTrackPoint ( void ) ;
trackPoint_t * getLastTrackPoint ( void ) ;
2017-06-12 14:46:03 +00:00
void getNextLogTrackPoint ( trackPoint_t * log ) ;
2017-09-11 04:45:19 +00:00
void init_tracking_manager ( bool useGPS ) ;
trackPoint_t * getLogBuffer ( uint16_t id ) ;
2017-05-30 22:58:20 +00:00
# endif
2017-06-12 14:46:03 +00:00