Massive clean thanks to Schwabe : unifdef -m -DCPUARM -UCPUM64 -UCPUM2560 -UPCBSTD -UPCBMEGA2560 -UPCBGRUVIN9X -UPCB9X $(find . -name "*.cpp" -or -name "*.h")
This commit is contained in:
@@ -22,9 +22,7 @@
|
||||
|
||||
CustomFunctionsContext modelFunctionsContext = { 0 };
|
||||
|
||||
#if defined(CPUARM)
|
||||
CustomFunctionsContext globalFunctionsContext = { 0 };
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG)
|
||||
/*
|
||||
@@ -49,7 +47,6 @@ PLAY_FUNCTION(playValue, source_t idx)
|
||||
|
||||
getvalue_t val = getValue(idx);
|
||||
|
||||
#if defined(CPUARM)
|
||||
if (idx >= MIXSRC_FIRST_TELEM) {
|
||||
TelemetrySensor & telemetrySensor = g_model.telemetrySensors[(idx-MIXSRC_FIRST_TELEM) / 3];
|
||||
uint8_t attr = 0;
|
||||
@@ -89,128 +86,9 @@ PLAY_FUNCTION(playValue, source_t idx)
|
||||
}
|
||||
PLAY_NUMBER(val, 0, 0);
|
||||
}
|
||||
#else
|
||||
switch (idx) {
|
||||
case MIXSRC_FIRST_TELEM+TELEM_TX_VOLTAGE-1:
|
||||
PLAY_NUMBER(val, 1+UNIT_VOLTS, PREC1);
|
||||
break;
|
||||
case MIXSRC_FIRST_TELEM+TELEM_TIMER1-1:
|
||||
case MIXSRC_FIRST_TELEM+TELEM_TIMER2-1:
|
||||
PLAY_DURATION(val, 0);
|
||||
break;
|
||||
#if defined(TELEMETRY_FRSKY)
|
||||
case MIXSRC_FIRST_TELEM+TELEM_RSSI_TX-1:
|
||||
case MIXSRC_FIRST_TELEM+TELEM_RSSI_RX-1:
|
||||
PLAY_NUMBER(val, 1+UNIT_DB, 0);
|
||||
break;
|
||||
case MIXSRC_FIRST_TELEM+TELEM_MIN_A1-1:
|
||||
case MIXSRC_FIRST_TELEM+TELEM_MIN_A2-1:
|
||||
idx -= TELEM_MIN_A1-TELEM_A1;
|
||||
// no break
|
||||
case MIXSRC_FIRST_TELEM+TELEM_A1-1:
|
||||
case MIXSRC_FIRST_TELEM+TELEM_A2-1:
|
||||
if (TELEMETRY_STREAMING()) {
|
||||
idx -= (MIXSRC_FIRST_TELEM+TELEM_A1-1);
|
||||
uint8_t att = 0;
|
||||
int16_t converted_value = div_and_round(applyChannelRatio(idx, val), 10);
|
||||
if (ANA_CHANNEL_UNIT(idx) < UNIT_RAW) {
|
||||
att = PREC1;
|
||||
}
|
||||
PLAY_NUMBER(converted_value, 1+ANA_CHANNEL_UNIT(idx), att);
|
||||
}
|
||||
break;
|
||||
case MIXSRC_FIRST_TELEM+TELEM_CELL-1:
|
||||
case MIXSRC_FIRST_TELEM+TELEM_MIN_CELL-1:
|
||||
PLAY_NUMBER(div_and_round(val, 10), 1+UNIT_VOLTS, PREC1);
|
||||
break;
|
||||
|
||||
case MIXSRC_FIRST_TELEM+TELEM_VFAS-1:
|
||||
case MIXSRC_FIRST_TELEM+TELEM_CELLS_SUM-1:
|
||||
case MIXSRC_FIRST_TELEM+TELEM_MIN_CELLS_SUM-1:
|
||||
case MIXSRC_FIRST_TELEM+TELEM_MIN_VFAS-1:
|
||||
PLAY_NUMBER(val, 1+UNIT_VOLTS, PREC1);
|
||||
break;
|
||||
|
||||
case MIXSRC_FIRST_TELEM+TELEM_CURRENT-1:
|
||||
case MIXSRC_FIRST_TELEM+TELEM_MAX_CURRENT-1:
|
||||
PLAY_NUMBER(val, 1+UNIT_AMPS, PREC1);
|
||||
break;
|
||||
|
||||
case MIXSRC_FIRST_TELEM+TELEM_ACCx-1:
|
||||
case MIXSRC_FIRST_TELEM+TELEM_ACCy-1:
|
||||
case MIXSRC_FIRST_TELEM+TELEM_ACCz-1:
|
||||
PLAY_NUMBER(div_and_round(val, 10), 1+UNIT_G, PREC1);
|
||||
break;
|
||||
|
||||
case MIXSRC_FIRST_TELEM+TELEM_VSPEED-1:
|
||||
PLAY_NUMBER(div_and_round(val, 10), 1+UNIT_METERS_PER_SECOND, PREC1);
|
||||
break;
|
||||
|
||||
case MIXSRC_FIRST_TELEM+TELEM_ASPEED-1:
|
||||
case MIXSRC_FIRST_TELEM+TELEM_MAX_ASPEED-1:
|
||||
PLAY_NUMBER(val/10, 1+UNIT_KTS, 0);
|
||||
break;
|
||||
|
||||
case MIXSRC_FIRST_TELEM+TELEM_CONSUMPTION-1:
|
||||
PLAY_NUMBER(val, 1+UNIT_MAH, 0);
|
||||
break;
|
||||
|
||||
case MIXSRC_FIRST_TELEM+TELEM_POWER-1:
|
||||
PLAY_NUMBER(val, 1+UNIT_WATTS, 0);
|
||||
break;
|
||||
|
||||
case MIXSRC_FIRST_TELEM+TELEM_ALT-1:
|
||||
case MIXSRC_FIRST_TELEM+TELEM_MIN_ALT-1:
|
||||
case MIXSRC_FIRST_TELEM+TELEM_MAX_ALT-1:
|
||||
#if defined(WS_HOW_HIGH)
|
||||
if (IS_IMPERIAL_ENABLE() && IS_USR_PROTO_WS_HOW_HIGH())
|
||||
PLAY_NUMBER(val, 1+UNIT_FEET, 0);
|
||||
else
|
||||
#endif
|
||||
PLAY_NUMBER(val, 1+UNIT_DIST, 0);
|
||||
break;
|
||||
|
||||
case MIXSRC_FIRST_TELEM+TELEM_RPM-1:
|
||||
case MIXSRC_FIRST_TELEM+TELEM_MAX_RPM-1:
|
||||
{
|
||||
getvalue_t rpm = val;
|
||||
if (rpm > 100)
|
||||
rpm = 10 * div_and_round(rpm, 10);
|
||||
if (rpm > 1000)
|
||||
rpm = 10 * div_and_round(rpm, 10);
|
||||
PLAY_NUMBER(rpm, 1+UNIT_RPMS, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
case MIXSRC_FIRST_TELEM+TELEM_HDG-1:
|
||||
PLAY_NUMBER(val, 1+UNIT_HDG, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
uint8_t unit = 1;
|
||||
if (idx < MIXSRC_GVAR1)
|
||||
val = calcRESXto100(val);
|
||||
if (idx >= MIXSRC_FIRST_TELEM+TELEM_ALT-1 && idx <= MIXSRC_FIRST_TELEM+TELEM_GPSALT-1)
|
||||
unit = idx - (MIXSRC_FIRST_TELEM+TELEM_ALT-1);
|
||||
else if (idx >= MIXSRC_FIRST_TELEM+TELEM_MAX_T1-1 && idx <= MIXSRC_FIRST_TELEM+TELEM_MAX_DIST-1)
|
||||
unit = 3 + idx - (MIXSRC_FIRST_TELEM+TELEM_MAX_T1-1);
|
||||
|
||||
unit = pgm_read_byte(bchunit_ar+unit);
|
||||
PLAY_NUMBER(val, unit == UNIT_RAW ? 0 : unit+1, 0);
|
||||
break;
|
||||
}
|
||||
#else
|
||||
default:
|
||||
PLAY_NUMBER(val, 0, 0);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
void playCustomFunctionFile(const CustomFunctionData * sd, uint8_t id)
|
||||
{
|
||||
if (sd->play.name[0] != '\0') {
|
||||
@@ -222,9 +100,7 @@ void playCustomFunctionFile(const CustomFunctionData * sd, uint8_t id)
|
||||
PLAY_FILE(filename, sd->func==FUNC_BACKGND_MUSIC ? PLAY_BACKGROUND : 0, id);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
bool isRepeatDelayElapsed(const CustomFunctionData * functions, CustomFunctionsContext & functionsContext, uint8_t index)
|
||||
{
|
||||
const CustomFunctionData * cfn = &functions[index];
|
||||
@@ -241,32 +117,17 @@ bool isRepeatDelayElapsed(const CustomFunctionData * functions, CustomFunctionsC
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define isRepeatDelayElapsed(...) true
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
#define VOLUME_HYSTERESIS 10 // how much must a input value change to actually be considered for new volume setting
|
||||
getvalue_t requiredSpeakerVolumeRawLast = 1024 + 1; //initial value must be outside normal range
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
void evalFunctions(const CustomFunctionData * functions, CustomFunctionsContext & functionsContext)
|
||||
#else
|
||||
#define functions g_model.customFn
|
||||
#define functionsContext modelFunctionsContext
|
||||
void evalFunctions()
|
||||
#endif
|
||||
{
|
||||
MASK_FUNC_TYPE newActiveFunctions = 0;
|
||||
MASK_CFN_TYPE newActiveSwitches = 0;
|
||||
|
||||
#if defined(CPUARM)
|
||||
uint8_t playFirstIndex = (functions == g_model.customFn ? 1 : 1+MAX_SPECIAL_FUNCTIONS);
|
||||
#define PLAY_INDEX (i+playFirstIndex)
|
||||
#else
|
||||
#define PLAY_INDEX (i+1)
|
||||
#endif
|
||||
|
||||
#if defined(ROTARY_ENCODERS) && defined(GVARS)
|
||||
static rotenc_t rePreviousValues[ROTARY_ENCODERS];
|
||||
@@ -290,11 +151,7 @@ void evalFunctions()
|
||||
if (swtch) {
|
||||
MASK_CFN_TYPE switch_mask = ((MASK_CFN_TYPE)1 << i);
|
||||
|
||||
#if defined(CPUARM)
|
||||
bool active = getSwitch(swtch, IS_PLAY_FUNC(CFN_FUNC(cfn)) ? GETSWITCH_MIDPOS_DELAY : 0);
|
||||
#else
|
||||
bool active = getSwitch(swtch);
|
||||
#endif
|
||||
|
||||
if (HAS_ENABLE_PARAM(CFN_FUNC(cfn))) {
|
||||
active &= (bool)CFN_ACTIVE(cfn);
|
||||
@@ -333,18 +190,12 @@ void evalFunctions()
|
||||
switch (CFN_PARAM(cfn)) {
|
||||
case FUNC_RESET_TIMER1:
|
||||
case FUNC_RESET_TIMER2:
|
||||
#if defined(CPUARM)
|
||||
case FUNC_RESET_TIMER3:
|
||||
#endif
|
||||
timerReset(CFN_PARAM(cfn));
|
||||
break;
|
||||
case FUNC_RESET_FLIGHT:
|
||||
if (!(functionsContext.activeSwitches & switch_mask)) {
|
||||
#if defined(CPUARM)
|
||||
mainRequestFlags |= (1 << REQUEST_FLIGHT_RESET); // on systems with threads flightReset() must not be called from the mixers thread!
|
||||
#else
|
||||
flightReset();
|
||||
#endif // defined(CPUARM)
|
||||
}
|
||||
break;
|
||||
#if defined(TELEMETRY_FRSKY)
|
||||
@@ -362,17 +213,14 @@ void evalFunctions()
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
#if defined(CPUARM)
|
||||
if (CFN_PARAM(cfn)>=FUNC_RESET_PARAM_FIRST_TELEM) {
|
||||
uint8_t item = CFN_PARAM(cfn)-FUNC_RESET_PARAM_FIRST_TELEM;
|
||||
if (item < MAX_TELEMETRY_SENSORS) {
|
||||
telemetryItems[item].clear();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
#if defined(CPUARM)
|
||||
case FUNC_SET_TIMER:
|
||||
timerSet(CFN_TIMER_INDEX(cfn), CFN_PARAM(cfn));
|
||||
break;
|
||||
@@ -392,7 +240,6 @@ void evalFunctions()
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#endif // defined(CPUARM)
|
||||
|
||||
#if defined(GVARS)
|
||||
case FUNC_ADJUST_GVAR:
|
||||
@@ -404,11 +251,7 @@ void evalFunctions()
|
||||
}
|
||||
else if (CFN_GVAR_MODE(cfn) == FUNC_ADJUST_GVAR_INCDEC) {
|
||||
if (!(functionsContext.activeSwitches & switch_mask)) {
|
||||
#if defined(CPUARM)
|
||||
SET_GVAR(CFN_GVAR_INDEX(cfn), limit<int16_t>(MODEL_GVAR_MIN(CFN_GVAR_INDEX(cfn)), GVAR_VALUE(CFN_GVAR_INDEX(cfn), getGVarFlightMode(mixerCurrentFlightMode, CFN_GVAR_INDEX(cfn))) + CFN_PARAM(cfn), MODEL_GVAR_MAX(CFN_GVAR_INDEX(cfn))), mixerCurrentFlightMode);
|
||||
#else
|
||||
SET_GVAR(CFN_GVAR_INDEX(cfn), GVAR_VALUE(CFN_GVAR_INDEX(cfn), getGVarFlightMode(mixerCurrentFlightMode, CFN_GVAR_INDEX(cfn))) + (CFN_PARAM(cfn) ? +1 : -1), mixerCurrentFlightMode);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if (CFN_PARAM(cfn) >= MIXSRC_FIRST_TRIM && CFN_PARAM(cfn) <= MIXSRC_LAST_TRIM) {
|
||||
@@ -418,20 +261,12 @@ void evalFunctions()
|
||||
else if (CFN_PARAM(cfn) >= MIXSRC_REa && CFN_PARAM(cfn) < MIXSRC_TrimRud) {
|
||||
int8_t scroll = rePreviousValues[CFN_PARAM(cfn)-MIXSRC_REa] - (rotencValue[CFN_PARAM(cfn)-MIXSRC_REa] / ROTARY_ENCODER_GRANULARITY);
|
||||
if (scroll) {
|
||||
#if defined(CPUARM)
|
||||
SET_GVAR(CFN_GVAR_INDEX(cfn), limit<int16_t>(MODEL_GVAR_MIN(CFN_GVAR_INDEX(cfn)), GVAR_VALUE(CFN_GVAR_INDEX(cfn), getGVarFlightMode(mixerCurrentFlightMode, CFN_GVAR_INDEX(cfn))) + scroll, MODEL_GVAR_MAX(CFN_GVAR_INDEX(cfn))), mixerCurrentFlightMode);
|
||||
#else
|
||||
SET_GVAR(CFN_GVAR_INDEX(cfn), GVAR_VALUE(CFN_GVAR_INDEX(cfn), getGVarFlightMode(mixerCurrentFlightMode, CFN_GVAR_INDEX(cfn))) + scroll, mixerCurrentFlightMode);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
#if defined(CPUARM)
|
||||
SET_GVAR(CFN_GVAR_INDEX(cfn), limit<int16_t>(MODEL_GVAR_MIN(CFN_GVAR_INDEX(cfn)), calcRESXto100(getValue(CFN_PARAM(cfn))), MODEL_GVAR_MAX(CFN_GVAR_INDEX(cfn))), mixerCurrentFlightMode);
|
||||
#else
|
||||
SET_GVAR(CFN_GVAR_INDEX(cfn), calcRESXto100(getValue(CFN_PARAM(cfn))), mixerCurrentFlightMode);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
@@ -543,18 +378,6 @@ void evalFunctions()
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(HAPTIC) && !defined(CPUARM)
|
||||
case FUNC_HAPTIC:
|
||||
{
|
||||
tmr10ms_t tmr10ms = get_tmr10ms();
|
||||
uint8_t repeatParam = CFN_PLAY_REPEAT(cfn);
|
||||
if (!functionsContext.lastFunctionTime[i] || (repeatParam && (signed)(tmr10ms-functionsContext.lastFunctionTime[i])>=1000*repeatParam)) {
|
||||
functionsContext.lastFunctionTime[i] = tmr10ms;
|
||||
haptic.event(AU_SPECIAL_SOUND_LAST+CFN_PARAM(cfn));
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SDCARD)
|
||||
case FUNC_LOGS:
|
||||
@@ -617,7 +440,3 @@ void evalFunctions()
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(CPUARM)
|
||||
#undef functions
|
||||
#undef functionsContext
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user