mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 00:35:39 +03:00
Add MAX7456 image options to CMS
This commit is contained in:
parent
6ea05b93ab
commit
7919a6ffbd
5 changed files with 62 additions and 16 deletions
|
@ -133,7 +133,7 @@ static OSD_Entry menuMainEntries[] =
|
||||||
{"PROFILE", OME_Submenu, cmsMenuChange, &cmsx_menuImu, 0},
|
{"PROFILE", OME_Submenu, cmsMenuChange, &cmsx_menuImu, 0},
|
||||||
{"FEATURES", OME_Submenu, cmsMenuChange, &menuFeatures, 0},
|
{"FEATURES", OME_Submenu, cmsMenuChange, &menuFeatures, 0},
|
||||||
#ifdef OSD
|
#ifdef OSD
|
||||||
{"SCR LAYOUT", OME_Submenu, cmsMenuChange, &cmsx_menuOsdLayout, 0},
|
{"OSD", OME_Submenu, cmsMenuChange, &cmsx_menuOsd, 0},
|
||||||
{"ALARMS", OME_Submenu, cmsMenuChange, &cmsx_menuAlarms, 0},
|
{"ALARMS", OME_Submenu, cmsMenuChange, &cmsx_menuAlarms, 0},
|
||||||
#endif
|
#endif
|
||||||
{"FC&FW INFO", OME_Submenu, cmsMenuChange, &menuInfo, 0},
|
{"FC&FW INFO", OME_Submenu, cmsMenuChange, &menuInfo, 0},
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "config/parameter_group.h"
|
#include "config/parameter_group.h"
|
||||||
#include "config/parameter_group_ids.h"
|
#include "config/parameter_group_ids.h"
|
||||||
|
|
||||||
|
#include "io/displayport_max7456.h"
|
||||||
#include "io/osd.h"
|
#include "io/osd.h"
|
||||||
|
|
||||||
static uint8_t osdConfig_rssi_alarm;
|
static uint8_t osdConfig_rssi_alarm;
|
||||||
|
@ -145,20 +146,55 @@ CMS_Menu menuOsdActiveElems = {
|
||||||
.entries = menuOsdActiveElemsEntries
|
.entries = menuOsdActiveElemsEntries
|
||||||
};
|
};
|
||||||
|
|
||||||
OSD_Entry cmsx_menuOsdLayoutEntries[] =
|
#ifdef USE_MAX7456
|
||||||
|
static bool displayPortProfileMax7456_invert;
|
||||||
|
static uint8_t displayPortProfileMax7456_blackBrightness;
|
||||||
|
static uint8_t displayPortProfileMax7456_whiteBrightness;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static long cmsx_menuOsdOnEnter(void)
|
||||||
{
|
{
|
||||||
{"---SCREEN LAYOUT---", OME_Label, NULL, NULL, 0},
|
#ifdef USE_MAX7456
|
||||||
|
displayPortProfileMax7456_invert = displayPortProfileMax7456()->invert;
|
||||||
|
displayPortProfileMax7456_blackBrightness = displayPortProfileMax7456()->blackBrightness;
|
||||||
|
displayPortProfileMax7456_whiteBrightness = displayPortProfileMax7456()->whiteBrightness;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static long cmsx_menuOsdOnExit(const OSD_Entry *self)
|
||||||
|
{
|
||||||
|
UNUSED(self);
|
||||||
|
|
||||||
|
#ifdef USE_MAX7456
|
||||||
|
displayPortProfileMax7456Mutable()->invert = displayPortProfileMax7456_invert;
|
||||||
|
displayPortProfileMax7456Mutable()->blackBrightness = displayPortProfileMax7456_blackBrightness;
|
||||||
|
displayPortProfileMax7456Mutable()->whiteBrightness = displayPortProfileMax7456_whiteBrightness;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
OSD_Entry cmsx_menuOsdEntries[] =
|
||||||
|
{
|
||||||
|
{"---OSD---", OME_Label, NULL, NULL, 0},
|
||||||
{"ACTIVE ELEM", OME_Submenu, cmsMenuChange, &menuOsdActiveElems, 0},
|
{"ACTIVE ELEM", OME_Submenu, cmsMenuChange, &menuOsdActiveElems, 0},
|
||||||
|
#ifdef USE_MAX7456
|
||||||
|
{"INVERT", OME_Bool, NULL, &displayPortProfileMax7456_invert, 0},
|
||||||
|
{"BRT BLACK", OME_UINT8, NULL, &(OSD_UINT8_t){&displayPortProfileMax7456_blackBrightness, 0, 3, 1}, 0},
|
||||||
|
{"BRT WHITE", OME_UINT8, NULL, &(OSD_UINT8_t){&displayPortProfileMax7456_whiteBrightness, 0, 3, 1}, 0},
|
||||||
|
#endif
|
||||||
{"BACK", OME_Back, NULL, NULL, 0},
|
{"BACK", OME_Back, NULL, NULL, 0},
|
||||||
{NULL, OME_END, NULL, NULL, 0}
|
{NULL, OME_END, NULL, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
CMS_Menu cmsx_menuOsdLayout = {
|
CMS_Menu cmsx_menuOsd = {
|
||||||
.GUARD_text = "MENULAYOUT",
|
.GUARD_text = "MENUOSD",
|
||||||
.GUARD_type = OME_MENU,
|
.GUARD_type = OME_MENU,
|
||||||
.onEnter = NULL,
|
.onEnter = cmsx_menuOsdOnEnter,
|
||||||
.onExit = NULL,
|
.onExit = cmsx_menuOsdOnExit,
|
||||||
.onGlobalExit = NULL,
|
.onGlobalExit = NULL,
|
||||||
.entries = cmsx_menuOsdLayoutEntries
|
.entries = cmsx_menuOsdEntries
|
||||||
};
|
};
|
||||||
#endif // CMS
|
#endif // CMS
|
||||||
|
|
|
@ -18,4 +18,4 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
extern CMS_Menu cmsx_menuAlarms;
|
extern CMS_Menu cmsx_menuAlarms;
|
||||||
extern CMS_Menu cmsx_menuOsdLayout;
|
extern CMS_Menu cmsx_menuOsd;
|
||||||
|
|
|
@ -435,11 +435,11 @@ void max7456Invert(bool invert)
|
||||||
* Sets the brighness of black and white pixels.
|
* Sets the brighness of black and white pixels.
|
||||||
*
|
*
|
||||||
* @param black Black brightness (0-3, 0 is darkest)
|
* @param black Black brightness (0-3, 0 is darkest)
|
||||||
* @param white White brightness (0-3, 0 is brightest)
|
* @param white White brightness (0-3, 0 is darkest)
|
||||||
*/
|
*/
|
||||||
void max7456Brightness(uint8_t black, uint8_t white)
|
void max7456Brightness(uint8_t black, uint8_t white)
|
||||||
{
|
{
|
||||||
uint8_t reg = (black << 2) | white;
|
uint8_t reg = (black << 2) | (3 - white);
|
||||||
|
|
||||||
ENABLE_MAX7456;
|
ENABLE_MAX7456;
|
||||||
for (int i = MAX7456ADD_RB0; i <= MAX7456ADD_RB15; i++) {
|
for (int i = MAX7456ADD_RB0; i <= MAX7456ADD_RB15; i++) {
|
||||||
|
|
|
@ -37,8 +37,18 @@
|
||||||
|
|
||||||
displayPort_t max7456DisplayPort;
|
displayPort_t max7456DisplayPort;
|
||||||
|
|
||||||
// no template required since defaults are zero
|
PG_REGISTER_WITH_RESET_FN(displayPortProfile_t, displayPortProfileMax7456, PG_DISPLAY_PORT_MAX7456_CONFIG, 0);
|
||||||
PG_REGISTER(displayPortProfile_t, displayPortProfileMax7456, PG_DISPLAY_PORT_MAX7456_CONFIG, 0);
|
|
||||||
|
void pgResetFn_displayPortProfileMax7456(displayPortProfile_t *displayPortProfile)
|
||||||
|
{
|
||||||
|
displayPortProfile->colAdjust = 0;
|
||||||
|
displayPortProfile->rowAdjust = 0;
|
||||||
|
|
||||||
|
// Set defaults as per MAX7456 datasheet
|
||||||
|
displayPortProfile->invert = false;
|
||||||
|
displayPortProfile->blackBrightness = 0;
|
||||||
|
displayPortProfile->whiteBrightness = 2;
|
||||||
|
}
|
||||||
|
|
||||||
static int grab(displayPort_t *displayPort)
|
static int grab(displayPort_t *displayPort)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue