1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-19 22:35:23 +03:00

Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Marcin Baliniak 2016-09-25 11:24:51 +02:00
commit 0892c4786b
6 changed files with 1485 additions and 1613 deletions

View file

@ -136,7 +136,7 @@ typedef struct master_t {
#endif #endif
#ifdef OSD #ifdef OSD
osd_profile osdProfile; osd_profile_t osdProfile;
#endif #endif
profile_t profile[MAX_PROFILE_COUNT]; profile_t profile[MAX_PROFILE_COUNT];

View file

@ -37,7 +37,7 @@
#include "max7456.h" #include "max7456.h"
#include "max7456_symbols.h" #include "max7456_symbols.h"
//on shared SPI buss we want to change clock for OSD chip and restore for other devices // On shared SPI bus 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
@ -50,30 +50,29 @@
#define DISABLE_MAX7456 IOHi(max7456CsPin) #define DISABLE_MAX7456 IOHi(max7456CsPin)
#endif #endif
uint16_t max_screen_size = VIDEO_BUFFER_CHARS_PAL; uint16_t maxScreenSize = VIDEO_BUFFER_CHARS_PAL;
// we write everything in SCREEN_BUFFER and then comapre // we write everything in SCREEN_BUFFER and then comapre
// SCREEN_BUFFER with SHADOW_BUFFER to upgrade only changed chars // SCREEN_BUFFER with SHADOW_BUFFER to upgrade only changed chars
// this solution is faster then redraw all screen // 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 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
static uint8_t SHADOW_BUFFER[VIDEO_BUFFER_CHARS_PAL]; static uint8_t SHADOW_BUFFER[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 uint8_t dma_transaction_in_progress = 0; volatile bool dmaTxInProgress = false;
#endif #endif // MAX7456_DMA_CHANNEL_TX
static uint8_t spi_buff[MAX_CHARS2UPDATE*6]; static uint8_t spiBuffer[MAX_CHARS2UPDATE * 6];
static uint8_t video_signal_cfg = 0; static uint8_t videoSignalCfg = 0;
static uint8_t video_signal_reg = VIDEO_MODE_PAL | OSD_ENABLE; //PAL by default static uint8_t videoSignalReg = VIDEO_MODE_PAL | OSD_ENABLE; //PAL by default
static uint8_t max7456_lock = 0; static bool max7456Lock = false;
static IO_t max7456CsPin = IO_NONE; static IO_t max7456CsPin = IO_NONE;
static bool fontIsLoading = false; static bool fontIsLoading = false;
static uint8_t max7456_send(uint8_t add, uint8_t data) static uint8_t max7456_send(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);
} }
@ -83,15 +82,15 @@ static void max7456_send_dma(void* tx_buffer, void* rx_buffer, uint16_t buffer_s
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 #else // MAX7456_DMA_CHANNEL_RX
UNUSED(rx_buffer); UNUSED(rx_buffer);
#endif #endif // MAX7456_DMA_CHANNEL_RX
while (dma_transaction_in_progress); // Wait for prev DMA transaction while (dmaTxInProgress); // 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 #endif // MAX7456_DMA_CHANNEL_RX
// Common to both channels // Common to both channels
DMA_StructInit(&DMA_InitStructure); DMA_StructInit(&DMA_InitStructure);
@ -108,24 +107,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 #else // STM32F4
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 #endif // STM32F4
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 #endif // MAX7456_DMA_CHANNEL_RX
// 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 #else // STM32F4
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 #endif // STM32F4
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);
@ -133,18 +132,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 #else // MAX7456_DMA_CHANNEL_RX
DMA_ITConfig(MAX7456_DMA_CHANNEL_TX, DMA_IT_TC, ENABLE); DMA_ITConfig(MAX7456_DMA_CHANNEL_TX, DMA_IT_TC, ENABLE);
#endif #endif // MAX7456_DMA_CHANNEL_RX
// Enable SPI TX/RX request // Enable SPI TX/RX request
ENABLE_MAX7456; ENABLE_MAX7456;
dma_transaction_in_progress = 1; dmaTxInProgress = 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 #endif // MAX7456_DMA_CHANNEL_RX
SPI_I2S_DMAReq_Tx, ENABLE); SPI_I2S_DMAReq_Tx, ENABLE);
} }
@ -153,7 +152,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 #endif // MAX7456_DMA_CHANNEL_RX
// 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) {};
@ -171,11 +170,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 #endif // MAX7456_DMA_CHANNEL_RX
SPI_I2S_DMAReq_Tx, DISABLE); SPI_I2S_DMAReq_Tx, DISABLE);
DISABLE_MAX7456; DISABLE_MAX7456;
dma_transaction_in_progress = 0; dmaTxInProgress = false;
} }
if (DMA_GET_FLAG_STATUS(descriptor, DMA_IT_HTIF)) { if (DMA_GET_FLAG_STATUS(descriptor, DMA_IT_HTIF)) {
@ -185,12 +184,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
#endif uint8_t max7456_get_rows_count(void) {
if (videoSignalReg & VIDEO_MODE_PAL)
uint8_t max7456_get_rows_count(void)
{
if (video_signal_reg & VIDEO_MODE_PAL)
return VIDEO_LINES_PAL; return VIDEO_LINES_PAL;
return VIDEO_LINES_NTSC; return VIDEO_LINES_NTSC;
@ -198,12 +195,11 @@ 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 max7456_init2(void) {
{ uint8_t maxScreenRows;
uint8_t max_screen_rows;
uint8_t srdata = 0; uint8_t srdata = 0;
uint16_t x; uint16_t x;
static uint8_t first_init = 1; static bool firstInit = true;
//do not init MAX before camera power up correctly //do not init MAX before camera power up correctly
if (millis() < 1500) if (millis() < 1500)
@ -211,53 +207,50 @@ void max7456_init2(void)
ENABLE_MAX7456; ENABLE_MAX7456;
switch(video_signal_cfg) { switch(videoSignalCfg) {
case PAL: case PAL:
video_signal_reg = VIDEO_MODE_PAL | OSD_ENABLE; videoSignalReg = VIDEO_MODE_PAL | OSD_ENABLE;
break; break;
case NTSC: case NTSC:
video_signal_reg = VIDEO_MODE_NTSC | OSD_ENABLE; videoSignalReg = VIDEO_MODE_NTSC | OSD_ENABLE;
break; break;
default: default:
srdata = max7456_send(MAX7456ADD_STAT, 0x00); srdata = max7456_send(MAX7456ADD_STAT, 0x00);
if ((0x02 & srdata) == 0x02) if ((0x02 & srdata) == 0x02)
video_signal_reg = VIDEO_MODE_NTSC | OSD_ENABLE; videoSignalReg = VIDEO_MODE_NTSC | OSD_ENABLE;
} }
if (video_signal_reg & VIDEO_MODE_PAL) { //PAL if (videoSignalReg & VIDEO_MODE_PAL) { //PAL
max_screen_size = VIDEO_BUFFER_CHARS_PAL; maxScreenSize = VIDEO_BUFFER_CHARS_PAL;
max_screen_rows = VIDEO_LINES_PAL; maxScreenRows = VIDEO_LINES_PAL;
} else { // NTSC } else { // NTSC
max_screen_size = VIDEO_BUFFER_CHARS_NTSC; maxScreenSize = VIDEO_BUFFER_CHARS_NTSC;
max_screen_rows = VIDEO_LINES_NTSC; maxScreenRows = VIDEO_LINES_NTSC;
} }
// set all rows to same charactor black/white level // set all rows to same charactor black/white level
for(x = 0; x < max_screen_rows; x++) { for(x = 0; x < maxScreenRows; x++) {
max7456_send(MAX7456ADD_RB0 + x, BWBRIGHTNESS); max7456_send(MAX7456ADD_RB0 + x, BWBRIGHTNESS);
} }
// make sure the Max7456 is enabled // make sure the Max7456 is enabled
max7456_send(VM0_REG, video_signal_reg); max7456_send(VM0_REG, videoSignalReg);
max7456_send(DMM_REG, CLEAR_DISPLAY); max7456_send(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, max_screen_size); memset(SHADOW_BUFFER, 0, maxScreenSize);
if (first_init) if (firstInit) {
{
max7456_refresh_all(); max7456_refresh_all();
first_init = 0; 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 video_system) void max7456_init(uint8_t videoSystem) {
{
#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 #endif // MAX7456_SPI_CS_PIN
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);
@ -266,17 +259,16 @@ void max7456_init(uint8_t video_system)
ENABLE_MAX7456; ENABLE_MAX7456;
max7456_send(VM0_REG, MAX7456_RESET); max7456_send(VM0_REG, MAX7456_RESET);
DISABLE_MAX7456; DISABLE_MAX7456;
video_signal_cfg = video_system; videoSignalCfg = videoSystem;
#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 #endif // MAX7456_DMA_CHANNEL_TX
//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 max7456_clear_screen(void) {
{
uint16_t x; uint16_t x;
uint32_t *p = (uint32_t*)&SCREEN_BUFFER[0]; uint32_t *p = (uint32_t*)&SCREEN_BUFFER[0];
for (x = 0; x < VIDEO_BUFFER_CHARS_PAL/4; x++) for (x = 0; x < VIDEO_BUFFER_CHARS_PAL/4; x++)
@ -287,13 +279,11 @@ uint8_t* max7456_get_screen_buffer(void) {
return SCREEN_BUFFER; return SCREEN_BUFFER;
} }
void max7456_write_char(uint8_t x, uint8_t y, uint8_t c) void max7456_write_char(uint8_t x, uint8_t y, uint8_t c) {
{
SCREEN_BUFFER[y*30+x] = c; SCREEN_BUFFER[y*30+x] = c;
} }
void max7456_write(uint8_t x, uint8_t y, char *buff) void max7456_write(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
@ -301,80 +291,75 @@ void max7456_write(uint8_t x, uint8_t y, char *buff)
} }
#ifdef MAX7456_DMA_CHANNEL_TX #ifdef MAX7456_DMA_CHANNEL_TX
uint8_t max7456_dma_in_progres(void) uint8_t max7456_dma_in_progres(void) {
{ return dmaTxInProgress;
return dma_transaction_in_progress;
} }
#endif #endif // MAX7456_DMA_CHANNEL_TX
void max7456_draw_screen(void) { void max7456_draw_screen(void) {
uint8_t check; uint8_t check;
static uint16_t pos = 0; static uint16_t pos = 0;
int k = 0, buff_len=0; int k = 0, buff_len=0;
if (!max7456_lock && !fontIsLoading) { if (!max7456Lock && !fontIsLoading) {
//-----------------detect MAX7456 fail, or initialize it at startup when it is ready-------- //-----------------detect MAX7456 fail, or initialize it at startup when it is ready--------
max7456_lock = 1; max7456Lock = true;
ENABLE_MAX7456; ENABLE_MAX7456;
check = max7456_send(VM0_REG | 0x80, 0x00); check = max7456_send(VM0_REG | 0x80, 0x00);
DISABLE_MAX7456; DISABLE_MAX7456;
if ( check != video_signal_reg ) if ( check != videoSignalReg )
max7456_init2(); max7456_init2();
//------------ 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 (SCREEN_BUFFER[pos] != SHADOW_BUFFER[pos]) spiBuffer[buff_len++] = MAX7456ADD_DMAH;
{ spiBuffer[buff_len++] = pos >> 8;
spi_buff[buff_len++] = MAX7456ADD_DMAH; spiBuffer[buff_len++] = MAX7456ADD_DMAL;
spi_buff[buff_len++] = pos >> 8; spiBuffer[buff_len++] = pos & 0xff;
spi_buff[buff_len++] = MAX7456ADD_DMAL; spiBuffer[buff_len++] = MAX7456ADD_DMDI;
spi_buff[buff_len++] = pos & 0xff; spiBuffer[buff_len++] = SCREEN_BUFFER[pos];
spi_buff[buff_len++] = MAX7456ADD_DMDI;
spi_buff[buff_len++] = SCREEN_BUFFER[pos];
SHADOW_BUFFER[pos] = SCREEN_BUFFER[pos]; SHADOW_BUFFER[pos] = SCREEN_BUFFER[pos];
k++; k++;
} }
if (++pos >= max_screen_size) { if (++pos >= maxScreenSize) {
pos = 0; pos = 0;
break; break;
} }
} }
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(spi_buff, NULL, buff_len); max7456_send_dma(spiBuffer, 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, spi_buff[k]); spiTransferByte(MAX7456_SPI_INSTANCE, spiBuffer[k]);
DISABLE_MAX7456; DISABLE_MAX7456;
#endif // MAX7456_DMA_CHANNEL_TX #endif // MAX7456_DMA_CHANNEL_TX
} }
max7456_lock = 0; max7456Lock = 0;
} }
} }
// 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 max7456_refresh_all(void) {
{ if (!max7456Lock) {
if (!max7456_lock) {
#ifdef MAX7456_DMA_CHANNEL_TX #ifdef MAX7456_DMA_CHANNEL_TX
while (dma_transaction_in_progress); while (dmaTxInProgress);
#endif #endif
uint16_t xx; uint16_t xx;
max7456_lock = 1; max7456Lock = true;
ENABLE_MAX7456; ENABLE_MAX7456;
max7456_send(MAX7456ADD_DMAH, 0); max7456_send(MAX7456ADD_DMAH, 0);
max7456_send(MAX7456ADD_DMAL, 0); max7456_send(MAX7456ADD_DMAL, 0);
max7456_send(MAX7456ADD_DMM, 1); max7456_send(MAX7456ADD_DMM, 1);
for (xx = 0; xx < max_screen_size; ++xx) for (xx = 0; xx < maxScreenSize; ++xx) {
{
max7456_send(MAX7456ADD_DMDI, SCREEN_BUFFER[xx]); max7456_send(MAX7456ADD_DMDI, SCREEN_BUFFER[xx]);
SHADOW_BUFFER[xx] = SCREEN_BUFFER[xx]; SHADOW_BUFFER[xx] = SCREEN_BUFFER[xx];
} }
@ -382,7 +367,7 @@ void max7456_refresh_all(void)
max7456_send(MAX7456ADD_DMDI, 0xFF); max7456_send(MAX7456ADD_DMDI, 0xFF);
max7456_send(MAX7456ADD_DMM, 0); max7456_send(MAX7456ADD_DMM, 0);
DISABLE_MAX7456; DISABLE_MAX7456;
max7456_lock = 0; max7456Lock = 0;
} }
} }
@ -390,10 +375,10 @@ void max7456_write_nvm(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 (dma_transaction_in_progress); while (dmaTxInProgress);
#endif #endif
while (max7456_lock); while (max7456Lock);
max7456_lock = 1; max7456Lock = true;
ENABLE_MAX7456; ENABLE_MAX7456;
// disable display // disable display
@ -407,9 +392,9 @@ void max7456_write_nvm(uint8_t char_address, uint8_t *font_data) {
max7456_send(MAX7456ADD_CMDI, font_data[x]); max7456_send(MAX7456ADD_CMDI, font_data[x]);
#ifdef LED0_TOGGLE #ifdef LED0_TOGGLE
LED0_TOGGLE; LED0_TOGGLE;
#else #else // LED0_TOGGLE
LED1_TOGGLE; LED1_TOGGLE;
#endif #endif // LED0_TOGGLE
} }
// transfer 54 bytes from shadow ram to NVM // transfer 54 bytes from shadow ram to NVM
@ -420,8 +405,7 @@ void max7456_write_nvm(uint8_t char_address, uint8_t *font_data) {
DISABLE_MAX7456; DISABLE_MAX7456;
max7456_lock = 0; max7456Lock = 0;
} }
#endif // USE_MAX7456
#endif

View file

@ -20,6 +20,7 @@
#ifndef WHITEBRIGHTNESS #ifndef WHITEBRIGHTNESS
#define WHITEBRIGHTNESS 0x01 #define WHITEBRIGHTNESS 0x01
#endif #endif
#ifndef BLACKBRIGHTNESS #ifndef BLACKBRIGHTNESS
#define BLACKBRIGHTNESS 0x00 #define BLACKBRIGHTNESS 0x00
#endif #endif
@ -47,7 +48,6 @@
// 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
@ -77,7 +77,6 @@
#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
#define MAX7456ADD_HOS 0x02 #define MAX7456ADD_HOS 0x02
@ -142,7 +141,7 @@
enum VIDEO_TYPES { AUTO = 0, PAL, NTSC }; enum VIDEO_TYPES { AUTO = 0, PAL, NTSC };
extern uint16_t max_screen_size; extern uint16_t maxScreenSize;
void max7456_init(uint8_t system); void max7456_init(uint8_t system);
void max7456_draw_screen(void); void max7456_draw_screen(void);

View file

@ -109,7 +109,6 @@
#define SYM_GIMBAL 0x16 #define SYM_GIMBAL 0x16
#define SYM_GIMBAL1 0x17 #define SYM_GIMBAL1 0x17
// Sensor´s Presence // Sensor´s Presence
#define SYM_ACC 0xA0 #define SYM_ACC 0xA0
#define SYM_MAG 0xA1 #define SYM_MAG 0xA1
@ -133,11 +132,9 @@
#define SYM_AH_DECORATION_UP 0xC9 #define SYM_AH_DECORATION_UP 0xC9
#define SYM_AH_DECORATION_DOWN 0xCF #define SYM_AH_DECORATION_DOWN 0xCF
// AH Bars // AH Bars
#define SYM_AH_BAR9_0 0x80 #define SYM_AH_BAR9_0 0x80
// Temperature // Temperature
#define SYM_TEMP_F 0x0D #define SYM_TEMP_F 0x0D
#define SYM_TEMP_C 0x0E #define SYM_TEMP_C 0x0E
@ -223,4 +220,4 @@
#define SYM_MIN 0xB3 #define SYM_MIN 0xB3
#define SYM_AVG 0xB4 #define SYM_AVG 0xB4
#endif #endif // USE_MAX7456

File diff suppressed because it is too large Load diff

View file

@ -1,3 +1,20 @@
/*
* This file is part of Cleanflight.
*
* Cleanflight is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Cleanflight is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once #pragma once
#include <stdint.h> #include <stdint.h>
@ -28,7 +45,8 @@ typedef enum {
typedef struct { typedef struct {
uint16_t item_pos[OSD_MAX_ITEMS]; uint16_t item_pos[OSD_MAX_ITEMS];
//alarms
// Alarms
uint8_t rssi_alarm; uint8_t rssi_alarm;
uint16_t cap_alarm; uint16_t cap_alarm;
uint16_t time_alarm; uint16_t time_alarm;
@ -36,20 +54,15 @@ typedef struct {
uint8_t video_system; uint8_t video_system;
osd_unit_t units; osd_unit_t units;
} osd_profile; } osd_profile_t;
typedef struct { typedef struct {
int16_t max_speed; int16_t max_speed;
int16_t min_voltage; // /10 int16_t min_voltage; // /10
int16_t max_current; // /10 int16_t max_current; // /10
int16_t min_rssi; int16_t min_rssi;
} tStatistic; } statistic_t;
void osdInit(void); void osdInit(void);
void OSD_Update(uint8_t guiKey); void resetOsdConfig(osd_profile_t *osdProfile);
void OSD_OpenMenu(void);
void OSD_HandleGui(uint8_t cmd);
void OSD_ResetSettings(void);
void OSD_Message(char *line1, char *line2, uint8_t timeout);
void resetOsdConfig(osd_profile *osdProfile);
void updateOsd(void); void updateOsd(void);