Merge pull request #11198 from SteveCEvans/sce_rc2
[betaflight.git] / src / main / io / displayport_oled.c
blob45d76c49e6fd6853765bda79f1d28958a181bd43
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>
24 #include "platform.h"
26 #include "common/utils.h"
28 #include "drivers/display.h"
29 #include "drivers/display_ug2864hsweg01.h"
31 static displayPort_t oledDisplayPort;
33 static int oledGrab(displayPort_t *displayPort)
35 UNUSED(displayPort);
36 return 0;
39 static int oledRelease(displayPort_t *displayPort)
41 UNUSED(displayPort);
42 return 0;
45 static int oledClearScreen(displayPort_t *displayPort)
47 i2c_OLED_clear_display_quick(displayPort->device);
48 return 0;
51 static bool oledDrawScreen(displayPort_t *displayPort)
53 UNUSED(displayPort);
54 return 0;
57 static int oledScreenSize(const displayPort_t *displayPort)
59 return displayPort->rows * displayPort->cols;
62 static int oledWriteString(displayPort_t *displayPort, uint8_t x, uint8_t y, uint8_t attr, const char *s)
64 UNUSED(attr);
66 i2c_OLED_set_xy(displayPort->device, x, y);
67 i2c_OLED_send_string(displayPort->device, s);
68 return 0;
71 static int oledWriteChar(displayPort_t *displayPort, uint8_t x, uint8_t y, uint8_t attr, uint8_t c)
73 UNUSED(attr);
75 i2c_OLED_set_xy(displayPort->device, x, y);
76 i2c_OLED_send_char(displayPort->device, c);
77 return 0;
80 static bool oledIsTransferInProgress(const displayPort_t *displayPort)
82 UNUSED(displayPort);
83 return false;
86 static bool oledIsSynced(const displayPort_t *displayPort)
88 UNUSED(displayPort);
89 return true;
92 static int oledHeartbeat(displayPort_t *displayPort)
94 UNUSED(displayPort);
95 return 0;
98 static void oledRedraw(displayPort_t *displayPort)
100 UNUSED(displayPort);
103 static uint32_t oledTxBytesFree(const displayPort_t *displayPort)
105 UNUSED(displayPort);
106 return UINT32_MAX;
109 static const displayPortVTable_t oledVTable = {
110 .grab = oledGrab,
111 .release = oledRelease,
112 .clearScreen = oledClearScreen,
113 .drawScreen = oledDrawScreen,
114 .screenSize = oledScreenSize,
115 .writeString = oledWriteString,
116 .writeChar = oledWriteChar,
117 .isTransferInProgress = oledIsTransferInProgress,
118 .heartbeat = oledHeartbeat,
119 .redraw = oledRedraw,
120 .isSynced = oledIsSynced,
121 .txBytesFree = oledTxBytesFree,
122 .layerSupported = NULL,
123 .layerSelect = NULL,
124 .layerCopy = NULL,
127 displayPort_t *displayPortOledInit(void *device)
129 oledDisplayPort.device = device;
130 displayInit(&oledDisplayPort, &oledVTable, DISPLAYPORT_DEVICE_TYPE_OLED);
131 oledDisplayPort.rows = SCREEN_CHARACTER_ROW_COUNT;
132 oledDisplayPort.cols = SCREEN_CHARACTER_COLUMN_COUNT;
133 return &oledDisplayPort;