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/>.
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
;
34 DISPLAYPORT_ATTR_NONE
= 0,
35 DISPLAYPORT_ATTR_INFO
,
36 DISPLAYPORT_ATTR_WARNING
,
37 DISPLAYPORT_ATTR_CRITICAL
,
40 #define DISPLAYPORT_ATTR_BLINK 0x80 // Device local blink bit or'ed into displayPortAttr_e
43 DISPLAYPORT_LAYER_FOREGROUND
,
44 DISPLAYPORT_LAYER_BACKGROUND
,
45 DISPLAYPORT_LAYER_COUNT
,
49 DISPLAY_TRANSACTION_OPT_NONE
= 0,
50 DISPLAY_TRANSACTION_OPT_PROFILED
= 1 << 0,
51 DISPLAY_TRANSACTION_OPT_RESET_DRAWING
= 1 << 1,
52 } displayTransactionOption_e
;
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
;
63 // Display drivers that can perform screen clearing in the background, e.g. via DMA, should do so.
64 // use `displayCheckReady` function to check if the screen clear has been completed.
65 DISPLAY_CLEAR_NONE
= 0,
67 // * when set, the display driver should block until the screen clear has completed, use in synchronous cases
68 // only, e.g. where the screen is cleared and the display is immediately drawn to.
69 // * when NOT set, return immediately and do not block unless screen is a simple operation or cannot
70 // be performed in the background. As with any long delay, waiting can cause task starvation which
71 // can result in RX loss.
72 DISPLAY_CLEAR_WAIT
= 1 << 0,
73 } displayClearOption_e
;
75 struct displayCanvas_s
;
76 struct osdCharacter_s
;
77 struct displayPortVTable_s
;
79 typedef struct displayPort_s
{
80 const struct displayPortVTable_s
*vTable
;
93 // Displayport device capability
96 // The type of display device
97 displayPortDeviceType_e deviceType
;
100 typedef struct displayPortVTable_s
{
101 int (*grab
)(displayPort_t
*displayPort
);
102 int (*release
)(displayPort_t
*displayPort
);
103 int (*clearScreen
)(displayPort_t
*displayPort
, displayClearOption_e options
);
104 bool (*drawScreen
)(displayPort_t
*displayPort
);
105 int (*screenSize
)(const displayPort_t
*displayPort
);
106 int (*writeString
)(displayPort_t
*displayPort
, uint8_t x
, uint8_t y
, uint8_t attr
, const char *text
);
107 int (*writeChar
)(displayPort_t
*displayPort
, uint8_t x
, uint8_t y
, uint8_t attr
, uint8_t c
);
108 bool (*isTransferInProgress
)(const displayPort_t
*displayPort
);
109 int (*heartbeat
)(displayPort_t
*displayPort
);
110 void (*redraw
)(displayPort_t
*displayPort
);
111 bool (*isSynced
)(const displayPort_t
*displayPort
);
112 uint32_t (*txBytesFree
)(const displayPort_t
*displayPort
);
113 bool (*layerSupported
)(displayPort_t
*displayPort
, displayPortLayer_e layer
);
114 bool (*layerSelect
)(displayPort_t
*displayPort
, displayPortLayer_e layer
);
115 bool (*layerCopy
)(displayPort_t
*displayPort
, displayPortLayer_e destLayer
, displayPortLayer_e sourceLayer
);
116 bool (*writeFontCharacter
)(displayPort_t
*instance
, uint16_t addr
, const struct osdCharacter_s
*chr
);
117 bool (*checkReady
)(displayPort_t
*displayPort
, bool rescan
);
118 void (*beginTransaction
)(displayPort_t
*displayPort
, displayTransactionOption_e opts
);
119 void (*commitTransaction
)(displayPort_t
*displayPort
);
120 bool (*getCanvas
)(struct displayCanvas_s
*canvas
, const displayPort_t
*displayPort
);
121 void (*setBackgroundType
)(displayPort_t
*displayPort
, displayPortBackground_e backgroundType
);
122 } displayPortVTable_t
;
124 void displayGrab(displayPort_t
*instance
);
125 void displayRelease(displayPort_t
*instance
);
126 void displayReleaseAll(displayPort_t
*instance
);
127 bool displayIsGrabbed(const displayPort_t
*instance
);
128 void displayClearScreen(displayPort_t
*instance
, displayClearOption_e options
);
129 bool displayDrawScreen(displayPort_t
*instance
);
130 int displayScreenSize(const displayPort_t
*instance
);
131 void displaySetXY(displayPort_t
*instance
, uint8_t x
, uint8_t y
);
132 int displayWrite(displayPort_t
*instance
, uint8_t x
, uint8_t y
, uint8_t attr
, const char *s
);
133 int displayWriteChar(displayPort_t
*instance
, uint8_t x
, uint8_t y
, uint8_t attr
, uint8_t c
);
134 bool displayIsTransferInProgress(const displayPort_t
*instance
);
135 bool displayHeartbeat(displayPort_t
*instance
);
136 void displayRedraw(displayPort_t
*instance
);
137 bool displayIsSynced(const displayPort_t
*instance
);
138 uint16_t displayTxBytesFree(const displayPort_t
*instance
);
139 bool displayWriteFontCharacter(displayPort_t
*instance
, uint16_t addr
, const struct osdCharacter_s
*chr
);
140 bool displayCheckReady(displayPort_t
*instance
, bool rescan
);
141 void displayBeginTransaction(displayPort_t
*instance
, displayTransactionOption_e opts
);
142 void displayCommitTransaction(displayPort_t
*instance
);
143 bool displayGetCanvas(struct displayCanvas_s
*canvas
, const displayPort_t
*instance
);
144 void displayInit(displayPort_t
*instance
, const displayPortVTable_t
*vTable
, displayPortDeviceType_e deviceType
);
145 bool displayLayerSupported(displayPort_t
*instance
, displayPortLayer_e layer
);
146 bool displayLayerSelect(displayPort_t
*instance
, displayPortLayer_e layer
);
147 bool displayLayerCopy(displayPort_t
*instance
, displayPortLayer_e destLayer
, displayPortLayer_e sourceLayer
);
148 void displaySetBackgroundType(displayPort_t
*instance
, displayPortBackground_e backgroundType
);
149 bool displaySupportsOsdSymbols(displayPort_t
*instance
);