diff --git a/Multiprotocol/A7105_SPI.ino b/Multiprotocol/A7105_SPI.ino
index fe54cfd..6b3f7f0 100644
--- a/Multiprotocol/A7105_SPI.ino
+++ b/Multiprotocol/A7105_SPI.ino
@@ -217,6 +217,14 @@ void A7105_Init(void)
for (uint8_t i = 0; i < 0x32; i++)
{
uint8_t val=pgm_read_byte_near(&A7105_Regs[i]);
+ #ifdef FLYSKY_A7105_INO
+ if(protocol==MODE_FLYSKY && sub_protocol==CX20)
+ {
+ if(i==0x0E) val=0x01;
+ if(i==0x1F) val=0x1F;
+ if(i==0x20) val=0x1E;
+ }
+ #endif
if( val != 0xFF)
A7105_WriteReg(i, val);
}
diff --git a/Multiprotocol/CX10_nrf24l01.ino b/Multiprotocol/CX10_nrf24l01.ino
index 2c649b4..ee87a44 100644
--- a/Multiprotocol/CX10_nrf24l01.ino
+++ b/Multiprotocol/CX10_nrf24l01.ino
@@ -60,9 +60,6 @@ static void __attribute__((unused)) CX10_Write_Packet(uint8_t bind)
uint16_t aileron=Servo_data[AILERON];
uint16_t elevator=3000-Servo_data[ELEVATOR];
uint16_t rudder=3000-Servo_data[RUDDER];
- packet[9+offset]= lowByte(Servo_data[THROTTLE]);
- packet[10+offset]= highByte(Servo_data[THROTTLE]);
-
// Channel 5 - flip flag
packet[12+offset] = GET_FLAG(Servo_AUX1,CX10_FLAG_FLIP); // flip flag applied on rudder
@@ -85,9 +82,9 @@ static void __attribute__((unused)) CX10_Write_Packet(uint8_t bind)
break;
case Q282:
case Q242:
- case Q222:
aileron = 3000 - aileron;
rudder = 3000 - rudder;
+ case Q222:
memcpy(&packet[15], "\x10\x10\xaa\xaa\x00\x00", 6);
//FLIP|LED|PICTURE|VIDEO|HEADLESS|RTH|XCAL|YCAL
flags2 = GET_FLAG(Servo_AUX1, 0x80) // Channel 5 - FLIP
@@ -152,6 +149,8 @@ static void __attribute__((unused)) CX10_Write_Packet(uint8_t bind)
packet[6+offset]= highByte(aileron);
packet[7+offset]= lowByte(elevator);
packet[8+offset]= highByte(elevator);
+ packet[9+offset] = lowByte(Servo_data[THROTTLE]);
+ packet[10+offset]= highByte(Servo_data[THROTTLE]);
packet[11+offset]= lowByte(rudder);
packet[12+offset]|= highByte(rudder);
packet[13+offset]=flags;
diff --git a/Multiprotocol/DSM_cyrf6936.ino b/Multiprotocol/DSM_cyrf6936.ino
index acc4331..d80cf6e 100644
--- a/Multiprotocol/DSM_cyrf6936.ino
+++ b/Multiprotocol/DSM_cyrf6936.ino
@@ -411,7 +411,9 @@ uint16_t ReadDsm()
if(len==10 && DSM_Check_RX_packet())
{
pkt[0]=0x80;
+#if defined(TELEMETRY)
telemetry_link=1; // send received data on serial
+#endif
phase++;
return 2000;
}
@@ -493,7 +495,9 @@ uint16_t ReadDsm()
len=MAX_PKT-2;
CYRF_ReadDataPacketLen(pkt+1, len);
pkt[0]=CYRF_ReadRegister(CYRF_13_RSSI)&0x1F;// store RSSI of the received telemetry signal
+#if defined(TELEMETRY)
telemetry_link=1;
+#endif
}
CYRF_WriteRegister(CYRF_29_RX_ABORT, 0x20); // Abort RX operation
if (phase == DSM_CH2_READ_A && (sub_protocol==DSM2_22 || sub_protocol==DSMX_22) && DSM_num_ch < 8) // 22ms mode
diff --git a/Multiprotocol/Devo_cyrf6936.ino b/Multiprotocol/Devo_cyrf6936.ino
index 885e6c0..e210c5a 100644
--- a/Multiprotocol/Devo_cyrf6936.ino
+++ b/Multiprotocol/Devo_cyrf6936.ino
@@ -13,7 +13,7 @@
along with Multiprotocol. If not, see .
*/
-#if defined(DEVO_CYRF6936_INO)
+#if defined(DEVO_CYRF6936_INO) && defined(CYRF6936_INSTALLED)
#include "iface_cyrf6936.h"
diff --git a/Multiprotocol/FlySky_a7105.ino b/Multiprotocol/FlySky_a7105.ino
index c1632e7..f1ce4c4 100644
--- a/Multiprotocol/FlySky_a7105.ino
+++ b/Multiprotocol/FlySky_a7105.ino
@@ -55,7 +55,6 @@ const uint8_t PROGMEM V912_X17_SEQ[10] = { 0x14, 0x31, 0x40, 0x49, 0x49, //
static void __attribute__((unused)) flysky_apply_extension_flags()
{
- static uint8_t seq_counter;
switch(sub_protocol)
{
case V9X9:
@@ -100,9 +99,9 @@ static void __attribute__((unused)) flysky_apply_extension_flags()
break;
case V912:
- seq_counter++;
- if( seq_counter > 9)
- seq_counter = 0;
+ packet_count++;
+ if( packet_count > 9)
+ packet_count = 0;
packet[12] |= 0x20; // bit 6 is always set ?
packet[13] = 0x00; // unknown
packet[14] = 0x00;
@@ -112,8 +111,8 @@ static void __attribute__((unused)) flysky_apply_extension_flags()
packet[14] |= FLAG_V912_TOPBTN;
packet[15] = 0x27; // [15] and [16] apparently hold an analog channel with a value lower than 1000
packet[16] = 0x03; // maybe it's there for a pitch channel for a CP copter ?
- packet[17] = pgm_read_byte( &V912_X17_SEQ[seq_counter] ) ; // not sure what [17] & [18] are for
- if(seq_counter == 0) // V912 Rx does not even read those bytes... [17-20]
+ packet[17] = pgm_read_byte( &V912_X17_SEQ[packet_count] ) ; // not sure what [17] & [18] are for
+ if(packet_count == 0) // V912 Rx does not even read those bytes... [17-20]
packet[18] = 0x02;
else
packet[18] = 0x00;
@@ -121,6 +120,10 @@ static void __attribute__((unused)) flysky_apply_extension_flags()
packet[20] = 0x00; // unknown
break;
+ case CX20:
+ packet[19] = 0x00; // unknown
+ packet[20] = (hopping_frequency_no<<4)|0x0A;
+ break;
default:
break;
}
@@ -160,11 +163,15 @@ uint16_t ReadFlySky()
else
{
flysky_build_packet(0);
- A7105_WriteData(21, hopping_frequency[hopping_frequency_no]);
- hopping_frequency_no = (hopping_frequency_no + 1) & 0x0F;
+ A7105_WriteData(21, hopping_frequency[hopping_frequency_no & 0x0F]);
A7105_SetPower();
}
- return 1510; //1460 on deviation but not working with the latest V911 bricks... Turnigy 9X v2 is 1533, Flysky TX for 9XR/9XR Pro is 1510, V911 TX is 1490.
+ hopping_frequency_no++;
+
+ if(sub_protocol==CX20)
+ return 3984;
+ else
+ return 1510; //1460 on deviation but not working with the latest V911 bricks... Turnigy 9X v2 is 1533, Flysky TX for 9XR/9XR Pro is 1510, V911 TX is 1490.
}
const uint8_t PROGMEM tx_channels[8][4] = {
@@ -188,24 +195,31 @@ uint16_t initFlySky()
if ((rx_tx_addr[3]&0xF0) > 0x90) // limit offset to 9 as higher values don't work with some RX (ie V912)
rx_tx_addr[3]=rx_tx_addr[3]-0x70;
+
+ // Build frequency hop table
chanrow=rx_tx_addr[3] & 0x0F;
chanoffset=rx_tx_addr[3]/16;
-
- // Build frequency hop table
for(uint8_t i=0;i<16;i++)
{
temp=pgm_read_byte_near(&tx_channels[chanrow>>1][i>>2]);
- if(i&0x01)
+ if(i&0x02)
temp&=0x0F;
else
temp>>=4;
temp*=0x0A;
- if(i&0x02)
+ if(i&0x01)
temp+=0x50;
+ if(sub_protocol==CX20)
+ {//Might need more dumps to be 100% sure but this is how it looks like to work
+ if(temp==0x0A)
+ temp+=0x37;
+ if(temp==0xA0)
+ temp-=0x73;
+ }
hopping_frequency[((chanrow&1)?15-i:i)]=temp-chanoffset;
}
hopping_frequency_no=0;
-
+ packet_count=0;
if(IS_AUTOBIND_FLAG_on)
bind_counter = FLYSKY_BIND_COUNT;
else
diff --git a/Multiprotocol/I2C_Nunchuck.ino b/Multiprotocol/I2C_Nunchuck.ino
new file mode 100644
index 0000000..1d86efa
--- /dev/null
+++ b/Multiprotocol/I2C_Nunchuck.ino
@@ -0,0 +1,94 @@
+#ifdef ENABLE_NUNCHUCK
+#include
+
+#include
+Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, 3, NEO_GRB + NEO_KHZ800);
+
+// Doit etre ajuste en fonction de chaque nunchuck
+#define ZEROX 530
+#define ZEROY 530
+#define ZEROZ 530
+
+#define WII_NUNCHUK_I2C_ADDRESS 0x52 // adresse I2C du nunchuck
+int chan;
+uint8_t tpsc=0, tpsz=0;
+uint8_t data[6]; //nunchuck
+boolean c=false, z=false, cl=false, zl=false, op=false;
+
+void nunchuck_init() {
+ strip.begin();
+ strip.setPixelColor(0, color[0], color[0+1], color[0+2]);
+ strip.setBrightness(200);
+ strip.show();
+
+ Wire.begin();
+
+ Wire.beginTransmission(WII_NUNCHUK_I2C_ADDRESS);
+ Wire.write(0xF0);
+ Wire.write(0x55);
+ Wire.endTransmission();
+
+ Wire.beginTransmission(WII_NUNCHUK_I2C_ADDRESS);
+ Wire.write(0xFB);
+ Wire.write(0x00);
+ Wire.endTransmission();
+ nunchuck_read();
+ nunchuck_read();
+}
+
+void nunchuck_read() {
+ // on demande 6 octets au nunchuck
+ Wire.requestFrom(WII_NUNCHUK_I2C_ADDRESS, 6);
+
+ chan = 0;
+ // tant qu'il y a des donnees
+ while(Wire.available()) { data[chan++] = Wire.read(); } // on recupere les donnees
+
+ // on reinitialise le nunchuck pour la prochaine demande
+ Wire.beginTransmission(WII_NUNCHUK_I2C_ADDRESS);
+ Wire.write(0x00);
+ Wire.endTransmission();
+}
+void nunchuck_update() {
+ nunchuck_read();
+ if(chan >= 5) {
+ // on extrait les donnees
+ // dans mon exemple j'utilise uniquement les donnees d'acceleration sur l'axe Y
+ int JX = data[0];
+ int JY = data[1];
+ // on limite la valeur entre -180 et 180 puis reechantillonnage de 0-255
+ double accelX = constrain( ((data[2] << 2) + ((data[5] >> 2) & 0x03) - ZEROX), -180, 180); //droite / gauche
+ double accelY = constrain( ((data[3] << 2) + ((data[5] >> 4) & 0x03) - ZEROY), -180, 180); // av / ar
+ double accelZ = constrain( ((data[4] << 2) + ((data[5] >> 6) & 0x03) - ZEROZ), -180, 180); // haut / bas
+
+ // calcul appuis long sur boutton
+ if((data[5] >> 0) & 1) { tpsc++; } // compte temps
+ else if(tpsc>300) { cl=!cl; tpsc=0; } // RAZ tps + déclaration appuis LONG
+ else if(tpsc) { c=!c; tpsc=0; } // RAZ tps + déclaration appuis COURT
+// boolean zButton = !((data[5] >> 0) & 1);
+
+ if((data[5] >> 1) & 1) { tpsz++; } else if(tpsz>300) { zl=!zl; tpsz=0; } else if(tpsz) { z=!z; tpsz=0; }
+// boolean cButton = !((data[5] >> 1) & 1);
+
+ Servo_data[THROTTLE] = JY;
+ Servo_data[ELEVATOR] = accelY;
+ Servo_data[RUDDER] = accelX;
+ Servo_data[AILERON] = JX;
+ if(!op) {
+ Servo_data[AUX1] = z;
+ Servo_data[AUX2] = c;
+ Servo_data[AUX3] = cl;
+ }
+ }
+}
+
+/*
+#define DIVISOR_PERCENTS (32)
+#define PERCENT_TO_BYTE(P) ((int8_t)((((int)P) * DIVISOR_PERCENTS) / 100))
+#define BYTE_TO_PERCENT(P) ((int8_t)((((int)P) * 100) / DIVISOR_PERCENTS))
+int16_t expo(int8_t a, int32_t x) {
+ return (((BYTE_TO_PERCENT(a) * x * x) / 100) * x) / (((int32_t)MAX_LEVEL) * MAX_LEVEL)
+ + (100 - BYTE_TO_PERCENT(a)) * x / 100;
+}
+*/
+#endif
\ No newline at end of file
diff --git a/Multiprotocol/Multiprotocol 3.zip b/Multiprotocol/Multiprotocol 3.zip
new file mode 100644
index 0000000..8eef260
Binary files /dev/null and b/Multiprotocol/Multiprotocol 3.zip differ
diff --git a/Multiprotocol/Multiprotocol.ino b/Multiprotocol/Multiprotocol.ino
index cbaebb2..1727a1e 100644
--- a/Multiprotocol/Multiprotocol.ino
+++ b/Multiprotocol/Multiprotocol.ino
@@ -31,6 +31,18 @@
#include "TX_Def.h"
#include "Validate.h"
+#ifdef ENABLE_NUNCHUCK
+ #undef ENABLE_SERIAL
+ #undef ENABLE_PPM
+
+ #undef TELEMETRY
+
+ #undef CYRF6936_INSTALLED
+ #undef CC2500_INSTALLED
+ #undef NRF24L01_INSTALLED
+
+#endif
+
#ifndef STM32_BOARD
#include
#else
@@ -163,7 +175,7 @@ void_function_t remote_callback = 0;
// Init
void setup()
{
- // General pinout
+ // General pinout
#ifdef ORANGE_TX
//XMEGA
PORTD.OUTSET = 0x17 ;
@@ -277,7 +289,7 @@ void setup()
for(uint8_t i=0;i