DSM: Throttle Kill option

This commit is contained in:
Pascal Langer 2018-11-20 16:54:55 +01:00
parent 1525e564cb
commit 6c7312a09c
4 changed files with 47 additions and 10 deletions

View File

@ -262,7 +262,9 @@ static void __attribute__((unused)) DSM_build_data_packet(uint8_t upper)
if(sub_protocol==DSM2_22)
bits=10; // Only DSM_22 is using a resolution of 1024
}
#ifdef DSM_THROTTLE_KILL_CH
uint32_t kill_ch=Channel_data[DSM_THROTTLE_KILL_CH];
#endif
for (uint8_t i = 0; i < 7; i++)
{
uint8_t idx = ch_map[(upper?7:0) + i];//1,5,2,3,0,4
@ -271,11 +273,22 @@ static void __attribute__((unused)) DSM_build_data_packet(uint8_t upper)
{
/* Spektrum own remotes transmit normal values during bind and actually use this (e.g. Nano CP X) to
select the transmitter mode (e.g. computer vs non-computer radio), so always send normal output */
#ifdef DSM_MAX_THROW
value=Channel_data[CH_TAER[idx]]; // -100%..+100% => 1024..1976us and -125%..+125% => 904..2096us based on Redcon 6 channel DSM2 RX
#else
value=convert_channel_16b_nolimit(CH_TAER[idx],0x150,0x6B0); // -100%..+100% => 1100..1900us and -125%..+125% => 1000..2000us based on Redcon 6 channel DSM2 RX
#ifdef DSM_THROTTLE_KILL_CH
if(CH_TAER[idx]==THROTTLE && kill_ch<=604)
{//Activate throttle kill only if DSM_THROTTLE_KILL_CH below -50%
if(kill_ch<CHANNEL_MIN_100) // restrict val to 0...400
kill_ch=0;
else
kill_ch-=CHANNEL_MIN_100;
value=(uint16_t)((kill_ch*0x150)/400); // kill channel -100%->904us ... -50%->1100us
}
else
#endif
#ifdef DSM_MAX_THROW
value=Channel_data[CH_TAER[idx]]; // -100%..+100% => 1024..1976us and -125%..+125% => 904..2096us based on Redcon 6 channel DSM2 RX
#else
value=convert_channel_16b_nolimit(CH_TAER[idx],0x150,0x6B0); // -100%..+100% => 1100..1900us and -125%..+125% => 1000..2000us based on Redcon 6 channel DSM2 RX
#endif
if(bits==10) value>>=1;
value |= (upper && i==0 ? 0x8000 : 0) | (idx << bits);
}

View File

@ -19,7 +19,7 @@
#define VERSION_MAJOR 1
#define VERSION_MINOR 2
#define VERSION_REVISION 1
#define VERSION_PATCH_LEVEL 16
#define VERSION_PATCH_LEVEL 17
//******************
// Protocols

View File

@ -273,6 +273,15 @@
#endif
#endif
#if defined(DSM_THROTTLE_KILL_CH)
#if DSM_THROTTLE_KILL_CH<4
#error DSM_THROTTLE_KILL_CH must be above 4.
#endif
#if DSM_THROTTLE_KILL_CH>16
#error DSM_THROTTLE_KILL_CH must be below or equal to 16.
#endif
#endif
#if MIN_PPM_CHANNELS>16
#error MIN_PPM_CHANNELS must be below or equal to 16. The default for this value is 4.
#endif

View File

@ -49,10 +49,6 @@
//#define REVERSE_THROTTLE
//#define REVERSE_RUDDER
//DSM protocol is using by default the Spektrum throw of 1100..1900us @100% and 1000..2000us @125%.
//For more throw, 1024..1976us @100% and 904..2096us @125%, remove the "//" on the line below. Be aware that too much throw can damage some UMX servos. To achieve standard throw in this mode use a channel weight of 84%.
//#define DSM_MAX_THROW
/*****************/
/*** AUTO BIND ***/ // Also referred as "Bind on powerup"
@ -200,6 +196,25 @@
#define V911S_NRF24L01_INO
#define YD717_NRF24L01_INO
/***************************/
/*** PROTOCOLS SETTINGS ***/
/***************************/
//DSM specific settings
//---------------------
//The DSM protocol is using by default the Spektrum throw of 1100..1900us @100% and 1000..2000us @125%.
// For more throw, 1024..1976us @100% and 904..2096us @125%, remove the "//" on the line below. Be aware that too much throw can damage some UMX servos. To achieve standard throw in this mode use a channel weight of 84%.
//#define DSM_MAX_THROW
//Some models (X-Vert, Balde 230S...) require a special value to instant stop the motor(s).
// You can disable this feature by adding "//" on the line below. You have to specify which channel (15 by default) will be used to kill the throttle channel.
// If the channel is between -50% and -100%, the throttle output will be forced between -100% and -150%. If the channel is above -50%, the throttle is untouched.
#define DSM_THROTTLE_KILL_CH 15
//AFHDS2A specific settings
//-------------------------
//TODO: make LQI available on RX channel
/**************************/
/*** FAILSAFE SETTINGS ***/
/**************************/