GPS: using 16-bit integers for course over ground

pull/267/head
Marco 2024-03-31 15:30:15 +02:00 zatwierdzone przez Silvano Seva
rodzic a17ad80f10
commit 70f0ce45d3
4 zmienionych plików z 11 dodań i 12 usunięć

Wyświetl plik

@ -52,8 +52,8 @@ typedef struct
int32_t longitude; // Longitude coordinates
int16_t altitude; // Antenna altitude above mean sea level (geoid) in m
uint16_t speed; // Ground speed in km/h
float tmg_mag; // Course over ground, degrees, magnetic
float tmg_true; // Course over ground, degrees, true
int16_t tmg_mag; // Course over ground, degrees, magnetic
int16_t tmg_true; // Course over ground, degrees, true
}
gps_t;

Wyświetl plik

@ -167,8 +167,8 @@ void gps_task()
if (minmea_parse_vtg(&frame, sentence))
{
gps_data.speed = minmea_toint(&frame.speed_kph);
gps_data.tmg_mag = minmea_tofloat(&frame.magnetic_track_degrees);
gps_data.tmg_true = minmea_tofloat(&frame.true_track_degrees);
gps_data.tmg_mag = minmea_toint(&frame.magnetic_track_degrees);
gps_data.tmg_true = minmea_toint(&frame.true_track_degrees);
}
}
break;

Wyświetl plik

@ -550,7 +550,7 @@ void vp_announceM17Info(const channel_t* channel, bool isEditing,
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
(tmg_true > (90 - margin) && tmg_true < (90 + margin)) || // east
@ -638,7 +638,7 @@ void vp_announceGPSInfo(vpGPSInfoFlags_t gpsInfoFlags)
vp_queuePrompt(PROMPT_COMPASS);
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_queuePrompt(PROMPT_DEGREES);
}

Wyświetl plik

@ -1272,10 +1272,10 @@ void ui_saveState()
#ifdef CONFIG_GPS
static uint16_t priorGPSSpeed = 0;
static int16_t priorGPSAltitude = 0;
static float priorGPSDirection = 500; // impossible value init.
static uint8_t priorGPSFixQuality= 0;
static uint8_t priorGPSFixType = 0;
static uint8_t priorSatellitesInView = 0;
static int16_t priorGPSDirection = 500; // impossible value init.
static uint8_t priorGPSFixQuality= 0;
static uint8_t priorGPSFixType = 0;
static uint8_t priorSatellitesInView = 0;
static uint32_t vpGPSLastUpdate = 0;
static vpGPSInfoFlags_t GetGPSDirectionOrSpeedChanged()
@ -1313,8 +1313,7 @@ static vpGPSInfoFlags_t GetGPSDirectionOrSpeedChanged()
priorGPSAltitude = state.gps_data.altitude;
}
float degreeDiff = fabs(state.gps_data.tmg_true - priorGPSDirection);
if (degreeDiff >= 1)
if (state.gps_data.tmg_true != priorGPSDirection)
{
whatChanged |= vpGPSDirection;
priorGPSDirection = state.gps_data.tmg_true;