Merge d312a823902262052b6b5eeb7d8dd431fce107f2 into 6535f6469986872daf4123639ca8007099c897bb

This commit is contained in:
tipouic 2017-11-20 18:13:08 +00:00 committed by GitHub
commit 917053a18e
2 changed files with 30 additions and 5 deletions

View File

@ -374,8 +374,13 @@ void setup()
if(PPM_prot[mode_select].power) POWER_FLAG_on; if(PPM_prot[mode_select].power) POWER_FLAG_on;
if(PPM_prot[mode_select].autobind) AUTOBIND_FLAG_on; if(PPM_prot[mode_select].autobind) AUTOBIND_FLAG_on;
mode_select++; mode_select++;
servo_max_100=PPM_MAX_100; servo_min_100=PPM_MIN_100; #ifdef PPM_MAP
servo_max_125=PPM_MAX_125; servo_min_125=PPM_MIN_125; servo_max_100=SERIAL_MAX_100; servo_min_100=SERIAL_MIN_100;
servo_max_125=SERIAL_MAX_125; servo_min_125=SERIAL_MIN_125;
#else
servo_max_100=PPM_MAX_100; servo_min_100=PPM_MIN_100;
servo_max_125=PPM_MAX_125; servo_min_125=PPM_MIN_125;
#endif // PPM_MAP
protocol_init(); protocol_init();
@ -520,15 +525,30 @@ uint8_t Update_All()
#ifdef ENABLE_PPM #ifdef ENABLE_PPM
if(mode_select!=MODE_SERIAL && IS_PPM_FLAG_on) // PPM mode and a full frame has been received if(mode_select!=MODE_SERIAL && IS_PPM_FLAG_on) // PPM mode and a full frame has been received
{ {
#ifdef PPM_CHG
boolean PPM_CHG_is_on = (PPM_data[PPM_CHG-1]>PPM_MAX_COMMAND) ? 1 : 0;
#endif // PPM_CHG
for(uint8_t i=0;i<MAX_PPM_CHANNELS;i++) for(uint8_t i=0;i<MAX_PPM_CHANNELS;i++)
{ // update servo data without interrupts to prevent bad read in protocols { // update servo data without interrupts to prevent bad read in protocols
uint16_t temp_ppm ; uint16_t temp_ppm ;
cli(); // disable global int cli(); // disable global int
temp_ppm = PPM_data[i] ; temp_ppm = PPM_data[i] ;
sei(); // enable global int sei(); // enable global int
if(temp_ppm<PPM_MIN_125) temp_ppm=PPM_MIN_125; #ifdef PPM_MAP
else if(temp_ppm>PPM_MAX_125) temp_ppm=PPM_MAX_125; temp_ppm = map(temp_ppm, PPM_MIN_100, PPM_MAX_100, SERIAL_MIN_100, SERIAL_MAX_100);
Servo_data[i]= temp_ppm ; if(temp_ppm<SERIAL_MIN_125) temp_ppm=SERIAL_MIN_125;
else if(temp_ppm>SERIAL_MAX_125) temp_ppm=SERIAL_MAX_125;
#else
if(temp_ppm<PPM_MIN_125) temp_ppm=PPM_MIN_125;
else if(temp_ppm>PPM_MAX_125) temp_ppm=PPM_MAX_125;
#endif // PPM_MAP
#ifdef PPM_CHG
if(PPM_CHG_is_on && i == PPM_CHG_A) { Servo_data[PPM_CHG_B]= temp_ppm ; } else
if(PPM_CHG_is_on && i == PPM_CHG_B) { Servo_data[PPM_CHG_A]= temp_ppm ; } else
#endif // PPM_CHG
{
Servo_data[i]= temp_ppm ;
}
} }
PPM_FLAG_off; // wait for next frame before update PPM_FLAG_off; // wait for next frame before update
update_channels_aux(); update_channels_aux();

View File

@ -250,6 +250,11 @@ const int8_t AFHDS2AFailsafe[14]= {
#define PPM_MIN_100 1100 // 100% #define PPM_MIN_100 1100 // 100%
#define PPM_MAX_125 2000 // 125% #define PPM_MAX_125 2000 // 125%
#define PPM_MIN_125 1000 // 125% #define PPM_MIN_125 1000 // 125%
#define PPM_MAP 1 // MAP PPM to SERIAL
#define PPM_CHG 5 // channel for switch ELEVATOR / RUDDER
#define PPM_CHG_A ELEVATOR // channel for switch ELEVATOR / RUDDER
#define PPM_CHG_B AILERON // channel for switch ELEVATOR / RUDDER
#endif #endif
// The line below is used to set the minimum number of channels which the module should receive to consider a PPM frame valid. // The line below is used to set the minimum number of channels which the module should receive to consider a PPM frame valid.