Multi channels naming tool (#7538)
Mostly-authored-by: Pascal Langer <planger@mathworks.com>
This commit is contained in:
@@ -86,7 +86,24 @@ static int luaModelSetInfo(lua_State *L)
|
||||
|
||||
Get RF module parameters
|
||||
|
||||
`subType` values:
|
||||
`Type` values:
|
||||
* 0 NONE
|
||||
* 1 PPM
|
||||
* 2 XJT_PXX1
|
||||
* 3 ISRM_PXX2
|
||||
* 4 DSM2
|
||||
* 5 CROSSFIRE
|
||||
* 6 MULTIMODULE
|
||||
* 7 R9M_PXX1
|
||||
* 8 R9M_PXX2
|
||||
* 9 R9M_LITE_PXX1
|
||||
* 10 R9M_LITE_PXX2
|
||||
* 11 R9M_LITE_PRO_PXX1
|
||||
* 12 R9M_LITE_PRO_PXX2
|
||||
* 13 SBUS
|
||||
* 14 XJT_LITE_PXX2
|
||||
|
||||
`subType` values for XJT_PXX1:
|
||||
* -1 OFF
|
||||
* 0 D16
|
||||
* 1 D8
|
||||
@@ -101,6 +118,11 @@ Get RF module parameters
|
||||
* `modelId` (number) receiver number
|
||||
* `firstChannel` (number) start channel (0 is CH1)
|
||||
* `channelsCount` (number) number of channels sent to module
|
||||
* `Type` (number) module type
|
||||
* if the module type is Multi additional information are available
|
||||
* `protocol` (number) protocol number
|
||||
* `subProtocol` (number) sub-protocol number
|
||||
* `channelsOrder` (number) first 4 channels expected order
|
||||
|
||||
@status current Introduced in TODO
|
||||
*/
|
||||
@@ -114,6 +136,25 @@ static int luaModelGetModule(lua_State *L)
|
||||
lua_pushtableinteger(L, "modelId", g_model.header.modelId[idx]);
|
||||
lua_pushtableinteger(L, "firstChannel", module.channelsStart);
|
||||
lua_pushtableinteger(L, "channelsCount", module.channelsCount + 8);
|
||||
lua_pushtableinteger(L, "Type", module.type);
|
||||
#if defined(MULTIMODULE)
|
||||
if (module.type == MODULE_TYPE_MULTIMODULE) {
|
||||
int protocol = g_model.moduleData[idx].getMultiProtocol() + 1;
|
||||
int subprotocol = g_model.moduleData[idx].subType;
|
||||
convertOtxProtocolToMulti(&protocol, &subprotocol); // Special treatment for the FrSky entry...
|
||||
lua_pushtableinteger(L, "protocol", protocol);
|
||||
lua_pushtableinteger(L, "subProtocol", subprotocol);
|
||||
if (getMultiModuleStatus(idx).isValid()) {
|
||||
if (getMultiModuleStatus(idx).ch_order == 0xFF)
|
||||
lua_pushtableinteger(L, "channelsOrder", -1);
|
||||
else
|
||||
lua_pushtableinteger(L, "channelsOrder", getMultiModuleStatus(idx).ch_order);
|
||||
}
|
||||
else {
|
||||
lua_pushtableinteger(L, "channelsOrder", -1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
lua_pushnil(L);
|
||||
|
||||
+48
-42
@@ -244,6 +244,50 @@ void sendChannels(uint8_t moduleIdx)
|
||||
}
|
||||
}
|
||||
|
||||
void convertOtxProtocolToMulti(int *protocol, int *subprotocol)
|
||||
{
|
||||
// Special treatment for the FrSky entry...
|
||||
if (*protocol == MODULE_SUBTYPE_MULTI_FRSKY +1) {
|
||||
if (*subprotocol == MM_RF_FRSKY_SUBTYPE_D8) {
|
||||
//D8
|
||||
*protocol = 3;
|
||||
*subprotocol = 0;
|
||||
}
|
||||
else if (*subprotocol == MM_RF_FRSKY_SUBTYPE_D8_CLONED) {
|
||||
//D8
|
||||
*protocol = 3;
|
||||
*subprotocol = 1;
|
||||
}
|
||||
else if (*subprotocol == MM_RF_FRSKY_SUBTYPE_V8) {
|
||||
//V8
|
||||
*protocol = 25;
|
||||
*subprotocol = 0;
|
||||
}
|
||||
else {
|
||||
*protocol = 15;
|
||||
if (*subprotocol == MM_RF_FRSKY_SUBTYPE_D16_8CH)
|
||||
*subprotocol = 1;
|
||||
else if (*subprotocol == MM_RF_FRSKY_SUBTYPE_D16)
|
||||
*subprotocol = 0; // D16
|
||||
else if (*subprotocol == MM_RF_FRSKY_SUBTYPE_D16_LBT)
|
||||
*subprotocol = 2;
|
||||
else if (*subprotocol == MM_RF_FRSKY_SUBTYPE_D16_LBT_8CH)
|
||||
*subprotocol = 3;
|
||||
else
|
||||
*subprotocol = 4; // D16_CLONED
|
||||
}
|
||||
}
|
||||
else {
|
||||
// 15 for Multimodule is FrskyX or D16 which we map as a protocol of 3 (FrSky)
|
||||
// all protos > frskyx are therefore also off by one
|
||||
if (*protocol >= 15)
|
||||
*protocol = *protocol + 1;
|
||||
// 25 is again a FrSky *protocol (FrskyV) so shift again
|
||||
if (*protocol >= 25)
|
||||
*protocol = *protocol + 1;
|
||||
}
|
||||
}
|
||||
|
||||
void sendFrameProtocolHeader(uint8_t moduleIdx, bool failsafe)
|
||||
{// byte 1+2, protocol information
|
||||
|
||||
@@ -268,8 +312,7 @@ void sendFrameProtocolHeader(uint8_t moduleIdx, bool failsafe)
|
||||
protoByte |= MULTI_SEND_RANGECHECK;
|
||||
|
||||
// rfProtocol
|
||||
if (g_model.moduleData[moduleIdx].getMultiProtocol() == MODULE_SUBTYPE_MULTI_DSM2) {
|
||||
|
||||
if (type == MODULE_SUBTYPE_MULTI_DSM2 +1 ) {
|
||||
// Autobinding should always be done in DSMX 11ms
|
||||
if (g_model.moduleData[moduleIdx].multi.autoBindMode && moduleState[moduleIdx].mode == MODULE_MODE_BIND)
|
||||
subtype = MM_RF_DSM2_SUBTYPE_AUTO;
|
||||
@@ -279,48 +322,11 @@ void sendFrameProtocolHeader(uint8_t moduleIdx, bool failsafe)
|
||||
optionValue = 0x80 | sentModuleChannels(moduleIdx); // Max throw
|
||||
else
|
||||
optionValue = sentModuleChannels(moduleIdx);
|
||||
}
|
||||
|
||||
// 15 for Multimodule is FrskyX or D16 which we map as a subprotocol of 3 (FrSky)
|
||||
// all protos > frskyx are therefore also off by one
|
||||
if (type >= 15)
|
||||
type = type + 1;
|
||||
|
||||
// 25 is again a FrSky protocol (FrskyV) so shift again
|
||||
if (type >= 25)
|
||||
type = type + 1;
|
||||
|
||||
if (g_model.moduleData[moduleIdx].getMultiProtocol() == MODULE_SUBTYPE_MULTI_FRSKY) {
|
||||
if (subtype == MM_RF_FRSKY_SUBTYPE_D8) {
|
||||
//D8
|
||||
type = 3;
|
||||
subtype = 0;
|
||||
}
|
||||
else if (subtype == MM_RF_FRSKY_SUBTYPE_D8_CLONED) {
|
||||
//D8
|
||||
type = 3;
|
||||
subtype = 1;
|
||||
}
|
||||
else if (subtype == MM_RF_FRSKY_SUBTYPE_V8) {
|
||||
//V8
|
||||
type = 25;
|
||||
subtype = 0;
|
||||
}
|
||||
else {
|
||||
type = 15;
|
||||
if (subtype == MM_RF_FRSKY_SUBTYPE_D16_8CH) // D16 8ch
|
||||
subtype = 1;
|
||||
else if (subtype == MM_RF_FRSKY_SUBTYPE_D16)
|
||||
subtype = 0; // D16
|
||||
else if (subtype == MM_RF_FRSKY_SUBTYPE_D16_LBT)
|
||||
subtype = 2;
|
||||
else if (subtype == MM_RF_FRSKY_SUBTYPE_D16_LBT_8CH)
|
||||
subtype = 3;
|
||||
else
|
||||
subtype = 4;
|
||||
}
|
||||
}
|
||||
|
||||
// Special treatment for the FrSky entry...
|
||||
convertOtxProtocolToMulti(&type, &subtype);
|
||||
|
||||
// Set the highest bit of option byte in AFHDS2A protocol to instruct MULTI to passthrough telemetry bytes instead
|
||||
// of sending Frsky D telemetry
|
||||
if (g_model.moduleData[moduleIdx].getMultiProtocol() == MODULE_SUBTYPE_MULTI_FS_AFHDS2A)
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "pulses_common.h"
|
||||
|
||||
void multiPatchCustom(uint8_t moduleIdx);
|
||||
void convertOtxProtocolToMulti(int *protocol, int *subprotocol);
|
||||
|
||||
class UartMultiPulses: public DataBuffer<uint8_t, 64>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user