mirror of
https://github.com/opentx/opentx.git
synced 2025-07-15 20:35:17 +03:00
FrSky Single stick radio
This commit is contained in:
parent
2670b3121d
commit
3530e68e3d
9 changed files with 73 additions and 56 deletions
|
@ -20,16 +20,6 @@
|
|||
|
||||
#include "opentx.h"
|
||||
|
||||
bool isThrottleOutput(uint8_t ch)
|
||||
{
|
||||
for (uint8_t i=0; i<MAX_MIXERS; i++) {
|
||||
MixData *mix = mixAddress(i);
|
||||
if (mix->destCh==ch && mix->srcRaw==MIXSRC_Thr)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
enum MenuModelOutputsItems {
|
||||
ITEM_OUTPUTS_OFFSET,
|
||||
ITEM_OUTPUTS_MIN,
|
||||
|
@ -43,9 +33,9 @@ enum MenuModelOutputsItems {
|
|||
#define LIMITS_OFFSET_POS 11*FW
|
||||
#define LIMITS_MIN_POS 15*FW
|
||||
#define LIMITS_MAX_POS 18*FW
|
||||
#define LIMITS_REVERT_POS 19*FW
|
||||
#define LIMITS_REVERT_POS 19*FW-1
|
||||
|
||||
#define LIMITS_MIN_MAX_OFFSET 100
|
||||
#define LIMITS_MIN_MAX_OFFSET 1000
|
||||
#define CONVERT_US_MIN_MAX(x) ((int16_t(x)*128)/25)
|
||||
#define MIN_MAX_ATTR attr
|
||||
|
||||
|
@ -100,14 +90,14 @@ void menuModelLimits(event_t event)
|
|||
break;
|
||||
|
||||
case ITEM_OUTPUTS_MIN:
|
||||
lcdDrawNumber(LIMITS_MIN_POS, y, MIN_MAX_DISPLAY(ld->min-LIMITS_MIN_MAX_OFFSET), MIN_MAX_ATTR|RIGHT);
|
||||
lcdDrawNumber(LIMITS_MIN_POS, y, MIN_MAX_DISPLAY(ld->min-LIMITS_MIN_MAX_OFFSET), MIN_MAX_ATTR|RIGHT|PREC1);
|
||||
if (active) {
|
||||
ld->min = LIMITS_MIN_MAX_OFFSET + checkIncDec(event, ld->min-LIMITS_MIN_MAX_OFFSET, -limit, 0, EE_MODEL);
|
||||
}
|
||||
break;
|
||||
|
||||
case ITEM_OUTPUTS_MAX:
|
||||
lcdDrawNumber(LIMITS_MAX_POS, y, MIN_MAX_DISPLAY(ld->max+LIMITS_MIN_MAX_OFFSET), MIN_MAX_ATTR|RIGHT);
|
||||
lcdDrawNumber(LIMITS_MAX_POS, y, MIN_MAX_DISPLAY(ld->max+LIMITS_MIN_MAX_OFFSET), MIN_MAX_ATTR|RIGHT|PREC1);
|
||||
if (active) {
|
||||
ld->max = -LIMITS_MIN_MAX_OFFSET + checkIncDec(event, ld->max+LIMITS_MIN_MAX_OFFSET, 0, +limit, EE_MODEL);
|
||||
}
|
||||
|
@ -122,13 +112,7 @@ void menuModelLimits(event_t event)
|
|||
lcdDrawTextAtIndex(LIMITS_REVERT_POS, y, STR_MMMINV, revert, attr);
|
||||
#endif
|
||||
if (active) {
|
||||
uint8_t revert_new = checkIncDecModel(event, revert, 0, 1);
|
||||
if (checkIncDec_Ret && isThrottleOutput(k)) {
|
||||
POPUP_CONFIRMATION(STR_INVERT_THR);
|
||||
}
|
||||
else {
|
||||
ld->revert = revert_new;
|
||||
}
|
||||
ld->revert = checkIncDecModel(event, revert, 0, 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ void menuCommonCalib(event_t event)
|
|||
|
||||
switch (event) {
|
||||
case EVT_ENTRY:
|
||||
case EVT_KEY_BREAK(KEY_EXIT):
|
||||
#if defined(PCBACAIR)
|
||||
ENABLE_FACTORY_MODE();
|
||||
ENABLE_KEYS();
|
||||
|
@ -128,13 +129,11 @@ void menuCommonCalib(event_t event)
|
|||
void menuRadioCalibration(event_t event)
|
||||
{
|
||||
check_simple(event, MENU_RADIO_CALIBRATION, menuTabModel, DIM(menuTabModel), 0);
|
||||
|
||||
TITLE(STR_MENUCALIBRATION);
|
||||
menuCommonCalib(READ_ONLY() ? 0 : event);
|
||||
if (menuEvent) {
|
||||
menuCalibrationState = CALIB_START;
|
||||
}
|
||||
|
||||
TITLE(STR_MENUCALIBRATION);
|
||||
menuCommonCalib(READ_ONLY() ? 0 : event);
|
||||
}
|
||||
|
||||
void menuFirstCalib(event_t event)
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
enum MenuRadioSetupItems {
|
||||
ITEM_SETUP_SWITCH_SA,
|
||||
ITEM_SETUP_SWITCH_SB,
|
||||
ITEM_SETUP_SWITCH_SC,
|
||||
ITEM_SETUP_BATT_RANGE,
|
||||
ITEM_SETUP_BATTERY_WARNING,
|
||||
ITEM_SETUP_CONTRAST,
|
||||
|
@ -41,6 +42,7 @@ void menuRadioSetup(event_t event)
|
|||
HEADER_LINE_COLUMNS
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
|
@ -61,7 +63,9 @@ void menuRadioSetup(event_t event)
|
|||
|
||||
switch (k) {
|
||||
case ITEM_SETUP_SWITCH_SA:
|
||||
case ITEM_SETUP_SWITCH_SB: {
|
||||
case ITEM_SETUP_SWITCH_SB:
|
||||
case ITEM_SETUP_SWITCH_SC:
|
||||
{
|
||||
int index = k - ITEM_SETUP_SWITCH_SA;
|
||||
int config = SWITCH_CONFIG(index);
|
||||
lcdDrawTextAtIndex(0, y, STR_VSRCRAW, MIXSRC_FIRST_SWITCH - MIXSRC_Rud + index + 1,
|
||||
|
|
|
@ -810,9 +810,13 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
|
|||
if (mode==e_perout_mode_normal && pass==0) swOn[i].activeMix = 0;
|
||||
#endif
|
||||
|
||||
MixData *md = mixAddress(i);
|
||||
MixData * md = mixAddress(i);
|
||||
|
||||
#if defined(PCBACAIR)
|
||||
if (md->srcRaw == 0) continue;
|
||||
#else
|
||||
if (md->srcRaw == 0) break;
|
||||
#endif
|
||||
|
||||
mixsrc_t stickIndex = md->srcRaw - MIXSRC_FIRST_STICK;
|
||||
|
||||
|
|
|
@ -260,17 +260,20 @@ void generalDefault()
|
|||
g_eeGeneral.slidersConfig = 0x03; // LS and RS = sliders with detent
|
||||
#endif
|
||||
|
||||
#if defined(PCBX7)
|
||||
#if defined(PCBACAIR)
|
||||
g_eeGeneral.switchConfig = 0x0000002b;
|
||||
#elif defined(PCBX7)
|
||||
g_eeGeneral.switchConfig = 0x000006ff; // 4x3POS, 1x2POS, 1xTOGGLE
|
||||
#elif defined(PCBTARANIS) || defined(PCBHORUS)
|
||||
g_eeGeneral.switchConfig = 0x00007bff; // 6x3POS, 1x2POS, 1xTOGGLE
|
||||
#endif
|
||||
|
||||
#if defined(PCBX9E)
|
||||
// NI-MH 9.6V
|
||||
g_eeGeneral.vBatWarn = 87;
|
||||
g_eeGeneral.vBatMin = -5;
|
||||
g_eeGeneral.vBatMax = -5;
|
||||
#if defined(PCBACAIR)
|
||||
g_eeGeneral.switchConfig = 0x0000002b;
|
||||
#elif defined(PCBX9E)
|
||||
g_eeGeneral.vBatWarn = 65;
|
||||
g_eeGeneral.vBatMin = -30;
|
||||
g_eeGeneral.vBatMax = -30;
|
||||
#elif defined(PCBTARANIS)
|
||||
// NI-MH 7.2V
|
||||
g_eeGeneral.vBatWarn = 65;
|
||||
|
@ -292,6 +295,10 @@ void generalDefault()
|
|||
|
||||
#if defined(PCBFLAMENCO)
|
||||
g_eeGeneral.inactivityTimer = 50;
|
||||
#elif defined(PCBACAIR)
|
||||
g_eeGeneral.backlightMode = e_backlight_mode_all;
|
||||
g_eeGeneral.lightAutoOff = 2;
|
||||
g_eeGeneral.inactivityTimer = 5;
|
||||
#elif !defined(CPUM64)
|
||||
g_eeGeneral.backlightMode = e_backlight_mode_all;
|
||||
g_eeGeneral.lightAutoOff = 2;
|
||||
|
@ -383,7 +390,7 @@ inline void applyDefaultTemplate()
|
|||
void applyDefaultTemplate()
|
||||
{
|
||||
g_model.extendedLimits = true;
|
||||
g_model.switchWarningEnable = 0b11;
|
||||
g_model.switchWarningEnable = 0;
|
||||
memcpy(g_model.header.name, "\001\003\000\001\367\356", 6);
|
||||
|
||||
g_model.moduleData[INTERNAL_MODULE].failsafeMode = FAILSAFE_CUSTOM;
|
||||
|
@ -402,6 +409,8 @@ void applyDefaultTemplate()
|
|||
}
|
||||
|
||||
// 3 dual rates for Rud and Thr
|
||||
const uint8_t RUD_WEIGHT[] = {40, 20, 10};
|
||||
const uint8_t THR_WEIGHT[] = {80, 40, 20};
|
||||
for (int i=0; i<3; i++) {
|
||||
// Rud
|
||||
ExpoData * expo = expoAddress(i);
|
||||
|
@ -409,17 +418,17 @@ void applyDefaultTemplate()
|
|||
expo->srcRaw = MIXSRC_Rud;
|
||||
expo->swtch = SWSRC_SA0 + i;
|
||||
expo->curve.type = CURVE_REF_EXPO;
|
||||
expo->curve.value = 40;
|
||||
expo->weight = 100 - i * 20;
|
||||
expo->mode = 3;
|
||||
expo->curve.value = 0;
|
||||
expo->weight = RUD_WEIGHT[i];
|
||||
expo->mode = 3; // TODO constant
|
||||
// Thr
|
||||
expo = expoAddress(3 + i);
|
||||
expo->chn = 1;
|
||||
expo->srcRaw = MIXSRC_Thr;
|
||||
expo->swtch = SWSRC_SA0 + i;
|
||||
expo->curve.type = CURVE_REF_EXPO;
|
||||
expo->curve.value = 20;
|
||||
expo->weight = 100 - i * 20;
|
||||
expo->curve.value = 0;
|
||||
expo->weight = THR_WEIGHT[i];
|
||||
expo->mode = 3; // TODO constant
|
||||
}
|
||||
|
||||
|
@ -445,17 +454,31 @@ void applyDefaultTemplate()
|
|||
++mix;
|
||||
mix->destCh = 2;
|
||||
mix->weight = 100;
|
||||
mix->srcRaw = MIXSRC_SB;
|
||||
mix->srcRaw = MIXSRC_NONE;
|
||||
++mix;
|
||||
mix->destCh = 3;
|
||||
mix->weight = 100;
|
||||
mix->srcRaw = MIXSRC_SC;
|
||||
for (int i=4; i<8; i++) {
|
||||
mix->srcRaw = MIXSRC_NONE;
|
||||
++mix;
|
||||
mix->destCh = i;
|
||||
mix->destCh = 4;
|
||||
mix->weight = 100;
|
||||
mix->srcRaw = MIXSRC_SC;
|
||||
++mix;
|
||||
mix->destCh = 5;
|
||||
mix->weight = 100;
|
||||
mix->srcRaw = MIXSRC_SB;
|
||||
++mix;
|
||||
mix->destCh = 6;
|
||||
mix->weight = 100;
|
||||
mix->srcRaw = MIXSRC_NONE;
|
||||
}
|
||||
|
||||
// The outputs
|
||||
LimitData * ch2 = limitAddress(1);
|
||||
ch2->revert = 1;
|
||||
LimitData * ch5 = limitAddress(4);
|
||||
ch5->offset = +100; // 10.0%
|
||||
LimitData * ch6 = limitAddress(5);
|
||||
ch6->min = +100; // 0%
|
||||
|
||||
storageDirty(EE_MODEL);
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ void simuInit()
|
|||
simuSetSwitch(i, 0);
|
||||
simuSetKey(i, false); // a little dirty, but setting keys that don't exist is perfectly OK here
|
||||
}
|
||||
for (int i=0; i < (NUM_STICKS+NUM_AUX_TRIMS)*2; i++)
|
||||
for (int i=0; i < NUM_TRIMS*2; i++)
|
||||
simuSetTrim(i, false);
|
||||
|
||||
#if defined(ROTARY_ENCODERS) || defined(ROTARY_ENCODER_NAVIGATION)
|
||||
|
|
|
@ -90,7 +90,7 @@ set(TARGET_DIR taranis)
|
|||
# set(PPM_LIMITS_SYMETRICAL YES)
|
||||
|
||||
if(SPLASH STREQUAL OFF)
|
||||
message(FATAL_ERROR "Option SPLASH=OFF not supported on Taranis")
|
||||
# message(FATAL_ERROR "Option SPLASH=OFF not supported on Taranis")
|
||||
endif()
|
||||
|
||||
add_definitions(-DPCBTARANIS -DPPM_PIN_TIMER)
|
||||
|
|
|
@ -145,6 +145,7 @@ void readKeysAndTrims()
|
|||
|
||||
in = readKeys();
|
||||
if (FACTORY_MODE_ENABLED()) {
|
||||
TRACE("FACTORY 0x%x", in);
|
||||
if (in == ((1 << KEY_MENU) | (1 << KEY_ENTER))) {
|
||||
ENABLE_KEYS();
|
||||
}
|
||||
|
@ -201,6 +202,7 @@ void readKeysAndTrims()
|
|||
xxx = ~SWITCHES_GPIO_REG_ ## x & SWITCHES_GPIO_PIN_ ## x ; \
|
||||
break;
|
||||
#endif
|
||||
#if !defined(PCBACAIR)
|
||||
#define ADD_3POS_CASE(x, i) \
|
||||
case SW_S ## x ## 0: \
|
||||
xxx = (SWITCHES_GPIO_REG_ ## x ## _H & SWITCHES_GPIO_PIN_ ## x ## _H); \
|
||||
|
@ -217,6 +219,7 @@ void readKeysAndTrims()
|
|||
xxx = xxx && (SWITCHES_GPIO_REG_ ## x ## _L & SWITCHES_GPIO_PIN_ ## x ## _L); \
|
||||
} \
|
||||
break
|
||||
#endif
|
||||
|
||||
uint8_t keyState(uint8_t index)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue