Merge pull request #3375 from martinbudden/bf_displayport_tidy
Displayport tidy
This commit is contained in:
commit
9028db79c8
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
|
@ -66,13 +67,23 @@ bool displayIsGrabbed(const displayPort_t *instance)
|
|||
return (instance && instance->grabCount > 0);
|
||||
}
|
||||
|
||||
void displaySetXY(displayPort_t *instance, uint8_t x, uint8_t y)
|
||||
{
|
||||
instance->posX = x;
|
||||
instance->posY = y;
|
||||
}
|
||||
|
||||
int displayWrite(displayPort_t *instance, uint8_t x, uint8_t y, const char *s)
|
||||
{
|
||||
return instance->vTable->write(instance, x, y, s);
|
||||
instance->posX = x + strlen(s);
|
||||
instance->posY = y;
|
||||
return instance->vTable->writeString(instance, x, y, s);
|
||||
}
|
||||
|
||||
int displayWriteChar(displayPort_t *instance, uint8_t x, uint8_t y, uint8_t c)
|
||||
{
|
||||
instance->posX = x + 1;
|
||||
instance->posY = y;
|
||||
return instance->vTable->writeChar(instance, x, y, c);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@ typedef struct displayPort_s {
|
|||
void *device;
|
||||
uint8_t rows;
|
||||
uint8_t cols;
|
||||
uint8_t posX;
|
||||
uint8_t posY;
|
||||
|
||||
// CMS state
|
||||
bool cleared;
|
||||
|
@ -36,7 +38,7 @@ typedef struct displayPortVTable_s {
|
|||
int (*clearScreen)(displayPort_t *displayPort);
|
||||
int (*drawScreen)(displayPort_t *displayPort);
|
||||
int (*screenSize)(const displayPort_t *displayPort);
|
||||
int (*write)(displayPort_t *displayPort, uint8_t x, uint8_t y, const char *text);
|
||||
int (*writeString)(displayPort_t *displayPort, uint8_t x, uint8_t y, const char *text);
|
||||
int (*writeChar)(displayPort_t *displayPort, uint8_t x, uint8_t y, uint8_t c);
|
||||
bool (*isTransferInProgress)(const displayPort_t *displayPort);
|
||||
int (*heartbeat)(displayPort_t *displayPort);
|
||||
|
@ -59,6 +61,7 @@ bool displayIsGrabbed(const displayPort_t *instance);
|
|||
void displayClearScreen(displayPort_t *instance);
|
||||
void displayDrawScreen(displayPort_t *instance);
|
||||
int displayScreenSize(const displayPort_t *instance);
|
||||
void displaySetXY(displayPort_t *instance, uint8_t x, uint8_t y);
|
||||
int displayWrite(displayPort_t *instance, uint8_t x, uint8_t y, const char *s);
|
||||
int displayWriteChar(displayPort_t *instance, uint8_t x, uint8_t y, uint8_t c);
|
||||
bool displayIsTransferInProgress(const displayPort_t *instance);
|
||||
|
|
|
@ -95,7 +95,7 @@ static int screenSize(const displayPort_t *displayPort)
|
|||
return maxScreenSize;
|
||||
}
|
||||
|
||||
static int write(displayPort_t *displayPort, uint8_t x, uint8_t y, const char *s)
|
||||
static int writeString(displayPort_t *displayPort, uint8_t x, uint8_t y, const char *s)
|
||||
{
|
||||
UNUSED(displayPort);
|
||||
max7456Write(x, y, s);
|
||||
|
@ -143,7 +143,7 @@ static const displayPortVTable_t max7456VTable = {
|
|||
.clearScreen = clearScreen,
|
||||
.drawScreen = drawScreen,
|
||||
.screenSize = screenSize,
|
||||
.write = write,
|
||||
.writeString = writeString,
|
||||
.writeChar = writeChar,
|
||||
.isTransferInProgress = isTransferInProgress,
|
||||
.heartbeat = heartbeat,
|
||||
|
|
|
@ -100,7 +100,7 @@ static int screenSize(const displayPort_t *displayPort)
|
|||
return displayPort->rows * displayPort->cols;
|
||||
}
|
||||
|
||||
static int write(displayPort_t *displayPort, uint8_t col, uint8_t row, const char *string)
|
||||
static int writeString(displayPort_t *displayPort, uint8_t col, uint8_t row, const char *string)
|
||||
{
|
||||
#define MSP_OSD_MAX_STRING_LENGTH 30 // FIXME move this
|
||||
uint8_t buf[MSP_OSD_MAX_STRING_LENGTH + 4];
|
||||
|
@ -125,7 +125,7 @@ static int writeChar(displayPort_t *displayPort, uint8_t col, uint8_t row, uint8
|
|||
|
||||
buf[0] = c;
|
||||
buf[1] = 0;
|
||||
return write(displayPort, col, row, buf); //!!TODO - check if there is a direct MSP command to do this
|
||||
return writeString(displayPort, col, row, buf); //!!TODO - check if there is a direct MSP command to do this
|
||||
}
|
||||
|
||||
static bool isTransferInProgress(const displayPort_t *displayPort)
|
||||
|
@ -152,7 +152,7 @@ static const displayPortVTable_t mspDisplayPortVTable = {
|
|||
.clearScreen = clearScreen,
|
||||
.drawScreen = drawScreen,
|
||||
.screenSize = screenSize,
|
||||
.write = write,
|
||||
.writeString = writeString,
|
||||
.writeChar = writeChar,
|
||||
.isTransferInProgress = isTransferInProgress,
|
||||
.heartbeat = heartbeat,
|
||||
|
|
|
@ -56,7 +56,7 @@ static int oledScreenSize(const displayPort_t *displayPort)
|
|||
return displayPort->rows * displayPort->cols;
|
||||
}
|
||||
|
||||
static int oledWrite(displayPort_t *displayPort, uint8_t x, uint8_t y, const char *s)
|
||||
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);
|
||||
|
@ -99,7 +99,7 @@ static const displayPortVTable_t oledVTable = {
|
|||
.clearScreen = oledClearScreen,
|
||||
.drawScreen = oledDrawScreen,
|
||||
.screenSize = oledScreenSize,
|
||||
.write = oledWrite,
|
||||
.writeString = oledWriteString,
|
||||
.writeChar = oledWriteChar,
|
||||
.isTransferInProgress = oledIsTransferInProgress,
|
||||
.heartbeat = oledHeartbeat,
|
||||
|
|
|
@ -67,7 +67,7 @@ static int displayPortTestScreenSize(const displayPort_t *displayPort)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int displayPortTestWrite(displayPort_t *displayPort, uint8_t x, uint8_t y, const char *s)
|
||||
static int displayPortTestWriteString(displayPort_t *displayPort, uint8_t x, uint8_t y, const char *s)
|
||||
{
|
||||
UNUSED(displayPort);
|
||||
for (unsigned int i = 0; i < strlen(s); i++) {
|
||||
|
@ -112,7 +112,7 @@ static const displayPortVTable_t testDisplayPortVTable = {
|
|||
.clearScreen = displayPortTestClearScreen,
|
||||
.drawScreen = displayPortTestDrawScreen,
|
||||
.screenSize = displayPortTestScreenSize,
|
||||
.write = displayPortTestWrite,
|
||||
.writeString = displayPortTestWriteString,
|
||||
.writeChar = displayPortTestWriteChar,
|
||||
.isTransferInProgress = displayPortTestIsTransferInProgress,
|
||||
.heartbeat = displayPortTestHeartbeat,
|
||||
|
|
Loading…
Reference in New Issue