mirror of
https://github.com/opentx/opentx.git
synced 2025-07-22 15:55:26 +03:00
Fixes #36
This commit is contained in:
parent
1466f96e51
commit
be3c674fe5
4 changed files with 28 additions and 22 deletions
|
@ -320,6 +320,7 @@ void per10ms()
|
||||||
if (flashCounter) flashCounter--;
|
if (flashCounter) flashCounter--;
|
||||||
if (s_noHi) s_noHi--;
|
if (s_noHi) s_noHi--;
|
||||||
if (trimsCheckTimer) trimsCheckTimer--;
|
if (trimsCheckTimer) trimsCheckTimer--;
|
||||||
|
if (ppmInValid) ppmInValid--;
|
||||||
|
|
||||||
#if defined(RTCLOCK)
|
#if defined(RTCLOCK)
|
||||||
/* Update global Date/Time every 100 per10ms cycles */
|
/* Update global Date/Time every 100 per10ms cycles */
|
||||||
|
@ -3196,7 +3197,7 @@ void evalInputs(uint8_t mode)
|
||||||
}
|
}
|
||||||
#endif
|
#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
|
// trainer mode
|
||||||
TrainerMix* td = &g_eeGeneral.trainer.mix[ch];
|
TrainerMix* td = &g_eeGeneral.trainer.mix[ch];
|
||||||
if (td->mode) {
|
if (td->mode) {
|
||||||
|
@ -3823,6 +3824,10 @@ void perOut(uint8_t mode, uint8_t tick10ms)
|
||||||
bool mixCondition = (md->phases != 0 || md->swtch);
|
bool mixCondition = (md->phases != 0 || md->swtch);
|
||||||
delayval_t mixEnabled = !(md->phases & (1 << s_perout_flight_phase)) && getSwitch(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 ===============
|
//========== VALUE ===============
|
||||||
getvalue_t v = 0;
|
getvalue_t v = 0;
|
||||||
if (mode > e_perout_mode_inactive_phase) {
|
if (mode > e_perout_mode_inactive_phase) {
|
||||||
|
@ -5046,6 +5051,7 @@ void perMain()
|
||||||
|
|
||||||
int16_t g_ppmIns[NUM_TRAINER];
|
int16_t g_ppmIns[NUM_TRAINER];
|
||||||
uint8_t ppmInState = 0; // 0=unsync 1..8= wait for value i-1
|
uint8_t ppmInState = 0; // 0=unsync 1..8= wait for value i-1
|
||||||
|
uint8_t ppmInValid = 0;
|
||||||
|
|
||||||
#if !defined(SIMU) && !defined(CPUARM)
|
#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
|
// G: We process g_ppmIns immediately here, to make servo movement as smooth as possible
|
||||||
// while under trainee control
|
// 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
|
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
|
ppmInState = 0; // not triggered
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lastCapt = capture;
|
lastCapt = capture;
|
||||||
|
|
||||||
|
|
|
@ -1013,6 +1013,7 @@ extern uint8_t g_beepCnt;
|
||||||
extern uint8_t g_beepVal[5];
|
extern uint8_t g_beepVal[5];
|
||||||
|
|
||||||
extern uint8_t ppmInState; //0=unsync 1..8= wait for value i-1
|
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 int16_t g_ppmIns[NUM_TRAINER];
|
||||||
extern int32_t chans[NUM_CHNOUT];
|
extern int32_t chans[NUM_CHNOUT];
|
||||||
extern int16_t ex_chans[NUM_CHNOUT]; // Outputs (before LIMITS) of the last perMain
|
extern int16_t ex_chans[NUM_CHNOUT]; // Outputs (before LIMITS) of the last perMain
|
||||||
|
|
|
@ -314,17 +314,16 @@ extern "C" void TC3_IRQHandler() //capture ppm in at 2MHz
|
||||||
ppmInState = 1; // triggered
|
ppmInState = 1; // triggered
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (ppmInState && ppmInState<=16)
|
if (ppmInState>0 && ppmInState<=16) {
|
||||||
{
|
if (val>800 && val<2200) { // if valid pulse-width range
|
||||||
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.
|
||||||
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
|
ppmInState = 0; // not triggered
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lastCapt = capture;
|
lastCapt = capture;
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,12 +126,13 @@ extern "C" void TIM3_IRQHandler()
|
||||||
|
|
||||||
// We process g_ppmInsright here to make servo movement as smooth as possible
|
// We process g_ppmInsright here to make servo movement as smooth as possible
|
||||||
// while under trainee control
|
// 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
|
ppmInState = 1; // triggered
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (ppmInState && (ppmInState<=16)) {
|
if (ppmInState>0 && ppmInState<=16) {
|
||||||
if ((val>800) && (val<2200)) {
|
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.
|
g_ppmIns[ppmInState++ - 1] = (int16_t)(val - 1500)*(g_eeGeneral.PPM_Multiplier+10)/10; //+-500 != 512, but close enough.
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue