Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
raul-ortega committed Nov 15, 2018
2 parents a87b4a7 + e54cb38 commit 22b4fa0
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/main/config/config_master.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ typedef struct master_t {
uint8_t init_servos;
uint8_t telemetry_min_sats;
uint8_t telemetry_provider;
uint8_t telemetry_home;
uint8_t gps_min_sats;
uint8_t min_logic_level;
// NO PID CONTROL SYSTEM
Expand Down
8 changes: 7 additions & 1 deletion src/main/io/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ extern int16_t telemetry_alt;
extern int16_t telemetry_sats;
extern uint8_t telemetry_failed_cs;
extern uint8_t telemetry_fixtype;
extern uint8_t telemetry_frequency;
extern positionVector_t targetPosition;
extern positionVector_t trackerPosition;
extern bool gotFix;
Expand Down Expand Up @@ -653,11 +654,16 @@ void showCliModePage(void)

void showTelemetryPage(void){
uint8_t rowIndex = PAGE_TITLE_LINE_COUNT;
i2c_OLED_set_line(rowIndex++);
//i2c_OLED_set_line(rowIndex++);
if(!PROTOCOL(TP_MFD)) {
if(telemetry_sats>99)
telemetry_sats = 99;

tfp_sprintf(lineBuffer, "Hz : %d",telemetry_frequency);
padLineBuffer();
i2c_OLED_set_line(rowIndex++);
i2c_OLED_send_string(lineBuffer);

tfp_sprintf(lineBuffer, "Sat: %02d %s FCS:%d", telemetry_sats, telemetryFixType[telemetry_fixtype], telemetry_failed_cs);
padLineBuffer();
i2c_OLED_set_line(rowIndex++);
Expand Down
9 changes: 8 additions & 1 deletion src/main/io/serial_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,11 @@ static const char * const lookupTableAlignment[] = {
};

static const char * const lookupTabletelemetryProvider[] = {
"NONE", "DIY_GPS","INAV", NULL
"NONE", "DIY_GPS","INAV","APM10"
};

static const char * const lookupTabletelemetryHome[] = {
"DEFAULT", "AUTO"
};

#ifdef GPS
Expand Down Expand Up @@ -401,6 +405,7 @@ typedef enum {
TABLE_UNIT,
TABLE_ALIGNMENT,
TABLE_TELEMETRY_PROVIDER,
TABLE_TELEMETRY_HOME,
#ifdef GPS
TABLE_GPS_PROVIDER,
TABLE_GPS_SBAS_MODE,
Expand All @@ -419,6 +424,7 @@ static const lookupTableEntry_t lookupTables[] = {
{ lookupTableUnit, sizeof(lookupTableUnit) / sizeof(char *) },
{ lookupTableAlignment, sizeof(lookupTableAlignment) / sizeof(char *) },
{ lookupTabletelemetryProvider, sizeof(lookupTabletelemetryProvider) / sizeof(char *) },
{ lookupTabletelemetryHome, sizeof(lookupTabletelemetryHome) / sizeof(char *) },
#ifdef GPS
{ lookupTableGPSProvider, sizeof(lookupTableGPSProvider) / sizeof(char *) },
{ lookupTableGPSSBASMode, sizeof(lookupTableGPSSBASMode) / sizeof(char *) },
Expand Down Expand Up @@ -733,6 +739,7 @@ const clivalue_t valueTable[] = {
{ "telemetry_protocol", VAR_UINT16 | TRACKER_VALUE, &masterConfig.telemetry_protocol, .config.minmax = { TP_SERVOTEST, TP_PITLAB } },
{ "telemetry_min_sats", VAR_UINT8 | TRACKER_VALUE, &masterConfig.telemetry_min_sats, .config.minmax = { 0, 20 } },
{ "telemetry_provider", VAR_UINT8 | TRACKER_VALUE | MODE_LOOKUP, &masterConfig.telemetry_provider, .config.lookup = {TABLE_TELEMETRY_PROVIDER} },
{ "telemetry_home" , VAR_UINT8 | TRACKER_VALUE | MODE_LOOKUP, &masterConfig.telemetry_home, .config.lookup = {TABLE_TELEMETRY_HOME} },
//{ "gps_port", VAR_UINT8 | TRACKER_VALUE, &masterConfig.serialConfig.portConfigs[0].msp_baudrateIndex, .config.minmax = { 0, 4 } },
{ "start_tracking_distance", VAR_UINT8 | TRACKER_VALUE, &masterConfig.start_tracking_distance, .config.minmax = { 0, 100 } },
{ "start_tracking_altitude", VAR_UINT8 | TRACKER_VALUE, &masterConfig.start_tracking_altitude, .config.minmax = { 0, 100 } },
Expand Down
6 changes: 5 additions & 1 deletion src/main/tracker/frskyd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This file is part of u360gts, aka amv-open360tracker 32bits:
* https://github.com/raul-ortega/amv-open360tracker-32bits
*
* The code below is an adaptation by Raúl Ortega of the original code written by Samuel Brucksch:
* The code below is an adaptation by Raúl Ortega of the original code written by Samuel Brucksch:
* https://github.com/SamuelBrucksch/open360tracker
*
* u360gts is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -241,6 +241,10 @@ void parseTelemHubByte(uint8_t c) {
alt = (int16_t)((c << 8) + byte0);
gotAlt = true;
break;
case BARO_ALT_BP_ID:
alt = (int16_t)((c << 8) + byte0);
gotAlt = true;
break;
case GPS_LON_BP_ID:
lon_bp = (c << 8) + byte0;
break;
Expand Down
18 changes: 18 additions & 0 deletions src/main/tracker/frskyx.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ int32_t coordToLong(int8_t neg, uint16_t bp, uint16_t ap);
//used for sats and fix type
#define TEMP2 0x05

// FrSky Passthrough DATA IDs from APM
#define GPS_STATUS 0x5002
#define AIRCRAFT_HOME 0X5004
#define bitmask(X,Y) (((1 << X) -1) << Y)

// FrSky new DATA IDs (2 bytes)
#define ALT_FIRST_ID 0x0100
#define ALT_LAST_ID 0x010f
Expand Down Expand Up @@ -247,6 +252,19 @@ void processSportPacket(uint8_t *packet)
}

}
else if(appId == GPS_STATUS && telemetry_provider==3){
sats = (uint8_t) (SPORT_DATA_U32(packet) & bitmask(4,0));
}
else if(appId == AIRCRAFT_HOME && telemetry_provider==3){
uint16_t msl_dc, msl_x, msl_sgn;
msl_dc = (SPORT_DATA_U32(packet) & bitmask(7,24)) >> 24;
msl_x = (SPORT_DATA_U32(packet) & bitmask(2,22)) >> 22;
msl_sgn = (SPORT_DATA_U32(packet) & bitmask(1,31)) >> 31;
//homeAlt = bit32.extract(VALUE,14,10) * (10^bit32.extract(VALUE,12,2)) * 0.1 * (bit32.extract(VALUE,24,1) == 1 and -1 or 1) --m
alt = ((int16_t) (msl_dc * msl_x * 0.1 * msl_sgn == 1?-1:1));
telemetry_alt = alt;
gotAlt = true;
}
break;
}
}
Expand Down
37 changes: 35 additions & 2 deletions src/main/tracker/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void offsetTrimDecrease(void);
float map(long x, long in_min, long in_max, long out_min, long out_max);
void calcEstimatedPosition();
bool couldLolcalGpsSetHome(bool setByUser);
bool couldTelemetrySetHome();
bool couldTelemetrySetHome(void);
void updateCalibratePan();
uint16_t calculateDeltaHeading(uint16_t heading1, uint16_t heading2);
void setEpsMode(void);
Expand All @@ -152,6 +152,7 @@ void protocolInit(void);
void trackingInit(void);
void telemetryPortInit(void);
void setHomeByLocalGps(positionVector_t *tracker, int32_t lat, int32_t lon, int16_t alt, bool home_updated, bool beep);
void calcTelemetryFrequency(void);
uint8_t filterTiltAngle(uint8_t target);
//EASING
int16_t _lastTilt;
Expand Down Expand Up @@ -305,6 +306,10 @@ extern uint8_t telemetry_provider;
extern int32_t telemetry_lat;
extern int32_t telemetry_lon;

extern uint8_t telemetry_frequency;
uint8_t telemetry_fixes;
uint32_t telemetry_millis;

void tracker_setup(void)
{

Expand Down Expand Up @@ -383,6 +388,9 @@ void trackingInit(void){
menuState = 0;

targetPosition.home_alt = -32768;

telemetry_frequency = 0;
telemetry_millis = millis();
}

void tracker_loop(void)
Expand Down Expand Up @@ -801,6 +809,8 @@ void updateTelemetryLost(void){
if(lostTelemetry) {
gotFix = false;
gotAlt = false;
telemetry_frequency = 0;
telemetry_fixes = 0;
return;
}

Expand Down Expand Up @@ -840,6 +850,9 @@ void updateTargetPosition(void){

if(!PROTOCOL(TP_MFD)){
if (gotFix) {

calcTelemetryFrequency();

targetPosition.lat = getTargetLat();
targetPosition.lon = getTargetLon();
currentDistance = distance_between(targetLast.lat / TELEMETRY_LATLON_DIVIDER_F,targetLast.lon / TELEMETRY_LATLON_DIVIDER_F,targetPosition.lat / TELEMETRY_LATLON_DIVIDER_F,targetPosition.lon / TELEMETRY_LATLON_DIVIDER_F);
Expand Down Expand Up @@ -1063,14 +1076,22 @@ void updateSetHomeByGPS(void){
home_timer_reset = 0;
} else if(masterConfig.update_home_by_local_gps == 1 && homeSet && couldLolcalGpsSetHome(false)){
setHomeByLocalGps(&trackerPosition,GPS_coord[LAT]/10,GPS_coord[LON]/10,GPS_altitude,true,false);
} else if(!homeSet && couldTelemetrySetHome()){
setHomeByTelemetry(&trackerPosition, &targetPosition);
if(masterConfig.gpsConfig.homeBeeper)
beeper(BEEPER_ARMING_GPS_FIX);
}
}

bool couldLolcalGpsSetHome(bool setByUser){
if(feature(FEATURE_DEBUG)){
return true;
}
return ((setByUser && GPS_numSat >= 4) || (!setByUser && GPS_numSat >= masterConfig.gps_min_sats)) && feature(FEATURE_GPS) && STATE(GPS_FIX);
return ((setByUser && GPS_numSat >= 4) || (!setByUser && GPS_numSat >= masterConfig.gps_min_sats)) && (feature(FEATURE_GPS) && STATE(GPS_FIX));
}

bool couldTelemetrySetHome(void){
return (!feature(FEATURE_GPS) && masterConfig.telemetry_home == 1 && telemetry_sats >= masterConfig.telemetry_min_sats);
}

void updateMFD(void){
Expand Down Expand Up @@ -1600,3 +1621,15 @@ void protocolInit(void){
uint8_t filterTiltAngle(uint8_t target){
return (masterConfig.tilt_max_angle > 0 && target > masterConfig.tilt_max_angle)?masterConfig.tilt_max_angle:target;
}

void calcTelemetryFrequency(void){

telemetry_fixes++;

if(millis() - telemetry_millis >= 5000){
telemetry_frequency = (uint8_t) (telemetry_fixes / 5.0);
telemetry_fixes = 0;
telemetry_millis = millis();
}
}

4 changes: 4 additions & 0 deletions src/main/tracker/telemetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ uint8_t telemetry_provider = 0;

uint8_t telemetry_fixtype = 0;

uint8_t telemetry_fixes = 0;
uint8_t telemetry_frequency = 0;
uint32_t telemetry_millis = 0;

uint8_t a;

uint8_t LOCAL_GPS;
Expand Down
2 changes: 1 addition & 1 deletion src/main/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

#define FC_VERSION_MAJOR 9 // increment when a major release is made (big new feature, etc)
#define FC_VERSION_MINOR 4 // increment when a minor release is made (small new feature, change etc)
#define FC_VERSION_MINOR 5 // 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
Expand Down

0 comments on commit 22b4fa0

Please sign in to comment.