mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-02-04 21:48:12 +00:00
WAIT_FOR_BIND feature
This feature will not activate the selected protocol unless a bind is requested using bind from channel or the GUI "Bind" button. It is only enabled if bind from channel and autobind are set since I think they are working well together. The goal is to prevent binding other people's model when powering up the TX, changing model or scanning through protocols. There is a new blinking pattern associated to it as well as a new status "Waiting for bind". This feature is enabled by default in _config.h .
This commit is contained in:
parent
72052925a6
commit
0c5fae01b5
@ -19,7 +19,7 @@
|
|||||||
#define VERSION_MAJOR 1
|
#define VERSION_MAJOR 1
|
||||||
#define VERSION_MINOR 1
|
#define VERSION_MINOR 1
|
||||||
#define VERSION_REVISION 6
|
#define VERSION_REVISION 6
|
||||||
#define VERSION_PATCH_LEVEL 16
|
#define VERSION_PATCH_LEVEL 17
|
||||||
//******************
|
//******************
|
||||||
// Protocols
|
// Protocols
|
||||||
//******************
|
//******************
|
||||||
@ -284,11 +284,17 @@ enum MultiPacketTypes {
|
|||||||
#define INPUT_SIGNAL_on protocol_flags2 |= _BV(5)
|
#define INPUT_SIGNAL_on protocol_flags2 |= _BV(5)
|
||||||
#define IS_INPUT_SIGNAL_on ( ( protocol_flags2 & _BV(5) ) !=0 )
|
#define IS_INPUT_SIGNAL_on ( ( protocol_flags2 & _BV(5) ) !=0 )
|
||||||
#define IS_INPUT_SIGNAL_off ( ( protocol_flags2 & _BV(5) ) ==0 )
|
#define IS_INPUT_SIGNAL_off ( ( protocol_flags2 & _BV(5) ) ==0 )
|
||||||
//CH16
|
//Bind from channel
|
||||||
#define BIND_CH_PREV_off protocol_flags2 &= ~_BV(6)
|
#define BIND_CH_PREV_off protocol_flags2 &= ~_BV(6)
|
||||||
#define BIND_CH_PREV_on protocol_flags2 |= _BV(6)
|
#define BIND_CH_PREV_on protocol_flags2 |= _BV(6)
|
||||||
#define IS_BIND_CH_PREV_on ( ( protocol_flags2 & _BV(6) ) !=0 )
|
#define IS_BIND_CH_PREV_on ( ( protocol_flags2 & _BV(6) ) !=0 )
|
||||||
#define IS_BIND_CH_PREV_off ( ( protocol_flags2 & _BV(6) ) ==0 )
|
#define IS_BIND_CH_PREV_off ( ( protocol_flags2 & _BV(6) ) ==0 )
|
||||||
|
//Wait for bind
|
||||||
|
#define WAIT_BIND_off protocol_flags2 &= ~_BV(7)
|
||||||
|
#define WAIT_BIND_on protocol_flags2 |= _BV(7)
|
||||||
|
#define IS_WAIT_BIND_on ( ( protocol_flags2 & _BV(7) ) !=0 )
|
||||||
|
#define IS_WAIT_BIND_off ( ( protocol_flags2 & _BV(7) ) ==0 )
|
||||||
|
|
||||||
|
|
||||||
//********************
|
//********************
|
||||||
//*** Blink timing ***
|
//*** Blink timing ***
|
||||||
@ -296,8 +302,11 @@ enum MultiPacketTypes {
|
|||||||
#define BLINK_BIND_TIME 100
|
#define BLINK_BIND_TIME 100
|
||||||
#define BLINK_SERIAL_TIME 500
|
#define BLINK_SERIAL_TIME 500
|
||||||
#define BLINK_PPM_TIME 1000
|
#define BLINK_PPM_TIME 1000
|
||||||
#define BLINK_BAD_PROTO_TIME_LOW 1000
|
|
||||||
#define BLINK_BAD_PROTO_TIME_HIGH 50
|
#define BLINK_BAD_PROTO_TIME_HIGH 50
|
||||||
|
#define BLINK_BAD_PROTO_TIME_LOW 1000
|
||||||
|
#define BLINK_WAIT_BIND_TIME_HIGH 1000
|
||||||
|
#define BLINK_WAIT_BIND_TIME_LOW 100
|
||||||
|
|
||||||
|
|
||||||
//*******************
|
//*******************
|
||||||
//*** AUX flags ***
|
//*** AUX flags ***
|
||||||
@ -600,6 +609,7 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p --
|
|||||||
0x02 = Serial mode enabled
|
0x02 = Serial mode enabled
|
||||||
0x04 = protocol is valid
|
0x04 = protocol is valid
|
||||||
0x08 = module is in binding mode
|
0x08 = module is in binding mode
|
||||||
|
0x10 = module waits a bind event to load the protocol
|
||||||
[3] major
|
[3] major
|
||||||
[4] minor
|
[4] minor
|
||||||
[5] revision
|
[5] revision
|
||||||
@ -633,6 +643,7 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p --
|
|||||||
0x02 = Serial mode enabled
|
0x02 = Serial mode enabled
|
||||||
0x04 = protocol is valid
|
0x04 = protocol is valid
|
||||||
0x08 = module is in binding mode
|
0x08 = module is in binding mode
|
||||||
|
0x10 = module waits a bind event to load the protocol
|
||||||
[5] major
|
[5] major
|
||||||
[6] minor
|
[6] minor
|
||||||
[7] revision
|
[7] revision
|
||||||
|
@ -396,13 +396,13 @@ void loop()
|
|||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
if(remote_callback==0 || diff>2*200)
|
if(remote_callback==0 || IS_WAIT_BIND_on || diff>2*200)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Update_All();
|
Update_All();
|
||||||
}
|
}
|
||||||
while(remote_callback==0);
|
while(remote_callback==0 || IS_WAIT_BIND_on);
|
||||||
}
|
}
|
||||||
#ifndef STM32_BOARD
|
#ifndef STM32_BOARD
|
||||||
if( (TIFR1 & OCF1A_bm) != 0)
|
if( (TIFR1 & OCF1A_bm) != 0)
|
||||||
@ -501,6 +501,13 @@ uint8_t Update_All()
|
|||||||
}
|
}
|
||||||
#endif //ENABLE_PPM
|
#endif //ENABLE_PPM
|
||||||
update_channels_aux();
|
update_channels_aux();
|
||||||
|
update_led_status();
|
||||||
|
#if defined(TELEMETRY)
|
||||||
|
#if ( !( defined(MULTI_TELEMETRY) || defined(MULTI_STATUS) ) )
|
||||||
|
if((protocol==MODE_FRSKYD) || (protocol==MODE_BAYANG) || (protocol==MODE_HUBSAN) || (protocol==MODE_AFHDS2A) || (protocol==MODE_FRSKYX) || (protocol==MODE_DSM) )
|
||||||
|
#endif
|
||||||
|
TelemetryUpdate();
|
||||||
|
#endif
|
||||||
#ifdef ENABLE_BIND_CH
|
#ifdef ENABLE_BIND_CH
|
||||||
if(IS_AUTOBIND_FLAG_on && IS_BIND_CH_PREV_off && Servo_data[BIND_CH-1]>PPM_MAX_COMMAND && Servo_data[THROTTLE]<(servo_min_100+25))
|
if(IS_AUTOBIND_FLAG_on && IS_BIND_CH_PREV_off && Servo_data[BIND_CH-1]>PPM_MAX_COMMAND && Servo_data[THROTTLE]<(servo_min_100+25))
|
||||||
{ // Autobind is on and BIND_CH went up and Throttle is low
|
{ // Autobind is on and BIND_CH went up and Throttle is low
|
||||||
@ -521,18 +528,9 @@ uint8_t Update_All()
|
|||||||
#endif //ENABLE_BIND_CH
|
#endif //ENABLE_BIND_CH
|
||||||
if(IS_CHANGE_PROTOCOL_FLAG_on)
|
if(IS_CHANGE_PROTOCOL_FLAG_on)
|
||||||
{ // Protocol needs to be changed or relaunched for bind
|
{ // Protocol needs to be changed or relaunched for bind
|
||||||
LED_off; //led off during protocol init
|
|
||||||
modules_reset(); //reset all modules
|
|
||||||
protocol_init(); //init new protocol
|
protocol_init(); //init new protocol
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#if defined(TELEMETRY)
|
|
||||||
#if ( !( defined(MULTI_TELEMETRY) || defined(MULTI_STATUS) ) )
|
|
||||||
if((protocol==MODE_FRSKYD) || (protocol==MODE_BAYANG) || (protocol==MODE_HUBSAN) || (protocol==MODE_AFHDS2A) || (protocol==MODE_FRSKYX) || (protocol==MODE_DSM) )
|
|
||||||
#endif
|
|
||||||
TelemetryUpdate();
|
|
||||||
#endif
|
|
||||||
update_led_status();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -583,11 +581,21 @@ static void update_led_status(void)
|
|||||||
blink+=BLINK_BAD_PROTO_TIME_HIGH;
|
blink+=BLINK_BAD_PROTO_TIME_HIGH;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if(IS_WAIT_BIND_on)
|
||||||
|
{
|
||||||
|
if(IS_LED_on) //flash to indicate WAIT_BIND
|
||||||
|
blink+=BLINK_WAIT_BIND_TIME_LOW;
|
||||||
|
else
|
||||||
|
blink+=BLINK_WAIT_BIND_TIME_HIGH;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if(IS_BIND_DONE_on)
|
if(IS_BIND_DONE_on)
|
||||||
LED_off; //bind completed force led on
|
LED_off; //bind completed force led on
|
||||||
blink+=BLINK_BIND_TIME; //blink fastly during binding
|
blink+=BLINK_BIND_TIME; //blink fastly during binding
|
||||||
}
|
}
|
||||||
|
}
|
||||||
LED_toggle;
|
LED_toggle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -653,9 +661,13 @@ void start_timer2()
|
|||||||
// Protocol start
|
// Protocol start
|
||||||
static void protocol_init()
|
static void protocol_init()
|
||||||
{
|
{
|
||||||
uint16_t next_callback=0; // Default is immediate call back
|
static uint16_t next_callback;
|
||||||
remote_callback = 0;
|
if(IS_WAIT_BIND_off)
|
||||||
CHANGE_PROTOCOL_FLAG_off;
|
{
|
||||||
|
remote_callback = 0; // No protocol
|
||||||
|
next_callback=0; // Default is immediate call back
|
||||||
|
LED_off; // Led off during protocol init
|
||||||
|
modules_reset(); // Reset all modules
|
||||||
|
|
||||||
// reset telemetry
|
// reset telemetry
|
||||||
#ifdef TELEMETRY
|
#ifdef TELEMETRY
|
||||||
@ -931,6 +943,17 @@ static void protocol_init()
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(WAIT_FOR_BIND) && defined(ENABLE_BIND_CH)
|
||||||
|
if( IS_AUTOBIND_FLAG_on && ! ( IS_BIND_CH_PREV_on || IS_BIND_BUTTON_FLAG_on || (cur_protocol[1]&0x80)!=0 ) )
|
||||||
|
{
|
||||||
|
WAIT_BIND_on;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
WAIT_BIND_off;
|
||||||
|
CHANGE_PROTOCOL_FLAG_off;
|
||||||
|
|
||||||
if(next_callback>32000)
|
if(next_callback>32000)
|
||||||
{ // next_callback should not be more than 32767 so we will wait here...
|
{ // next_callback should not be more than 32767 so we will wait here...
|
||||||
@ -971,6 +994,7 @@ void update_serial_data()
|
|||||||
if( (rx_ok_buff[0] != cur_protocol[0]) || ((rx_ok_buff[1]&0x5F) != (cur_protocol[1]&0x5F)) || ( (rx_ok_buff[2]&0x7F) != (cur_protocol[2]&0x7F) ) )
|
if( (rx_ok_buff[0] != cur_protocol[0]) || ((rx_ok_buff[1]&0x5F) != (cur_protocol[1]&0x5F)) || ( (rx_ok_buff[2]&0x7F) != (cur_protocol[2]&0x7F) ) )
|
||||||
{ // New model has been selected
|
{ // New model has been selected
|
||||||
CHANGE_PROTOCOL_FLAG_on; //change protocol
|
CHANGE_PROTOCOL_FLAG_on; //change protocol
|
||||||
|
WAIT_BIND_off;
|
||||||
protocol=(rx_ok_buff[0]==0x55?0:32) + (rx_ok_buff[1]&0x1F); //protocol no (0-63) bits 4-6 of buff[1] and bit 0 of buf[0]
|
protocol=(rx_ok_buff[0]==0x55?0:32) + (rx_ok_buff[1]&0x1F); //protocol no (0-63) bits 4-6 of buff[1] and bit 0 of buf[0]
|
||||||
sub_protocol=(rx_ok_buff[2]>>4)& 0x07; //subprotocol no (0-7) bits 4-6
|
sub_protocol=(rx_ok_buff[2]>>4)& 0x07; //subprotocol no (0-7) bits 4-6
|
||||||
RX_num=rx_ok_buff[2]& 0x0F; // rx_num bits 0---3
|
RX_num=rx_ok_buff[2]& 0x0F; // rx_num bits 0---3
|
||||||
|
@ -72,6 +72,9 @@ static void multi_send_status()
|
|||||||
if (remote_callback != 0)
|
if (remote_callback != 0)
|
||||||
{
|
{
|
||||||
flags |= 0x04;
|
flags |= 0x04;
|
||||||
|
if (IS_WAIT_BIND_on)
|
||||||
|
flags |= 0x10;
|
||||||
|
else
|
||||||
if (!IS_BIND_DONE_on)
|
if (!IS_BIND_DONE_on)
|
||||||
flags |= 0x08;
|
flags |= 0x08;
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@
|
|||||||
#if not defined(DSM_CYRF6936_INO)
|
#if not defined(DSM_CYRF6936_INO)
|
||||||
#undef DSM_TELEMETRY
|
#undef DSM_TELEMETRY
|
||||||
#endif
|
#endif
|
||||||
#if not defined(DSM_TELEMETRY) && not defined(SPORT_TELEMETRY) && not defined(HUB_TELEMETRY) && not defined(HUBSAN_HUB_TELEMETRY) && not defined(BAYANG_HUB_TELEMETRY) && not defined(AFHDS2A_HUB_TELEMETRY) && not defined(AFHDS2A_FW_TELEMETRY)
|
#if not defined(DSM_TELEMETRY) && not defined(SPORT_TELEMETRY) && not defined(HUB_TELEMETRY) && not defined(HUBSAN_HUB_TELEMETRY) && not defined(BAYANG_HUB_TELEMETRY) && not defined(AFHDS2A_HUB_TELEMETRY) && not defined(AFHDS2A_FW_TELEMETRY) && not defined(MULTI_TELEMETRY) && not defined(MULTI_STATUS)
|
||||||
#undef TELEMETRY
|
#undef TELEMETRY
|
||||||
#undef INVERT_TELEMETRY
|
#undef INVERT_TELEMETRY
|
||||||
#endif
|
#endif
|
||||||
|
@ -31,11 +31,24 @@
|
|||||||
//#define REVERSE_THROTTLE
|
//#define REVERSE_THROTTLE
|
||||||
//#define REVERSE_RUDDER
|
//#define REVERSE_RUDDER
|
||||||
|
|
||||||
//Comment to disable the bind feature on a channel
|
|
||||||
|
/*************************/
|
||||||
|
/*** BIND FROM CHANNEL ***/
|
||||||
|
/*************************/
|
||||||
|
//Bind from channel enables you to bind when a specified channel is giong from low to high. This feature is only active
|
||||||
|
// if you specify AUTOBIND in PPM mode or set AutoBind to YES for serial mode. It also requires that the throttle channel is low.
|
||||||
|
|
||||||
|
//Comment to globaly disable the bind feature from a channel.
|
||||||
#define ENABLE_BIND_CH
|
#define ENABLE_BIND_CH
|
||||||
|
|
||||||
//Set the channel number used for bind. Default is 16.
|
//Set the channel number used for bind. Default is 16.
|
||||||
#define BIND_CH 16
|
#define BIND_CH 16
|
||||||
|
|
||||||
|
//Comment to disable the wait for bind feature. This feature will not activate the selected
|
||||||
|
// protocol unless a bind is requested using bind from channel or the GUI "Bind" button.
|
||||||
|
//The goal is to prevent binding other people's model when powering up the TX, changing model or scanning through protocols.
|
||||||
|
#define WAIT_FOR_BIND
|
||||||
|
|
||||||
|
|
||||||
/**************************/
|
/**************************/
|
||||||
/*** RF CHIPS INSTALLED ***/
|
/*** RF CHIPS INSTALLED ***/
|
||||||
@ -57,6 +70,7 @@
|
|||||||
//All the protocols will not fit in the Atmega328p module so you need to pick and choose.
|
//All the protocols will not fit in the Atmega328p module so you need to pick and choose.
|
||||||
//Comment the protocols you are not using with "//" to save Flash space.
|
//Comment the protocols you are not using with "//" to save Flash space.
|
||||||
|
|
||||||
|
|
||||||
//The protocols below need an A7105 to be installed
|
//The protocols below need an A7105 to be installed
|
||||||
#define FLYSKY_A7105_INO
|
#define FLYSKY_A7105_INO
|
||||||
#define HUBSAN_A7105_INO
|
#define HUBSAN_A7105_INO
|
||||||
@ -94,6 +108,7 @@
|
|||||||
#define HONTAI_NRF24L01_INO
|
#define HONTAI_NRF24L01_INO
|
||||||
#define Q303_NRF24L01_INO
|
#define Q303_NRF24L01_INO
|
||||||
|
|
||||||
|
|
||||||
/**************************/
|
/**************************/
|
||||||
/*** TELEMETRY SETTINGS ***/
|
/*** TELEMETRY SETTINGS ***/
|
||||||
/**************************/
|
/**************************/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user