Improved algorithm for keeping track of active satellites
This commit is contained in:
parent
1f9793d268
commit
7577b4d6ae
|
|
@ -267,8 +267,9 @@ void gfx_drawSmeter(point_t start, uint16_t width, uint16_t height, float rssi,
|
||||||
* @param width: Bar graph width
|
* @param width: Bar graph width
|
||||||
* @param height: Bar graph height
|
* @param height: Bar graph height
|
||||||
* @param sats: pointer to the array of satellites data
|
* @param sats: pointer to the array of satellites data
|
||||||
|
* @param active_sats: bitset representing which sats are part of the fix
|
||||||
*/
|
*/
|
||||||
void gfx_drawGPSgraph(point_t start, uint16_t width, uint16_t height, sat_t *sats);
|
void gfx_drawGPSgraph(point_t start, uint16_t width, uint16_t height, sat_t *sats, uint16_t active_sats);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to draw a compass of arbitrary size.
|
* Function to draw a compass of arbitrary size.
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,6 @@ typedef struct
|
||||||
uint8_t elevation; // Elevation in degrees
|
uint8_t elevation; // Elevation in degrees
|
||||||
uint16_t azimuth; // Azimuth in degrees
|
uint16_t azimuth; // Azimuth in degrees
|
||||||
uint8_t snr; // Quality of the signal in range 0-99
|
uint8_t snr; // Quality of the signal in range 0-99
|
||||||
bool active; // True if this satellite is part of the fix
|
|
||||||
}
|
}
|
||||||
sat_t;
|
sat_t;
|
||||||
|
|
||||||
|
|
@ -50,6 +49,7 @@ typedef struct
|
||||||
uint8_t satellites_tracked; // Number of tracked satellites
|
uint8_t satellites_tracked; // Number of tracked satellites
|
||||||
uint8_t satellites_in_view; // Satellites in view
|
uint8_t satellites_in_view; // Satellites in view
|
||||||
sat_t satellites[12]; // Details about satellites in view
|
sat_t satellites[12]; // Details about satellites in view
|
||||||
|
uint16_t active_sats; // Bitmap representing which sats are part of the fix
|
||||||
float latitude; // Latitude coordinates
|
float latitude; // Latitude coordinates
|
||||||
float longitude; // Longitude coordinates
|
float 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
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ void gps_taskFunc(char *line, int len, gps_t *state)
|
||||||
|
|
||||||
case MINMEA_SENTENCE_GSA:
|
case MINMEA_SENTENCE_GSA:
|
||||||
{
|
{
|
||||||
|
state->active_sats = 0;
|
||||||
struct minmea_sentence_gsa frame;
|
struct minmea_sentence_gsa frame;
|
||||||
if (minmea_parse_gsa(&frame, line))
|
if (minmea_parse_gsa(&frame, line))
|
||||||
{
|
{
|
||||||
|
|
@ -66,14 +67,7 @@ void gps_taskFunc(char *line, int len, gps_t *state)
|
||||||
{
|
{
|
||||||
if (frame.sats[i] != 0)
|
if (frame.sats[i] != 0)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < 12; j++)
|
state->active_sats |= 1 << frame.sats[i];
|
||||||
{
|
|
||||||
if (state->satellites[j].id == frame.sats[i])
|
|
||||||
{
|
|
||||||
state->satellites[j].active = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -92,7 +86,6 @@ void gps_taskFunc(char *line, int len, gps_t *state)
|
||||||
state->satellites[index].elevation = frame.sats[i].elevation;
|
state->satellites[index].elevation = frame.sats[i].elevation;
|
||||||
state->satellites[index].azimuth = frame.sats[i].azimuth;
|
state->satellites[index].azimuth = frame.sats[i].azimuth;
|
||||||
state->satellites[index].snr = frame.sats[i].snr;
|
state->satellites[index].snr = frame.sats[i].snr;
|
||||||
state->satellites[index].active = false;
|
|
||||||
}
|
}
|
||||||
// Zero out unused satellite slots
|
// Zero out unused satellite slots
|
||||||
if (frame.msg_nr == frame.total_msgs && frame.total_msgs < 3)
|
if (frame.msg_nr == frame.total_msgs && frame.total_msgs < 3)
|
||||||
|
|
|
||||||
|
|
@ -641,7 +641,8 @@ void gfx_drawSmeter(point_t start, uint16_t width, uint16_t height, float rssi,
|
||||||
void gfx_drawGPSgraph(point_t start,
|
void gfx_drawGPSgraph(point_t start,
|
||||||
uint16_t width,
|
uint16_t width,
|
||||||
uint16_t height,
|
uint16_t height,
|
||||||
sat_t *sats)
|
sat_t *sats,
|
||||||
|
uint16_t active_sats)
|
||||||
{
|
{
|
||||||
color_t white = {255, 255, 255, 255};
|
color_t white = {255, 255, 255, 255};
|
||||||
color_t yellow = {250, 180, 19 , 255};
|
color_t yellow = {250, 180, 19 , 255};
|
||||||
|
|
@ -655,11 +656,11 @@ void gfx_drawGPSgraph(point_t start,
|
||||||
bar_height = (height - 8) * sats[i].snr / 100 + 1;
|
bar_height = (height - 8) * sats[i].snr / 100 + 1;
|
||||||
point_t bar_pos = {start.x + 2 + i * (bar_width + 2),
|
point_t bar_pos = {start.x + 2 + i * (bar_width + 2),
|
||||||
start.y + (height - 8) - bar_height};
|
start.y + (height - 8) - bar_height};
|
||||||
color_t bar_color = (sats[i].active) ? yellow : white;
|
color_t bar_color = (active_sats & 1 << sats[i].id) ? yellow : white;
|
||||||
gfx_drawRect(bar_pos, bar_width, bar_height, bar_color, true);
|
gfx_drawRect(bar_pos, bar_width, bar_height, bar_color, true);
|
||||||
snprintf(id_buf, 5, "%2d ", sats[i].id);
|
snprintf(id_buf, 5, "%2d ", sats[i].id);
|
||||||
point_t id_pos = {bar_pos.x, start.y + height};
|
point_t id_pos = {bar_pos.x, start.y + height};
|
||||||
gfx_print(id_pos, id_buf, FONT_SIZE_5PT, TEXT_ALIGN_LEFT, white);
|
gfx_print(id_pos, id_buf, FONT_SIZE_5PT, TEXT_ALIGN_LEFT, bar_color);
|
||||||
}
|
}
|
||||||
uint8_t bars_width = 9 + 11 * (bar_width + 2);
|
uint8_t bars_width = 9 + 11 * (bar_width + 2);
|
||||||
point_t left_line_end = {start.x, start.y + height - 9};
|
point_t left_line_end = {start.x, start.y + height - 9};
|
||||||
|
|
@ -683,19 +684,20 @@ void gfx_drawGPScompass(point_t start,
|
||||||
gfx_drawCircle(circle_pos, radius, white);
|
gfx_drawCircle(circle_pos, radius, white);
|
||||||
point_t n_box = {start.x + radius - 5, start.y};
|
point_t n_box = {start.x + radius - 5, start.y};
|
||||||
gfx_drawRect(n_box, 13, 13, black, true);
|
gfx_drawRect(n_box, 13, 13, black, true);
|
||||||
|
float needle_radius = radius - 4;
|
||||||
if (active)
|
if (active)
|
||||||
{
|
{
|
||||||
// Needle
|
// Needle
|
||||||
deg = -deg;
|
deg = -deg;
|
||||||
deg -= 90.0f;
|
deg -= 90.0f;
|
||||||
point_t p1 = {circle_pos.x + radius * COS(deg),
|
point_t p1 = {circle_pos.x + needle_radius * COS(deg),
|
||||||
circle_pos.y + radius * SIN(deg)};
|
circle_pos.y + needle_radius * SIN(deg)};
|
||||||
point_t p2 = {circle_pos.x + radius * COS(deg + 145.0f),
|
point_t p2 = {circle_pos.x + needle_radius * COS(deg + 145.0f),
|
||||||
circle_pos.y + radius * SIN(deg + 145.0f)};
|
circle_pos.y + needle_radius * SIN(deg + 145.0f)};
|
||||||
point_t p3 = {circle_pos.x + radius / 2 * COS(deg + 180.0f),
|
point_t p3 = {circle_pos.x + needle_radius / 2 * COS(deg + 180.0f),
|
||||||
circle_pos.y + radius / 2 * SIN(deg + 180.0f)};
|
circle_pos.y + needle_radius / 2 * SIN(deg + 180.0f)};
|
||||||
point_t p4 = {circle_pos.x + radius * COS(deg - 145.0f),
|
point_t p4 = {circle_pos.x + needle_radius * COS(deg - 145.0f),
|
||||||
circle_pos.y + radius * SIN(deg - 145.0f)};
|
circle_pos.y + needle_radius * SIN(deg - 145.0f)};
|
||||||
gfx_drawLine(p1, p2, yellow);
|
gfx_drawLine(p1, p2, yellow);
|
||||||
gfx_drawLine(p2, p3, yellow);
|
gfx_drawLine(p2, p3, yellow);
|
||||||
gfx_drawLine(p3, p4, yellow);
|
gfx_drawLine(p3, p4, yellow);
|
||||||
|
|
|
||||||
|
|
@ -316,7 +316,8 @@ void _ui_drawMenuGPS(ui_state_t* ui_state)
|
||||||
gfx_drawGPSgraph(bar_pos,
|
gfx_drawGPSgraph(bar_pos,
|
||||||
(SCREEN_WIDTH * 2 / 3) - layout.horizontal_pad,
|
(SCREEN_WIDTH * 2 / 3) - layout.horizontal_pad,
|
||||||
SCREEN_HEIGHT / 3,
|
SCREEN_HEIGHT / 3,
|
||||||
last_state.gps_data.satellites);
|
last_state.gps_data.satellites,
|
||||||
|
last_state.gps_data.active_sats);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _ui_drawMenuSettings(ui_state_t* ui_state)
|
void _ui_drawMenuSettings(ui_state_t* ui_state)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue