kopia lustrzana https://github.com/OpenRTX/OpenRTX
GPS: using 16-bit integers for course over ground
rodzic
a17ad80f10
commit
70f0ce45d3
|
@ -52,8 +52,8 @@ typedef struct
|
||||||
int32_t longitude; // Longitude coordinates
|
int32_t longitude; // Longitude coordinates
|
||||||
int16_t altitude; // Antenna altitude above mean sea level (geoid) in m
|
int16_t altitude; // Antenna altitude above mean sea level (geoid) in m
|
||||||
uint16_t speed; // Ground speed in km/h
|
uint16_t speed; // Ground speed in km/h
|
||||||
float tmg_mag; // Course over ground, degrees, magnetic
|
int16_t tmg_mag; // Course over ground, degrees, magnetic
|
||||||
float tmg_true; // Course over ground, degrees, true
|
int16_t tmg_true; // Course over ground, degrees, true
|
||||||
}
|
}
|
||||||
gps_t;
|
gps_t;
|
||||||
|
|
||||||
|
|
|
@ -167,8 +167,8 @@ void gps_task()
|
||||||
if (minmea_parse_vtg(&frame, sentence))
|
if (minmea_parse_vtg(&frame, sentence))
|
||||||
{
|
{
|
||||||
gps_data.speed = minmea_toint(&frame.speed_kph);
|
gps_data.speed = minmea_toint(&frame.speed_kph);
|
||||||
gps_data.tmg_mag = minmea_tofloat(&frame.magnetic_track_degrees);
|
gps_data.tmg_mag = minmea_toint(&frame.magnetic_track_degrees);
|
||||||
gps_data.tmg_true = minmea_tofloat(&frame.true_track_degrees);
|
gps_data.tmg_true = minmea_toint(&frame.true_track_degrees);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -550,7 +550,7 @@ void vp_announceM17Info(const channel_t* channel, bool isEditing,
|
||||||
|
|
||||||
static bool IsCompassCloseEnoughToCardinalPoint()
|
static bool IsCompassCloseEnoughToCardinalPoint()
|
||||||
{
|
{
|
||||||
float tmg_true = state.gps_data.tmg_true;
|
int16_t tmg_true = state.gps_data.tmg_true;
|
||||||
|
|
||||||
return (tmg_true < (0 + margin) || tmg_true > (360 - margin)) || // north
|
return (tmg_true < (0 + margin) || tmg_true > (360 - margin)) || // north
|
||||||
(tmg_true > (90 - margin) && tmg_true < (90 + margin)) || // east
|
(tmg_true > (90 - margin) && tmg_true < (90 + margin)) || // east
|
||||||
|
@ -638,7 +638,7 @@ void vp_announceGPSInfo(vpGPSInfoFlags_t gpsInfoFlags)
|
||||||
vp_queuePrompt(PROMPT_COMPASS);
|
vp_queuePrompt(PROMPT_COMPASS);
|
||||||
if (!IsCompassCloseEnoughToCardinalPoint())
|
if (!IsCompassCloseEnoughToCardinalPoint())
|
||||||
{
|
{
|
||||||
sniprintf(buffer, 16, "%3.1f", state.gps_data.tmg_true);
|
sniprintf(buffer, 16, "%d", state.gps_data.tmg_true);
|
||||||
vp_queueString(buffer, vpAnnounceCommonSymbols);
|
vp_queueString(buffer, vpAnnounceCommonSymbols);
|
||||||
vp_queuePrompt(PROMPT_DEGREES);
|
vp_queuePrompt(PROMPT_DEGREES);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1272,10 +1272,10 @@ void ui_saveState()
|
||||||
#ifdef CONFIG_GPS
|
#ifdef CONFIG_GPS
|
||||||
static uint16_t priorGPSSpeed = 0;
|
static uint16_t priorGPSSpeed = 0;
|
||||||
static int16_t priorGPSAltitude = 0;
|
static int16_t priorGPSAltitude = 0;
|
||||||
static float priorGPSDirection = 500; // impossible value init.
|
static int16_t priorGPSDirection = 500; // impossible value init.
|
||||||
static uint8_t priorGPSFixQuality= 0;
|
static uint8_t priorGPSFixQuality= 0;
|
||||||
static uint8_t priorGPSFixType = 0;
|
static uint8_t priorGPSFixType = 0;
|
||||||
static uint8_t priorSatellitesInView = 0;
|
static uint8_t priorSatellitesInView = 0;
|
||||||
static uint32_t vpGPSLastUpdate = 0;
|
static uint32_t vpGPSLastUpdate = 0;
|
||||||
|
|
||||||
static vpGPSInfoFlags_t GetGPSDirectionOrSpeedChanged()
|
static vpGPSInfoFlags_t GetGPSDirectionOrSpeedChanged()
|
||||||
|
@ -1313,8 +1313,7 @@ static vpGPSInfoFlags_t GetGPSDirectionOrSpeedChanged()
|
||||||
priorGPSAltitude = state.gps_data.altitude;
|
priorGPSAltitude = state.gps_data.altitude;
|
||||||
}
|
}
|
||||||
|
|
||||||
float degreeDiff = fabs(state.gps_data.tmg_true - priorGPSDirection);
|
if (state.gps_data.tmg_true != priorGPSDirection)
|
||||||
if (degreeDiff >= 1)
|
|
||||||
{
|
{
|
||||||
whatChanged |= vpGPSDirection;
|
whatChanged |= vpGPSDirection;
|
||||||
priorGPSDirection = state.gps_data.tmg_true;
|
priorGPSDirection = state.gps_data.tmg_true;
|
||||||
|
|
Ładowanie…
Reference in New Issue