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/>.
27 #include "common/utils.h"
31 void displayClearScreen(displayPort_t
*instance
)
33 instance
->vTable
->clearScreen(instance
);
34 instance
->cleared
= true;
35 instance
->cursorRow
= -1;
38 void displayDrawScreen(displayPort_t
*instance
)
40 instance
->vTable
->drawScreen(instance
);
43 int displayScreenSize(const displayPort_t
*instance
)
45 return instance
->vTable
->screenSize(instance
);
48 void displayGrab(displayPort_t
*instance
)
50 instance
->vTable
->grab(instance
);
51 instance
->vTable
->clearScreen(instance
);
52 ++instance
->grabCount
;
55 void displayRelease(displayPort_t
*instance
)
57 instance
->vTable
->release(instance
);
58 --instance
->grabCount
;
61 void displayReleaseAll(displayPort_t
*instance
)
63 instance
->vTable
->release(instance
);
64 instance
->grabCount
= 0;
67 bool displayIsGrabbed(const displayPort_t
*instance
)
69 // can be called before initialised
70 return (instance
&& instance
->grabCount
> 0);
73 void displaySetXY(displayPort_t
*instance
, uint8_t x
, uint8_t y
)
79 int displayWrite(displayPort_t
*instance
, uint8_t x
, uint8_t y
, const char *s
)
81 instance
->posX
= x
+ strlen(s
);
83 return instance
->vTable
->writeString(instance
, x
, y
, s
);
86 int displayWriteChar(displayPort_t
*instance
, uint8_t x
, uint8_t y
, uint8_t c
)
88 instance
->posX
= x
+ 1;
90 return instance
->vTable
->writeChar(instance
, x
, y
, c
);
93 bool displayIsTransferInProgress(const displayPort_t
*instance
)
95 return instance
->vTable
->isTransferInProgress(instance
);
98 bool displayIsSynced(const displayPort_t
*instance
)
100 return instance
->vTable
->isSynced(instance
);
103 void displayHeartbeat(displayPort_t
*instance
)
105 instance
->vTable
->heartbeat(instance
);
108 void displayResync(displayPort_t
*instance
)
110 instance
->vTable
->resync(instance
);
113 uint16_t displayTxBytesFree(const displayPort_t
*instance
)
115 return instance
->vTable
->txBytesFree(instance
);
118 void displayInit(displayPort_t
*instance
, const displayPortVTable_t
*vTable
)
120 instance
->vTable
= vTable
;
121 instance
->vTable
->clearScreen(instance
);
122 instance
->useFullscreen
= false;
123 instance
->cleared
= true;
124 instance
->grabCount
= 0;
125 instance
->cursorRow
= -1;