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 #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
)
39 static int oledRelease(displayPort_t
*displayPort
)
45 static int oledClearScreen(displayPort_t
*displayPort
, displayClearOption_e options
)
49 i2c_OLED_clear_display_quick(displayPort
->device
);
53 static bool oledDrawScreen(displayPort_t
*displayPort
)
59 static int oledScreenSize(const displayPort_t
*displayPort
)
61 return displayPort
->rows
* displayPort
->cols
;
64 static int oledWriteString(displayPort_t
*displayPort
, uint8_t x
, uint8_t y
, uint8_t attr
, const char *s
)
68 i2c_OLED_set_xy(displayPort
->device
, x
, y
);
69 i2c_OLED_send_string(displayPort
->device
, s
);
73 static int oledWriteChar(displayPort_t
*displayPort
, uint8_t x
, uint8_t y
, uint8_t attr
, uint8_t c
)
77 i2c_OLED_set_xy(displayPort
->device
, x
, y
);
78 i2c_OLED_send_char(displayPort
->device
, c
);
82 static bool oledIsTransferInProgress(const displayPort_t
*displayPort
)
88 static bool oledIsSynced(const displayPort_t
*displayPort
)
94 static int oledHeartbeat(displayPort_t
*displayPort
)
100 static void oledRedraw(displayPort_t
*displayPort
)
105 static uint32_t oledTxBytesFree(const displayPort_t
*displayPort
)
111 static const displayPortVTable_t oledVTable
= {
113 .release
= oledRelease
,
114 .clearScreen
= oledClearScreen
,
115 .drawScreen
= oledDrawScreen
,
116 .screenSize
= oledScreenSize
,
117 .writeString
= oledWriteString
,
118 .writeChar
= oledWriteChar
,
119 .isTransferInProgress
= oledIsTransferInProgress
,
120 .heartbeat
= oledHeartbeat
,
121 .redraw
= oledRedraw
,
122 .isSynced
= oledIsSynced
,
123 .txBytesFree
= oledTxBytesFree
,
124 .layerSupported
= NULL
,
129 displayPort_t
*displayPortOledInit(void *device
)
131 oledDisplayPort
.device
= device
;
132 displayInit(&oledDisplayPort
, &oledVTable
, DISPLAYPORT_DEVICE_TYPE_OLED
);
133 oledDisplayPort
.rows
= SCREEN_CHARACTER_ROW_COUNT
;
134 oledDisplayPort
.cols
= SCREEN_CHARACTER_COLUMN_COUNT
;
135 return &oledDisplayPort
;