From 4b6185548e54ac76dae976fc1f42f786ee3f6b4d Mon Sep 17 00:00:00 2001 From: BrianQuad <39316832+brianquad@users.noreply.github.com> Date: Mon, 13 Aug 2018 06:14:40 -0600 Subject: [PATCH] Expanded Bayang protocol to have Option 2, which adds two analog auxiliary channels driven by channels 14 and 15. The expert byte is taken over, as is the extra txid byte, which is not used by Silverware. --- Multiprotocol/Bayang_nrf24l01.ino | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/Multiprotocol/Bayang_nrf24l01.ino b/Multiprotocol/Bayang_nrf24l01.ino index e294da5..10b79f2 100644 --- a/Multiprotocol/Bayang_nrf24l01.ino +++ b/Multiprotocol/Bayang_nrf24l01.ino @@ -47,7 +47,7 @@ static void __attribute__((unused)) BAYANG_send_packet(uint8_t bind) if (bind) { #ifdef BAYANG_HUB_TELEMETRY - if(option) + if(option > 0) packet[0]= 0xA3; // telemetry is enabled else #endif @@ -86,7 +86,13 @@ static void __attribute__((unused)) BAYANG_send_packet(uint8_t bind) packet[0] = 0xA5; break; } - packet[1] = 0xFA; // normal mode is 0xf7, expert 0xfa + if (option == 2) + { + // Analog aux channel 1 (channel 14) + packet[1] = convert_channel_8b(CH14); + } + else + packet[1] = 0xFA; // normal mode is 0xf7, expert 0xfa //Flags packet[2] packet[2] = 0x00; @@ -110,7 +116,7 @@ static void __attribute__((unused)) BAYANG_send_packet(uint8_t bind) if(CH11_SW) dyntrim = 0; if(CH12_SW) - packet[3] |= BAYANG_FLAG_TAKE_OFF; + packet[3] |= BAYANG_FLAG_TAKE_OFF; if(CH13_SW) packet[3] |= BAYANG_FLAG_EMG_STOP; //Aileron @@ -146,7 +152,13 @@ static void __attribute__((unused)) BAYANG_send_packet(uint8_t bind) break; default: packet[12] = rx_tx_addr[2]; // txid[2] - packet[13] = 0x0A; + if (option == 2) + { + // Analog aux channel 2 (channel 15) + packet[13] = convert_channel_8b(CH15); + } + else + packet[13] = 0x0A; break; } packet[14] = 0; @@ -170,7 +182,7 @@ static void __attribute__((unused)) BAYANG_send_packet(uint8_t bind) XN297_Configure(_BV(NRF24L01_00_EN_CRC) | _BV(NRF24L01_00_CRCO) | _BV(NRF24L01_00_PWR_UP)); #ifdef BAYANG_HUB_TELEMETRY - if (option) + if (option > 0) { // switch radio to rx as soon as packet is sent while (!(NRF24L01_ReadReg(NRF24L01_07_STATUS) & _BV(NRF24L01_07_TX_DS))); NRF24L01_WriteReg(NRF24L01_00_CONFIG, 0x03); @@ -253,7 +265,7 @@ uint16_t BAYANG_callback() BAYANG_send_packet(0); packet_count++; #ifdef BAYANG_HUB_TELEMETRY - if (option) + if (option > 0) { // telemetry is enabled state++; if (state > 1000) @@ -320,4 +332,4 @@ uint16_t initBAYANG(void) return BAYANG_INITIAL_WAIT+BAYANG_PACKET_PERIOD; } -#endif \ No newline at end of file +#endif