kopia lustrzana https://github.com/OpenRTX/OpenRTX
Add GPS compass stub
rodzic
c7e8a258f3
commit
586b524625
|
@ -204,6 +204,7 @@ void gfx_drawVLine(uint16_t x, uint16_t width, color_t color);
|
|||
|
||||
/**
|
||||
* Draw a rectangle of specified width, height and color.
|
||||
* @param start: screen position of the rectangle, in pixels
|
||||
* @param width: rectangle width, in pixels, borders included.
|
||||
* @param height: rectangle height, in pixels, borders included.
|
||||
* @param color: border and fill color, in color_t format.
|
||||
|
@ -211,6 +212,14 @@ void gfx_drawVLine(uint16_t x, uint16_t width, color_t color);
|
|||
*/
|
||||
void gfx_drawRect(point_t start, uint16_t width, uint16_t height, color_t color, bool fill);
|
||||
|
||||
/**
|
||||
* Draw the outline of a circle of specified radius and color.
|
||||
* @param start: screen position of the center of the circle, in pixels
|
||||
* @param r: circle radius, in pixels, border included.
|
||||
* @param color: border color, in color_t format.
|
||||
*/
|
||||
void gfx_drawCircle(point_t start, uint16_t r, color_t color);
|
||||
|
||||
/**
|
||||
* Prints text on the screen.
|
||||
* @param start: text line start point, in pixel coordinates.
|
||||
|
@ -261,4 +270,13 @@ void gfx_drawSmeter(point_t start, uint16_t width, uint16_t height, float rssi,
|
|||
*/
|
||||
void gfx_drawGPSgraph(point_t start, uint16_t width, uint16_t height, sat_t *sats);
|
||||
|
||||
/**
|
||||
* Function to draw a compass of arbitrary size.
|
||||
* Starting coordinates are relative to the top left point.
|
||||
* @param start: Compass start point, in pixel coordinates.
|
||||
* @param width: Compass radius
|
||||
* @param sats: pointer to the array of satellites data
|
||||
*/
|
||||
void gfx_drawGPScompass(point_t start, uint16_t radius, sat_t *sats);
|
||||
|
||||
#endif /* GRAPHICS_H */
|
||||
|
|
|
@ -228,6 +228,65 @@ void gfx_drawRect(point_t start, uint16_t width, uint16_t height, color_t color,
|
|||
}
|
||||
}
|
||||
|
||||
void gfx_drawCircle(point_t start, uint16_t r, color_t color)
|
||||
{
|
||||
int16_t f = 1 - r;
|
||||
int16_t ddF_x = 1;
|
||||
int16_t ddF_y = -2 * r;
|
||||
int16_t x = 0;
|
||||
int16_t y = r;
|
||||
|
||||
point_t pos = start;
|
||||
pos.y += r;
|
||||
gfx_setPixel(pos, color);
|
||||
pos.y -= 2 * r;
|
||||
gfx_setPixel(pos, color);
|
||||
pos.y += r;
|
||||
pos.x += r;
|
||||
gfx_setPixel(pos, color);
|
||||
pos.x -= 2 * r;
|
||||
gfx_setPixel(pos, color);
|
||||
|
||||
while (x < y)
|
||||
{
|
||||
if (f >= 0)
|
||||
{
|
||||
y--;
|
||||
ddF_y += 2;
|
||||
f += ddF_y;
|
||||
}
|
||||
|
||||
x++;
|
||||
ddF_x += 2;
|
||||
f += ddF_x;
|
||||
|
||||
pos.x = start.x + x;
|
||||
pos.y = start.y + y;
|
||||
gfx_setPixel(pos, color);
|
||||
pos.x = start.x - x;
|
||||
pos.y = start.y + y;
|
||||
gfx_setPixel(pos, color);
|
||||
pos.x = start.x + x;
|
||||
pos.y = start.y - y;
|
||||
gfx_setPixel(pos, color);
|
||||
pos.x = start.x - x;
|
||||
pos.y = start.y - y;
|
||||
gfx_setPixel(pos, color);
|
||||
pos.x = start.x + y;
|
||||
pos.y = start.y + x;
|
||||
gfx_setPixel(pos, color);
|
||||
pos.x = start.x - y;
|
||||
pos.y = start.y + x;
|
||||
gfx_setPixel(pos, color);
|
||||
pos.x = start.x + y;
|
||||
pos.y = start.y - x;
|
||||
gfx_setPixel(pos, color);
|
||||
pos.x = start.x - y;
|
||||
pos.y = start.y - x;
|
||||
gfx_setPixel(pos, color);
|
||||
}
|
||||
}
|
||||
|
||||
void gfx_drawHLine(uint16_t y, uint16_t height, color_t color)
|
||||
{
|
||||
point_t start = {0, y};
|
||||
|
@ -568,3 +627,15 @@ void gfx_drawGPSgraph(point_t start,
|
|||
gfx_drawLine(start, left_line_end, white);
|
||||
gfx_drawLine(right_line_start, right_line_end, white);
|
||||
}
|
||||
|
||||
void gfx_drawGPScompass(point_t start,
|
||||
uint16_t radius,
|
||||
sat_t *sats)
|
||||
{
|
||||
color_t white = {255, 255, 255, 255};
|
||||
|
||||
point_t n_pos = {start.x + radius, start.y + 3};
|
||||
gfx_print(n_pos, "N", FONT_SIZE_5PT, TEXT_ALIGN_LEFT, white);
|
||||
point_t circle_pos = {start.x + radius + 1, start.y + radius + 3};
|
||||
gfx_drawCircle(circle_pos, radius, white);
|
||||
}
|
||||
|
|
|
@ -294,6 +294,9 @@ void _ui_drawMenuGPS(ui_state_t* ui_state)
|
|||
last_state.gps_data.altitude);
|
||||
gfx_print(layout.bottom_pos, data_buf, layout.bottom_font, TEXT_ALIGN_CENTER,
|
||||
color_white);
|
||||
// Draw compass
|
||||
point_t compass_pos = {layout.horizontal_pad * 2, SCREEN_HEIGHT / 2};
|
||||
gfx_drawGPScompass(compass_pos, SCREEN_WIDTH / 9, last_state.gps_data.satellites);
|
||||
// Draw satellites bar graph
|
||||
point_t bar_pos = {layout.line3_pos.x + SCREEN_WIDTH * 1 / 3, SCREEN_HEIGHT / 2};
|
||||
gfx_drawGPSgraph(bar_pos,
|
||||
|
|
Ładowanie…
Reference in New Issue