mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-07-03 03:57:51 +00:00
Correction script LUA + suivit
This commit is contained in:
parent
c5d819be81
commit
8faf5abe38
@ -196,19 +196,8 @@ const uint8_t PROGMEM FLYSKY_A7105_regs[] = {
|
||||
0x13, 0xc3, 0x00, 0xff, 0x00, 0x00, 0x3b, 0x00, 0x17, 0x47, 0x80, 0x03, 0x01, 0x45, 0x18, 0x00,
|
||||
0x01, 0x0f, 0xff
|
||||
};
|
||||
|
||||
#define ID_NORMAL 0x55201041
|
||||
#define ID_PLUS 0xAA201041
|
||||
|
||||
/*
|
||||
static const uint8_t a7105Regs[] = {
|
||||
-1, 0x42, 0x00, 0x14, 0x00, -1 , -1 , 0x00, 0x00, 0x00, 0x00, 0x01, 0x21, 0x05, 0x00, 0x50,
|
||||
0x9e, 0x4b, 0x00, 0x02, 0x16, 0x2b, 0x12, 0x00, 0x62, 0x80, 0x80, 0x00, 0x0a, 0x32, 0xc3, 0x0f,
|
||||
0x13, 0xc3, 0x00, -1, 0x00, 0x00, 0x3b, 0x00, 0x17, 0x47, 0x80, 0x03, 0x01, 0x45, 0x18, 0x00,
|
||||
0x01, 0x0f, -1,
|
||||
};
|
||||
*/
|
||||
|
||||
void A7105_Init(uint8_t protocol)
|
||||
{
|
||||
void *A7105_Regs;
|
||||
|
@ -181,14 +181,15 @@ static void __attribute__((unused)) hubsan_build_packet()
|
||||
}
|
||||
|
||||
#if defined(TELEMETRY)
|
||||
/*static uint8_t hubsan_check_integrity()
|
||||
static uint8_t __attribute__((unused)) hubsan_check_integrity()
|
||||
{
|
||||
int sum = 0;
|
||||
if( (packet[0]&0xFE) != 0xE0 )
|
||||
return 0;
|
||||
uint8_t sum = 0;
|
||||
for(uint8_t i = 0; i < 15; i++)
|
||||
sum += packet[i];
|
||||
return packet[15] == ((256 - (sum % 256)) & 0xFF);
|
||||
return ( packet[15] == (uint8_t)(-sum) );
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
|
||||
uint16_t ReadHubsan()
|
||||
@ -295,7 +296,8 @@ uint16_t ReadHubsan()
|
||||
}
|
||||
else {
|
||||
#if defined(TELEMETRY)
|
||||
if( rfMode == A7105_TX) {// switch to rx mode 3ms after packet sent
|
||||
if( rfMode == A7105_TX)
|
||||
{// switch to rx mode 3ms after packet sent
|
||||
for( i=0; i<10; i++)
|
||||
{
|
||||
if( !(A7105_ReadReg(A7105_00_MODE) & 0x01)) {// wait for tx completion
|
||||
@ -306,15 +308,23 @@ uint16_t ReadHubsan()
|
||||
}
|
||||
}
|
||||
}
|
||||
if( rfMode == A7105_RX) { // check for telemetry frame
|
||||
for( i=0; i<10; i++) {
|
||||
if( !(A7105_ReadReg(A7105_00_MODE) & 0x01)) { // data received
|
||||
if( rfMode == A7105_RX)
|
||||
{ // check for telemetry frame
|
||||
for( i=0; i<10; i++)
|
||||
{
|
||||
if( !(A7105_ReadReg(A7105_00_MODE) & 0x01))
|
||||
{ // data received
|
||||
A7105_ReadData();
|
||||
if( !(A7105_ReadReg(A7105_00_MODE) & 0x01)){ // data received
|
||||
v_lipo=packet[13];// hubsan lipo voltage 8bits the real value is h_lipo/10(0x2A=42-4.2V)
|
||||
if( hubsan_check_integrity() )
|
||||
{
|
||||
v_lipo=packet[13];// hubsan lipo voltage 8bits the real value is h_lipo/10(0x2A=42 -> 4.2V)
|
||||
telemetry_link=1;
|
||||
}
|
||||
A7105_Strobe(A7105_RX);
|
||||
// Read TX RSSI
|
||||
RSSI_dBm=256-(A7105_ReadReg(A7105_1D_RSSI_THOLD)*8)/5; // value from A7105 is between 8 for maximum signal strength to 160 or less
|
||||
if(RSSI_dBm<0) RSSI_dBm=0;
|
||||
else if(RSSI_dBm>255) RSSI_dBm=255;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -344,7 +354,6 @@ uint16_t initHubsan() {
|
||||
packet_count=0;
|
||||
id_data=ID_NORMAL;
|
||||
#if defined(TELEMETRY)
|
||||
v_lipo=0;
|
||||
telemetry_link=0;
|
||||
#endif
|
||||
return 10000;
|
||||
|
@ -100,7 +100,6 @@ uint8_t pktt[MAX_PKT];//telemetry receiving packets
|
||||
int16_t RSSI_dBm;
|
||||
//const uint8_t RSSI_offset=72;//69 71.72 values db
|
||||
uint8_t telemetry_link=0;
|
||||
#include "telemetry.h"
|
||||
#endif
|
||||
|
||||
// Callback
|
||||
@ -623,11 +622,11 @@ uint16_t limit_channel_100(uint8_t ch)
|
||||
#if defined(TELEMETRY)
|
||||
void Serial_write(uint8_t data)
|
||||
{
|
||||
uint8_t t=tx_head;
|
||||
if(++t>=TXBUFFER_SIZE)
|
||||
t=0;
|
||||
tx_buff[t]=data;
|
||||
tx_head=t;
|
||||
cli(); // disable global int
|
||||
if(++tx_head>=TXBUFFER_SIZE)
|
||||
tx_head=0;
|
||||
tx_buff[tx_head]=data;
|
||||
sei(); // enable global int
|
||||
UCSR0B |= (1<<UDRIE0);//enable UDRE interrupt
|
||||
}
|
||||
#endif
|
||||
@ -647,6 +646,7 @@ static void Mprotocol_serial_init()
|
||||
UCSR0B |= (1<<TXEN0);//tx enable
|
||||
}
|
||||
|
||||
#if defined(TELEMETRY)
|
||||
static void PPM_Telemetry_serial_init()
|
||||
{
|
||||
//9600 bauds
|
||||
@ -656,6 +656,7 @@ static void PPM_Telemetry_serial_init()
|
||||
UCSR0C |= (1<<UCSZ01)|(1<<UCSZ00);
|
||||
UCSR0B |= (1<<TXEN0);//tx enable
|
||||
}
|
||||
#endif
|
||||
|
||||
// Convert 32b id to rx_tx_addr
|
||||
static void set_rx_tx_addr(uint32_t id)
|
||||
|
@ -22,7 +22,7 @@ void frskySendStuffed()
|
||||
if ((frame[i] == 0x7e) || (frame[i] == 0x7d))
|
||||
{
|
||||
Serial_write(0x7D);
|
||||
frame[i] ^= 0x20;
|
||||
frame[i] ^= 0x20;
|
||||
}
|
||||
Serial_write(frame[i]);
|
||||
}
|
||||
@ -39,25 +39,24 @@ void compute_RSSIdbm(){
|
||||
|
||||
void frsky_link_frame()
|
||||
{
|
||||
frame[0] = 0xfe;
|
||||
frame[0] = 0xFE;
|
||||
if ((cur_protocol[0]&0x1F)==MODE_FRSKY)
|
||||
{
|
||||
compute_RSSIdbm();
|
||||
frame[1] = pktt[3];
|
||||
frame[2] = pktt[4];
|
||||
frame[3] = (uint8_t)RSSI_dBm;
|
||||
compute_RSSIdbm();
|
||||
frame[1] = pktt[3];
|
||||
frame[2] = pktt[4];
|
||||
frame[3] = (uint8_t)RSSI_dBm;
|
||||
frame[4] = pktt[5]*2;
|
||||
frame[5] = frame[6] = frame[7] = frame[8] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
if ((cur_protocol[0]&0x1F)==MODE_HUBSAN)
|
||||
{
|
||||
frame[1] = v_lipo*2; //v_lipo; common 0x2A=42/10=4.2V
|
||||
frame[2] = frame[1];
|
||||
frame[3] =0X6e;
|
||||
frame[4] =2*0x6e;
|
||||
frame[5] = frame[6] = frame[7] = frame[8] = 0;
|
||||
}
|
||||
frame[3] = 0x00;
|
||||
frame[4] = (uint8_t)RSSI_dBm;
|
||||
}
|
||||
frame[5] = frame[6] = frame[7] = frame[8] = 0;
|
||||
frskySendStuffed();
|
||||
}
|
||||
|
||||
@ -129,7 +128,7 @@ void frsky_user_frame()
|
||||
}
|
||||
else
|
||||
pass=0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void frskyUpdate()
|
||||
@ -141,9 +140,9 @@ void frskyUpdate()
|
||||
return;
|
||||
}
|
||||
#if defined HUB_TELEMETRY
|
||||
if(!telemetry_link)
|
||||
if(!telemetry_link && (cur_protocol[0]&0x1F) != MODE_HUBSAN )
|
||||
frsky_user_frame();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
@ -44,7 +44,7 @@ local function run_func(proto, sw)
|
||||
|
||||
-- delais init
|
||||
if proto ~= debut then
|
||||
tps = getTime() + 500 -- delai pour mini 12 cycle PPM
|
||||
tps = getTime() + 250 -- delai pour mini 12 cycle PPM
|
||||
tpsact = 1024
|
||||
debut = proto
|
||||
end
|
||||
@ -54,7 +54,7 @@ local function run_func(proto, sw)
|
||||
local dir = 0
|
||||
local pro = 0
|
||||
|
||||
if tpsact == 0 and sw < 200 then
|
||||
if tpsact == 0 and sw < 100 then
|
||||
-- reprise valeur input
|
||||
pro = getValue(1)
|
||||
ail = getValue(2)
|
||||
@ -82,7 +82,10 @@ local function run_func(proto, sw)
|
||||
if proto % 3 == 1 then dir = -1024 end
|
||||
if proto % 3 == 0 then dir = 1024 end
|
||||
|
||||
if tps < getTime() then tpsact = 0 end
|
||||
if tps < getTime() then
|
||||
tpsact = tpsact - 512
|
||||
if tpsact>-20 then tps = getTime() + 250 end
|
||||
end
|
||||
sw = tpsact
|
||||
end
|
||||
|
||||
|
@ -13,6 +13,14 @@
|
||||
along with Multiprotocol. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Check selected board type
|
||||
#ifndef ARDUINO_AVR_PRO
|
||||
#error You must select the board type "Arduino Pro or Pro Mini"
|
||||
#endif
|
||||
#if F_CPU != 16000000L || not defined(__AVR_ATmega328P__)
|
||||
#error You must select the processor type "ATmega328(5V, 16MHz)"
|
||||
#endif
|
||||
|
||||
//******************
|
||||
// Protocols
|
||||
//******************
|
||||
|
BIN
sync.ffs_db
BIN
sync.ffs_db
Binary file not shown.
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 77 KiB |
Loading…
x
Reference in New Issue
Block a user