vtx: fix VTX_SETTINGS_POWER_COUNT and add dummy entries to saPowerNames
[inav.git] / src / main / io / displayport_srxl.c
blob8c73be1ae5220003f2e47ec1001d44f0814d2684
1 /*
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)
8 * any later version.
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/>.
21 #include <stdbool.h>
22 #include <stdint.h>
23 #include <string.h>
25 #include "platform.h"
26 #if defined (USE_SPEKTRUM_CMS_TELEMETRY) && defined (USE_CMS) && defined(USE_TELEMETRY_SRXL)
28 #include "common/utils.h"
30 #include "drivers/display.h"
31 #include "cms/cms.h"
33 #include "telemetry/srxl.h"
35 displayPort_t srxlDisplayPort;
37 static int srxlDrawScreen(displayPort_t *displayPort)
39 UNUSED(displayPort);
40 return 0;
43 static int srxlScreenSize(const displayPort_t *displayPort)
45 return displayPort->rows * displayPort->cols;
48 static int srxlWriteChar(displayPort_t *displayPort, uint8_t col, uint8_t row, uint16_t c, textAttributes_t attr)
50 return (spektrumTmTextGenPutChar(col, row, c));
51 UNUSED(displayPort);
52 UNUSED(attr);
56 static int srxlWriteString(displayPort_t *displayPort, uint8_t col, uint8_t row, const char *s, textAttributes_t attr)
58 while (*s) {
59 srxlWriteChar(displayPort, col++, row, *(s++), attr);
61 return 0;
64 static int srxlClearScreen(displayPort_t *displayPort)
66 textAttributes_t attr = 0;
67 for (int row = 0; row < SPEKTRUM_SRXL_TEXTGEN_BUFFER_ROWS; row++) {
68 for (int col= 0; col < SPEKTRUM_SRXL_TEXTGEN_BUFFER_COLS; col++) {
69 srxlWriteChar(displayPort, col, row, ' ', attr);
72 srxlWriteString(displayPort, 1, 0, "INAV", attr);
74 if (displayPort->grabCount == 0) {
75 srxlWriteString(displayPort, 0, 2, CMS_STARTUP_HELP_TEXT1, attr);
76 srxlWriteString(displayPort, 2, 3, CMS_STARTUP_HELP_TEXT2, attr);
77 srxlWriteString(displayPort, 2, 4, CMS_STARTUP_HELP_TEXT3, attr);
79 return 0;
82 static bool srxlIsTransferInProgress(const displayPort_t *displayPort)
84 UNUSED(displayPort);
85 return false;
89 static bool srxlIsSynced(const displayPort_t *displayPort)
91 UNUSED(displayPort);
92 return true;
96 static int srxlHeartbeat(displayPort_t *displayPort)
98 UNUSED(displayPort);
99 return 0;
102 static void srxlResync(displayPort_t *displayPort)
104 UNUSED(displayPort);
107 static uint32_t srxlTxBytesFree(const displayPort_t *displayPort)
109 UNUSED(displayPort);
110 return UINT32_MAX;
113 static int srxlGrab(displayPort_t *displayPort)
115 return displayPort->grabCount = 1;
118 static int srxlRelease(displayPort_t *displayPort)
120 int cnt = displayPort->grabCount = 0;
121 srxlClearScreen(displayPort);
122 return cnt;
125 static const displayPortVTable_t srxlVTable = {
126 .grab = srxlGrab,
127 .release = srxlRelease,
128 .clearScreen = srxlClearScreen,
129 .drawScreen = srxlDrawScreen,
130 .screenSize = srxlScreenSize,
131 .writeString = srxlWriteString,
132 .writeChar = srxlWriteChar,
133 .isTransferInProgress = srxlIsTransferInProgress,
134 .heartbeat = srxlHeartbeat,
135 .resync = srxlResync,
136 //.isSynced = srxlIsSynced,
137 .txBytesFree = srxlTxBytesFree,
138 //.layerSupported = NULL,
139 //.layerSelect = NULL,
140 //.layerCopy = NULL,
143 displayPort_t *displayPortSrxlInit(void)
145 srxlDisplayPort.device = NULL;
146 displayInit(&srxlDisplayPort, &srxlVTable);
147 srxlDisplayPort.rows = SPEKTRUM_SRXL_TEXTGEN_BUFFER_ROWS;
148 srxlDisplayPort.cols = SPEKTRUM_SRXL_TEXTGEN_BUFFER_COLS;
149 return &srxlDisplayPort;
152 #endif