mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-07-03 03:57:51 +00:00
Fixes to IKEA Ansluta implementation
This commit is contained in:
parent
ea571ac6ab
commit
33a9f78529
@ -18,95 +18,103 @@
|
|||||||
// Once bound, the TX can send one of three commands:
|
// Once bound, the TX can send one of three commands:
|
||||||
// lights off, lights dimmed 50% and lights on.
|
// lights off, lights dimmed 50% and lights on.
|
||||||
// Those are mapped to throttle ranges 0..0x55, 0x56..0xAA, 0xAB..0xFF.
|
// Those are mapped to throttle ranges 0..0x55, 0x56..0xAA, 0xAB..0xFF.
|
||||||
#if defined(IKEA_ANSLUTA_CC2500_INO)
|
#if defined(IKEAANSLUTA_CC2500_INO)
|
||||||
|
|
||||||
#include "iface_cc2500.h"
|
#include "iface_cc2500.h"
|
||||||
|
|
||||||
#define IKEA_ANSLUTA_BIND_COUNT 30 // ~ 2sec autobind/65ms per loop = 30 binding packets
|
#define IKEAANSLUTA_BIND_COUNT 30 // ~ 2sec autobind/65ms per loop = 30 binding packets
|
||||||
|
|
||||||
// Address of the transmitter consist of two bytes, the first one we fix to 0x01,
|
|
||||||
// while the second is provided by the "Option" setting.
|
|
||||||
// Receiver learns the TX address during binding.
|
|
||||||
#define IKEA_ANSLUTA_ADDRESS_A 0x01
|
|
||||||
|
|
||||||
// Commands
|
// Commands
|
||||||
#define IKEA_ANSLUTA_LIGHT_OFF 0x01
|
#define IKEAANSLUTA_LIGHT_OFF 0x01
|
||||||
#define IKEA_ANSLUTA_LIGHT_DIM 0x02 // 50% dimmed light
|
#define IKEAANSLUTA_LIGHT_DIM 0x02 // 50% dimmed light
|
||||||
#define IKEA_ANSLUTA_LIGHT_ON 0x03
|
#define IKEAANSLUTA_LIGHT_ON 0x03
|
||||||
#define IKEA_ANSLUTA_PAIR 0xFF
|
#define IKEAANSLUTA_PAIR 0xFF
|
||||||
|
|
||||||
void IKEA_ANSLUTA_send_command(uint8_t command){
|
void IKEAANSLUTA_send_command(uint8_t command){
|
||||||
CC2500_Strobe(CC2500_SIDLE);
|
CC2500_Strobe(CC2500_SIDLE);
|
||||||
packet[4] = option;
|
packet[4] = option;
|
||||||
packet[5] = command;
|
packet[5] = command;
|
||||||
CC2500_WriteData(packet, 8);
|
CC2500_WriteData(packet, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t IKEA_ANSLUTA_callback(void)
|
uint16_t IKEAANSLUTA_callback(void)
|
||||||
{
|
{
|
||||||
if (IS_BIND_IN_PROGRESS && bind_counter == 0) bind_counter = IKEA_ANSLUTA_BIND_COUNT;
|
|
||||||
if (bind_counter) {
|
if (bind_counter) {
|
||||||
IKEA_ANSLUTA_send_command(IKEA_ANSLUTA_PAIR);
|
IKEAANSLUTA_send_command(IKEAANSLUTA_PAIR);
|
||||||
bind_counter--;
|
if(--bind_counter == 0) {
|
||||||
if (bind_counter == 0) {
|
|
||||||
BIND_DONE;
|
BIND_DONE;
|
||||||
CC2500_SetPower();
|
CC2500_SetPower();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
uint8_t throttle = convert_channel_8b(THROTTLE);
|
uint8_t throttle = convert_channel_8b(THROTTLE);
|
||||||
uint8_t cmd = throttle <= 0x55 ? IKEA_ANSLUTA_LIGHT_OFF :
|
uint8_t cmd = throttle <= 0x55 ? IKEAANSLUTA_LIGHT_OFF :
|
||||||
throttle <= 0xAA ? IKEA_ANSLUTA_LIGHT_DIM :
|
throttle <= 0xAA ? IKEAANSLUTA_LIGHT_DIM :
|
||||||
IKEA_ANSLUTA_LIGHT_ON;
|
IKEAANSLUTA_LIGHT_ON;
|
||||||
IKEA_ANSLUTA_send_command(cmd);
|
IKEAANSLUTA_send_command(cmd);
|
||||||
}
|
}
|
||||||
return 65535; // 65ms loop cycle is more than enough here (we could make it even longer if not for uint16_t)
|
return 65535; // 65ms loop cycle is more than enough here (we could make it even longer if not for uint16_t)
|
||||||
}
|
}
|
||||||
|
|
||||||
void IKEA_ANSLUTA_init(void)
|
// Register initialization values as a continuous memory block (to save on flash memory)
|
||||||
|
const PROGMEM uint8_t IKEAANSLUTA_init_values[] = {
|
||||||
|
0xFF, // CC2500_06_PKTLEN
|
||||||
|
0x04, // CC2500_07_PKTCTRL1
|
||||||
|
0x05, // CC2500_08_PKTCTRL0
|
||||||
|
0x00, // CC2500_09_ADDR (unused, default)
|
||||||
|
0x10, // CC2500_0A_CHANNR
|
||||||
|
0x09, // CC2500_0B_FSCTRL1
|
||||||
|
0x00, // CC2500_0C_FSCTRL0
|
||||||
|
0x5D, // CC2500_0D_FREQ2
|
||||||
|
0x93, // CC2500_0E_FREQ1
|
||||||
|
0xB1, // CC2500_0F_FREQ0
|
||||||
|
0x2D, // CC2500_10_MDMCFG4
|
||||||
|
0x3B, // CC2500_11_MDMCFG3
|
||||||
|
0x73, // CC2500_12_MDMCFG2
|
||||||
|
0xA2, // CC2500_13_MDMCFG1
|
||||||
|
0xF8, // CC2500_14_MDMCFG0
|
||||||
|
0x01, // CC2500_15_DEVIATN
|
||||||
|
0x07, // CC2500_16_MCSM2
|
||||||
|
0x30, // CC2500_17_MCSM1
|
||||||
|
0x18, // CC2500_18_MCSM0
|
||||||
|
0x1D, // CC2500_19_FOCCFG
|
||||||
|
0x1C, // CC2500_1A_BSCFG
|
||||||
|
0xC7, // CC2500_1B_AGCCTRL2
|
||||||
|
0x00, // CC2500_1C_AGCCTRL1
|
||||||
|
0xB2, // CC2500_1D_AGCCTRL0
|
||||||
|
0x87, // CC2500_1E_WOREVT1 (unused, default)
|
||||||
|
0x6b, // CC2500_1F_WOREVT0 (unused, default)
|
||||||
|
0xf8, // CC2500_20_WORCTRL (unused, default)
|
||||||
|
0xB6, // CC2500_21_FREND1
|
||||||
|
0x10, // CC2500_22_FREND0
|
||||||
|
0xEA, // CC2500_23_FSCAL3
|
||||||
|
0x0A, // CC2500_24_FSCAL2
|
||||||
|
0x00, // CC2500_25_FSCAL1
|
||||||
|
0x11, // CC2500_26_FSCAL0
|
||||||
|
0x41, // CC2500_27_RCCTRL1
|
||||||
|
0x00, // CC2500_28_RCCTRL0
|
||||||
|
};
|
||||||
|
|
||||||
|
void IKEAANSLUTA_init(void)
|
||||||
{
|
{
|
||||||
|
if (IS_BIND_DONE) bind_counter = 0;
|
||||||
|
else bind_counter = IKEAANSLUTA_BIND_COUNT;
|
||||||
|
|
||||||
// All packets we send are the same
|
// All packets we send are the same
|
||||||
packet[0] = 0x06;
|
packet[0] = 0x06;
|
||||||
packet[1] = 0x55;
|
packet[1] = 0x55;
|
||||||
packet[2] = 0x01;
|
packet[2] = 0x01;
|
||||||
packet[3] = IKEA_ANSLUTA_ADDRESS_A;
|
// Bytes 3&4 are the transmitter address (to which the RX binds)
|
||||||
packet[4] = option;
|
// Byte 5 is the command.
|
||||||
packet[5] = 0x00; // Command goes here
|
packet[3] = rx_tx_addr[3]; // <pseudorandom tx-fixed value> + <rx_num>
|
||||||
|
// packet[4] = option;
|
||||||
|
// packet[5] = 0x00; // Command goes here
|
||||||
packet[6] = 0xAA;
|
packet[6] = 0xAA;
|
||||||
packet[7] = 0xFF;
|
packet[7] = 0xFF;
|
||||||
|
|
||||||
CC2500_Reset();
|
// Configure & initialize CC2500
|
||||||
CC2500_WriteReg(CC2500_06_PKTLEN, 0xFF);
|
for (uint8_t i = 0; i <= CC2500_28_RCCTRL0-CC2500_06_PKTLEN; ++i)
|
||||||
CC2500_WriteReg(CC2500_07_PKTCTRL1, 0x04);
|
CC2500_WriteReg(CC2500_06_PKTLEN+i, pgm_read_byte_near(&IKEAANSLUTA_init_values[i]));
|
||||||
CC2500_WriteReg(CC2500_08_PKTCTRL0, 0x05);
|
|
||||||
CC2500_WriteReg(CC2500_0A_CHANNR, 0x10);
|
|
||||||
CC2500_WriteReg(CC2500_0B_FSCTRL1, 0x09);
|
|
||||||
CC2500_WriteReg(CC2500_0C_FSCTRL0, 0x00);
|
|
||||||
CC2500_WriteReg(CC2500_0D_FREQ2, 0x5D);
|
|
||||||
CC2500_WriteReg(CC2500_0E_FREQ1, 0x93);
|
|
||||||
CC2500_WriteReg(CC2500_0F_FREQ0, 0xB1);
|
|
||||||
CC2500_WriteReg(CC2500_10_MDMCFG4, 0x2D);
|
|
||||||
CC2500_WriteReg(CC2500_11_MDMCFG3, 0x3B);
|
|
||||||
CC2500_WriteReg(CC2500_12_MDMCFG2, 0x73);
|
|
||||||
CC2500_WriteReg(CC2500_13_MDMCFG1, 0xA2);
|
|
||||||
CC2500_WriteReg(CC2500_14_MDMCFG0, 0xF8);
|
|
||||||
CC2500_WriteReg(CC2500_15_DEVIATN, 0x01);
|
|
||||||
CC2500_WriteReg(CC2500_16_MCSM2, 0x07);
|
|
||||||
CC2500_WriteReg(CC2500_17_MCSM1, 0x30);
|
|
||||||
CC2500_WriteReg(CC2500_18_MCSM0, 0x18);
|
|
||||||
CC2500_WriteReg(CC2500_19_FOCCFG, 0x1D);
|
|
||||||
CC2500_WriteReg(CC2500_1A_BSCFG, 0x1C);
|
|
||||||
CC2500_WriteReg(CC2500_1B_AGCCTRL2, 0xC7);
|
|
||||||
CC2500_WriteReg(CC2500_1C_AGCCTRL1, 0x00);
|
|
||||||
CC2500_WriteReg(CC2500_1D_AGCCTRL0, 0xB2);
|
|
||||||
CC2500_WriteReg(CC2500_21_FREND1, 0xB6);
|
|
||||||
CC2500_WriteReg(CC2500_22_FREND0, 0x10);
|
|
||||||
CC2500_WriteReg(CC2500_23_FSCAL3, 0xEA);
|
|
||||||
CC2500_WriteReg(CC2500_24_FSCAL2, 0x0A);
|
|
||||||
CC2500_WriteReg(CC2500_25_FSCAL1, 0x00);
|
|
||||||
CC2500_WriteReg(CC2500_26_FSCAL0, 0x11);
|
|
||||||
CC2500_WriteReg(CC2500_27_RCCTRL1, 0x41);
|
|
||||||
CC2500_WriteReg(CC2500_28_RCCTRL0, 0x00);
|
|
||||||
CC2500_SetTxRxMode(TX_EN);
|
CC2500_SetTxRxMode(TX_EN);
|
||||||
CC2500_SetPower();
|
CC2500_SetPower();
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ const char STR_E010R5[] ="E010r5";
|
|||||||
const char STR_LOLI[] ="LOLI";
|
const char STR_LOLI[] ="LOLI";
|
||||||
const char STR_E129[] ="E129";
|
const char STR_E129[] ="E129";
|
||||||
const char STR_E016H[] ="E016H";
|
const char STR_E016H[] ="E016H";
|
||||||
const char STR_IKEA_ANSLUTA[]="Ansluta";
|
const char STR_IKEAANSLUTA[]="Ansluta";
|
||||||
const char STR_CONFIG[] ="Config";
|
const char STR_CONFIG[] ="Config";
|
||||||
|
|
||||||
const char STR_SUBTYPE_FLYSKY[] = "\x04""Std\0""V9x9""V6x6""V912""CX20";
|
const char STR_SUBTYPE_FLYSKY[] = "\x04""Std\0""V9x9""V6x6""V912""CX20";
|
||||||
@ -331,8 +331,8 @@ const mm_protocol_definition multi_protocols[] = {
|
|||||||
#if defined(HUBSAN_A7105_INO)
|
#if defined(HUBSAN_A7105_INO)
|
||||||
{PROTO_HUBSAN, STR_HUBSAN, STR_SUBTYPE_HUBSAN, 3, OPTION_VIDFREQ, 0, 0, SW_A7105, HUBSAN_init, HUBSAN_callback },
|
{PROTO_HUBSAN, STR_HUBSAN, STR_SUBTYPE_HUBSAN, 3, OPTION_VIDFREQ, 0, 0, SW_A7105, HUBSAN_init, HUBSAN_callback },
|
||||||
#endif
|
#endif
|
||||||
#if defined(IKEA_ANSLUTA_CC2500_INO)
|
#if defined(IKEAANSLUTA_CC2500_INO)
|
||||||
{PROTO_IKEA_ANSLUTA,STR_IKEA_ANSLUTA,NO_SUBTYPE, 0, OPTION_OPTION, 0, 0, SW_CC2500, IKEA_ANSLUTA_init,IKEA_ANSLUTA_callback },
|
{PROTO_IKEAANSLUTA,STR_IKEAANSLUTA,NO_SUBTYPE, 0, OPTION_OPTION, 0, 0, SW_CC2500, IKEAANSLUTA_init,IKEAANSLUTA_callback },
|
||||||
#endif
|
#endif
|
||||||
#if defined(J6PRO_CYRF6936_INO)
|
#if defined(J6PRO_CYRF6936_INO)
|
||||||
{PROTO_J6PRO, STR_J6PRO, NO_SUBTYPE, 0, OPTION_NONE, 0, 1, SW_CYRF, J6PRO_init, J6PRO_callback },
|
{PROTO_J6PRO, STR_J6PRO, NO_SUBTYPE, 0, OPTION_NONE, 0, 1, SW_CYRF, J6PRO_init, J6PRO_callback },
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define VERSION_MAJOR 1
|
#define VERSION_MAJOR 1
|
||||||
#define VERSION_MINOR 3
|
#define VERSION_MINOR 3
|
||||||
#define VERSION_REVISION 2
|
#define VERSION_REVISION 2
|
||||||
#define VERSION_PATCH_LEVEL 78
|
#define VERSION_PATCH_LEVEL 79
|
||||||
|
|
||||||
#define MODE_SERIAL 0
|
#define MODE_SERIAL 0
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ enum PROTOCOLS
|
|||||||
PROTO_E129 = 83, // =>CYRF6936
|
PROTO_E129 = 83, // =>CYRF6936
|
||||||
PROTO_JOYSWAY = 84, // =>A7105
|
PROTO_JOYSWAY = 84, // =>A7105
|
||||||
PROTO_E016H = 85, // =>NRF24L01
|
PROTO_E016H = 85, // =>NRF24L01
|
||||||
PROTO_IKEA_ANSLUTA = 86,// =>CC2500
|
PROTO_IKEAANSLUTA = 86, // =>CC2500
|
||||||
PROTO_CONFIG = 87, // Module config
|
PROTO_CONFIG = 87, // Module config
|
||||||
|
|
||||||
PROTO_NANORF = 126, // =>NRF24L01
|
PROTO_NANORF = 126, // =>NRF24L01
|
||||||
|
@ -203,7 +203,7 @@
|
|||||||
#define FRSKY_RX_CC2500_INO
|
#define FRSKY_RX_CC2500_INO
|
||||||
#define HITEC_CC2500_INO
|
#define HITEC_CC2500_INO
|
||||||
#define HOTT_CC2500_INO
|
#define HOTT_CC2500_INO
|
||||||
#define IKEA_ANSLUTA_CC2500_INO
|
//#define IKEAANSLUTA_CC2500_INO // This is mostly a "for-fun" kind of a thing, not needed for most users
|
||||||
#define SCANNER_CC2500_INO
|
#define SCANNER_CC2500_INO
|
||||||
#define FUTABA_CC2500_INO
|
#define FUTABA_CC2500_INO
|
||||||
#define SKYARTEC_CC2500_INO
|
#define SKYARTEC_CC2500_INO
|
||||||
@ -694,7 +694,7 @@ const PPM_Parameters PPM_prot[14*NBR_BANKS]= {
|
|||||||
H107
|
H107
|
||||||
H301
|
H301
|
||||||
H501
|
H501
|
||||||
PROTO_IKEA_ANSLUTA
|
PROTO_IKEAANSLUTA
|
||||||
PROTO_J6PRO
|
PROTO_J6PRO
|
||||||
NONE
|
NONE
|
||||||
PROTO_JJRC345
|
PROTO_JJRC345
|
||||||
|
Loading…
x
Reference in New Issue
Block a user