[4.4.2] Remove 15 m/s limit on estimated vario (#12788)
[betaflight.git] / src / main / io / displayport_srxl.c
blobd12767d479ea0645ae86178a0e736fe88be6f426
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"
27 #if defined(USE_SPEKTRUM_CMS_TELEMETRY)
29 #include "cms/cms.h"
31 #include "common/utils.h"
33 #include "drivers/display.h"
35 #include "telemetry/srxl.h"
37 #include "displayport_srxl.h"
39 displayPort_t srxlDisplayPort;
41 static bool srxlDrawScreen(displayPort_t *displayPort)
43 UNUSED(displayPort);
44 return 0;
47 static int srxlScreenSize(const displayPort_t *displayPort)
49 return displayPort->rows * displayPort->cols;
52 static int srxlWriteChar(displayPort_t *displayPort, uint8_t col, uint8_t row, uint8_t attr, uint8_t c)
54 UNUSED(displayPort);
55 UNUSED(attr);
57 return (spektrumTmTextGenPutChar(col, row, c));
61 static int srxlWriteString(displayPort_t *displayPort, uint8_t col, uint8_t row, uint8_t attr, const char *s)
63 while (*s) {
64 srxlWriteChar(displayPort, col++, row, attr, *(s++));
66 return 0;
69 static int srxlClearScreen(displayPort_t *displayPort, displayClearOption_e options)
71 UNUSED(options);
72 for (int row = 0; row < SPEKTRUM_SRXL_TEXTGEN_BUFFER_ROWS; row++) {
73 for (int col= 0; col < SPEKTRUM_SRXL_TEXTGEN_BUFFER_COLS; col++) {
74 srxlWriteChar(displayPort, col, row, DISPLAYPORT_SEVERITY_NORMAL, ' ');
77 srxlWriteString(displayPort, 1, 0, DISPLAYPORT_SEVERITY_NORMAL, "BETAFLIGHT");
79 if (displayPort->grabCount == 0) {
80 srxlWriteString(displayPort, 0, 2, DISPLAYPORT_SEVERITY_NORMAL, CMS_STARTUP_HELP_TEXT1);
81 srxlWriteString(displayPort, 2, 3, DISPLAYPORT_SEVERITY_NORMAL, CMS_STARTUP_HELP_TEXT2);
82 srxlWriteString(displayPort, 2, 4, DISPLAYPORT_SEVERITY_NORMAL, CMS_STARTUP_HELP_TEXT3);
84 return 0;
87 static bool srxlIsTransferInProgress(const displayPort_t *displayPort)
89 UNUSED(displayPort);
90 return false;
93 static bool srxlIsSynced(const displayPort_t *displayPort)
95 UNUSED(displayPort);
96 return true;
99 static int srxlHeartbeat(displayPort_t *displayPort)
101 UNUSED(displayPort);
102 return 0;
105 static void srxlRedraw(displayPort_t *displayPort)
107 UNUSED(displayPort);
110 static uint32_t srxlTxBytesFree(const displayPort_t *displayPort)
112 UNUSED(displayPort);
113 return UINT32_MAX;
116 static int srxlGrab(displayPort_t *displayPort)
118 return displayPort->grabCount = 1;
121 static int srxlRelease(displayPort_t *displayPort)
123 int cnt = displayPort->grabCount = 0;
124 srxlClearScreen(displayPort, DISPLAY_CLEAR_WAIT);
125 return cnt;
128 static const displayPortVTable_t srxlVTable = {
129 .grab = srxlGrab,
130 .release = srxlRelease,
131 .clearScreen = srxlClearScreen,
132 .drawScreen = srxlDrawScreen,
133 .screenSize = srxlScreenSize,
134 .writeString = srxlWriteString,
135 .writeChar = srxlWriteChar,
136 .isTransferInProgress = srxlIsTransferInProgress,
137 .heartbeat = srxlHeartbeat,
138 .redraw = srxlRedraw,
139 .isSynced = srxlIsSynced,
140 .txBytesFree = srxlTxBytesFree,
141 .layerSupported = NULL,
142 .layerSelect = NULL,
143 .layerCopy = NULL,
146 static displayPort_t *displayPortSrxlInit(void)
148 srxlDisplayPort.device = NULL;
149 displayInit(&srxlDisplayPort, &srxlVTable, DISPLAYPORT_DEVICE_TYPE_SRXL);
150 srxlDisplayPort.rows = SPEKTRUM_SRXL_TEXTGEN_BUFFER_ROWS;
151 srxlDisplayPort.cols = SPEKTRUM_SRXL_TEXTGEN_BUFFER_COLS;
153 return &srxlDisplayPort;
156 void srxlDisplayportRegister(void)
158 cmsDisplayPortRegister(displayPortSrxlInit());
160 #endif