Skip to content

Commit

Permalink
Add iFlight Commando8
Browse files Browse the repository at this point in the history
Add iFlight Commando8 ELRS radio
  • Loading branch information
XING-IF authored and raphaelcoeffic committed Jun 19, 2022
1 parent 8874711 commit 29d1feb
Show file tree
Hide file tree
Showing 38 changed files with 472 additions and 43 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
- x9lites
- xlite
- xlites
- commando8
container:
image: ghcr.io/edgetx/edgetx-dev:latest
volumes:
Expand Down Expand Up @@ -94,6 +95,7 @@ jobs:
- x9e;x9e-hall
- x9lite;x9lites
- xlite;xlites
- commando8
container:
image: ghcr.io/edgetx/edgetx-dev:latest
volumes:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
- x9d;x9dp;x9dp2019
- x9lite;x9lites
- xlite;xlites
- commando8
container:
image: ghcr.io/edgetx/edgetx-dev:latest
volumes:
Expand Down
5 changes: 5 additions & 0 deletions radio/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,11 @@ if(FRSKY_RELEASE)
set(POPUP_LEVEL 3)
endif()

if(IFLIGHT_RELEASE)
add_definitions(-DIFLIGHT_RELEASE)
endif()


if(HARDWARE_TRAINER_MULTI)
add_definitions(-DHARDWARE_TRAINER_MULTI)
endif()
Expand Down
2 changes: 1 addition & 1 deletion radio/src/gui/128x64/view_channels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ constexpr coord_t CHANNEL_GAUGE_OFFSET = CHANNEL_VALUE_OFFSET;
constexpr coord_t CHANNEL_BAR_WIDTH = 70;
constexpr coord_t CHANNEL_PROPERTIES_OFFSET = CHANNEL_GAUGE_OFFSET + CHANNEL_BAR_WIDTH + 2;

#if defined(RADIO_T8)
#if defined(RADIO_T8) || defined(RADIO_COMMANDO8)
#define EVT_KEY_PREVIOUS_VIEW EVT_KEY_BREAK(KEY_PAGEUP)
#define EVT_KEY_NEXT_VIEW EVT_KEY_BREAK(KEY_PAGEDN)
#define EVT_KEY_NEXT_PAGE EVT_KEY_BREAK(KEY_PLUS)
Expand Down
2 changes: 1 addition & 1 deletion radio/src/gui/128x64/view_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ void displayBattVoltage()

#define displayVoltageOrAlarm() displayBattVoltage()

#if defined(RADIO_T8)
#if defined(RADIO_T8) || defined(RADIO_COMMANDO8)
#define EVT_KEY_CONTEXT_MENU EVT_KEY_LONG(KEY_ENTER)
#define EVT_KEY_PREVIOUS_VIEW EVT_KEY_BREAK(KEY_PAGEUP)
#define EVT_KEY_NEXT_VIEW EVT_KEY_FIRST(KEY_PAGEDN)
Expand Down
2 changes: 1 addition & 1 deletion radio/src/gui/common/stdlcd/radio_hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ enum {
#define SWITCH_TYPE_MAX(sw) ((MIXSRC_SF - MIXSRC_FIRST_SWITCH == sw || MIXSRC_SH - MIXSRC_FIRST_SWITCH == sw) ? SWITCH_2POS : SWITCH_3POS)
#elif defined(RADIO_ZORRO)
#define SWITCH_TYPE_MAX(sw) ((MIXSRC_SB - MIXSRC_FIRST_SWITCH == sw || MIXSRC_SC - MIXSRC_FIRST_SWITCH == sw) ? SWITCH_3POS : SWITCH_2POS)
#elif defined(RADIO_T8)
#elif defined(RADIO_T8) || defined(RADIO_COMMANDO8)
#define SWITCH_TYPE_MAX(sw) ((MIXSRC_SA - MIXSRC_FIRST_SWITCH == sw || MIXSRC_SD - MIXSRC_FIRST_SWITCH == sw) ? SWITCH_2POS : SWITCH_3POS)
#elif defined(RADIO_TX12)
#define SWITCH_TYPE_MAX(sw) (((MIXSRC_SA - MIXSRC_FIRST_SWITCH == sw || MIXSRC_SD - MIXSRC_FIRST_SWITCH == sw) || \
Expand Down
11 changes: 11 additions & 0 deletions radio/src/gui/gui_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,11 @@ bool isInternalModuleSupported(int moduleType)

bool isInternalModuleAvailable(int moduleType)
{
#if defined(MUTUALLY_EXCLUSIVE_MODULES)
if (!isModuleNone(EXTERNAL_MODULE))
return false;
#endif

if (moduleType == MODULE_TYPE_NONE)
return true;

Expand Down Expand Up @@ -681,6 +686,12 @@ bool isInternalModuleAvailable(int moduleType)

bool isExternalModuleAvailable(int moduleType)
{

#if defined(MUTUALLY_EXCLUSIVE_MODULES)
if (!isModuleNone(INTERNAL_MODULE))
return false;
#endif

#if !defined(HARDWARE_EXTERNAL_MODULE_SIZE_SML)
if (isModuleTypeR9MLite(moduleType) || moduleType == MODULE_TYPE_XJT_LITE_PXX2)
return false;
Expand Down
2 changes: 2 additions & 0 deletions radio/src/gui/screenshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ const char * writeScreenshot()
return error;
}

#if defined(RTCLOCK)
char * tmp = strAppend(&filename[sizeof(SCREENSHOTS_PATH)-1], "/screen");
tmp = strAppendDate(tmp, true);
strcpy(tmp, BMP_EXT);
#endif

FRESULT result = f_open(&bmpFile, filename, FA_CREATE_ALWAYS | FA_WRITE);
if (result != FR_OK) {
Expand Down
2 changes: 1 addition & 1 deletion radio/src/keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ inline bool IS_KEY_EVT(event_t evt, uint8_t key)
#define EVT_ROTARY_LONG EVT_KEY_LONG(KEY_ENTER)
#define IS_NEXT_EVENT(event) (event==EVT_KEY_FIRST(KEY_DOWN) || event==EVT_KEY_REPT(KEY_DOWN))
#define IS_PREVIOUS_EVENT(event) (event==EVT_KEY_FIRST(KEY_UP) || event==EVT_KEY_REPT(KEY_UP))
#elif defined(RADIO_T8)
#elif defined(RADIO_T8) || defined(RADIO_COMMANDO8)
#define EVT_ROTARY_BREAK EVT_KEY_BREAK(KEY_ENTER)
#define EVT_ROTARY_LONG EVT_KEY_LONG(KEY_ENTER)
#define IS_NEXT_EVENT(event) (event==EVT_KEY_FIRST(KEY_DOWN) || event==EVT_KEY_REPT(KEY_DOWN))
Expand Down
1 change: 1 addition & 0 deletions radio/src/lua/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ if(PYTHONINTERP_FOUND)
add_lua_export_target(tx12 ${LUA_INCLUDES} -DPCBTARANIS -DPCBX7 -DRADIO_TX12)
add_lua_export_target(zorro ${LUA_INCLUDES} -DPCBTARANIS -DPCBX7 -DRADIO_ZORRO)
add_lua_export_target(t8 ${LUA_INCLUDES} -DPCBTARANIS -DPCBX7 -DRADIO_T8)
add_lua_export_target(commando8 ${LUA_INCLUDES} -DPCBTARANIS -DPCBX7 -DRADIO_COMMANDO8)
add_lua_export_target(t16 ${LUA_INCLUDES} -DPCBHORUS -DPCBX10 -DRADIO_T16)
add_lua_export_target(nv14 ${LUA_INCLUDES} -I${RADIO_SRC_DIR}/targets/nv14 -DPCBNV14)
endif()
6 changes: 4 additions & 2 deletions radio/src/lua/api_general.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
#include "lua/lua_exports_zorro.inc"
#elif defined(RADIO_T8)
#include "lua/lua_exports_t8.inc"
#elif defined(RADIO_COMMANDO8)
#include "lua/lua_exports_commando8.inc"
#elif defined(PCBX9LITES)
#include "lua/lua_exports_x9lites.inc"
#elif defined(PCBX9LITE)
Expand Down Expand Up @@ -2669,7 +2671,7 @@ const luaR_value_entry opentxConstants[] = {
{ "ROTENC_LOWSPEED", ROTENC_LOWSPEED },
{ "ROTENC_MIDSPEED", ROTENC_MIDSPEED },
{ "ROTENC_HIGHSPEED", ROTENC_HIGHSPEED },
#elif defined(PCBX9D) || defined(PCBX9DP) || defined(RADIO_T8) // key reverted between field nav and value change
#elif defined(PCBX9D) || defined(PCBX9DP) || defined(RADIO_T8) || defined(RADIO_COMMANDO8)// key reverted between field nav and value change
{ "EVT_VIRTUAL_PREV", EVT_KEY_FIRST(KEY_PLUS) },
{ "EVT_VIRTUAL_PREV_REPT", EVT_KEY_REPT(KEY_PLUS) },
{ "EVT_VIRTUAL_NEXT", EVT_KEY_FIRST(KEY_MINUS) },
Expand Down Expand Up @@ -2706,7 +2708,7 @@ const luaR_value_entry opentxConstants[] = {
{ "EVT_VIRTUAL_ENTER_LONG", EVT_KEY_LONG(KEY_ENTER) },
{ "EVT_VIRTUAL_EXIT", EVT_KEY_BREAK(KEY_EXIT) },
#elif defined(NAVIGATION_X7) || defined(NAVIGATION_X9D)
#if defined(RADIO_TX12) || defined(RADIO_ZORRO) || defined(RADIO_T8)
#if defined(RADIO_TX12) || defined(RADIO_ZORRO) || defined(RADIO_T8) || defined(RADIO_COMMANDO8)
{ "EVT_VIRTUAL_PREV_PAGE", EVT_KEY_BREAK(KEY_PAGEUP) },
{ "EVT_VIRTUAL_NEXT_PAGE", EVT_KEY_BREAK(KEY_PAGEDN) },
{ "EVT_VIRTUAL_MENU", EVT_KEY_BREAK(KEY_MODEL) },
Expand Down
6 changes: 6 additions & 0 deletions radio/src/opentx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,12 @@ void generalDefault()
g_eeGeneral.pwrOnSpeed = 1; // 1 second
#endif

#if defined(IFLIGHT_RELEASE)
g_eeGeneral.splashMode = 3;
g_eeGeneral.pwrOnSpeed = 2;
g_eeGeneral.pwrOffSpeed = 2;
#endif

g_eeGeneral.chkSum = 0xFFFF;
}

Expand Down
2 changes: 1 addition & 1 deletion radio/src/opentx.h
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ constexpr uint8_t OPENTX_START_NO_CHECKS = 0x04;

#if defined(STATUS_LEDS)
#define LED_ERROR_BEGIN() ledRed()
#if defined(RADIO_T8)
#if defined(RADIO_T8) || defined(RADIO_COMMANDO8)
// Because of green backlit logo, green is preferred on this radio
#define LED_ERROR_END() ledGreen()
#define LED_BIND() ledBlue()
Expand Down
2 changes: 1 addition & 1 deletion radio/src/simu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ void OpenTxSim::updateKeysAndSwitches(bool start)
KEY_Down, KEY_EXIT,
KEY_Right, KEY_TELE,
KEY_Left, KEY_SYS,
#elif defined(RADIO_T8)
#elif defined(RADIO_T8) || defined(RADIO_COMMANDO8)
KEY_Page_Up, KEY_PAGEUP,
KEY_Page_Down, KEY_PAGEDN,
KEY_Return, KEY_ENTER,
Expand Down
4 changes: 3 additions & 1 deletion radio/src/stamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
#define DISPLAY_VERSION "-jumper"
#elif defined(RADIOMASTER_RELEASE)
#define DISPLAY_VERSION "-RM"
#elif defined(IFLIGHT_RELEASE)
#define DISPLAY_VERSION "-IF"
#elif defined(TBS_RELEASE)
#define DISPLAY_VERSION "-tbs"
#elif defined(IMRC_RELEASE)
Expand All @@ -64,7 +66,7 @@
const char vers_stamp[] = "FW" TAB ": edgetx-" BOARD_NAME "\036VERS" TAB ": " VERSION DISPLAY_VERSION " (" GIT_STR ")" "\036DATE" TAB ": " DATE " " TIME "\036CFGV" TAB ": " CFGV_STR;
#elif defined(RADIOMASTER_RELEASE)
const char vers_stamp[] = "FW" TAB ": edgetx-" FLAVOUR "\036VERS" TAB ": RM Factory (" GIT_STR ")" "\036BUILT BY : EdgeTX" "\036DATE" TAB ": " DATE " " TIME "\036CFGV" TAB ": " CFGV_STR;
#elif defined(JUMPER_RELEASE)
#elif defined(JUMPER_RELEASE) || defined(IFLIGHT_RELEASE)
const char vers_stamp[] = "FW" TAB ": edgetx-" FLAVOUR "\036VERS" TAB ": Factory (" GIT_STR ")" "\036BUILT BY : EdgeTX" "\036DATE" TAB ": " DATE " " TIME "\036CFGV" TAB ": " CFGV_STR;
#else
#if defined(VERSION_TAG)
Expand Down
2 changes: 1 addition & 1 deletion radio/src/strhelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ char getRawSwitchFromIdx(int idx)
#endif
else
return 'A' + idx;
#elif defined(RADIO_TX12) || defined(RADIO_T8)
#elif defined(RADIO_TX12) || defined(RADIO_T8) || defined(RADIO_COMMANDO8)
if (idx < 6)
return 'A' + idx;
else
Expand Down
40 changes: 34 additions & 6 deletions radio/src/targets/common/arm/stm32/audio_dac_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,34 @@ void dacTimerInit()
AUDIO_TIMER->CR1 = TIM_CR1_CEN ;
}

#if defined(AUDIO_MUTE_GPIO_PIN)
static inline void setMutePin(bool enabled)
{
if (enabled) {
#if defined(INVERTED_MUTE_PIN)
GPIO_ResetBits(AUDIO_MUTE_GPIO, AUDIO_MUTE_GPIO_PIN);
#else
GPIO_SetBits(AUDIO_MUTE_GPIO, AUDIO_MUTE_GPIO_PIN);
#endif
} else {
#if defined(INVERTED_MUTE_PIN)
GPIO_SetBits(AUDIO_MUTE_GPIO, AUDIO_MUTE_GPIO_PIN);
#else
GPIO_ResetBits(AUDIO_MUTE_GPIO, AUDIO_MUTE_GPIO_PIN);
#endif
}
}

static inline bool getMutePin(void)
{
#if defined(INVERTED_MUTE_PIN)
return !GPIO_ReadOutputDataBit(AUDIO_MUTE_GPIO, AUDIO_MUTE_GPIO_PIN);
#else
return GPIO_ReadOutputDataBit(AUDIO_MUTE_GPIO, AUDIO_MUTE_GPIO_PIN);
#endif
}
#endif

// Configure DAC0
// Not sure why PB14 has not be allocated to the DAC, although it is an EXTRA function
// So maybe it is automatically done
Expand All @@ -60,7 +88,7 @@ void dacInit()
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(AUDIO_MUTE_GPIO, &GPIO_InitStructure);
GPIO_SetBits(AUDIO_MUTE_GPIO, AUDIO_MUTE_GPIO_PIN);
setMutePin(true);
#endif

GPIO_InitStructure.GPIO_Pin = AUDIO_OUTPUT_GPIO_PIN;
Expand Down Expand Up @@ -100,27 +128,27 @@ void audioMute()
}
else if (now - audioQueue.lastAudioPlayTime > AUDIO_MUTE_DELAY / 10) {
// delay expired, we may mute
GPIO_SetBits(AUDIO_MUTE_GPIO, AUDIO_MUTE_GPIO_PIN);
setMutePin(true);
}
#else
// mute
GPIO_SetBits(AUDIO_MUTE_GPIO, AUDIO_MUTE_GPIO_PIN);
setMutePin(true);
#endif
}

void audioUnmute()
{
#if defined(AUDIO_UNMUTE_DELAY)
// if muted
if (GPIO_ReadOutputDataBit(AUDIO_MUTE_GPIO, AUDIO_MUTE_GPIO_PIN)) {
if (getMutePin()) {
// ..un-mute
GPIO_ResetBits(AUDIO_MUTE_GPIO, AUDIO_MUTE_GPIO_PIN);
setMutePin(false);
RTOS_WAIT_MS(AUDIO_UNMUTE_DELAY);
}
// reset the mute delay
audioQueue.lastAudioPlayTime = 0;
#else
GPIO_ResetBits(AUDIO_MUTE_GPIO, AUDIO_MUTE_GPIO_PIN);
setMutePin(false);
#endif
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion radio/src/targets/common/arm/stm32/board_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void delay_ms(uint32_t count);
#define ROTENC_HIGHSPEED 50
#define ROTENC_DELAY_MIDSPEED 32
#define ROTENC_DELAY_HIGHSPEED 16
#elif defined(RADIO_T8) && defined(__cplusplus)
#elif (defined(RADIO_T8) || defined(RADIO_COMMANDO8)) && defined(__cplusplus)
constexpr uint8_t rotencSpeed = 1;
#endif

Expand Down
8 changes: 2 additions & 6 deletions radio/src/targets/common/arm/stm32/bootloader/boot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void bootloaderInitApp()
}
}

#if defined(RADIO_T8) && !defined(RADIOMASTER_RELEASE)
#if (defined(RADIO_T8) || defined(RADIO_COMMANDO8)) && !defined(RADIOMASTER_RELEASE)
// Bind button not pressed
if ((~KEYS_GPIO_REG_BIND & KEYS_GPIO_PIN_BIND) == false) {
#else
Expand Down Expand Up @@ -544,16 +544,12 @@ int bootloaderMain()
}

if (state == ST_REBOOT) {
lcdClear();
lcdRefresh();
lcdRefreshWait();

#if !defined(SIMU)
#if defined(RTC_BACKUP_RAM)
rtcInit();
RTC->BKP0R = SOFTRESET_REQUEST;
#endif

blExit();
NVIC_SystemReset();
#else
exit(1);
Expand Down
2 changes: 2 additions & 0 deletions radio/src/targets/common/arm/stm32/bootloader/boot.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,6 @@ void bootloaderDrawScreen(BootloaderState st, int opt, const char* str = nullptr
// Once for each file in a filename list on screen
void bootloaderDrawFilename(const char* str, uint8_t line, bool selected);

void blExit();

#endif
10 changes: 10 additions & 0 deletions radio/src/targets/common/arm/stm32/sticks_pwm_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,20 @@ extern "C" void PWM_IRQHandler(void)
}
}

#if defined(STICK_CHANNEL_CHANGE)
void sticksPwmRead(uint16_t * values)
{
values[0] = timer_capture_values[STICK_PWM_CHANNEL_0];
values[1] = timer_capture_values[STICK_PWM_CHANNEL_1];
values[2] = timer_capture_values[STICK_PWM_CHANNEL_2];
values[3] = timer_capture_values[STICK_PWM_CHANNEL_3];
}
#else
void sticksPwmRead(uint16_t * values)
{
values[0] = timer_capture_values[0];
values[1] = timer_capture_values[1];
values[2] = timer_capture_values[3];
values[3] = timer_capture_values[2];
}
#endif
2 changes: 1 addition & 1 deletion radio/src/targets/common/arm/stm32/stm32_hal_adc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ stm32_hal_adc_channel ADC_MAIN_channels[] = {
{ ADC_CHANNEL_SLIDER2, ADC_SAMPTIME },
{ ADC_CHANNEL_BATT, ADC_SAMPTIME }
#else
#if defined(RADIO_T8) || defined(RADIO_TLITE)
#if defined(RADIO_T8) || defined(RADIO_TLITE) || defined(RADIO_COMMANDO8)
// fake channels to fill unsused POT1/POT2
{0, 0},
{0, 0},
Expand Down
7 changes: 7 additions & 0 deletions radio/src/targets/horus/bootloader/boot_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,10 @@ void bootloaderDrawFilename(const char* str, uint8_t line, bool selected)
lcd->drawSolidRect(119, 72 + (line * 25), 278, 26, 2, BL_SELECTED);
}
}

void blExit(void)
{
lcdClear();
lcdRefresh();
lcdRefreshWait();
}
7 changes: 7 additions & 0 deletions radio/src/targets/nv14/bootloader/boot_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,10 @@ void bootloaderDrawFilename(const char* str, uint8_t line, bool selected)
BL_SELECTED);
}
}

void blExit(void)
{
lcdClear();
lcdRefresh();
lcdRefreshWait();
}
Loading

0 comments on commit 29d1feb

Please sign in to comment.