From 5289eff6aa0d9c1621ecb5260f7387d03356e650 Mon Sep 17 00:00:00 2001 From: Ettore Forigo Date: Sat, 26 Jul 2025 03:31:05 +0200 Subject: [PATCH 1/3] preliminary support for new CX-10 --- Multiprotocol/CX10_nrf24l01.ino | 109 ++++++++++++++++++++++++++++++-- 1 file changed, 104 insertions(+), 5 deletions(-) diff --git a/Multiprotocol/CX10_nrf24l01.ino b/Multiprotocol/CX10_nrf24l01.ino index d792c5f..de6cabc 100644 --- a/Multiprotocol/CX10_nrf24l01.ino +++ b/Multiprotocol/CX10_nrf24l01.ino @@ -26,6 +26,11 @@ #define CX10_PACKET_PERIOD 1316 // Timeout for callback in uSec #define CX10A_PACKET_PERIOD 6000 +#define CX10N_PACKET_SIZE 12 +#define CX10N_BIND_COUNT 100 +#define CX10N_PACKET_PERIOD 4000 +#define CX10N_RF_BIND_CHANNEL 48 + #define CX10_INITIAL_WAIT 500 // flags @@ -51,18 +56,41 @@ static void __attribute__((unused)) CX10_Write_Packet() uint8_t offset = 0; if(sub_protocol == CX10_BLUE) offset = 4; + +if (false) { + packet[0] = IS_BIND_IN_PROGRESS ? 0xAA : 0x55; packet[1] = rx_tx_addr[0]; packet[2] = rx_tx_addr[1]; packet[3] = rx_tx_addr[2]; packet[4] = rx_tx_addr[3]; + +} else { + + packet[0] = IS_BIND_IN_PROGRESS ? 0xC5 : 0x85; + packet[1] = IS_BIND_IN_PROGRESS ? 0x11 : packet_count++; + packet[2] = rx_tx_addr[0]; + packet[3] = rx_tx_addr[1]; + +} + +/* + // packet[5] to [8] (aircraft id) is filled during bind for blue board uint16_t aileron= convert_channel_16b_limit(AILERON ,1000,2000); uint16_t elevator=convert_channel_16b_limit(ELEVATOR,2000,1000); uint16_t throttle=convert_channel_16b_limit(THROTTLE,1000,2000); uint16_t rudder= convert_channel_16b_limit(RUDDER ,2000,1000); + +*/ + + uint8_t aileron = convert_channel_8b(AILERON); + uint8_t elevator = convert_channel_8b(ELEVATOR); + uint8_t throttle = convert_channel_8b(THROTTLE); + uint8_t rudder = convert_channel_8b(RUDDER); + // Channel 5 - flip flag - packet[12+offset] = GET_FLAG(CH5_SW,CX10_FLAG_FLIP); // flip flag applied on rudder +// packet[12+offset] = GET_FLAG(CH5_SW,CX10_FLAG_FLIP); // flip flag applied on rudder // Channel 6 - rate mode is 2 lsb of packet 13 if(CH6_SW) // rate 3 / headless on CX-10A @@ -72,6 +100,10 @@ static void __attribute__((unused)) CX10_Write_Packet() flags = 0x00; // rate 1 else flags = 0x01; // rate 2 + + +if (false) { + uint8_t flags2=0; // packet 14 uint8_t video_state=packet[14] & 0x21; @@ -150,7 +182,31 @@ static void __attribute__((unused)) CX10_Write_Packet() packet[12+offset]|= highByte(rudder); packet[13+offset]=flags; packet[14+offset]=flags2; - + +} else { + + packet[4] = throttle; + packet[5] = rudder; + packet[6] = elevator; + packet[7] = aileron; + + if(IS_BIND_DONE) { + packet[8] = !CH5_SW ? 0x04 + flags : 0x0C; + + // TODO horizontal and vertical adjustments + packet[10] = 0x42; + packet[11] = 0x10; + + } else { + + packet[8] = 0x00; + + packet[10] = 0xAA; + packet[11] = 0x55; + } + +} + // Send if(IS_BIND_DONE) { @@ -165,9 +221,11 @@ static void __attribute__((unused)) CX10_Write_Packet() static void __attribute__((unused)) CX10_RF_init() { XN297_Configure(XN297_CRCEN, XN297_SCRAMBLED, XN297_1M); - XN297_SetTXAddr((uint8_t *)"\xcc\xcc\xcc\xcc\xcc", 5); +// XN297_SetTXAddr((uint8_t *)"\xcc\xcc\xcc\xcc\xcc", 5); + XN297_SetTXAddr((uint8_t *)"\xc7\x95\x3c\xbb\xa5", 5); XN297_SetRXAddr((uint8_t *)"\xcc\xcc\xcc\xcc\xcc", packet_length); - XN297_RFChannel(CX10_RF_BIND_CHANNEL); +// XN297_RFChannel(CX10_RF_BIND_CHANNEL); + XN297_RFChannel(CX10N_RF_BIND_CHANNEL); } uint16_t CX10_callback() @@ -234,17 +292,45 @@ static void __attribute__((unused)) CX10_initialize_txid() } else { + +if (false) { + hopping_frequency[0] = 0x03 + (rx_tx_addr[0] & 0x0F); hopping_frequency[1] = 0x16 + (rx_tx_addr[0] >> 4); hopping_frequency[2] = 0x2D + (rx_tx_addr[1] & 0x0F); hopping_frequency[3] = 0x40 + (rx_tx_addr[1] >> 4); + +} else { + + rx_tx_addr[0] = 0x4C; + rx_tx_addr[1] = 0xD7; + + hopping_frequency[0] = 55; + hopping_frequency[1] = 66; + hopping_frequency[2] = 71; + hopping_frequency[3] = 60; + +/* + rx_tx_addr[0] = 0x50; + rx_tx_addr[1] = 0xE1; + + hopping_frequency[0] = 59; + hopping_frequency[1] = 75; + hopping_frequency[2] = 70; + hopping_frequency[3] = 65; +*/ + +} + } } void CX10_init(void) { BIND_IN_PROGRESS; // autobind protocol - + +if (false) { + if(protocol == PROTO_Q2X2) sub_protocol|=0x08; // Increase the number of sub_protocols for CX-10 @@ -269,6 +355,19 @@ void CX10_init(void) phase = CX10_BIND1; bind_counter = CX10_BIND_COUNT; } + +} else { + + packet_length = CX10N_PACKET_SIZE; + packet_period = CX10N_PACKET_PERIOD; + packet_count = 0; + phase = CX10_BIND1; + bind_counter = CX10N_BIND_COUNT; + + packet[9] = 0x00; + +} + CX10_initialize_txid(); CX10_RF_init(); } From 397627a3c0d3038ec119c639ee158199aa9c7d11 Mon Sep 17 00:00:00 2001 From: Ettore Forigo Date: Sun, 27 Jul 2025 16:18:14 +0200 Subject: [PATCH 2/3] use preproc if instead of lang if, use id bytes 2 and 3 instead of 0 and 1, formatting --- Multiprotocol/CX10_nrf24l01.ino | 43 +++++++++++++-------------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/Multiprotocol/CX10_nrf24l01.ino b/Multiprotocol/CX10_nrf24l01.ino index de6cabc..f55204e 100644 --- a/Multiprotocol/CX10_nrf24l01.ino +++ b/Multiprotocol/CX10_nrf24l01.ino @@ -57,7 +57,7 @@ static void __attribute__((unused)) CX10_Write_Packet() if(sub_protocol == CX10_BLUE) offset = 4; -if (false) { +#if 0 packet[0] = IS_BIND_IN_PROGRESS ? 0xAA : 0x55; packet[1] = rx_tx_addr[0]; @@ -65,16 +65,14 @@ if (false) { packet[3] = rx_tx_addr[2]; packet[4] = rx_tx_addr[3]; -} else { +#endif packet[0] = IS_BIND_IN_PROGRESS ? 0xC5 : 0x85; packet[1] = IS_BIND_IN_PROGRESS ? 0x11 : packet_count++; - packet[2] = rx_tx_addr[0]; - packet[3] = rx_tx_addr[1]; + packet[2] = rx_tx_addr[2]; + packet[3] = rx_tx_addr[3]; -} - -/* +#if 0 // packet[5] to [8] (aircraft id) is filled during bind for blue board uint16_t aileron= convert_channel_16b_limit(AILERON ,1000,2000); @@ -82,7 +80,7 @@ if (false) { uint16_t throttle=convert_channel_16b_limit(THROTTLE,1000,2000); uint16_t rudder= convert_channel_16b_limit(RUDDER ,2000,1000); -*/ +#endif uint8_t aileron = convert_channel_8b(AILERON); uint8_t elevator = convert_channel_8b(ELEVATOR); @@ -102,7 +100,7 @@ if (false) { flags = 0x01; // rate 2 -if (false) { +#if 0 uint8_t flags2=0; // packet 14 @@ -183,7 +181,7 @@ if (false) { packet[13+offset]=flags; packet[14+offset]=flags2; -} else { +#endif packet[4] = throttle; packet[5] = rudder; @@ -205,8 +203,6 @@ if (false) { packet[11] = 0x55; } -} - // Send if(IS_BIND_DONE) { @@ -222,7 +218,7 @@ static void __attribute__((unused)) CX10_RF_init() { XN297_Configure(XN297_CRCEN, XN297_SCRAMBLED, XN297_1M); // XN297_SetTXAddr((uint8_t *)"\xcc\xcc\xcc\xcc\xcc", 5); - XN297_SetTXAddr((uint8_t *)"\xc7\x95\x3c\xbb\xa5", 5); + XN297_SetTXAddr((uint8_t *)"\xC7\x95\x3C\xBB\xA5", 5); XN297_SetRXAddr((uint8_t *)"\xcc\xcc\xcc\xcc\xcc", packet_length); // XN297_RFChannel(CX10_RF_BIND_CHANNEL); XN297_RFChannel(CX10N_RF_BIND_CHANNEL); @@ -293,17 +289,17 @@ static void __attribute__((unused)) CX10_initialize_txid() else { -if (false) { +#if 0 hopping_frequency[0] = 0x03 + (rx_tx_addr[0] & 0x0F); hopping_frequency[1] = 0x16 + (rx_tx_addr[0] >> 4); hopping_frequency[2] = 0x2D + (rx_tx_addr[1] & 0x0F); hopping_frequency[3] = 0x40 + (rx_tx_addr[1] >> 4); -} else { +#endif - rx_tx_addr[0] = 0x4C; - rx_tx_addr[1] = 0xD7; + rx_tx_addr[2] = 0x4C; + rx_tx_addr[3] = 0xD7; hopping_frequency[0] = 55; hopping_frequency[1] = 66; @@ -311,17 +307,14 @@ if (false) { hopping_frequency[3] = 60; /* - rx_tx_addr[0] = 0x50; - rx_tx_addr[1] = 0xE1; + rx_tx_addr[2] = 0x50; + rx_tx_addr[3] = 0xE1; hopping_frequency[0] = 59; hopping_frequency[1] = 75; hopping_frequency[2] = 70; hopping_frequency[3] = 65; */ - -} - } } @@ -329,7 +322,7 @@ void CX10_init(void) { BIND_IN_PROGRESS; // autobind protocol -if (false) { +#if 0 if(protocol == PROTO_Q2X2) sub_protocol|=0x08; // Increase the number of sub_protocols for CX-10 @@ -356,7 +349,7 @@ if (false) { bind_counter = CX10_BIND_COUNT; } -} else { +#endif packet_length = CX10N_PACKET_SIZE; packet_period = CX10N_PACKET_PERIOD; @@ -366,8 +359,6 @@ if (false) { packet[9] = 0x00; -} - CX10_initialize_txid(); CX10_RF_init(); } From d004eb0328972765062b07acb7dc61c8c901c7ba Mon Sep 17 00:00:00 2001 From: Ettore Forigo Date: Sun, 27 Jul 2025 16:19:16 +0200 Subject: [PATCH 3/3] preliminary impl of CX-10 proto as sub of SGF22 --- Multiprotocol/SGF22_nrf24l01.ino | 38 +++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/Multiprotocol/SGF22_nrf24l01.ino b/Multiprotocol/SGF22_nrf24l01.ino index 37da91d..35134cc 100644 --- a/Multiprotocol/SGF22_nrf24l01.ino +++ b/Multiprotocol/SGF22_nrf24l01.ino @@ -27,6 +27,7 @@ Multiprotocol is distributed in the hope that it will be useful, #define SGF22_RF_NUM_CHANNELS 4 #define SGF22_F22S_BIND_RF_CHANNEL 10 #define SGF22_J20_BIND_RF_CHANNEL 28 +#define CX10_BIND_RF_CHANNEL 48 //packet[8] #define SGF22_FLAG_3D 0x00 @@ -61,7 +62,9 @@ static void __attribute__((unused)) SGF22_send_packet() { if(IS_BIND_IN_PROGRESS) { - packet[ 0] = 0x5B; +// packet[ 0] = 0x5B; + packet[ 0] = 0xC5; + packet[ 1] = 0x11; packet[ 8] = 0x00; // ??? do they have to be 0 for bind to succeed ? packet[ 9] = 0x00; // ??? do they have to be 0 for bind to succeed ? packet[10] = 0xAA; @@ -78,7 +81,9 @@ static void __attribute__((unused)) SGF22_send_packet() if(packet_sent > 0x7B) packet_sent = 0; //packet - packet[0] = 0x1B; +// packet[0] = 0x1B; + packet[0] = 0x85; + packet[1] = packet_count; // sequence packet[8] = SGF22_FLAG_3D // CH5 -100%, F22 & F22S - 3D mode, J20 - Gyro off | GET_FLAG(CH6_SW, SGF22_FLAG_ROLL) // roll | GET_FLAG(CH7_SW, SGF22_FLAG_LIGHT) // push up throttle trim for light in the stock TX @@ -89,6 +94,17 @@ static void __attribute__((unused)) SGF22_send_packet() packet[8] |= SGF22_FLAG_VERTICAL; // CH5 100%, vertical mode (torque) else if(Channel_data[CH5] > CHANNEL_MIN_COMMAND ) packet[8] |= ( sub_protocol == SGF22_J20 ? SGF22_J20_FLAG_HORIZONTAL : SGF22_FLAG_6G ); // CH5 0%, F22 & F22S - 6G mode, J20 - Horizontal mode + + // Channel 6 - packet 8 is rate mode or flip mode + if(CH6_SW) // rate 3 + flags = 0x02; + else + if(Channel_data[CH6] < CHANNEL_MIN_COMMAND) + flags = 0x00; // rate 1 + else + flags = 0x01; + packet[8] = !CH5_SW ? 0x04 + flags : 0x0C; + packet[9] = GET_FLAG(CH8_SW, SGF22_FLAG_PHOTO) // F22: photo, press in throttle trim in the stock TX, J20: invert flight | GET_FLAG(CH10_SW, ( sub_protocol == SGF22_J20 ? SGF22_J20_FLAG_FIXHEIGHT : SGF22_FLAG_TRIMRESET )) ; // F22: Both sticks down inwards in the stock TX, J20: Altitude hold packet[10] = 0x42; // no fine tune @@ -98,7 +114,7 @@ static void __attribute__((unused)) SGF22_send_packet() packet[0] += 6; else if (sub_protocol == SGF22_J20) packet[0] += 3; - packet[1] = packet_count; // sequence +// packet[1] = packet_count; // sequence packet[2] = rx_tx_addr[2]; packet[3] = rx_tx_addr[3]; packet[4] = convert_channel_8b(THROTTLE); @@ -108,7 +124,8 @@ static void __attribute__((unused)) SGF22_send_packet() XN297_SetPower(); XN297_SetTxRxMode(TX_EN); - XN297_WriteEnhancedPayload(packet, SGF22_PAYLOAD_SIZE,0); +// XN297_WriteEnhancedPayload(packet, SGF22_PAYLOAD_SIZE,0); + XN297_WritePayload(packet, SGF22_PAYLOAD_SIZE); #if 0 debug_time(""); for(uint8_t i=0; i