kopia lustrzana https://github.com/OpenRTX/OpenRTX
Add GPS satellites snr bar graph
rodzic
0cf86ce6ea
commit
ec06b14618
|
@ -23,6 +23,7 @@
|
|||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <interfaces/display.h>
|
||||
#include <state.h>
|
||||
#include <gfxfont.h>
|
||||
#include <TomThumb.h>
|
||||
#include <FreeSans6pt7b.h>
|
||||
|
@ -250,4 +251,14 @@ void gfx_drawBattery(point_t start, uint16_t width, uint16_t height, float perce
|
|||
*/
|
||||
void gfx_drawSmeter(point_t start, uint16_t width, uint16_t height, float rssi, float squelch, color_t color);
|
||||
|
||||
/**
|
||||
* Function to draw GPS SNR bar graph of arbitrary size.
|
||||
* Starting coordinates are relative to the top left point.
|
||||
* @param start: Bar graph start point, in pixel coordinates.
|
||||
* @param width: Bar graph width
|
||||
* @param height: Bar graph height
|
||||
* @param sats: pointer to the array of satellites data
|
||||
*/
|
||||
void gfx_drawGPSgraph(point_t start, uint16_t width, uint16_t height, sat_t *sats);
|
||||
|
||||
#endif /* GRAPHICS_H */
|
||||
|
|
|
@ -516,3 +516,54 @@ void gfx_drawSmeter(point_t start, uint16_t width, uint16_t height, float rssi,
|
|||
point_t squelch_pos = { start.x, start.y + 1 + rssi_height };
|
||||
gfx_drawRect(squelch_pos, squelch_width, squelch_height, color, true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function to draw GPS satellites snr bar graph of arbitrary size
|
||||
* starting coordinates are relative to the top left point.
|
||||
*
|
||||
* **** |
|
||||
* **** **** |
|
||||
* **** **** **** | <-- Height (px)
|
||||
* **** **** **** |
|
||||
* **** **** **** |
|
||||
* **** **** **** |
|
||||
* |
|
||||
* N N+1 N+2 |
|
||||
* __________________
|
||||
*
|
||||
* ^
|
||||
* |
|
||||
*
|
||||
* Width (px)
|
||||
*
|
||||
*/
|
||||
void gfx_drawGPSgraph(point_t start,
|
||||
uint16_t width,
|
||||
uint16_t height,
|
||||
sat_t *sats)
|
||||
{
|
||||
color_t white = {255, 255, 255, 255};
|
||||
color_t yellow = {250, 180, 19 , 255};
|
||||
color_t red = {255, 0, 0 , 255};
|
||||
char id_buf[5] = { 0 };
|
||||
|
||||
// SNR Bars and satellite identifiers
|
||||
uint8_t bar_width = (width - 26) / 12;
|
||||
uint8_t bar_height = 1;
|
||||
for(int i = 0; i < 12; i++)
|
||||
{
|
||||
bar_height = (height - 8) * sats[i].snr / 100 + 1;
|
||||
point_t bar_pos = {start.x + 2 + i * (bar_width + 2),
|
||||
start.y + (height - 8) - bar_height};
|
||||
gfx_drawRect(bar_pos, bar_width, bar_height, white, true);
|
||||
snprintf(id_buf, 5, "%2d ", sats[i].id);
|
||||
point_t id_start = {bar_pos.x, start.y + height};
|
||||
gfx_print(id_start, id_buf, FONT_SIZE_5PT, TEXT_ALIGN_LEFT, white);
|
||||
}
|
||||
uint8_t bars_width = 9 + 11 * (bar_width + 2);
|
||||
point_t left_line_end = {start.x, start.y + height - 9};
|
||||
point_t right_line_start = {start.x + bars_width, start.y};
|
||||
point_t right_line_end = {start.x + bars_width, start.y + height - 9};
|
||||
gfx_drawLine(start, left_line_end, white);
|
||||
gfx_drawLine(right_line_start, right_line_end, white);
|
||||
}
|
||||
|
|
|
@ -233,8 +233,9 @@ void _ui_drawMenuContacts(ui_state_t* ui_state)
|
|||
void _ui_drawMenuGPS(ui_state_t* ui_state)
|
||||
{
|
||||
char *fix_buf, *type_buf;
|
||||
char lat_buf[12] = { 0 }, lon_buf[12] = { 0 };
|
||||
char data_buf[18] = { 0 }, track_buf[8] = { 0 };
|
||||
char lat_buf[12] = { 0 };
|
||||
char lon_buf[12] = { 0 };
|
||||
char data_buf[25] = { 0 };
|
||||
gfx_clearScreen();
|
||||
// Print "GPS" on top bar
|
||||
gfx_print(layout.top_pos, "GPS", layout.top_font,
|
||||
|
@ -288,16 +289,17 @@ void _ui_drawMenuGPS(ui_state_t* ui_state)
|
|||
snprintf(lon_buf, 12, "%8.6f", last_state.gps_data.longitude);
|
||||
gfx_print(layout.line2_pos, lon_buf, layout.top_font, TEXT_ALIGN_RIGHT,
|
||||
color_white);
|
||||
snprintf(data_buf, 18, "S %5.2fkm/h\nA %5.2fm",
|
||||
snprintf(data_buf, 25, "S %5.2fkm/h A %5.2fm",
|
||||
last_state.gps_data.speed,
|
||||
last_state.gps_data.altitude);
|
||||
gfx_print(layout.line3_pos, data_buf, layout.top_font, TEXT_ALIGN_LEFT,
|
||||
color_white);
|
||||
snprintf(track_buf, 8, "%d/%d",
|
||||
last_state.gps_data.satellites_tracked,
|
||||
last_state.gps_data.satellites_in_view);
|
||||
gfx_print(layout.line3_pos, track_buf, layout.line3_font, TEXT_ALIGN_RIGHT,
|
||||
gfx_print(layout.bottom_pos, data_buf, layout.bottom_font, TEXT_ALIGN_CENTER,
|
||||
color_white);
|
||||
// Draw satellites bar graph
|
||||
point_t bar_pos = {layout.line3_pos.x + SCREEN_WIDTH * 1 / 3, SCREEN_HEIGHT / 2};
|
||||
gfx_drawGPSgraph(bar_pos,
|
||||
(SCREEN_WIDTH * 2 / 3) - layout.horizontal_pad,
|
||||
SCREEN_HEIGHT / 3,
|
||||
last_state.gps_data.satellites);
|
||||
}
|
||||
|
||||
void _ui_drawMenuSettings(ui_state_t* ui_state)
|
||||
|
|
Ładowanie…
Reference in New Issue