Initial coding
[inav.git] / src / main / drivers / osd.h
blob668d8231e6bb5b193abf15b0ff40182012793723
1 /*
2 * This file is part of Cleanflight, Betaflight and INAV
4 * Cleanflight, Betaflight and INAV are free software. You can
5 * redistribute this software and/or modify this software under
6 * the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License,
8 * or (at your option) any later version.
10 * Cleanflight, Betaflight and INAV are distributed in the hope that
11 * they will be useful, but WITHOUT ANY WARRANTY; without even the
12 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 * PURPOSE. See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
21 #pragma once
23 #include <stdint.h>
25 #include "common/utils.h"
27 #define OSD_CHAR_WIDTH 12
28 #define OSD_CHAR_HEIGHT 18
29 #define OSD_CHAR_BITS_PER_PIXEL 2
30 #define OSD_CHAR_VISIBLE_BYTES (OSD_CHAR_WIDTH * OSD_CHAR_HEIGHT * OSD_CHAR_BITS_PER_PIXEL / 8)
31 // Only the first 54 bytes of a character represent visible data. However, some OSD drivers
32 // accept 64 bytes and use the extra 10 bytes for metadata.
33 #define OSD_CHAR_BYTES 64
35 #define OSD_CHARACTER_COLOR_BLACK 0
36 #define OSD_CHARACTER_COLOR_TRANSPARENT 1
37 #define OSD_CHARACTER_COLOR_WHITE 2
39 // 3 is unused but it's interpreted as transparent by all drivers
41 typedef struct displayCanvas_s displayCanvas_t;
43 // Video Character Display parameters
45 typedef enum {
46 VIDEO_SYSTEM_AUTO = 0,
47 VIDEO_SYSTEM_PAL,
48 VIDEO_SYSTEM_NTSC,
49 VIDEO_SYSTEM_HDZERO,
50 VIDEO_SYSTEM_DJIWTF,
51 VIDEO_SYSTEM_AVATAR
52 } videoSystem_e;
54 typedef enum {
55 OSD_DRIVER_NONE = 0,
56 OSD_DRIVER_MAX7456 = 1,
57 } osdDriver_e;
59 // osdCharacter_t represents the binary data for an OSD
60 // character. All OSD drivers use the same character format
61 // as defined by OSD_CHARACTER_WIDTH, OSD_CHARACTER_HEIGHT
62 // and OSD_CHARACTER_BITS_PER_PIXEL.
63 typedef struct osdCharacter_s {
64 uint8_t data[OSD_CHAR_BYTES];
65 } osdCharacter_t;
67 typedef struct osdUnit_t
69 uint16_t scale; // The scale between the value and the represented unit. e.g. if you're providing cms but you want to draw meters this should be 100 ([0, 1023])
70 uint16_t symbol; // Symbol to append/prepend to the value when it's not scaled [0, 511]
71 uint16_t divisor; // If abs(value) > divisor, divide it by this. e.g. for meters and km you'd set this to 1000 [0, UINT16_MAX)
72 uint16_t divided_symbol; // Symbol to append/prepend to the value when it's divided (e.g. the km symbol) [0, 511]
73 } osdUnit_t;
75 #define OSD_CHARACTER_GRID_MAX_WIDTH 30
76 #define OSD_CHARACTER_GRID_MAX_HEIGHT 16
77 #define OSD_CHARACTER_GRID_BUFFER_SIZE (OSD_CHARACTER_GRID_MAX_WIDTH * OSD_CHARACTER_GRID_MAX_HEIGHT)
79 extern uint16_t osdCharacterGridBuffer[OSD_CHARACTER_GRID_BUFFER_SIZE] ALIGNED(4);
81 // Sets all buffer entries to SYM_BLANK
82 void osdCharacterGridBufferClear(void);
83 void osdGridBufferClearGridRect(int x, int y, int w, int h);
84 void osdGridBufferClearPixelRect(displayCanvas_t *canvas, int x, int y, int w, int h);
86 uint16_t *osdCharacterGridBufferGetEntryPtr(unsigned x, unsigned y);