/* This project is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Multiprotocol is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Multiprotocol. If not, see . */ // Compatible with FEI XIONG P38 plane. #if defined(FX_NRF24L01_INO) #include "iface_xn297.h" #define FX_BIND_COUNT 300 //3sec #define FX_SWITCH 20 #define FX_NUM_CHANNELS 4 #define FX816_PACKET_PERIOD 10000 #define FX816_BIND_CHANNEL 40 #define FX816_PAYLOAD_SIZE 6 #define FX816_CH_OFFSET 3 #define FX620_PACKET_PERIOD 3250 #define FX620_BIND_PACKET_PERIOD 4500 #define FX620_BIND_CHANNEL 18 #define FX620_PAYLOAD_SIZE 7 #define FX620_CH_OFFSET 1 #define FORCE_FX620_ID static void __attribute__((unused)) FX_send_packet() { //Hopp if(IS_BIND_DONE) { XN297_Hopping(hopping_frequency_no++); hopping_frequency_no &= 0x03; } memset(packet,0x00,packet_length); //Channels uint8_t offset=sub_protocol == FX816 ? FX816_CH_OFFSET:FX620_CH_OFFSET; uint8_t val=convert_channel_8b(AILERON); if(val>127+FX_SWITCH) packet[offset] = sub_protocol == FX816 ? 1:0xFF; else if(val<127-FX_SWITCH) packet[offset] = sub_protocol == FX816 ? 2:0x00; else packet[offset] = sub_protocol == FX816 ? 0:0x7F; packet[offset+1] = convert_channel_16b_limit(THROTTLE,0,100); //FX816:0x00..0x63, FX620:0x00..0x5E but that should work //Bind and specifics if(sub_protocol == FX816) { if(IS_BIND_IN_PROGRESS) packet[0] = 0x55; else packet[0] = 0xAA; packet[1] = rx_tx_addr[0]; packet[2] = rx_tx_addr[1]; } else //FX620 { if(IS_BIND_IN_PROGRESS) { memcpy(packet,rx_tx_addr,3); packet[3] = hopping_frequency[0]; if(bind_counter > (FX_BIND_COUNT >> 1)) packet[5] = 0x78; } else { packet[0] = 0x1F; // Is it based on ID?? packet[5] = 0xAB; // Is it based on ID?? } } //Check val=0; for(uint8_t i=0;i