2 * This file is part of Cleanflight.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
23 #include "common/utils.h"
25 #include "drivers/display.h"
26 #include "drivers/display_ug2864hsweg01.h"
28 static displayPort_t oledDisplayPort
;
30 static int oledGrab(displayPort_t
*displayPort
)
36 static int oledRelease(displayPort_t
*displayPort
)
42 static int oledClearScreen(displayPort_t
*displayPort
)
45 i2c_OLED_clear_display_quick();
49 static int oledDrawScreen(displayPort_t
*displayPort
)
55 static int oledScreenSize(const displayPort_t
*displayPort
)
57 return displayPort
->rows
* displayPort
->cols
;
60 static int oledWriteString(displayPort_t
*displayPort
, uint8_t x
, uint8_t y
, const char *s
, textAttributes_t attr
)
64 i2c_OLED_set_xy(x
, y
);
65 i2c_OLED_send_string(s
);
69 static int oledWriteChar(displayPort_t
*displayPort
, uint8_t x
, uint8_t y
, uint16_t c
, textAttributes_t attr
)
73 i2c_OLED_set_xy(x
, y
);
74 i2c_OLED_send_char(c
);
78 static bool oledIsTransferInProgress(const displayPort_t
*displayPort
)
84 static int oledHeartbeat(displayPort_t
*displayPort
)
90 static void oledResync(displayPort_t
*displayPort
)
95 static uint32_t oledTxBytesFree(const displayPort_t
*displayPort
)
101 static const displayPortVTable_t oledVTable
= {
103 .release
= oledRelease
,
104 .clearScreen
= oledClearScreen
,
105 .drawScreen
= oledDrawScreen
,
106 .screenSize
= oledScreenSize
,
107 .writeString
= oledWriteString
,
108 .writeChar
= oledWriteChar
,
110 .isTransferInProgress
= oledIsTransferInProgress
,
111 .heartbeat
= oledHeartbeat
,
112 .resync
= oledResync
,
113 .txBytesFree
= oledTxBytesFree
,
114 .supportedTextAttributes
= NULL
,
117 displayPort_t
*displayPortOledInit(void)
119 displayInit(&oledDisplayPort
, &oledVTable
);
120 oledDisplayPort
.rows
= SCREEN_CHARACTER_ROW_COUNT
;
121 oledDisplayPort
.cols
= SCREEN_CHARACTER_COLUMN_COUNT
;
122 return &oledDisplayPort
;