Skip to content

Commit

Permalink
feat(radio): Delay warnings until after splash screen finished (#3887)
Browse files Browse the repository at this point in the history
  • Loading branch information
philmoz authored Sep 7, 2023
1 parent c4f1e71 commit e485db9
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 125 deletions.
193 changes: 119 additions & 74 deletions radio/src/opentx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,6 @@ void doSplash()
resetBacklightTimeout();
drawSplash();


getADC(); // init ADC array

inactivityCheckInputs();
Expand Down Expand Up @@ -608,17 +607,13 @@ void doSplash()
}
#endif


checkBacklight();
}
#if defined(LIBOPENUI)
MainWindow::instance()->setActiveScreen();
#endif
}
}
#else
#define Splash()
#define doSplash()
#endif


Expand Down Expand Up @@ -1098,67 +1093,6 @@ void flightReset(uint8_t check)
}
}

#if !defined(OPENTX_START_DEFAULT_ARGS)
#define OPENTX_START_DEFAULT_ARGS 0
#endif

void opentxStart(const uint8_t startOptions = OPENTX_START_DEFAULT_ARGS)
{
TRACE("opentxStart(%u)", startOptions);

uint8_t calibration_needed = !(startOptions & OPENTX_START_NO_CALIBRATION) && (g_eeGeneral.chkSum != evalChkSum());

#if defined(BLUETOOTH_PROBE)
extern volatile uint8_t btChipPresent;
auto oldBtMode = g_eeGeneral.bluetoothMode;
g_eeGeneral.bluetoothMode = BLUETOOTH_TELEMETRY;
#endif

#if defined(GUI)
if (!calibration_needed && !(startOptions & OPENTX_START_NO_SPLASH)) {
if (!g_eeGeneral.dontPlayHello)
AUDIO_HELLO();
doSplash();
}
#endif

#if defined(DEBUG_TRACE_BUFFER)
trace_event(trace_start, 0x12345678);
#endif


#if defined(TEST_BUILD_WARNING)
ALERT(STR_TEST_WARNING, TR_TEST_NOTSAFE, AU_ERROR);
#endif

#if defined(FUNCTION_SWITCHES)
if (!UNEXPECTED_SHUTDOWN()) {
setFSStartupPosition();
}
#endif

#if defined(GUI)
if (calibration_needed) {
#if defined(LIBOPENUI)
startCalibration();
#else
chainMenu(menuFirstCalib);
#endif
}
else if (!(startOptions & OPENTX_START_NO_CHECKS)) {
checkAlarm();
checkAll();
PLAY_MODEL_NAME();
}
#endif

#if defined(BLUETOOTH_PROBE)
if (bluetooth.localAddr[0] != '\0')
btChipPresent = 1;
g_eeGeneral.bluetoothMode = oldBtMode;
#endif
}

void opentxClose(uint8_t shutdown)
{
TRACE("opentxClose");
Expand Down Expand Up @@ -1244,9 +1178,6 @@ void opentxResume()
TRACE("theme reloaded & ViewMain invalidated");
#endif

// removed to avoid the double warnings (throttle, switch, etc.)
// opentxStart(OPENTX_START_NO_SPLASH | OPENTX_START_NO_CALIBRATION | OPENTX_START_NO_CHECKS);

referenceSystemAudioFiles();

if (!g_eeGeneral.unexpectedShutdown) {
Expand Down Expand Up @@ -1445,9 +1376,31 @@ void moveTrimsToOffsets() // copy state of 3 primary to subtrim
AUDIO_WARNING2();
}

#if !defined(OPENTX_START_DEFAULT_ARGS)
#define OPENTX_START_DEFAULT_ARGS 0
#endif

const uint8_t startOptions = OPENTX_START_DEFAULT_ARGS;

void opentxInit()
{
TRACE("opentxInit");

#if defined(SPLASH) && !defined(STARTUP_ANIMATION)
tmr10ms_t splashStartTime = 0;
bool waitSplash = false;
if (!UNEXPECTED_SHUTDOWN()) {
splashStartTime = get_tmr10ms();
waitSplash = true;
drawSplash();
TRACE("drawSplash() completed");
}
#endif

#if defined(HARDWARE_TOUCH) && !defined(PCBFLYSKY) && !defined(SIMU)
touchPanelInit();
#endif

#if defined(LIBOPENUI)
// create ViewMain
ViewMain::instance();
Expand Down Expand Up @@ -1512,7 +1465,7 @@ void opentxInit()
g_eeGeneral.pwrOffSpeed = 2;
runFatalErrorScreen(STR_NO_SDCARD);
}
#endif
#endif // !defined(COLORLCD)

#if defined(AUTOUPDATE)
sportStopSendByteLoop();
Expand All @@ -1524,14 +1477,14 @@ void opentxInit()
if (bluetooth.flashFirmware(AUTOUPDATE_FILENAME) == nullptr)
f_unlink(AUTOUPDATE_FILENAME);
}
#endif
#endif // defined(BLUETOOTH)
}
}
#endif
#endif // defined(AUTOUPDATE)

logsInit();
}
#endif
#endif // defined(SDCARD)

#if defined(EEPROM)
if (!radioSettingsValid)
Expand Down Expand Up @@ -1598,7 +1551,99 @@ void opentxInit()
}

if (!globalData.unexpectedShutdown) {
opentxStart();

uint8_t calibration_needed = !(startOptions & OPENTX_START_NO_CALIBRATION) && (g_eeGeneral.chkSum != evalChkSum());

#if defined(GUI)
if (!calibration_needed && !(startOptions & OPENTX_START_NO_SPLASH)) {
if (!g_eeGeneral.dontPlayHello)
AUDIO_HELLO();

// TODO: This needs some refactoring and cleanup
#if defined(SPLASH)
// Handle B&W splash screen
doSplash();

// Handle color splash screen
#if !defined(STARTUP_ANIMATION)
if (waitSplash) {
extern bool inactivityCheckInputs();
extern void checkSpeakerVolume();

#if defined(SIMU)
// Simulator - inputsMoved() returns true immediately without this!
RTOS_WAIT_TICKS(30);
#endif // defined(SIMU)

splashStartTime += SPLASH_TIMEOUT;
while (splashStartTime > get_tmr10ms()) {
WDG_RESET();
checkSpeakerVolume();
checkBacklight();
RTOS_WAIT_TICKS(10);
auto evt = getEvent();
if (evt || inactivityCheckInputs()) {
if (evt)
killEvents(evt);
break;
}
#if defined(SIMU)
// Allow simulator to exit if closed while splash showing
uint32_t pwr_check = pwrCheck();
if (pwr_check == e_power_off) {
break;
}
#endif // defined(SIMU)
}

// Reset timer so special/global functions set to !1x don't get triggered
START_SILENCE_PERIOD();
}
#endif // !defined(STARTUP_ANIMATION)
#endif // defined(SPLASH)
}
#endif // defined(GUI)

#if defined(BLUETOOTH_PROBE)
extern volatile uint8_t btChipPresent;
auto oldBtMode = g_eeGeneral.bluetoothMode;
g_eeGeneral.bluetoothMode = BLUETOOTH_TELEMETRY;
#endif

#if defined(DEBUG_TRACE_BUFFER)
trace_event(trace_start, 0x12345678);
#endif

#if defined(TEST_BUILD_WARNING)
ALERT(STR_TEST_WARNING, TR_TEST_NOTSAFE, AU_ERROR);
#endif

#if defined(FUNCTION_SWITCHES)
if (!UNEXPECTED_SHUTDOWN()) {
setFSStartupPosition();
}
#endif

#if defined(GUI)
if (calibration_needed) {
#if defined(LIBOPENUI)
startCalibration();
#else
chainMenu(menuFirstCalib);
#endif // defined(LIBOPENUI)
}
else if (!(startOptions & OPENTX_START_NO_CHECKS)) {
checkAlarm();
checkAll();
PLAY_MODEL_NAME();
}
#endif // defined(GUI)

#if defined(BLUETOOTH_PROBE)
if (bluetooth.localAddr[0] != '\0')
btChipPresent = 1;
g_eeGeneral.bluetoothMode = oldBtMode;
#endif
}

#if !defined(RTC_BACKUP_RAM)
Expand Down
51 changes: 0 additions & 51 deletions radio/src/tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,59 +47,8 @@ TASK_FUNCTION(menusTask)
LvglWrapper::instance();
#endif

#if defined(SPLASH) && !defined(STARTUP_ANIMATION)
tmr10ms_t splashStartTime = 0;
bool waitSplash = false;
if (!UNEXPECTED_SHUTDOWN()) {
splashStartTime = get_tmr10ms();
waitSplash = true;
drawSplash();
TRACE("drawSplash() completed");
}
#endif

#if defined(HARDWARE_TOUCH) && !defined(PCBFLYSKY) && !defined(SIMU)
touchPanelInit();
#endif

opentxInit();

#if defined(SPLASH) && !defined(STARTUP_ANIMATION)
if (waitSplash){
extern bool inactivityCheckInputs();
extern void checkSpeakerVolume();

#if defined(SIMU)
// Simulator - inputsMoved() returns true immediately without this!
RTOS_WAIT_TICKS(30);
#endif

splashStartTime += SPLASH_TIMEOUT;
while (splashStartTime > get_tmr10ms()) {
WDG_RESET();
checkSpeakerVolume();
checkBacklight();
RTOS_WAIT_TICKS(10);
auto evt = getEvent();
if (evt || inactivityCheckInputs()) {
if (evt)
killEvents(evt);
break;
}
#if defined(SIMU)
// Allow simulator to exit if closed while splash showing
uint32_t pwr_check = pwrCheck();
if (pwr_check == e_power_off) {
break;
}
#endif
}

// Reset timer so special/global functions set to !1x don't get triggered
START_SILENCE_PERIOD();
}
#endif

mixerTaskInit();

#if defined(PWR_BUTTON_PRESS)
Expand Down

0 comments on commit e485db9

Please sign in to comment.