mirror of
https://github.com/opentx/opentx.git
synced 2025-07-26 01:35:21 +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 {
|
enum MixSources {
|
||||||
MIXSRC_NONE,
|
MIXSRC_NONE,
|
||||||
|
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
MIXSRC_FIRST_INPUT, LUA_EXPORT_MULTIPLE("input", "Input [I%d]", MAX_INPUTS)
|
MIXSRC_FIRST_INPUT, LUA_EXPORT_MULTIPLE("input", "Input [I%d]", MAX_INPUTS)
|
||||||
MIXSRC_LAST_INPUT = MIXSRC_FIRST_INPUT+MAX_INPUTS-1,
|
MIXSRC_LAST_INPUT = MIXSRC_FIRST_INPUT+MAX_INPUTS-1,
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(LUA_INPUTS)
|
#if defined(LUA_INPUTS)
|
||||||
MIXSRC_FIRST_LUA,
|
MIXSRC_FIRST_LUA,
|
||||||
|
|
|
@ -247,7 +247,6 @@ PACK(struct TimerData {
|
||||||
* Swash Ring structure
|
* Swash Ring structure
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
PACK(struct SwashRingData {
|
PACK(struct SwashRingData {
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
uint8_t value;
|
uint8_t value;
|
||||||
|
@ -258,16 +257,6 @@ PACK(struct SwashRingData {
|
||||||
int8_t aileronWeight;
|
int8_t aileronWeight;
|
||||||
int8_t elevatorWeight;
|
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
|
#if MAX_SCRIPTS > 0
|
||||||
union ScriptDataInput {
|
union ScriptDataInput {
|
||||||
|
|
|
@ -341,16 +341,14 @@ void drawStatusLine();
|
||||||
#define EDIT_MODE_INIT -1
|
#define EDIT_MODE_INIT -1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern uint8_t editNameCursorPos;
|
extern uint8_t editNameCursorPos;
|
||||||
|
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
uint8_t getExposCount();
|
uint8_t getExposCount();
|
||||||
void insertExpo(uint8_t idx);
|
void insertExpo(uint8_t idx);
|
||||||
void deleteExpo(uint8_t idx);
|
void deleteExpo(uint8_t idx);
|
||||||
uint8_t getMixesCount();
|
uint8_t getMixesCount();
|
||||||
void insertMix(uint8_t idx);
|
void insertMix(uint8_t idx);
|
||||||
void deleteMix(uint8_t idx);
|
void deleteMix(uint8_t idx);
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef int (*FnFuncP) (int x);
|
typedef int (*FnFuncP) (int x);
|
||||||
void drawFunction(FnFuncP fn, uint8_t offset=0);
|
void drawFunction(FnFuncP fn, uint8_t offset=0);
|
||||||
|
|
|
@ -23,19 +23,12 @@
|
||||||
enum MenuModelHeliItems {
|
enum MenuModelHeliItems {
|
||||||
ITEM_HELI_SWASHTYPE,
|
ITEM_HELI_SWASHTYPE,
|
||||||
ITEM_HELI_SWASHRING,
|
ITEM_HELI_SWASHRING,
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
ITEM_HELI_ELE,
|
ITEM_HELI_ELE,
|
||||||
ITEM_HELI_ELE_WEIGHT,
|
ITEM_HELI_ELE_WEIGHT,
|
||||||
ITEM_HELI_AIL,
|
ITEM_HELI_AIL,
|
||||||
ITEM_HELI_AIL_WEIGHT,
|
ITEM_HELI_AIL_WEIGHT,
|
||||||
ITEM_HELI_COL,
|
ITEM_HELI_COL,
|
||||||
ITEM_HELI_COL_WEIGHT,
|
ITEM_HELI_COL_WEIGHT,
|
||||||
#else
|
|
||||||
ITEM_HELI_COLLECTIVE,
|
|
||||||
ITEM_HELI_ELEDIRECTION,
|
|
||||||
ITEM_HELI_AILDIRECTION,
|
|
||||||
ITEM_HELI_COLDIRECTION,
|
|
||||||
#endif
|
|
||||||
ITEM_HELI_MAX
|
ITEM_HELI_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -51,14 +44,9 @@ void menuModelHeli(event_t event)
|
||||||
|
|
||||||
uint8_t sub = menuVerticalPosition - HEADER_LINE;
|
uint8_t sub = menuVerticalPosition - HEADER_LINE;
|
||||||
|
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
for (uint8_t i=0; i<NUM_BODY_LINES; i++) {
|
for (uint8_t i=0; i<NUM_BODY_LINES; i++) {
|
||||||
coord_t y = MENU_HEADER_HEIGHT + 1 + i*FH;
|
coord_t y = MENU_HEADER_HEIGHT + 1 + i*FH;
|
||||||
uint8_t k = i + menuVerticalOffset;
|
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 blink = (s_editMode > 0 ? BLINK|INVERS : INVERS);
|
||||||
LcdFlags attr = (sub == k ? blink : 0);
|
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);
|
if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, g_model.swashR.value, 100);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
case ITEM_HELI_ELE:
|
case ITEM_HELI_ELE:
|
||||||
lcdDrawTextAlignedLeft(y, STR_ELEVATOR);
|
lcdDrawTextAlignedLeft(y, STR_ELEVATOR);
|
||||||
drawSource(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.elevatorSource, attr);
|
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);
|
lcdDrawNumber(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.collectiveWeight, LEFT|attr);
|
||||||
if (attr) CHECK_INCDEC_MODELVAR(event, g_model.swashR.collectiveWeight, -100, 100);
|
if (attr) CHECK_INCDEC_MODELVAR(event, g_model.swashR.collectiveWeight, -100, 100);
|
||||||
break;
|
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)
|
endmacro(add_lua_export_target)
|
||||||
|
|
||||||
set(LUA_INCLUDES
|
set(LUA_INCLUDES
|
||||||
-DCPUARM -DLUA -DVIRTUAL_INPUTS -DLUA_INPUTS
|
-DCPUARM -DLUA -DLUA_INPUTS
|
||||||
-I${RADIO_SRC_DIRECTORY}/targets/${TARGET_DIR}
|
-I${RADIO_SRC_DIRECTORY}/targets/${TARGET_DIR}
|
||||||
-I${RADIO_SRC_DIRECTORY}/thirdparty
|
-I${RADIO_SRC_DIRECTORY}/thirdparty
|
||||||
-I${RADIO_SRC_DIRECTORY}/targets/common/arm/stm32
|
-I${RADIO_SRC_DIRECTORY}/targets/common/arm/stm32
|
||||||
|
|
|
@ -21,15 +21,10 @@
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
#include "timers.h"
|
#include "timers.h"
|
||||||
|
|
||||||
#if defined(VIRTUAL_INPUTS)
|
int8_t virtualInputsTrims[NUM_INPUTS];
|
||||||
int8_t virtualInputsTrims[NUM_INPUTS];
|
int16_t anas [NUM_INPUTS] = {0};
|
||||||
#else
|
int16_t trims[NUM_TRIMS] = {0};
|
||||||
int16_t rawAnas[NUM_INPUTS] = {0};
|
int32_t chans[MAX_OUTPUT_CHANNELS] = {0};
|
||||||
#endif
|
|
||||||
|
|
||||||
int16_t anas [NUM_INPUTS] = {0};
|
|
||||||
int16_t trims[NUM_TRIMS] = {0};
|
|
||||||
int32_t chans[MAX_OUTPUT_CHANNELS] = {0};
|
|
||||||
BeepANACenter bpanaCenter = 0;
|
BeepANACenter bpanaCenter = 0;
|
||||||
|
|
||||||
int32_t act [MAX_MIXERS] = {0};
|
int32_t act [MAX_MIXERS] = {0};
|
||||||
|
@ -153,11 +148,6 @@ int expo(int x, int k)
|
||||||
|
|
||||||
void applyExpos(int16_t * anas, uint8_t mode APPLY_EXPOS_EXTRA_PARAMS)
|
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;
|
int8_t cur_chn = -1;
|
||||||
|
|
||||||
for (uint8_t i=0; i<MAX_EXPOS; i++) {
|
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))
|
if (ed->flightModes & (1<<mixerCurrentFlightMode))
|
||||||
continue;
|
continue;
|
||||||
if (getSwitch(ed->swtch)) {
|
if (getSwitch(ed->swtch)) {
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
int32_t v;
|
int32_t v;
|
||||||
if (ed->srcRaw == ovwrIdx) {
|
if (ed->srcRaw == ovwrIdx) {
|
||||||
v = ovwrValue;
|
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);
|
v = limit<int32_t>(-1024, v, 1024);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
int16_t v = anas2[ed->chn];
|
|
||||||
#endif
|
|
||||||
if (EXPO_MODE_ENABLE(ed, v)) {
|
if (EXPO_MODE_ENABLE(ed, v)) {
|
||||||
#if defined(BOLD_FONT)
|
#if defined(BOLD_FONT)
|
||||||
if (mode==e_perout_mode_normal) swOn[i].activeExpo = true;
|
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);
|
int32_t weight = GET_GVAR_PREC1(ed->weight, MIN_EXPO_WEIGHT, 100, mixerCurrentFlightMode);
|
||||||
v = div_and_round((int32_t)v * weight, 1000);
|
v = div_and_round((int32_t)v * weight, 1000);
|
||||||
|
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
//========== OFFSET ===============
|
//========== OFFSET ===============
|
||||||
int32_t offset = GET_GVAR_PREC1(ed->offset, -100, 100, mixerCurrentFlightMode);
|
int32_t offset = GET_GVAR_PREC1(ed->offset, -100, 100, mixerCurrentFlightMode);
|
||||||
if (offset) v += div_and_round(calc100toRESX(offset), 10);
|
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;
|
virtualInputsTrims[cur_chn] = ed->srcRaw - MIXSRC_Rud;
|
||||||
else
|
else
|
||||||
virtualInputsTrims[cur_chn] = -1;
|
virtualInputsTrims[cur_chn] = -1;
|
||||||
#endif
|
|
||||||
|
|
||||||
anas[cur_chn] = v;
|
anas[cur_chn] = v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -317,13 +300,9 @@ getvalue_t getValue(mixsrc_t i)
|
||||||
if (i == MIXSRC_NONE) {
|
if (i == MIXSRC_NONE) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
else if (i <= MIXSRC_LAST_INPUT) {
|
else if (i <= MIXSRC_LAST_INPUT) {
|
||||||
return anas[i-MIXSRC_FIRST_INPUT];
|
return anas[i-MIXSRC_FIRST_INPUT];
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(LUA_INPUTS)
|
#if defined(LUA_INPUTS)
|
||||||
else if (i < MIXSRC_LAST_LUA) {
|
else if (i < MIXSRC_LAST_LUA) {
|
||||||
#if defined(LUA_MODEL_SCRIPTS)
|
#if defined(LUA_MODEL_SCRIPTS)
|
||||||
|
@ -445,18 +424,6 @@ void evalInputs(uint8_t mode)
|
||||||
{
|
{
|
||||||
BeepANACenter anaCenter = 0;
|
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++) {
|
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS; i++) {
|
||||||
// normalization [0..2048] -> [-1024..1024]
|
// normalization [0..2048] -> [-1024..1024]
|
||||||
uint8_t ch = (i < NUM_STICKS ? CONVERT_MODE(i) : i);
|
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 (ch < NUM_STICKS) { // only do this for sticks
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
if (mode & e_perout_mode_nosticks) {
|
if (mode & e_perout_mode_nosticks) {
|
||||||
v = 0;
|
v = 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (mode <= e_perout_mode_inactive_flight_mode && isFunctionActive(FUNCTION_TRAINER+ch) && IS_TRAINER_INPUT_VALID()) {
|
if (mode <= e_perout_mode_inactive_flight_mode && isFunctionActive(FUNCTION_TRAINER+ch) && IS_TRAINER_INPUT_VALID()) {
|
||||||
// trainer mode
|
// trainer mode
|
||||||
|
@ -524,18 +489,7 @@ void evalInputs(uint8_t mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
calibratedAnalogs[ch] = v;
|
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)
|
int getStickTrimValue(int stick, int stickValue)
|
||||||
{
|
{
|
||||||
if (stick < 0)
|
if (stick < 0)
|
||||||
|
@ -599,7 +552,6 @@ int getSourceTrimValue(int source, int stickValue=0)
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
uint8_t mixerCurrentFlightMode;
|
uint8_t mixerCurrentFlightMode;
|
||||||
void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
|
void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
|
||||||
|
@ -613,13 +565,8 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HELI)
|
#if defined(HELI)
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
int heliEleValue = getValue(g_model.swashR.elevatorSource);
|
int heliEleValue = getValue(g_model.swashR.elevatorSource);
|
||||||
int heliAilValue = getValue(g_model.swashR.aileronSource);
|
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) {
|
if (g_model.swashR.value) {
|
||||||
uint32_t v = ((int32_t)heliEleValue*heliEleValue + (int32_t)heliAilValue*heliAilValue);
|
uint32_t v = ((int32_t)heliEleValue*heliEleValue + (int32_t)heliAilValue*heliAilValue);
|
||||||
uint32_t q = calc100toRESX(g_model.swashR.value);
|
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
|
#define REZ_SWASH_Y(x) ((x)) // 1024 => 1024
|
||||||
|
|
||||||
if (g_model.swashR.type) {
|
if (g_model.swashR.type) {
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
getvalue_t vp = heliEleValue + getSourceTrimValue(g_model.swashR.elevatorSource);
|
getvalue_t vp = heliEleValue + getSourceTrimValue(g_model.swashR.elevatorSource);
|
||||||
getvalue_t vr = heliAilValue + getSourceTrimValue(g_model.swashR.aileronSource);
|
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;
|
getvalue_t vc = 0;
|
||||||
if (g_model.swashR.collectiveSource)
|
if (g_model.swashR.collectiveSource)
|
||||||
vc = getValue(g_model.swashR.collectiveSource);
|
vc = getValue(g_model.swashR.collectiveSource);
|
||||||
|
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
vp = (vp * g_model.swashR.elevatorWeight) / 100;
|
vp = (vp * g_model.swashR.elevatorWeight) / 100;
|
||||||
vr = (vr * g_model.swashR.aileronWeight) / 100;
|
vr = (vr * g_model.swashR.aileronWeight) / 100;
|
||||||
vc = (vc * g_model.swashR.collectiveWeight) / 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) {
|
switch (g_model.swashR.type) {
|
||||||
case SWASH_TYPE_120:
|
case SWASH_TYPE_120:
|
||||||
|
@ -747,39 +683,22 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
|
||||||
//========== VALUE ===============
|
//========== VALUE ===============
|
||||||
getvalue_t v = 0;
|
getvalue_t v = 0;
|
||||||
if (mode > e_perout_mode_inactive_flight_mode) {
|
if (mode > e_perout_mode_inactive_flight_mode) {
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
if (!mixEnabled) {
|
if (!mixEnabled) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
v = getValue(md->srcRaw);
|
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 {
|
else {
|
||||||
#if !defined(VIRTUAL_INPUTS)
|
mixsrc_t srcRaw = MIXSRC_Rud + stickIndex;
|
||||||
if (stickIndex < NUM_STICKS) {
|
v = getValue(srcRaw);
|
||||||
v = md->noExpo ? rawAnas[stickIndex] : anas[stickIndex];
|
srcRaw -= MIXSRC_CH1;
|
||||||
}
|
if (srcRaw<=MIXSRC_LAST_CH-MIXSRC_CH1 && md->destCh != srcRaw) {
|
||||||
else
|
if (dirtyChannels & ((bitfield_channels_t)1 << srcRaw) & (passDirtyChannels|~(((bitfield_channels_t) 1 << md->destCh)-1)))
|
||||||
#endif
|
passDirtyChannels |= (bitfield_channels_t) 1 << md->destCh;
|
||||||
{
|
if (srcRaw < md->destCh || pass > 0)
|
||||||
mixsrc_t srcRaw = MIXSRC_Rud + stickIndex;
|
v = chans[srcRaw] >> 8;
|
||||||
v = getValue(srcRaw);
|
|
||||||
srcRaw -= MIXSRC_CH1;
|
|
||||||
if (srcRaw<=MIXSRC_LAST_CH-MIXSRC_CH1 && md->destCh != srcRaw) {
|
|
||||||
if (dirtyChannels & ((bitfield_channels_t)1 << srcRaw) & (passDirtyChannels|~(((bitfield_channels_t) 1 << md->destCh)-1)))
|
|
||||||
passDirtyChannels |= (bitfield_channels_t) 1 << md->destCh;
|
|
||||||
if (srcRaw < md->destCh || pass > 0)
|
|
||||||
v = chans[srcRaw] >> 8;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!mixCondition) {
|
if (!mixCondition) {
|
||||||
mixEnabled = v >> DELAY_POS_SHIFT;
|
mixEnabled = v >> DELAY_POS_SHIFT;
|
||||||
|
@ -833,26 +752,9 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
|
||||||
|
|
||||||
//========== TRIMS ================
|
//========== TRIMS ================
|
||||||
if (!(mode & e_perout_mode_notrims)) {
|
if (!(mode & e_perout_mode_notrims)) {
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
if (md->carryTrim == 0) {
|
if (md->carryTrim == 0) {
|
||||||
v += getSourceTrimValue(md->srcRaw, v);
|
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;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
void clearInputs()
|
void clearInputs()
|
||||||
{
|
{
|
||||||
memset(g_model.expoData, 0, sizeof(g_model.expoData)); // clear all expos
|
memset(g_model.expoData, 0, sizeof(g_model.expoData)); // clear all expos
|
||||||
|
@ -345,25 +344,16 @@ void defaultInputs()
|
||||||
}
|
}
|
||||||
storageDirty(EE_MODEL);
|
storageDirty(EE_MODEL);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void applyDefaultTemplate()
|
void applyDefaultTemplate()
|
||||||
{
|
{
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
defaultInputs(); // calls storageDirty internally
|
defaultInputs(); // calls storageDirty internally
|
||||||
#else
|
|
||||||
storageDirty(EE_MODEL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (int i=0; i<NUM_STICKS; i++) {
|
for (int i=0; i<NUM_STICKS; i++) {
|
||||||
MixData * mix = mixAddress(i);
|
MixData * mix = mixAddress(i);
|
||||||
mix->destCh = i;
|
mix->destCh = i;
|
||||||
mix->weight = 100;
|
mix->weight = 100;
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
mix->srcRaw = i+1;
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
bool isInputRecursive(int index)
|
bool isInputRecursive(int index)
|
||||||
{
|
{
|
||||||
ExpoData * line = expoAddress(0);
|
ExpoData * line = expoAddress(0);
|
||||||
|
@ -533,7 +522,6 @@ bool isInputRecursive(int index)
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(AUTOSOURCE)
|
#if defined(AUTOSOURCE)
|
||||||
int8_t getMovedSource(GET_MOVED_SOURCE_PARAMS)
|
int8_t getMovedSource(GET_MOVED_SOURCE_PARAMS)
|
||||||
|
@ -541,7 +529,6 @@ int8_t getMovedSource(GET_MOVED_SOURCE_PARAMS)
|
||||||
int8_t result = 0;
|
int8_t result = 0;
|
||||||
static tmr10ms_t s_move_last_time = 0;
|
static tmr10ms_t s_move_last_time = 0;
|
||||||
|
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
static int16_t inputsStates[MAX_INPUTS];
|
static int16_t inputsStates[MAX_INPUTS];
|
||||||
if (min <= MIXSRC_FIRST_INPUT) {
|
if (min <= MIXSRC_FIRST_INPUT) {
|
||||||
for (uint8_t i=0; i<MAX_INPUTS; i++) {
|
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];
|
static int16_t sourcesStates[NUM_STICKS+NUM_POTS+NUM_SLIDERS+NUM_MOUSE_ANALOGS];
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
|
@ -571,9 +557,7 @@ int8_t getMovedSource(GET_MOVED_SOURCE_PARAMS)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result || recent) {
|
if (result || recent) {
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
memcpy(inputsStates, anas, sizeof(inputsStates));
|
memcpy(inputsStates, anas, sizeof(inputsStates));
|
||||||
#endif
|
|
||||||
memcpy(sourcesStates, calibratedAnalogs, sizeof(sourcesStates));
|
memcpy(sourcesStates, calibratedAnalogs, sizeof(sourcesStates));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -994,11 +978,6 @@ void checkTHR()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
calibratedAnalogs[thrchn] = -1024;
|
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);
|
RAISE_ALERT(STR_THROTTLEWARN, STR_THROTTLENOTIDLE, STR_PRESSANYKEYTOSKIP, AU_THROTTLE_ALERT);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -1257,46 +1236,20 @@ JitterMeter<uint16_t> avgJitter[NUM_ANALOGS];
|
||||||
tmr10ms_t jitterResetTime = 0;
|
tmr10ms_t jitterResetTime = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(VIRTUAL_INPUTS)
|
#define JITTER_FILTER_STRENGTH 4 // tune this value, bigger value - more filtering (range: 1-5) (see explanation below)
|
||||||
#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)
|
||||||
#define ANALOG_SCALE 1 // tune this value, bigger value - more filtering (range: 0-1) (see explanation below)
|
|
||||||
|
|
||||||
#define JITTER_ALPHA (1<<JITTER_FILTER_STRENGTH)
|
#define JITTER_ALPHA (1<<JITTER_FILTER_STRENGTH)
|
||||||
#define ANALOG_MULTIPLIER (1<<ANALOG_SCALE)
|
#define ANALOG_MULTIPLIER (1<<ANALOG_SCALE)
|
||||||
#define ANA_FILT(chan) (s_anaFilt[chan] / (JITTER_ALPHA * ANALOG_MULTIPLIER))
|
#define ANA_FILT(chan) (s_anaFilt[chan] / (JITTER_ALPHA * ANALOG_MULTIPLIER))
|
||||||
#if (JITTER_ALPHA * ANALOG_MULTIPLIER > 32)
|
#if (JITTER_ALPHA * ANALOG_MULTIPLIER > 32)
|
||||||
#error "JITTER_FILTER_STRENGTH and ANALOG_SCALE are too big, their summ should be <= 5 !!!"
|
#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
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if !defined(SIMU)
|
#if !defined(SIMU)
|
||||||
uint16_t anaIn(uint8_t chan)
|
uint16_t anaIn(uint8_t chan)
|
||||||
{
|
{
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
return ANA_FILT(chan);
|
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()
|
void getADC()
|
||||||
|
@ -1319,7 +1272,6 @@ void getADC()
|
||||||
for (uint8_t x=0; x<NUM_ANALOGS; x++) {
|
for (uint8_t x=0; x<NUM_ANALOGS; x++) {
|
||||||
uint16_t v = getAnalogValue(x) >> (1 - ANALOG_SCALE);
|
uint16_t v = getAnalogValue(x) >> (1 - ANALOG_SCALE);
|
||||||
|
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
// Jitter filter:
|
// Jitter filter:
|
||||||
// * pass trough any big change directly
|
// * pass trough any big change directly
|
||||||
// * for small change use Modified moving average (MMA) filter
|
// * for small change use Modified moving average (MMA) filter
|
||||||
|
@ -1360,10 +1312,8 @@ void getADC()
|
||||||
// apply jitter filter
|
// apply jitter filter
|
||||||
s_anaFilt[x] = (s_anaFilt[x] - previous) + v;
|
s_anaFilt[x] = (s_anaFilt[x] - previous) + v;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
#endif // #if defined(VIRTUAL_INPUTS)
|
// use unfiltered value
|
||||||
{
|
|
||||||
//use unfiltered value
|
|
||||||
s_anaFilt[x] = v * JITTER_ALPHA;
|
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
|
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 {
|
else {
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
val = RESX + calibratedAnalogs[g_model.thrTraceSrc == 0 ? THR_STICK : g_model.thrTraceSrc+NUM_STICKS-1];
|
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)
|
#if defined(ACCURAT_THROTTLE_TIMER)
|
||||||
|
@ -1885,11 +1831,9 @@ uint8_t getSticksNavigationEvent()
|
||||||
|
|
||||||
void instantTrim()
|
void instantTrim()
|
||||||
{
|
{
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
int16_t anas_0[NUM_INPUTS];
|
int16_t anas_0[NUM_INPUTS];
|
||||||
evalInputs(e_perout_mode_notrainer | e_perout_mode_nosticks);
|
evalInputs(e_perout_mode_notrainer | e_perout_mode_nosticks);
|
||||||
memcpy(anas_0, anas, sizeof(anas_0));
|
memcpy(anas_0, anas, sizeof(anas_0));
|
||||||
#endif
|
|
||||||
|
|
||||||
evalInputs(e_perout_mode_notrainer);
|
evalInputs(e_perout_mode_notrainer);
|
||||||
|
|
||||||
|
@ -1897,7 +1841,6 @@ void instantTrim()
|
||||||
if (stick!=THR_STICK) {
|
if (stick!=THR_STICK) {
|
||||||
// don't instant trim the throttle stick
|
// don't instant trim the throttle stick
|
||||||
uint8_t trim_phase = getTrimFlightMode(mixerCurrentFlightMode, stick);
|
uint8_t trim_phase = getTrimFlightMode(mixerCurrentFlightMode, stick);
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
int16_t delta = 0;
|
int16_t delta = 0;
|
||||||
for (int e=0; e<MAX_EXPOS; e++) {
|
for (int e=0; e<MAX_EXPOS; e++) {
|
||||||
ExpoData * ed = expoAddress(e);
|
ExpoData * ed = expoAddress(e);
|
||||||
|
@ -1907,9 +1850,6 @@ void instantTrim()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
int16_t delta = anas[stick];
|
|
||||||
#endif
|
|
||||||
if (abs(delta) >= INSTANT_TRIM_MARGIN) {
|
if (abs(delta) >= INSTANT_TRIM_MARGIN) {
|
||||||
int16_t trim = limit<int16_t>(TRIM_EXTENDED_MIN, (delta + trims[stick]) / 2, TRIM_EXTENDED_MAX);
|
int16_t trim = limit<int16_t>(TRIM_EXTENDED_MIN, (delta + trims[stick]) / 2, TRIM_EXTENDED_MAX);
|
||||||
setTrimValue(trim_phase, stick, trim);
|
setTrimValue(trim_phase, stick, trim);
|
||||||
|
|
|
@ -292,11 +292,7 @@ void memswap(void * a, void * b, uint8_t size);
|
||||||
#define IS_MULTIPOS_CALIBRATED(cal) (false)
|
#define IS_MULTIPOS_CALIBRATED(cal) (false)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(VIRTUAL_INPUTS)
|
#define IS_THROTTLE_TRIM(x) (x == virtualInputsTrims[THR_STICK])
|
||||||
#define IS_THROTTLE_TRIM(x) (x == virtualInputsTrims[THR_STICK])
|
|
||||||
#else
|
|
||||||
#define IS_THROTTLE_TRIM(x) (x == THR_STICK)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(PWR_BUTTON_PRESS)
|
#if defined(PWR_BUTTON_PRESS)
|
||||||
#define pwrOffPressed() pwrPressed()
|
#define pwrOffPressed() pwrPressed()
|
||||||
|
|
|
@ -77,7 +77,7 @@ if(MULTIMODULE)
|
||||||
add_definitions(-DMULTIMODULE)
|
add_definitions(-DMULTIMODULE)
|
||||||
set(SRC ${SRC} pulses/multi_arm.cpp telemetry/spektrum.cpp telemetry/flysky_ibus.cpp telemetry/multi.cpp)
|
set(SRC ${SRC} pulses/multi_arm.cpp telemetry/spektrum.cpp telemetry/flysky_ibus.cpp telemetry/multi.cpp)
|
||||||
endif()
|
endif()
|
||||||
add_definitions(-DCPUARM -DVIRTUAL_INPUTS)
|
add_definitions(-DCPUARM)
|
||||||
add_definitions(-DTELEMETRY_FRSKY -DTELEMETRY_FRSKY_SPORT -DFRSKY_HUB -DGPS -DPXX -DDSM2)
|
add_definitions(-DTELEMETRY_FRSKY -DTELEMETRY_FRSKY_SPORT -DFRSKY_HUB -DGPS -DPXX -DDSM2)
|
||||||
add_definitions(-DBOLD_FONT -DBATTGRAPH -DTHRTRACE -DGAUGES)
|
add_definitions(-DBOLD_FONT -DBATTGRAPH -DTHRTRACE -DGAUGES)
|
||||||
add_definitions(-DREQUIRED_SDCARD_VERSION="${SDCARD_VERSION}")
|
add_definitions(-DREQUIRED_SDCARD_VERSION="${SDCARD_VERSION}")
|
||||||
|
|
|
@ -159,7 +159,7 @@ set(STM32LIB_SRC
|
||||||
if(PYTHONINTERP_FOUND)
|
if(PYTHONINTERP_FOUND)
|
||||||
add_custom_target(datacopy
|
add_custom_target(datacopy
|
||||||
WORKING_DIRECTORY ${RADIO_DIRECTORY}/src
|
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
|
DEPENDS ${RADIO_DIRECTORY}/src/datastructs.h ${RADIO_DIRECTORY}/util/generate_datacopy.py
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -168,14 +168,8 @@ TEST_F(TrimsTest, invertedThrottlePlusThrottleTrim)
|
||||||
TEST_F(TrimsTest, throttleTrimWithZeroWeightOnThrottle)
|
TEST_F(TrimsTest, throttleTrimWithZeroWeightOnThrottle)
|
||||||
{
|
{
|
||||||
g_model.thrTrim = 1;
|
g_model.thrTrim = 1;
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
// the input already exists
|
// the input already exists
|
||||||
ExpoData *expo = expoAddress(THR_STICK);
|
ExpoData *expo = expoAddress(THR_STICK);
|
||||||
#else
|
|
||||||
ExpoData *expo = expoAddress(0);
|
|
||||||
expo->mode = 3;
|
|
||||||
expo->chn = THR_STICK;
|
|
||||||
#endif
|
|
||||||
expo->weight = 0;
|
expo->weight = 0;
|
||||||
// stick max + trim max
|
// stick max + trim max
|
||||||
anaInValues[THR_STICK] = +1024;
|
anaInValues[THR_STICK] = +1024;
|
||||||
|
@ -245,14 +239,8 @@ TEST_F(TrimsTest, invertedThrottlePlusthrottleTrimWithZeroWeightOnThrottle)
|
||||||
{
|
{
|
||||||
g_model.throttleReversed = 1;
|
g_model.throttleReversed = 1;
|
||||||
g_model.thrTrim = 1;
|
g_model.thrTrim = 1;
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
// the input already exists
|
// the input already exists
|
||||||
ExpoData *expo = expoAddress(THR_STICK);
|
ExpoData *expo = expoAddress(THR_STICK);
|
||||||
#else
|
|
||||||
ExpoData *expo = expoAddress(0);
|
|
||||||
expo->mode = 3;
|
|
||||||
expo->chn = THR_STICK;
|
|
||||||
#endif
|
|
||||||
expo->weight = 0;
|
expo->weight = 0;
|
||||||
// stick max + trim max
|
// stick max + trim max
|
||||||
anaInValues[THR_STICK] = +1024;
|
anaInValues[THR_STICK] = +1024;
|
||||||
|
@ -318,32 +306,6 @@ TEST_F(TrimsTest, invertedThrottlePlusthrottleTrimWithZeroWeightOnThrottle)
|
||||||
EXPECT_EQ(channelOutputs[2], 0);
|
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)
|
TEST_F(TrimsTest, CopyTrimsToOffset)
|
||||||
{
|
{
|
||||||
setTrimValue(0, ELE_STICK, -100); // -100 on elevator
|
setTrimValue(0, ELE_STICK, -100); // -100 on elevator
|
||||||
|
@ -368,7 +330,6 @@ TEST_F(TrimsTest, InstantTrim)
|
||||||
EXPECT_EQ(25, getTrimValue(0, AIL_STICK));
|
EXPECT_EQ(25, getTrimValue(0, AIL_STICK));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(VIRTUAL_INPUTS)
|
|
||||||
TEST_F(TrimsTest, InstantTrimNegativeCurve)
|
TEST_F(TrimsTest, InstantTrimNegativeCurve)
|
||||||
{
|
{
|
||||||
ExpoData *expo = expoAddress(AIL_STICK);
|
ExpoData *expo = expoAddress(AIL_STICK);
|
||||||
|
@ -383,7 +344,6 @@ TEST_F(TrimsTest, InstantTrimNegativeCurve)
|
||||||
instantTrim();
|
instantTrim();
|
||||||
EXPECT_EQ(128, getTrimValue(0, AIL_STICK));
|
EXPECT_EQ(128, getTrimValue(0, AIL_STICK));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
TEST(Curves, LinearIntpol)
|
TEST(Curves, LinearIntpol)
|
||||||
{
|
{
|
||||||
|
@ -567,30 +527,6 @@ TEST_F(MixerTest, DelayOnSwitch)
|
||||||
EXPECT_EQ(chans[0], 0);
|
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)
|
TEST_F(MixerTest, SlowOnMultiply)
|
||||||
{
|
{
|
||||||
g_model.mixData[0].destCh = 0;
|
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)
|
TEST(Heli, BasicTest)
|
||||||
{
|
{
|
||||||
SYSTEM_RESET();
|
SYSTEM_RESET();
|
||||||
|
@ -687,22 +623,6 @@ TEST(Heli, Mode2Test)
|
||||||
}
|
}
|
||||||
#endif
|
#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)
|
TEST(Trainer, UnpluggedTest)
|
||||||
{
|
{
|
||||||
SYSTEM_RESET();
|
SYSTEM_RESET();
|
||||||
|
|
|
@ -20,17 +20,6 @@
|
||||||
|
|
||||||
#include "gtests.h"
|
#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)
|
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;
|
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].duration = _duration;
|
||||||
g_model.logicalSw[index].andsw = _andsw;
|
g_model.logicalSw[index].andsw = _andsw;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
TEST(getSwitch, OldTypeStickyCSW)
|
TEST(getSwitch, OldTypeStickyCSW)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue