mirror of
https://github.com/opentx/opentx.git
synced 2025-07-25 01:05:10 +03:00
VIRTUAL_INPUTS #define removed
This commit is contained in:
parent
a8707baf57
commit
d2697345e1
12 changed files with 27 additions and 327 deletions
|
@ -520,10 +520,8 @@ enum SwitchSources {
|
|||
enum MixSources {
|
||||
MIXSRC_NONE,
|
||||
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
MIXSRC_FIRST_INPUT, LUA_EXPORT_MULTIPLE("input", "Input [I%d]", MAX_INPUTS)
|
||||
MIXSRC_LAST_INPUT = MIXSRC_FIRST_INPUT+MAX_INPUTS-1,
|
||||
#endif
|
||||
|
||||
#if defined(LUA_INPUTS)
|
||||
MIXSRC_FIRST_LUA,
|
||||
|
|
|
@ -247,7 +247,6 @@ PACK(struct TimerData {
|
|||
* Swash Ring structure
|
||||
*/
|
||||
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
PACK(struct SwashRingData {
|
||||
uint8_t type;
|
||||
uint8_t value;
|
||||
|
@ -258,16 +257,6 @@ PACK(struct SwashRingData {
|
|||
int8_t aileronWeight;
|
||||
int8_t elevatorWeight;
|
||||
});
|
||||
#else
|
||||
PACK(struct SwashRingData {
|
||||
uint8_t invertELE:1;
|
||||
uint8_t invertAIL:1;
|
||||
uint8_t invertCOL:1;
|
||||
uint8_t type:5;
|
||||
uint8_t collectiveSource;
|
||||
uint8_t value;
|
||||
});
|
||||
#endif
|
||||
|
||||
#if MAX_SCRIPTS > 0
|
||||
union ScriptDataInput {
|
||||
|
|
|
@ -343,14 +343,12 @@ void drawStatusLine();
|
|||
|
||||
extern uint8_t editNameCursorPos;
|
||||
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
uint8_t getExposCount();
|
||||
void insertExpo(uint8_t idx);
|
||||
void deleteExpo(uint8_t idx);
|
||||
uint8_t getMixesCount();
|
||||
void insertMix(uint8_t idx);
|
||||
void deleteMix(uint8_t idx);
|
||||
#endif
|
||||
|
||||
typedef int (*FnFuncP) (int x);
|
||||
void drawFunction(FnFuncP fn, uint8_t offset=0);
|
||||
|
|
|
@ -23,19 +23,12 @@
|
|||
enum MenuModelHeliItems {
|
||||
ITEM_HELI_SWASHTYPE,
|
||||
ITEM_HELI_SWASHRING,
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
ITEM_HELI_ELE,
|
||||
ITEM_HELI_ELE_WEIGHT,
|
||||
ITEM_HELI_AIL,
|
||||
ITEM_HELI_AIL_WEIGHT,
|
||||
ITEM_HELI_COL,
|
||||
ITEM_HELI_COL_WEIGHT,
|
||||
#else
|
||||
ITEM_HELI_COLLECTIVE,
|
||||
ITEM_HELI_ELEDIRECTION,
|
||||
ITEM_HELI_AILDIRECTION,
|
||||
ITEM_HELI_COLDIRECTION,
|
||||
#endif
|
||||
ITEM_HELI_MAX
|
||||
};
|
||||
|
||||
|
@ -51,14 +44,9 @@ void menuModelHeli(event_t event)
|
|||
|
||||
uint8_t sub = menuVerticalPosition - HEADER_LINE;
|
||||
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
for (uint8_t i=0; i<NUM_BODY_LINES; i++) {
|
||||
coord_t y = MENU_HEADER_HEIGHT + 1 + i*FH;
|
||||
uint8_t k = i + menuVerticalOffset;
|
||||
#else
|
||||
for (uint8_t k=0; k<ITEM_HELI_MAX; k++) {
|
||||
coord_t y = MENU_HEADER_HEIGHT + 1 + k*FH;
|
||||
#endif
|
||||
LcdFlags blink = (s_editMode > 0 ? BLINK|INVERS : INVERS);
|
||||
LcdFlags attr = (sub == k ? blink : 0);
|
||||
|
||||
|
@ -73,7 +61,6 @@ void menuModelHeli(event_t event)
|
|||
if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, g_model.swashR.value, 100);
|
||||
break;
|
||||
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
case ITEM_HELI_ELE:
|
||||
lcdDrawTextAlignedLeft(y, STR_ELEVATOR);
|
||||
drawSource(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.elevatorSource, attr);
|
||||
|
@ -109,24 +96,6 @@ void menuModelHeli(event_t event)
|
|||
lcdDrawNumber(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.collectiveWeight, LEFT|attr);
|
||||
if (attr) CHECK_INCDEC_MODELVAR(event, g_model.swashR.collectiveWeight, -100, 100);
|
||||
break;
|
||||
#else
|
||||
case ITEM_HELI_COLLECTIVE:
|
||||
g_model.swashR.collectiveSource = editChoice(MODEL_HELI_2ND_COLUMN, y, STR_COLLECTIVE, NULL, g_model.swashR.collectiveSource, 0, MIXSRC_LAST_CH, attr, event);
|
||||
drawSource(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.collectiveSource, attr);
|
||||
break;
|
||||
|
||||
case ITEM_HELI_ELEDIRECTION:
|
||||
g_model.swashR.invertELE = editChoice(MODEL_HELI_2ND_COLUMN, y, STR_ELEDIRECTION, STR_MMMINV, g_model.swashR.invertELE, 0, 1, attr, event);
|
||||
break;
|
||||
|
||||
case ITEM_HELI_AILDIRECTION:
|
||||
g_model.swashR.invertAIL = editChoice(MODEL_HELI_2ND_COLUMN, y, STR_AILDIRECTION, STR_MMMINV, g_model.swashR.invertAIL, 0, 1, attr, event);
|
||||
break;
|
||||
|
||||
case ITEM_HELI_COLDIRECTION:
|
||||
g_model.swashR.invertCOL = editChoice(MODEL_HELI_2ND_COLUMN, y, STR_COLDIRECTION, STR_MMMINV, g_model.swashR.invertCOL, 0, 1, attr, event);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ macro(add_lua_export_target target)
|
|||
endmacro(add_lua_export_target)
|
||||
|
||||
set(LUA_INCLUDES
|
||||
-DCPUARM -DLUA -DVIRTUAL_INPUTS -DLUA_INPUTS
|
||||
-DCPUARM -DLUA -DLUA_INPUTS
|
||||
-I${RADIO_SRC_DIRECTORY}/targets/${TARGET_DIR}
|
||||
-I${RADIO_SRC_DIRECTORY}/thirdparty
|
||||
-I${RADIO_SRC_DIRECTORY}/targets/common/arm/stm32
|
||||
|
|
|
@ -21,12 +21,7 @@
|
|||
#include "opentx.h"
|
||||
#include "timers.h"
|
||||
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
int8_t virtualInputsTrims[NUM_INPUTS];
|
||||
#else
|
||||
int16_t rawAnas[NUM_INPUTS] = {0};
|
||||
#endif
|
||||
|
||||
int16_t anas [NUM_INPUTS] = {0};
|
||||
int16_t trims[NUM_TRIMS] = {0};
|
||||
int32_t chans[MAX_OUTPUT_CHANNELS] = {0};
|
||||
|
@ -153,11 +148,6 @@ int expo(int x, int k)
|
|||
|
||||
void applyExpos(int16_t * anas, uint8_t mode APPLY_EXPOS_EXTRA_PARAMS)
|
||||
{
|
||||
#if !defined(VIRTUAL_INPUTS)
|
||||
int16_t anas2[NUM_INPUTS]; // values before expo, to ensure same expo base when multiple expo lines are used
|
||||
memcpy(anas2, anas, sizeof(anas2));
|
||||
#endif
|
||||
|
||||
int8_t cur_chn = -1;
|
||||
|
||||
for (uint8_t i=0; i<MAX_EXPOS; i++) {
|
||||
|
@ -171,7 +161,6 @@ void applyExpos(int16_t * anas, uint8_t mode APPLY_EXPOS_EXTRA_PARAMS)
|
|||
if (ed->flightModes & (1<<mixerCurrentFlightMode))
|
||||
continue;
|
||||
if (getSwitch(ed->swtch)) {
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
int32_t v;
|
||||
if (ed->srcRaw == ovwrIdx) {
|
||||
v = ovwrValue;
|
||||
|
@ -183,9 +172,6 @@ void applyExpos(int16_t * anas, uint8_t mode APPLY_EXPOS_EXTRA_PARAMS)
|
|||
}
|
||||
v = limit<int32_t>(-1024, v, 1024);
|
||||
}
|
||||
#else
|
||||
int16_t v = anas2[ed->chn];
|
||||
#endif
|
||||
if (EXPO_MODE_ENABLE(ed, v)) {
|
||||
#if defined(BOLD_FONT)
|
||||
if (mode==e_perout_mode_normal) swOn[i].activeExpo = true;
|
||||
|
@ -201,7 +187,6 @@ void applyExpos(int16_t * anas, uint8_t mode APPLY_EXPOS_EXTRA_PARAMS)
|
|||
int32_t weight = GET_GVAR_PREC1(ed->weight, MIN_EXPO_WEIGHT, 100, mixerCurrentFlightMode);
|
||||
v = div_and_round((int32_t)v * weight, 1000);
|
||||
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
//========== OFFSET ===============
|
||||
int32_t offset = GET_GVAR_PREC1(ed->offset, -100, 100, mixerCurrentFlightMode);
|
||||
if (offset) v += div_and_round(calc100toRESX(offset), 10);
|
||||
|
@ -213,8 +198,6 @@ void applyExpos(int16_t * anas, uint8_t mode APPLY_EXPOS_EXTRA_PARAMS)
|
|||
virtualInputsTrims[cur_chn] = ed->srcRaw - MIXSRC_Rud;
|
||||
else
|
||||
virtualInputsTrims[cur_chn] = -1;
|
||||
#endif
|
||||
|
||||
anas[cur_chn] = v;
|
||||
}
|
||||
}
|
||||
|
@ -317,13 +300,9 @@ getvalue_t getValue(mixsrc_t i)
|
|||
if (i == MIXSRC_NONE) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
else if (i <= MIXSRC_LAST_INPUT) {
|
||||
return anas[i-MIXSRC_FIRST_INPUT];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(LUA_INPUTS)
|
||||
else if (i < MIXSRC_LAST_LUA) {
|
||||
#if defined(LUA_MODEL_SCRIPTS)
|
||||
|
@ -445,18 +424,6 @@ void evalInputs(uint8_t mode)
|
|||
{
|
||||
BeepANACenter anaCenter = 0;
|
||||
|
||||
#if defined(HELI) && !defined(VIRTUAL_INPUTS)
|
||||
uint16_t d = 0;
|
||||
if (g_model.swashR.value) {
|
||||
uint32_t v = (int32_t(calibratedAnalogs[ELE_STICK])*calibratedAnalogs[ELE_STICK] + int32_t(calibratedAnalogs[AIL_STICK])*calibratedAnalogs[AIL_STICK]);
|
||||
uint32_t q = calc100toRESX(g_model.swashR.value);
|
||||
q *= q;
|
||||
if (v > q) {
|
||||
d = isqrt32(v);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS; i++) {
|
||||
// normalization [0..2048] -> [-1024..1024]
|
||||
uint8_t ch = (i < NUM_STICKS ? CONVERT_MODE(i) : i);
|
||||
|
@ -498,11 +465,9 @@ void evalInputs(uint8_t mode)
|
|||
}
|
||||
|
||||
if (ch < NUM_STICKS) { // only do this for sticks
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
if (mode & e_perout_mode_nosticks) {
|
||||
v = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mode <= e_perout_mode_inactive_flight_mode && isFunctionActive(FUNCTION_TRAINER+ch) && IS_TRAINER_INPUT_VALID()) {
|
||||
// trainer mode
|
||||
|
@ -524,18 +489,7 @@ void evalInputs(uint8_t mode)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
calibratedAnalogs[ch] = v;
|
||||
#else
|
||||
#if defined(HELI)
|
||||
if (d && (ch==ELE_STICK || ch==AIL_STICK)) {
|
||||
v = (int32_t(v) * calc100toRESX(g_model.swashR.value)) / int32_t(d);
|
||||
}
|
||||
#endif
|
||||
rawAnas[ch] = v;
|
||||
anas[ch] = v; // set values for mixer
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -571,7 +525,6 @@ void evalInputs(uint8_t mode)
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
int getStickTrimValue(int stick, int stickValue)
|
||||
{
|
||||
if (stick < 0)
|
||||
|
@ -599,7 +552,6 @@ int getSourceTrimValue(int source, int stickValue=0)
|
|||
else
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8_t mixerCurrentFlightMode;
|
||||
void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
|
||||
|
@ -613,13 +565,8 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
|
|||
#endif
|
||||
|
||||
#if defined(HELI)
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
int heliEleValue = getValue(g_model.swashR.elevatorSource);
|
||||
int heliAilValue = getValue(g_model.swashR.aileronSource);
|
||||
#else
|
||||
int16_t heliEleValue = anas[ELE_STICK];
|
||||
int16_t heliAilValue = anas[AIL_STICK];
|
||||
#endif
|
||||
if (g_model.swashR.value) {
|
||||
uint32_t v = ((int32_t)heliEleValue*heliEleValue + (int32_t)heliAilValue*heliAilValue);
|
||||
uint32_t q = calc100toRESX(g_model.swashR.value);
|
||||
|
@ -636,26 +583,15 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
|
|||
#define REZ_SWASH_Y(x) ((x)) // 1024 => 1024
|
||||
|
||||
if (g_model.swashR.type) {
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
getvalue_t vp = heliEleValue + getSourceTrimValue(g_model.swashR.elevatorSource);
|
||||
getvalue_t vr = heliAilValue + getSourceTrimValue(g_model.swashR.aileronSource);
|
||||
#else
|
||||
getvalue_t vp = heliEleValue + trims[ELE_STICK];
|
||||
getvalue_t vr = heliAilValue + trims[AIL_STICK];
|
||||
#endif
|
||||
getvalue_t vc = 0;
|
||||
if (g_model.swashR.collectiveSource)
|
||||
vc = getValue(g_model.swashR.collectiveSource);
|
||||
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
vp = (vp * g_model.swashR.elevatorWeight) / 100;
|
||||
vr = (vr * g_model.swashR.aileronWeight) / 100;
|
||||
vc = (vc * g_model.swashR.collectiveWeight) / 100;
|
||||
#else
|
||||
if (g_model.swashR.invertELE) vp = -vp;
|
||||
if (g_model.swashR.invertAIL) vr = -vr;
|
||||
if (g_model.swashR.invertCOL) vc = -vc;
|
||||
#endif
|
||||
|
||||
switch (g_model.swashR.type) {
|
||||
case SWASH_TYPE_120:
|
||||
|
@ -747,30 +683,14 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
|
|||
//========== VALUE ===============
|
||||
getvalue_t v = 0;
|
||||
if (mode > e_perout_mode_inactive_flight_mode) {
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
if (!mixEnabled) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
v = getValue(md->srcRaw);
|
||||
}
|
||||
#else
|
||||
if (!mixEnabled || stickIndex >= NUM_STICKS || (stickIndex == THR_STICK && g_model.thrTrim)) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
if (!(mode & e_perout_mode_nosticks)) v = anas[stickIndex];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
#if !defined(VIRTUAL_INPUTS)
|
||||
if (stickIndex < NUM_STICKS) {
|
||||
v = md->noExpo ? rawAnas[stickIndex] : anas[stickIndex];
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
mixsrc_t srcRaw = MIXSRC_Rud + stickIndex;
|
||||
v = getValue(srcRaw);
|
||||
srcRaw -= MIXSRC_CH1;
|
||||
|
@ -780,7 +700,6 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
|
|||
if (srcRaw < md->destCh || pass > 0)
|
||||
v = chans[srcRaw] >> 8;
|
||||
}
|
||||
}
|
||||
if (!mixCondition) {
|
||||
mixEnabled = v >> DELAY_POS_SHIFT;
|
||||
}
|
||||
|
@ -833,26 +752,9 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
|
|||
|
||||
//========== TRIMS ================
|
||||
if (!(mode & e_perout_mode_notrims)) {
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
if (md->carryTrim == 0) {
|
||||
v += getSourceTrimValue(md->srcRaw, v);
|
||||
}
|
||||
#else
|
||||
int8_t mix_trim = md->carryTrim;
|
||||
if (mix_trim < TRIM_ON)
|
||||
mix_trim = -mix_trim - 1;
|
||||
else if (mix_trim == TRIM_ON && stickIndex < NUM_STICKS)
|
||||
mix_trim = stickIndex;
|
||||
else
|
||||
mix_trim = -1;
|
||||
if (mix_trim >= 0) {
|
||||
int16_t trim = trims[mix_trim];
|
||||
if (mix_trim == THR_STICK && g_model.throttleReversed)
|
||||
v -= trim;
|
||||
else
|
||||
v += trim;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -312,7 +312,6 @@ uint16_t evalChkSum()
|
|||
return sum;
|
||||
}
|
||||
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
void clearInputs()
|
||||
{
|
||||
memset(g_model.expoData, 0, sizeof(g_model.expoData)); // clear all expos
|
||||
|
@ -345,25 +344,16 @@ void defaultInputs()
|
|||
}
|
||||
storageDirty(EE_MODEL);
|
||||
}
|
||||
#endif
|
||||
|
||||
void applyDefaultTemplate()
|
||||
{
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
defaultInputs(); // calls storageDirty internally
|
||||
#else
|
||||
storageDirty(EE_MODEL);
|
||||
#endif
|
||||
|
||||
for (int i=0; i<NUM_STICKS; i++) {
|
||||
MixData * mix = mixAddress(i);
|
||||
mix->destCh = i;
|
||||
mix->weight = 100;
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
mix->srcRaw = i+1;
|
||||
#else
|
||||
mix->srcRaw = MIXSRC_Rud - 1 + channel_order(i+1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -519,7 +509,6 @@ void modelDefault(uint8_t id)
|
|||
#endif
|
||||
}
|
||||
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
bool isInputRecursive(int index)
|
||||
{
|
||||
ExpoData * line = expoAddress(0);
|
||||
|
@ -533,7 +522,6 @@ bool isInputRecursive(int index)
|
|||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(AUTOSOURCE)
|
||||
int8_t getMovedSource(GET_MOVED_SOURCE_PARAMS)
|
||||
|
@ -541,7 +529,6 @@ int8_t getMovedSource(GET_MOVED_SOURCE_PARAMS)
|
|||
int8_t result = 0;
|
||||
static tmr10ms_t s_move_last_time = 0;
|
||||
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
static int16_t inputsStates[MAX_INPUTS];
|
||||
if (min <= MIXSRC_FIRST_INPUT) {
|
||||
for (uint8_t i=0; i<MAX_INPUTS; i++) {
|
||||
|
@ -553,7 +540,6 @@ int8_t getMovedSource(GET_MOVED_SOURCE_PARAMS)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static int16_t sourcesStates[NUM_STICKS+NUM_POTS+NUM_SLIDERS+NUM_MOUSE_ANALOGS];
|
||||
if (result == 0) {
|
||||
|
@ -571,9 +557,7 @@ int8_t getMovedSource(GET_MOVED_SOURCE_PARAMS)
|
|||
}
|
||||
|
||||
if (result || recent) {
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
memcpy(inputsStates, anas, sizeof(inputsStates));
|
||||
#endif
|
||||
memcpy(sourcesStates, calibratedAnalogs, sizeof(sourcesStates));
|
||||
}
|
||||
|
||||
|
@ -994,11 +978,6 @@ void checkTHR()
|
|||
}
|
||||
else {
|
||||
calibratedAnalogs[thrchn] = -1024;
|
||||
#if !defined(VIRTUAL_INPUTS)
|
||||
if (thrchn < NUM_STICKS) {
|
||||
rawAnas[thrchn] = anas[thrchn] = calibratedAnalogs[thrchn];
|
||||
}
|
||||
#endif
|
||||
RAISE_ALERT(STR_THROTTLEWARN, STR_THROTTLENOTIDLE, STR_PRESSANYKEYTOSKIP, AU_THROTTLE_ALERT);
|
||||
}
|
||||
#else
|
||||
|
@ -1257,7 +1236,6 @@ JitterMeter<uint16_t> avgJitter[NUM_ANALOGS];
|
|||
tmr10ms_t jitterResetTime = 0;
|
||||
#endif
|
||||
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
#define JITTER_FILTER_STRENGTH 4 // tune this value, bigger value - more filtering (range: 1-5) (see explanation below)
|
||||
#define ANALOG_SCALE 1 // tune this value, bigger value - more filtering (range: 0-1) (see explanation below)
|
||||
|
||||
|
@ -1267,36 +1245,11 @@ tmr10ms_t jitterResetTime = 0;
|
|||
#if (JITTER_ALPHA * ANALOG_MULTIPLIER > 32)
|
||||
#error "JITTER_FILTER_STRENGTH and ANALOG_SCALE are too big, their summ should be <= 5 !!!"
|
||||
#endif
|
||||
#else
|
||||
#define ANALOG_SCALE 0
|
||||
#define JITTER_ALPHA 1
|
||||
#define ANALOG_MULTIPLIER 1
|
||||
#define ANA_FILT(chan) (s_anaFilt[chan])
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(SIMU)
|
||||
uint16_t anaIn(uint8_t chan)
|
||||
{
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
return ANA_FILT(chan);
|
||||
#else
|
||||
#if defined(TELEMETRY_MOD_14051) || defined(TELEMETRY_MOD_14051_SWAPPED)
|
||||
static const pm_char crossAna[] PROGMEM = {3,1,2,0,4,5,6,0/* shouldn't be used */,TX_VOLTAGE};
|
||||
#else
|
||||
static const pm_char crossAna[] PROGMEM = {3,1,2,0,4,5,6,7};
|
||||
#endif
|
||||
#if defined(FRSKY_STICKS)
|
||||
volatile uint16_t temp = s_anaFilt[pgm_read_byte(crossAna+chan)]; // volatile saves here 40 bytes; maybe removed for newer AVR when available
|
||||
if (chan < NUM_STICKS && (g_eeGeneral.stickReverse & (1 << chan))) {
|
||||
temp = 2048 - temp;
|
||||
}
|
||||
return temp;
|
||||
#else
|
||||
volatile uint16_t *p = &s_anaFilt[pgm_read_byte(crossAna+chan)];
|
||||
return *p;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void getADC()
|
||||
|
@ -1319,7 +1272,6 @@ void getADC()
|
|||
for (uint8_t x=0; x<NUM_ANALOGS; x++) {
|
||||
uint16_t v = getAnalogValue(x) >> (1 - ANALOG_SCALE);
|
||||
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
// Jitter filter:
|
||||
// * pass trough any big change directly
|
||||
// * for small change use Modified moving average (MMA) filter
|
||||
|
@ -1360,9 +1312,7 @@ void getADC()
|
|||
// apply jitter filter
|
||||
s_anaFilt[x] = (s_anaFilt[x] - previous) + v;
|
||||
}
|
||||
else
|
||||
#endif // #if defined(VIRTUAL_INPUTS)
|
||||
{
|
||||
else {
|
||||
// use unfiltered value
|
||||
s_anaFilt[x] = v * JITTER_ALPHA;
|
||||
}
|
||||
|
@ -1551,11 +1501,7 @@ void doMixerCalculations()
|
|||
if (val<0) val=0; // prevent val be negative, which would corrupt throttle trace and timers; could occur if safetyswitch is smaller than limits
|
||||
}
|
||||
else {
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
val = RESX + calibratedAnalogs[g_model.thrTraceSrc == 0 ? THR_STICK : g_model.thrTraceSrc+NUM_STICKS-1];
|
||||
#else
|
||||
val = RESX + (g_model.thrTraceSrc == 0 ? rawAnas[THR_STICK] : calibratedAnalogs[g_model.thrTraceSrc+NUM_STICKS-1]);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(ACCURAT_THROTTLE_TIMER)
|
||||
|
@ -1885,11 +1831,9 @@ uint8_t getSticksNavigationEvent()
|
|||
|
||||
void instantTrim()
|
||||
{
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
int16_t anas_0[NUM_INPUTS];
|
||||
evalInputs(e_perout_mode_notrainer | e_perout_mode_nosticks);
|
||||
memcpy(anas_0, anas, sizeof(anas_0));
|
||||
#endif
|
||||
|
||||
evalInputs(e_perout_mode_notrainer);
|
||||
|
||||
|
@ -1897,7 +1841,6 @@ void instantTrim()
|
|||
if (stick!=THR_STICK) {
|
||||
// don't instant trim the throttle stick
|
||||
uint8_t trim_phase = getTrimFlightMode(mixerCurrentFlightMode, stick);
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
int16_t delta = 0;
|
||||
for (int e=0; e<MAX_EXPOS; e++) {
|
||||
ExpoData * ed = expoAddress(e);
|
||||
|
@ -1907,9 +1850,6 @@ void instantTrim()
|
|||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
int16_t delta = anas[stick];
|
||||
#endif
|
||||
if (abs(delta) >= INSTANT_TRIM_MARGIN) {
|
||||
int16_t trim = limit<int16_t>(TRIM_EXTENDED_MIN, (delta + trims[stick]) / 2, TRIM_EXTENDED_MAX);
|
||||
setTrimValue(trim_phase, stick, trim);
|
||||
|
|
|
@ -292,11 +292,7 @@ void memswap(void * a, void * b, uint8_t size);
|
|||
#define IS_MULTIPOS_CALIBRATED(cal) (false)
|
||||
#endif
|
||||
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
#define IS_THROTTLE_TRIM(x) (x == virtualInputsTrims[THR_STICK])
|
||||
#else
|
||||
#define IS_THROTTLE_TRIM(x) (x == THR_STICK)
|
||||
#endif
|
||||
|
||||
#if defined(PWR_BUTTON_PRESS)
|
||||
#define pwrOffPressed() pwrPressed()
|
||||
|
|
|
@ -77,7 +77,7 @@ if(MULTIMODULE)
|
|||
add_definitions(-DMULTIMODULE)
|
||||
set(SRC ${SRC} pulses/multi_arm.cpp telemetry/spektrum.cpp telemetry/flysky_ibus.cpp telemetry/multi.cpp)
|
||||
endif()
|
||||
add_definitions(-DCPUARM -DVIRTUAL_INPUTS)
|
||||
add_definitions(-DCPUARM)
|
||||
add_definitions(-DTELEMETRY_FRSKY -DTELEMETRY_FRSKY_SPORT -DFRSKY_HUB -DGPS -DPXX -DDSM2)
|
||||
add_definitions(-DBOLD_FONT -DBATTGRAPH -DTHRTRACE -DGAUGES)
|
||||
add_definitions(-DREQUIRED_SDCARD_VERSION="${SDCARD_VERSION}")
|
||||
|
|
|
@ -159,7 +159,7 @@ set(STM32LIB_SRC
|
|||
if(PYTHONINTERP_FOUND)
|
||||
add_custom_target(datacopy
|
||||
WORKING_DIRECTORY ${RADIO_DIRECTORY}/src
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${RADIO_DIRECTORY}/util/generate_datacopy.py datastructs.h -DPCBHORUS -DPCBX10 -DCPUARM -DCOLORLCD -DBACKUP -DVIRTUAL_INPUTS -Itargets/horus > storage/datacopy.cpp
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${RADIO_DIRECTORY}/util/generate_datacopy.py datastructs.h -DPCBHORUS -DPCBX10 -DCPUARM -DCOLORLCD -DBACKUP -Itargets/horus > storage/datacopy.cpp
|
||||
DEPENDS ${RADIO_DIRECTORY}/src/datastructs.h ${RADIO_DIRECTORY}/util/generate_datacopy.py
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -168,14 +168,8 @@ TEST_F(TrimsTest, invertedThrottlePlusThrottleTrim)
|
|||
TEST_F(TrimsTest, throttleTrimWithZeroWeightOnThrottle)
|
||||
{
|
||||
g_model.thrTrim = 1;
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
// the input already exists
|
||||
ExpoData *expo = expoAddress(THR_STICK);
|
||||
#else
|
||||
ExpoData *expo = expoAddress(0);
|
||||
expo->mode = 3;
|
||||
expo->chn = THR_STICK;
|
||||
#endif
|
||||
expo->weight = 0;
|
||||
// stick max + trim max
|
||||
anaInValues[THR_STICK] = +1024;
|
||||
|
@ -245,14 +239,8 @@ TEST_F(TrimsTest, invertedThrottlePlusthrottleTrimWithZeroWeightOnThrottle)
|
|||
{
|
||||
g_model.throttleReversed = 1;
|
||||
g_model.thrTrim = 1;
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
// the input already exists
|
||||
ExpoData *expo = expoAddress(THR_STICK);
|
||||
#else
|
||||
ExpoData *expo = expoAddress(0);
|
||||
expo->mode = 3;
|
||||
expo->chn = THR_STICK;
|
||||
#endif
|
||||
expo->weight = 0;
|
||||
// stick max + trim max
|
||||
anaInValues[THR_STICK] = +1024;
|
||||
|
@ -318,32 +306,6 @@ TEST_F(TrimsTest, invertedThrottlePlusthrottleTrimWithZeroWeightOnThrottle)
|
|||
EXPECT_EQ(channelOutputs[2], 0);
|
||||
}
|
||||
|
||||
#if !defined(VIRTUAL_INPUTS)
|
||||
TEST_F(TrimsTest, greaterTrimLink)
|
||||
{
|
||||
setTrimValue(1, RUD_STICK, TRIM_EXTENDED_MAX+3); // link to FP3 trim
|
||||
setTrimValue(3, RUD_STICK, 32);
|
||||
EXPECT_EQ(getRawTrimValue(getTrimFlightMode(1, RUD_STICK), RUD_STICK), 32);
|
||||
}
|
||||
|
||||
TEST_F(TrimsTest, chainedTrims)
|
||||
{
|
||||
setTrimValue(0, RUD_STICK, 32);
|
||||
setTrimValue(1, RUD_STICK, TRIM_EXTENDED_MAX+1); // link to FP0 trim
|
||||
setTrimValue(2, RUD_STICK, TRIM_EXTENDED_MAX+2); // link to FP1 trim
|
||||
EXPECT_EQ(getRawTrimValue(getTrimFlightMode(0, RUD_STICK), RUD_STICK), 32);
|
||||
}
|
||||
|
||||
TEST_F(TrimsTest, infiniteChainedTrims)
|
||||
{
|
||||
setTrimValue(0, RUD_STICK, 32);
|
||||
setTrimValue(1, RUD_STICK, TRIM_EXTENDED_MAX+3); // link to FP3 trim
|
||||
setTrimValue(2, RUD_STICK, TRIM_EXTENDED_MAX+2); // link to FP1 trim
|
||||
setTrimValue(3, RUD_STICK, TRIM_EXTENDED_MAX+3); // link to FP2 trim
|
||||
EXPECT_EQ(getRawTrimValue(getTrimFlightMode(0, RUD_STICK), RUD_STICK), 32);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST_F(TrimsTest, CopyTrimsToOffset)
|
||||
{
|
||||
setTrimValue(0, ELE_STICK, -100); // -100 on elevator
|
||||
|
@ -368,7 +330,6 @@ TEST_F(TrimsTest, InstantTrim)
|
|||
EXPECT_EQ(25, getTrimValue(0, AIL_STICK));
|
||||
}
|
||||
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
TEST_F(TrimsTest, InstantTrimNegativeCurve)
|
||||
{
|
||||
ExpoData *expo = expoAddress(AIL_STICK);
|
||||
|
@ -383,7 +344,6 @@ TEST_F(TrimsTest, InstantTrimNegativeCurve)
|
|||
instantTrim();
|
||||
EXPECT_EQ(128, getTrimValue(0, AIL_STICK));
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(Curves, LinearIntpol)
|
||||
{
|
||||
|
@ -567,30 +527,6 @@ TEST_F(MixerTest, DelayOnSwitch)
|
|||
EXPECT_EQ(chans[0], 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if !defined(VIRTUAL_INPUTS)
|
||||
TEST_F(MixerTest, NoTrimOnInactiveMix)
|
||||
{
|
||||
g_model.mixData[0].destCh = 0;
|
||||
g_model.mixData[0].mltpx = MLTPX_ADD;
|
||||
g_model.mixData[0].srcRaw = MIXSRC_Thr;
|
||||
g_model.mixData[0].weight = 100;
|
||||
g_model.mixData[0].swtch = SWSRC_THR;
|
||||
g_model.mixData[0].speedUp = SLOW_STEP*5;
|
||||
g_model.mixData[0].speedDown = SLOW_STEP*5;
|
||||
setTrimValue(0, 2, 256);
|
||||
|
||||
s_mixer_first_run_done = true;
|
||||
|
||||
simuSetSwitch(1, 1);
|
||||
CHECK_SLOW_MOVEMENT(0, 1, 100);
|
||||
|
||||
simuSetSwitch(1, -1);
|
||||
CHECK_SLOW_MOVEMENT(0, -1, 100);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST_F(MixerTest, SlowOnMultiply)
|
||||
{
|
||||
g_model.mixData[0].destCh = 0;
|
||||
|
@ -618,7 +554,7 @@ TEST_F(MixerTest, SlowOnMultiply)
|
|||
}
|
||||
|
||||
|
||||
#if defined(HELI) && defined(VIRTUAL_INPUTS)
|
||||
#if defined(HELI)
|
||||
TEST(Heli, BasicTest)
|
||||
{
|
||||
SYSTEM_RESET();
|
||||
|
@ -687,22 +623,6 @@ TEST(Heli, Mode2Test)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(HELI) && !defined(VIRTUAL_INPUTS)
|
||||
TEST(Heli, SimpleTest)
|
||||
{
|
||||
SYSTEM_RESET();
|
||||
MODEL_RESET();
|
||||
MIXER_RESET();
|
||||
modelDefault(0);
|
||||
applyTemplate(TMPL_HELI_SETUP);
|
||||
anaInValues[ELE_STICK] = 1024;
|
||||
evalFlightModeMixes(e_perout_mode_normal, 0);
|
||||
EXPECT_EQ(chans[0], -CHANNEL_MAX);
|
||||
EXPECT_EQ(chans[1], CHANNEL_MAX/2);
|
||||
EXPECT_EQ(chans[1], CHANNEL_MAX/2);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(Trainer, UnpluggedTest)
|
||||
{
|
||||
SYSTEM_RESET();
|
||||
|
|
|
@ -20,17 +20,6 @@
|
|||
|
||||
#include "gtests.h"
|
||||
|
||||
#if !defined(VIRTUAL_INPUTS)
|
||||
TEST(getSwitch, undefCSW)
|
||||
{
|
||||
MODEL_RESET();
|
||||
EXPECT_EQ(getSwitch(NUM_PSWITCH), false);
|
||||
EXPECT_EQ(getSwitch(-NUM_PSWITCH), true); // no good answer there!
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(VIRTUAL_INPUTS)
|
||||
void setLogicalSwitch(int index, uint16_t _func, int16_t _v1, int16_t _v2, int16_t _v3 = 0, uint8_t _delay = 0, uint8_t _duration = 0, int8_t _andsw = 0)
|
||||
{
|
||||
g_model.logicalSw[index].func = _func;
|
||||
|
@ -41,7 +30,6 @@ void setLogicalSwitch(int index, uint16_t _func, int16_t _v1, int16_t _v2, int16
|
|||
g_model.logicalSw[index].duration = _duration;
|
||||
g_model.logicalSw[index].andsw = _andsw;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
TEST(getSwitch, OldTypeStickyCSW)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue