Merge pull request #11198 from SteveCEvans/sce_rc2
[betaflight.git] / src / main / drivers / display.h
blob3a287bd197c24335f4ee8040bf1c96524fcd40eb
1 /*
2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
8 * any later version.
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * 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 typedef enum {
24 DISPLAYPORT_DEVICE_TYPE_MAX7456 = 0,
25 DISPLAYPORT_DEVICE_TYPE_OLED,
26 DISPLAYPORT_DEVICE_TYPE_MSP,
27 DISPLAYPORT_DEVICE_TYPE_FRSKYOSD,
28 DISPLAYPORT_DEVICE_TYPE_CRSF,
29 DISPLAYPORT_DEVICE_TYPE_HOTT,
30 DISPLAYPORT_DEVICE_TYPE_SRXL,
31 } displayPortDeviceType_e;
33 typedef enum {
34 DISPLAYPORT_ATTR_NONE = 0,
35 DISPLAYPORT_ATTR_INFO,
36 DISPLAYPORT_ATTR_WARNING,
37 DISPLAYPORT_ATTR_CRITICAL,
38 } displayPortAttr_e;
40 #define DISPLAYPORT_ATTR_BLINK 0x80 // Device local blink bit or'ed into displayPortAttr_e
42 typedef enum {
43 DISPLAYPORT_LAYER_FOREGROUND,
44 DISPLAYPORT_LAYER_BACKGROUND,
45 DISPLAYPORT_LAYER_COUNT,
46 } displayPortLayer_e;
48 typedef enum {
49 DISPLAY_TRANSACTION_OPT_NONE = 0,
50 DISPLAY_TRANSACTION_OPT_PROFILED = 1 << 0,
51 DISPLAY_TRANSACTION_OPT_RESET_DRAWING = 1 << 1,
52 } displayTransactionOption_e;
54 typedef enum {
55 DISPLAY_BACKGROUND_TRANSPARENT,
56 DISPLAY_BACKGROUND_BLACK,
57 DISPLAY_BACKGROUND_GRAY,
58 DISPLAY_BACKGROUND_LTGRAY,
59 DISPLAY_BACKGROUND_COUNT // must be the last entry
60 } displayPortBackground_e;
62 struct displayCanvas_s;
63 struct osdCharacter_s;
64 struct displayPortVTable_s;
66 typedef struct displayPort_s {
67 const struct displayPortVTable_s *vTable;
68 void *device;
69 uint8_t rows;
70 uint8_t cols;
71 uint8_t posX;
72 uint8_t posY;
74 // CMS state
75 bool useFullscreen;
76 bool cleared;
77 int8_t cursorRow;
78 int8_t grabCount;
80 // Displayport device capability
81 bool useDeviceBlink;
83 // The type of display device
84 displayPortDeviceType_e deviceType;
85 } displayPort_t;
87 typedef struct displayPortVTable_s {
88 int (*grab)(displayPort_t *displayPort);
89 int (*release)(displayPort_t *displayPort);
90 int (*clearScreen)(displayPort_t *displayPort);
91 bool (*drawScreen)(displayPort_t *displayPort);
92 int (*screenSize)(const displayPort_t *displayPort);
93 int (*writeString)(displayPort_t *displayPort, uint8_t x, uint8_t y, uint8_t attr, const char *text);
94 int (*writeChar)(displayPort_t *displayPort, uint8_t x, uint8_t y, uint8_t attr, uint8_t c);
95 bool (*isTransferInProgress)(const displayPort_t *displayPort);
96 int (*heartbeat)(displayPort_t *displayPort);
97 void (*redraw)(displayPort_t *displayPort);
98 bool (*isSynced)(const displayPort_t *displayPort);
99 uint32_t (*txBytesFree)(const displayPort_t *displayPort);
100 bool (*layerSupported)(displayPort_t *displayPort, displayPortLayer_e layer);
101 bool (*layerSelect)(displayPort_t *displayPort, displayPortLayer_e layer);
102 bool (*layerCopy)(displayPort_t *displayPort, displayPortLayer_e destLayer, displayPortLayer_e sourceLayer);
103 bool (*writeFontCharacter)(displayPort_t *instance, uint16_t addr, const struct osdCharacter_s *chr);
104 bool (*checkReady)(displayPort_t *displayPort, bool rescan);
105 void (*beginTransaction)(displayPort_t *displayPort, displayTransactionOption_e opts);
106 void (*commitTransaction)(displayPort_t *displayPort);
107 bool (*getCanvas)(struct displayCanvas_s *canvas, const displayPort_t *displayPort);
108 void (*setBackgroundType)(displayPort_t *displayPort, displayPortBackground_e backgroundType);
109 } displayPortVTable_t;
111 void displayGrab(displayPort_t *instance);
112 void displayRelease(displayPort_t *instance);
113 void displayReleaseAll(displayPort_t *instance);
114 bool displayIsGrabbed(const displayPort_t *instance);
115 void displayClearScreen(displayPort_t *instance);
116 bool displayDrawScreen(displayPort_t *instance);
117 int displayScreenSize(const displayPort_t *instance);
118 void displaySetXY(displayPort_t *instance, uint8_t x, uint8_t y);
119 int displayWrite(displayPort_t *instance, uint8_t x, uint8_t y, uint8_t attr, const char *s);
120 int displayWriteChar(displayPort_t *instance, uint8_t x, uint8_t y, uint8_t attr, uint8_t c);
121 bool displayIsTransferInProgress(const displayPort_t *instance);
122 bool displayHeartbeat(displayPort_t *instance);
123 void displayRedraw(displayPort_t *instance);
124 bool displayIsSynced(const displayPort_t *instance);
125 uint16_t displayTxBytesFree(const displayPort_t *instance);
126 bool displayWriteFontCharacter(displayPort_t *instance, uint16_t addr, const struct osdCharacter_s *chr);
127 bool displayCheckReady(displayPort_t *instance, bool rescan);
128 void displayBeginTransaction(displayPort_t *instance, displayTransactionOption_e opts);
129 void displayCommitTransaction(displayPort_t *instance);
130 bool displayGetCanvas(struct displayCanvas_s *canvas, const displayPort_t *instance);
131 void displayInit(displayPort_t *instance, const displayPortVTable_t *vTable, displayPortDeviceType_e deviceType);
132 bool displayLayerSupported(displayPort_t *instance, displayPortLayer_e layer);
133 bool displayLayerSelect(displayPort_t *instance, displayPortLayer_e layer);
134 bool displayLayerCopy(displayPort_t *instance, displayPortLayer_e destLayer, displayPortLayer_e sourceLayer);
135 void displaySetBackgroundType(displayPort_t *instance, displayPortBackground_e backgroundType);
136 bool displaySupportsOsdSymbols(displayPort_t *instance);