Stop trainers before changing model (#8075)
Turn off SBUS trainer to allow model switch
This commit is contained in:
@@ -51,8 +51,9 @@ void preModelLoad()
|
|||||||
if (pulsesStarted()) {
|
if (pulsesStarted()) {
|
||||||
pausePulses();
|
pausePulses();
|
||||||
}
|
}
|
||||||
|
|
||||||
pauseMixerCalculations();
|
pauseMixerCalculations();
|
||||||
|
|
||||||
|
stopTrainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void postRadioSettingsLoad()
|
void postRadioSettingsLoad()
|
||||||
|
|||||||
+48
-34
@@ -48,6 +48,11 @@ void checkTrainerSignalWarning()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PCBSKY9X)
|
#if defined(PCBSKY9X)
|
||||||
|
void stopTrainer()
|
||||||
|
{
|
||||||
|
stop_trainer_capture();
|
||||||
|
}
|
||||||
|
|
||||||
void checkTrainerSettings()
|
void checkTrainerSettings()
|
||||||
{
|
{
|
||||||
uint8_t requiredTrainerMode = SLAVE_MODE();
|
uint8_t requiredTrainerMode = SLAVE_MODE();
|
||||||
@@ -55,50 +60,59 @@ void checkTrainerSettings()
|
|||||||
if (requiredTrainerMode != currentTrainerMode) {
|
if (requiredTrainerMode != currentTrainerMode) {
|
||||||
currentTrainerMode = requiredTrainerMode;
|
currentTrainerMode = requiredTrainerMode;
|
||||||
if (requiredTrainerMode)
|
if (requiredTrainerMode)
|
||||||
stop_trainer_capture();
|
stopTrainer();
|
||||||
else
|
else
|
||||||
init_trainer_capture();
|
init_trainer_capture();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
void stopTrainer()
|
||||||
|
{
|
||||||
|
switch (currentTrainerMode) {
|
||||||
|
case TRAINER_MODE_MASTER_TRAINER_JACK:
|
||||||
|
stop_trainer_capture();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TRAINER_MODE_SLAVE:
|
||||||
|
stop_trainer_ppm();
|
||||||
|
break;
|
||||||
|
|
||||||
|
#if defined(TRAINER_MODULE_CPPM)
|
||||||
|
case TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE:
|
||||||
|
stop_trainer_module_cppm();
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TRAINER_MODULE_SBUS)
|
||||||
|
case TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE:
|
||||||
|
stop_trainer_module_sbus();
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TRAINER_BATTERY_COMPARTMENT)
|
||||||
|
case TRAINER_MODE_MASTER_BATTERY_COMPARTMENT:
|
||||||
|
#if defined(AUX_SERIAL)
|
||||||
|
if (g_eeGeneral.auxSerialMode == UART_MODE_SBUS_TRAINER)
|
||||||
|
auxSerialStop();
|
||||||
|
#endif
|
||||||
|
#if defined(AUX2_SERIAL)
|
||||||
|
if (g_eeGeneral.aux2SerialMode == UART_MODE_SBUS_TRAINER)
|
||||||
|
aux2SerialStop();
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
currentTrainerMode = 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
void checkTrainerSettings()
|
void checkTrainerSettings()
|
||||||
{
|
{
|
||||||
uint8_t requiredTrainerMode = g_model.trainerData.mode;
|
uint8_t requiredTrainerMode = g_model.trainerData.mode;
|
||||||
|
|
||||||
if (requiredTrainerMode != currentTrainerMode) {
|
if (requiredTrainerMode != currentTrainerMode) {
|
||||||
switch (currentTrainerMode) {
|
if (currentTrainerMode != 0xFF) {
|
||||||
case TRAINER_MODE_MASTER_TRAINER_JACK:
|
stopTrainer();
|
||||||
stop_trainer_capture();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TRAINER_MODE_SLAVE:
|
|
||||||
stop_trainer_ppm();
|
|
||||||
break;
|
|
||||||
|
|
||||||
#if defined(TRAINER_MODULE_CPPM)
|
|
||||||
case TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE:
|
|
||||||
stop_trainer_module_cppm();
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(TRAINER_MODULE_SBUS)
|
|
||||||
case TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE:
|
|
||||||
stop_trainer_module_sbus();
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(TRAINER_BATTERY_COMPARTMENT)
|
|
||||||
case TRAINER_MODE_MASTER_BATTERY_COMPARTMENT:
|
|
||||||
#if defined(AUX_SERIAL)
|
|
||||||
if (g_eeGeneral.auxSerialMode == UART_MODE_SBUS_TRAINER)
|
|
||||||
auxSerialStop();
|
|
||||||
#endif
|
|
||||||
#if defined(AUX2_SERIAL)
|
|
||||||
if (g_eeGeneral.aux2SerialMode == UART_MODE_SBUS_TRAINER)
|
|
||||||
aux2SerialStop();
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
currentTrainerMode = requiredTrainerMode;
|
currentTrainerMode = requiredTrainerMode;
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ extern uint8_t currentTrainerMode;
|
|||||||
|
|
||||||
void checkTrainerSignalWarning();
|
void checkTrainerSignalWarning();
|
||||||
void checkTrainerSettings();
|
void checkTrainerSettings();
|
||||||
|
void stopTrainer();
|
||||||
void forceResetTrainerSettings();
|
void forceResetTrainerSettings();
|
||||||
|
|
||||||
// Needs to be inlined to avoid slow function calls in ISR routines
|
// Needs to be inlined to avoid slow function calls in ISR routines
|
||||||
|
|||||||
Reference in New Issue
Block a user