5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
23 int16_t ppmInput
[MAX_TRAINER_CHANNELS
];
24 uint8_t ppmInputValidityTimer
;
25 uint8_t currentTrainerMode
= 0xff;
27 void checkTrainerSignalWarning()
29 enum PpmInValidState_t
{
35 static uint8_t ppmInputValidState
= PPM_IN_IS_NOT_USED
;
37 if (ppmInputValidityTimer
&& (ppmInputValidState
== PPM_IN_IS_NOT_USED
)) {
38 ppmInputValidState
= PPM_IN_IS_VALID
;
40 else if (!ppmInputValidityTimer
&& (ppmInputValidState
== PPM_IN_IS_VALID
)) {
41 ppmInputValidState
= PPM_IN_INVALID
;
44 else if (ppmInputValidityTimer
&& (ppmInputValidState
== PPM_IN_INVALID
)) {
45 ppmInputValidState
= PPM_IN_IS_VALID
;
51 void checkTrainerSettings()
53 uint8_t requiredTrainerMode
= SLAVE_MODE();
55 if (requiredTrainerMode
!= currentTrainerMode
) {
56 currentTrainerMode
= requiredTrainerMode
;
57 if (requiredTrainerMode
)
58 stop_trainer_capture();
60 init_trainer_capture();
64 void checkTrainerSettings()
66 uint8_t requiredTrainerMode
= g_model
.trainerData
.mode
;
68 if (requiredTrainerMode
!= currentTrainerMode
) {
69 switch (currentTrainerMode
) {
70 case TRAINER_MODE_MASTER_TRAINER_JACK
:
71 stop_trainer_capture();
74 case TRAINER_MODE_SLAVE
:
78 #if defined(TRAINER_MODULE_CPPM)
79 case TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE
:
80 stop_trainer_module_cppm();
84 #if defined(TRAINER_MODULE_SBUS)
85 case TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE
:
86 stop_trainer_module_sbus();
90 #if defined(TRAINER_BATTERY_COMPARTMENT)
91 case TRAINER_MODE_MASTER_BATTERY_COMPARTMENT
:
97 currentTrainerMode
= requiredTrainerMode
;
99 switch (requiredTrainerMode
) {
100 case TRAINER_MODE_SLAVE
:
104 #if defined(TRAINER_MODULE_CPPM)
105 case TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE
:
106 init_trainer_module_cppm();
110 #if defined(TRAINER_MODULE_SBUS)
111 case TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE
:
112 init_trainer_module_sbus();
116 #if defined(TRAINER_BATTERY_COMPARTMENT)
117 case TRAINER_MODE_MASTER_BATTERY_COMPARTMENT
:
118 if (g_eeGeneral
.auxSerialMode
== UART_MODE_SBUS_TRAINER
)
121 init_trainer_capture();
125 case TRAINER_MODE_MASTER_TRAINER_JACK
:
126 init_trainer_capture();
130 #if defined(TRAINER_MODULE_CPPM) || defined(TRAINER_MODULE_SBUS)
131 if (requiredTrainerMode
== TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE
|| requiredTrainerMode
== TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE
)
132 stop_intmodule_heartbeat();
134 init_intmodule_heartbeat();
136 init_intmodule_heartbeat();