2 * This file is part of Cleanflight.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
23 #if defined (USE_HOTT_TEXTMODE) && defined (USE_CMS)
25 #include "common/utils.h"
27 #include "telemetry/hott.h"
29 displayPort_t hottDisplayPort
;
31 static int hottDrawScreen(displayPort_t
*displayPort
)
37 static int hottScreenSize(const displayPort_t
*displayPort
)
39 return displayPort
->rows
* displayPort
->cols
;
42 static int hottWriteChar(displayPort_t
*displayPort
, uint8_t col
, uint8_t row
, uint8_t c
)
46 hottTextmodeWriteChar(col
, row
, c
);
50 static int hottWriteString(displayPort_t
*displayPort
, uint8_t col
, uint8_t row
, const char *s
)
53 hottWriteChar(displayPort
, col
++, row
, *(s
++));
58 static int hottClearScreen(displayPort_t
*displayPort
)
60 for (int row
= 0; row
< displayPort
->rows
; row
++) {
61 for (int col
= 0; col
< displayPort
->cols
; col
++) {
62 hottWriteChar(displayPort
, col
, row
, ' ');
68 static bool hottIsTransferInProgress(const displayPort_t
*displayPort
)
74 static int hottHeartbeat(displayPort_t
*displayPort
)
76 if (!hottTextmodeIsAlive()) {
77 cmsMenuExit(displayPort
, (void*)CMS_EXIT_SAVE
);
83 static void hottResync(displayPort_t
*displayPort
)
88 static uint32_t hottTxBytesFree(const displayPort_t
*displayPort
)
94 static int hottGrab(displayPort_t
*displayPort
)
97 return displayPort
->grabCount
= 1;
100 static int hottRelease(displayPort_t
*displayPort
)
102 int cnt
= displayPort
->grabCount
= 0;
103 hottClearScreen(displayPort
);
108 static const displayPortVTable_t hottVTable
= {
110 .release
= hottRelease
,
111 .clearScreen
= hottClearScreen
,
112 .drawScreen
= hottDrawScreen
,
113 .screenSize
= hottScreenSize
,
114 .writeString
= hottWriteString
,
115 .writeChar
= hottWriteChar
,
116 .isTransferInProgress
= hottIsTransferInProgress
,
117 .heartbeat
= hottHeartbeat
,
118 .resync
= hottResync
,
119 .txBytesFree
= hottTxBytesFree
122 displayPort_t
*displayPortHottInit()
124 hottDisplayPort
.device
= NULL
;
125 displayInit(&hottDisplayPort
, &hottVTable
);
126 hottDisplayPort
.useFullscreen
= true;
127 hottDisplayPort
.rows
= HOTT_TEXTMODE_DISPLAY_ROWS
;
128 hottDisplayPort
.cols
= HOTT_TEXTMODE_DISPLAY_COLUMNS
;
129 return &hottDisplayPort
;
132 void hottDisplayportRegister()
134 cmsDisplayPortRegister(displayPortHottInit());
140 cmsDisplayPortSelect(&hottDisplayPort
);
145 void hottSetCmsKey(uint8_t hottKey
, bool keepCmsOpen
)
148 case HOTTV4_BUTTON_DEC
:
149 cmsSetExternKey(CMS_KEY_UP
);
151 case HOTTV4_BUTTON_INC
:
152 cmsSetExternKey(CMS_KEY_DOWN
);
154 case HOTTV4_BUTTON_SET
:
156 cmsMenuExit(pCurrentDisplay
, (void*)CMS_EXIT_SAVE
);
158 cmsSetExternKey(CMS_KEY_NONE
);
160 case HOTTV4_BUTTON_NEXT
:
161 cmsSetExternKey(CMS_KEY_RIGHT
);
163 case HOTTV4_BUTTON_PREV
:
164 cmsSetExternKey(CMS_KEY_LEFT
);
165 if (keepCmsOpen
) { // Make sure CMS is open until textmode is closed.
170 cmsSetExternKey(CMS_KEY_NONE
);