mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 00:05:33 +03:00
Add OLED CMS support
This commit is contained in:
parent
38660aa8a6
commit
761e1c5bf2
8 changed files with 91 additions and 6 deletions
|
@ -39,11 +39,12 @@
|
||||||
#include "flight/pid.h"
|
#include "flight/pid.h"
|
||||||
#include "flight/altitudehold.h"
|
#include "flight/altitudehold.h"
|
||||||
|
|
||||||
|
#include "io/cms_types.h"
|
||||||
|
|
||||||
#include "io/beeper.h"
|
#include "io/beeper.h"
|
||||||
#include "io/display.h"
|
#include "io/display.h"
|
||||||
#include "io/gps.h"
|
#include "io/gps.h"
|
||||||
#include "io/ledstrip.h"
|
#include "io/ledstrip.h"
|
||||||
#include "io/cms_types.h"
|
|
||||||
#include "io/cms.h"
|
#include "io/cms.h"
|
||||||
#include "io/osd.h"
|
#include "io/osd.h"
|
||||||
#include "io/serial.h"
|
#include "io/serial.h"
|
||||||
|
|
|
@ -47,6 +47,8 @@
|
||||||
|
|
||||||
#include "rx/rx.h"
|
#include "rx/rx.h"
|
||||||
|
|
||||||
|
#include "io/cms_types.h"
|
||||||
|
|
||||||
#include "io/gps.h"
|
#include "io/gps.h"
|
||||||
#include "io/beeper.h"
|
#include "io/beeper.h"
|
||||||
#include "io/motors.h"
|
#include "io/motors.h"
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
|
|
||||||
#include "io/flashfs.h"
|
#include "io/flashfs.h"
|
||||||
#include "io/osd.h"
|
#include "io/osd.h"
|
||||||
|
#include "io/display.h"
|
||||||
|
|
||||||
#include "fc/config.h"
|
#include "fc/config.h"
|
||||||
#include "fc/rc_controls.h"
|
#include "fc/rc_controls.h"
|
||||||
|
@ -61,7 +62,7 @@ void cmsChangeScreen(void *);
|
||||||
void cmsMenuBack(void);
|
void cmsMenuBack(void);
|
||||||
void cmsEraseFlash(void *);
|
void cmsEraseFlash(void *);
|
||||||
|
|
||||||
screenFnVTable_t *pScreenFnVTable;
|
screenFnVTable_t *pScreenFnVTable = NULL;
|
||||||
|
|
||||||
uint8_t cmsRows;
|
uint8_t cmsRows;
|
||||||
uint8_t cmsCols;
|
uint8_t cmsCols;
|
||||||
|
@ -91,8 +92,7 @@ uint16_t cmsBatchsize;
|
||||||
//
|
//
|
||||||
|
|
||||||
#define LEFT_MENU_COLUMN 1
|
#define LEFT_MENU_COLUMN 1
|
||||||
//#define RIGHT_MENU_COLUMN (cmsCols - 7)
|
#define RIGHT_MENU_COLUMN (cmsCols - 7)
|
||||||
#define RIGHT_MENU_COLUMN (cmsCols - 9 - 7)
|
|
||||||
|
|
||||||
bool cmsScreenCleared;
|
bool cmsScreenCleared;
|
||||||
OSD_Entry *currentMenu;
|
OSD_Entry *currentMenu;
|
||||||
|
@ -154,6 +154,10 @@ pScreenFnVTable = osdCmsInit();
|
||||||
#ifdef CANVAS
|
#ifdef CANVAS
|
||||||
pScreenFnVTable = canvasInit();
|
pScreenFnVTable = canvasInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef OLEDCMS
|
||||||
|
pScreenFnVTable = displayCMSInit();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1107,6 +1111,9 @@ void cmsHandler(uint32_t unusedTime)
|
||||||
{
|
{
|
||||||
UNUSED(unusedTime);
|
UNUSED(unusedTime);
|
||||||
|
|
||||||
|
if (pScreenFnVTable == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
static uint32_t lastCalled = 0;
|
static uint32_t lastCalled = 0;
|
||||||
uint32_t now = millis();
|
uint32_t now = millis();
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,8 @@
|
||||||
#include "flight/imu.h"
|
#include "flight/imu.h"
|
||||||
#include "flight/failsafe.h"
|
#include "flight/failsafe.h"
|
||||||
|
|
||||||
|
#include "io/cms_types.h"
|
||||||
|
|
||||||
#ifdef GPS
|
#ifdef GPS
|
||||||
#include "io/gps.h"
|
#include "io/gps.h"
|
||||||
#include "flight/navigation.h"
|
#include "flight/navigation.h"
|
||||||
|
@ -581,10 +583,19 @@ void showDebugPage(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef OLEDCMS
|
||||||
|
static bool displayInCMS = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
void displayUpdate(uint32_t currentTime)
|
void displayUpdate(uint32_t currentTime)
|
||||||
{
|
{
|
||||||
static uint8_t previousArmedState = 0;
|
static uint8_t previousArmedState = 0;
|
||||||
|
|
||||||
|
#ifdef OLEDCMS
|
||||||
|
if (displayInCMS)
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
const bool updateNow = (int32_t)(currentTime - nextDisplayUpdateAt) >= 0L;
|
const bool updateNow = (int32_t)(currentTime - nextDisplayUpdateAt) >= 0L;
|
||||||
if (!updateNow) {
|
if (!updateNow) {
|
||||||
return;
|
return;
|
||||||
|
@ -733,4 +744,61 @@ void displayDisablePageCycling(void)
|
||||||
pageState.pageFlags &= ~PAGE_STATE_FLAG_CYCLE_ENABLED;
|
pageState.pageFlags &= ~PAGE_STATE_FLAG_CYCLE_ENABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef OLEDCMS
|
||||||
|
#include "io/cms_types.h"
|
||||||
|
|
||||||
|
void displayCMSGetDevParam(uint8_t *pRows, uint8_t *pCols, uint16_t *pBuftime, uint16_t *pBufsize)
|
||||||
|
{
|
||||||
|
*pRows = 8;
|
||||||
|
*pCols = 21;
|
||||||
|
*pBuftime = 1;
|
||||||
|
*pBufsize = 50000;
|
||||||
|
}
|
||||||
|
|
||||||
|
int displayCMSBegin(void)
|
||||||
|
{
|
||||||
|
displayInCMS = true;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int displayCMSEnd(void)
|
||||||
|
{
|
||||||
|
displayInCMS = false;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int displayCMSClear(void)
|
||||||
|
{
|
||||||
|
i2c_OLED_clear_display_quick();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int displayCMSWrite(uint8_t x, uint8_t y, char *s)
|
||||||
|
{
|
||||||
|
i2c_OLED_set_xy(x, y);
|
||||||
|
i2c_OLED_send_string(s);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
screenFnVTable_t displayCMSVTable = {
|
||||||
|
displayCMSGetDevParam,
|
||||||
|
displayCMSBegin,
|
||||||
|
displayCMSEnd,
|
||||||
|
displayCMSClear,
|
||||||
|
displayCMSWrite,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
|
||||||
|
screenFnVTable_t *displayCMSInit(void)
|
||||||
|
{
|
||||||
|
return &displayCMSVTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // OLEDCMS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -45,3 +45,5 @@ void displayEnablePageCycling(void);
|
||||||
void displayDisablePageCycling(void);
|
void displayDisablePageCycling(void);
|
||||||
void displayResetPageCycling(void);
|
void displayResetPageCycling(void);
|
||||||
void displaySetNextPageChangeAt(uint32_t futureMicros);
|
void displaySetNextPageChangeAt(uint32_t futureMicros);
|
||||||
|
|
||||||
|
screenFnVTable_t *displayCMSInit(void);
|
||||||
|
|
|
@ -41,6 +41,8 @@
|
||||||
|
|
||||||
#include "sensors/sensors.h"
|
#include "sensors/sensors.h"
|
||||||
|
|
||||||
|
#include "io/cms_types.h"
|
||||||
|
|
||||||
#include "io/serial.h"
|
#include "io/serial.h"
|
||||||
#include "io/display.h"
|
#include "io/display.h"
|
||||||
#include "io/gps.h"
|
#include "io/gps.h"
|
||||||
|
|
|
@ -74,6 +74,8 @@
|
||||||
#include "rx/rx.h"
|
#include "rx/rx.h"
|
||||||
#include "rx/spektrum.h"
|
#include "rx/spektrum.h"
|
||||||
|
|
||||||
|
#include "io/cms_types.h"
|
||||||
|
|
||||||
#include "io/beeper.h"
|
#include "io/beeper.h"
|
||||||
#include "io/serial.h"
|
#include "io/serial.h"
|
||||||
#include "io/flashfs.h"
|
#include "io/flashfs.h"
|
||||||
|
@ -86,7 +88,6 @@
|
||||||
#include "io/asyncfatfs/asyncfatfs.h"
|
#include "io/asyncfatfs/asyncfatfs.h"
|
||||||
#include "io/serial_cli.h"
|
#include "io/serial_cli.h"
|
||||||
#include "io/transponder_ir.h"
|
#include "io/transponder_ir.h"
|
||||||
#include "io/cms_types.h"
|
|
||||||
#include "io/cms.h"
|
#include "io/cms.h"
|
||||||
#include "io/osd.h"
|
#include "io/osd.h"
|
||||||
#include "io/vtx.h"
|
#include "io/vtx.h"
|
||||||
|
|
|
@ -95,10 +95,12 @@
|
||||||
// Use external OSD to run CMS
|
// Use external OSD to run CMS
|
||||||
//#define CANVAS
|
//#define CANVAS
|
||||||
|
|
||||||
|
#define OLEDCMS
|
||||||
|
|
||||||
// OSD define info:
|
// OSD define info:
|
||||||
// feature name (includes source) -> MAX_OSD, used in target.mk
|
// feature name (includes source) -> MAX_OSD, used in target.mk
|
||||||
// include the osd code
|
// include the osd code
|
||||||
#define OSD
|
//#define OSD
|
||||||
|
|
||||||
// include the max7456 driver
|
// include the max7456 driver
|
||||||
#define USE_MAX7456
|
#define USE_MAX7456
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue