mirror of
https://github.com/opentx/opentx.git
synced 2025-07-15 12:25:12 +03:00
* Fixes #3937: When executed from Special Functions, Flight Reset caused a GUI lockup * Cosmetics
This commit is contained in:
parent
81e9fe5201
commit
f4b54ea332
4 changed files with 27 additions and 14 deletions
|
@ -340,7 +340,11 @@ void evalFunctions()
|
||||||
timerReset(CFN_PARAM(cfn));
|
timerReset(CFN_PARAM(cfn));
|
||||||
break;
|
break;
|
||||||
case FUNC_RESET_FLIGHT:
|
case FUNC_RESET_FLIGHT:
|
||||||
|
#if defined(CPUARM)
|
||||||
|
mainRequestFlags |= (1 << REQUEST_FLIGHT_RESET); // on systems with threads flightReset() must not be called from the mixers thread!
|
||||||
|
#else
|
||||||
flightReset();
|
flightReset();
|
||||||
|
#endif // defined(CPUARM)
|
||||||
break;
|
break;
|
||||||
#if defined(TELEMETRY_FRSKY)
|
#if defined(TELEMETRY_FRSKY)
|
||||||
case FUNC_RESET_TELEMETRY:
|
case FUNC_RESET_TELEMETRY:
|
||||||
|
@ -573,7 +577,7 @@ void evalFunctions()
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
case FUNC_SCREENSHOT:
|
case FUNC_SCREENSHOT:
|
||||||
if (!(functionsContext.activeSwitches & switch_mask)) {
|
if (!(functionsContext.activeSwitches & switch_mask)) {
|
||||||
requestScreenshot = true;
|
mainRequestFlags |= (1 << REQUEST_SCREENSHOT);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
uint8_t currentSpeakerVolume = 255;
|
uint8_t currentSpeakerVolume = 255;
|
||||||
uint8_t requiredSpeakerVolume = 255;
|
uint8_t requiredSpeakerVolume = 255;
|
||||||
uint8_t requestScreenshot = false;
|
uint8_t mainRequestFlags = 0;
|
||||||
|
|
||||||
void handleUsbConnection()
|
void handleUsbConnection()
|
||||||
{
|
{
|
||||||
|
@ -399,6 +399,12 @@ void perMain()
|
||||||
periodicTick();
|
periodicTick();
|
||||||
DEBUG_TIMER_STOP(debugTimerPerMain1);
|
DEBUG_TIMER_STOP(debugTimerPerMain1);
|
||||||
|
|
||||||
|
if (mainRequestFlags & (1 << REQUEST_FLIGHT_RESET)) {
|
||||||
|
TRACE("Executing requested Flight Reset");
|
||||||
|
flightReset();
|
||||||
|
mainRequestFlags &= ~(1 << REQUEST_FLIGHT_RESET);
|
||||||
|
}
|
||||||
|
|
||||||
event_t evt = getEvent(false);
|
event_t evt = getEvent(false);
|
||||||
if (evt && (g_eeGeneral.backlightMode & e_backlight_mode_keys)) {
|
if (evt && (g_eeGeneral.backlightMode & e_backlight_mode_keys)) {
|
||||||
// on keypress turn the light on
|
// on keypress turn the light on
|
||||||
|
@ -455,9 +461,9 @@ void perMain()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
if (requestScreenshot) {
|
if (mainRequestFlags & (1 << REQUEST_SCREENSHOT)) {
|
||||||
requestScreenshot = false;
|
|
||||||
writeScreenshot();
|
writeScreenshot();
|
||||||
|
mainRequestFlags &= ~(1 << REQUEST_SCREENSHOT);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1347,8 +1347,13 @@ void clearMFP();
|
||||||
extern uint8_t requiredSpeakerVolume;
|
extern uint8_t requiredSpeakerVolume;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(CPUARM)
|
||||||
extern uint8_t requestScreenshot;
|
enum MainRequest {
|
||||||
|
REQUEST_SCREENSHOT,
|
||||||
|
REQUEST_FLIGHT_RESET,
|
||||||
|
};
|
||||||
|
|
||||||
|
extern uint8_t mainRequestFlags;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void checkBattery();
|
void checkBattery();
|
||||||
|
|
|
@ -42,23 +42,21 @@ TEST(SpecialFunctions, FlightReset)
|
||||||
g_model.customFn[0].all.val = FUNC_RESET_FLIGHT;
|
g_model.customFn[0].all.val = FUNC_RESET_FLIGHT;
|
||||||
g_model.customFn[0].active = true;
|
g_model.customFn[0].active = true;
|
||||||
|
|
||||||
// we (mis)use s_mixer_first_run_done for the flight reset detection
|
mainRequestFlags = 0;
|
||||||
s_mixer_first_run_done = true;
|
|
||||||
evalFunctions(g_model.customFn, modelFunctionsContext);
|
evalFunctions(g_model.customFn, modelFunctionsContext);
|
||||||
EXPECT_EQ(s_mixer_first_run_done, true);
|
EXPECT_EQ((bool)(mainRequestFlags & (1 << REQUEST_FLIGHT_RESET)), false);
|
||||||
|
|
||||||
// now trigger SA0
|
// now trigger SA0
|
||||||
simuSetSwitch(0, -1);
|
simuSetSwitch(0, -1);
|
||||||
|
|
||||||
// flightReset() should be called
|
// flightReset() should be called
|
||||||
evalFunctions(g_model.customFn, modelFunctionsContext);
|
evalFunctions(g_model.customFn, modelFunctionsContext);
|
||||||
EXPECT_EQ(s_mixer_first_run_done, false);
|
EXPECT_EQ((bool)(mainRequestFlags & (1 << REQUEST_FLIGHT_RESET)), true);
|
||||||
|
|
||||||
// now set s_mixer_first_run_done to true, and it should stay true (flightReset() should not be called again)
|
// now reset mainRequestFlags, and it should stay reset (flightReset() should not be called again)
|
||||||
s_mixer_first_run_done = true;
|
mainRequestFlags = 0;
|
||||||
evalFunctions(g_model.customFn, modelFunctionsContext);
|
evalFunctions(g_model.customFn, modelFunctionsContext);
|
||||||
EXPECT_EQ(s_mixer_first_run_done, true) << "Flight Reset repeats!";
|
EXPECT_EQ((bool)(mainRequestFlags & (1 << REQUEST_FLIGHT_RESET)), false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(GVARS)
|
#if defined(GVARS)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue