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()
|
static void __attribute__((unused)) DEVO_add_pkt_suffix()
|
||||||
{
|
{
|
||||||
uint8_t bind_state;
|
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;
|
MProtocol_id = RX_num + MProtocol_id_master;
|
||||||
bind_counter=DEVO_BIND_COUNT;
|
bind_counter=DEVO_BIND_COUNT;
|
||||||
|
@ -248,17 +248,27 @@ struct PPM_Parameters
|
|||||||
|
|
||||||
// LED
|
// LED
|
||||||
#ifdef XMEGA
|
#ifdef XMEGA
|
||||||
#define LED_ON PORTD.OUTCLR = _BV(1)
|
#define LED_ON PORTD.OUTCLR = _BV(1)
|
||||||
#define LED_OFF PORTD.OUTSET = _BV(1)
|
#define LED_OFF PORTD.OUTSET = _BV(1)
|
||||||
#define LED_TOGGLE PORTD.OUTTGL = _BV(1)
|
#define LED_TOGGLE PORTD.OUTTGL = _BV(1)
|
||||||
#define LED_SET_OUTPUT PORTD.DIRSET = _BV(1)
|
#define LED_SET_OUTPUT PORTD.DIRSET = _BV(1)
|
||||||
#define IS_LED_on ( (PORTD.OUT & _BV(1)) != 0x00 )
|
#define IS_LED_on ( (PORTD.OUT & _BV(1)) != 0x00 )
|
||||||
#else
|
#else
|
||||||
#define LED_ON PORTB |= _BV(5)
|
#define LED_ON PORTB |= _BV(5)
|
||||||
#define LED_OFF PORTB &= ~_BV(5)
|
#define LED_OFF PORTB &= ~_BV(5)
|
||||||
#define LED_TOGGLE PORTB ^= _BV(5)
|
#define LED_TOGGLE PORTB ^= _BV(5)
|
||||||
#define LED_SET_OUTPUT DDRB |= _BV(5)
|
#define LED_SET_OUTPUT DDRB |= _BV(5)
|
||||||
#define IS_LED_on ( (PORTB & _BV(5)) != 0x00 )
|
#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
|
#endif
|
||||||
|
|
||||||
// TX
|
// TX
|
||||||
|
@ -196,11 +196,7 @@ void setup()
|
|||||||
delayMilliseconds(100);
|
delayMilliseconds(100);
|
||||||
|
|
||||||
// Read status of bind button
|
// Read status of bind button
|
||||||
#ifdef XMEGA
|
if( IS_BIND_BUTTON_on )
|
||||||
if( (PORTD.IN & _BV(2)) == 0x00 )
|
|
||||||
#else
|
|
||||||
if( (PINB & _BV(5)) == 0x00 )
|
|
||||||
#endif
|
|
||||||
BIND_BUTTON_FLAG_on; // If bind button pressed save the status for protocol id reset under hubsan
|
BIND_BUTTON_FLAG_on; // If bind button pressed save the status for protocol id reset under hubsan
|
||||||
|
|
||||||
// Read status of mode select binary switch
|
// Read status of mode select binary switch
|
||||||
@ -483,6 +479,21 @@ static void protocol_init()
|
|||||||
#endif
|
#endif
|
||||||
#if defined(DEVO_CYRF6936_INO)
|
#if defined(DEVO_CYRF6936_INO)
|
||||||
case MODE_DEVO:
|
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
|
CTRL2_on; //antenna RF4
|
||||||
next_callback = DevoInit();
|
next_callback = DevoInit();
|
||||||
remote_callback = devo_callback;
|
remote_callback = devo_callback;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user