mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-02-04 16:48:10 +00:00
New protocol: Mould King
This commit is contained in:
parent
7157d3d906
commit
a8897df3f2
@ -192,3 +192,6 @@
|
||||
83,0,E129,E129,1,TakLan,EmStop,TrimA,TrimE,TrimR
|
||||
84,0,JOYSWAY,Std,0
|
||||
85,0,E016H,Std,1,Stop,Flip,n-a,HLess,RTH
|
||||
87,0,IKEA
|
||||
89,0,LOSI
|
||||
90,0,MouldKg,Std,E,F
|
@ -280,7 +280,7 @@ local function Multi_Init()
|
||||
end
|
||||
|
||||
--Exceptions on first 4 channels...
|
||||
if ( protocol == 73 or (protocol == 74 and sub_protocol == 0) or (protocol == 60 and sub_protocol == 2) ) then -- Kyosho or RadioLink Surface or Pelikan/SCX24
|
||||
if ( protocol == 73 or (protocol == 74 and sub_protocol == 0) or (protocol == 60 and sub_protocol == 2) or protocol == 89) then -- Kyosho or RadioLink Surface or Pelikan/SCX24 or Losi
|
||||
channel_names[1] = "ST"
|
||||
channel_names[2] = "THR"
|
||||
channel_names[3] = "CH3"
|
||||
@ -296,6 +296,12 @@ local function Multi_Init()
|
||||
channel_names[3] = "AUX1"
|
||||
channel_names[4] = "AUX2"
|
||||
end
|
||||
if ( protocol == 90 ) then -- Mould King
|
||||
channel_names[1] = "A"
|
||||
channel_names[2] = "B"
|
||||
channel_names[3] = "C"
|
||||
channel_names[4] = "D"
|
||||
end
|
||||
|
||||
--Check MultiChan.txt
|
||||
local f = io.open("/SCRIPTS/TOOLS/MultiChan.txt", "r")
|
||||
|
162
Multiprotocol/MouldKg_nrf24l01.ino
Normal file
162
Multiprotocol/MouldKg_nrf24l01.ino
Normal file
@ -0,0 +1,162 @@
|
||||
/*
|
||||
This project is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Multiprotocol is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Multiprotocol. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#if defined(MOULDKG_NRF24L01_INO)
|
||||
|
||||
#include "iface_xn297.h"
|
||||
|
||||
//#define FORCE_MOULDKG_ORIGINAL_ID
|
||||
|
||||
#define MOULDKG_PACKET_PERIOD 5000
|
||||
#define MOULDKG_BIND_PACKET_PERIOD 12000
|
||||
#define MOULDKG_TX_BIND_CHANNEL 11
|
||||
#define MOULDKG_RX_BIND_CHANNEL 76
|
||||
#define MOULDKG_PAYLOAD_SIZE 5
|
||||
#define MOULDKG_BIND_PAYLOAD_SIZE 7
|
||||
#define MOULDKG_BIND_COUNT 300
|
||||
#define MOULDKG_RF_NUM_CHANNELS 4
|
||||
|
||||
enum {
|
||||
MOULDKG_BINDTX=0,
|
||||
MOULDKG_BINDRX,
|
||||
MOULDKG_DATA,
|
||||
};
|
||||
|
||||
static void __attribute__((unused)) MOULDKG_send_packet()
|
||||
{
|
||||
memcpy(&packet[1],rx_tx_addr,3);
|
||||
if(IS_BIND_IN_PROGRESS)
|
||||
{
|
||||
packet[0] = 0xC0;
|
||||
memset(&packet[4], 0x00, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
XN297_RFChannel(hopping_frequency[(packet_count>>1)&0x03]);
|
||||
|
||||
uint8_t val=0;
|
||||
if(packet_count&1)
|
||||
{
|
||||
packet[0] = 0x31;
|
||||
//Button B
|
||||
if(Channel_data[CH2]>CHANNEL_MAX_COMMAND) val |= 0x40;
|
||||
else if(Channel_data[CH2]<CHANNEL_MIN_COMMAND) val |= 0x80;
|
||||
//Button C
|
||||
if(Channel_data[CH3]>CHANNEL_MAX_COMMAND) val |= 0x10;
|
||||
else if(Channel_data[CH3]<CHANNEL_MIN_COMMAND) val |= 0x20;
|
||||
}
|
||||
else
|
||||
{
|
||||
packet[0] = 0x30;
|
||||
val = 0x60
|
||||
| GET_FLAG(CH5_SW, 0x80) // Button E
|
||||
| GET_FLAG(CH6_SW, 0x10); // Button F
|
||||
}
|
||||
//Button A
|
||||
if(Channel_data[CH1]>CHANNEL_MAX_COMMAND) val |= 0x01;
|
||||
else if(Channel_data[CH1]<CHANNEL_MIN_COMMAND) val |= 0x02;
|
||||
//Button D
|
||||
if(Channel_data[CH4]>CHANNEL_MAX_COMMAND) val |= 0x04;
|
||||
else if(Channel_data[CH4]<CHANNEL_MIN_COMMAND) val |= 0x08;
|
||||
packet[4]= val;
|
||||
|
||||
packet_count++;
|
||||
}
|
||||
|
||||
// Send
|
||||
XN297_SetPower();
|
||||
XN297_SetTxRxMode(TX_EN);
|
||||
XN297_WritePayload(packet, IS_BIND_IN_PROGRESS?MOULDKG_BIND_PAYLOAD_SIZE:MOULDKG_PAYLOAD_SIZE);
|
||||
#if 0
|
||||
uint8_t len = IS_BIND_IN_PROGRESS?MOULDKG_BIND_PAYLOAD_SIZE:MOULDKG_PAYLOAD_SIZE;
|
||||
for(uint8_t i=0; i < len; i++)
|
||||
debug("%02X ", packet[i]);
|
||||
debugln();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) MOULDKG_initialize_txid()
|
||||
{
|
||||
rx_tx_addr[0]=rx_tx_addr[3]; // Use RX_num;
|
||||
#ifdef FORCE_MOULDKG_ORIGINAL_ID
|
||||
rx_tx_addr[0]=0x57;
|
||||
rx_tx_addr[1]=0x1B;
|
||||
rx_tx_addr[2]=0xF8;
|
||||
#endif
|
||||
//Are the frequencies constant??? If not where are they coming from???
|
||||
memcpy(hopping_frequency,(uint8_t*)"\x0F\x1C\x39\x3C", MOULDKG_RF_NUM_CHANNELS); // 15,28,57,60
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) MOULDKG_RF_init()
|
||||
{
|
||||
XN297_Configure(XN297_CRCEN, XN297_SCRAMBLED, XN297_1M);
|
||||
XN297_SetTXAddr((uint8_t*)"KDH", 3);
|
||||
XN297_SetRXAddr((uint8_t*)"KDH", MOULDKG_BIND_PAYLOAD_SIZE);
|
||||
}
|
||||
|
||||
uint16_t MOULDKG_callback()
|
||||
{
|
||||
switch(phase)
|
||||
{
|
||||
case MOULDKG_BINDTX:
|
||||
if(XN297_IsRX())
|
||||
{
|
||||
//Example: TX: C=11 S=Y A= 4B 44 48 P(7)= C0 37 02 4F 00 00 00
|
||||
// RX: C=76 S=Y A= 4B 44 48 P(7)= 5A 37 02 4F 03 0D 8E
|
||||
XN297_ReadPayload(packet_in, MOULDKG_BIND_PAYLOAD_SIZE);
|
||||
for(uint8_t i=0; i < MOULDKG_BIND_PAYLOAD_SIZE; i++)
|
||||
debug("%02X ", packet_in[i]);
|
||||
debugln();
|
||||
//Not sure if I should test packet_in[0]
|
||||
if(memcmp(&packet_in[1],&packet[1],3)==0)
|
||||
{//TX ID match, use RX ID to transmit normal packets
|
||||
XN297_SetTXAddr(&packet_in[4], 3);
|
||||
XN297_SetTxRxMode(TXRX_OFF);
|
||||
BIND_DONE;
|
||||
}
|
||||
}
|
||||
XN297_RFChannel(MOULDKG_TX_BIND_CHANNEL); // Set TX bind channel
|
||||
XN297_SetTxRxMode(TXRX_OFF);
|
||||
MOULDKG_send_packet();
|
||||
phase++;
|
||||
return 500;
|
||||
case MOULDKG_BINDRX:
|
||||
//Wait for the packet transmission to finish
|
||||
while(XN297_IsPacketSent()==false);
|
||||
//Switch to RX
|
||||
XN297_SetTxRxMode(TXRX_OFF);
|
||||
XN297_RFChannel(MOULDKG_RX_BIND_CHANNEL); // Set RX bind channel
|
||||
XN297_SetTxRxMode(RX_EN);
|
||||
phase = MOULDKG_BINDTX;
|
||||
return MOULDKG_BIND_PACKET_PERIOD-500;
|
||||
case MOULDKG_DATA:
|
||||
#ifdef MULTI_SYNC
|
||||
telemetry_set_input_sync(MOULDKG_PACKET_PERIOD);
|
||||
#endif
|
||||
MOULDKG_send_packet();
|
||||
break;
|
||||
}
|
||||
return MOULDKG_PACKET_PERIOD;
|
||||
}
|
||||
|
||||
void MOULDKG_init()
|
||||
{
|
||||
BIND_IN_PROGRESS; // autobind protocol
|
||||
MOULDKG_initialize_txid();
|
||||
MOULDKG_RF_init();
|
||||
bind_counter = MOULDKG_BIND_COUNT;
|
||||
packet_count = 0;
|
||||
}
|
||||
|
||||
#endif
|
@ -84,4 +84,5 @@
|
||||
84,JOYSWAY
|
||||
85,E016H
|
||||
87,IKEA
|
||||
89,LOSI
|
||||
89,Losi
|
||||
90,MouldKg
|
@ -101,6 +101,7 @@ const char STR_E016H[] ="E016H";
|
||||
const char STR_IKEAANSLUTA[]="Ansluta";
|
||||
const char STR_CONFIG[] ="Config";
|
||||
const char STR_LOSI[] ="Losi";
|
||||
const char STR_MOULDKG[] ="MouldKg";
|
||||
|
||||
const char STR_SUBTYPE_FLYSKY[] = "\x04""Std\0""V9x9""V6x6""V912""CX20";
|
||||
const char STR_SUBTYPE_HUBSAN[] = "\x04""H107""H301""H501";
|
||||
@ -365,6 +366,9 @@ const mm_protocol_definition multi_protocols[] = {
|
||||
#if defined(MLINK_CYRF6936_INO)
|
||||
{PROTO_MLINK, STR_MLINK, NO_SUBTYPE, 0, OPTION_NONE, 1, 0, SW_CYRF, MLINK_init, MLINK_callback },
|
||||
#endif
|
||||
#if defined(MOULDKG_NRF24L01_INO)
|
||||
{PROTO_MOULDKG, STR_MOULDKG, NO_SUBTYPE, 0, OPTION_NONE, 0, 0, SW_NRF, MOULDKG_init, MOULDKG_callback },
|
||||
#endif
|
||||
#if defined(MT99XX_CCNRF_INO)
|
||||
{PROTO_MT99XX, STR_MT99XX, STR_SUBTYPE_MT99, 7, OPTION_NONE, 0, 0, SW_NRF, MT99XX_init, MT99XX_callback },
|
||||
#endif
|
||||
|
@ -19,7 +19,7 @@
|
||||
#define VERSION_MAJOR 1
|
||||
#define VERSION_MINOR 3
|
||||
#define VERSION_REVISION 2
|
||||
#define VERSION_PATCH_LEVEL 80
|
||||
#define VERSION_PATCH_LEVEL 81
|
||||
|
||||
#define MODE_SERIAL 0
|
||||
|
||||
@ -117,6 +117,7 @@ enum PROTOCOLS
|
||||
PROTO_IKEAANSLUTA = 87, // =>CC2500
|
||||
PROTO_WILLIFM = 88, // 27/35ab/40/41/72 MHz module external project
|
||||
PROTO_LOSI = 89, // =>CYRF6936
|
||||
PROTO_MOULDKG = 90, // =>NRF24L01
|
||||
|
||||
PROTO_NANORF = 126, // =>NRF24L01
|
||||
PROTO_TEST = 127, // =>CC2500
|
||||
|
@ -277,6 +277,7 @@
|
||||
#undef FRSKY_RX_CC2500_INO
|
||||
#undef HITEC_CC2500_INO
|
||||
#undef HOTT_CC2500_INO
|
||||
#undef IKEAANSLUTA_CC2500_INO
|
||||
#undef REDPINE_CC2500_INO
|
||||
#undef RLINK_CC2500_INO
|
||||
#undef SCANNER_CC2500_INO
|
||||
@ -307,6 +308,7 @@
|
||||
#undef JJRC345_NRF24L01_INO
|
||||
#undef KN_NRF24L01_INO
|
||||
#undef LOLI_NRF24L01_INO
|
||||
#undef MOULDKG_NRF24L01_INO
|
||||
#undef NCC1701_NRF24L01_INO
|
||||
#undef POTENSIC_NRF24L01_INO
|
||||
#undef PROPEL_NRF24L01_INO
|
||||
|
@ -235,6 +235,7 @@
|
||||
#define JJRC345_NRF24L01_INO
|
||||
#define KN_NRF24L01_INO
|
||||
#define LOLI_NRF24L01_INO
|
||||
#define MOULDKG_NRF24L01_INO
|
||||
#define NCC1701_NRF24L01_INO
|
||||
#define POTENSIC_NRF24L01_INO
|
||||
#define PROPEL_NRF24L01_INO
|
||||
@ -726,6 +727,8 @@ const PPM_Parameters PPM_prot[14*NBR_BANKS]= {
|
||||
PHOENIX
|
||||
PROTO_MLINK
|
||||
NONE
|
||||
PROTO_MOULDKG
|
||||
NONE
|
||||
PROTO_MT99XX
|
||||
MT99
|
||||
H7
|
||||
|
@ -114,9 +114,10 @@ CFlie|38|CFlie||||||||NRF24L01|
|
||||
[KN](Protocols_Details.md#KN---9)|9|WLTOYS|FEILUN|||||||NRF24L01|
|
||||
[Kyosho](Protocols_Details.md#Kyosho---73)|73|FHSS|Hype|||||||A7105|
|
||||
[LOLI](Protocols_Details.md#LOLI---82)|82|||||||||NRF24L01|
|
||||
[Losi](Protocols_Details.md#LOLI---89)|89|||||||||CYRF6936|
|
||||
[Losi](Protocols_Details.md#Losi---89)|89|||||||||CYRF6936|
|
||||
[MJXq](Protocols_Details.md#MJXQ---18)|18|WLH08|X600|X800|H26D|E010*|H26WH|PHOENIX*||NRF24L01|XN297
|
||||
[MLINK](Protocols_Details.md#MLINK---78)|78|||||||||CYRF6936|
|
||||
[MouldKg]Protocols_Details.md#MouldKg---90)|90|||||||||NRF24L01|XN297
|
||||
[MT99xx](Protocols_Details.md#MT99XX---17)|17|MT|H7|YZ|LS|FY805|A180|DRAGON||NRF24L01|XN297
|
||||
[NCC1701](Protocols_Details.md#NCC1701---44)|44|||||||||NRF24L01|
|
||||
[OMP](Protocols_Details.md#OMP---77)|77|||||||||CC2500&NRF24L01|XN297L
|
||||
@ -1702,6 +1703,13 @@ CH14| CH6 | -100% | 0% | | - | -
|
||||
CH15| CH7 | -100% | 0% | - | - | +100%
|
||||
CH16| CH8 | -100% | 0% | - | - | -
|
||||
|
||||
## MouldKg - *90*
|
||||
Mould King 2.4GHz TX
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6
|
||||
---|---|---|---|---|---
|
||||
A|B|C|D|E|F
|
||||
|
||||
## NCC1701 - *44*
|
||||
Model: Air Hogs Star Trek USS Enterprise NCC-1701-A
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user