WFLY2: add failsafe (hold/no pulse not available yet)

This commit is contained in:
Pascal Langer 2020-12-16 16:14:45 +01:00
parent 6d38dd2d7a
commit 5ac41fdd15
13 changed files with 42 additions and 28 deletions

View File

@ -224,7 +224,7 @@ void A7105_AdjustLOBaseFreq(uint8_t cmd)
}
}
if(offset==1024) // Use channel 15 as an input
offset=convert_channel_16b_nolimit(CH15,-300,300);
offset=convert_channel_16b_nolimit(CH15,-300,300,false);
if(old_offset==offset) // offset is the same as before...
return;

View File

@ -184,7 +184,7 @@ static void __attribute__((unused)) DSM_build_data_packet(uint8_t upper)
if(option & 0x80)
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],0x156,0x6AA); // -100%..+100% => 1100..1900us and -125%..+125% => 1000..2000us based on a DX8 G2 dump
value=convert_channel_16b_nolimit(CH_TAER[idx],0x156,0x6AA,false); // -100%..+100% => 1100..1900us and -125%..+125% => 1000..2000us based on a DX8 G2 dump
#endif
if(bits==10) value>>=1;
value |= (upper && i==0 ? 0x8000 : 0) | (idx << bits);

View File

@ -146,7 +146,7 @@ static void __attribute__((unused)) DEVO_build_data_pkt()
uint8_t sign = 0x0b;
for (uint8_t i = 0; i < 4; i++)
{
int16_t value=convert_channel_16b_nolimit(CH_EATR[ch_idx * 4 + i],-1600,1600);//range -1600..+1600
int16_t value=convert_channel_16b_nolimit(CH_EATR[ch_idx * 4 + i],-1600,1600,false);//range -1600..+1600
if(value < 0)
{
value = -value;

View File

@ -182,7 +182,7 @@ static void __attribute__((unused)) SFHSS_build_data_packet()
#endif
{ //Normal data
for(uint8_t i=0;i<4;i++)
ch[i] = convert_channel_16b_nolimit(CH_AETR[ch_offset+i],2020,1020);
ch[i] = convert_channel_16b_nolimit(CH_AETR[ch_offset+i],2020,1020,false);
}

View File

@ -165,7 +165,7 @@ static void __attribute__((unused)) HITEC_build_packet()
packet[0] = 0x1A; // 26 bytes to follow
for(uint8_t i=0;i<9;i++)
{
uint16_t ch = convert_channel_16b_nolimit(i,0x1B87,0x3905);
uint16_t ch = convert_channel_16b_nolimit(i,0x1B87,0x3905,false);
packet[4+2*i] = ch >> 8;
packet[5+2*i] = ch & 0xFF;
}

View File

@ -196,7 +196,7 @@ static void __attribute__((unused)) MLINK_build_data_packet()
//Channels 426..1937..3448
for(uint8_t i=0;i<3;i++)
{
uint16_t tmp=ch[i]<16 ? convert_channel_16b_nolimit(ch[i],426,3448) : 0x0000;
uint16_t tmp=ch[i]<16 ? convert_channel_16b_nolimit(ch[i],426,3448,false) : 0x0000;
packet[i*2+1]=tmp>>8;
packet[i*2+2]=tmp;
}

View File

@ -454,7 +454,7 @@ enum MultiPacketTypes
//***************
//*** Tests ***
//***************
#define IS_FAILSAFE_PROTOCOL ( (protocol==PROTO_HISKY && sub_protocol==HK310) || protocol==PROTO_AFHDS2A || protocol==PROTO_DEVO || protocol==PROTO_FUTABA || protocol==PROTO_WK2x01 || protocol== PROTO_HOTT || protocol==PROTO_FRSKYX || protocol==PROTO_FRSKYX2 || protocol==PROTO_FRSKY_R9)
#define IS_FAILSAFE_PROTOCOL ( (protocol==PROTO_HISKY && sub_protocol==HK310) || protocol==PROTO_AFHDS2A || protocol==PROTO_DEVO || protocol==PROTO_FUTABA || protocol==PROTO_WK2x01 || protocol== PROTO_HOTT || protocol==PROTO_FRSKYX || protocol==PROTO_FRSKYX2 || protocol==PROTO_FRSKY_R9 || protocol==PROTO_WFLY2)
#define IS_CHMAP_PROTOCOL ( (protocol==PROTO_HISKY && sub_protocol==HK310) || protocol==PROTO_AFHDS2A || protocol==PROTO_DEVO || protocol==PROTO_FUTABA || protocol==PROTO_WK2x01 || protocol== PROTO_DSM || protocol==PROTO_SLT || protocol==PROTO_FLYSKY || (protocol==PROTO_KYOSHO && sub_protocol==KYOSHO_HYPE) || protocol==PROTO_ESKY || protocol==PROTO_J6PRO || protocol==PROTO_PELIKAN || protocol==PROTO_SKYARTEC || protocol==PROTO_ESKY150V2 || protocol==PROTO_DSM_RX)
//***************

View File

@ -56,16 +56,16 @@ static void __attribute__((unused)) pelikan_build_packet()
packet[13] = rx_tx_addr[3];
//Channels
uint8_t offset=upper?4:0;
uint16_t channel=convert_channel_16b_nolimit(CH_AETR[offset++], 153, 871);
uint16_t channel=convert_channel_16b_nolimit(CH_AETR[offset++], 153, 871,false);
uint8_t top=(channel>>2) & 0xC0;
packet[2] = channel;
channel=convert_channel_16b_nolimit(CH_AETR[offset++], 153, 871);
channel=convert_channel_16b_nolimit(CH_AETR[offset++], 153, 871,false);
top|=(channel>>4) & 0x30;
packet[3] = channel;
channel=convert_channel_16b_nolimit(CH_AETR[offset++], 153, 871);
channel=convert_channel_16b_nolimit(CH_AETR[offset++], 153, 871,false);
top|=(channel>>6) & 0x0C;
packet[4] = channel;
channel=convert_channel_16b_nolimit(CH_AETR[offset], 153, 871);
channel=convert_channel_16b_nolimit(CH_AETR[offset], 153, 871,false);
top|=(channel>>8) & 0x03;
packet[5] = channel;
packet[6] = top;

View File

@ -177,7 +177,7 @@ static void __attribute__((unused)) RLINK_send_packet()
// pack 16 channels on 11 bits values between 170 and 1876, 1023 middle. The last 8 channels are failsafe values associated to the first 8 values.
for (uint8_t i = 0; i < 16; i++)
{
uint32_t val = convert_channel_16b_nolimit(i,170,1876); // allow extended limits
uint32_t val = convert_channel_16b_nolimit(i,170,1876,false); // allow extended limits
if (val & 0x8000)
val = 0;
else if (val > 2047)

View File

@ -77,19 +77,19 @@ static void __attribute__((unused)) TRAXXAS_send_data_packet()
packet[0] = 0x01;
memset(&packet[1],0x00,TRAXXAS_PACKET_SIZE-1);
//Steering
uint16_t ch = convert_channel_16b_nolimit(RUDDER,500,1000);
uint16_t ch = convert_channel_16b_nolimit(RUDDER,500,1000,false);
packet[2]=ch>>8;
packet[3]=ch;
//Throttle
ch = convert_channel_16b_nolimit(THROTTLE,500,1000);
ch = convert_channel_16b_nolimit(THROTTLE,500,1000,false);
packet[4]=ch>>8;
packet[5]=ch;
//AUX3
ch = convert_channel_16b_nolimit(AILERON,500,1000);
ch = convert_channel_16b_nolimit(AILERON,500,1000,false);
packet[6]=ch>>8;
packet[7]=ch;
//AUX4???
ch = convert_channel_16b_nolimit(ELEVATOR,500,1000);
ch = convert_channel_16b_nolimit(ELEVATOR,500,1000,false);
packet[12]=ch>>8;
packet[13]=ch;

View File

@ -32,6 +32,7 @@ enum{
static void __attribute__((unused)) WFLY2_build_packet()
{
static uint16_t pseudo=0;
uint8_t offset=0;
//End bind
if(IS_BIND_IN_PROGRESS && bind_counter)
@ -73,6 +74,15 @@ static void __attribute__((unused)) WFLY2_build_packet()
{
//Header
//packet[0] = 0x00; // Normal packet
#ifdef FAILSAFE_ENABLE
if(IS_FAILSAFE_VALUES_on)
{
packet[0] = 0x01; //Failsafe packet
packet[5] = 0x58; // unknown, values are counting 58,59,5A,5B and rollover
packet[6] = 0x55; // unknown and constant
offset=2;
}
#endif
//Pseudo
uint16_t high_bit=(pseudo & 0x8000) ^ 0x8000; // toggle 0x8000 every other line
@ -104,15 +114,19 @@ static void __attribute__((unused)) WFLY2_build_packet()
//10 channels -100%=0x2C1...0%=0x800...+100%=0xD3F
for(uint8_t i = 0; i < 5; i++)
{
uint16_t temp=convert_channel_16b_nolimit(i*2 , 0x2C1, 0xD3F);
packet[5 + i*3] = temp&0xFF; // low byte
packet[7 + i*3] = (temp>>8)&0x0F; // high byte
temp=convert_channel_16b_nolimit(i*2+1, 0x2C1, 0xD3F);
packet[6 + i*3] = temp&0xFF; // low byte
packet[7 + i*3] |= (temp>>4)&0xF0; // high byte
uint16_t temp=convert_channel_16b_nolimit(i*2 , 0x2C1, 0xD3F, IS_FAILSAFE_VALUES_on);
packet[5 + offset + i*3] = temp&0xFF; // low byte
packet[7 + offset + i*3] = (temp>>8)&0x0F; // high byte
temp=convert_channel_16b_nolimit(i*2+1, 0x2C1, 0xD3F, IS_FAILSAFE_VALUES_on);
packet[6 + offset + i*3] = temp&0xFF; // low byte
packet[7 + offset + i*3] |= (temp>>4)&0xF0; // high byte
}
//Unknown bytes 20..31
//Unknown bytes 20+offset..31
#ifdef FAILSAFE_ENABLE
FAILSAFE_VALUES_off;
#endif
}
//Debug

View File

@ -105,23 +105,23 @@ static uint16_t __attribute__((unused)) WFLY_send_data_packet()
len=4;
for(uint8_t i=0;i<3;i++)
{ // Channels
uint16_t ch = convert_channel_16b_nolimit(i*4+0,151,847);
uint16_t ch = convert_channel_16b_nolimit(i*4+0,151,847,false);
uint8_t offset=i*5;
packet[3+offset]|=ch<<6;
packet[4+offset]=ch>>2;
len++;
if(--nbr_ch==0) break;
ch = convert_channel_16b_nolimit(i*4+1,151,847);
ch = convert_channel_16b_nolimit(i*4+1,151,847,false);
packet[5+offset]=ch;
packet[6+offset]=ch>>8;
len+=2;
if(--nbr_ch==0) break;
ch = convert_channel_16b_nolimit(i*4+2,151,847);
ch = convert_channel_16b_nolimit(i*4+2,151,847,false);
packet[6+offset]|=ch<<2;
packet[7+offset]=ch>>6;
len++;
if(--nbr_ch==0) break;
ch = convert_channel_16b_nolimit(i*4+3,151,847);
ch = convert_channel_16b_nolimit(i*4+3,151,847,false);
packet[7+offset]|=ch<<4;
packet[8+offset]=ch>>4;
len++;

View File

@ -79,7 +79,7 @@ static void __attribute__((unused)) WK_build_bind_pkt(const uint8_t *init)
static int16_t __attribute__((unused)) WK_get_channel(uint8_t ch, int32_t scale, int16_t center, int16_t range)
{
int16_t value = convert_channel_16b_nolimit(CH_AETR[ch],-scale,scale)+center;
int16_t value = convert_channel_16b_nolimit(CH_AETR[ch],-scale,scale,false)+center;
if (value < center - range) value = center - range;
if (value > center + range) value = center + range;
return value;