1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 16:25:31 +03:00

Merge branch 'master' into development

This commit is contained in:
borisbstyle 2016-09-26 00:51:27 +02:00
commit 3c4608d6fa
4 changed files with 234 additions and 224 deletions

View file

@ -37,62 +37,63 @@
#include "max7456.h" #include "max7456.h"
#include "max7456_symbols.h" #include "max7456_symbols.h"
// On shared SPI bus we want to change clock for OSD chip and restore for other devices //on shared SPI buss we want to change clock for OSD chip and restore for other devices
#ifdef MAX7456_SPI_CLK #ifdef MAX7456_SPI_CLK
#define ENABLE_MAX7456 {spiSetDivisor(MAX7456_SPI_INSTANCE, MAX7456_SPI_CLK);IOLo(max7456CsPin);} #define ENABLE_MAX7456 {spiSetDivisor(MAX7456_SPI_INSTANCE, MAX7456_SPI_CLK);IOLo(max7456CsPin);}
#else #else
#define ENABLE_MAX7456 IOLo(max7456CsPin) #define ENABLE_MAX7456 IOLo(max7456CsPin)
#endif #endif
#ifdef MAX7456_RESTORE_CLK #ifdef MAX7456_RESTORE_CLK
#define DISABLE_MAX7456 {IOHi(max7456CsPin);spiSetDivisor(MAX7456_SPI_INSTANCE, MAX7456_RESTORE_CLK);} #define DISABLE_MAX7456 {IOHi(max7456CsPin);spiSetDivisor(MAX7456_SPI_INSTANCE, MAX7456_RESTORE_CLK);}
#else #else
#define DISABLE_MAX7456 IOHi(max7456CsPin) #define DISABLE_MAX7456 IOHi(max7456CsPin)
#endif #endif
uint16_t maxScreenSize = VIDEO_BUFFER_CHARS_PAL; uint16_t maxScreenSize = VIDEO_BUFFER_CHARS_PAL;
// we write everything in SCREEN_BUFFER and then comapre
// SCREEN_BUFFER with SHADOW_BUFFER to upgrade only changed chars
// this solution is faster then redraw all screen
static uint8_t SCREEN_BUFFER[VIDEO_BUFFER_CHARS_PAL + 40]; //for faster writes we use memcpy so we need some space to don't overwrite buffer // we write everything in screenBuffer and then comapre
static uint8_t SHADOW_BUFFER[VIDEO_BUFFER_CHARS_PAL]; // screenBuffer with shadowBuffer to upgrade only changed chars
// this solution is faster then redraw all screen
static uint8_t screenBuffer[VIDEO_BUFFER_CHARS_PAL+40]; //for faster writes we use memcpy so we need some space to don't overwrite buffer
static uint8_t shadowBuffer[VIDEO_BUFFER_CHARS_PAL];
//max chars to update in one idle //max chars to update in one idle
#define MAX_CHARS2UPDATE 100 #define MAX_CHARS2UPDATE 100
#ifdef MAX7456_DMA_CHANNEL_TX #ifdef MAX7456_DMA_CHANNEL_TX
volatile bool dmaTxInProgress = false; volatile bool dmaTransactionInProgress = false;
#endif // MAX7456_DMA_CHANNEL_TX #endif
static uint8_t spiBuffer[MAX_CHARS2UPDATE * 6]; static uint8_t spiBuff[MAX_CHARS2UPDATE*6];
static uint8_t videoSignalCfg = 0; static uint8_t videoSignalCfg = 0;
static uint8_t videoSignalReg = VIDEO_MODE_PAL | OSD_ENABLE; //PAL by default static uint8_t videoSignalReg = VIDEO_MODE_PAL | OSD_ENABLE; //PAL by default
static bool max7456Lock = false; static bool max7456Lock = false;
static IO_t max7456CsPin = IO_NONE; static bool fontIsLoading = false;
static bool fontIsLoading = false; static IO_t max7456CsPin = IO_NONE;
static uint8_t max7456_send(uint8_t add, uint8_t data)
static uint8_t max7456Send(uint8_t add, uint8_t data)
{ {
spiTransferByte(MAX7456_SPI_INSTANCE, add); spiTransferByte(MAX7456_SPI_INSTANCE, add);
return spiTransferByte(MAX7456_SPI_INSTANCE, data); return spiTransferByte(MAX7456_SPI_INSTANCE, data);
} }
#ifdef MAX7456_DMA_CHANNEL_TX #ifdef MAX7456_DMA_CHANNEL_TX
static void max7456_send_dma(void* tx_buffer, void* rx_buffer, uint16_t buffer_size) static void max7456SendDma(void* tx_buffer, void* rx_buffer, uint16_t buffer_size)
{ {
DMA_InitTypeDef DMA_InitStructure; DMA_InitTypeDef DMA_InitStructure;
#ifdef MAX7456_DMA_CHANNEL_RX #ifdef MAX7456_DMA_CHANNEL_RX
static uint16_t dummy[] = {0xffff}; static uint16_t dummy[] = {0xffff};
#else // MAX7456_DMA_CHANNEL_RX #else
UNUSED(rx_buffer); UNUSED(rx_buffer);
#endif // MAX7456_DMA_CHANNEL_RX #endif
while (dmaTxInProgress); // Wait for prev DMA transaction while (dmaTransactionInProgress); // Wait for prev DMA transaction
DMA_DeInit(MAX7456_DMA_CHANNEL_TX); DMA_DeInit(MAX7456_DMA_CHANNEL_TX);
#ifdef MAX7456_DMA_CHANNEL_RX #ifdef MAX7456_DMA_CHANNEL_RX
DMA_DeInit(MAX7456_DMA_CHANNEL_RX); DMA_DeInit(MAX7456_DMA_CHANNEL_RX);
#endif // MAX7456_DMA_CHANNEL_RX #endif
// Common to both channels // Common to both channels
DMA_StructInit(&DMA_InitStructure); DMA_StructInit(&DMA_InitStructure);
@ -109,24 +110,24 @@ static void max7456_send_dma(void* tx_buffer, void* rx_buffer, uint16_t buffer_s
#ifdef STM32F4 #ifdef STM32F4
DMA_InitStructure.DMA_Memory0BaseAddr = rx_buffer ? (uint32_t)rx_buffer : (uint32_t)(dummy); DMA_InitStructure.DMA_Memory0BaseAddr = rx_buffer ? (uint32_t)rx_buffer : (uint32_t)(dummy);
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
#else // STM32F4 #else
DMA_InitStructure.DMA_MemoryBaseAddr = rx_buffer ? (uint32_t)rx_buffer : (uint32_t)(dummy); DMA_InitStructure.DMA_MemoryBaseAddr = rx_buffer ? (uint32_t)rx_buffer : (uint32_t)(dummy);
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
#endif // STM32F4 #endif
DMA_InitStructure.DMA_MemoryInc = rx_buffer ? DMA_MemoryInc_Enable : DMA_MemoryInc_Disable; DMA_InitStructure.DMA_MemoryInc = rx_buffer ? DMA_MemoryInc_Enable : DMA_MemoryInc_Disable;
DMA_Init(MAX7456_DMA_CHANNEL_RX, &DMA_InitStructure); DMA_Init(MAX7456_DMA_CHANNEL_RX, &DMA_InitStructure);
DMA_Cmd(MAX7456_DMA_CHANNEL_RX, ENABLE); DMA_Cmd(MAX7456_DMA_CHANNEL_RX, ENABLE);
#endif // MAX7456_DMA_CHANNEL_RX #endif
// Tx channel // Tx channel
#ifdef STM32F4 #ifdef STM32F4
DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)tx_buffer; //max7456_screen; DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)tx_buffer; //max7456_screen;
DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral; DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral;
#else // STM32F4 #else
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)tx_buffer; //max7456_screen; DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)tx_buffer; //max7456_screen;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
#endif // STM32F4 #endif
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_Init(MAX7456_DMA_CHANNEL_TX, &DMA_InitStructure); DMA_Init(MAX7456_DMA_CHANNEL_TX, &DMA_InitStructure);
@ -134,18 +135,18 @@ static void max7456_send_dma(void* tx_buffer, void* rx_buffer, uint16_t buffer_s
#ifdef MAX7456_DMA_CHANNEL_RX #ifdef MAX7456_DMA_CHANNEL_RX
DMA_ITConfig(MAX7456_DMA_CHANNEL_RX, DMA_IT_TC, ENABLE); DMA_ITConfig(MAX7456_DMA_CHANNEL_RX, DMA_IT_TC, ENABLE);
#else // MAX7456_DMA_CHANNEL_RX #else
DMA_ITConfig(MAX7456_DMA_CHANNEL_TX, DMA_IT_TC, ENABLE); DMA_ITConfig(MAX7456_DMA_CHANNEL_TX, DMA_IT_TC, ENABLE);
#endif // MAX7456_DMA_CHANNEL_RX #endif
// Enable SPI TX/RX request // Enable SPI TX/RX request
ENABLE_MAX7456; ENABLE_MAX7456;
dmaTxInProgress = true; dmaTransactionInProgress = true;
SPI_I2S_DMACmd(MAX7456_SPI_INSTANCE, SPI_I2S_DMACmd(MAX7456_SPI_INSTANCE,
#ifdef MAX7456_DMA_CHANNEL_RX #ifdef MAX7456_DMA_CHANNEL_RX
SPI_I2S_DMAReq_Rx | SPI_I2S_DMAReq_Rx |
#endif // MAX7456_DMA_CHANNEL_RX #endif
SPI_I2S_DMAReq_Tx, ENABLE); SPI_I2S_DMAReq_Tx, ENABLE);
} }
@ -154,7 +155,7 @@ void max7456_dma_irq_handler(dmaChannelDescriptor_t* descriptor)
if (DMA_GET_FLAG_STATUS(descriptor, DMA_IT_TCIF)) { if (DMA_GET_FLAG_STATUS(descriptor, DMA_IT_TCIF)) {
#ifdef MAX7456_DMA_CHANNEL_RX #ifdef MAX7456_DMA_CHANNEL_RX
DMA_Cmd(MAX7456_DMA_CHANNEL_RX, DISABLE); DMA_Cmd(MAX7456_DMA_CHANNEL_RX, DISABLE);
#endif // MAX7456_DMA_CHANNEL_RX #endif
// make sure spi dmd transfer is complete // make sure spi dmd transfer is complete
while (SPI_I2S_GetFlagStatus (MAX7456_SPI_INSTANCE, SPI_I2S_FLAG_TXE) == RESET) {}; while (SPI_I2S_GetFlagStatus (MAX7456_SPI_INSTANCE, SPI_I2S_FLAG_TXE) == RESET) {};
while (SPI_I2S_GetFlagStatus (MAX7456_SPI_INSTANCE, SPI_I2S_FLAG_BSY) == SET) {}; while (SPI_I2S_GetFlagStatus (MAX7456_SPI_INSTANCE, SPI_I2S_FLAG_BSY) == SET) {};
@ -172,11 +173,11 @@ void max7456_dma_irq_handler(dmaChannelDescriptor_t* descriptor)
SPI_I2S_DMACmd(MAX7456_SPI_INSTANCE, SPI_I2S_DMACmd(MAX7456_SPI_INSTANCE,
#ifdef MAX7456_DMA_CHANNEL_RX #ifdef MAX7456_DMA_CHANNEL_RX
SPI_I2S_DMAReq_Rx | SPI_I2S_DMAReq_Rx |
#endif // MAX7456_DMA_CHANNEL_RX #endif
SPI_I2S_DMAReq_Tx, DISABLE); SPI_I2S_DMAReq_Tx, DISABLE);
DISABLE_MAX7456; DISABLE_MAX7456;
dmaTxInProgress = false; dmaTransactionInProgress = false;
} }
if (DMA_GET_FLAG_STATUS(descriptor, DMA_IT_HTIF)) { if (DMA_GET_FLAG_STATUS(descriptor, DMA_IT_HTIF)) {
@ -186,9 +187,10 @@ void max7456_dma_irq_handler(dmaChannelDescriptor_t* descriptor)
DMA_CLEAR_FLAG(descriptor, DMA_IT_TEIF); DMA_CLEAR_FLAG(descriptor, DMA_IT_TEIF);
} }
} }
#endif // MAX7456_DMA_CHANNEL_TX
uint8_t max7456_get_rows_count(void) #endif
uint8_t max7456GetRowsCount(void)
{ {
if (videoSignalReg & VIDEO_MODE_PAL) if (videoSignalReg & VIDEO_MODE_PAL)
return VIDEO_LINES_PAL; return VIDEO_LINES_PAL;
@ -198,7 +200,7 @@ uint8_t max7456_get_rows_count(void)
//because MAX7456 need some time to detect video system etc. we need to wait for a while to initialize it at startup //because MAX7456 need some time to detect video system etc. we need to wait for a while to initialize it at startup
//and in case of restart we need to reinitialize chip //and in case of restart we need to reinitialize chip
void max7456_init2(void) void max7456ReInit(void)
{ {
uint8_t maxScreenRows; uint8_t maxScreenRows;
uint8_t srdata = 0; uint8_t srdata = 0;
@ -219,7 +221,7 @@ void max7456_init2(void)
videoSignalReg = VIDEO_MODE_NTSC | OSD_ENABLE; videoSignalReg = VIDEO_MODE_NTSC | OSD_ENABLE;
break; break;
default: default:
srdata = max7456_send(MAX7456ADD_STAT, 0x00); srdata = max7456Send(MAX7456ADD_STAT, 0x00);
if ((0x02 & srdata) == 0x02) if ((0x02 & srdata) == 0x02)
videoSignalReg = VIDEO_MODE_NTSC | OSD_ENABLE; videoSignalReg = VIDEO_MODE_NTSC | OSD_ENABLE;
} }
@ -234,79 +236,80 @@ void max7456_init2(void)
// set all rows to same charactor black/white level // set all rows to same charactor black/white level
for(x = 0; x < maxScreenRows; x++) { for(x = 0; x < maxScreenRows; x++) {
max7456_send(MAX7456ADD_RB0 + x, BWBRIGHTNESS); max7456Send(MAX7456ADD_RB0 + x, BWBRIGHTNESS);
} }
// make sure the Max7456 is enabled // make sure the Max7456 is enabled
max7456_send(VM0_REG, videoSignalReg); max7456Send(VM0_REG, videoSignalReg);
max7456_send(DMM_REG, CLEAR_DISPLAY); max7456Send(DMM_REG, CLEAR_DISPLAY);
DISABLE_MAX7456; DISABLE_MAX7456;
//clear shadow to force redraw all screen in non-dma mode //clear shadow to force redraw all screen in non-dma mode
memset(SHADOW_BUFFER, 0, maxScreenSize); memset(shadowBuffer, 0, maxScreenSize);
if (firstInit) { if (firstInit)
max7456_refresh_all(); {
max7456RefreshAll();
firstInit = false; firstInit = false;
} }
} }
//here we init only CS and try to init MAX for first time //here we init only CS and try to init MAX for first time
void max7456_init(uint8_t videoSystem) void max7456Init(uint8_t video_system)
{ {
#ifdef MAX7456_SPI_CS_PIN #ifdef MAX7456_SPI_CS_PIN
max7456CsPin = IOGetByTag(IO_TAG(MAX7456_SPI_CS_PIN)); max7456CsPin = IOGetByTag(IO_TAG(MAX7456_SPI_CS_PIN));
#endif // MAX7456_SPI_CS_PIN #endif
IOInit(max7456CsPin, OWNER_OSD, RESOURCE_SPI_CS, 0); IOInit(max7456CsPin, OWNER_OSD, RESOURCE_SPI_CS, 0);
IOConfigGPIO(max7456CsPin, SPI_IO_CS_CFG); IOConfigGPIO(max7456CsPin, SPI_IO_CS_CFG);
spiSetDivisor(MAX7456_SPI_INSTANCE, SPI_CLOCK_STANDARD); spiSetDivisor(MAX7456_SPI_INSTANCE, SPI_CLOCK_STANDARD);
// force soft reset on Max7456 // force soft reset on Max7456
ENABLE_MAX7456; ENABLE_MAX7456;
max7456_send(VM0_REG, MAX7456_RESET); max7456Send(VM0_REG, MAX7456_RESET);
DISABLE_MAX7456; DISABLE_MAX7456;
videoSignalCfg = videoSystem; videoSignalCfg = video_system;
#ifdef MAX7456_DMA_CHANNEL_TX #ifdef MAX7456_DMA_CHANNEL_TX
dmaSetHandler(MAX7456_DMA_IRQ_HANDLER_ID, max7456_dma_irq_handler, NVIC_PRIO_MAX7456_DMA, 0); dmaSetHandler(MAX7456_DMA_IRQ_HANDLER_ID, max7456_dma_irq_handler, NVIC_PRIO_MAX7456_DMA, 0);
#endif // MAX7456_DMA_CHANNEL_TX #endif
//real init will be made letter when driver idle detect //real init will be made letter when driver idle detect
} }
//just fill with spaces with some tricks //just fill with spaces with some tricks
void max7456_clear_screen(void) void max7456ClearScreen(void)
{ {
uint16_t x; uint16_t x;
uint32_t *p = (uint32_t*)&SCREEN_BUFFER[0]; uint32_t *p = (uint32_t*)&screenBuffer[0];
for (x = 0; x < VIDEO_BUFFER_CHARS_PAL/4; x++) for (x = 0; x < VIDEO_BUFFER_CHARS_PAL/4; x++)
p[x] = 0x20202020; p[x] = 0x20202020;
} }
uint8_t* max7456_get_screen_buffer(void) uint8_t* max7456GetScreenBuffer(void) {
{ return screenBuffer;
return SCREEN_BUFFER;
} }
void max7456_write_char(uint8_t x, uint8_t y, uint8_t c) void max7456WriteChar(uint8_t x, uint8_t y, uint8_t c)
{ {
SCREEN_BUFFER[y*30+x] = c; screenBuffer[y*30+x] = c;
} }
void max7456_write(uint8_t x, uint8_t y, char *buff) void max7456Write(uint8_t x, uint8_t y, char *buff)
{ {
uint8_t i = 0; uint8_t i = 0;
for (i = 0; *(buff+i); i++) for (i = 0; *(buff+i); i++)
if (x+i < 30) //do not write over screen if (x+i < 30) //do not write over screen
SCREEN_BUFFER[y*30+x+i] = *(buff+i); screenBuffer[y*30+x+i] = *(buff+i);
} }
#ifdef MAX7456_DMA_CHANNEL_TX #ifdef MAX7456_DMA_CHANNEL_TX
uint8_t max7456_dma_in_progres(void) bool max7456DmaInProgres(void)
{ {
return dmaTxInProgress; return dmaTransactionInProgress;
} }
#endif // MAX7456_DMA_CHANNEL_TX #endif
void max7456_draw_screen(void) void max7456DrawScreen(void)
{ {
uint8_t check; uint8_t check;
static uint16_t pos = 0; static uint16_t pos = 0;
@ -316,23 +319,23 @@ void max7456_draw_screen(void)
//-----------------detect MAX7456 fail, or initialize it at startup when it is ready-------- //-----------------detect MAX7456 fail, or initialize it at startup when it is ready--------
max7456Lock = true; max7456Lock = true;
ENABLE_MAX7456; ENABLE_MAX7456;
check = max7456_send(VM0_REG | 0x80, 0x00); check = max7456Send(VM0_REG | 0x80, 0x00);
DISABLE_MAX7456; DISABLE_MAX7456;
if ( check != videoSignalReg ) if ( check != videoSignalReg)
max7456_init2(); max7456ReInit();
//------------ end of (re)init------------------------------------- //------------ end of (re)init-------------------------------------
for (k=0; k< MAX_CHARS2UPDATE; k++) { for (k=0; k< MAX_CHARS2UPDATE; k++) {
if (SCREEN_BUFFER[pos] != SHADOW_BUFFER[pos]) { if (screenBuffer[pos] != shadowBuffer[pos]) {
spiBuffer[buff_len++] = MAX7456ADD_DMAH; spiBuff[buff_len++] = MAX7456ADD_DMAH;
spiBuffer[buff_len++] = pos >> 8; spiBuff[buff_len++] = pos >> 8;
spiBuffer[buff_len++] = MAX7456ADD_DMAL; spiBuff[buff_len++] = MAX7456ADD_DMAL;
spiBuffer[buff_len++] = pos & 0xff; spiBuff[buff_len++] = pos & 0xff;
spiBuffer[buff_len++] = MAX7456ADD_DMDI; spiBuff[buff_len++] = MAX7456ADD_DMDI;
spiBuffer[buff_len++] = SCREEN_BUFFER[pos]; spiBuff[buff_len++] = screenBuffer[pos];
SHADOW_BUFFER[pos] = SCREEN_BUFFER[pos]; shadowBuffer[pos] = screenBuffer[pos];
k++; k++;
} }
@ -343,52 +346,53 @@ void max7456_draw_screen(void)
} }
if (buff_len) { if (buff_len) {
#ifdef MAX7456_DMA_CHANNEL_TX #ifdef MAX7456_DMA_CHANNEL_TX
if (buff_len > 0) if (buff_len > 0)
max7456_send_dma(spiBuffer, NULL, buff_len); max7456SendDma(spiBuff, NULL, buff_len);
#else #else
ENABLE_MAX7456; ENABLE_MAX7456;
for (k=0; k < buff_len; k++) for (k=0; k < buff_len; k++)
spiTransferByte(MAX7456_SPI_INSTANCE, spiBuffer[k]); spiTransferByte(MAX7456_SPI_INSTANCE, spiBuff[k]);
DISABLE_MAX7456; DISABLE_MAX7456;
#endif // MAX7456_DMA_CHANNEL_TX #endif // MAX7456_DMA_CHANNEL_TX
} }
max7456Lock = 0; max7456Lock = false;
} }
} }
// this funcktion refresh all and should not be used when copter is armed // this funcktion refresh all and should not be used when copter is armed
void max7456_refresh_all(void) void max7456RefreshAll(void)
{ {
if (!max7456Lock) { if (!max7456Lock) {
#ifdef MAX7456_DMA_CHANNEL_TX #ifdef MAX7456_DMA_CHANNEL_TX
while (dmaTxInProgress); while (dmaTransactionInProgress);
#endif #endif
uint16_t xx; uint16_t xx;
max7456Lock = true; max7456Lock = true;
ENABLE_MAX7456; ENABLE_MAX7456;
max7456_send(MAX7456ADD_DMAH, 0); max7456Send(MAX7456ADD_DMAH, 0);
max7456_send(MAX7456ADD_DMAL, 0); max7456Send(MAX7456ADD_DMAL, 0);
max7456_send(MAX7456ADD_DMM, 1); max7456Send(MAX7456ADD_DMM, 1);
for (xx = 0; xx < maxScreenSize; ++xx) { for (xx = 0; xx < maxScreenSize; ++xx)
max7456_send(MAX7456ADD_DMDI, SCREEN_BUFFER[xx]); {
SHADOW_BUFFER[xx] = SCREEN_BUFFER[xx]; max7456Send(MAX7456ADD_DMDI, screenBuffer[xx]);
shadowBuffer[xx] = screenBuffer[xx];
} }
max7456_send(MAX7456ADD_DMDI, 0xFF); max7456Send(MAX7456ADD_DMDI, 0xFF);
max7456_send(MAX7456ADD_DMM, 0); max7456Send(MAX7456ADD_DMM, 0);
DISABLE_MAX7456; DISABLE_MAX7456;
max7456Lock = 0; max7456Lock = false;
} }
} }
void max7456_write_nvm(uint8_t char_address, uint8_t *font_data) void max7456WriteNvm(uint8_t char_address, uint8_t *font_data)
{ {
uint8_t x; uint8_t x;
#ifdef MAX7456_DMA_CHANNEL_TX #ifdef MAX7456_DMA_CHANNEL_TX
while (dmaTxInProgress); while (dmaTransactionInProgress);
#endif #endif
while (max7456Lock); while (max7456Lock);
max7456Lock = true; max7456Lock = true;
@ -396,29 +400,30 @@ void max7456_write_nvm(uint8_t char_address, uint8_t *font_data)
ENABLE_MAX7456; ENABLE_MAX7456;
// disable display // disable display
fontIsLoading = true; fontIsLoading = true;
max7456_send(VM0_REG, 0); max7456Send(VM0_REG, 0);
max7456_send(MAX7456ADD_CMAH, char_address); // set start address high max7456Send(MAX7456ADD_CMAH, char_address); // set start address high
for(x = 0; x < 54; x++) { for(x = 0; x < 54; x++) {
max7456_send(MAX7456ADD_CMAL, x); //set start address low max7456Send(MAX7456ADD_CMAL, x); //set start address low
max7456_send(MAX7456ADD_CMDI, font_data[x]); max7456Send(MAX7456ADD_CMDI, font_data[x]);
#ifdef LED0_TOGGLE #ifdef LED0_TOGGLE
LED0_TOGGLE; LED0_TOGGLE;
#else // LED0_TOGGLE #else
LED1_TOGGLE; LED1_TOGGLE;
#endif // LED0_TOGGLE #endif
} }
// transfer 54 bytes from shadow ram to NVM // transfer 54 bytes from shadow ram to NVM
max7456_send(MAX7456ADD_CMM, WRITE_NVR); max7456Send(MAX7456ADD_CMM, WRITE_NVR);
// wait until bit 5 in the status register returns to 0 (12ms) // wait until bit 5 in the status register returns to 0 (12ms)
while ((max7456_send(MAX7456ADD_STAT, 0x00) & STATUS_REG_NVR_BUSY) != 0x00); while ((max7456Send(MAX7456ADD_STAT, 0x00) & STATUS_REG_NVR_BUSY) != 0x00);
DISABLE_MAX7456; DISABLE_MAX7456;
max7456Lock = 0; max7456Lock = false;
} }
#endif // USE_MAX7456
#endif

View file

@ -20,7 +20,6 @@
#ifndef WHITEBRIGHTNESS #ifndef WHITEBRIGHTNESS
#define WHITEBRIGHTNESS 0x01 #define WHITEBRIGHTNESS 0x01
#endif #endif
#ifndef BLACKBRIGHTNESS #ifndef BLACKBRIGHTNESS
#define BLACKBRIGHTNESS 0x00 #define BLACKBRIGHTNESS 0x00
#endif #endif
@ -36,18 +35,19 @@
#define VM1_REG 0x01 #define VM1_REG 0x01
// video mode register 0 bits // video mode register 0 bits
#define VIDEO_BUFFER_DISABLE 0x01 #define VIDEO_BUFFER_DISABLE 0x01
#define MAX7456_RESET 0x02 #define MAX7456_RESET 0x02
#define VERTICAL_SYNC_NEXT_VSYNC 0x04 #define VERTICAL_SYNC_NEXT_VSYNC 0x04
#define OSD_ENABLE 0x08 #define OSD_ENABLE 0x08
#define SYNC_MODE_AUTO 0x00 #define SYNC_MODE_AUTO 0x00
#define SYNC_MODE_INTERNAL 0x30 #define SYNC_MODE_INTERNAL 0x30
#define SYNC_MODE_EXTERNAL 0x20 #define SYNC_MODE_EXTERNAL 0x20
#define VIDEO_MODE_PAL 0x40 #define VIDEO_MODE_PAL 0x40
#define VIDEO_MODE_NTSC 0x00 #define VIDEO_MODE_NTSC 0x00
// video mode register 1 bits // video mode register 1 bits
// duty cycle is on_off // duty cycle is on_off
#define BLINK_DUTY_CYCLE_50_50 0x00 #define BLINK_DUTY_CYCLE_50_50 0x00
#define BLINK_DUTY_CYCLE_33_66 0x01 #define BLINK_DUTY_CYCLE_33_66 0x01
@ -61,8 +61,8 @@
#define BLINK_TIME_3 0x0C #define BLINK_TIME_3 0x0C
// background mode brightness (percent) // background mode brightness (percent)
#define BACKGROUND_BRIGHTNESS_0 0x00 #define BACKGROUND_BRIGHTNESS_0 0x00
#define BACKGROUND_BRIGHTNESS_7 0x01 #define BACKGROUND_BRIGHTNESS_7 0x01
#define BACKGROUND_BRIGHTNESS_14 0x02 #define BACKGROUND_BRIGHTNESS_14 0x02
#define BACKGROUND_BRIGHTNESS_21 0x03 #define BACKGROUND_BRIGHTNESS_21 0x03
#define BACKGROUND_BRIGHTNESS_28 0x04 #define BACKGROUND_BRIGHTNESS_28 0x04
@ -73,9 +73,10 @@
#define BACKGROUND_MODE_GRAY 0x40 #define BACKGROUND_MODE_GRAY 0x40
//MAX7456 commands //MAX7456 commands
#define CLEAR_DISPLAY 0x04 #define CLEAR_DISPLAY 0x04
#define CLEAR_DISPLAY_VERT 0x06 #define CLEAR_DISPLAY_VERT 0x06
#define END_STRING 0xff #define END_STRING 0xff
#define MAX7456ADD_VM0 0x00 //0b0011100// 00 // 00 ,0011100 #define MAX7456ADD_VM0 0x00 //0b0011100// 00 // 00 ,0011100
#define MAX7456ADD_VM1 0x01 #define MAX7456ADD_VM1 0x01
@ -143,17 +144,16 @@ enum VIDEO_TYPES { AUTO = 0, PAL, NTSC };
extern uint16_t maxScreenSize; extern uint16_t maxScreenSize;
void max7456_init(uint8_t system); void max7456Init(uint8_t system);
void max7456_draw_screen(void); void max7456DrawScreen(void);
void max7456_write_string(const char *string, int16_t address); void max7456WriteNvm(uint8_t char_address, uint8_t *font_data);
void max7456_write_nvm(uint8_t char_address, uint8_t *font_data); uint8_t max7456GetRowsCount(void);
uint8_t max7456_get_rows_count(void); void max7456Write(uint8_t x, uint8_t y, char *buff);
void max7456_write(uint8_t x, uint8_t y, char *buff); void max7456WriteChar(uint8_t x, uint8_t y, uint8_t c);
void max7456_write_char(uint8_t x, uint8_t y, uint8_t c); void max7456ClearScreen(void);
void max7456_clear_screen(void); void max7456RefreshAll(void);
void max7456_refresh_all(void); uint8_t* max7456GetScreenBuffer(void);
uint8_t* max7456_get_screen_buffer(void);
#ifdef MAX7456_DMA_CHANNEL_TX #ifdef MAX7456_DMA_CHANNEL_TX
uint8_t max7456_dma_in_progres(void); bool max7456DmaInProgres(void);
#endif // MAX7456_DMA_CHANNEL_TX #endif // MAX7456_DMA_CHANNEL_TX

View file

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

View file

@ -1644,7 +1644,7 @@ static bool processInCommand(void)
for (i = 0; i < 54; i++) { for (i = 0; i < 54; i++) {
font_data[i] = read8(); font_data[i] = read8();
} }
max7456_write_nvm(addr, font_data); max7456WriteNvm(addr, font_data);
break; break;
#endif #endif