mirror of
https://github.com/opentx/opentx.git
synced 2025-07-13 19:40:20 +03:00
x9e with horus bt module (#5214)
* Basics to allow Horus BT module on X9E * wip * Temporary hack to prevent X9E to enter reset loop * The wait game starts :) * Temporary compil fixes * More sensibles defines
This commit is contained in:
parent
06f5e408ee
commit
6f3577c9a5
9 changed files with 37 additions and 17 deletions
|
@ -45,6 +45,7 @@ option(BINDING_OPTIONS "Allow advanced frsky bindings" OFF)
|
|||
option(FRSKY_STICKS "Reverse sticks for FrSky sticks" OFF)
|
||||
option(NANO "Use nano newlib and binalloc")
|
||||
option(NIGHTLY_BUILD_WARNING "Warn this is a nightly build" OFF)
|
||||
option(USEHORUSBT "X9E BT module replaced by Horus BT module" OFF)
|
||||
|
||||
# since we reset all default CMAKE compiler flags for firmware builds, provide an alternate way for user to specify additional flags.
|
||||
set(FIRMWARE_C_FLAGS "" CACHE STRING "Additional flags for firmware target c compiler (note: all CMAKE_C_FLAGS[_*] are ignored for firmware/bootloader).")
|
||||
|
@ -352,6 +353,10 @@ if(NIGHTLY_BUILD_WARNING)
|
|||
add_definitions(-DNIGHTLY_BUILD_WARNING)
|
||||
endif(NIGHTLY_BUILD_WARNING)
|
||||
|
||||
if(USEHORUSBT)
|
||||
add_definitions(-DUSEHORUSBT)
|
||||
endif(USEHORUSBT)
|
||||
|
||||
set(SRC
|
||||
${SRC}
|
||||
opentx.cpp
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#include "opentx.h"
|
||||
|
||||
#if defined(PCBX7) || defined(PCBHORUS)
|
||||
#if defined(PCBX7) || defined(PCBHORUS) || defined(USEHORUSBT)
|
||||
#define BLUETOOTH_COMMAND_NAME "AT+NAME"
|
||||
#define BLUETOOTH_ANSWER_NAME "OK+"
|
||||
#define BLUETOOTH_COMMAND_BAUD_115200 "AT+BAUD115200"
|
||||
|
@ -69,7 +69,7 @@ char * bluetoothReadline(bool error_reset)
|
|||
|
||||
while (1) {
|
||||
if (!btRxFifo.pop(byte)) {
|
||||
#if defined(PCBX9E) // X9E BT module can get unresponsive
|
||||
#if defined(PCBX9E) && !defined(USEHORUSBT) // X9E BT module can get unresponsive
|
||||
TRACE("NO RESPONSE FROM BT MODULE");
|
||||
#endif
|
||||
return NULL;
|
||||
|
@ -81,10 +81,14 @@ char * bluetoothReadline(bool error_reset)
|
|||
bluetoothBufferIndex = 0;
|
||||
TRACE("BT< %s", bluetoothBuffer);
|
||||
if (error_reset && !strcmp((char *)bluetoothBuffer, "ERROR")) {
|
||||
#if defined(PCBX9E) // X9E enter BT reset loop if following code is implemented
|
||||
TRACE("BT error...");
|
||||
#else
|
||||
TRACE("BT Reset...");
|
||||
bluetoothDone();
|
||||
bluetoothState = BLUETOOTH_STATE_OFF;
|
||||
bluetoothWakeupTime = get_tmr10ms() + 100; /* 1s */
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
@ -255,7 +259,7 @@ void bluetoothReceiveTrainer()
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(PCBX9E) && defined(DEBUG)
|
||||
#if defined(PCBX9E) && !defined(USEHORUSBT)
|
||||
void bluetoothWakeup(void)
|
||||
{
|
||||
if (!g_eeGeneral.bluetoothMode) {
|
||||
|
@ -346,11 +350,13 @@ void bluetoothWakeup()
|
|||
if (bluetoothState == BLUETOOTH_STATE_FACTORY_BAUDRATE_INIT) {
|
||||
bluetoothWriteString("AT+BAUD4\r\n");
|
||||
bluetoothState = BLUETOOTH_STATE_BAUDRATE_SENT;
|
||||
bluetoothWakeupTime = now + 10; /* 100ms */
|
||||
}
|
||||
else if (bluetoothState == BLUETOOTH_STATE_BAUDRATE_SENT) {
|
||||
bluetoothInit(BLUETOOTH_DEFAULT_BAUDRATE);
|
||||
bluetoothState = BLUETOOTH_STATE_BAUDRATE_INIT;
|
||||
bluetoothReadline(false);
|
||||
bluetoothWakeupTime = now + 10; /* 100ms */
|
||||
}
|
||||
else if (bluetoothState == BLUETOOTH_STATE_CONNECTED) {
|
||||
if (g_eeGeneral.bluetoothMode == BLUETOOTH_TRAINER && g_model.trainerMode == TRAINER_MODE_MASTER_BLUETOOTH) {
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
*/
|
||||
|
||||
enum BluetoothStates {
|
||||
#if defined(PCBX9E) && defined(DEBUG)
|
||||
#if defined(PCBX9E) && !defined(USEHORUSBT)
|
||||
BLUETOOTH_INIT,
|
||||
BLUETOOTH_WAIT_TTM,
|
||||
BLUETOOTH_WAIT_BAUDRATE_CHANGE,
|
||||
|
|
|
@ -241,7 +241,7 @@ int getSwitchWarningsCount()
|
|||
#define INTERNAL_MODULE_CHANNELS_ROWS IF_INTERNAL_MODULE_ON(1)
|
||||
#define PORT_CHANNELS_ROWS(x) (x==INTERNAL_MODULE ? INTERNAL_MODULE_CHANNELS_ROWS : (x==EXTERNAL_MODULE ? EXTERNAL_MODULE_CHANNELS_ROWS : 1))
|
||||
|
||||
#if defined(BLUETOOTH) && defined(DEBUG)
|
||||
#if defined(BLUETOOTH) && defined(USEHORUSBT)
|
||||
#define TRAINER_LINE1_BLUETOOTH_M_ROWS ((bluetoothDistantAddr[0] == 0 || bluetoothState == BLUETOOTH_STATE_CONNECTED) ? (uint8_t)0 : (uint8_t)1)
|
||||
#define TRAINER_LINE1_ROWS (g_model.trainerMode == TRAINER_MODE_SLAVE ? (uint8_t)1 : (g_model.trainerMode == TRAINER_MODE_MASTER_BLUETOOTH ? TRAINER_LINE1_BLUETOOTH_M_ROWS : (g_model.trainerMode == TRAINER_MODE_SLAVE_BLUETOOTH ? (uint8_t)1 : HIDDEN_ROW)))
|
||||
#define TRAINER_LINE2_ROWS (g_model.trainerMode == TRAINER_MODE_SLAVE ? (uint8_t)2 : HIDDEN_ROW)
|
||||
|
@ -721,7 +721,7 @@ void menuModelSetup(event_t event)
|
|||
if (attr) {
|
||||
g_model.trainerMode = checkIncDec(event, g_model.trainerMode, 0, TRAINER_MODE_MAX(), EE_MODEL, isTrainerModeAvailable);
|
||||
}
|
||||
#if defined(BLUETOOTH) && defined(DEBUG)
|
||||
#if defined(BLUETOOTH) && defined(USEHORUSBT)
|
||||
if (attr && checkIncDec_Ret) {
|
||||
bluetoothState = BLUETOOTH_STATE_OFF;
|
||||
bluetoothDistantAddr[0] = 0;
|
||||
|
@ -823,7 +823,7 @@ void menuModelSetup(event_t event)
|
|||
lcdDrawTextAlignedLeft(y, STR_TRAINER);
|
||||
break;
|
||||
|
||||
#if defined(BLUETOOTH) && defined(DEBUG)
|
||||
#if defined(BLUETOOTH) && defined(USEHORUSBT)
|
||||
case ITEM_MODEL_TRAINER_LINE1:
|
||||
if (g_model.trainerMode == TRAINER_MODE_MASTER_BLUETOOTH) {
|
||||
if (attr) {
|
||||
|
|
|
@ -77,7 +77,7 @@ enum menuRadioHwItems {
|
|||
#define SWITCHES_ROWS NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1
|
||||
#endif
|
||||
|
||||
#if defined(BLUETOOTH) && defined(DEBUG)
|
||||
#if defined(BLUETOOTH) && defined(USEHORUSBT)
|
||||
#define BLUETOOTH_ROWS 0, uint8_t(g_eeGeneral.bluetoothMode == BLUETOOTH_OFF ? -1 : 0),
|
||||
#else
|
||||
#define BLUETOOTH_ROWS
|
||||
|
@ -198,7 +198,7 @@ void menuRadioHardware(event_t event)
|
|||
break;
|
||||
}
|
||||
|
||||
#if defined(BLUETOOTH) && defined(DEBUG)
|
||||
#if defined(BLUETOOTH) && defined(USEHORUSBT)
|
||||
case ITEM_RADIO_HARDWARE_BLUETOOTH_MODE:
|
||||
lcdDrawText(INDENT_WIDTH, y, STR_BLUETOOTH);
|
||||
lcdDrawTextAtIndex(HW_SETTINGS_COLUMN, y, STR_BLUETOOTH_MODES, g_eeGeneral.bluetoothMode, attr);
|
||||
|
|
|
@ -565,8 +565,8 @@ bool isTrainerModeAvailable(int mode)
|
|||
{
|
||||
if (IS_EXTERNAL_MODULE_ENABLED() && (mode == TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE || mode == TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE))
|
||||
return false;
|
||||
#if defined(DEBUG)
|
||||
else if (mode == TRAINER_MODE_MASTER_BLUETOOTH || mode == TRAINER_MODE_MASTER_BATTERY_COMPARTMENT)
|
||||
#if defined(USEHORUSBT)
|
||||
else if (mode == TRAINER_MODE_MASTER_BATTERY_COMPARTMENT)
|
||||
#else
|
||||
else if (mode == TRAINER_MODE_MASTER_BLUETOOTH || mode == TRAINER_MODE_MASTER_BATTERY_COMPARTMENT || mode == TRAINER_MODE_SLAVE_BLUETOOTH)
|
||||
#endif
|
||||
|
|
|
@ -152,7 +152,7 @@
|
|||
#define CASE_SDCARD(x)
|
||||
#endif
|
||||
|
||||
#if defined(BLUETOOTH) && !(defined(PCBX9E) && !defined(DEBUG))
|
||||
#if defined(BLUETOOTH) && !(defined(PCBX9E) && !defined(USEHORUSBT))
|
||||
#define CASE_BLUETOOTH(x) x,
|
||||
#else
|
||||
#define CASE_BLUETOOTH(x)
|
||||
|
@ -200,7 +200,7 @@
|
|||
#define CASE_PCBX9E(x)
|
||||
#endif
|
||||
|
||||
#if defined(BLUETOOTH) && (!defined(PCBX9E) || defined(DEBUG))
|
||||
#if defined(BLUETOOTH) && !(defined(PCBX9E) && !defined(USEHORUSBT))
|
||||
#define CASE_BLUETOOTH(x) x,
|
||||
#else
|
||||
#define CASE_BLUETOOTH(x)
|
||||
|
@ -231,7 +231,7 @@
|
|||
#define IS_FAI_FORBIDDEN(idx) (IS_FAI_ENABLED() && idx >= MIXSRC_FIRST_TELEM)
|
||||
|
||||
#if defined(BLUETOOTH)
|
||||
#if defined(X9E)
|
||||
#if defined(X9E) && !defined(USEHORUSBT)
|
||||
#define IS_BLUETOOTH_TRAINER() (g_model.trainerMode == TRAINER_MODE_SLAVE_BLUETOOTH)
|
||||
#define IS_SLAVE_TRAINER() (g_model.trainerMode == TRAINER_MODE_SLAVE)
|
||||
#else
|
||||
|
|
|
@ -545,7 +545,7 @@ void serial2Stop(void);
|
|||
|
||||
// BT driver
|
||||
#define BLUETOOTH_DEFAULT_BAUDRATE 115200
|
||||
#if defined(PCBX9E)
|
||||
#if defined(PCBX9E) && !defined(USEHORUSBT)
|
||||
#define BLUETOOTH_FACTORY_BAUDRATE 9600
|
||||
#else
|
||||
#define BLUETOOTH_FACTORY_BAUDRATE 57600
|
||||
|
|
|
@ -135,6 +135,15 @@ if [[ " X7 ALL " =~ " ${FLAVOR} " ]] ; then
|
|||
make -j${CORES} gtests ; ./gtests ${TEST_OPTIONS}
|
||||
fi
|
||||
|
||||
if [[ " X7S ALL " =~ " ${FLAVOR} " ]] ; then
|
||||
# OpenTX on X7S
|
||||
rm -rf *
|
||||
cmake ${COMMON_OPTIONS} -DPCB=X7S -DHELI=YES -DLUA=YES -DGVARS=YES ${SRCDIR}
|
||||
make -j${CORES} ${FIRMARE_TARGET}
|
||||
make -j${CORES} simu
|
||||
make -j${CORES} gtests ; ./gtests ${TEST_OPTIONS}
|
||||
fi
|
||||
|
||||
if [[ " X9D X9 ALL " =~ " ${FLAVOR} " ]] ; then
|
||||
# OpenTX on X9D
|
||||
rm -rf *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue