mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 08:15:30 +03:00
Merge branch 'master' into development
This commit is contained in:
commit
3c4608d6fa
4 changed files with 234 additions and 224 deletions
|
@ -165,7 +165,7 @@ statistic_t stats;
|
|||
|
||||
#define LEFT_MENU_COLUMN 1
|
||||
#define RIGHT_MENU_COLUMN 23
|
||||
#define MAX_MENU_ITEMS (max7456_get_rows_count() - 2)
|
||||
#define MAX_MENU_ITEMS (max7456GetRowsCount() - 2)
|
||||
|
||||
uint8_t osdRows;
|
||||
|
||||
|
@ -344,19 +344,19 @@ OSD_Entry menuBlackbox[] =
|
|||
uint8_t ledColor;
|
||||
|
||||
static const char * const LED_COLOR_NAMES[] = {
|
||||
" BLACK",
|
||||
" WHITE",
|
||||
" RED",
|
||||
" ORANGE",
|
||||
" YELLOW",
|
||||
" BLACK ",
|
||||
" WHITE ",
|
||||
" RED ",
|
||||
" ORANGE ",
|
||||
" YELLOW ",
|
||||
" LIME GREEN",
|
||||
" GREEN",
|
||||
" GREEN ",
|
||||
" MINT GREEN",
|
||||
" CYAN",
|
||||
" CYAN ",
|
||||
" LIGHT BLUE",
|
||||
" BLUE",
|
||||
" BLUE ",
|
||||
"DARK VIOLET",
|
||||
" MAGNETA",
|
||||
" MAGENTA ",
|
||||
" DEEP PINK"
|
||||
};
|
||||
|
||||
|
@ -401,7 +401,7 @@ OSD_Entry menuLedstrip[] =
|
|||
|
||||
#if defined(VTX) || defined(USE_RTC6705)
|
||||
static const char * const vtxBandNames[] = {
|
||||
"BOACAM A",
|
||||
"BOSCAM A",
|
||||
"BOSCAM B",
|
||||
"BOSCAM E",
|
||||
"FATSHARK",
|
||||
|
@ -664,35 +664,36 @@ void osdInit(void)
|
|||
|
||||
armState = ARMING_FLAG(ARMED);
|
||||
|
||||
max7456_init(masterConfig.osdProfile.video_system);
|
||||
max7456Init(masterConfig.osdProfile.video_system);
|
||||
|
||||
max7456_clear_screen();
|
||||
max7456ClearScreen();
|
||||
|
||||
// display logo and help
|
||||
x = 160;
|
||||
for (int i = 1; i < 5; i++) {
|
||||
for (int j = 3; j < 27; j++) {
|
||||
if (x != 255)
|
||||
max7456_write_char(j, i, x++);
|
||||
max7456WriteChar(j, i, x++);
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(string_buffer, "BF VERSION: %s", FC_VERSION_STRING);
|
||||
max7456_write(5, 6, string_buffer);
|
||||
max7456_write(7, 7, "MENU: THRT MID");
|
||||
max7456_write(13, 8, "YAW RIGHT");
|
||||
max7456_write(13, 9, "PITCH UP");
|
||||
max7456_refresh_all();
|
||||
max7456Write(5, 6, string_buffer);
|
||||
max7456Write(7, 7, "MENU: THRT MID");
|
||||
max7456Write(13, 8, "YAW RIGHT");
|
||||
max7456Write(13, 9, "PITCH UP");
|
||||
max7456RefreshAll();
|
||||
|
||||
refreshTimeout = 4 * REFRESH_1S;
|
||||
}
|
||||
|
||||
void osdUpdateAlarms(void)
|
||||
{
|
||||
uint16_t rval = rssi * 100 / 1024; // zmiana zakresu
|
||||
int32_t alt = BaroAlt / 100;
|
||||
|
||||
if (rval < OSD_cfg.rssi_alarm)
|
||||
statRssi = rssi * 100 / 1024;
|
||||
|
||||
if (statRssi < OSD_cfg.rssi_alarm)
|
||||
OSD_cfg.item_pos[OSD_RSSI_VALUE] |= BLINK_FLAG;
|
||||
else
|
||||
OSD_cfg.item_pos[OSD_RSSI_VALUE] &= ~BLINK_FLAG;
|
||||
|
@ -755,7 +756,7 @@ uint8_t osdHandleKey(uint8_t key)
|
|||
else {
|
||||
if (nextPage) // we have more pages
|
||||
{
|
||||
max7456_clear_screen();
|
||||
max7456ClearScreen();
|
||||
p = nextPage;
|
||||
nextPage = currentMenu;
|
||||
currentMenu = (OSD_Entry *)p;
|
||||
|
@ -774,7 +775,7 @@ uint8_t osdHandleKey(uint8_t key)
|
|||
|
||||
if (currentMenuPos == -1 || (currentMenu + currentMenuPos)->type == OME_Label) {
|
||||
if (nextPage) {
|
||||
max7456_clear_screen();
|
||||
max7456ClearScreen();
|
||||
p = nextPage;
|
||||
nextPage = currentMenu;
|
||||
currentMenu = (OSD_Entry *)p;
|
||||
|
@ -946,7 +947,7 @@ void osdMenuBack(void)
|
|||
memcpy(&masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile], &rateProfile, sizeof(controlRateConfig_t));
|
||||
|
||||
if (menuStackIdx) {
|
||||
max7456_clear_screen();
|
||||
max7456ClearScreen();
|
||||
menuStackIdx--;
|
||||
nextPage = NULL;
|
||||
currentMenu = menuStack[menuStackIdx];
|
||||
|
@ -998,10 +999,10 @@ void osdDrawMenu(void)
|
|||
|
||||
for (p = currentMenu; p->type != OME_END; p++) {
|
||||
if (currentMenuPos == i)
|
||||
max7456_write(LEFT_MENU_COLUMN, i + top, " >");
|
||||
max7456Write(LEFT_MENU_COLUMN, i + top, " >");
|
||||
else
|
||||
max7456_write(LEFT_MENU_COLUMN, i + top, " ");
|
||||
max7456_write(LEFT_MENU_COLUMN + 2, i + top, p->text);
|
||||
max7456Write(LEFT_MENU_COLUMN, i + top, " ");
|
||||
max7456Write(LEFT_MENU_COLUMN + 2, i + top, p->text);
|
||||
|
||||
switch (p->type) {
|
||||
case OME_POS: {
|
||||
|
@ -1013,19 +1014,19 @@ void osdDrawMenu(void)
|
|||
break;
|
||||
}
|
||||
case OME_Submenu:
|
||||
max7456_write(RIGHT_MENU_COLUMN, i + top, ">");
|
||||
max7456Write(RIGHT_MENU_COLUMN, i + top, ">");
|
||||
break;
|
||||
case OME_Bool:
|
||||
if (p->data) {
|
||||
if (*((uint8_t *)(p->data)))
|
||||
max7456_write(RIGHT_MENU_COLUMN, i + top, "YES");
|
||||
max7456Write(RIGHT_MENU_COLUMN, i + top, "YES");
|
||||
else
|
||||
max7456_write(RIGHT_MENU_COLUMN, i + top, "NO ");
|
||||
max7456Write(RIGHT_MENU_COLUMN, i + top, "NO ");
|
||||
}
|
||||
break;
|
||||
case OME_TAB: {
|
||||
OSD_TAB_t *ptr = p->data;
|
||||
max7456_write(RIGHT_MENU_COLUMN - 5, i + top, (char *)ptr->names[*ptr->val]);
|
||||
max7456Write(RIGHT_MENU_COLUMN - 5, i + top, (char *)ptr->names[*ptr->val]);
|
||||
break;
|
||||
}
|
||||
case OME_VISIBLE:
|
||||
|
@ -1036,49 +1037,49 @@ void osdDrawMenu(void)
|
|||
val = (uint16_t *)address;
|
||||
|
||||
if (VISIBLE(*val))
|
||||
max7456_write(RIGHT_MENU_COLUMN, i + top, "YES");
|
||||
max7456Write(RIGHT_MENU_COLUMN, i + top, "YES");
|
||||
else
|
||||
max7456_write(RIGHT_MENU_COLUMN, i + top, "NO ");
|
||||
max7456Write(RIGHT_MENU_COLUMN, i + top, "NO ");
|
||||
}
|
||||
break;
|
||||
case OME_UINT8:
|
||||
if (p->data) {
|
||||
OSD_UINT8_t *ptr = p->data;
|
||||
itoa(*ptr->val, buff, 10);
|
||||
max7456_write(RIGHT_MENU_COLUMN, i + top, " ");
|
||||
max7456_write(RIGHT_MENU_COLUMN, i + top, buff);
|
||||
max7456Write(RIGHT_MENU_COLUMN, i + top, " ");
|
||||
max7456Write(RIGHT_MENU_COLUMN, i + top, buff);
|
||||
}
|
||||
break;
|
||||
case OME_INT8:
|
||||
if (p->data) {
|
||||
OSD_INT8_t *ptr = p->data;
|
||||
itoa(*ptr->val, buff, 10);
|
||||
max7456_write(RIGHT_MENU_COLUMN, i + top, " ");
|
||||
max7456_write(RIGHT_MENU_COLUMN, i + top, buff);
|
||||
max7456Write(RIGHT_MENU_COLUMN, i + top, " ");
|
||||
max7456Write(RIGHT_MENU_COLUMN, i + top, buff);
|
||||
}
|
||||
break;
|
||||
case OME_UINT16:
|
||||
if (p->data) {
|
||||
OSD_UINT16_t *ptr = p->data;
|
||||
itoa(*ptr->val, buff, 10);
|
||||
max7456_write(RIGHT_MENU_COLUMN, i + top, " ");
|
||||
max7456_write(RIGHT_MENU_COLUMN, i + top, buff);
|
||||
max7456Write(RIGHT_MENU_COLUMN, i + top, " ");
|
||||
max7456Write(RIGHT_MENU_COLUMN, i + top, buff);
|
||||
}
|
||||
break;
|
||||
case OME_INT16:
|
||||
if (p->data) {
|
||||
OSD_UINT16_t *ptr = p->data;
|
||||
itoa(*ptr->val, buff, 10);
|
||||
max7456_write(RIGHT_MENU_COLUMN, i + top, " ");
|
||||
max7456_write(RIGHT_MENU_COLUMN, i + top, buff);
|
||||
max7456Write(RIGHT_MENU_COLUMN, i + top, " ");
|
||||
max7456Write(RIGHT_MENU_COLUMN, i + top, buff);
|
||||
}
|
||||
break;
|
||||
case OME_FLOAT:
|
||||
if (p->data) {
|
||||
OSD_FLOAT_t *ptr = p->data;
|
||||
simple_ftoa(*ptr->val * ptr->multipler, buff);
|
||||
max7456_write(RIGHT_MENU_COLUMN - 1, i + top, " ");
|
||||
max7456_write(RIGHT_MENU_COLUMN - 1, i + top, buff);
|
||||
max7456Write(RIGHT_MENU_COLUMN - 1, i + top, " ");
|
||||
max7456Write(RIGHT_MENU_COLUMN - 1, i + top, buff);
|
||||
}
|
||||
break;
|
||||
case OME_OSD_Exit:
|
||||
|
@ -1132,34 +1133,34 @@ void osdShowStats(void)
|
|||
uint8_t top = 2;
|
||||
char buff[10];
|
||||
|
||||
max7456_clear_screen();
|
||||
max7456_write(2, top++, " --- STATS ---");
|
||||
max7456ClearScreen();
|
||||
max7456Write(2, top++, " --- STATS ---");
|
||||
|
||||
if (STATE(GPS_FIX)) {
|
||||
max7456_write(2, top, "MAX SPEED :");
|
||||
max7456Write(2, top, "MAX SPEED :");
|
||||
itoa(stats.max_speed, buff, 10);
|
||||
max7456_write(22, top++, buff);
|
||||
max7456Write(22, top++, buff);
|
||||
}
|
||||
|
||||
max7456_write(2, top, "MIN BATTERY :");
|
||||
max7456Write(2, top, "MIN BATTERY :");
|
||||
sprintf(buff, "%d.%1dV", stats.min_voltage / 10, stats.min_voltage % 10);
|
||||
max7456_write(22, top++, buff);
|
||||
max7456Write(22, top++, buff);
|
||||
|
||||
max7456_write(2, top, "MIN RSSI :");
|
||||
max7456Write(2, top, "MIN RSSI :");
|
||||
itoa(stats.min_rssi, buff, 10);
|
||||
strcat(buff, "%");
|
||||
max7456_write(22, top++, buff);
|
||||
max7456Write(22, top++, buff);
|
||||
|
||||
if (feature(FEATURE_CURRENT_METER)) {
|
||||
max7456_write(2, top, "MAX CURRENT :");
|
||||
itoa(stats.max_current / 10, buff, 10);
|
||||
max7456Write(2, top, "MAX CURRENT :");
|
||||
itoa(stats.max_current, buff, 10);
|
||||
strcat(buff, "A");
|
||||
max7456_write(22, top++, buff);
|
||||
max7456Write(22, top++, buff);
|
||||
|
||||
max7456_write(2, top, "USED MAH :");
|
||||
max7456Write(2, top, "USED MAH :");
|
||||
itoa(mAhDrawn, buff, 10);
|
||||
strcat(buff, "\x07");
|
||||
max7456_write(22, top++, buff);
|
||||
max7456Write(22, top++, buff);
|
||||
}
|
||||
refreshTimeout = 60 * REFRESH_1S;
|
||||
}
|
||||
|
@ -1167,8 +1168,8 @@ void osdShowStats(void)
|
|||
// called when motors armed
|
||||
void osdArmMotors(void)
|
||||
{
|
||||
max7456_clear_screen();
|
||||
max7456_write(12, 7, "ARMED");
|
||||
max7456ClearScreen();
|
||||
max7456Write(12, 7, "ARMED");
|
||||
refreshTimeout = REFRESH_1S / 2;
|
||||
osdResetStats();
|
||||
}
|
||||
|
@ -1178,7 +1179,7 @@ void updateOsd(uint32_t currentTime)
|
|||
static uint32_t counter;
|
||||
#ifdef MAX7456_DMA_CHANNEL_TX
|
||||
// don't touch buffers if DMA transaction is in progress
|
||||
if (max7456_dma_in_progres())
|
||||
if (max7456DmaInProgres())
|
||||
return;
|
||||
#endif // MAX7456_DMA_CHANNEL_TX
|
||||
|
||||
|
@ -1186,7 +1187,7 @@ void updateOsd(uint32_t currentTime)
|
|||
if (counter++ % 5 == 0)
|
||||
osdUpdate(currentTime);
|
||||
else // rest of time redraw screen 10 chars per idle to don't lock the main idle
|
||||
max7456_draw_screen();
|
||||
max7456DrawScreen();
|
||||
|
||||
// do not allow ARM if we are in menu
|
||||
if (inMenu)
|
||||
|
@ -1208,7 +1209,7 @@ void osdUpdate(uint32_t currentTime)
|
|||
if (ARMING_FLAG(ARMED))
|
||||
osdArmMotors(); // reset statistic etc
|
||||
else
|
||||
osdShowStats(); // schow statistic
|
||||
osdShowStats(); // show statistic
|
||||
|
||||
armState = ARMING_FLAG(ARMED);
|
||||
}
|
||||
|
@ -1227,7 +1228,7 @@ void osdUpdate(uint32_t currentTime)
|
|||
refreshTimeout = 1;
|
||||
refreshTimeout--;
|
||||
if (!refreshTimeout)
|
||||
max7456_clear_screen();
|
||||
max7456ClearScreen();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1295,7 +1296,7 @@ void osdUpdate(uint32_t currentTime)
|
|||
|
||||
*currentElement &= 0xFC00;
|
||||
*currentElement |= OSD_POS(x, y);
|
||||
max7456_clear_screen();
|
||||
max7456ClearScreen();
|
||||
}
|
||||
}
|
||||
osdDrawElements();
|
||||
|
@ -1313,7 +1314,7 @@ void osdChangeScreen(void *ptr)
|
|||
{
|
||||
uint8_t i;
|
||||
if (ptr) {
|
||||
max7456_clear_screen();
|
||||
max7456ClearScreen();
|
||||
// hack - save profile to temp
|
||||
if (ptr == &menuPid[0]) {
|
||||
for (i = 0; i < 3; i++) {
|
||||
|
@ -1344,16 +1345,16 @@ void osdEraseFlash(void *ptr)
|
|||
{
|
||||
UNUSED(ptr);
|
||||
|
||||
max7456_clear_screen();
|
||||
max7456_write(5, 3, "ERASING FLASH...");
|
||||
max7456_refresh_all();
|
||||
max7456ClearScreen();
|
||||
max7456Write(5, 3, "ERASING FLASH...");
|
||||
max7456RefreshAll();
|
||||
|
||||
flashfsEraseCompletely();
|
||||
while (!flashfsIsReady()) {
|
||||
delay(100);
|
||||
}
|
||||
max7456_clear_screen();
|
||||
max7456_refresh_all();
|
||||
max7456ClearScreen();
|
||||
max7456RefreshAll();
|
||||
}
|
||||
#endif // USE_FLASHFS
|
||||
|
||||
|
@ -1369,14 +1370,14 @@ void osdEditElement(void *ptr)
|
|||
currentElement = (uint16_t *)address;
|
||||
|
||||
*currentElement |= BLINK_FLAG;
|
||||
max7456_clear_screen();
|
||||
max7456ClearScreen();
|
||||
}
|
||||
|
||||
void osdExitMenu(void *ptr)
|
||||
{
|
||||
max7456_clear_screen();
|
||||
max7456_write(5, 3, "RESTARTING IMU...");
|
||||
max7456_refresh_all();
|
||||
max7456ClearScreen();
|
||||
max7456Write(5, 3, "RESTARTING IMU...");
|
||||
max7456RefreshAll();
|
||||
stopMotors();
|
||||
stopPwmAllMotors();
|
||||
delay(200);
|
||||
|
@ -1385,13 +1386,18 @@ void osdExitMenu(void *ptr)
|
|||
// save local variables to configuration
|
||||
if (featureBlackbox)
|
||||
featureSet(FEATURE_BLACKBOX);
|
||||
else
|
||||
featureClear(FEATURE_BLACKBOX);
|
||||
|
||||
if (featureLedstrip)
|
||||
featureSet(FEATURE_LED_STRIP);
|
||||
|
||||
else
|
||||
featureClear(FEATURE_LED_STRIP);
|
||||
#if defined(VTX) || defined(USE_RTC6705)
|
||||
if (featureVtx)
|
||||
featureSet(FEATURE_VTX);
|
||||
else
|
||||
featureClear(FEATURE_VTX);
|
||||
#endif // VTX || USE_RTC6705
|
||||
|
||||
#ifdef VTX
|
||||
|
@ -1435,14 +1441,13 @@ void osdOpenMenu(void)
|
|||
vtxChannel = masterConfig.vtx_channel % 8 + 1;
|
||||
#endif // USE_RTC6705
|
||||
|
||||
osdRows = max7456_get_rows_count();
|
||||
osdRows = max7456GetRowsCount();
|
||||
inMenu = true;
|
||||
refreshTimeout = 0;
|
||||
max7456_clear_screen();
|
||||
max7456ClearScreen();
|
||||
currentMenu = &menuMain[0];
|
||||
osdResetAlarms();
|
||||
osdChangeScreen(currentMenu);
|
||||
|
||||
#ifdef LED_STRIP
|
||||
getLedColor();
|
||||
#endif // LED_STRIP
|
||||
|
@ -1450,16 +1455,16 @@ void osdOpenMenu(void)
|
|||
|
||||
void osdDrawElementPositioningHelp(void)
|
||||
{
|
||||
max7456_write(OSD_X(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]), OSD_Y(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]), "--- HELP --- ");
|
||||
max7456_write(OSD_X(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]), OSD_Y(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]) + 1, "USE ROLL/PITCH");
|
||||
max7456_write(OSD_X(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]), OSD_Y(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]) + 2, "TO MOVE ELEM. ");
|
||||
max7456_write(OSD_X(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]), OSD_Y(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]) + 3, " ");
|
||||
max7456_write(OSD_X(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]), OSD_Y(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]) + 4, "YAW - EXIT ");
|
||||
max7456Write(OSD_X(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]), OSD_Y(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]), "--- HELP --- ");
|
||||
max7456Write(OSD_X(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]), OSD_Y(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]) + 1, "USE ROLL/PITCH");
|
||||
max7456Write(OSD_X(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]), OSD_Y(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]) + 2, "TO MOVE ELEM. ");
|
||||
max7456Write(OSD_X(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]), OSD_Y(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]) + 3, " ");
|
||||
max7456Write(OSD_X(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]), OSD_Y(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]) + 4, "YAW - EXIT ");
|
||||
}
|
||||
|
||||
void osdDrawElements(void)
|
||||
{
|
||||
max7456_clear_screen();
|
||||
max7456ClearScreen();
|
||||
|
||||
if (currentElement)
|
||||
osdDrawElementPositioningHelp();
|
||||
|
@ -1595,7 +1600,7 @@ void osdDrawSingleElement(uint8_t item)
|
|||
else if (FLIGHT_MODE(HORIZON_MODE))
|
||||
p = "HOR";
|
||||
|
||||
max7456_write(elemPosX, elemPosY, p);
|
||||
max7456Write(elemPosX, elemPosY, p);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1632,7 +1637,7 @@ void osdDrawSingleElement(uint8_t item)
|
|||
|
||||
case OSD_ARTIFICIAL_HORIZON:
|
||||
{
|
||||
uint8_t *screenBuffer = max7456_get_screen_buffer();
|
||||
uint8_t *screenBuffer = max7456GetScreenBuffer();
|
||||
uint16_t position = 194;
|
||||
|
||||
int rollAngle = attitude.values.roll;
|
||||
|
@ -1673,7 +1678,7 @@ void osdDrawSingleElement(uint8_t item)
|
|||
|
||||
case OSD_HORIZON_SIDEBARS:
|
||||
{
|
||||
uint8_t *screenBuffer = max7456_get_screen_buffer();
|
||||
uint8_t *screenBuffer = max7456GetScreenBuffer();
|
||||
uint16_t position = 194;
|
||||
|
||||
if (maxScreenSize == VIDEO_BUFFER_CHARS_PAL)
|
||||
|
@ -1698,7 +1703,7 @@ void osdDrawSingleElement(uint8_t item)
|
|||
return;
|
||||
}
|
||||
|
||||
max7456_write(elemPosX, elemPosY, buff);
|
||||
max7456Write(elemPosX, elemPosY, buff);
|
||||
}
|
||||
|
||||
#endif // OSD
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue