1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-22 07:45:14 +03:00
This commit is contained in:
bsongis 2014-05-05 10:36:34 +02:00
parent 1466f96e51
commit be3c674fe5
4 changed files with 28 additions and 22 deletions

View file

@ -320,6 +320,7 @@ void per10ms()
if (flashCounter) flashCounter--;
if (s_noHi) s_noHi--;
if (trimsCheckTimer) trimsCheckTimer--;
if (ppmInValid) ppmInValid--;
#if defined(RTCLOCK)
/* Update global Date/Time every 100 per10ms cycles */
@ -3196,7 +3197,7 @@ void evalInputs(uint8_t mode)
}
#endif
if (mode <= e_perout_mode_inactive_phase && isFunctionActive(FUNCTION_TRAINER+ch)) {
if (mode <= e_perout_mode_inactive_phase && isFunctionActive(FUNCTION_TRAINER+ch) && ppmInValid) {
// trainer mode
TrainerMix* td = &g_eeGeneral.trainer.mix[ch];
if (td->mode) {
@ -3823,6 +3824,10 @@ void perOut(uint8_t mode, uint8_t tick10ms)
bool mixCondition = (md->phases != 0 || md->swtch);
delayval_t mixEnabled = !(md->phases & (1 << s_perout_flight_phase)) && getSwitch(md->swtch);
if (mixEnabled && md->srcRaw >= MIXSRC_FIRST_TRAINER && md->srcRaw <= MIXSRC_LAST_TRAINER && !ppmInValid) {
mixEnabled = 0;
}
//========== VALUE ===============
getvalue_t v = 0;
if (mode > e_perout_mode_inactive_phase) {
@ -5046,6 +5051,7 @@ void perMain()
int16_t g_ppmIns[NUM_TRAINER];
uint8_t ppmInState = 0; // 0=unsync 1..8= wait for value i-1
uint8_t ppmInValid = 0;
#if !defined(SIMU) && !defined(CPUARM)
@ -5132,21 +5138,20 @@ ISR(TIMER3_CAPT_vect) // G: High frequency noise can cause stack overflo with IS
// G: We process g_ppmIns immediately here, to make servo movement as smooth as possible
// while under trainee control
if (val>4000 && val < 16000) // G: Prioritize reset pulse. (Needed when less than 8 incoming pulses)
if (val>4000 && val < 16000) { // G: Prioritize reset pulse. (Needed when less than 8 incoming pulses)
ppmInState = 1; // triggered
else
{
if (ppmInState && ppmInState<=8)
{
if (val>800 && val<2200) // if valid pulse-width range
{
g_ppmIns[ppmInState++ - 1] =
(int16_t)(val - 1500)*(g_eeGeneral.PPM_Multiplier+10)/10; //+-500 != 512, but close enough.
}
else
else {
if (ppmInState>0 && ppmInState<=8) {
if (val>800 && val<2200) { // if valid pulse-width range
ppmInValid = 100;
g_ppmIns[ppmInState++ - 1] = (int16_t)(val - 1500) * (uint8_t)(g_eeGeneral.PPM_Multiplier+10)/10; //+-500 != 512, but close enough.
}
else {
ppmInState = 0; // not triggered
}
}
}
lastCapt = capture;

View file

@ -1013,6 +1013,7 @@ extern uint8_t g_beepCnt;
extern uint8_t g_beepVal[5];
extern uint8_t ppmInState; //0=unsync 1..8= wait for value i-1
extern uint8_t ppmInValid;
extern int16_t g_ppmIns[NUM_TRAINER];
extern int32_t chans[NUM_CHNOUT];
extern int16_t ex_chans[NUM_CHNOUT]; // Outputs (before LIMITS) of the last perMain

View file

@ -314,17 +314,16 @@ extern "C" void TC3_IRQHandler() //capture ppm in at 2MHz
ppmInState = 1; // triggered
}
else {
if (ppmInState && ppmInState<=16)
{
if (val>800 && val<2200) // if valid pulse-width range
{
g_ppmIns[ppmInState++ - 1] =
(int16_t)(val - 1500)*(g_eeGeneral.PPM_Multiplier+10)/10; //+-500 != 512, but close enough.
if (ppmInState>0 && ppmInState<=16) {
if (val>800 && val<2200) { // if valid pulse-width range
ppmInValid = 100;
g_ppmIns[ppmInState++ - 1] = (int16_t)(val - 1500)*(g_eeGeneral.PPM_Multiplier+10)/10; //+-500 != 512, but close enough.
}
else
else {
ppmInState = 0; // not triggered
}
}
}
lastCapt = capture;
}

View file

@ -126,12 +126,13 @@ extern "C" void TIM3_IRQHandler()
// We process g_ppmInsright here to make servo movement as smooth as possible
// while under trainee control
if ((val>4000) && (val < 19000)) { // G: Prioritize reset pulse. (Needed when less than 16 incoming pulses)
if (val>4000 && val<19000) { // G: Prioritize reset pulse. (Needed when less than 16 incoming pulses)
ppmInState = 1; // triggered
}
else {
if (ppmInState && (ppmInState<=16)) {
if ((val>800) && (val<2200)) {
if (ppmInState>0 && ppmInState<=16) {
if (val>800 && val<2200) {
ppmInValid = 100;
g_ppmIns[ppmInState++ - 1] = (int16_t)(val - 1500)*(g_eeGeneral.PPM_Multiplier+10)/10; //+-500 != 512, but close enough.
}
else {