diff --git a/Multiprotocol/Bayang_nrf24l01.ino b/Multiprotocol/Bayang_nrf24l01.ino index d1a42b5..eb03aa7 100644 --- a/Multiprotocol/Bayang_nrf24l01.ino +++ b/Multiprotocol/Bayang_nrf24l01.ino @@ -41,14 +41,28 @@ enum BAYANG_FLAGS { BAYANG_FLAG_EMG_STOP = 0x04|0x08, // 0x08 for VISUO XS809H-W-HD-G }; +enum BAYANG_OPTION_FLAGS { + BAYANG_OPTION_FLAG_TELEMETRY = 0x01, + BAYANG_OPTION_FLAG_ANALOGAUX = 0x02, +}; + static void __attribute__((unused)) BAYANG_send_packet(uint8_t bind) { uint8_t i; if (bind) { #ifdef BAYANG_HUB_TELEMETRY - if(option) - packet[0]= 0xA3; // telemetry is enabled + if(option & BAYANG_OPTION_FLAG_TELEMETRY) + if(option & BAYANG_OPTION_FLAG_ANALOGAUX) + packet[0]= 0xA1; // telemetry and analog aux are enabled + else + packet[0]= 0xA3; // telemetry is enabled + else if(option & BAYANG_OPTION_FLAG_ANALOGAUX) + packet[0]= 0xA2; // analog aux is enabled + else + #else + if(option & BAYANG_OPTION_FLAG_ANALOGAUX) + packet[0]= 0xA2; // analog aux is enabled else #endif packet[0]= 0xA4; @@ -86,7 +100,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 & BAYANG_OPTION_FLAG_ANALOGAUX) + { + // 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 +130,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 +166,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 & BAYANG_OPTION_FLAG_ANALOGAUX) + { + // Analog aux channel 2 (channel 15) + packet[13] = convert_channel_8b(CH15); + } + else + packet[13] = 0x0A; break; } packet[14] = 0; @@ -170,7 +196,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 & BAYANG_OPTION_FLAG_TELEMETRY) { // 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 +279,7 @@ uint16_t BAYANG_callback() BAYANG_send_packet(0); packet_count++; #ifdef BAYANG_HUB_TELEMETRY - if (option) + if (option & BAYANG_OPTION_FLAG_TELEMETRY) { // telemetry is enabled state++; if (state > 1000) @@ -320,4 +346,4 @@ uint16_t initBAYANG(void) return BAYANG_INITIAL_WAIT+BAYANG_PACKET_PERIOD; } -#endif \ No newline at end of file +#endif diff --git a/Protocols_Details.md b/Protocols_Details.md index 6ba1de5..cc7e282 100644 --- a/Protocols_Details.md +++ b/Protocols_Details.md @@ -527,23 +527,29 @@ The transmitter must be close to the receiver while binding. ## BAYANG - *14* Autobind protocol -CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11 ----|---|---|---|---|---|---|---|---|----|---- -A|E|T|R|FLIP|RTH|PICTURE|VIDEO|HEADLESS|INVERTED|RATES +CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11|-|-|CH14|CH15 +---|---|---|---|---|---|---|---|---|----|----|---|---|----|---- +A|E|T|R|FLIP|RTH|PICTURE|VIDEO|HEADLESS|INVERTED|RATES|-|-|ANAAUX1|ANAAUX2 RATES: -100%(default)=>higher rates by enabling dynamic trims (except for Headless), 100%=>disable dynamic trims +Channels 14 and 15 (ANAAUX1 and ANAAUX2) only available with analog aux channel option, indicated below. + ### Sub_protocol BAYANG - *0* -Models: EAchine H8(C) mini, BayangToys X6/X7/X9, JJRC JJ850, Floureon H101 ... +Models: Eachine H8(C) mini, BayangToys X6/X7/X9, JJRC JJ850, Floureon H101 ... Option=0 -> normal Bayang protocol Option=1 -> enable telemetry with [Silverxxx firmware](https://github.com/silver13/H101-acro/tree/master). Value returned to the TX using FrSkyD Hub are RX RSSI, TX RSSI, A1=uncompensated battery voltage, A2=compensated battery voltage +Option=2 -> enable analog aux channels with [NFE Silverware firmware](https://github.com/NotFastEnuf/NFE_Silverware). Two otherwise static bytes in the protocol overridden to add two 'analog' (non-binary) auxiliary channels. + +Option=3 -> both Silverware telemetry and analog aux channels enabled. + ### Sub_protocol H8S3D - *1* Model: H8S 3D -Same channels assignement as above. +Same channels assignment as above. ### Sub_protocol X16_AH - *2* Model: X16 AH