Fix WS2812 led definition
[inav.git] / src / main / io / osd_common.h
blob0f700c445e4b14a36f79e9669267fac50649a8aa
1 /*
2 * This file is part of INAV.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
6 * You can obtain one at http://mozilla.org/MPL/2.0/.
8 * Alternatively, the contents of this file may be used under the terms
9 * of the GNU General Public License Version 3, as described below:
11 * This file is free software: you may copy, redistribute and/or modify
12 * it under the terms of the GNU General Public License as published by the
13 * Free Software Foundation, either version 3 of the License, or (at your
14 * option) any later version.
16 * This file is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
19 * Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see http://www.gnu.org/licenses/.
24 * @author Alberto Garcia Hierro <alberto@garciahierro.com>
27 #pragma once
29 #include <stdbool.h>
30 #include <stdint.h>
32 #include "config/parameter_group.h"
34 #if defined(USE_OSD) || defined(USE_DJI_HD_OSD)
36 typedef enum {
37 OSD_SPEED_SOURCE_GROUND = 0,
38 OSD_SPEED_SOURCE_3D = 1,
39 OSD_SPEED_SOURCE_AIR = 2
40 } osdSpeedSource_e;
42 typedef struct {
43 osdSpeedSource_e speedSource;
44 } osdCommonConfig_t;
46 PG_DECLARE(osdCommonConfig_t, osdCommonConfig);
48 int16_t osdGetSpeedFromSelectedSource(void);
50 #endif // defined(USE_OSD) || defined(USE_DJI_HD_OSD)
52 #define OSD_VARIO_CM_S_PER_ARROW 50 // 1 arrow = 50cm/s
53 #define OSD_VARIO_HEIGHT_ROWS 5
55 #define OSD_AHI_HEIGHT 9
56 #define OSD_AHI_WIDTH 11
57 #define OSD_AHI_PREV_SIZE (OSD_AHI_WIDTH > OSD_AHI_HEIGHT ? OSD_AHI_WIDTH : OSD_AHI_HEIGHT)
58 #define OSD_AHI_H_SYM_COUNT 9
59 #define OSD_AHI_V_SYM_COUNT 6
61 #define OSD_HEADING_GRAPH_WIDTH 9
62 #define OSD_HEADING_GRAPH_DECIDEGREES_PER_CHAR 225
64 #define OSD_AH_SIDEBAR_WIDTH_POS 7
65 #define OSD_AH_SIDEBAR_HEIGHT_POS 3
67 typedef struct displayPort_s displayPort_t;
68 typedef struct displayCanvas_s displayCanvas_t;
70 typedef enum {
71 OSD_DRAW_POINT_TYPE_GRID,
72 OSD_DRAW_POINT_TYPE_PIXEL,
73 } osdDrawPointType_e;
75 typedef struct osdDrawPoint_s {
76 osdDrawPointType_e type;
77 union {
78 struct {
79 uint8_t gx;
80 uint8_t gy;
81 } grid;
82 struct {
83 int16_t px;
84 int16_t py;
85 } pixel;
87 } osdDrawPoint_t;
89 #define OSD_DRAW_POINT_GRID(_x, _y) (&(osdDrawPoint_t){ .type = OSD_DRAW_POINT_TYPE_GRID, .grid = {.gx = (_x), .gy = (_y)}})
90 #define OSD_DRAW_POINT_PIXEL(_x, _y) (&(osdDrawPoint_t){ .type = OSD_DRAW_POINT_TYPE_PIXEL, .pixel = {.px = (_x), .py = (_y)}})
92 void osdDrawPointGetGrid(uint8_t *gx, uint8_t *gy, const displayPort_t *display, const displayCanvas_t *canvas, const osdDrawPoint_t *p);
93 void osdDrawPointGetPixels(int *px, int *py, const displayPort_t *display, const displayCanvas_t *canvas, const osdDrawPoint_t *p);
95 void osdDrawVario(displayPort_t *display, displayCanvas_t *canvas, const osdDrawPoint_t *p, float zvel);
96 // Draws an arrow at the given point, where 0 degrees points to the top of the viewport and
97 // positive angles result in clockwise rotation. If eraseBefore is true, the rect surrouing
98 // the arrow will be erased first (need for e.g. the home arrow, since it uses multiple symbols)
99 void osdDrawDirArrow(displayPort_t *display, displayCanvas_t *canvas, const osdDrawPoint_t *p, float degrees);
100 void osdDrawArtificialHorizon(displayPort_t *display, displayCanvas_t *canvas, const osdDrawPoint_t *p, float rollAngle, float pitchAngle);
101 // Draws a heading graph with heading given as 0.1 degree steps i.e. [0, 3600). It uses 9 horizontal
102 // grid slots.
103 void osdDrawHeadingGraph(displayPort_t *display, displayCanvas_t *canvas, const osdDrawPoint_t *p, int heading);
104 void osdDrawSidebars(displayPort_t *display, displayCanvas_t *canvas);
106 #ifdef USE_GPS
107 int16_t osdGet3DSpeed(void);
108 #endif