mirror of
https://github.com/opentx/opentx.git
synced 2025-07-24 00:35:18 +03:00
Cosmetics
This commit is contained in:
parent
b82ffe308d
commit
f857d5454e
3 changed files with 53 additions and 67 deletions
|
@ -774,7 +774,7 @@ ifeq ($(NAVIGATION), ROTENC)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(TURNIGY_TRANSMITTER_FIX), YES)
|
ifeq ($(TURNIGY_TRANSMITTER_FIX), YES)
|
||||||
CPPDEFS += -DINPUT_WARNINGS_GENERATE_SIM_DATA
|
CPPDEFS += -DMODULE_ALWAYS_SEND_PULSES
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(AUTOSWITCH), YES)
|
ifeq ($(AUTOSWITCH), YES)
|
||||||
|
|
|
@ -51,8 +51,8 @@ int24_t act [MAX_MIXERS] = {0};
|
||||||
SwOn swOn [MAX_MIXERS]; // TODO better name later...
|
SwOn swOn [MAX_MIXERS]; // TODO better name later...
|
||||||
|
|
||||||
uint8_t mixWarning;
|
uint8_t mixWarning;
|
||||||
#ifdef INPUT_WARNINGS_GENERATE_SIM_DATA
|
#if defined(MODULE_ALWAYS_SEND_PULSES)
|
||||||
uint8_t checkWarningState;
|
uint8_t startupWarningState;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
|
@ -1405,16 +1405,17 @@ bool getSwitch(int8_t swtch)
|
||||||
}
|
}
|
||||||
else if (cs_idx <= SWSRC_LAST_SWITCH) {
|
else if (cs_idx <= SWSRC_LAST_SWITCH) {
|
||||||
result = SWITCH_POSITION(cs_idx-SWSRC_FIRST_SWITCH);
|
result = SWITCH_POSITION(cs_idx-SWSRC_FIRST_SWITCH);
|
||||||
#ifdef INPUT_WARNINGS_GENERATE_SIM_DATA
|
#if defined(MODULE_ALWAYS_SEND_PULSES)
|
||||||
if (checkWarningState<e_InWarnFinished) {
|
if (startupWarningState < STARTUP_WARNING_DONE) {
|
||||||
// if throttle or switch warning is currently active, ignore actual stick position and use wanted values
|
// if throttle or switch warning is currently active, ignore actual stick position and use wanted values
|
||||||
if (cs_idx<=3) {
|
if (cs_idx <= 3) {
|
||||||
if (!(g_model.nSwToWarn&1)) { // ID1 to ID3 is just one bit in nSwToWarn
|
if (!(g_model.nSwToWarn&1)) { // ID1 to ID3 is just one bit in nSwToWarn
|
||||||
result=(cs_idx)==((g_model.switchWarningStates&3)+1); // overwrite result with desired value
|
result = (cs_idx)==((g_model.switchWarningStates&3)+1); // overwrite result with desired value
|
||||||
}
|
}
|
||||||
} else if (!(g_model.nSwToWarn&(1<<(cs_idx-3)) )) {
|
}
|
||||||
|
else if (!(g_model.nSwToWarn & (1<<(cs_idx-3)))) {
|
||||||
// current switch should not be ignored for warning
|
// current switch should not be ignored for warning
|
||||||
result=g_model.switchWarningStates&(1<<(cs_idx-2)); // overwrite result with desired value
|
result = g_model.switchWarningStates & (1<<(cs_idx-2)); // overwrite result with desired value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -2279,31 +2280,14 @@ void doSplash()
|
||||||
#define doSplash()
|
#define doSplash()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// #define INPUT_WARNINGS_GENERATE_SIM_DATA
|
|
||||||
// the latests deliveries from 9x transmitters (since 2 years now, 2014) do not stop sending if no pulses are generated.
|
|
||||||
// This fact totally breaks the nice throttle and switch warning concept, because even we prevent sending pulses the
|
|
||||||
// transmitter modul ignores this, and continous to send the last value or 0 at beginning. And 0 means in the middle of throttle -> 50%.
|
|
||||||
// To cope with this situation, we need a new concept how to handle throttle and switch warnings.
|
|
||||||
// My solution is, not to stop pulses at all. In warning situation the input of the appropriate channels are ignored and
|
|
||||||
// replaced with a value which wouldn't generate the warning, e.g. for throttle -100%
|
|
||||||
// Because this new concept is also compatible with the better (older) transmitter we can enable it by default and let the user choose if
|
|
||||||
// he want's the old handling or new one.
|
|
||||||
|
|
||||||
#if defined(PCBTARANIS) && defined(INPUT_WARNINGS_GENERATE_SIM_DATA)
|
|
||||||
// #error "INPUT_WARNINGS_GENERATE_SIM_DATA is not yet implemented for Taranis build."
|
|
||||||
// according current transmitters, this shouldn't be necessary as well
|
|
||||||
// but if wanted the switch simulation part needs to be simulated the same way as for stock
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void checkAll()
|
void checkAll()
|
||||||
{
|
{
|
||||||
#if !defined(PCBSKY9X)
|
#if !defined(PCBSKY9X)
|
||||||
checkLowEEPROM();
|
checkLowEEPROM();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef INPUT_WARNINGS_GENERATE_SIM_DATA
|
#if defined(MODULE_ALWAYS_SEND_PULSES)
|
||||||
checkWarningState=e_InWarnBegin;
|
startupWarningState = STARTUP_WARNING_INIT;
|
||||||
#else
|
#else
|
||||||
checkTHR();
|
checkTHR();
|
||||||
checkSwitches();
|
checkSwitches();
|
||||||
|
@ -2321,13 +2305,15 @@ void checkAll()
|
||||||
clearKeyEvents();
|
clearKeyEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef INPUT_WARNINGS_GENERATE_SIM_DATA
|
#if defined(MODULE_ALWAYS_SEND_PULSES)
|
||||||
void checkInMix()
|
void checkStartupWarnings()
|
||||||
{
|
{
|
||||||
if (checkWarningState>=e_InWarnFinished) return; // no more checks
|
if (startupWarningState >= STARTUP_WARNING_DONE) return; // no more checks
|
||||||
|
|
||||||
if (checkWarningState<e_InWarnStartSwitchWarn) checkTHR();
|
if (startupWarningState < STARTUP_WARNING_SWITCHES)
|
||||||
else checkSwitches();
|
checkTHR();
|
||||||
|
else
|
||||||
|
checkSwitches();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2343,32 +2329,30 @@ void checkLowEEPROM()
|
||||||
|
|
||||||
void checkTHR()
|
void checkTHR()
|
||||||
{
|
{
|
||||||
uint8_t thrchn = ((g_model.thrTraceSrc==0)||(g_model.thrTraceSrc>NUM_POTS)) ?
|
uint8_t thrchn = ((g_model.thrTraceSrc==0) || (g_model.thrTraceSrc>NUM_POTS)) ? THR_STICK : g_model.thrTraceSrc+NUM_STICKS-1;
|
||||||
THR_STICK : g_model.thrTraceSrc+NUM_STICKS-1;
|
|
||||||
// throttle channel is either the stick according stick mode (already handled in evalInputs)
|
// throttle channel is either the stick according stick mode (already handled in evalInputs)
|
||||||
// or P1 to P3;
|
// or P1 to P3;
|
||||||
// in case an output channel is choosen as throttle source (thrTraceSrc>NUM_POTS) we assume the throttle stick is the input
|
// in case an output channel is choosen as throttle source (thrTraceSrc>NUM_POTS) we assume the throttle stick is the input
|
||||||
// no other information avaialbe at the moment, and good enough to my option (otherwise too much exceptions...)
|
// no other information avaialbe at the moment, and good enough to my option (otherwise too much exceptions...)
|
||||||
|
|
||||||
|
|
||||||
#ifdef INPUT_WARNINGS_GENERATE_SIM_DATA
|
#if defined(MODULE_ALWAYS_SEND_PULSES)
|
||||||
int16_t v = calibratedStick[thrchn];
|
int16_t v = calibratedStick[thrchn];
|
||||||
if ((v<=(THRCHK_DEADBAND-1024)) || g_model.disableThrottleWarning) {
|
if ((v<=(THRCHK_DEADBAND-1024)) || g_model.disableThrottleWarning) {
|
||||||
checkWarningState=e_InWarnStartSwitchWarn;
|
startupWarningState = STARTUP_WARNING_SWITCHES; // TODO += 1
|
||||||
// checkWarningState=e_InWarnFinished;
|
}
|
||||||
} else {
|
else {
|
||||||
calibratedStick[thrchn]=-1024;
|
calibratedStick[thrchn] = -1024;
|
||||||
#if !defined(PCBTARANIS)
|
#if !defined(PCBTARANIS)
|
||||||
rawAnas[thrchn]=anas[thrchn]=calibratedStick[thrchn];
|
rawAnas[thrchn] = anas[thrchn] = calibratedStick[thrchn];
|
||||||
#endif
|
#endif
|
||||||
if (checkWarningState<e_InWarnThrottleWarnActive) {
|
if (startupWarningState < STARTUP_WARNING_THROTTLE) {
|
||||||
// warning message is not yet visible
|
// warning message is not yet visible
|
||||||
MESSAGE(STR_THROTTLEWARN, STR_THROTTLENOTIDLE, STR_PRESSANYKEYTOSKIP, AU_THROTTLE_ALERT);
|
MESSAGE(STR_THROTTLEWARN, STR_THROTTLENOTIDLE, STR_PRESSANYKEYTOSKIP, AU_THROTTLE_ALERT);
|
||||||
checkWarningState=e_InWarnThrottleWarnActive;
|
startupWarningState = STARTUP_WARNING_THROTTLE;
|
||||||
} else if (pwrCheck()==e_power_off || keyDown()) {
|
}
|
||||||
|
else if (pwrCheck()==e_power_off || keyDown()) {
|
||||||
// key pressed -> disable warning
|
// key pressed -> disable warning
|
||||||
checkWarningState=e_InWarnStartSwitchWarn;
|
startupWarningState = STARTUP_WARNING_SWITCHES;
|
||||||
// checkWarningState=e_InWarnFinished;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -2402,7 +2386,7 @@ void checkAlarm() // added by Gohst
|
||||||
|
|
||||||
void checkSwitches()
|
void checkSwitches()
|
||||||
{
|
{
|
||||||
#ifdef INPUT_WARNINGS_GENERATE_SIM_DATA
|
#ifdef MODULE_ALWAYS_SEND_PULSES
|
||||||
static swstate_t last_bad_switches = 0xff;
|
static swstate_t last_bad_switches = 0xff;
|
||||||
#else
|
#else
|
||||||
swstate_t last_bad_switches = 0xff;
|
swstate_t last_bad_switches = 0xff;
|
||||||
|
@ -2413,13 +2397,13 @@ void checkSwitches()
|
||||||
uint8_t bad_pots = 0, last_bad_pots = 0xff;
|
uint8_t bad_pots = 0, last_bad_pots = 0xff;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef INPUT_WARNINGS_GENERATE_SIM_DATA
|
#ifndef MODULE_ALWAYS_SEND_PULSES
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
#if defined(TELEMETRY_MOD_14051) || defined(PCBTARANIS)
|
#if defined(TELEMETRY_MOD_14051) || defined(PCBTARANIS)
|
||||||
getADC();
|
getADC();
|
||||||
#endif
|
#endif
|
||||||
#endif //INPUT_WARNINGS_GENERATE_SIM_DATA
|
#endif //MODULE_ALWAYS_SEND_PULSES
|
||||||
|
|
||||||
getMovedSwitch();
|
getMovedSwitch();
|
||||||
|
|
||||||
|
@ -2455,9 +2439,9 @@ void checkSwitches()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef INPUT_WARNINGS_GENERATE_SIM_DATA
|
#if defined(MODULE_ALWAYS_SEND_PULSES)
|
||||||
if (!warn) {
|
if (!warn) {
|
||||||
checkWarningState=e_InWarnFinished;
|
startupWarningState = STARTUP_WARNING_DONE;
|
||||||
last_bad_switches = 0xff;
|
last_bad_switches = 0xff;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2519,10 +2503,10 @@ void checkSwitches()
|
||||||
last_bad_switches = switches_states;
|
last_bad_switches = switches_states;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef INPUT_WARNINGS_GENERATE_SIM_DATA
|
#if defined(MODULE_ALWAYS_SEND_PULSES)
|
||||||
// checkWarningState=e_InWarnSwitchWarnActive; not needed, because redraw is prevented with last switch compare
|
// startupWarningState=e_InWarnSwitchWarnActive; not needed, because redraw is prevented with last switch compare
|
||||||
if (pwrCheck()==e_power_off || keyDown()) {
|
if (pwrCheck()==e_power_off || keyDown()) {
|
||||||
checkWarningState=e_InWarnFinished;
|
startupWarningState = STARTUP_WARNING_DONE;
|
||||||
last_bad_switches = 0xff;
|
last_bad_switches = 0xff;
|
||||||
// return; // Usb on or power off
|
// return; // Usb on or power off
|
||||||
}
|
}
|
||||||
|
@ -3619,8 +3603,8 @@ void perOut(uint8_t mode, uint8_t tick10ms)
|
||||||
{
|
{
|
||||||
evalInputs(mode);
|
evalInputs(mode);
|
||||||
|
|
||||||
#ifdef INPUT_WARNINGS_GENERATE_SIM_DATA
|
#if defined(MODULE_ALWAYS_SEND_PULSES)
|
||||||
checkInMix();
|
checkStartupWarnings();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HELI)
|
#if defined(HELI)
|
||||||
|
@ -4603,8 +4587,11 @@ void perMain()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef INPUT_WARNINGS_GENERATE_SIM_DATA
|
#if defined(MODULE_ALWAYS_SEND_PULSES)
|
||||||
if (checkWarningState<e_InWarnFinished) return; // don't do menu's until throttle and switch warnings are handled
|
if (startupWarningState < STARTUP_WARNING_DONE) {
|
||||||
|
// don't do menu's until throttle and switch warnings are handled
|
||||||
|
return;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!usbPlugged()) {
|
if (!usbPlugged()) {
|
||||||
|
|
|
@ -804,15 +804,14 @@ enum PerOutMode {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifdef INPUT_WARNINGS_GENERATE_SIM_DATA
|
#if defined(MODULE_ALWAYS_SEND_PULSES)
|
||||||
extern uint8_t checkWarningState;
|
extern uint8_t startupWarningState;
|
||||||
|
|
||||||
enum InputWarningStates {
|
enum StartupWarningStates {
|
||||||
e_InWarnBegin = 0,
|
STARTUP_WARNING_INIT,
|
||||||
e_InWarnThrottleWarnActive = 1,
|
STARTUP_WARNING_THROTTLE,
|
||||||
e_InWarnStartSwitchWarn = 2,
|
STARTUP_WARNING_SWITCHES,
|
||||||
// e_InWarnSwitchWarnActive = 3, currently not needed
|
STARTUP_WARNING_DONE,
|
||||||
e_InWarnFinished = 3,
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue