From 58ed8ca60f4a83c796092da94a7983ded9ffacf2 Mon Sep 17 00:00:00 2001 From: Pascal Langer Date: Thu, 27 May 2021 19:01:08 +0200 Subject: [PATCH] Mould King: Analog and digital sub protocols --- Lua_scripts/MultiChan.txt | 3 +- Multiprotocol/Losi_cyrf6936.ino | 5 ++- Multiprotocol/MouldKg_nrf24l01.ino | 70 +++++++++++++++++++----------- Multiprotocol/Multi.txt | 2 +- Multiprotocol/Multi_Protos.ino | 3 +- Multiprotocol/Multiprotocol.h | 8 +++- Multiprotocol/_Config.h | 3 +- Protocols_Details.md | 10 ++++- 8 files changed, 70 insertions(+), 34 deletions(-) diff --git a/Lua_scripts/MultiChan.txt b/Lua_scripts/MultiChan.txt index b968d16..943f2c0 100644 --- a/Lua_scripts/MultiChan.txt +++ b/Lua_scripts/MultiChan.txt @@ -194,4 +194,5 @@ 85,0,E016H,Std,1,Stop,Flip,n-a,HLess,RTH 87,0,IKEA 89,0,LOSI -90,0,MouldKg,Std,E,F \ No newline at end of file +90,0,MouldKg,Analog +90,1,MouldKg,Digit,E,F \ No newline at end of file diff --git a/Multiprotocol/Losi_cyrf6936.ino b/Multiprotocol/Losi_cyrf6936.ino index e504ff4..114b09f 100644 --- a/Multiprotocol/Losi_cyrf6936.ino +++ b/Multiprotocol/Losi_cyrf6936.ino @@ -121,14 +121,15 @@ uint16_t LOSI_callback() void LOSI_init() { LOSI_cyrf_init(); - CYRF_FindBestChannels(hopping_frequency, 1, 0, 0x13, 75); // 75 is unknown since dump stops at 0x27, this routine resets the CRC Seed to 0 - CYRF_ConfigRFChannel(hopping_frequency[0] | 1); // Only odd channels + //CYRF_FindBestChannels(hopping_frequency, 1, 0, 0x13, 75); // 75 is unknown since dump stops at 0x27, this routine resets the CRC Seed to 0 + //CYRF_ConfigRFChannel(hopping_frequency[0] | 1); // Only odd channels #ifdef LOSI_FORCE_ID rx_tx_addr[0] = 0x47; rx_tx_addr[1] = 0x52; rx_tx_addr[2] = 0xAE; rx_tx_addr[3] = 0xAA; + CYRF_ConfigRFChannel(0x27); #endif if(IS_BIND_IN_PROGRESS) diff --git a/Multiprotocol/MouldKg_nrf24l01.ino b/Multiprotocol/MouldKg_nrf24l01.ino index 53e38bb..c1eeb6c 100644 --- a/Multiprotocol/MouldKg_nrf24l01.ino +++ b/Multiprotocol/MouldKg_nrf24l01.ino @@ -22,7 +22,8 @@ Multiprotocol is distributed in the hope that it will be useful, #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_PAYLOAD_SIZE_DIGIT 5 +#define MOULDKG_PAYLOAD_SIZE_ANALOG 10 #define MOULDKG_BIND_PAYLOAD_SIZE 7 #define MOULDKG_BIND_COUNT 300 #define MOULDKG_RF_NUM_CHANNELS 4 @@ -35,6 +36,7 @@ enum { static void __attribute__((unused)) MOULDKG_send_packet() { + uint8_t len = MOULDKG_BIND_PAYLOAD_SIZE; memcpy(&packet[1],rx_tx_addr,3); if(IS_BIND_IN_PROGRESS) { @@ -45,41 +47,52 @@ static void __attribute__((unused)) MOULDKG_send_packet() { XN297_RFChannel(hopping_frequency[(packet_count>>1)&0x03]); - uint8_t val=0; - if(packet_count&1==0) + if(sub_protocol == MOULDKG_ANALOG) { - packet[0] = 0x31; - //Button B - if(Channel_data[CH2]>CHANNEL_MAX_COMMAND) val |= 0x40; - else if(Channel_data[CH2]CHANNEL_MAX_COMMAND) val |= 0x10; - else if(Channel_data[CH3]CHANNEL_MAX_COMMAND) val |= 0x01; - else if(Channel_data[CH1]CHANNEL_MAX_COMMAND) val |= 0x04; - else if(Channel_data[CH4]CHANNEL_MAX_COMMAND) val |= 0x40; + else if(Channel_data[CH2]CHANNEL_MAX_COMMAND) val |= 0x10; + else if(Channel_data[CH3]CHANNEL_MAX_COMMAND) val |= 0x01; + else if(Channel_data[CH1]CHANNEL_MAX_COMMAND) val |= 0x04; + else if(Channel_data[CH4]