mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 01:05:27 +03:00
Significantly reduces the time the OSD task spends drawing elements that are completely or mostly static. The larger the element the more time savings are realized. Currently implemented support for: - Crosshairs - Artificial Horizon Sidebars - Craft name - Display name - Stick overlay Since the static portions are only rendered once, the static elements add no processing time to the OSD task. As an example, enabling the above elements prior to these changes results in a total rendering time of 47us. After the enhancements they take only 6us (basically the rendering phase minimum overhead). So effectively 41us are removed from the OSD task. Opens the possibility to add large mostly static elements with no additional overhead. An example would be a camera framing element that might draw a "box" around most of the screen. Previously this would add significant processing overhead to the OSD task, but now it will have no impact.
130 lines
3.2 KiB
C
130 lines
3.2 KiB
C
/*
|
|
* This file is part of Cleanflight and Betaflight.
|
|
*
|
|
* Cleanflight and Betaflight are free software. You can redistribute
|
|
* this software and/or modify this software under the terms of the
|
|
* GNU General Public License as published by the Free Software
|
|
* Foundation, either version 3 of the License, or (at your option)
|
|
* any later version.
|
|
*
|
|
* Cleanflight and Betaflight are distributed in the hope that they
|
|
* will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
* See the GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this software.
|
|
*
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
#include "platform.h"
|
|
|
|
#include "common/utils.h"
|
|
|
|
#include "drivers/display.h"
|
|
#include "drivers/display_ug2864hsweg01.h"
|
|
|
|
static displayPort_t oledDisplayPort;
|
|
|
|
static int oledGrab(displayPort_t *displayPort)
|
|
{
|
|
UNUSED(displayPort);
|
|
return 0;
|
|
}
|
|
|
|
static int oledRelease(displayPort_t *displayPort)
|
|
{
|
|
UNUSED(displayPort);
|
|
return 0;
|
|
}
|
|
|
|
static int oledClearScreen(displayPort_t *displayPort)
|
|
{
|
|
i2c_OLED_clear_display_quick(displayPort->device);
|
|
return 0;
|
|
}
|
|
|
|
static int oledDrawScreen(displayPort_t *displayPort)
|
|
{
|
|
UNUSED(displayPort);
|
|
return 0;
|
|
}
|
|
|
|
static int oledScreenSize(const displayPort_t *displayPort)
|
|
{
|
|
return displayPort->rows * displayPort->cols;
|
|
}
|
|
|
|
static int oledWriteString(displayPort_t *displayPort, uint8_t x, uint8_t y, const char *s)
|
|
{
|
|
i2c_OLED_set_xy(displayPort->device, x, y);
|
|
i2c_OLED_send_string(displayPort->device, s);
|
|
return 0;
|
|
}
|
|
|
|
static int oledWriteChar(displayPort_t *displayPort, uint8_t x, uint8_t y, uint8_t c)
|
|
{
|
|
i2c_OLED_set_xy(displayPort->device, x, y);
|
|
i2c_OLED_send_char(displayPort->device, c);
|
|
return 0;
|
|
}
|
|
|
|
static bool oledIsTransferInProgress(const displayPort_t *displayPort)
|
|
{
|
|
UNUSED(displayPort);
|
|
return false;
|
|
}
|
|
|
|
static bool oledIsSynced(const displayPort_t *displayPort)
|
|
{
|
|
UNUSED(displayPort);
|
|
return true;
|
|
}
|
|
|
|
static int oledHeartbeat(displayPort_t *displayPort)
|
|
{
|
|
UNUSED(displayPort);
|
|
return 0;
|
|
}
|
|
|
|
static void oledResync(displayPort_t *displayPort)
|
|
{
|
|
UNUSED(displayPort);
|
|
}
|
|
|
|
static uint32_t oledTxBytesFree(const displayPort_t *displayPort)
|
|
{
|
|
UNUSED(displayPort);
|
|
return UINT32_MAX;
|
|
}
|
|
|
|
static const displayPortVTable_t oledVTable = {
|
|
.grab = oledGrab,
|
|
.release = oledRelease,
|
|
.clearScreen = oledClearScreen,
|
|
.drawScreen = oledDrawScreen,
|
|
.screenSize = oledScreenSize,
|
|
.writeString = oledWriteString,
|
|
.writeChar = oledWriteChar,
|
|
.isTransferInProgress = oledIsTransferInProgress,
|
|
.heartbeat = oledHeartbeat,
|
|
.resync = oledResync,
|
|
.isSynced = oledIsSynced,
|
|
.txBytesFree = oledTxBytesFree,
|
|
.layerSupported = NULL,
|
|
.layerSelect = NULL,
|
|
.layerCopy = NULL,
|
|
};
|
|
|
|
displayPort_t *displayPortOledInit(void *device)
|
|
{
|
|
oledDisplayPort.device = device;
|
|
displayInit(&oledDisplayPort, &oledVTable);
|
|
oledDisplayPort.rows = SCREEN_CHARACTER_ROW_COUNT;
|
|
oledDisplayPort.cols = SCREEN_CHARACTER_COLUMN_COUNT;
|
|
return &oledDisplayPort;
|
|
}
|