kopia lustrzana https://github.com/OpenRTX/OpenRTX
GPS: using fixed-point 32-bit value for latitude and longitude
rodzic
36ef3b310c
commit
e4a62f30ee
|
@ -48,8 +48,8 @@ typedef struct
|
||||||
uint8_t satellites_in_view; // Satellites in view
|
uint8_t satellites_in_view; // Satellites in view
|
||||||
gpssat_t satellites[12]; // Details about satellites in view
|
gpssat_t satellites[12]; // Details about satellites in view
|
||||||
uint32_t active_sats; // Bitmap representing which sats are part of the fix
|
uint32_t active_sats; // Bitmap representing which sats are part of the fix
|
||||||
float latitude; // Latitude coordinates
|
int32_t latitude; // Latitude coordinates
|
||||||
float longitude; // Longitude coordinates
|
int32_t longitude; // Longitude coordinates
|
||||||
float altitude; // Antenna altitude above mean sea level (geoid) in m
|
float altitude; // Antenna altitude above mean sea level (geoid) in m
|
||||||
float speed; // Ground speed in km/h
|
float speed; // Ground speed in km/h
|
||||||
float tmg_mag; // Course over ground, degrees, magnetic
|
float tmg_mag; // Course over ground, degrees, magnetic
|
||||||
|
|
|
@ -90,8 +90,8 @@ void gps_task()
|
||||||
struct minmea_sentence_rmc frame;
|
struct minmea_sentence_rmc frame;
|
||||||
if (minmea_parse_rmc(&frame, sentence))
|
if (minmea_parse_rmc(&frame, sentence))
|
||||||
{
|
{
|
||||||
gps_data.latitude = minmea_tocoord(&frame.latitude);
|
gps_data.latitude = minmea_tofixedpoint(&frame.latitude);
|
||||||
gps_data.longitude = minmea_tocoord(&frame.longitude);
|
gps_data.longitude = minmea_tofixedpoint(&frame.longitude);
|
||||||
gps_data.timestamp.hour = frame.time.hours;
|
gps_data.timestamp.hour = frame.time.hours;
|
||||||
gps_data.timestamp.minute = frame.time.minutes;
|
gps_data.timestamp.minute = frame.time.minutes;
|
||||||
gps_data.timestamp.second = frame.time.seconds;
|
gps_data.timestamp.second = frame.time.seconds;
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <utils.h>
|
#include <utils.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include <ui/ui_default.h>
|
#include <ui/ui_default.h>
|
||||||
#include <beeps.h>
|
#include <beeps.h>
|
||||||
#include "interfaces/cps_io.h"
|
#include "interfaces/cps_io.h"
|
||||||
|
@ -689,20 +690,26 @@ void vp_announceGPSInfo(vpGPSInfoFlags_t gpsInfoFlags)
|
||||||
|
|
||||||
if ((gpsInfoFlags & vpGPSLatitude) != 0)
|
if ((gpsInfoFlags & vpGPSLatitude) != 0)
|
||||||
{
|
{
|
||||||
// lat/long
|
// Convert from signed longitude, to unsigned + direction
|
||||||
sniprintf(buffer, 16, "%8.6f", state.gps_data.latitude);
|
int32_t latitude = abs(state.gps_data.latitude);
|
||||||
|
uint8_t latitude_int = latitude / 1000000;
|
||||||
|
int32_t latitude_dec = latitude % 1000000;
|
||||||
|
voicePrompt_t direction = (state.gps_data.latitude < 0) ? PROMPT_SOUTH : PROMPT_NORTH;
|
||||||
|
sniprintf(buffer, 16, "%d.%06"PRId32, latitude_int, latitude_dec);
|
||||||
stripTrailingZeroes(buffer);
|
stripTrailingZeroes(buffer);
|
||||||
vp_queuePrompt(PROMPT_LATITUDE);
|
vp_queuePrompt(PROMPT_LATITUDE);
|
||||||
vp_queueString(buffer, vpAnnounceCommonSymbols);
|
vp_queueString(buffer, vpAnnounceCommonSymbols);
|
||||||
vp_queuePrompt(PROMPT_NORTH);
|
vp_queuePrompt(direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((gpsInfoFlags & vpGPSLongitude) != 0)
|
if ((gpsInfoFlags & vpGPSLongitude) != 0)
|
||||||
{
|
{
|
||||||
float longitude = state.gps_data.longitude;
|
// Convert from signed longitude, to unsigned + direction
|
||||||
voicePrompt_t direction = (longitude < 0) ? PROMPT_WEST : PROMPT_EAST;
|
int32_t longitude = abs(state.gps_data.longitude);
|
||||||
longitude = (longitude < 0) ? -longitude : longitude;
|
uint8_t longitude_int = longitude / 1000000;
|
||||||
sniprintf(buffer, 16, "%8.6f", longitude);
|
int32_t longitude_dec = longitude % 1000000;
|
||||||
|
voicePrompt_t direction = (state.gps_data.longitude < 0) ? PROMPT_WEST : PROMPT_EAST;
|
||||||
|
sniprintf(buffer, 16, "%d.%06"PRId32, longitude_int, longitude_dec);
|
||||||
stripTrailingZeroes(buffer);
|
stripTrailingZeroes(buffer);
|
||||||
|
|
||||||
vp_queuePrompt(PROMPT_LONGITUDE);
|
vp_queuePrompt(PROMPT_LONGITUDE);
|
||||||
|
|
|
@ -682,20 +682,30 @@ void _ui_drawMenuGPS()
|
||||||
}
|
}
|
||||||
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_LEFT,
|
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_LEFT,
|
||||||
color_white, fix_buf);
|
color_white, fix_buf);
|
||||||
|
|
||||||
|
// Convert from signed longitude, to unsigned + direction
|
||||||
|
int32_t latitude = abs(last_state.gps_data.latitude);
|
||||||
|
uint8_t latitude_int = latitude / 1000000;
|
||||||
|
int32_t latitude_dec = latitude % 1000000;
|
||||||
|
char *direction_lat = (last_state.gps_data.latitude < 0) ? "S " : "N ";
|
||||||
|
|
||||||
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_CENTER,
|
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_CENTER,
|
||||||
color_white, "N ");
|
color_white, direction_lat);
|
||||||
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_RIGHT,
|
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_RIGHT,
|
||||||
color_white, "%8.6f", last_state.gps_data.latitude);
|
color_white, "%d.%.6d", latitude_int, latitude_dec);
|
||||||
gfx_print(layout.line2_pos, layout.top_font, TEXT_ALIGN_LEFT,
|
gfx_print(layout.line2_pos, layout.top_font, TEXT_ALIGN_LEFT,
|
||||||
color_white, type_buf);
|
color_white, type_buf);
|
||||||
|
|
||||||
// Convert from signed longitude, to unsigned + direction
|
// Convert from signed longitude, to unsigned + direction
|
||||||
float longitude = last_state.gps_data.longitude;
|
int32_t longitude = abs(last_state.gps_data.longitude);
|
||||||
char *direction = (longitude < 0) ? "W " : "E ";
|
uint8_t longitude_int = longitude / 1000000;
|
||||||
longitude = (longitude < 0) ? -longitude : longitude;
|
int32_t longitude_dec = longitude % 1000000;
|
||||||
|
char *direction_lon = (last_state.gps_data.longitude < 0) ? "W " : "E ";
|
||||||
|
|
||||||
gfx_print(layout.line2_pos, layout.top_font, TEXT_ALIGN_CENTER,
|
gfx_print(layout.line2_pos, layout.top_font, TEXT_ALIGN_CENTER,
|
||||||
color_white, direction);
|
color_white, direction_lon);
|
||||||
gfx_print(layout.line2_pos, layout.top_font, TEXT_ALIGN_RIGHT,
|
gfx_print(layout.line2_pos, layout.top_font, TEXT_ALIGN_RIGHT,
|
||||||
color_white, "%8.6f", longitude);
|
color_white, "%d.%.6d", longitude_int, longitude_dec);
|
||||||
gfx_print(layout.bottom_pos, layout.bottom_font, TEXT_ALIGN_CENTER,
|
gfx_print(layout.bottom_pos, layout.bottom_font, TEXT_ALIGN_CENTER,
|
||||||
color_white, "S %4.1fkm/h A %4.1fm",
|
color_white, "S %4.1fkm/h A %4.1fm",
|
||||||
last_state.gps_data.speed,
|
last_state.gps_data.speed,
|
||||||
|
|
Ładowanie…
Reference in New Issue