Added altitude to aprs geofence. APRS always enabled below 200m

master
Richard Meadows 2015-06-25 19:49:47 +01:00
rodzic 3cda2aba21
commit 28c044f95f
4 zmienionych plików z 12 dodań i 6 usunięć

Wyświetl plik

@ -32,6 +32,6 @@ bool latlon_in_aprs_zone(int32_t aprs_zone, int32_t aprs_zone_outline, float lon
bool aprs_location_tx_allow(void);
int32_t aprs_location_frequency(void);
void aprs_location_update(float lon, float lat);
void aprs_location_update(float lon, float lat, uint32_t altitude);
#endif /* LOCATION_H */

Wyświetl plik

@ -30,6 +30,7 @@
#include "geofence_aprs.h"
int32_t current_aprs_zone = -2, current_aprs_zone_outline = -2;
uint32_t _altitude = 0;
#define polyX(i) (poly[(i*2)+0])
#define polyY(i) (poly[(i*2)+1])
@ -97,8 +98,10 @@ bool latlon_in_aprs_zone(int32_t aprs_zone, int32_t aprs_zone_outline, float lon
*/
bool aprs_location_tx_allow(void) {
/* Not in any zone, or in a zone other than Alpha */
return (current_aprs_zone == -1) || (current_aprs_zone > 0);
/* Not in any zone, or in a zone other than Alpha, or not airbourne */
return (current_aprs_zone == -1) ||
(current_aprs_zone > 0) ||
(_altitude < 200);
}
/**
* Returns the aprs frequency in the current zone.
@ -118,10 +121,13 @@ int32_t aprs_location_frequency(void) {
/**
* Updates the aprs location based on the current lat/lon
*/
void aprs_location_update(float lon, float lat) {
void aprs_location_update(float lon, float lat, uint32_t altitude) {
uint32_t z, outline;
/* Record altitude */
_altitude = altitude;
/* Were we in an aprs zone last time? */
if (current_aprs_zone >= 0 && current_aprs_zone_outline >= 0) {

Wyświetl plik

@ -191,7 +191,7 @@ void aprs_telemetry(void) {
uint32_t altitude = pos.payload.height / 1000;
/* Update location */
aprs_location_update(lon, lat);
aprs_location_update(lon, lat, altitude);
/* aprs okay here? */
if (aprs_location_tx_allow()) {

Wyświetl plik

@ -21,7 +21,7 @@ struct location_aprs_tc_results {
/* Function */
__verification__ void location_aprs_tc(void) {
aprs_location_update(location_aprs_tc_params.lon, location_aprs_tc_params.lat);
aprs_location_update(location_aprs_tc_params.lon, location_aprs_tc_params.lat, 0);
location_aprs_tc_results.tx_allow = aprs_location_tx_allow();
location_aprs_tc_results.frequency = aprs_location_frequency();