chores(flysky): Separate AFHDS2A and AFHDS3 into 2 different module type (#3783)

* chores(flysky): separate AFHDS2A and AFHDS3 into 2 different module type

This should allow to remove some of the hacks added earlier.

* chore: Add some EL18 CI bits

* fix(afhds): cmake defs

* fix(ci): add el18 to commit-tests.sh

* chore(cpn): separate AFHDS2A and AFHDS3

* chore(cpn): remove binary import of afhds and legacy fxFreq field for afhds3

* fix(cpn): limit available internal afhds protocols to those supported by hardware

* chore(cpn): update Flysky int module test

* fix(cpn): compile error

* fix(cpn): afhds2a max channels

* fix: TR_MODULE_PROTOCOLS

* enh(cpn): more support for afhds2a and 3

* fix(cpn): rebase compile error

* fix(cpn): bit indexes

* fix(cpn): emi toString

* fix(cpn): limit available internal afhds protocols to those supported by hardware

* enh(cpn): add support for Flysky EL18

* fix(cpn): available protocols

* fix(cpn): rebase moduledata

* chore(cpn): add module fields to model print

* Separate AFHDS2A and AFHDS3 UI settings.

* Fix AFHDS3 conversion from old subtype value.
Fix 'Channel Range' layout on portrait LCD.

* Fix name.

---------

Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
Co-authored-by: elecpower <neilh713@tpg.com.au>
Co-authored-by: Phil Mitchell <phil.a.mitchell@gmail.com>
This commit is contained in:
Raphael Coeffic
2023-09-07 19:24:03 +10:00
committed by GitHub
co-authored by Peter Feerick elecpower Phil Mitchell
parent 9515d29c9d
commit c4f1e7127d
59 changed files with 1098 additions and 463 deletions
+2 -6
View File
@@ -40,7 +40,8 @@ enum ModuleType {
MODULE_TYPE_R9M_LITE_PRO_PXX2,
MODULE_TYPE_SBUS,
MODULE_TYPE_XJT_LITE_PXX2,
MODULE_TYPE_FLYSKY,
MODULE_TYPE_FLYSKY_AFHDS2A,
MODULE_TYPE_FLYSKY_AFHDS3,
MODULE_TYPE_LEMON_DSMP,
MODULE_TYPE_COUNT SKIP,
MODULE_TYPE_MAX SKIP = MODULE_TYPE_COUNT - 1
@@ -132,11 +133,6 @@ enum ModuleSubtypeDSM2 {
DSM2_PROTO_DSMX,
};
enum ModuleSubtypeFlysky {
FLYSKY_SUBTYPE_AFHDS3=0,
FLYSKY_SUBTYPE_AFHDS2A
};
enum FailsafeModes {
FAILSAFE_NOT_SET,
FAILSAFE_HOLD,
+30 -27
View File
@@ -33,7 +33,7 @@
#include "telemetry/multi.h"
#endif
#if defined(PCBNV14)
#if defined(PCBNV14) && defined(AFHDS2)
extern uint32_t NV14internalModuleFwVersion;
#endif
@@ -398,22 +398,19 @@ inline bool isModuleSBUS(uint8_t moduleIdx)
return g_model.moduleData[moduleIdx].type == MODULE_TYPE_SBUS;
}
inline bool isModuleFlySky(uint8_t idx)
{
return
(g_model.moduleData[idx].type == MODULE_TYPE_FLYSKY);
}
inline bool isModuleAFHDS2A(uint8_t idx)
{
return isModuleFlySky(idx)
&& (g_model.moduleData[idx].subType == FLYSKY_SUBTYPE_AFHDS2A);
return (g_model.moduleData[idx].type == MODULE_TYPE_FLYSKY_AFHDS2A);
}
inline bool isModuleAFHDS3(uint8_t idx)
{
return isModuleFlySky(idx)
&& (g_model.moduleData[idx].subType == FLYSKY_SUBTYPE_AFHDS3);
return (g_model.moduleData[idx].type == MODULE_TYPE_FLYSKY_AFHDS3);
}
inline bool isModuleFlySky(uint8_t idx)
{
return (isModuleAFHDS2A(idx) || isModuleAFHDS3(idx));
}
inline bool isModuleDSMP(uint8_t idx)
@@ -439,7 +436,8 @@ static const int8_t maxChannelsModules_M8[] = {
0, // MODULE_TYPE_R9M_LITE_PRO_PXX2: index NOT USED
8, // MODULE_TYPE_SBUS
0, // MODULE_TYPE_XJT_LITE_PXX2: index NOT USED
6, // MODULE_TYPE_FLYSKY: 14 channels for AFHDS2A, AFHDS3 special cased
6, // MODULE_TYPE_FLYSKY_AFHDS2A: 14 channels
10,// MODULE_TYPE_FLYSKY_AFHDS3: 18 channels
4, // MODULE_TYPE_LEMON_DSMP: 12 channels for DSMX
};
@@ -484,8 +482,6 @@ inline int8_t maxModuleChannels_M8(uint8_t moduleIdx)
} else {
return 8; // always 16 channels in FCC / FLEX
}
} else if (isModuleAFHDS3(moduleIdx)) {
return 10;
} else if (isModuleMultimoduleDSM2(moduleIdx)) {
return 4; // 12 channels
} else if (isModuleDSMP(moduleIdx) &&
@@ -641,7 +637,7 @@ inline bool isModuleBindRangeAvailable(uint8_t moduleIdx)
inline uint32_t getNV14RfFwVersion()
{
#if defined(PCBNV14)
#if defined(PCBNV14) && defined(AFHDS2)
return NV14internalModuleFwVersion;
#else
return 0;
@@ -651,11 +647,11 @@ inline uint32_t getNV14RfFwVersion()
inline bool isModuleRangeAvailable(uint8_t moduleIdx)
{
bool ret = isModuleBindRangeAvailable(moduleIdx) && !IS_RX_MULTI(moduleIdx);
#if defined(PCBNV14)
#if defined(PCBNV14) && defined(AFHDS2)
ret = ret &&
(!isModuleFlySky(moduleIdx) || NV14internalModuleFwVersion >= 0x1000E);
#else
ret = ret && (!isModuleFlySky(moduleIdx));
(!isModuleAFHDS2A(moduleIdx) || NV14internalModuleFwVersion >= 0x1000E);
#elif defined(AFHDS3)
ret = ret && (!isModuleAFHDS3(moduleIdx));
#endif
return ret;
}
@@ -805,21 +801,25 @@ inline void resetAccessAuthenticationCount()
globalData.authenticationCount = 0;
}
inline void resetAfhdsOptions(uint8_t moduleIdx)
inline void resetAfhds3Options(uint8_t moduleIdx)
{
#if defined(AFHDS3)
auto & data = g_model.moduleData[moduleIdx];
data.subType = FLYSKY_SUBTYPE_AFHDS3;
data.subType = 0;
data.afhds3.emi = 2; // FCC
data.afhds3.telemetry = 1;
data.afhds3.phyMode = 0;
#elif defined(AFHDS2)
auto & data = g_model.moduleData[moduleIdx];
data.subType = FLYSKY_SUBTYPE_AFHDS2A;
data.flysky.setDefault();
#endif
}
inline void resetAfhds2AOptions(uint8_t moduleIdx)
{
#if defined(AFHDS2)
auto & data = g_model.moduleData[moduleIdx];
data.subType = 0;
data.flysky.setDefault();
#endif
}
inline void setModuleType(uint8_t moduleIdx, uint8_t moduleType)
{
@@ -831,8 +831,11 @@ inline void setModuleType(uint8_t moduleIdx, uint8_t moduleType)
moduleData.sbus.refreshRate = -31;
else if (moduleData.type == MODULE_TYPE_PPM)
setDefaultPpmFrameLength(moduleIdx);
else if (moduleData.type == MODULE_TYPE_FLYSKY) {
resetAfhdsOptions(moduleIdx);
else if (moduleData.type == MODULE_TYPE_FLYSKY_AFHDS2A) {
resetAfhds2AOptions(moduleIdx);
}
else if (moduleData.type == MODULE_TYPE_FLYSKY_AFHDS3) {
resetAfhds3Options(moduleIdx);
}
else
resetAccessAuthenticationCount();
+9 -7
View File
@@ -329,13 +329,15 @@ uint8_t getRequiredProtocol(uint8_t module)
break;
#endif
#if defined(AFHDS3) || defined(AFHDS2)
case MODULE_TYPE_FLYSKY:
if (isModuleAFHDS3(module)) {
protocol = PROTOCOL_CHANNELS_AFHDS3;
} else if (isModuleAFHDS2A(module)) {
protocol = PROTOCOL_CHANNELS_AFHDS2A;
}
#if defined(AFHDS2)
case MODULE_TYPE_FLYSKY_AFHDS2A:
protocol = PROTOCOL_CHANNELS_AFHDS2A;
break;
#endif
#if defined(AFHDS3)
case MODULE_TYPE_FLYSKY_AFHDS3:
protocol = PROTOCOL_CHANNELS_AFHDS3;
break;
#endif