mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 04:45:24 +03:00
Merge branch 'master' into development
Conflicts: src/main/build/version.h src/main/drivers/max7456.c src/main/io/osd.c src/main/io/osd.h src/main/target/OMNIBUSF4/target.c
This commit is contained in:
commit
03f340fe14
18 changed files with 2089 additions and 1018 deletions
|
@ -41,7 +41,7 @@ env:
|
||||||
# - TARGET=REVO_OPBL
|
# - TARGET=REVO_OPBL
|
||||||
# - TARGET=RMDO
|
# - TARGET=RMDO
|
||||||
# - TARGET=SINGULARITY
|
# - TARGET=SINGULARITY
|
||||||
# - TARGET=SIRINFPV
|
- TARGET=SIRINFPV
|
||||||
- TARGET=SPARKY
|
- TARGET=SPARKY
|
||||||
# - TARGET=SPARKY2
|
# - TARGET=SPARKY2
|
||||||
# - TARGET=SPARKY_OPBL
|
# - TARGET=SPARKY_OPBL
|
||||||
|
@ -53,7 +53,7 @@ env:
|
||||||
# - TARGET=X_RACERSPI
|
# - TARGET=X_RACERSPI
|
||||||
# - TARGET=ZCOREF3
|
# - TARGET=ZCOREF3
|
||||||
# - TARGET=RCEXPLORERF3
|
# - TARGET=RCEXPLORERF3
|
||||||
|
|
||||||
# use new docker environment
|
# use new docker environment
|
||||||
sudo: false
|
sudo: false
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@ typedef struct master_s {
|
||||||
#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];
|
||||||
|
|
|
@ -17,6 +17,9 @@
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
||||||
|
@ -24,35 +27,50 @@
|
||||||
|
|
||||||
#include "common/printf.h"
|
#include "common/printf.h"
|
||||||
|
|
||||||
#include "bus_spi.h"
|
#include "drivers/bus_spi.h"
|
||||||
#include "light_led.h"
|
#include "drivers/light_led.h"
|
||||||
#include "io.h"
|
#include "drivers/io.h"
|
||||||
#include "system.h"
|
#include "drivers/system.h"
|
||||||
#include "nvic.h"
|
#include "drivers/nvic.h"
|
||||||
#include "dma.h"
|
#include "drivers/dma.h"
|
||||||
|
|
||||||
#include "max7456.h"
|
#include "max7456.h"
|
||||||
#include "max7456_symbols.h"
|
#include "max7456_symbols.h"
|
||||||
|
|
||||||
#define DISABLE_MAX7456 IOHi(max7456CsPin)
|
// On shared SPI bus we want to change clock for OSD chip and restore for other devices
|
||||||
#define ENABLE_MAX7456 IOLo(max7456CsPin)
|
#ifdef MAX7456_SPI_CLK
|
||||||
|
#define ENABLE_MAX7456 {spiSetDivisor(MAX7456_SPI_INSTANCE, MAX7456_SPI_CLK);IOLo(max7456CsPin);}
|
||||||
uint16_t max_screen_size;
|
#else
|
||||||
static MAX7456_CHAR_TYPE max7456_screen[VIDEO_BUFFER_CHARS_PAL + 5];
|
#define ENABLE_MAX7456 IOLo(max7456CsPin)
|
||||||
#define SCREEN_BUFFER ((MAX7456_CHAR_TYPE*)&max7456_screen[3])
|
|
||||||
|
|
||||||
#ifdef MAX7456_DMA_CHANNEL_TX
|
|
||||||
volatile uint8_t dma_transaction_in_progress = 0;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static uint8_t video_signal_type = 0;
|
#ifdef MAX7456_RESTORE_CLK
|
||||||
static uint8_t max7456_lock = 0;
|
#define DISABLE_MAX7456 {IOHi(max7456CsPin);spiSetDivisor(MAX7456_SPI_INSTANCE, MAX7456_RESTORE_CLK);}
|
||||||
static IO_t max7456CsPin = IO_NONE;
|
#else
|
||||||
|
#define DISABLE_MAX7456 IOHi(max7456CsPin)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
MAX7456_CHAR_TYPE* max7456_get_screen_buffer(void) {
|
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
|
||||||
return SCREEN_BUFFER;
|
static uint8_t SHADOW_BUFFER[VIDEO_BUFFER_CHARS_PAL];
|
||||||
}
|
|
||||||
|
//max chars to update in one idle
|
||||||
|
#define MAX_CHARS2UPDATE 100
|
||||||
|
#ifdef MAX7456_DMA_CHANNEL_TX
|
||||||
|
volatile bool dmaTxInProgress = false;
|
||||||
|
#endif // MAX7456_DMA_CHANNEL_TX
|
||||||
|
|
||||||
|
static uint8_t spiBuffer[MAX_CHARS2UPDATE * 6];
|
||||||
|
|
||||||
|
static uint8_t videoSignalCfg = 0;
|
||||||
|
static uint8_t videoSignalReg = VIDEO_MODE_PAL | OSD_ENABLE; //PAL by default
|
||||||
|
static bool max7456Lock = false;
|
||||||
|
static IO_t max7456CsPin = IO_NONE;
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
|
@ -61,19 +79,20 @@ static uint8_t max7456_send(uint8_t add, uint8_t 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 max7456_send_dma(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
|
#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);
|
||||||
|
@ -90,24 +109,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);
|
||||||
|
@ -115,31 +134,37 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
void max7456_dma_irq_handler(dmaChannelDescriptor_t* descriptor) {
|
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);
|
||||||
#else
|
#endif // MAX7456_DMA_CHANNEL_RX
|
||||||
|
// 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_BSY) == SET) {};
|
||||||
|
|
||||||
//Empty RX buffer. RX DMA takes care of it if enabled
|
//Empty RX buffer. RX DMA takes care of it if enabled
|
||||||
|
//this should be done after transmission finish!!!
|
||||||
while (SPI_I2S_GetFlagStatus(MAX7456_SPI_INSTANCE, SPI_I2S_FLAG_RXNE) == SET) {
|
while (SPI_I2S_GetFlagStatus(MAX7456_SPI_INSTANCE, SPI_I2S_FLAG_RXNE) == SET) {
|
||||||
MAX7456_SPI_INSTANCE->DR;
|
MAX7456_SPI_INSTANCE->DR;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
DMA_Cmd(MAX7456_DMA_CHANNEL_TX, DISABLE);
|
DMA_Cmd(MAX7456_DMA_CHANNEL_TX, DISABLE);
|
||||||
|
|
||||||
DMA_CLEAR_FLAG(descriptor, DMA_IT_TCIF);
|
DMA_CLEAR_FLAG(descriptor, DMA_IT_TCIF);
|
||||||
|
@ -147,139 +172,231 @@ 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;
|
||||||
for (uint16_t x = 0; x < max_screen_size; x++)
|
dmaTxInProgress = false;
|
||||||
max7456_screen[x + 3] = MAX7456_CHAR(' ');
|
}
|
||||||
dma_transaction_in_progress = 0;
|
|
||||||
|
if (DMA_GET_FLAG_STATUS(descriptor, DMA_IT_HTIF)) {
|
||||||
|
DMA_CLEAR_FLAG(descriptor, DMA_IT_HTIF);
|
||||||
|
}
|
||||||
|
if (DMA_GET_FLAG_STATUS(descriptor, DMA_IT_TEIF)) {
|
||||||
|
DMA_CLEAR_FLAG(descriptor, DMA_IT_TEIF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif // MAX7456_DMA_CHANNEL_TX
|
||||||
|
|
||||||
void max7456_init(uint8_t video_system)
|
uint8_t max7456_get_rows_count(void)
|
||||||
{
|
{
|
||||||
uint8_t max_screen_rows;
|
if (videoSignalReg & VIDEO_MODE_PAL)
|
||||||
|
return VIDEO_LINES_PAL;
|
||||||
|
|
||||||
|
return VIDEO_LINES_NTSC;
|
||||||
|
}
|
||||||
|
|
||||||
|
//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
|
||||||
|
void max7456_init2(void)
|
||||||
|
{
|
||||||
|
uint8_t maxScreenRows;
|
||||||
uint8_t srdata = 0;
|
uint8_t srdata = 0;
|
||||||
uint16_t x;
|
uint16_t x;
|
||||||
|
static bool firstInit = true;
|
||||||
|
|
||||||
#ifdef MAX7456_SPI_CS_PIN
|
//do not init MAX before camera power up correctly
|
||||||
max7456CsPin = IOGetByTag(IO_TAG(MAX7456_SPI_CS_PIN));
|
if (millis() < 1500)
|
||||||
#endif
|
return;
|
||||||
IOInit(max7456CsPin, OWNER_OSD, RESOURCE_SPI_CS, 0);
|
|
||||||
IOConfigGPIO(max7456CsPin, SPI_IO_CS_CFG);
|
|
||||||
|
|
||||||
//Minimum spi clock period for max7456 is 100ns (10Mhz)
|
|
||||||
spiSetDivisor(MAX7456_SPI_INSTANCE, SPI_CLOCK_STANDARD);
|
|
||||||
|
|
||||||
delay(1000);
|
|
||||||
// force soft reset on Max7456
|
|
||||||
ENABLE_MAX7456;
|
ENABLE_MAX7456;
|
||||||
max7456_send(VM0_REG, MAX7456_RESET);
|
|
||||||
delay(100);
|
|
||||||
|
|
||||||
srdata = max7456_send(0xA0, 0xFF);
|
switch(videoSignalCfg) {
|
||||||
if ((0x01 & srdata) == 0x01) { //PAL
|
|
||||||
video_signal_type = VIDEO_MODE_PAL;
|
|
||||||
}
|
|
||||||
else if ((0x02 & srdata) == 0x02) { //NTSC
|
|
||||||
video_signal_type = VIDEO_MODE_NTSC;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Override detected type: 0-AUTO, 1-PAL, 2-NTSC
|
|
||||||
switch(video_system) {
|
|
||||||
case PAL:
|
case PAL:
|
||||||
video_signal_type = VIDEO_MODE_PAL;
|
videoSignalReg = VIDEO_MODE_PAL | OSD_ENABLE;
|
||||||
break;
|
break;
|
||||||
case NTSC:
|
case NTSC:
|
||||||
video_signal_type = VIDEO_MODE_NTSC;
|
videoSignalReg = VIDEO_MODE_NTSC | OSD_ENABLE;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
srdata = max7456_send(MAX7456ADD_STAT, 0x00);
|
||||||
|
if ((0x02 & srdata) == 0x02)
|
||||||
|
videoSignalReg = VIDEO_MODE_NTSC | OSD_ENABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (video_signal_type) { //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, OSD_ENABLE | video_signal_type);
|
max7456_send(VM0_REG, videoSignalReg);
|
||||||
|
max7456_send(DMM_REG, CLEAR_DISPLAY);
|
||||||
DISABLE_MAX7456;
|
DISABLE_MAX7456;
|
||||||
delay(100);
|
|
||||||
|
|
||||||
for (x = 0; x < max_screen_size; x++)
|
//clear shadow to force redraw all screen in non-dma mode
|
||||||
SCREEN_BUFFER[x] = MAX7456_CHAR(' ');
|
memset(SHADOW_BUFFER, 0, maxScreenSize);
|
||||||
|
if (firstInit) {
|
||||||
#ifdef MAX7456_DMA_CHANNEL_TX
|
max7456_refresh_all();
|
||||||
max7456_screen[0] = (uint16_t)(MAX7456ADD_DMAH | (0 << 8));
|
firstInit = false;
|
||||||
max7456_screen[1] = (uint16_t)(MAX7456ADD_DMAL | (0 << 8));
|
|
||||||
max7456_screen[2] = (uint16_t)(MAX7456ADD_DMM | (1 << 8));
|
|
||||||
max7456_screen[max_screen_size + 3] = (uint16_t)(MAX7456ADD_DMDI | (0xFF << 8));
|
|
||||||
max7456_screen[max_screen_size + 4] = (uint16_t)(MAX7456ADD_DMM | (0 << 8));
|
|
||||||
|
|
||||||
dmaSetHandler(MAX7456_DMA_IRQ_HANDLER_ID, max7456_dma_irq_handler, NVIC_PRIO_MAX7456_DMA, 0);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy string from ram into screen buffer
|
|
||||||
void max7456_write_string(const char *string, int16_t address) {
|
|
||||||
MAX7456_CHAR_TYPE *dest;
|
|
||||||
|
|
||||||
if (address >= 0)
|
|
||||||
dest = SCREEN_BUFFER + address;
|
|
||||||
else
|
|
||||||
dest = SCREEN_BUFFER + (max_screen_size + address);
|
|
||||||
|
|
||||||
while(*string && dest < (SCREEN_BUFFER + max_screen_size)) {
|
|
||||||
*dest++ = MAX7456_CHAR(*string++);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void max7456_draw_screen(void) {
|
//here we init only CS and try to init MAX for first time
|
||||||
if (!max7456_lock) {
|
void max7456_init(uint8_t videoSystem)
|
||||||
#ifdef MAX7456_DMA_CHANNEL_TX
|
{
|
||||||
max7456_send_dma(max7456_screen, NULL, max_screen_size * 2 + 10);
|
#ifdef MAX7456_SPI_CS_PIN
|
||||||
#else
|
max7456CsPin = IOGetByTag(IO_TAG(MAX7456_SPI_CS_PIN));
|
||||||
uint16_t xx;
|
#endif // MAX7456_SPI_CS_PIN
|
||||||
max7456_lock = 1;
|
IOInit(max7456CsPin, OWNER_OSD, RESOURCE_SPI_CS, 0);
|
||||||
|
IOConfigGPIO(max7456CsPin, SPI_IO_CS_CFG);
|
||||||
|
|
||||||
|
spiSetDivisor(MAX7456_SPI_INSTANCE, SPI_CLOCK_STANDARD);
|
||||||
|
// force soft reset on Max7456
|
||||||
|
ENABLE_MAX7456;
|
||||||
|
max7456_send(VM0_REG, MAX7456_RESET);
|
||||||
|
DISABLE_MAX7456;
|
||||||
|
videoSignalCfg = videoSystem;
|
||||||
|
|
||||||
|
#ifdef MAX7456_DMA_CHANNEL_TX
|
||||||
|
dmaSetHandler(MAX7456_DMA_IRQ_HANDLER_ID, max7456_dma_irq_handler, NVIC_PRIO_MAX7456_DMA, 0);
|
||||||
|
#endif // MAX7456_DMA_CHANNEL_TX
|
||||||
|
//real init will be made letter when driver idle detect
|
||||||
|
}
|
||||||
|
|
||||||
|
//just fill with spaces with some tricks
|
||||||
|
void max7456_clear_screen(void)
|
||||||
|
{
|
||||||
|
uint16_t x;
|
||||||
|
uint32_t *p = (uint32_t*)&SCREEN_BUFFER[0];
|
||||||
|
for (x = 0; x < VIDEO_BUFFER_CHARS_PAL/4; x++)
|
||||||
|
p[x] = 0x20202020;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t* max7456_get_screen_buffer(void)
|
||||||
|
{
|
||||||
|
return SCREEN_BUFFER;
|
||||||
|
}
|
||||||
|
|
||||||
|
void max7456_write_char(uint8_t x, uint8_t y, uint8_t c)
|
||||||
|
{
|
||||||
|
SCREEN_BUFFER[y*30+x] = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
void max7456_write(uint8_t x, uint8_t y, char *buff)
|
||||||
|
{
|
||||||
|
uint8_t i = 0;
|
||||||
|
for (i = 0; *(buff+i); i++)
|
||||||
|
if (x+i < 30) //do not write over screen
|
||||||
|
SCREEN_BUFFER[y*30+x+i] = *(buff+i);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef MAX7456_DMA_CHANNEL_TX
|
||||||
|
uint8_t max7456_dma_in_progres(void)
|
||||||
|
{
|
||||||
|
return dmaTxInProgress;
|
||||||
|
}
|
||||||
|
#endif // MAX7456_DMA_CHANNEL_TX
|
||||||
|
|
||||||
|
void max7456_draw_screen(void)
|
||||||
|
{
|
||||||
|
uint8_t check;
|
||||||
|
static uint16_t pos = 0;
|
||||||
|
int k = 0, buff_len=0;
|
||||||
|
|
||||||
|
if (!max7456Lock && !fontIsLoading) {
|
||||||
|
//-----------------detect MAX7456 fail, or initialize it at startup when it is ready--------
|
||||||
|
max7456Lock = true;
|
||||||
|
ENABLE_MAX7456;
|
||||||
|
check = max7456_send(VM0_REG | 0x80, 0x00);
|
||||||
|
DISABLE_MAX7456;
|
||||||
|
|
||||||
|
if ( check != videoSignalReg )
|
||||||
|
max7456_init2();
|
||||||
|
|
||||||
|
//------------ end of (re)init-------------------------------------
|
||||||
|
|
||||||
|
for (k=0; k< MAX_CHARS2UPDATE; k++) {
|
||||||
|
if (SCREEN_BUFFER[pos] != SHADOW_BUFFER[pos]) {
|
||||||
|
spiBuffer[buff_len++] = MAX7456ADD_DMAH;
|
||||||
|
spiBuffer[buff_len++] = pos >> 8;
|
||||||
|
spiBuffer[buff_len++] = MAX7456ADD_DMAL;
|
||||||
|
spiBuffer[buff_len++] = pos & 0xff;
|
||||||
|
spiBuffer[buff_len++] = MAX7456ADD_DMDI;
|
||||||
|
spiBuffer[buff_len++] = SCREEN_BUFFER[pos];
|
||||||
|
SHADOW_BUFFER[pos] = SCREEN_BUFFER[pos];
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (++pos >= maxScreenSize) {
|
||||||
|
pos = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buff_len) {
|
||||||
|
#ifdef MAX7456_DMA_CHANNEL_TX
|
||||||
|
if (buff_len > 0)
|
||||||
|
max7456_send_dma(spiBuffer, NULL, buff_len);
|
||||||
|
#else
|
||||||
|
ENABLE_MAX7456;
|
||||||
|
for (k=0; k < buff_len; k++)
|
||||||
|
spiTransferByte(MAX7456_SPI_INSTANCE, spiBuffer[k]);
|
||||||
|
DISABLE_MAX7456;
|
||||||
|
#endif // MAX7456_DMA_CHANNEL_TX
|
||||||
|
}
|
||||||
|
max7456Lock = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// this funcktion refresh all and should not be used when copter is armed
|
||||||
|
void max7456_refresh_all(void)
|
||||||
|
{
|
||||||
|
if (!max7456Lock) {
|
||||||
|
#ifdef MAX7456_DMA_CHANNEL_TX
|
||||||
|
while (dmaTxInProgress);
|
||||||
|
#endif
|
||||||
|
uint16_t xx;
|
||||||
|
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]);
|
||||||
SCREEN_BUFFER[xx] = MAX7456_CHAR(' ');
|
SHADOW_BUFFER[xx] = SCREEN_BUFFER[xx];
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void max7456_write_nvm(uint8_t char_address, uint8_t *font_data) {
|
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
|
||||||
max7456_send(VM0_REG, video_signal_type);
|
fontIsLoading = true;
|
||||||
|
max7456_send(VM0_REG, 0);
|
||||||
|
|
||||||
max7456_send(MAX7456ADD_CMAH, char_address); // set start address high
|
max7456_send(MAX7456ADD_CMAH, char_address); // set start address high
|
||||||
|
|
||||||
|
@ -288,21 +405,20 @@ 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
|
||||||
max7456_send(MAX7456ADD_CMM, WRITE_NVR);
|
max7456_send(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, 0) & STATUS_REG_NVR_BUSY) != 0x00);
|
while ((max7456_send(MAX7456ADD_STAT, 0x00) & STATUS_REG_NVR_BUSY) != 0x00);
|
||||||
|
|
||||||
max7456_send(VM0_REG, video_signal_type | 0x0C);
|
|
||||||
DISABLE_MAX7456;
|
DISABLE_MAX7456;
|
||||||
max7456_lock = 0;
|
|
||||||
|
max7456Lock = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // USE_MAX7456
|
||||||
#endif
|
|
||||||
|
|
59
src/main/drivers/max7456.h
Normal file → Executable file
59
src/main/drivers/max7456.h
Normal file → Executable 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
|
||||||
|
@ -35,19 +36,18 @@
|
||||||
#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,10 +73,9 @@
|
||||||
#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
|
||||||
|
@ -142,19 +141,19 @@
|
||||||
|
|
||||||
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_draw_screen(void);
|
||||||
|
void max7456_write_string(const char *string, int16_t address);
|
||||||
|
void max7456_write_nvm(uint8_t char_address, uint8_t *font_data);
|
||||||
|
uint8_t max7456_get_rows_count(void);
|
||||||
|
void max7456_write(uint8_t x, uint8_t y, char *buff);
|
||||||
|
void max7456_write_char(uint8_t x, uint8_t y, uint8_t c);
|
||||||
|
void max7456_clear_screen(void);
|
||||||
|
void max7456_refresh_all(void);
|
||||||
|
uint8_t* max7456_get_screen_buffer(void);
|
||||||
|
|
||||||
#ifdef MAX7456_DMA_CHANNEL_TX
|
#ifdef MAX7456_DMA_CHANNEL_TX
|
||||||
#define MAX7456_CHAR_TYPE uint16_t
|
uint8_t max7456_dma_in_progres(void);
|
||||||
#define MAX7456_CHAR(X) (MAX7456ADD_DMDI | ((X) << 8))
|
#endif // MAX7456_DMA_CHANNEL_TX
|
||||||
#else
|
|
||||||
#define MAX7456_CHAR_TYPE char
|
|
||||||
#define MAX7456_CHAR(X) (X)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void max7456_init(uint8_t system);
|
|
||||||
void max7456_draw_screen(void);
|
|
||||||
void max7456_write_string(const char *string, int16_t address);
|
|
||||||
void max7456_write_nvm(uint8_t char_address, uint8_t *font_data);
|
|
||||||
MAX7456_CHAR_TYPE* max7456_get_screen_buffer(void);
|
|
||||||
|
|
||||||
|
|
|
@ -36,29 +36,29 @@
|
||||||
|
|
||||||
// Direction arrows
|
// Direction arrows
|
||||||
#define SYM_ARROW_SOUTH 0x60
|
#define SYM_ARROW_SOUTH 0x60
|
||||||
#define SYM_ARROW_2 0x61
|
#define SYM_ARROW_2 0x61
|
||||||
#define SYM_ARROW_3 0x62
|
#define SYM_ARROW_3 0x62
|
||||||
#define SYM_ARROW_4 0x63
|
#define SYM_ARROW_4 0x63
|
||||||
#define SYM_ARROW_EAST 0x64
|
#define SYM_ARROW_EAST 0x64
|
||||||
#define SYM_ARROW_6 0x65
|
#define SYM_ARROW_6 0x65
|
||||||
#define SYM_ARROW_7 0x66
|
#define SYM_ARROW_7 0x66
|
||||||
#define SYM_ARROW_8 0x67
|
#define SYM_ARROW_8 0x67
|
||||||
#define SYM_ARROW_NORTH 0x68
|
#define SYM_ARROW_NORTH 0x68
|
||||||
#define SYM_ARROW_10 0x69
|
#define SYM_ARROW_10 0x69
|
||||||
#define SYM_ARROW_11 0x6A
|
#define SYM_ARROW_11 0x6A
|
||||||
#define SYM_ARROW_12 0x6B
|
#define SYM_ARROW_12 0x6B
|
||||||
#define SYM_ARROW_WEST 0x6C
|
#define SYM_ARROW_WEST 0x6C
|
||||||
#define SYM_ARROW_14 0x6D
|
#define SYM_ARROW_14 0x6D
|
||||||
#define SYM_ARROW_15 0x6E
|
#define SYM_ARROW_15 0x6E
|
||||||
#define SYM_ARROW_16 0x6F
|
#define SYM_ARROW_16 0x6F
|
||||||
|
|
||||||
// Heading Graphics
|
// Heading Graphics
|
||||||
#define SYM_HEADING_N 0x18
|
#define SYM_HEADING_N 0x18
|
||||||
#define SYM_HEADING_S 0x19
|
#define SYM_HEADING_S 0x19
|
||||||
#define SYM_HEADING_E 0x1A
|
#define SYM_HEADING_E 0x1A
|
||||||
#define SYM_HEADING_W 0x1B
|
#define SYM_HEADING_W 0x1B
|
||||||
#define SYM_HEADING_DIVIDED_LINE 0x1C
|
#define SYM_HEADING_DIVIDED_LINE 0x1C
|
||||||
#define SYM_HEADING_LINE 0x1D
|
#define SYM_HEADING_LINE 0x1D
|
||||||
|
|
||||||
// FRSKY HUB
|
// FRSKY HUB
|
||||||
#define SYM_CELL0 0xF0
|
#define SYM_CELL0 0xF0
|
||||||
|
@ -93,63 +93,60 @@
|
||||||
#define SYM_ALT 0xCC
|
#define SYM_ALT 0xCC
|
||||||
|
|
||||||
// GPS Mode and Autopilot
|
// GPS Mode and Autopilot
|
||||||
#define SYM_3DFIX 0xDF
|
#define SYM_3DFIX 0xDF
|
||||||
#define SYM_HOLD 0xEF
|
#define SYM_HOLD 0xEF
|
||||||
#define SYM_G_HOME 0xFF
|
#define SYM_G_HOME 0xFF
|
||||||
#define SYM_GHOME 0x9D
|
#define SYM_GHOME 0x9D
|
||||||
#define SYM_GHOME1 0x9E
|
#define SYM_GHOME1 0x9E
|
||||||
#define SYM_GHOLD 0xCD
|
#define SYM_GHOLD 0xCD
|
||||||
#define SYM_GHOLD1 0xCE
|
#define SYM_GHOLD1 0xCE
|
||||||
#define SYM_GMISSION 0xB5
|
#define SYM_GMISSION 0xB5
|
||||||
#define SYM_GMISSION1 0xB6
|
#define SYM_GMISSION1 0xB6
|
||||||
#define SYM_GLAND 0xB7
|
#define SYM_GLAND 0xB7
|
||||||
#define SYM_GLAND1 0xB8
|
#define SYM_GLAND1 0xB8
|
||||||
|
|
||||||
// Gimbal active Mode
|
// Gimbal active Mode
|
||||||
#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
|
||||||
#define SYM_BAR 0xA2
|
#define SYM_BAR 0xA2
|
||||||
#define SYM_GPS 0xA3
|
#define SYM_GPS 0xA3
|
||||||
#define SYM_MAN 0xC0
|
#define SYM_MAN 0xC0
|
||||||
#define SYM_MAN1 0xC1
|
#define SYM_MAN1 0xC1
|
||||||
#define SYM_MAN2 0xC2
|
#define SYM_MAN2 0xC2
|
||||||
#define SYM_CHECK 0xBE
|
#define SYM_CHECK 0xBE
|
||||||
#define SYM_BARO10 0xB7
|
#define SYM_BARO10 0xB7
|
||||||
#define SYM_BARO11 0xB8
|
#define SYM_BARO11 0xB8
|
||||||
#define SYM_MAG10 0xB5
|
#define SYM_MAG10 0xB5
|
||||||
#define SYM_MAG11 0xB6
|
#define SYM_MAG11 0xB6
|
||||||
|
|
||||||
// AH Center screen Graphics
|
// AH Center screen Graphics
|
||||||
#define SYM_AH_CENTER_LINE 0x26
|
#define SYM_AH_CENTER_LINE 0x26
|
||||||
#define SYM_AH_CENTER_LINE_RIGHT 0x27
|
#define SYM_AH_CENTER_LINE_RIGHT 0x27
|
||||||
#define SYM_AH_CENTER 0x7E
|
#define SYM_AH_CENTER 0x7E
|
||||||
#define SYM_AH_RIGHT 0x02
|
#define SYM_AH_RIGHT 0x02
|
||||||
#define SYM_AH_LEFT 0x03
|
#define SYM_AH_LEFT 0x03
|
||||||
#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
|
||||||
|
|
||||||
// Batt evolution
|
// Batt evolution
|
||||||
#define SYM_BATT_FULL 0x90
|
#define SYM_BATT_FULL 0x90
|
||||||
#define SYM_BATT_5 0x91
|
#define SYM_BATT_5 0x91
|
||||||
#define SYM_BATT_4 0x92
|
#define SYM_BATT_4 0x92
|
||||||
#define SYM_BATT_3 0x93
|
#define SYM_BATT_3 0x93
|
||||||
#define SYM_BATT_2 0x94
|
#define SYM_BATT_2 0x94
|
||||||
#define SYM_BATT_1 0x95
|
#define SYM_BATT_1 0x95
|
||||||
#define SYM_BATT_EMPTY 0x96
|
#define SYM_BATT_EMPTY 0x96
|
||||||
|
|
||||||
// Vario
|
// Vario
|
||||||
#define SYM_VARIO 0x7F
|
#define SYM_VARIO 0x7F
|
||||||
|
@ -159,41 +156,41 @@
|
||||||
|
|
||||||
// Batt Icon´s
|
// Batt Icon´s
|
||||||
#define SYM_MAIN_BATT 0x97
|
#define SYM_MAIN_BATT 0x97
|
||||||
#define SYM_VID_BAT 0xBF
|
#define SYM_VID_BAT 0xBF
|
||||||
|
|
||||||
// Unit Icon´s (Metric)
|
// Unit Icon´s (Metric)
|
||||||
#define SYM_MS 0x9F
|
#define SYM_MS 0x9F
|
||||||
#define SYM_KMH 0xA5
|
#define SYM_KMH 0xA5
|
||||||
#define SYM_ALTM 0xA7
|
#define SYM_ALTM 0xA7
|
||||||
#define SYM_DISTHOME_M 0xBB
|
#define SYM_DISTHOME_M 0xBB
|
||||||
#define SYM_M 0x0C
|
#define SYM_M 0x0C
|
||||||
|
|
||||||
// Unit Icon´s (Imperial)
|
// Unit Icon´s (Imperial)
|
||||||
#define SYM_FTS 0x99
|
#define SYM_FTS 0x99
|
||||||
#define SYM_MPH 0xA6
|
#define SYM_MPH 0xA6
|
||||||
#define SYM_ALTFT 0xA8
|
#define SYM_ALTFT 0xA8
|
||||||
#define SYM_DISTHOME_FT 0xB9
|
#define SYM_DISTHOME_FT 0xB9
|
||||||
#define SYM_FT 0x0F
|
#define SYM_FT 0x0F
|
||||||
|
|
||||||
// Voltage and amperage
|
// Voltage and amperage
|
||||||
#define SYM_VOLT 0x06
|
#define SYM_VOLT 0x06
|
||||||
#define SYM_AMP 0x9A
|
#define SYM_AMP 0x9A
|
||||||
#define SYM_MAH 0x07
|
#define SYM_MAH 0x07
|
||||||
#define SYM_WATT 0x57
|
#define SYM_WATT 0x57
|
||||||
|
|
||||||
// Flying Mode
|
// Flying Mode
|
||||||
#define SYM_ACRO 0xAE
|
#define SYM_ACRO 0xAE
|
||||||
#define SYM_ACROGY 0x98
|
#define SYM_ACROGY 0x98
|
||||||
#define SYM_ACRO1 0xAF
|
#define SYM_ACRO1 0xAF
|
||||||
#define SYM_STABLE 0xAC
|
#define SYM_STABLE 0xAC
|
||||||
#define SYM_STABLE1 0xAD
|
#define SYM_STABLE1 0xAD
|
||||||
#define SYM_HORIZON 0xC4
|
#define SYM_HORIZON 0xC4
|
||||||
#define SYM_HORIZON1 0xC5
|
#define SYM_HORIZON1 0xC5
|
||||||
#define SYM_PASS 0xAA
|
#define SYM_PASS 0xAA
|
||||||
#define SYM_PASS1 0xAB
|
#define SYM_PASS1 0xAB
|
||||||
#define SYM_AIR 0xEA
|
#define SYM_AIR 0xEA
|
||||||
#define SYM_AIR1 0xEB
|
#define SYM_AIR1 0xEB
|
||||||
#define SYM_PLUS 0x89
|
#define SYM_PLUS 0x89
|
||||||
|
|
||||||
// Note, these change with scrolling enabled (scrolling is TODO)
|
// Note, these change with scrolling enabled (scrolling is TODO)
|
||||||
//#define SYM_AH_DECORATION_LEFT 0x13
|
//#define SYM_AH_DECORATION_LEFT 0x13
|
||||||
|
@ -201,14 +198,14 @@
|
||||||
#define SYM_AH_DECORATION 0x13
|
#define SYM_AH_DECORATION 0x13
|
||||||
|
|
||||||
// Time
|
// Time
|
||||||
#define SYM_ON_M 0x9B
|
#define SYM_ON_M 0x9B
|
||||||
#define SYM_FLY_M 0x9C
|
#define SYM_FLY_M 0x9C
|
||||||
#define SYM_ON_H 0x70
|
#define SYM_ON_H 0x70
|
||||||
#define SYM_FLY_H 0x71
|
#define SYM_FLY_H 0x71
|
||||||
|
|
||||||
// Throttle Position (%)
|
// Throttle Position (%)
|
||||||
#define SYM_THR 0x04
|
#define SYM_THR 0x04
|
||||||
#define SYM_THR1 0x05
|
#define SYM_THR1 0x05
|
||||||
|
|
||||||
// RSSI
|
// RSSI
|
||||||
#define SYM_RSSI 0x01
|
#define SYM_RSSI 0x01
|
||||||
|
@ -223,4 +220,4 @@
|
||||||
#define SYM_MIN 0xB3
|
#define SYM_MIN 0xB3
|
||||||
#define SYM_AVG 0xB4
|
#define SYM_AVG 0xB4
|
||||||
|
|
||||||
#endif
|
#endif // USE_MAX7456
|
||||||
|
|
2233
src/main/io/osd.c
Normal file → Executable file
2233
src/main/io/osd.c
Normal file → Executable file
File diff suppressed because it is too large
Load diff
62
src/main/io/osd.h
Normal file → Executable file
62
src/main/io/osd.h
Normal file → Executable file
|
@ -15,44 +15,25 @@
|
||||||
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define MAX_MENU_ROWS 8
|
#pragma once
|
||||||
#define MAX_MENU_COLS 3
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
const char* title;
|
|
||||||
uint8_t x_pos;
|
|
||||||
} osd_col_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
const char* title;
|
|
||||||
void (*update)(int value_change_direction, uint8_t col);
|
|
||||||
void (*print)(uint16_t pos, uint8_t col);
|
|
||||||
} osd_row_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
const char* title;
|
|
||||||
uint8_t cols_number;
|
|
||||||
uint8_t rows_number;
|
|
||||||
osd_col_t cols[MAX_MENU_COLS];
|
|
||||||
osd_row_t rows[MAX_MENU_ROWS];
|
|
||||||
} osd_page_t;
|
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
OSD_MAIN_BATT_VOLTAGE,
|
|
||||||
OSD_RSSI_VALUE,
|
OSD_RSSI_VALUE,
|
||||||
OSD_TIMER,
|
OSD_MAIN_BATT_VOLTAGE,
|
||||||
OSD_THROTTLE_POS,
|
|
||||||
OSD_CPU_LOAD,
|
|
||||||
OSD_VTX_CHANNEL,
|
|
||||||
OSD_VOLTAGE_WARNING,
|
|
||||||
OSD_ARMED,
|
|
||||||
OSD_DISARMED,
|
|
||||||
OSD_ARTIFICIAL_HORIZON,
|
OSD_ARTIFICIAL_HORIZON,
|
||||||
OSD_HORIZON_SIDEBARS,
|
OSD_HORIZON_SIDEBARS,
|
||||||
|
OSD_ONTIME,
|
||||||
|
OSD_FLYTIME,
|
||||||
|
OSD_FLYMODE,
|
||||||
|
OSD_CRAFT_NAME,
|
||||||
|
OSD_THROTTLE_POS,
|
||||||
|
OSD_VTX_CHANNEL,
|
||||||
OSD_CURRENT_DRAW,
|
OSD_CURRENT_DRAW,
|
||||||
OSD_MAH_DRAWN,
|
OSD_MAH_DRAWN,
|
||||||
OSD_CRAFT_NAME,
|
OSD_GPS_SPEED,
|
||||||
|
OSD_GPS_SATS,
|
||||||
OSD_ALTITUDE,
|
OSD_ALTITUDE,
|
||||||
OSD_MAX_ITEMS, // MUST BE LAST
|
OSD_MAX_ITEMS, // MUST BE LAST
|
||||||
} osd_items_t;
|
} osd_items_t;
|
||||||
|
@ -63,12 +44,25 @@ typedef enum {
|
||||||
} osd_unit_t;
|
} osd_unit_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
// AUTO / PAL / NTSC in VIDEO_TYPES enum
|
uint16_t item_pos[OSD_MAX_ITEMS];
|
||||||
|
|
||||||
|
// Alarms
|
||||||
|
uint8_t rssi_alarm;
|
||||||
|
uint16_t cap_alarm;
|
||||||
|
uint16_t time_alarm;
|
||||||
|
uint16_t alt_alarm;
|
||||||
|
|
||||||
uint8_t video_system;
|
uint8_t video_system;
|
||||||
osd_unit_t units;
|
osd_unit_t units;
|
||||||
int16_t item_pos[OSD_MAX_ITEMS];
|
} osd_profile_t;
|
||||||
} osd_profile;
|
|
||||||
|
typedef struct {
|
||||||
|
int16_t max_speed;
|
||||||
|
int16_t min_voltage; // /10
|
||||||
|
int16_t max_current; // /10
|
||||||
|
int16_t min_rssi;
|
||||||
|
} statistic_t;
|
||||||
|
|
||||||
void updateOsd(uint32_t currentTime);
|
void updateOsd(uint32_t currentTime);
|
||||||
void osdInit(void);
|
void osdInit(void);
|
||||||
void resetOsdConfig(osd_profile *osdProfile);
|
void resetOsdConfig(osd_profile_t *osdProfile);
|
||||||
|
|
37
src/main/io/serial_cli.c
Normal file → Executable file
37
src/main/io/serial_cli.c
Normal file → Executable file
|
@ -918,24 +918,29 @@ const clivalue_t valueTable[] = {
|
||||||
{ "vtx_channel", VAR_UINT8 | MASTER_VALUE, &masterConfig.vtx_channel, .config.minmax = { 0, 39 } },
|
{ "vtx_channel", VAR_UINT8 | MASTER_VALUE, &masterConfig.vtx_channel, .config.minmax = { 0, 39 } },
|
||||||
{ "vtx_power", VAR_UINT8 | MASTER_VALUE, &masterConfig.vtx_power, .config.minmax = { 0, 1 } },
|
{ "vtx_power", VAR_UINT8 | MASTER_VALUE, &masterConfig.vtx_power, .config.minmax = { 0, 1 } },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef OSD
|
#ifdef OSD
|
||||||
{ "osd_video_system", VAR_UINT8 | MASTER_VALUE, &masterConfig.osdProfile.video_system, .config.minmax = { 0, 2 } },
|
{ "osd_video_system", VAR_UINT8 | MASTER_VALUE, &masterConfig.osdProfile.video_system, .config.minmax = { 0, 2 } },
|
||||||
{ "osd_units", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.osdProfile.units, .config.lookup = { TABLE_UNIT } },
|
{ "osd_units", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.osdProfile.units, .config.lookup = { TABLE_UNIT } },
|
||||||
{ "osd_main_voltage_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_MAIN_BATT_VOLTAGE], .config.minmax = { -480, 480 } },
|
{ "osd_rssi_alarm", VAR_UINT8 | MASTER_VALUE, &masterConfig.osdProfile.rssi_alarm, .config.minmax = { 0, 100 } },
|
||||||
{ "osd_rssi_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_RSSI_VALUE], .config.minmax = { -480, 480 } },
|
{ "osd_cap_alarm", VAR_UINT16 | MASTER_VALUE, &masterConfig.osdProfile.cap_alarm, .config.minmax = { 0, 20000 } },
|
||||||
{ "osd_timer_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_TIMER], .config.minmax = { -480, 480 } },
|
{ "osd_time_alarm", VAR_UINT16 | MASTER_VALUE, &masterConfig.osdProfile.time_alarm, .config.minmax = { 0, 60 } },
|
||||||
{ "osd_throttle_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_THROTTLE_POS], .config.minmax = { -480, 480 } },
|
{ "osd_alt_alarm", VAR_UINT16 | MASTER_VALUE, &masterConfig.osdProfile.alt_alarm, .config.minmax = { 0, 10000 } },
|
||||||
{ "osd_cpu_load_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_CPU_LOAD], .config.minmax = { -480, 480 } },
|
|
||||||
{ "osd_vtx_channel_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_VTX_CHANNEL], .config.minmax = { -480, 480 } },
|
{ "osd_main_voltage_pos", VAR_UINT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_MAIN_BATT_VOLTAGE], .config.minmax = { 0, 65536 } },
|
||||||
{ "osd_voltage_warning_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_VOLTAGE_WARNING], .config.minmax = { -480, 480 } },
|
{ "osd_rssi_pos", VAR_UINT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_RSSI_VALUE], .config.minmax = { 0, 65536 } },
|
||||||
{ "osd_armed_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_ARMED], .config.minmax = { -480, 480 } },
|
{ "osd_flytimer_pos", VAR_UINT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_FLYTIME], .config.minmax = { 0, 65536 } },
|
||||||
{ "osd_disarmed_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_DISARMED], .config.minmax = { -480, 480 } },
|
{ "osd_ontime_pos", VAR_UINT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_ONTIME], .config.minmax = { 0, 65536 } },
|
||||||
{ "osd_artificial_horizon", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_ARTIFICIAL_HORIZON], .config.minmax = { -1, 0 } },
|
{ "osd_flymode_pos", VAR_UINT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_FLYMODE], .config.minmax = { 0, 65536 } },
|
||||||
{ "osd_horizon_sidebars", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_HORIZON_SIDEBARS], .config.minmax = { -1, 0 } },
|
{ "osd_throttle_pos", VAR_UINT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_THROTTLE_POS], .config.minmax = { 0, 65536 } },
|
||||||
{ "osd_current_draw_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_CURRENT_DRAW], .config.minmax = { -480, 480 } },
|
{ "osd_vtx_channel_pos", VAR_UINT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_VTX_CHANNEL], .config.minmax = { 0, 65536 } },
|
||||||
{ "osd_mah_drawn_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_MAH_DRAWN], .config.minmax = { -480, 480 } },
|
{ "osd_artificial_horizon", VAR_UINT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_ARTIFICIAL_HORIZON], .config.minmax = { 0, 65536 } },
|
||||||
{ "osd_craft_name_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_CRAFT_NAME], .config.minmax = { -480, 480 } },
|
{ "osd_current_draw_pos", VAR_UINT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_CURRENT_DRAW], .config.minmax = { 0, 65536 } },
|
||||||
{ "osd_altitude_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_ALTITUDE], .config.minmax = { -480, 480 } },
|
{ "osd_mah_drawn_pos", VAR_UINT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_MAH_DRAWN], .config.minmax = { 0, 65536 } },
|
||||||
|
{ "osd_craft_name_pos", VAR_UINT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_CRAFT_NAME], .config.minmax = { 0, 65536 } },
|
||||||
|
{ "osd_gps_speed_pos", VAR_UINT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_GPS_SPEED], .config.minmax = { 0, 65536 } },
|
||||||
|
{ "osd_gps_sats_pos", VAR_UINT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_GPS_SATS], .config.minmax = { 0, 65536 } },
|
||||||
|
{ "osd_altitude", VAR_UINT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_ALTITUDE], .config.minmax = { 0, 65536 } },
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3463,7 +3468,7 @@ static void cliStatus(char *cmdline)
|
||||||
|
|
||||||
#ifdef USE_SDCARD
|
#ifdef USE_SDCARD
|
||||||
cliSdInfo(NULL);
|
cliSdInfo(NULL);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SKIP_TASK_STATISTICS
|
#ifndef SKIP_TASK_STATISTICS
|
||||||
|
|
19
src/main/io/serial_msp.c
Normal file → Executable file
19
src/main/io/serial_msp.c
Normal file → Executable file
|
@ -555,7 +555,7 @@ void mspSerialInit(serialConfig_t *serialConfig)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
activeBoxIds[activeBoxIdCount++] = BOXFPVANGLEMIX;
|
activeBoxIds[activeBoxIdCount++] = BOXFPVANGLEMIX;
|
||||||
|
|
||||||
if (feature(FEATURE_3D)) {
|
if (feature(FEATURE_3D)) {
|
||||||
activeBoxIds[activeBoxIdCount++] = BOX3DDISABLESWITCH;
|
activeBoxIds[activeBoxIdCount++] = BOX3DDISABLESWITCH;
|
||||||
}
|
}
|
||||||
|
@ -567,11 +567,11 @@ void mspSerialInit(serialConfig_t *serialConfig)
|
||||||
if (feature(FEATURE_INFLIGHT_ACC_CAL)) {
|
if (feature(FEATURE_INFLIGHT_ACC_CAL)) {
|
||||||
activeBoxIds[activeBoxIdCount++] = BOXCALIB;
|
activeBoxIds[activeBoxIdCount++] = BOXCALIB;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (feature(FEATURE_OSD)) {
|
if (feature(FEATURE_OSD)) {
|
||||||
activeBoxIds[activeBoxIdCount++] = BOXOSD;
|
activeBoxIds[activeBoxIdCount++] = BOXOSD;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TELEMETRY
|
#ifdef TELEMETRY
|
||||||
if (feature(FEATURE_TELEMETRY) && masterConfig.telemetryConfig.telemetry_switch) {
|
if (feature(FEATURE_TELEMETRY) && masterConfig.telemetryConfig.telemetry_switch) {
|
||||||
activeBoxIds[activeBoxIdCount++] = BOXTELEMETRY;
|
activeBoxIds[activeBoxIdCount++] = BOXTELEMETRY;
|
||||||
|
@ -1238,11 +1238,16 @@ static bool processOutCommand(uint8_t cmdMSP)
|
||||||
|
|
||||||
case MSP_OSD_CONFIG:
|
case MSP_OSD_CONFIG:
|
||||||
#ifdef OSD
|
#ifdef OSD
|
||||||
headSerialReply(3 + (OSD_MAX_ITEMS * 2));
|
headSerialReply(10 + (OSD_MAX_ITEMS * 2));
|
||||||
serialize8(1); // OSD supported
|
serialize8(1); // OSD supported
|
||||||
// send video system (AUTO/PAL/NTSC)
|
// send video system (AUTO/PAL/NTSC)
|
||||||
serialize8(masterConfig.osdProfile.video_system);
|
serialize8(masterConfig.osdProfile.video_system);
|
||||||
serialize8(masterConfig.osdProfile.units);
|
serialize8(masterConfig.osdProfile.units);
|
||||||
|
serialize8(masterConfig.osdProfile.rssi_alarm);
|
||||||
|
serialize16(masterConfig.osdProfile.cap_alarm);
|
||||||
|
serialize16(masterConfig.osdProfile.time_alarm);
|
||||||
|
serialize16(masterConfig.osdProfile.alt_alarm);
|
||||||
|
|
||||||
for (i = 0; i < OSD_MAX_ITEMS; i++) {
|
for (i = 0; i < OSD_MAX_ITEMS; i++) {
|
||||||
serialize16(masterConfig.osdProfile.item_pos[i]);
|
serialize16(masterConfig.osdProfile.item_pos[i]);
|
||||||
}
|
}
|
||||||
|
@ -1624,6 +1629,10 @@ static bool processInCommand(void)
|
||||||
if ((int8_t)addr == -1) {
|
if ((int8_t)addr == -1) {
|
||||||
masterConfig.osdProfile.video_system = read8();
|
masterConfig.osdProfile.video_system = read8();
|
||||||
masterConfig.osdProfile.units = read8();
|
masterConfig.osdProfile.units = read8();
|
||||||
|
masterConfig.osdProfile.rssi_alarm = read8();
|
||||||
|
masterConfig.osdProfile.cap_alarm = read16();
|
||||||
|
masterConfig.osdProfile.time_alarm = read16();
|
||||||
|
masterConfig.osdProfile.alt_alarm = read16();
|
||||||
}
|
}
|
||||||
// set a position setting
|
// set a position setting
|
||||||
else {
|
else {
|
||||||
|
@ -1926,7 +1935,7 @@ static bool processInCommand(void)
|
||||||
masterConfig.baro_hardware = read8();
|
masterConfig.baro_hardware = read8();
|
||||||
masterConfig.mag_hardware = read8();
|
masterConfig.mag_hardware = read8();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSP_SET_NAME:
|
case MSP_SET_NAME:
|
||||||
memset(masterConfig.name, 0, ARRAYLEN(masterConfig.name));
|
memset(masterConfig.name, 0, ARRAYLEN(masterConfig.name));
|
||||||
for (i = 0; i < MIN(MAX_NAME_LENGTH, currentPort->dataSize); i++) {
|
for (i = 0; i < MIN(MAX_NAME_LENGTH, currentPort->dataSize); i++) {
|
||||||
|
|
|
@ -158,7 +158,7 @@
|
||||||
#define USE_ADC
|
#define USE_ADC
|
||||||
#define BOARD_HAS_VOLTAGE_DIVIDER
|
#define BOARD_HAS_VOLTAGE_DIVIDER
|
||||||
#define VBAT_ADC_PIN PC1
|
#define VBAT_ADC_PIN PC1
|
||||||
#define RSSI_ADC_GPIO_PIN PC2
|
#define RSSI_ADC_PIN PC2
|
||||||
#define CURRENT_METER_ADC_PIN PC3
|
#define CURRENT_METER_ADC_PIN PC3
|
||||||
|
|
||||||
#define DEFAULT_FEATURES (FEATURE_VBAT | FEATURE_BLACKBOX)
|
#define DEFAULT_FEATURES (FEATURE_VBAT | FEATURE_BLACKBOX)
|
||||||
|
|
|
@ -97,6 +97,8 @@
|
||||||
#define USE_MAX7456
|
#define USE_MAX7456
|
||||||
#define MAX7456_SPI_INSTANCE SPI1
|
#define MAX7456_SPI_INSTANCE SPI1
|
||||||
#define MAX7456_SPI_CS_PIN PB1
|
#define MAX7456_SPI_CS_PIN PB1
|
||||||
|
#define MAX7456_SPI_CLK (SPI_CLOCK_STANDARD*2)
|
||||||
|
#define MAX7456_RESTORE_CLK (SPI_CLOCK_FAST)
|
||||||
//#define MAX7456_DMA_CHANNEL_TX DMA1_Channel3
|
//#define MAX7456_DMA_CHANNEL_TX DMA1_Channel3
|
||||||
//#define MAX7456_DMA_CHANNEL_RX DMA1_Channel2
|
//#define MAX7456_DMA_CHANNEL_RX DMA1_Channel2
|
||||||
//#define MAX7456_DMA_IRQ_HANDLER_ID DMA1_CH3_HANDLER
|
//#define MAX7456_DMA_IRQ_HANDLER_ID DMA1_CH3_HANDLER
|
||||||
|
|
|
@ -27,9 +27,10 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LED0 PB5
|
#define LED0 PB5
|
||||||
#define LED1 PB4
|
//#define LED1 PB4
|
||||||
|
|
||||||
#define BEEPER PB4
|
#define BEEPER PB4
|
||||||
|
#define BEEPER_INVERTED
|
||||||
|
|
||||||
#define INVERTER PC0 // PC0 used as inverter select GPIO
|
#define INVERTER PC0 // PC0 used as inverter select GPIO
|
||||||
#define INVERTER_USART USART1
|
#define INVERTER_USART USART1
|
||||||
|
@ -39,11 +40,11 @@
|
||||||
|
|
||||||
#define ACC
|
#define ACC
|
||||||
#define USE_ACC_SPI_MPU6000
|
#define USE_ACC_SPI_MPU6000
|
||||||
#define GYRO_MPU6000_ALIGN CW270_DEG
|
#define GYRO_MPU6000_ALIGN CW180_DEG
|
||||||
|
|
||||||
#define GYRO
|
#define GYRO
|
||||||
#define USE_GYRO_SPI_MPU6000
|
#define USE_GYRO_SPI_MPU6000
|
||||||
#define ACC_MPU6000_ALIGN CW270_DEG
|
#define ACC_MPU6000_ALIGN CW180_DEG
|
||||||
|
|
||||||
// MPU6000 interrupts
|
// MPU6000 interrupts
|
||||||
#define USE_EXTI
|
#define USE_EXTI
|
||||||
|
@ -113,7 +114,7 @@
|
||||||
#define USE_ADC
|
#define USE_ADC
|
||||||
#define CURRENT_METER_ADC_PIN PC1
|
#define CURRENT_METER_ADC_PIN PC1
|
||||||
#define VBAT_ADC_PIN PC2
|
#define VBAT_ADC_PIN PC2
|
||||||
#define RSSI_ADC_GPIO_PIN PA0
|
#define RSSI_ADC_PIN PA0
|
||||||
|
|
||||||
|
|
||||||
#define SENSORS_SET (SENSOR_ACC)
|
#define SENSORS_SET (SENSOR_ACC)
|
||||||
|
@ -130,4 +131,4 @@
|
||||||
#define TARGET_IO_PORTD 0xffff
|
#define TARGET_IO_PORTD 0xffff
|
||||||
|
|
||||||
#define USABLE_TIMER_CHANNEL_COUNT 12
|
#define USABLE_TIMER_CHANNEL_COUNT 12
|
||||||
#define USED_TIMERS ( TIM_N(2) | TIM_N(3) | TIM_N(5) | TIM_N(12) | TIM_N(8) | TIM_N(9))
|
#define USED_TIMERS ( TIM_N(1) | TIM_N(2) | TIM_N(3) | TIM_N(5) | TIM_N(12) | TIM_N(8) | TIM_N(9))
|
||||||
|
|
69
src/main/target/RACEBASE/hardware_revision.c
Executable file
69
src/main/target/RACEBASE/hardware_revision.c
Executable file
|
@ -0,0 +1,69 @@
|
||||||
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
|
|
||||||
|
#include "build_config.h"
|
||||||
|
|
||||||
|
#include "drivers/system.h"
|
||||||
|
#include "drivers/bus_spi.h"
|
||||||
|
#include "drivers/sensor.h"
|
||||||
|
#include "drivers/io.h"
|
||||||
|
#include "drivers/gpio.h"
|
||||||
|
#include "drivers/exti.h"
|
||||||
|
#include "drivers/accgyro.h"
|
||||||
|
#include "drivers/accgyro_mpu.h"
|
||||||
|
#include "drivers/accgyro_mpu6500.h"
|
||||||
|
|
||||||
|
#include "hardware_revision.h"
|
||||||
|
|
||||||
|
uint8_t hardwareRevision = 1;
|
||||||
|
|
||||||
|
void detectHardwareRevision(void)
|
||||||
|
{
|
||||||
|
gpio_config_t gpio;
|
||||||
|
|
||||||
|
// GYRO CS as output
|
||||||
|
gpio.pin = GPIO_Pin_5;
|
||||||
|
gpio.mode = Mode_Out_PP;
|
||||||
|
gpio.speed = Speed_2MHz;
|
||||||
|
gpioInit(GPIOB, &gpio);
|
||||||
|
GPIO_SetBits(GPIOB, GPIO_Pin_5);
|
||||||
|
|
||||||
|
gpio.pin = GPIO_Pin_7;
|
||||||
|
gpio.mode = Mode_Out_PP;
|
||||||
|
gpio.speed = Speed_2MHz;
|
||||||
|
gpioInit(GPIOA, &gpio);
|
||||||
|
GPIO_SetBits(GPIOA, GPIO_Pin_7);
|
||||||
|
|
||||||
|
gpio.pin = GPIO_Pin_12;
|
||||||
|
gpio.mode = Mode_Out_PP;
|
||||||
|
gpio.speed = Speed_2MHz;
|
||||||
|
gpioInit(GPIOB, &gpio);
|
||||||
|
GPIO_SetBits(GPIOB, GPIO_Pin_12);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void updateHardwareRevision(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
24
src/main/target/RACEBASE/hardware_revision.h
Executable file
24
src/main/target/RACEBASE/hardware_revision.h
Executable file
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
#include "drivers/exti.h"
|
||||||
|
|
||||||
|
extern uint8_t hardwareRevision;
|
||||||
|
|
||||||
|
void updateHardwareRevision(void);
|
||||||
|
void detectHardwareRevision(void);
|
|
@ -18,6 +18,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define TARGET_BOARD_IDENTIFIER "RBFC"
|
#define TARGET_BOARD_IDENTIFIER "RBFC"
|
||||||
|
#define USE_HARDWARE_REVISION_DETECTION
|
||||||
#define TARGET_CONFIG
|
#define TARGET_CONFIG
|
||||||
|
|
||||||
#define LED0 PB3
|
#define LED0 PB3
|
||||||
|
@ -76,6 +77,9 @@
|
||||||
#define USE_MAX7456
|
#define USE_MAX7456
|
||||||
#define MAX7456_SPI_INSTANCE SPI2
|
#define MAX7456_SPI_INSTANCE SPI2
|
||||||
#define MAX7456_SPI_CS_PIN PA7
|
#define MAX7456_SPI_CS_PIN PA7
|
||||||
|
#define MAX7456_SPI_CLK (SPI_CLOCK_STANDARD*2)
|
||||||
|
#define MAX7456_RESTORE_CLK (SPI_CLOCK_FAST)
|
||||||
|
|
||||||
|
|
||||||
#define M25P16_CS_PIN PB12
|
#define M25P16_CS_PIN PB12
|
||||||
#define M25P16_SPI_INSTANCE SPI2
|
#define M25P16_SPI_INSTANCE SPI2
|
||||||
|
|
|
@ -27,8 +27,12 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LED0 PB5
|
#define LED0 PB5
|
||||||
#define LED1 PB4
|
// Disable LED1, conflicts with AirbotF4/Flip32F4 beeper
|
||||||
|
//#define LED1 PB4
|
||||||
|
|
||||||
#define BEEPER PB4
|
#define BEEPER PB4
|
||||||
|
#define BEEPER_INVERTED
|
||||||
|
|
||||||
#define INVERTER PC0 // PC0 used as inverter select GPIO
|
#define INVERTER PC0 // PC0 used as inverter select GPIO
|
||||||
#define INVERTER_USART USART1
|
#define INVERTER_USART USART1
|
||||||
|
|
||||||
|
@ -102,12 +106,23 @@
|
||||||
#define USE_ADC
|
#define USE_ADC
|
||||||
#define CURRENT_METER_ADC_PIN PC1
|
#define CURRENT_METER_ADC_PIN PC1
|
||||||
#define VBAT_ADC_PIN PC2
|
#define VBAT_ADC_PIN PC2
|
||||||
#define RSSI_ADC_GPIO_PIN PA0
|
//#define RSSI_ADC_PIN PA0
|
||||||
|
|
||||||
|
#define LED_STRIP
|
||||||
|
// LED Strip can run off Pin 6 (PA0) of the MOTOR outputs.
|
||||||
|
#define WS2811_GPIO_AF GPIO_AF_TIM5
|
||||||
|
#define WS2811_PIN PA0
|
||||||
|
#define WS2811_TIMER TIM5
|
||||||
|
#define WS2811_TIMER_CHANNEL TIM_Channel_2
|
||||||
|
#define WS2811_DMA_HANDLER_IDENTIFER DMA1_ST2_HANDLER
|
||||||
|
#define WS2811_DMA_STREAM DMA1_Stream2
|
||||||
|
#define WS2811_DMA_CHANNEL DMA_Channel_6
|
||||||
|
#define WS2811_DMA_IRQ DMA1_Stream2_IRQn
|
||||||
|
#define WS2811_DMA_FLAG DMA_FLAG_TCIF2
|
||||||
|
#define WS2811_DMA_IT DMA_IT_TCIF2
|
||||||
|
|
||||||
#define SENSORS_SET (SENSOR_ACC)
|
#define SENSORS_SET (SENSOR_ACC)
|
||||||
|
|
||||||
|
|
||||||
#define DEFAULT_RX_FEATURE FEATURE_RX_SERIAL
|
#define DEFAULT_RX_FEATURE FEATURE_RX_SERIAL
|
||||||
#define DEFAULT_FEATURES (FEATURE_BLACKBOX)
|
#define DEFAULT_FEATURES (FEATURE_BLACKBOX)
|
||||||
|
|
||||||
|
|
|
@ -4,5 +4,6 @@ FEATURES += VCP ONBOARDFLASH
|
||||||
TARGET_SRC = \
|
TARGET_SRC = \
|
||||||
drivers/accgyro_spi_mpu6000.c \
|
drivers/accgyro_spi_mpu6000.c \
|
||||||
drivers/barometer_ms5611.c \
|
drivers/barometer_ms5611.c \
|
||||||
drivers/compass_hmc5883l.c
|
drivers/compass_hmc5883l.c \
|
||||||
|
drivers/light_ws2811strip.c \
|
||||||
|
drivers/light_ws2811strip_stm32f4xx.c
|
||||||
|
|
|
@ -152,7 +152,7 @@
|
||||||
#define USE_ADC
|
#define USE_ADC
|
||||||
#define BOARD_HAS_VOLTAGE_DIVIDER
|
#define BOARD_HAS_VOLTAGE_DIVIDER
|
||||||
#define VBAT_ADC_PIN PC0
|
#define VBAT_ADC_PIN PC0
|
||||||
#define RSSI_ADC_GPIO_PIN PB1
|
#define RSSI_ADC_PIN PB1
|
||||||
#define CURRENT_METER_ADC_PIN PA5
|
#define CURRENT_METER_ADC_PIN PA5
|
||||||
|
|
||||||
#define DEFAULT_FEATURES (FEATURE_VBAT | FEATURE_SOFTSERIAL | FEATURE_TELEMETRY)
|
#define DEFAULT_FEATURES (FEATURE_VBAT | FEATURE_SOFTSERIAL | FEATURE_TELEMETRY)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue