@@ -197,6 +197,10 @@ void logsWrite()
|
||||
{
|
||||
static const char * error_displayed = nullptr;
|
||||
|
||||
if (!sdMounted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isFunctionActive(FUNCTION_LOGS) && logDelay > 0) {
|
||||
tmr10ms_t tmr10ms = get_tmr10ms();
|
||||
if (lastLogTime == 0 || (tmr10ms_t)(tmr10ms - lastLogTime) >= (tmr10ms_t)logDelay*10) {
|
||||
|
||||
+34
-28
@@ -42,34 +42,35 @@ void onUSBConnectMenu(const char *result)
|
||||
void handleUsbConnection()
|
||||
{
|
||||
#if defined(STM32) && !defined(SIMU)
|
||||
if (!usbStarted() && usbPlugged() && !(getSelectedUsbMode() == USB_UNSELECTED_MODE)) {
|
||||
usbStart();
|
||||
if (getSelectedUsbMode() == USB_MASS_STORAGE_MODE) {
|
||||
opentxClose(false);
|
||||
usbPluggedIn();
|
||||
}
|
||||
}
|
||||
if (!usbStarted() && usbPlugged() && getSelectedUsbMode() == USB_UNSELECTED_MODE) {
|
||||
if (g_eeGeneral.USBMode == USB_UNSELECTED_MODE && popupMenuItemsCount == 0) {
|
||||
POPUP_MENU_ADD_ITEM(STR_USB_JOYSTICK);
|
||||
POPUP_MENU_ADD_ITEM(STR_USB_MASS_STORAGE);
|
||||
if (!usbStarted() && usbPlugged()) {
|
||||
if (getSelectedUsbMode() == USB_UNSELECTED_MODE) {
|
||||
if (g_eeGeneral.USBMode == USB_UNSELECTED_MODE && popupMenuItemsCount == 0) {
|
||||
POPUP_MENU_ADD_ITEM(STR_USB_JOYSTICK);
|
||||
POPUP_MENU_ADD_ITEM(STR_USB_MASS_STORAGE);
|
||||
#if defined(DEBUG)
|
||||
POPUP_MENU_ADD_ITEM(STR_USB_SERIAL);
|
||||
POPUP_MENU_ADD_ITEM(STR_USB_SERIAL);
|
||||
#endif
|
||||
POPUP_MENU_START(onUSBConnectMenu);
|
||||
POPUP_MENU_START(onUSBConnectMenu);
|
||||
}
|
||||
else {
|
||||
setSelectedUsbMode(g_eeGeneral.USBMode);
|
||||
}
|
||||
}
|
||||
if (g_eeGeneral.USBMode != USB_UNSELECTED_MODE) {
|
||||
setSelectedUsbMode(g_eeGeneral.USBMode);
|
||||
else {
|
||||
if (getSelectedUsbMode() == USB_MASS_STORAGE_MODE) {
|
||||
opentxClose(false);
|
||||
usbPluggedIn();
|
||||
}
|
||||
usbStart();
|
||||
}
|
||||
}
|
||||
|
||||
if (usbStarted() && !usbPlugged()) {
|
||||
usbStop();
|
||||
if (getSelectedUsbMode() == USB_MASS_STORAGE_MODE) {
|
||||
opentxResume();
|
||||
}
|
||||
#if !defined(BOOT)
|
||||
setSelectedUsbMode(USB_UNSELECTED_MODE);
|
||||
#endif
|
||||
}
|
||||
#endif // defined(STM32) && !defined(SIMU)
|
||||
}
|
||||
@@ -157,12 +158,10 @@ void checkSpeakerVolume()
|
||||
#if defined(EEPROM)
|
||||
void checkEeprom()
|
||||
{
|
||||
if (!usbPlugged()) {
|
||||
if (eepromIsWriting())
|
||||
eepromWriteProcess();
|
||||
else if (TIME_TO_WRITE())
|
||||
storageCheck(false);
|
||||
}
|
||||
if (eepromIsWriting())
|
||||
eepromWriteProcess();
|
||||
else if (TIME_TO_WRITE())
|
||||
storageCheck(false);
|
||||
}
|
||||
#else
|
||||
void checkEeprom()
|
||||
@@ -483,13 +482,20 @@ void perMain()
|
||||
#if defined(PCBSKY9X)
|
||||
calcConsumption();
|
||||
#endif
|
||||
|
||||
checkSpeakerVolume();
|
||||
checkEeprom();
|
||||
logsWrite();
|
||||
|
||||
if (!usbPlugged()) {
|
||||
checkEeprom();
|
||||
logsWrite();
|
||||
}
|
||||
|
||||
handleUsbConnection();
|
||||
|
||||
#if defined(PCBXLITES)
|
||||
handleJackConnection();
|
||||
#endif
|
||||
|
||||
checkTrainerSettings();
|
||||
periodicTick();
|
||||
DEBUG_TIMER_STOP(debugTimerPerMain1);
|
||||
@@ -500,7 +506,7 @@ void perMain()
|
||||
mainRequestFlags &= ~(1 << REQUEST_FLIGHT_RESET);
|
||||
}
|
||||
|
||||
doLoopCommonActions();
|
||||
checkBacklight();
|
||||
|
||||
event_t evt = getEvent(false);
|
||||
|
||||
@@ -512,14 +518,14 @@ void perMain()
|
||||
#endif
|
||||
|
||||
#if defined(STM32)
|
||||
if (SD_CARD_PRESENT() && !sdMounted()) {
|
||||
if (!usbPlugged() && SD_CARD_PRESENT() && !sdMounted()) {
|
||||
sdMount();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(EEPROM)
|
||||
// In case the SD card is removed during the session
|
||||
if (!SD_CARD_PRESENT() && !globalData.unexpectedShutdown) {
|
||||
if (!usbPlugged() && !SD_CARD_PRESENT() && !globalData.unexpectedShutdown) {
|
||||
drawFatalErrorScreen(STR_NO_SDCARD);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -712,11 +712,6 @@ void checkBacklight()
|
||||
}
|
||||
}
|
||||
|
||||
void doLoopCommonActions()
|
||||
{
|
||||
checkBacklight();
|
||||
}
|
||||
|
||||
void backlightOn()
|
||||
{
|
||||
lightOffCounter = ((uint16_t)g_eeGeneral.lightAutoOff*250) << 1;
|
||||
@@ -802,7 +797,7 @@ void doSplash()
|
||||
}
|
||||
#endif
|
||||
|
||||
doLoopCommonActions();
|
||||
checkBacklight();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1021,7 +1016,7 @@ void checkThrottleStick()
|
||||
}
|
||||
#endif
|
||||
|
||||
doLoopCommonActions();
|
||||
checkBacklight();
|
||||
|
||||
WDG_RESET();
|
||||
|
||||
@@ -1060,7 +1055,7 @@ void alert(const char * title, const char * msg , uint8_t sound)
|
||||
if (keyDown()) // wait for key release
|
||||
break;
|
||||
|
||||
doLoopCommonActions();
|
||||
checkBacklight();
|
||||
|
||||
WDG_RESET();
|
||||
|
||||
@@ -1591,8 +1586,9 @@ void opentxClose(uint8_t shutdown)
|
||||
{
|
||||
TRACE("opentxClose");
|
||||
|
||||
watchdogSuspend(2000/*20s*/);
|
||||
|
||||
if (shutdown) {
|
||||
watchdogSuspend(2000/*20s*/);
|
||||
pausePulses(); // stop mixer task to disable trims processing while in shutdown
|
||||
AUDIO_BYE();
|
||||
// TODO needed? telemetryEnd();
|
||||
|
||||
@@ -642,7 +642,6 @@ static inline void GET_ADC_IF_MIXER_NOT_RUNNING()
|
||||
|
||||
void backlightOn();
|
||||
void checkBacklight();
|
||||
void doLoopCommonActions();
|
||||
|
||||
#define BITMASK(bit) (1<<(bit))
|
||||
|
||||
|
||||
@@ -766,7 +766,7 @@ void checkSwitches()
|
||||
}
|
||||
#endif
|
||||
|
||||
doLoopCommonActions();
|
||||
checkBacklight();
|
||||
|
||||
WDG_RESET();
|
||||
|
||||
|
||||
@@ -1026,7 +1026,7 @@ void sdDone()
|
||||
#if defined(LOG_TELEMETRY)
|
||||
f_close(&g_telemetryFile);
|
||||
#endif
|
||||
f_mount(NULL, "", 0); // unmount SD
|
||||
f_mount(nullptr, "", 0); // unmount SD
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user