mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-02-09 22:58:14 +00:00
AFHDS2A update RF channels and Failsafe
You need to bind all the RXs again...
This commit is contained in:
parent
467756df48
commit
5538d4d1c4
@ -42,34 +42,26 @@ static void AFHDS2A_calc_channels()
|
|||||||
while (idx < AFHDS2A_NUMFREQ)
|
while (idx < AFHDS2A_NUMFREQ)
|
||||||
{
|
{
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
uint8_t count_1_42 = 0, count_43_85 = 0, count_86_128 = 0, count_129_168 = 0;
|
uint8_t band_no = ((((idx<<1) | ((idx>>1) & 0b01)) + rx_tx_addr[3]) & 0b11);
|
||||||
rnd = rnd * 0x0019660D + 0x3C6EF35F; // Randomization
|
rnd = rnd * 0x0019660D + 0x3C6EF35F; // Randomization
|
||||||
|
|
||||||
uint8_t next_ch = ((rnd >> (idx%32)) % 0xa8) + 1;
|
uint8_t next_ch = band_no*41 + 1 + ((rnd >> idx) % 41); // Channel range: 1..164
|
||||||
// Keep the distance 2 between the channels - either odd or even
|
|
||||||
if (((next_ch ^ MProtocol_id) & 0x01 )== 0)
|
|
||||||
continue;
|
|
||||||
// Check that it's not duplicate and spread uniformly
|
|
||||||
for (i = 0; i < idx; i++)
|
for (i = 0; i < idx; i++)
|
||||||
{
|
{
|
||||||
if(hopping_frequency[i] == next_ch)
|
// Keep the distance 5 between the channels
|
||||||
break;
|
uint8_t distance;
|
||||||
if(hopping_frequency[i] <= 42)
|
if (next_ch > hopping_frequency[i])
|
||||||
count_1_42++;
|
distance = next_ch - hopping_frequency[i];
|
||||||
else if (hopping_frequency[i] <= 85)
|
|
||||||
count_43_85++;
|
|
||||||
else if (hopping_frequency[i] <= 128)
|
|
||||||
count_86_128++;
|
|
||||||
else
|
else
|
||||||
count_129_168++;
|
distance = hopping_frequency[i] - next_ch;
|
||||||
|
|
||||||
|
if (distance < 5) break;
|
||||||
}
|
}
|
||||||
if (i != idx)
|
|
||||||
continue;
|
if (i != idx) continue;
|
||||||
if ((next_ch <= 42 && count_1_42 < 5)
|
|
||||||
||(next_ch >= 43 && next_ch <= 85 && count_43_85 < 5)
|
hopping_frequency[idx++] = next_ch;
|
||||||
||(next_ch >= 86 && next_ch <=128 && count_86_128 < 5)
|
|
||||||
||(next_ch >= 129 && count_129_168 < 5))
|
|
||||||
hopping_frequency[idx++] = next_ch;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,9 +192,9 @@ static void AFHDS2A_build_packet(uint8_t type)
|
|||||||
{
|
{
|
||||||
#ifdef FAILSAFE_ENABLE
|
#ifdef FAILSAFE_ENABLE
|
||||||
uint16_t failsafeMicros = Failsafe_data[CH_AETR[ch]];
|
uint16_t failsafeMicros = Failsafe_data[CH_AETR[ch]];
|
||||||
failsafeMicros = (((failsafeMicros<<2)+failsafeMicros)>>3)+860;
|
if( failsafeMicros!=FAILSAFE_CHANNEL_HOLD && failsafeMicros!=FAILSAFE_CHANNEL_NOPULSES)
|
||||||
if( failsafeMicros!=FAILSAFE_CHANNEL_HOLD+860)
|
|
||||||
{ // Failsafe values
|
{ // Failsafe values
|
||||||
|
failsafeMicros = (((failsafeMicros<<2)+failsafeMicros)>>3)+860;
|
||||||
packet[9 + ch*2] = failsafeMicros & 0xff;
|
packet[9 + ch*2] = failsafeMicros & 0xff;
|
||||||
packet[10+ ch*2] = ( failsafeMicros >> 8) & 0xff;
|
packet[10+ ch*2] = ( failsafeMicros >> 8) & 0xff;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define VERSION_MAJOR 1
|
#define VERSION_MAJOR 1
|
||||||
#define VERSION_MINOR 2
|
#define VERSION_MINOR 2
|
||||||
#define VERSION_REVISION 1
|
#define VERSION_REVISION 1
|
||||||
#define VERSION_PATCH_LEVEL 37
|
#define VERSION_PATCH_LEVEL 38
|
||||||
|
|
||||||
//******************
|
//******************
|
||||||
// Protocols
|
// Protocols
|
||||||
|
Loading…
x
Reference in New Issue
Block a user