mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-02-05 00:08:13 +00:00
Merge pull request #23 from schwabe/opentx_flysky_telemetry
Allow TX to request forwarding of FlySky telemetry data
This commit is contained in:
commit
d731ab3682
@ -86,7 +86,17 @@ static void AFHDS2A_update_telemetry()
|
|||||||
{
|
{
|
||||||
// AA | TXID | rx_id | sensor id | sensor # | value 16 bit big endian | sensor id ......
|
// AA | TXID | rx_id | sensor id | sensor # | value 16 bit big endian | sensor id ......
|
||||||
// max 7 sensors per packet
|
// max 7 sensors per packet
|
||||||
|
#if defined AFHDS2A_TELEMETRY
|
||||||
|
if (option & 0x80) {
|
||||||
|
// forward telemetry to TX, skip rx and tx id to save space
|
||||||
|
pkt[0]= TX_RSSI;
|
||||||
|
for(int i=9;i < AFHDS2A_RXPACKET_SIZE; i++)
|
||||||
|
pkt[i-8]=packet[i];
|
||||||
|
|
||||||
|
telemetry_link=2;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
for(uint8_t sensor=0; sensor<7; sensor++)
|
for(uint8_t sensor=0; sensor<7; sensor++)
|
||||||
{
|
{
|
||||||
uint8_t index = 9+(4*sensor);
|
uint8_t index = 9+(4*sensor);
|
||||||
@ -180,7 +190,7 @@ static void AFHDS2A_build_packet(uint8_t type)
|
|||||||
packet[0] = 0xaa;
|
packet[0] = 0xaa;
|
||||||
packet[9] = 0xfd;
|
packet[9] = 0xfd;
|
||||||
packet[10]= 0xff;
|
packet[10]= 0xff;
|
||||||
uint16_t val_hz=5*option+50; // option value should be between 0 and 70 which gives a value between 50 and 400Hz
|
uint16_t val_hz=5*(option & 0x7f)+50; // option value should be between 0 and 70 which gives a value between 50 and 400Hz
|
||||||
if(val_hz<50 || val_hz>400) val_hz=50; // default is 50Hz
|
if(val_hz<50 || val_hz>400) val_hz=50; // default is 50Hz
|
||||||
packet[11]= val_hz;
|
packet[11]= val_hz;
|
||||||
packet[12]= val_hz >> 8;
|
packet[12]= val_hz >> 8;
|
||||||
|
@ -449,6 +449,11 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p --
|
|||||||
FORMAT_HONTAI 0
|
FORMAT_HONTAI 0
|
||||||
FORMAT_JJRCX1 1
|
FORMAT_JJRCX1 1
|
||||||
FORMAT_X5C1 2
|
FORMAT_X5C1 2
|
||||||
|
sub_protocol==AFHDS2A
|
||||||
|
FORMAT_IBUS+PWM 0
|
||||||
|
FORMAT_IBUS+PPM 1
|
||||||
|
FORMAT_SBUS+PWM 2
|
||||||
|
FORMAT_SBUS+PPM 3
|
||||||
Power value => 0x80 0=High/1=Low
|
Power value => 0x80 0=High/1=Low
|
||||||
Stream[3] = option_protocol;
|
Stream[3] = option_protocol;
|
||||||
option_protocol value is -127..127
|
option_protocol value is -127..127
|
||||||
|
@ -127,7 +127,7 @@ volatile uint8_t rx_ok_buff[RXBUFFER_SIZE];
|
|||||||
volatile uint8_t discard_frame = 0;
|
volatile uint8_t discard_frame = 0;
|
||||||
|
|
||||||
// Telemetry
|
// Telemetry
|
||||||
#define MAX_PKT 27
|
#define MAX_PKT 29
|
||||||
uint8_t pkt[MAX_PKT];//telemetry receiving packets
|
uint8_t pkt[MAX_PKT];//telemetry receiving packets
|
||||||
#if defined(TELEMETRY)
|
#if defined(TELEMETRY)
|
||||||
#ifdef INVERT_TELEMETRY
|
#ifdef INVERT_TELEMETRY
|
||||||
|
@ -61,6 +61,15 @@ void DSM_frame()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined AFHDS2A_TELEMETRY
|
||||||
|
void AFHDSA_short_frame()
|
||||||
|
{
|
||||||
|
Serial_write(0xAA); // Telemetry packet
|
||||||
|
for (uint8_t i = 0; i < 29; i++) // RSSI value followed by 4*7 bytes of telemetry data
|
||||||
|
Serial_write(pkt[i]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void frskySendStuffed()
|
void frskySendStuffed()
|
||||||
{
|
{
|
||||||
Serial_write(START_STOP);
|
Serial_write(START_STOP);
|
||||||
@ -485,6 +494,13 @@ void TelemetryUpdate()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if defined AFHDS2A_TELEMETRY
|
||||||
|
if(telemetry_link == 2 && protocol == MODE_AFHDS2A)
|
||||||
|
{
|
||||||
|
AFHDSA_short_frame();
|
||||||
|
telemetry_link=0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if(telemetry_link && protocol != MODE_FRSKYX )
|
if(telemetry_link && protocol != MODE_FRSKYX )
|
||||||
{ // FrSkyD + Hubsan + AFHDS2A
|
{ // FrSkyD + Hubsan + AFHDS2A
|
||||||
frsky_link_frame();
|
frsky_link_frame();
|
||||||
|
@ -106,7 +106,7 @@
|
|||||||
#define DSM_TELEMETRY
|
#define DSM_TELEMETRY
|
||||||
#define SPORT_TELEMETRY
|
#define SPORT_TELEMETRY
|
||||||
#define HUB_TELEMETRY
|
#define HUB_TELEMETRY
|
||||||
|
#define AFHDS2A_TELEMETRY
|
||||||
|
|
||||||
/****************************/
|
/****************************/
|
||||||
/*** SERIAL MODE SETTINGS ***/
|
/*** SERIAL MODE SETTINGS ***/
|
||||||
@ -271,4 +271,4 @@ const PPM_Parameters PPM_prot[15]= {
|
|||||||
// As an example, it's usefull for the WLTOYS F929/F939/F949/F959 (all using the Flysky protocol) which requires a bind at each power up.
|
// As an example, it's usefull for the WLTOYS F929/F939/F949/F959 (all using the Flysky protocol) which requires a bind at each power up.
|
||||||
|
|
||||||
// Option: the value is between -127 and +127.
|
// Option: the value is between -127 and +127.
|
||||||
// The option value is only valid for some protocols, read this page for more information: https://github.com/pascallanger/DIY-Multiprotocol-TX-Module/blob/master/Protocols_Details.md
|
// The option value is only valid for some protocols, read this page for more information: https://github.com/pascallanger/DIY-Multiprotocol-TX-Module/blob/master/Protocols_Details.md
|
||||||
|
Loading…
x
Reference in New Issue
Block a user