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/>.
26 #if defined (USE_HOTT_TEXTMODE) && defined (USE_CMS)
28 #include "common/utils.h"
30 #include "telemetry/hott.h"
32 displayPort_t hottDisplayPort
;
34 static bool hottDrawScreen(displayPort_t
*displayPort
)
40 static int hottScreenSize(const displayPort_t
*displayPort
)
42 return displayPort
->rows
* displayPort
->cols
;
45 static int hottWriteChar(displayPort_t
*displayPort
, uint8_t col
, uint8_t row
, uint8_t attr
, uint8_t c
)
50 hottTextmodeWriteChar(col
, row
, c
);
54 static int hottWriteString(displayPort_t
*displayPort
, uint8_t col
, uint8_t row
, uint8_t attr
, const char *s
)
59 hottWriteChar(displayPort
, col
++, row
, DISPLAYPORT_ATTR_NONE
, *(s
++));
64 static int hottClearScreen(displayPort_t
*displayPort
)
66 for (int row
= 0; row
< displayPort
->rows
; row
++) {
67 for (int col
= 0; col
< displayPort
->cols
; col
++) {
68 hottWriteChar(displayPort
, col
, row
, DISPLAYPORT_ATTR_NONE
, ' ');
74 static bool hottIsTransferInProgress(const displayPort_t
*displayPort
)
80 static int hottHeartbeat(displayPort_t
*displayPort
)
82 if (!hottTextmodeIsAlive()) {
83 cmsMenuExit(displayPort
, (void*)CMS_EXIT_SAVE
);
89 static void hottRedraw(displayPort_t
*displayPort
)
94 static uint32_t hottTxBytesFree(const displayPort_t
*displayPort
)
100 static int hottGrab(displayPort_t
*displayPort
)
103 return displayPort
->grabCount
= 1;
106 static int hottRelease(displayPort_t
*displayPort
)
108 int cnt
= displayPort
->grabCount
= 0;
109 hottClearScreen(displayPort
);
114 static const displayPortVTable_t hottVTable
= {
116 .release
= hottRelease
,
117 .clearScreen
= hottClearScreen
,
118 .drawScreen
= hottDrawScreen
,
119 .screenSize
= hottScreenSize
,
120 .writeString
= hottWriteString
,
121 .writeChar
= hottWriteChar
,
122 .isTransferInProgress
= hottIsTransferInProgress
,
123 .heartbeat
= hottHeartbeat
,
124 .redraw
= hottRedraw
,
125 .txBytesFree
= hottTxBytesFree
,
126 .layerSupported
= NULL
,
131 static displayPort_t
*displayPortHottInit()
133 hottDisplayPort
.device
= NULL
;
134 displayInit(&hottDisplayPort
, &hottVTable
, DISPLAYPORT_DEVICE_TYPE_HOTT
);
135 hottDisplayPort
.useFullscreen
= true;
136 hottDisplayPort
.rows
= HOTT_TEXTMODE_DISPLAY_ROWS
;
137 hottDisplayPort
.cols
= HOTT_TEXTMODE_DISPLAY_COLUMNS
;
138 return &hottDisplayPort
;
141 void hottDisplayportRegister()
143 cmsDisplayPortRegister(displayPortHottInit());
149 cmsDisplayPortSelect(&hottDisplayPort
);
154 void hottSetCmsKey(uint8_t hottKey
, bool keepCmsOpen
)
157 case HOTTV4_BUTTON_DEC
:
158 cmsSetExternKey(CMS_KEY_UP
);
160 case HOTTV4_BUTTON_INC
:
161 cmsSetExternKey(CMS_KEY_DOWN
);
163 case HOTTV4_BUTTON_SET
:
165 cmsMenuExit(pCurrentDisplay
, (void*)CMS_EXIT_SAVE
);
167 cmsSetExternKey(CMS_KEY_NONE
);
169 case HOTTV4_BUTTON_NEXT
:
170 cmsSetExternKey(CMS_KEY_RIGHT
);
172 case HOTTV4_BUTTON_PREV
:
173 cmsSetExternKey(CMS_KEY_LEFT
);
174 if (keepCmsOpen
) { // Make sure CMS is open until textmode is closed.
179 cmsSetExternKey(CMS_KEY_NONE
);