Bsongis/gui refactoring for x7 d (#3701)
* [X7D] New board added * Cosmetics
This commit is contained in:
@@ -9,12 +9,10 @@ set(LINKER_SCRIPT targets/horus/stm32f4_flash.ld)
|
||||
set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} horus_bitmaps)
|
||||
set(LUA_EXPORT lua_export_horus)
|
||||
set(FLAVOUR horus)
|
||||
set(VIRTUAL_INPUTS YES)
|
||||
set(RAMBACKUP YES)
|
||||
option(DISK_CACHE "Enable SD card disk cache" YES)
|
||||
add_definitions(-DPCBHORUS -DCOLORLCD -DSTM32F429_439xx -DSDRAM -DPPM_PIN_UART -DPPM_PIN_TIMER)
|
||||
add_definitions(-DEEPROM_VARIANT=0 -DAUDIO -DVOICE -DRTCLOCK)
|
||||
add_definitions(-DLUAINPUTS -DXCURVES -DVARIO)
|
||||
include_directories(${RADIO_SRC_DIRECTORY}/fonts/480x272 gui/${GUI_DIR} gui/${GUI_DIR}/layouts)
|
||||
file(GLOB THEMES_SRC RELATIVE ${RADIO_SRC_DIRECTORY}/gui/480x272 ${RADIO_SRC_DIRECTORY}/gui/480x272/themes/*.cpp)
|
||||
file(GLOB LAYOUTS_SRC RELATIVE ${RADIO_SRC_DIRECTORY}/gui/480x272 ${RADIO_SRC_DIRECTORY}/gui/480x272/layouts/*.cpp)
|
||||
@@ -27,6 +25,7 @@ set(GUI_SRC
|
||||
radio_hardware.cpp
|
||||
model_inputs.cpp
|
||||
model_mixes.cpp
|
||||
model_curves.cpp
|
||||
view_channels.cpp
|
||||
view_logical_switches.cpp
|
||||
view_about.cpp
|
||||
@@ -40,13 +39,18 @@ set(GUI_SRC
|
||||
${LAYOUTS_SRC}
|
||||
${WIDGETS_SRC}
|
||||
)
|
||||
if(HELI)
|
||||
set(GUI_SRC ${GUI_SRC} model_heli.cpp)
|
||||
endif()
|
||||
if(DISK_CACHE)
|
||||
set(SRC ${SRC} disk_cache.cpp)
|
||||
add_definitions(-DDISK_CACHE)
|
||||
endif()
|
||||
set(SERIAL2_DRIVER serial2_driver.cpp)
|
||||
set(TARGET_SRC
|
||||
${TARGET_SRC}
|
||||
board.cpp
|
||||
led_driver.cpp
|
||||
extmodule_driver.cpp
|
||||
../common/arm/stm32/rtc_driver.cpp
|
||||
)
|
||||
@@ -54,10 +58,8 @@ set(FIRMWARE_TARGET_SRC
|
||||
${FIRMWARE_TARGET_SRC}
|
||||
sdio_sd.c
|
||||
lcd_driver.cpp
|
||||
delays.c
|
||||
pwr_driver.cpp
|
||||
sdram_driver.c
|
||||
led_driver.cpp
|
||||
startup_stm32f40_41xxx.s
|
||||
)
|
||||
set(STM32LIB_SRC
|
||||
@@ -69,6 +71,6 @@ set(STM32LIB_SRC
|
||||
)
|
||||
add_custom_target(datacopy
|
||||
WORKING_DIRECTORY ${RADIO_DIRECTORY}/src
|
||||
COMMAND python ${RADIO_DIRECTORY}/util/generate_datacopy.py datastructs.h -DPCBHORUS -DCPUARM -DCOLORLCD -DVIRTUALINPUTS -DBACKUP > storage/datacopy.cpp
|
||||
COMMAND python ${RADIO_DIRECTORY}/util/generate_datacopy.py datastructs.h -DPCBHORUS -DCPUARM -DCOLORLCD -DCPUARM -DBACKUP > storage/datacopy.cpp
|
||||
DEPENDS ${RADIO_DIRECTORY}/src/datastructs.h ${RADIO_DIRECTORY}/util/generate_datacopy.py
|
||||
)
|
||||
|
||||
@@ -172,7 +172,7 @@ void boardInit()
|
||||
|
||||
void boardOff()
|
||||
{
|
||||
BACKLIGHT_OFF();
|
||||
BACKLIGHT_DISABLE();
|
||||
|
||||
while (pwrPressed()) {
|
||||
wdt_reset();
|
||||
|
||||
@@ -77,7 +77,7 @@ extern "C" {
|
||||
extern uint16_t sessionTimer;
|
||||
|
||||
#define SLAVE_MODE() (g_model.trainerMode == TRAINER_MODE_SLAVE)
|
||||
#define TRAINER_CONNECTED() (GPIO_ReadInputDataBit(TRAINER_GPIO_DETECT, TRAINER_GPIO_PIN_DETECT) == Bit_RESET)
|
||||
#define TRAINER_CONNECTED() (GPIO_ReadInputDataBit(TRAINER_DETECT_GPIO, TRAINER_DETECT_GPIO_PIN) == Bit_RESET)
|
||||
|
||||
// Board driver
|
||||
void boardInit(void);
|
||||
@@ -118,6 +118,7 @@ uint32_t sdMounted(void);
|
||||
#define SD_IS_HC() (0)
|
||||
#define SD_GET_SPEED() (0)
|
||||
#define sdInit()
|
||||
#define sdMount()
|
||||
#define sdDone()
|
||||
#define SD_CARD_PRESENT() true
|
||||
#endif
|
||||
@@ -168,7 +169,82 @@ void init_trainer_capture(void);
|
||||
void stop_trainer_capture(void);
|
||||
|
||||
// Keys driver
|
||||
#define NUM_SWITCHES 8
|
||||
enum EnumKeys
|
||||
{
|
||||
KEY_PGUP,
|
||||
KEY_PGDN,
|
||||
KEY_ENTER,
|
||||
KEY_MODEL,
|
||||
KEY_UP = KEY_MODEL,
|
||||
KEY_EXIT,
|
||||
KEY_DOWN = KEY_EXIT,
|
||||
KEY_TELEM,
|
||||
KEY_RIGHT = KEY_TELEM,
|
||||
KEY_RADIO,
|
||||
KEY_LEFT = KEY_RADIO,
|
||||
|
||||
TRM_BASE,
|
||||
TRM_LH_DWN = TRM_BASE,
|
||||
TRM_LH_UP,
|
||||
TRM_LV_DWN,
|
||||
TRM_LV_UP,
|
||||
TRM_RV_DWN,
|
||||
TRM_RV_UP,
|
||||
TRM_RH_DWN,
|
||||
TRM_RH_UP,
|
||||
TRM_LS_DWN,
|
||||
TRM_LS_UP,
|
||||
TRM_RS_DWN,
|
||||
TRM_RS_UP,
|
||||
TRM_LAST = TRM_RS_UP,
|
||||
|
||||
NUM_KEYS
|
||||
};
|
||||
|
||||
enum EnumSwitches
|
||||
{
|
||||
SW_SA,
|
||||
SW_SB,
|
||||
SW_SC,
|
||||
SW_SD,
|
||||
SW_SE,
|
||||
SW_SF,
|
||||
SW_SG,
|
||||
SW_SH
|
||||
};
|
||||
#define IS_3POS(x) ((x) != SW_SF && (x) != SW_SH)
|
||||
|
||||
enum EnumSwitchesPositions
|
||||
{
|
||||
SW_SA0,
|
||||
SW_SA1,
|
||||
SW_SA2,
|
||||
SW_SB0,
|
||||
SW_SB1,
|
||||
SW_SB2,
|
||||
SW_SC0,
|
||||
SW_SC1,
|
||||
SW_SC2,
|
||||
SW_SD0,
|
||||
SW_SD1,
|
||||
SW_SD2,
|
||||
SW_SE0,
|
||||
SW_SE1,
|
||||
SW_SE2,
|
||||
SW_SF0,
|
||||
SW_SF1,
|
||||
SW_SF2,
|
||||
SW_SG0,
|
||||
SW_SG1,
|
||||
SW_SG2,
|
||||
SW_SH0,
|
||||
SW_SH1,
|
||||
SW_SH2,
|
||||
};
|
||||
void keysInit(void);
|
||||
uint8_t keyState(uint8_t index);
|
||||
uint32_t switchState(uint8_t index);
|
||||
uint32_t readKeys(void);
|
||||
uint32_t readTrims(void);
|
||||
#define TRIMS_PRESSED() (readTrims())
|
||||
@@ -200,15 +276,19 @@ void watchdogInit(unsigned int duration);
|
||||
#define WAS_RESET_BY_WATCHDOG_OR_SOFTWARE() (RCC->CSR & (RCC_CSR_WDGRSTF | RCC_CSR_WWDGRSTF | RCC_CSR_SFTRSTF))
|
||||
|
||||
// ADC driver
|
||||
#define NUM_POTS 3
|
||||
#define NUM_SLIDERS 4
|
||||
#define NUM_XPOTS 3
|
||||
enum Analogs {
|
||||
STICK1,
|
||||
STICK2,
|
||||
STICK3,
|
||||
STICK4,
|
||||
POT1,
|
||||
POT_FIRST,
|
||||
POT1 = POT_FIRST,
|
||||
POT2,
|
||||
POT3,
|
||||
POT_LAST=POT3,
|
||||
POT_LAST = POT3,
|
||||
SLIDER1,
|
||||
SLIDER2,
|
||||
SLIDER3,
|
||||
@@ -218,6 +298,8 @@ enum Analogs {
|
||||
MOUSE2,
|
||||
NUMBER_ANALOG
|
||||
};
|
||||
#define IS_POT(x) ((x)>=POT_FIRST && (x)<=POT_LAST)
|
||||
#define IS_SLIDER(x) ((x)>=SLIDER1 && (x)<=SLIDER4)
|
||||
extern uint16_t adcValues[NUMBER_ANALOG];
|
||||
void adcInit(void);
|
||||
void adcRead(void);
|
||||
@@ -245,6 +327,9 @@ void ledRed(void);
|
||||
void ledBlue(void);
|
||||
|
||||
// LCD driver
|
||||
#define LCD_W 480
|
||||
#define LCD_H 272
|
||||
#define LCD_DEPTH 16
|
||||
void lcdInit(void);
|
||||
void lcdRefresh(void);
|
||||
void DMAFillRect(uint16_t * dest, uint16_t destw, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color);
|
||||
@@ -253,12 +338,19 @@ void DMACopyAlphaBitmap(uint16_t * dest, uint16_t destw, uint16_t x, uint16_t y,
|
||||
void DMABitmapConvert(uint16_t * dest, const uint8_t * src, uint16_t w, uint16_t h, uint32_t format);
|
||||
void lcdStoreBackupBuffer(void);
|
||||
int lcdRestoreBackupBuffer(void);
|
||||
void LCD_ControlLight(uint16_t dutyCycle);
|
||||
void lcdSetContrast();
|
||||
#define lcdOff(...)
|
||||
#define lcdSetRefVolt(...)
|
||||
#define lcdRefreshWait(...)
|
||||
|
||||
// Backlight driver
|
||||
#define setBacklight(xx) LCD_ControlLight(xx)
|
||||
#define backlightEnable() setBacklight(UNEXPECTED_SHUTDOWN() ? 100 : 100-g_eeGeneral.backlightBright)
|
||||
#define backlightDisable() setBacklight(g_eeGeneral.blOffBright)
|
||||
#if defined(SIMU)
|
||||
#define backlightEnable(...)
|
||||
#else
|
||||
void backlightEnable(uint8_t dutyCycle);
|
||||
#endif
|
||||
#define BACKLIGHT_ENABLE() backlightEnable(UNEXPECTED_SHUTDOWN() ? 100 : 100-g_eeGeneral.backlightBright)
|
||||
#define BACKLIGHT_DISABLE() backlightEnable(UNEXPECTED_SHUTDOWN() ? 100 : g_eeGeneral.blOffBright)
|
||||
#define isBacklightEnable() true
|
||||
|
||||
// USB driver
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program 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.
|
||||
*/
|
||||
|
||||
#include <OsConfig.h>
|
||||
#include "board.h"
|
||||
|
||||
#define SYSTEM_TICKS_1US ((CFG_CPU_FREQ + 500000) / 1000000) // number of system ticks in 1us
|
||||
#define SYSTEM_TICKS_01US ((CFG_CPU_FREQ + 5000000) / 10000000) // number of system ticks in 0.1us (rounding needed for sys frequencies that are not multiple of 10MHz)
|
||||
|
||||
void delaysInit(void)
|
||||
{
|
||||
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
|
||||
DWT->CYCCNT = 0;
|
||||
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
|
||||
}
|
||||
|
||||
void delay_01us(uint16_t nb)
|
||||
{
|
||||
volatile uint32_t dwtStart = DWT->CYCCNT;
|
||||
volatile uint32_t dwtTotal = (SYSTEM_TICKS_01US * nb) - 10;
|
||||
while((DWT->CYCCNT - dwtStart) < dwtTotal);
|
||||
}
|
||||
|
||||
void delay_us(uint16_t nb)
|
||||
{
|
||||
volatile uint32_t dwtStart = DWT->CYCCNT;
|
||||
volatile uint32_t dwtTotal = (SYSTEM_TICKS_1US * nb) - 10;
|
||||
while((DWT->CYCCNT - dwtStart) < dwtTotal);
|
||||
}
|
||||
|
||||
void delay_ms(uint32_t ms)
|
||||
{
|
||||
while(ms--) {
|
||||
delay_us(1000);
|
||||
}
|
||||
}
|
||||
@@ -312,12 +312,12 @@
|
||||
#define TRAINER_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_DMA1)
|
||||
#define TRAINER_RCC_APB1Periph RCC_APB1Periph_TIM3
|
||||
#define TRAINER_GPIO GPIOC
|
||||
#define TRAINER_GPIO_PIN_IN GPIO_Pin_6 // PC.06
|
||||
#define TRAINER_GPIO_PinSource_IN GPIO_PinSource6
|
||||
#define TRAINER_GPIO_PIN_OUT GPIO_Pin_7 // PC.07
|
||||
#define TRAINER_GPIO_PinSource_OUT GPIO_PinSource7
|
||||
#define TRAINER_GPIO_DETECT GPIOB
|
||||
#define TRAINER_GPIO_PIN_DETECT GPIO_Pin_4 // PB.04
|
||||
#define TRAINER_IN_GPIO_PIN GPIO_Pin_6 // PC.06
|
||||
#define TRAINER_IN_GPIO_PinSource GPIO_PinSource6
|
||||
#define TRAINER_OUT_GPIO_PIN GPIO_Pin_7 // PC.07
|
||||
#define TRAINER_OUT_GPIO_PinSource GPIO_PinSource7
|
||||
#define TRAINER_DETECT_GPIO GPIOB
|
||||
#define TRAINER_DETECT_GPIO_PIN GPIO_Pin_4 // PB.04
|
||||
#define TRAINER_TIMER TIM3
|
||||
#define TRAINER_TIMER_IRQn TIM3_IRQn
|
||||
#define TRAINER_TIMER_IRQHandler TIM3_IRQHandler
|
||||
|
||||
@@ -115,10 +115,10 @@ void readKeysAndTrims()
|
||||
{
|
||||
register uint32_t i;
|
||||
|
||||
uint8_t enuk = 0;
|
||||
uint8_t index = 0;
|
||||
uint32_t in = readKeys();
|
||||
for (i = 0; i < TRM_BASE; i++) {
|
||||
keys[enuk++].input(in & (1 << i));
|
||||
keys[index++].input(in & (1 << i));
|
||||
}
|
||||
|
||||
static rotenc_t rePreviousValue;
|
||||
@@ -145,7 +145,7 @@ void readKeysAndTrims()
|
||||
|
||||
in = readTrims();
|
||||
for (i = 1; i < 4096; i <<= 1) {
|
||||
keys[enuk++].input(in & i);
|
||||
keys[index++].input(in & i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,13 +181,16 @@ void readKeysAndTrims()
|
||||
break
|
||||
|
||||
#if !defined(BOOT)
|
||||
bool switchState(EnumKeys enuk)
|
||||
uint8_t keyState(uint8_t index)
|
||||
{
|
||||
return keys[index].state();
|
||||
}
|
||||
|
||||
uint32_t switchState(uint8_t index)
|
||||
{
|
||||
register uint32_t xxx = 0;
|
||||
|
||||
if (enuk < (int) DIM(keys)) return keys[enuk].state() ? 1 : 0;
|
||||
|
||||
switch ((uint8_t) enuk) {
|
||||
|
||||
switch (index) {
|
||||
ADD_3POS_CASE(A, 0);
|
||||
ADD_3POS_CASE(B, 1);
|
||||
ADD_3POS_CASE(C, 2);
|
||||
@@ -200,7 +203,7 @@ bool switchState(EnumKeys enuk)
|
||||
break;
|
||||
}
|
||||
|
||||
// TRACE("switch %d => %d", enuk, xxx);
|
||||
// TRACE("switch %d => %d", index, xxx);
|
||||
return xxx;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -318,9 +318,9 @@ void LCD_LayerInit()
|
||||
LTDC_DitherCmd(ENABLE);
|
||||
}
|
||||
|
||||
void LCD_ControlLight(uint16_t dutyCycle)
|
||||
void backlightEnable(uint8_t dutyCycle)
|
||||
{
|
||||
static uint16_t existingDutyCycle;
|
||||
static uint8_t existingDutyCycle;
|
||||
|
||||
if (dutyCycle == existingDutyCycle || dutyCycle < 5) {
|
||||
return;
|
||||
@@ -374,11 +374,12 @@ void LCD_Init(void)
|
||||
|
||||
LCD_Init_LTDC();
|
||||
|
||||
//config backlight
|
||||
// TODO split backlight from LCD
|
||||
// Config backlight
|
||||
LCD_Backlight_Config();
|
||||
|
||||
//Max Value
|
||||
LCD_ControlLight(100);
|
||||
// Max Value
|
||||
backlightEnable(100);
|
||||
}
|
||||
|
||||
BitmapBuffer lcdBuffer1(BMP_RGB565, LCD_W, LCD_H, (uint16_t *)LCD_FIRST_FRAME_BUFFER);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "board.h"
|
||||
#include "opentx.h"
|
||||
|
||||
void ledOn()
|
||||
{
|
||||
|
||||
@@ -24,10 +24,10 @@ void trainerSendNextFrame();
|
||||
|
||||
void init_trainer_ppm()
|
||||
{
|
||||
GPIO_PinAFConfig(TRAINER_GPIO, TRAINER_GPIO_PinSource_OUT, TRAINER_GPIO_AF);
|
||||
GPIO_PinAFConfig(TRAINER_GPIO, TRAINER_OUT_GPIO_PinSource, TRAINER_GPIO_AF);
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin = TRAINER_GPIO_PIN_OUT;
|
||||
GPIO_InitStructure.GPIO_Pin = TRAINER_OUT_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
@@ -69,13 +69,13 @@ void init_trainer_capture()
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = TRAINER_GPIO_PIN_IN;
|
||||
GPIO_InitStructure.GPIO_Pin = TRAINER_IN_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(TRAINER_GPIO, &GPIO_InitStructure);
|
||||
GPIO_PinAFConfig(TRAINER_GPIO, TRAINER_GPIO_PinSource_IN, TRAINER_GPIO_AF);
|
||||
GPIO_PinAFConfig(TRAINER_GPIO, TRAINER_IN_GPIO_PinSource, TRAINER_GPIO_AF);
|
||||
|
||||
TRAINER_TIMER->ARR = 0xFFFF;
|
||||
TRAINER_TIMER->PSC = TRAINER_TIMER_FREQ / 2000000 - 1; // 0.5uS
|
||||
|
||||
Reference in New Issue
Block a user