mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-07-01 01:57:52 +00:00
DEVO PPM fixed id mode
This commit is contained in:
parent
78ee77444f
commit
f6c5252376
@ -78,7 +78,20 @@ static void __attribute__((unused)) DEVO_scramble_pkt()
|
||||
static void __attribute__((unused)) DEVO_add_pkt_suffix()
|
||||
{
|
||||
uint8_t bind_state;
|
||||
if(prev_option!=option)
|
||||
#ifdef ENABLE_PPM
|
||||
if(mode_select && option==0 && IS_BIND_DONE_on) //PPM mode and option not already set and bind is finished
|
||||
{
|
||||
BIND_SET_INPUT;
|
||||
BIND_SET_PULLUP; // set pullup
|
||||
if(IS_BIND_BUTTON_on)
|
||||
{
|
||||
eeprom_write_byte((uint8_t*)(30+mode_select),0x01); // Set fixed id mode for the current model
|
||||
option=1;
|
||||
}
|
||||
BIND_SET_OUTPUT;
|
||||
}
|
||||
#endif //ENABLE_PPM
|
||||
if(prev_option!=option && IS_BIND_DONE_on)
|
||||
{
|
||||
MProtocol_id = RX_num + MProtocol_id_master;
|
||||
bind_counter=DEVO_BIND_COUNT;
|
||||
|
@ -261,6 +261,16 @@ struct PPM_Parameters
|
||||
#define IS_LED_on ( (PORTB & _BV(5)) != 0x00 )
|
||||
#endif
|
||||
|
||||
//BIND
|
||||
#ifdef XMEGA
|
||||
#define IS_BIND_BUTTON_on ( (PORTD.IN & _BV(2)) == 0x00 )
|
||||
#else
|
||||
#define BIND_SET_INPUT DDRB &= ~_BV(5)
|
||||
#define BIND_SET_PULLUP PORTB |= _BV(5)
|
||||
#define IS_BIND_BUTTON_on ( (PINB & _BV(5)) == 0x00 )
|
||||
#define BIND_SET_OUTPUT DDRB |= _BV(5)
|
||||
#endif
|
||||
|
||||
// TX
|
||||
#define TX_ON PORTD |= _BV(1)
|
||||
#define TX_OFF PORTD &= ~_BV(1)
|
||||
|
@ -196,11 +196,7 @@ void setup()
|
||||
delayMilliseconds(100);
|
||||
|
||||
// Read status of bind button
|
||||
#ifdef XMEGA
|
||||
if( (PORTD.IN & _BV(2)) == 0x00 )
|
||||
#else
|
||||
if( (PINB & _BV(5)) == 0x00 )
|
||||
#endif
|
||||
if( IS_BIND_BUTTON_on )
|
||||
BIND_BUTTON_FLAG_on; // If bind button pressed save the status for protocol id reset under hubsan
|
||||
|
||||
// Read status of mode select binary switch
|
||||
@ -483,6 +479,21 @@ static void protocol_init()
|
||||
#endif
|
||||
#if defined(DEVO_CYRF6936_INO)
|
||||
case MODE_DEVO:
|
||||
#ifdef ENABLE_PPM
|
||||
if(mode_select) //PPM mode
|
||||
{
|
||||
if(IS_BIND_BUTTON_FLAG_on)
|
||||
{
|
||||
eeprom_write_byte((uint8_t*)(30+mode_select),0x00); // reset to autobind mode for the current model
|
||||
option=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
option=eeprom_read_byte((uint8_t*)(30+mode_select)); // load previous mode: autobind or fixed id
|
||||
if(option!=1) option=0; // if not fixed id mode then it should be autobind
|
||||
}
|
||||
}
|
||||
#endif //ENABLE_PPM
|
||||
CTRL2_on; //antenna RF4
|
||||
next_callback = DevoInit();
|
||||
remote_callback = devo_callback;
|
||||
|
Loading…
x
Reference in New Issue
Block a user