Skip to content

Commit d0db782

Browse files
committed
Multi config: enabled by default, LUA script update
1 parent 58ed8ca commit d0db782

File tree

8 files changed

+485
-68
lines changed

8 files changed

+485
-68
lines changed

Lua_scripts/MultiConfig.lua

Lines changed: 436 additions & 53 deletions
Large diffs are not rendered by default.

Lua_scripts/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ If you like this project and want to support further development please consider
1313
</tr>
1414
</table>
1515

16+
## MultiConfig
17+
18+
Enables to modify on a Multi module the Global ID, Cyrf ID or format the EEPROM.
19+
20+
Notes:
21+
- Supported from Multi v1.3.2.85 or above and OpenTX 2.3.12 or above
22+
- The Multi module to be configured must be active, if there is a second Multi module in the radio it must be off
23+
- Located on the radio SD card under \SCRIPTS\TOOLS
24+
25+
[![MultiCconfig](https://img.youtube.com/vi/lGyCV2kpqHU/0.jpg)](https://www.youtube.com/watch?v=lGyCV2kpqHU)
26+
1627
## MultiChannelsUpdater
1728

1829
Automatically name the channels based on the loaded Multi protocol and sub protocol including the module channel order convention.

Multiprotocol/CYRF6936_SPI.ino

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,24 @@ uint8_t CYRF_Reset()
7979
void CYRF_GetMfgData(uint8_t data[])
8080
{
8181
#ifndef FORCE_CYRF_ID
82-
/* Fuses power on */
83-
CYRF_WriteRegister(CYRF_25_MFG_ID, 0xFF);
82+
if(eeprom_read_byte((EE_ADDR)EEPROM_CID_INIT_OFFSET)==0xf0)
83+
{//read Cyrf ID from EEPROM
84+
for(uint8_t i=0;i<6;i++)
85+
data[i] = eeprom_read_byte((EE_ADDR)EEPROM_CID_OFFSET+i);
86+
}
87+
else
88+
{//read Cyrf ID and store it EEPROM
89+
/* Fuses power on */
90+
CYRF_WriteRegister(CYRF_25_MFG_ID, 0xFF);
8491

85-
CYRF_ReadRegisterMulti(CYRF_25_MFG_ID, data, 6);
92+
CYRF_ReadRegisterMulti(CYRF_25_MFG_ID, data, 6);
93+
for(uint8_t i=0;i<6;i++)
94+
eeprom_write_byte((EE_ADDR)EEPROM_CID_OFFSET+i, data[i]);
95+
eeprom_write_byte((EE_ADDR)EEPROM_CID_INIT_OFFSET, 0xf0);
8696

87-
/* Fuses power off */
88-
CYRF_WriteRegister(CYRF_25_MFG_ID, 0x00);
97+
/* Fuses power off */
98+
CYRF_WriteRegister(CYRF_25_MFG_ID, 0x00);
99+
}
89100
#else
90101
memcpy(data,FORCE_CYRF_ID,6);
91102
#endif

Multiprotocol/Multi_Config.ino

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,19 @@
1919
#include "iface_cyrf6936.h"
2020
#endif
2121

22-
void CONFIG_write_ID(uint32_t id)
22+
void CONFIG_write_GID(uint32_t id)
2323
{
2424
for(uint8_t i=0;i<4;i++)
2525
eeprom_write_byte((EE_ADDR)EEPROM_ID_OFFSET+i,id >> (i*8));
26-
eeprom_write_byte((EE_ADDR)(EEPROM_ID_OFFSET+10),0xf0);
26+
//eeprom_write_byte((EE_ADDR)(EEPROM_ID_OFFSET+10),0xf0);
2727
}
2828

29+
void CONFIG_write_CID(uint8_t *data)
30+
{
31+
for(uint8_t i=0;i<6;i++)
32+
eeprom_write_byte((EE_ADDR)EEPROM_CID_OFFSET+i, data[i]);
33+
//eeprom_write_byte((EE_ADDR)EEPROM_CID_INIT_OFFSET, 0xf0);
34+
}
2935
uint16_t CONFIG_callback()
3036
{
3137
static uint8_t line=0, page=0;
@@ -51,15 +57,15 @@ uint16_t CONFIG_callback()
5157
id |= CONFIG_SerialRX_val[i+1];
5258
}
5359
debugln("Update ID to %lx", id);
54-
CONFIG_write_ID(id);
60+
CONFIG_write_GID(id);
5561
break;
5662
case 2:
5763
if(CONFIG_SerialRX_val[1]==0xAA)
5864
{
5965
#define STM32_UUID ((uint32_t *)0x1FFFF7E8)
6066
id = STM32_UUID[0] ^ STM32_UUID[1] ^ STM32_UUID[2];
6167
debugln("Reset GID to %lx", id);
62-
CONFIG_write_ID(id);
68+
CONFIG_write_GID(id);
6369
}
6470
break;
6571
#ifdef CYRF6936_INSTALLED
@@ -68,6 +74,7 @@ uint16_t CONFIG_callback()
6874
for(uint8_t i=0; i<6; i++)
6975
debug("%02X ",CONFIG_SerialRX_val[i+1]);
7076
debugln("");
77+
CONFIG_write_CID(&CONFIG_SerialRX_val[1]);
7178
case 5:
7279
if(CONFIG_SerialRX_val[1]==0xAA)
7380
{
@@ -79,6 +86,7 @@ uint16_t CONFIG_callback()
7986
for(uint8_t i=0; i<6; i++)
8087
debug("%02X ",data[i]);
8188
debugln("");
89+
CONFIG_write_CID(data);
8290
}
8391
break;
8492
#endif

Multiprotocol/Multi_Protos.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ enum
192192
const mm_protocol_definition multi_protocols[] = {
193193
// Protocol number, Protocol String, Sub_protocol strings, Number of sub_protocols, Option type, Failsafe, ChMap, RF switch, Init, Callback
194194
#if defined(MULTI_CONFIG_INO)
195-
{0x00, STR_CONFIG, NO_SUBTYPE, 0, OPTION_NONE, 0, 0, 0, CONFIG_init, CONFIG_callback },
196195
{PROTO_CONFIG, STR_CONFIG, NO_SUBTYPE, 0, OPTION_NONE, 0, 0, 0, CONFIG_init, CONFIG_callback },
197196
#endif
198197
#if defined(ASSAN_NRF24L01_INO)

Multiprotocol/Multiprotocol.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define VERSION_MAJOR 1
2020
#define VERSION_MINOR 3
2121
#define VERSION_REVISION 2
22-
#define VERSION_PATCH_LEVEL 84
22+
#define VERSION_PATCH_LEVEL 85
2323

2424
#define MODE_SERIAL 0
2525

@@ -28,7 +28,6 @@
2828
//******************
2929
enum PROTOCOLS
3030
{
31-
//PROTO_CONFIG = 0, // Module config
3231
PROTO_FLYSKY = 1, // =>A7105
3332
PROTO_HUBSAN = 2, // =>A7105
3433
PROTO_FRSKYD = 3, // =>CC2500
@@ -784,6 +783,8 @@ enum {
784783
#define SPEED_125K 3
785784

786785
/** EEPROM Layout */
786+
#define EEPROM_CID_INIT_OFFSET 0 // 1 byte flag that Cyrf ID is initialized
787+
#define EEPROM_CID_OFFSET 1 // 6 bytes Cyrf ID
787788
#define EEPROM_ID_OFFSET 10 // Module ID (4 bytes)
788789
#define EEPROM_BANK_OFFSET 15 // Current bank number (1 byte)
789790
#define EEPROM_ID_VALID_OFFSET 20 // 1 byte flag that ID is valid
@@ -800,7 +801,8 @@ enum {
800801
#define FRSKYX_CLONE_EEPROM_OFFSET 822 // (1) format + (3) TX ID + (47) channels, 51 bytes, end is 873
801802
#define FRSKYX2_CLONE_EEPROM_OFFSET 873 // (1) format + (3) TX ID, 4 bytes, end is 877
802803
#define DSM_RX_EEPROM_OFFSET 877 // (4) TX ID + format, 5 bytes, end is 882
803-
//#define CONFIG_EEPROM_OFFSET 882 // Current configuration of the multimodule
804+
#define MOULDKG_EEPROM_OFFSET 882 // RX ID, 3 bytes per model, end is 882+64*3=1074
805+
//#define CONFIG_EEPROM_OFFSET 1074 // Current configuration of the multimodule
804806

805807
/* STM32 Flash Size */
806808
#ifndef DISABLE_FLASH_SIZE_CHECK

Multiprotocol/Telemetry.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ static void multi_send_status()
190190
// Protocol next/prev
191191
if(multi_protocols[multi_protocols_index+1].protocol != 0xFF)
192192
{
193-
if(multi_protocols[multi_protocols_index+1].protocol == PROTO_SCANNER)
193+
if(multi_protocols[multi_protocols_index+1].protocol == PROTO_SCANNER )//|| multi_protocols[multi_protocols_index+1].protocol == PROTO_CONFIG )
194194
{// if next is scanner
195195
if(multi_protocols[multi_protocols_index+2].protocol != 0xFF)
196196
Serial_write(multi_protocols[multi_protocols_index+2].protocol); // skip to next protocol number
@@ -204,7 +204,7 @@ static void multi_send_status()
204204
Serial_write(multi_protocols[multi_protocols_index].protocol); // end of list
205205
if(multi_protocols_index>0 && multi_protocols[multi_protocols_index-1].protocol != 0)
206206
{
207-
if(multi_protocols[multi_protocols_index-1].protocol==PROTO_SCANNER)
207+
if(multi_protocols[multi_protocols_index-1].protocol == PROTO_SCANNER )//|| multi_protocols[multi_protocols_index-1].protocol == PROTO_CONFIG )
208208
{// if prev is scanner
209209
if(multi_protocols_index > 1)
210210
Serial_write(multi_protocols[multi_protocols_index-2].protocol); // skip to prev protocol number

Multiprotocol/_Config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@
168168
//All the protocols will not fit in the Atmega328p module so you need to pick and choose.
169169
//Comment the protocols you are not using with "//" to save Flash space.
170170

171+
//Protocol for module configuration
172+
#define MULTI_CONFIG_INO
173+
171174
//The protocols below need an A7105 to be installed
172175
#define AFHDS2A_A7105_INO
173176
#define AFHDS2A_RX_A7105_INO

0 commit comments

Comments
 (0)