Skip to content

Commit

Permalink
Merge pull request #21 from raul-ortega/development
Browse files Browse the repository at this point in the history
GPS and Telemetry altitudes treated as relative
  • Loading branch information
raul-ortega authored Apr 13, 2018
2 parents a907819 + e5e6337 commit bbb1904
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/main/rx/rx.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,5 @@ void suspendRxSignal(void);
void resumeRxSignal(void);

void initRxRefreshRate(uint16_t *rxRefreshRatePtr);

uint8_t calculateRssiPercentage(void);
2 changes: 1 addition & 1 deletion src/main/tracker/TinyGPS.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define COMBINE(sentence_type, term_number) (((unsigned)(sentence_type) << 5) | term_number)


bool TinyGPS_encode(char c);

int from_hex(char a);
unsigned long parse_decimal();
unsigned long parse_degrees();
Expand Down
2 changes: 1 addition & 1 deletion src/main/tracker/TinyGPS.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

enum {_GPS_SENTENCE_GPGGA, _GPS_SENTENCE_GNGGA, _GPS_SENTENCE_GPRMC, _GPS_SENTENCE_OTHER};


bool TinyGPS_encode(char c);

// internal utilities
/*int from_hex(char a);
Expand Down
1 change: 1 addition & 0 deletions src/main/tracker/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ typedef struct {
int16_t alt;
uint16_t heading;
uint32_t distance;
int16_t home_alt;
}
positionVector_t;

Expand Down
25 changes: 22 additions & 3 deletions src/main/tracker/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ void trackingInit(void){
gotNewHeading = false;

menuState = 0;

targetPosition.home_alt = -32768;
}

void tracker_loop(void)
Expand Down Expand Up @@ -680,6 +682,9 @@ void setHomeByTelemetry(positionVector_t *tracker, positionVector_t *target) {
tracker->lat = 47403583; tracker->lon = 8535850; tracker->alt = 474;
}

tracker->alt = 0;
tracker->home_alt = target->alt;

homeSet = true;
homeSet_BY_GPS = false;
homeReset = false;
Expand All @@ -692,9 +697,21 @@ void setHomeByLocalGps(positionVector_t *tracker, int32_t lat, int32_t lon, int1
tracker->lat = lat;
tracker->lon = lon;
tracker->alt = alt;

if(feature(FEATURE_DEBUG)) {
tracker->lat = 47403583; tracker->lon = 8535850; tracker->alt = 474;
}

if(home_updated) {
tracker->alt = alt - tracker->home_alt;
} else {
tracker->alt = 0;
tracker->home_alt = alt;
}

if(targetPosition.home_alt == -32768)
targetPosition.alt = 0;

homeSet = true;
homeSet_BY_GPS = true;
homeReset = false;
Expand Down Expand Up @@ -801,7 +818,10 @@ void updateTargetPosition(void){
if(!PROTOCOL(TP_SERVOTEST)){
if (gotAlt) {

targetPosition.alt = getTargetAlt();
if(telemetry_sats >= masterConfig.telemetry_min_sats && targetPosition.home_alt == -32768)
targetPosition.home_alt = getTargetAlt(0);

targetPosition.alt = getTargetAlt(targetPosition.home_alt);

if(PROTOCOL(TP_MFD)){
distance = getDistance();
Expand Down Expand Up @@ -1058,7 +1078,7 @@ void updateMFD(void){

if (mfdTestMode || (homeSet && gotFix)) {
targetPosition.distance = getDistance();
targetPosition.alt = getTargetAlt();
targetPosition.alt = getTargetAlt(targetPosition.home_alt);
targetPosition.heading = getAzimuth() * 10;
gotFix = false;
}
Expand Down Expand Up @@ -1572,4 +1592,3 @@ void protocolInit(void){
break;
}
}

4 changes: 2 additions & 2 deletions src/main/tracker/telemetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ int32_t getTargetLon() {
return telemetry_lon;
}

int16_t getTargetAlt() {
return telemetry_alt;
int16_t getTargetAlt(int16_t home_alt) {
return telemetry_alt - home_alt;
}

uint16_t getSats() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/tracker/telemetry.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ extern float telemetry_yaw;
extern uint8_t telemetry_failed_cs;
extern uint8_t telemetry_provider;

int16_t getTargetAlt();
int16_t getTargetAlt(int16_t home_alt);
void encodeTargetData(uint8_t c);
int32_t getTargetLat();
int32_t getTargetLon();
Expand Down
4 changes: 2 additions & 2 deletions src/main/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/

#define FC_VERSION_MAJOR 9 // increment when a major release is made (big new feature, etc)
#define FC_VERSION_MINOR 2 // increment when a minor release is made (small new feature, change etc)
#define FC_VERSION_PATCH_LEVEL 4 // increment when a bug is fixed
#define FC_VERSION_MINOR 3 // increment when a minor release is made (small new feature, change etc)
#define FC_VERSION_PATCH_LEVEL 0 // increment when a bug is fixed

#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)
Expand Down

0 comments on commit bbb1904

Please sign in to comment.