1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-19 06:15:16 +03:00

CMS-OSD separation

This commit is contained in:
jflyper 2016-10-21 11:22:29 +09:00
parent c795135542
commit 6cf9086f56
19 changed files with 1518 additions and 1351 deletions

View file

@ -37,6 +37,7 @@
#include "io/motors.h"
#include "io/servos.h"
#include "io/gps.h"
#include "io/cms_types.h"
#include "io/osd.h"
#include "io/ledstrip.h"
#include "io/vtx.h"

View file

@ -63,6 +63,7 @@
#include "io/servos.h"
#include "io/ledstrip.h"
#include "io/gps.h"
#include "io/cms_types.h"
#include "io/osd.h"
#include "io/vtx.h"

View file

@ -66,9 +66,9 @@
#include "io/flashfs.h"
#include "io/transponder_ir.h"
#include "io/asyncfatfs/asyncfatfs.h"
#include "io/osd.h"
//#include "io/osd.h"
#include "io/serial_4way.h"
#include "io/vtx.h"
//#include "io/vtx.h"
#include "msp/msp_protocol.h"
#include "msp/msp.h"

View file

@ -43,11 +43,12 @@
#include "io/display.h"
#include "io/gps.h"
#include "io/ledstrip.h"
#include "io/cms_types.h"
#include "io/cms.h"
#include "io/osd.h"
#include "io/serial.h"
#include "io/serial_cli.h"
#include "io/transponder_ir.h"
#include "io/cms.h"
#include "msp/msp_serial.h"

86
src/main/io/canvas.c Normal file
View file

@ -0,0 +1,86 @@
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <ctype.h>
#include "platform.h"
#include "build/version.h"
#ifdef CANVAS
#include "io/cms_types.h"
#include "fc/fc_msp.h"
#include "msp/msp_protocol.h"
#include "msp/msp_serial.h"
void canvasGetSize(uint8_t *pRows, uint8_t *pCols)
{
*pRows = 13;
*pCols = 30;
}
void canvasBegin(void)
{
uint8_t subcmd[] = { 0 };
mspSerialPush(MSP_CANVAS, subcmd, sizeof(subcmd));
}
void canvasHeartBeat(void)
{
canvasBegin();
}
void canvasEnd(void)
{
uint8_t subcmd[] = { 1 };
mspSerialPush(MSP_CANVAS, subcmd, sizeof(subcmd));
}
void canvasClear(void)
{
uint8_t subcmd[] = { 2 };
mspSerialPush(MSP_CANVAS, subcmd, sizeof(subcmd));
}
void canvasWrite(uint8_t col, uint8_t row, char *string)
{
//debug[0]++; // Let's capture excess canvas writes
int len;
char buf[30 + 4];
if ((len = strlen(string)) >= 30)
len = 30;
buf[0] = 3;
buf[1] = row;
buf[2] = col;
buf[3] = 0;
memcpy((char *)&buf[4], string, len);
mspSerialPush(MSP_CANVAS, (uint8_t *)buf, len + 4);
}
screenFnVTable_t canvasVTable = {
canvasGetSize,
canvasBegin,
canvasEnd,
canvasClear,
canvasWrite,
canvasHeartBeat,
NULL,
};
screenFnVTable_t *canvasInit(void)
{
mspSerialPushInit(mspFcPushInit()); // Called once at startup to initialize push function in msp
return &canvasVTable;
}
#endif

3
src/main/io/canvas.h Normal file
View file

@ -0,0 +1,3 @@
#pragma once
screenFnVTable_t *canvasInit(void);

1207
src/main/io/cms.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,2 +1,13 @@
#pragma once
void cmsInit(void);
void cmsHandler(uint32_t);
void cmsOpenMenu();
void cmsUpdate(uint32_t);
void cmsScreenResync(void);
// Required for external CMS tables
void cmsChangeScreen(void * ptr);
void cmsExitMenu(void * ptr);

96
src/main/io/cms_types.h Normal file
View file

@ -0,0 +1,96 @@
//
// Menu element types
// XXX Upon separation, all OME would be renamed to CME_ or similar.
//
#pragma once
typedef void (*OSDMenuFuncPtr)(void *data);
//type of elements
typedef enum
{
OME_Label,
OME_Back,
OME_OSD_Exit,
OME_Submenu,
OME_Bool,
OME_INT8,
OME_UINT8,
OME_UINT16,
OME_INT16,
OME_Poll_INT16,
OME_FLOAT, //only up to 255 value and cant be 2.55 or 25.5, just for PID's
//wlasciwosci elementow
OME_VISIBLE,
OME_POS,
OME_TAB,
OME_END,
} OSD_MenuElement;
typedef struct
{
char *text;
OSD_MenuElement type;
OSDMenuFuncPtr func;
void *data;
bool changed;
} OSD_Entry;
typedef struct
{
uint8_t *val;
uint8_t min;
uint8_t max;
uint8_t step;
} OSD_UINT8_t;
typedef struct
{
int8_t *val;
int8_t min;
int8_t max;
int8_t step;
} OSD_INT8_t;
typedef struct
{
int16_t *val;
int16_t min;
int16_t max;
int16_t step;
} OSD_INT16_t;
typedef struct
{
uint16_t *val;
uint16_t min;
uint16_t max;
uint16_t step;
} OSD_UINT16_t;
typedef struct
{
uint8_t *val;
uint8_t min;
uint8_t max;
uint8_t step;
uint16_t multipler;
} OSD_FLOAT_t;
typedef struct
{
uint8_t *val;
uint8_t max;
const char * const *names;
} OSD_TAB_t;
typedef struct screenFnVTable_s {
void (*getsize)(uint8_t *, uint8_t *);
void (*begin)(void);
void (*end)(void);
void (*clear)(void);
void (*write)(uint8_t, uint8_t, char *);
void (*heartbeat)(void);
void (*resync)(void);
} screenFnVTable_t;

View file

@ -62,8 +62,8 @@
#include "io/gimbal.h"
#include "io/serial.h"
#include "io/gps.h"
#include "io/osd.h"
#include "io/vtx.h"
//#include "io/osd.h"
//#include "io/vtx.h"
#include "flight/failsafe.h"
#include "flight/mixer.h"

File diff suppressed because it is too large Load diff

View file

@ -68,3 +68,7 @@ typedef struct {
void updateOsd(uint32_t currentTime);
void osdInit(void);
void resetOsdConfig(osd_profile_t *osdProfile);
screenFnVTable_t *osdCmsInit(void);
#define VISIBLE_FLAG 0x0800
#define VISIBLE(x) (x & VISIBLE_FLAG)

View file

@ -70,6 +70,7 @@ uint8_t cliMode = 0;
#include "io/flashfs.h"
#include "io/beeper.h"
#include "io/asyncfatfs/asyncfatfs.h"
#include "io/cms_types.h"
#include "io/osd.h"
#include "io/vtx.h"

View file

@ -86,9 +86,10 @@
#include "io/asyncfatfs/asyncfatfs.h"
#include "io/serial_cli.h"
#include "io/transponder_ir.h"
#include "io/cms_types.h"
#include "io/cms.h"
#include "io/osd.h"
#include "io/vtx.h"
#include "io/cms.h"
#include "scheduler/scheduler.h"

View file

@ -93,15 +93,15 @@
#define CMS
// Use external OSD to run CMS
#define CANVAS
//#define CANVAS
// OSD define info:
// feature name (includes source) -> MAX_OSD, used in target.mk
// include the osd code
//#define OSD
#define OSD
// include the max7456 driver
//#define USE_MAX7456
#define USE_MAX7456
#define MAX7456_SPI_INSTANCE SPI1
#define MAX7456_SPI_CS_PIN PB1
#define MAX7456_SPI_CLK (SPI_CLOCK_STANDARD*2)

View file

@ -14,4 +14,5 @@ TARGET_SRC = \
drivers/transponder_ir_stm32f30x.c \
io/transponder_ir.c \
drivers/max7456.c \
io/osd.c
io/osd.c \
io/cms.c

View file

@ -9,5 +9,6 @@ TARGET_SRC = \
drivers/barometer_bmp280.c \
drivers/compass_ak8975.c \
drivers/compass_hmc5883l.c \
io/osd.c
io/cms.c \
io/canvas.c

View file

@ -65,8 +65,8 @@
#include "io/gps.h"
#include "io/ledstrip.h"
#include "io/beeper.h"
#include "io/osd.h"
#include "io/vtx.h"
//#include "io/osd.h"
//#include "io/vtx.h"
#include "rx/rx.h"

View file

@ -36,9 +36,9 @@
#include "io/gps.h"
#include "io/gimbal.h"
#include "io/serial.h"
#include "io/ledstrip.h"
#include "io/osd.h"
#include "io/vtx.h"
//#include "io/ledstrip.h"
//#include "io/osd.h"
//#include "io/vtx.h"
#include "sensors/boardalignment.h"
#include "sensors/sensors.h"