mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 04:45:24 +03:00
Cleanups
This commit is contained in:
parent
042096fbb7
commit
f58f7f65b1
12 changed files with 94 additions and 91 deletions
|
@ -1778,17 +1778,3 @@ void mspFcInit(void)
|
|||
{
|
||||
initActiveBoxIds();
|
||||
}
|
||||
|
||||
void mspServerPush(mspPacket_t *push, uint8_t *data, int len)
|
||||
{
|
||||
sbuf_t *dst = &push->buf;
|
||||
|
||||
while (len--) {
|
||||
sbufWriteU8(dst, *data++);
|
||||
}
|
||||
}
|
||||
|
||||
mspPushCommandFnPtr mspFcPushInit(void)
|
||||
{
|
||||
return mspServerPush;
|
||||
}
|
||||
|
|
|
@ -21,5 +21,3 @@
|
|||
|
||||
void mspFcInit(void);
|
||||
mspResult_e mspFcProcessCommand(mspPacket_t *cmd, mspPacket_t *reply, mspPostProcessFnPtr *mspPostProcessFn);
|
||||
|
||||
mspPushCommandFnPtr mspFcPushInit(void);
|
||||
|
|
BIN
src/main/io/.canvas.c.swo
Normal file
BIN
src/main/io/.canvas.c.swo
Normal file
Binary file not shown.
|
@ -9,6 +9,8 @@
|
|||
|
||||
#ifdef CANVAS
|
||||
|
||||
#include "common/utils.h"
|
||||
|
||||
#include "drivers/system.h"
|
||||
|
||||
#include "io/cms.h"
|
||||
|
@ -67,32 +69,36 @@ int canvasWrite(uint8_t col, uint8_t row, char *string)
|
|||
return canvasOutput(MSP_CANVAS, (uint8_t *)buf, len + 4);
|
||||
}
|
||||
|
||||
uint16_t canvasTxRoom()
|
||||
void canvasResync(displayPort_t *pPort)
|
||||
{
|
||||
return mspSerialPushTxRoom();
|
||||
pPort->rows = 13; // XXX Will reflect NTSC/PAL in the future
|
||||
pPort->rows = 30;
|
||||
}
|
||||
|
||||
screenFnVTable_t canvasVTable = {
|
||||
uint32_t canvasTxRoom(void)
|
||||
{
|
||||
return mspSerialTxBytesFree();
|
||||
}
|
||||
|
||||
displayPortVTable_t canvasVTable = {
|
||||
canvasBegin,
|
||||
canvasEnd,
|
||||
canvasClear,
|
||||
canvasWrite,
|
||||
canvasHeartBeat,
|
||||
NULL,
|
||||
canvasResync,
|
||||
canvasTxRoom,
|
||||
};
|
||||
|
||||
void canvasCmsInit(displayPort_t *pPort)
|
||||
{
|
||||
pPort->rows = 13;
|
||||
pPort->rows = 13; // XXX Will reflect NTSC/PAL in the future
|
||||
pPort->cols = 30;
|
||||
pPort->vTable = &canvasVTable;
|
||||
}
|
||||
|
||||
void canvasInit()
|
||||
{
|
||||
mspSerialPushInit(mspFcPushInit()); // Called once at startup to initialize push function in msp
|
||||
|
||||
cmsDeviceRegister(canvasCmsInit);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -37,9 +37,7 @@
|
|||
|
||||
#include "io/cms.h"
|
||||
#include "io/cms_types.h"
|
||||
#ifdef CANVAS
|
||||
#include "io/canvas.h"
|
||||
#endif
|
||||
|
||||
#include "io/flashfs.h"
|
||||
#include "io/osd.h"
|
||||
|
@ -130,22 +128,17 @@ int cmsScreenWrite(displayPort_t *instance, uint8_t x, uint8_t y, char *s)
|
|||
|
||||
void cmsScreenHeartBeat(displayPort_t *instance)
|
||||
{
|
||||
if (instance->vTable->heartbeat)
|
||||
instance->vTable->heartbeat();
|
||||
}
|
||||
|
||||
void cmsScreenResync(displayPort_t *instance)
|
||||
{
|
||||
if (instance->vTable->resync)
|
||||
instance->vTable->resync();
|
||||
instance->vTable->resync(instance);
|
||||
}
|
||||
|
||||
uint16_t cmsScreenTxRoom(displayPort_t *instance)
|
||||
{
|
||||
if (instance->vTable->txroom)
|
||||
return instance->vTable->txroom();
|
||||
else
|
||||
return 10000;
|
||||
}
|
||||
|
||||
void cmsScreenInit(displayPort_t *pDisp, cmsDeviceInitFuncPtr cmsDeviceInitFunc)
|
||||
|
@ -372,10 +365,8 @@ int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row, bool dr
|
|||
return cnt;
|
||||
}
|
||||
|
||||
void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTime)
|
||||
void cmsDrawMenu(displayPort_t *pDisplay)
|
||||
{
|
||||
UNUSED(currentTime);
|
||||
|
||||
uint8_t i;
|
||||
OSD_Entry *p;
|
||||
uint8_t top = (pDisplay->rows - currentMenuIdx) / 2 - 1;
|
||||
|
@ -385,7 +376,7 @@ void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTime)
|
|||
static uint8_t pollDenom = 0;
|
||||
bool drawPolled = (++pollDenom % 8 == 0);
|
||||
|
||||
int room = cmsScreenTxRoom(pDisplay);
|
||||
uint32_t room = cmsScreenTxRoom(pDisplay);
|
||||
|
||||
if (!currentMenu)
|
||||
return;
|
||||
|
@ -799,7 +790,7 @@ void cmsUpdate(displayPort_t *pDisplay, uint32_t currentTime)
|
|||
return;
|
||||
}
|
||||
|
||||
cmsDrawMenu(pDisplay, currentTime);
|
||||
cmsDrawMenu(pDisplay);
|
||||
|
||||
if (currentTime > lastCmsHeartBeat + 500) {
|
||||
// Heart beat for external CMS display device @ 500msec
|
||||
|
@ -811,15 +802,13 @@ void cmsUpdate(displayPort_t *pDisplay, uint32_t currentTime)
|
|||
lastCalled = currentTime;
|
||||
}
|
||||
|
||||
void cmsHandler(uint32_t unusedTime)
|
||||
void cmsHandler(uint32_t currentTime)
|
||||
{
|
||||
UNUSED(unusedTime);
|
||||
|
||||
if (cmsDeviceCount < 0)
|
||||
return;
|
||||
|
||||
static uint32_t lastCalled = 0;
|
||||
uint32_t now = millis();
|
||||
const uint32_t now = currentTime / 1000;
|
||||
|
||||
if (now - lastCalled >= CMS_UPDATE_INTERVAL) {
|
||||
cmsUpdate(¤tDisplay, now);
|
||||
|
@ -1243,8 +1232,7 @@ OSD_Entry menuInfo[] = {
|
|||
|
||||
void cmsx_InfoInit(void)
|
||||
{
|
||||
int i;
|
||||
for (i = 0 ; i < GIT_SHORT_REVISION_LENGTH ; i++) {
|
||||
for (int i = 0 ; i < GIT_SHORT_REVISION_LENGTH ; i++) {
|
||||
if (shortGitRevision[i] >= 'a' && shortGitRevision[i] <= 'f')
|
||||
infoGitRev[i] = shortGitRevision[i] - 'a' + 'A';
|
||||
else
|
||||
|
|
|
@ -1,40 +1,41 @@
|
|||
#pragma once
|
||||
|
||||
typedef struct screenFnVTable_s {
|
||||
struct displayPort_s;
|
||||
|
||||
typedef struct displayPortVTable_s {
|
||||
int (*begin)(void);
|
||||
int (*end)(void);
|
||||
int (*clear)(void);
|
||||
int (*write)(uint8_t, uint8_t, char *);
|
||||
int (*write)(uint8_t col, uint8_t row, char *text);
|
||||
int (*heartbeat)(void);
|
||||
void (*resync)(void);
|
||||
uint16_t (*txroom)(void);
|
||||
} screenFnVTable_t;
|
||||
void (*resync)(struct displayPort_s *pPort);
|
||||
uint32_t (*txroom)(void);
|
||||
} displayPortVTable_t;
|
||||
|
||||
typedef struct displayPort_s {
|
||||
displayPortVTable_t *vTable;
|
||||
uint8_t rows;
|
||||
uint8_t cols;
|
||||
uint16_t buftime;
|
||||
uint16_t bufsize;
|
||||
screenFnVTable_t *vTable;
|
||||
|
||||
// CMS state
|
||||
bool cleared;
|
||||
} displayPort_t;
|
||||
|
||||
// Device management
|
||||
typedef void (*cmsDeviceInitFuncPtr)(displayPort_t *);
|
||||
typedef void (*cmsDeviceInitFuncPtr)(displayPort_t *pPort);
|
||||
bool cmsDeviceRegister(cmsDeviceInitFuncPtr);
|
||||
|
||||
// For main.c and scheduler
|
||||
void cmsInit(void);
|
||||
void cmsHandler(uint32_t);
|
||||
void cmsHandler(uint32_t currentTime);
|
||||
|
||||
// Required for external CMS tables
|
||||
|
||||
long cmsChangeScreen(displayPort_t *, void *);
|
||||
long cmsExitMenu(displayPort_t *, void *);
|
||||
|
||||
#define STARTUP_HELP_TEXT1 "MENU: THR MID"
|
||||
#define STARTUP_HELP_TEXT2 "+ YAW LEFT"
|
||||
#define STARTUP_HELP_TEXT3 "+ PITCH UP"
|
||||
long cmsChangeScreen(displayPort_t *pPort, void *ptr);
|
||||
long cmsExitMenu(displayPort_t *pPort, void *ptr);
|
||||
|
||||
#define CMS_STARTUP_HELP_TEXT1 "MENU: THR MID"
|
||||
#define CMS_STARTUP_HELP_TEXT2 "+ YAW LEFT"
|
||||
#define CMS_STARTUP_HELP_TEXT3 "+ PITCH UP"
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#ifdef DISPLAY
|
||||
|
||||
#include "common/utils.h"
|
||||
|
||||
#include "build/version.h"
|
||||
#include "build/debug.h"
|
||||
|
||||
|
@ -776,22 +778,35 @@ int displayCmsWrite(uint8_t x, uint8_t y, char *s)
|
|||
return 0;
|
||||
}
|
||||
|
||||
screenFnVTable_t displayCmsVTable = {
|
||||
int displayCmsHeartbeat(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void displayCmsResync(displayPort_t *pPort)
|
||||
{
|
||||
UNUSED(pPort);
|
||||
}
|
||||
|
||||
uint32_t displayCmsTxroom(void)
|
||||
{
|
||||
return UINT32_MAX;
|
||||
}
|
||||
|
||||
displayPortVTable_t displayCmsVTable = {
|
||||
displayCmsBegin,
|
||||
displayCmsEnd,
|
||||
displayCmsClear,
|
||||
displayCmsWrite,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
displayCmsHeartbeat,
|
||||
displayCmsResync,
|
||||
displayCmsTxroom,
|
||||
};
|
||||
|
||||
void displayCmsInit(displayPort_t *pPort)
|
||||
{
|
||||
pPort->rows = 8;
|
||||
pPort->cols = 21;
|
||||
pPort->buftime = 1;
|
||||
pPort->bufsize = 50000;
|
||||
pPort->rows = SCREEN_CHARACTER_ROW_COUNT;
|
||||
pPort->cols = SCREEN_CHARACTER_COLUMN_COUNT;
|
||||
pPort->vTable = &displayCmsVTable;
|
||||
}
|
||||
#endif // OLEDCMS
|
||||
|
|
|
@ -47,5 +47,5 @@ void displayResetPageCycling(void);
|
|||
void displaySetNextPageChangeAt(uint32_t futureMicros);
|
||||
|
||||
#ifdef CMS
|
||||
void displayCmsInit(displayPort_t *);
|
||||
void displayCmsInit(displayPort_t *pPort);
|
||||
#endif
|
||||
|
|
|
@ -392,9 +392,11 @@ void osdInit(void)
|
|||
|
||||
sprintf(string_buffer, "BF VERSION: %s", FC_VERSION_STRING);
|
||||
max7456Write(5, 6, string_buffer);
|
||||
max7456Write(7, 7, STARTUP_HELP_TEXT1);
|
||||
max7456Write(11, 8, STARTUP_HELP_TEXT2);
|
||||
max7456Write(11, 9, STARTUP_HELP_TEXT3);
|
||||
#ifdef CMS
|
||||
max7456Write(7, 7, CMS_STARTUP_HELP_TEXT1);
|
||||
max7456Write(11, 8, CMS_STARTUP_HELP_TEXT2);
|
||||
max7456Write(11, 9, CMS_STARTUP_HELP_TEXT3);
|
||||
#endif
|
||||
|
||||
max7456RefreshAll();
|
||||
|
||||
|
@ -669,6 +671,23 @@ int osdWrite(uint8_t x, uint8_t y, char *s)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void osdResync(displayPort_t *pPort)
|
||||
{
|
||||
max7456RefreshAll();
|
||||
pPort->rows = max7456GetRowsCount() - masterConfig.osdProfile.row_shiftdown;
|
||||
pPort->cols = 30;
|
||||
}
|
||||
|
||||
int osdHeartbeat(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t osdTxroom(void)
|
||||
{
|
||||
return UINT32_MAX;
|
||||
}
|
||||
|
||||
#ifdef EDIT_ELEMENT_SUPPORT
|
||||
void osdEditElement(void *ptr)
|
||||
{
|
||||
|
@ -695,21 +714,19 @@ void osdDrawElementPositioningHelp(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
screenFnVTable_t osdVTable = {
|
||||
displayPortVTable_t osdVTable = {
|
||||
osdMenuBegin,
|
||||
osdMenuEnd,
|
||||
osdClearScreen,
|
||||
osdWrite,
|
||||
NULL,
|
||||
max7456RefreshAll,
|
||||
NULL,
|
||||
osdHeartbeat,
|
||||
osdResync,
|
||||
osdTxroom,
|
||||
};
|
||||
|
||||
void osdCmsInit(displayPort_t *pPort)
|
||||
{
|
||||
shiftdown = masterConfig.osdProfile.row_shiftdown;
|
||||
pPort->rows = max7456GetRowsCount() - shiftdown;
|
||||
pPort->cols = 30;
|
||||
osdResync(pPort);
|
||||
pPort->vTable = &osdVTable;
|
||||
}
|
||||
#endif // OSD
|
||||
|
|
BIN
src/main/msp/.msp_serial.h.swo
Normal file
BIN
src/main/msp/.msp_serial.h.swo
Normal file
Binary file not shown.
|
@ -211,8 +211,6 @@ void mspSerialInit(void)
|
|||
mspSerialAllocatePorts();
|
||||
}
|
||||
|
||||
mspPushCommandFnPtr mspPushCommandFn;
|
||||
|
||||
void mspSerialPush(uint8_t cmd, uint8_t *data, int datalen)
|
||||
{
|
||||
static uint8_t pushBuf[30];
|
||||
|
@ -234,7 +232,7 @@ void mspSerialPush(uint8_t cmd, uint8_t *data, int datalen)
|
|||
continue;
|
||||
}
|
||||
|
||||
mspPushCommandFn(&push, data, datalen);
|
||||
sbufWriteData(&push.buf, data, datalen);
|
||||
|
||||
sbufSwitchToReader(&push.buf, pushBuf);
|
||||
|
||||
|
@ -242,14 +240,9 @@ void mspSerialPush(uint8_t cmd, uint8_t *data, int datalen)
|
|||
}
|
||||
}
|
||||
|
||||
void mspSerialPushInit(mspPushCommandFnPtr mspPushCommandFnToUse)
|
||||
uint32_t mspSerialTxBytesFree()
|
||||
{
|
||||
mspPushCommandFn = mspPushCommandFnToUse;
|
||||
}
|
||||
|
||||
uint16_t mspSerialPushTxRoom()
|
||||
{
|
||||
uint16_t minroom = 50000;
|
||||
uint32_t minroom = UINT16_MAX;
|
||||
|
||||
for (uint8_t portIndex = 0; portIndex < MAX_MSP_PORT_COUNT; portIndex++) {
|
||||
mspPort_t * const mspPort = &mspPorts[portIndex];
|
||||
|
@ -262,7 +255,7 @@ uint16_t mspSerialPushTxRoom()
|
|||
continue;
|
||||
}
|
||||
|
||||
uint32_t room = mspPort->port->vTable->serialTotalTxFree(mspPort->port);
|
||||
uint32_t room = serialTxBytesFree(mspPort->port);
|
||||
|
||||
if (room < minroom) {
|
||||
minroom = room;
|
||||
|
|
|
@ -66,6 +66,5 @@ void mspSerialInit(void);
|
|||
void mspSerialProcess(mspEvaluateNonMspData_e evaluateNonMspData, mspProcessCommandFnPtr mspProcessCommandFn);
|
||||
void mspSerialAllocatePorts(void);
|
||||
void mspSerialReleasePortIfAllocated(struct serialPort_s *serialPort);
|
||||
void mspSerialPushInit(mspPushCommandFnPtr mspPushCommandFn);
|
||||
void mspSerialPush(uint8_t, uint8_t *, int);
|
||||
uint16_t mspSerialPushTxRoom();
|
||||
void mspSerialPush(uint8_t cmd, uint8_t *data, int datalen);
|
||||
uint32_t mspSerialTxBytesFree(void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue