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)
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/>.
23 #define VIDEO_COLUMNS_SD 30
24 #define VIDEO_LINES_NTSC 13
25 #define VIDEO_LINES_PAL 16
28 DISPLAYPORT_DEVICE_TYPE_MAX7456
= 0,
29 DISPLAYPORT_DEVICE_TYPE_OLED
,
30 DISPLAYPORT_DEVICE_TYPE_MSP
,
31 DISPLAYPORT_DEVICE_TYPE_FRSKYOSD
,
32 DISPLAYPORT_DEVICE_TYPE_CRSF
,
33 DISPLAYPORT_DEVICE_TYPE_HOTT
,
34 DISPLAYPORT_DEVICE_TYPE_SRXL
,
35 } displayPortDeviceType_e
;
38 DISPLAYPORT_SEVERITY_NORMAL
= 0,
39 DISPLAYPORT_SEVERITY_INFO
,
40 DISPLAYPORT_SEVERITY_WARNING
,
41 DISPLAYPORT_SEVERITY_CRITICAL
,
42 DISPLAYPORT_SEVERITY_COUNT
,
43 } displayPortSeverity_e
;
45 #define DISPLAYPORT_BLINK 0x80 // Device local blink bit or'ed into displayPortSeverity_e
47 // System elements rendered by VTX or Goggles
49 DISPLAYPORT_SYS_GOGGLE_VOLTAGE
= 0,
50 DISPLAYPORT_SYS_VTX_VOLTAGE
= 1,
51 DISPLAYPORT_SYS_BITRATE
= 2,
52 DISPLAYPORT_SYS_DELAY
= 3,
53 DISPLAYPORT_SYS_DISTANCE
= 4,
54 DISPLAYPORT_SYS_LQ
= 5,
55 DISPLAYPORT_SYS_GOGGLE_DVR
= 6,
56 DISPLAYPORT_SYS_VTX_DVR
= 7,
57 DISPLAYPORT_SYS_WARNINGS
= 8,
58 DISPLAYPORT_SYS_VTX_TEMP
= 9,
59 DISPLAYPORT_SYS_FAN_SPEED
= 10,
60 DISPLAYPORT_SYS_COUNT
,
61 } displayPortSystemElement_e
;
64 DISPLAYPORT_LAYER_FOREGROUND
,
65 DISPLAYPORT_LAYER_BACKGROUND
,
66 DISPLAYPORT_LAYER_COUNT
,
70 DISPLAY_TRANSACTION_OPT_NONE
= 0,
71 DISPLAY_TRANSACTION_OPT_PROFILED
= 1 << 0,
72 DISPLAY_TRANSACTION_OPT_RESET_DRAWING
= 1 << 1,
73 } displayTransactionOption_e
;
76 DISPLAY_BACKGROUND_TRANSPARENT
,
77 DISPLAY_BACKGROUND_BLACK
,
78 DISPLAY_BACKGROUND_GRAY
,
79 DISPLAY_BACKGROUND_LTGRAY
,
80 DISPLAY_BACKGROUND_COUNT
// must be the last entry
81 } displayPortBackground_e
;
84 // Display drivers that can perform screen clearing in the background, e.g. via DMA, should do so.
85 // use `displayCheckReady` function to check if the screen clear has been completed.
86 DISPLAY_CLEAR_NONE
= 0,
88 // * when set, the display driver should block until the screen clear has completed, use in synchronous cases
89 // only, e.g. where the screen is cleared and the display is immediately drawn to.
90 // * when NOT set, return immediately and do not block unless screen is a simple operation or cannot
91 // be performed in the background. As with any long delay, waiting can cause task starvation which
92 // can result in RX loss.
93 DISPLAY_CLEAR_WAIT
= 1 << 0,
94 } displayClearOption_e
;
96 struct displayCanvas_s
;
97 struct osdCharacter_s
;
98 struct displayPortVTable_s
;
100 typedef struct displayPort_s
{
101 const struct displayPortVTable_s
*vTable
;
114 // Displayport device capability
117 // The type of display device
118 displayPortDeviceType_e deviceType
;
121 typedef struct displayPortVTable_s
{
122 int (*grab
)(displayPort_t
*displayPort
);
123 int (*release
)(displayPort_t
*displayPort
);
124 int (*clearScreen
)(displayPort_t
*displayPort
, displayClearOption_e options
);
125 bool (*drawScreen
)(displayPort_t
*displayPort
);
126 int (*screenSize
)(const displayPort_t
*displayPort
);
127 int (*writeSys
)(displayPort_t
*displayPort
, uint8_t x
, uint8_t y
, displayPortSystemElement_e systemElement
);
128 int (*writeString
)(displayPort_t
*displayPort
, uint8_t x
, uint8_t y
, uint8_t attr
, const char *text
);
129 int (*writeChar
)(displayPort_t
*displayPort
, uint8_t x
, uint8_t y
, uint8_t attr
, uint8_t c
);
130 bool (*isTransferInProgress
)(const displayPort_t
*displayPort
);
131 int (*heartbeat
)(displayPort_t
*displayPort
);
132 void (*redraw
)(displayPort_t
*displayPort
);
133 bool (*isSynced
)(const displayPort_t
*displayPort
);
134 uint32_t (*txBytesFree
)(const displayPort_t
*displayPort
);
135 bool (*layerSupported
)(displayPort_t
*displayPort
, displayPortLayer_e layer
);
136 bool (*layerSelect
)(displayPort_t
*displayPort
, displayPortLayer_e layer
);
137 bool (*layerCopy
)(displayPort_t
*displayPort
, displayPortLayer_e destLayer
, displayPortLayer_e sourceLayer
);
138 bool (*writeFontCharacter
)(displayPort_t
*instance
, uint16_t addr
, const struct osdCharacter_s
*chr
);
139 bool (*checkReady
)(displayPort_t
*displayPort
, bool rescan
);
140 void (*beginTransaction
)(displayPort_t
*displayPort
, displayTransactionOption_e opts
);
141 void (*commitTransaction
)(displayPort_t
*displayPort
);
142 bool (*getCanvas
)(struct displayCanvas_s
*canvas
, const displayPort_t
*displayPort
);
143 void (*setBackgroundType
)(displayPort_t
*displayPort
, displayPortBackground_e backgroundType
);
144 } displayPortVTable_t
;
146 void displayGrab(displayPort_t
*instance
);
147 void displayRelease(displayPort_t
*instance
);
148 void displayReleaseAll(displayPort_t
*instance
);
149 bool displayIsGrabbed(const displayPort_t
*instance
);
150 void displayClearScreen(displayPort_t
*instance
, displayClearOption_e options
);
151 bool displayDrawScreen(displayPort_t
*instance
);
152 int displayScreenSize(const displayPort_t
*instance
);
153 void displaySetXY(displayPort_t
*instance
, uint8_t x
, uint8_t y
);
154 int displaySys(displayPort_t
*instance
, uint8_t x
, uint8_t y
, displayPortSystemElement_e systemElement
);
155 int displayWrite(displayPort_t
*instance
, uint8_t x
, uint8_t y
, uint8_t attr
, const char *text
);
156 int displayWriteChar(displayPort_t
*instance
, uint8_t x
, uint8_t y
, uint8_t attr
, uint8_t c
);
157 bool displayIsTransferInProgress(const displayPort_t
*instance
);
158 bool displayHeartbeat(displayPort_t
*instance
);
159 void displayRedraw(displayPort_t
*instance
);
160 bool displayIsSynced(const displayPort_t
*instance
);
161 uint16_t displayTxBytesFree(const displayPort_t
*instance
);
162 bool displayWriteFontCharacter(displayPort_t
*instance
, uint16_t addr
, const struct osdCharacter_s
*chr
);
163 bool displayCheckReady(displayPort_t
*instance
, bool rescan
);
164 void displayBeginTransaction(displayPort_t
*instance
, displayTransactionOption_e opts
);
165 void displayCommitTransaction(displayPort_t
*instance
);
166 bool displayGetCanvas(struct displayCanvas_s
*canvas
, const displayPort_t
*instance
);
167 void displayInit(displayPort_t
*instance
, const displayPortVTable_t
*vTable
, displayPortDeviceType_e deviceType
);
168 bool displayLayerSupported(displayPort_t
*instance
, displayPortLayer_e layer
);
169 bool displayLayerSelect(displayPort_t
*instance
, displayPortLayer_e layer
);
170 bool displayLayerCopy(displayPort_t
*instance
, displayPortLayer_e destLayer
, displayPortLayer_e sourceLayer
);
171 void displaySetBackgroundType(displayPort_t
*instance
, displayPortBackground_e backgroundType
);
172 bool displaySupportsOsdSymbols(displayPort_t
*instance
);