feat(h7): increase GVAR limit to 15 (#6597)

Co-authored-by: elecpower <elecpower@users.noreply.github.com>
This commit is contained in:
3djc
2025-10-01 19:07:08 +10:00
committed by GitHub
co-authored by elecpower
parent 4de56d8096
commit 0da292001d
16 changed files with 100 additions and 43 deletions
+1 -1
View File
@@ -30,7 +30,7 @@
#define CPN_MAX_EXPOS 64
#define CPN_MAX_CURVES 32
#define CPN_MAX_POINTS 17
#define CPN_MAX_GVARS 9
#define CPN_MAX_GVARS 15 // 0, 9, 15
#define CPN_MAX_ENCODERS 2 // rotary encoders
#define CPN_MAX_CHNOUT 32 // number of real output channels
#define CPN_MAX_LOGICAL_SWITCHES 64 // number of custom switches
@@ -21,6 +21,7 @@
#include "adjustmentreference.h"
#include "modeldata.h"
#include "eeprominterface.h"
AdjustmentReference::AdjustmentReference(int value)
{
@@ -80,5 +81,10 @@ QString AdjustmentReference::toString(const ModelData * model, const bool sign)
const bool AdjustmentReference::isAvailable() const
{
Firmware *firmware = getCurrentFirmware();
if (type == ADJUST_REF_GVAR && abs(value) > firmware->getCapability(Gvars))
return false;
return true;
}
+13
View File
@@ -837,3 +837,16 @@ inline bool HAS_EEPROM_YAML(Board::Type board)
{
return IS_FAMILY_HORUS_OR_T16(board);
}
inline bool IS_STM32H5(Board::Type board)
{
return false;
}
inline bool IS_STM32H7(Board::Type board)
{
return IS_FLYSKY_PA01(board) ||
IS_FLYSKY_ST16(board) ||
IS_JUMPER_T15PRO(board) ||
IS_RADIOMASTER_TX15(board);
}
@@ -262,7 +262,7 @@ bool CustomFunctionData::isFuncAvailable(const int index, const ModelData * mode
(model ? model->timers[index - FuncSetTimer1].isModeOff() : false))) ||
((index == FuncScreenshot) && !IS_HORUS_OR_TARANIS(fw->getBoard())) ||
((index >= FuncRangeCheckInternalModule && index <= FuncBindExternalModule) && !fw->getCapability(DangerousFunctions)) ||
((index >= FuncAdjustGV1 && index <= FuncAdjustGVLast) && !fw->getCapability(Gvars)) ||
((index >= FuncAdjustGV1 && index <= FuncAdjustGVLast) && ((index - FuncAdjustGV1) >= fw->getCapability(Gvars))) ||
((index == FuncDisableTouch) && !IS_HORUS_OR_TARANIS(fw->getBoard())) ||
((index == FuncDisableAudioAmp && !Boards::getCapability(fw->getBoard(), Board::HasAudioMuteGPIO))) ||
((index == FuncRGBLed && !(Boards::getCapability(fw->getBoard(), Board::HasLedStripGPIO) || Boards::getCapability(fw->getBoard(), Board::FunctionSwitchColors)))) ||
@@ -512,30 +512,46 @@ bool convert<TimerData>::decode(const Node& node, TimerData& rhs)
static int32_t YamlReadLimitValue(const YAML::Node& node, int32_t shift = 0)
{
std::string val = node.as<std::string>();
if ((val.size() >= 4)
&& (val[0] == '-')
&& (val[1] == 'G')
&& (val[2] == 'V')
&& (val[3] >= '1')
&& (val[3] <= '9')) {
return -10000 - std::stoi(val.substr(3));
}
if ((val.size() >= 3)
&& (val[0] == 'G')
&& (val[1] == 'V')
&& (val[2] >= '1')
&& (val[2] <= '9')) {
return 10000 + std::stoi(val.substr(2));
}
Firmware *firmware = getCurrentFirmware();
std::string val_str = node.as<std::string>();
try {
return std::stoi(val) + shift;
return std::stoi(val_str) + shift;
} catch(...) {
throw YAML::TypedBadConversion<int>(node.Mark());
try {
const char* val = val_str.data();
int multiplier = 1;
if (val_str.size() >= 4
&& val[0] == '-') {
multiplier = -1;
val_str = val_str.substr(1);
}
if (val_str.size() >= 3
&& val[0] == 'G'
&& val[1] == 'V') {
int32_t num = 0;
try {
num = std::stoi(val_str.substr(2));
} catch (...) {
throw;
}
if (num <= firmware->getCapability(Gvars))
return ((10000 * multiplier) + (num * multiplier));
else
return 0;
} else {
throw "Invalid value";
}
} catch(...) {
throw YAML::TypedBadConversion<int>(node.Mark());
}
}
}
@@ -137,6 +137,7 @@ std::string YamlRawSourceEncode(const RawSource& rhs)
RawSource YamlRawSourceDecode(const std::string& src_str)
{
Firmware *firmware = getCurrentFirmware();
Board::Type board = getCurrentBoard();
Boards b = Boards(board);
RawSource rhs;
@@ -251,7 +252,7 @@ RawSource YamlRawSourceDecode(const std::string& src_str)
std::stringstream src(src_str_tmp.substr(3));
int gv = 0;
src >> gv;
if (gv < CPN_MAX_GVARS)
if (gv < firmware->getCapability(Gvars))
rhs = RawSource(SOURCE_TYPE_GVAR, gv + 1);
} else if (val_len > 5 &&
@@ -95,7 +95,9 @@ int OpenTxFirmware::getCapability(::Capability capability)
else
return id.contains("heli") ? 1 : 0;
case Gvars:
if (IS_HORUS_OR_TARANIS(board))
if (IS_STM32H7(board) || IS_STM32H5(board))
return id.contains("nogvars") ? 0 : 15;
else if (IS_HORUS_OR_TARANIS(board))
return id.contains("nogvars") ? 0 : 9;
else if (id.contains("gvars"))
return 9;
+3
View File
@@ -324,6 +324,9 @@ bool RawSource::isAvailable(const ModelData * const model, const GeneralSettings
if (type == SOURCE_TYPE_CYC && !firmware->getCapability(Heli))
return false;
if (type == SOURCE_TYPE_GVAR && abs(index) > firmware->getCapability(Gvars))
return false;
if (model) {
if (type == SOURCE_TYPE_TIMER && model->timers[abs(index) - 1].isModeOff())
return false;
+5 -5
View File
@@ -51,7 +51,7 @@ static inline void check_struct()
CHKSIZE(GVarData, 7);
CHKSIZE(RFAlarmData, 2);
CHKSIZE(TrainerData, 16);
CHKSIZE(FlightModeData, 22 + 2 * MAX_TRIMS + LEN_FLIGHT_MODE_NAME);
CHKSIZE(FlightModeData, 4 + 2 * MAX_GVARS + 2 * MAX_TRIMS + LEN_FLIGHT_MODE_NAME);
CHKSIZE(CustomFunctionData, 11);
#if defined(PCBX7) || defined(PCBXLITE) || defined(PCBX9LITE)
@@ -119,15 +119,15 @@ static inline void check_struct()
CHKSIZE(ModelData, 27693);
#endif
#elif defined(PCBST16)
CHKSIZE(ModelData, 27761);
CHKSIZE(ModelData, 27911);
#elif defined(PCBPA01)
CHKSIZE(ModelData, 27522);
CHKSIZE(ModelData, 27672);
#elif defined(RADIO_T15)
CHKSIZE(ModelData, 27683);
#elif defined(RADIO_T15PRO)
CHKSIZE(ModelData, 27761);
CHKSIZE(ModelData, 27911);
#elif defined(RADIO_TX15)
CHKSIZE(ModelData, 27761);
CHKSIZE(ModelData, 27911);
#elif defined(RADIO_H7RS)
// CHKSIZE()
#elif defined(PCBHORUS)
+9 -1
View File
@@ -39,7 +39,7 @@ enum MenuModelFlightModeItems {
ITEM_MODEL_FLIGHT_MODE_TRIMS2,
ITEM_MODEL_FLIGHT_MODE_FADE_IN,
ITEM_MODEL_FLIGHT_MODE_FADE_OUT,
#if defined(GVARS)
#if MAX_GVARS > 0
ITEM_MODEL_FLIGHT_MODE_GVARS_LABEL,
ITEM_MODEL_FLIGHT_MODE_GV1,
ITEM_MODEL_FLIGHT_MODE_GV2,
@@ -50,6 +50,14 @@ enum MenuModelFlightModeItems {
ITEM_MODEL_FLIGHT_MODE_GV7,
ITEM_MODEL_FLIGHT_MODE_GV8,
ITEM_MODEL_FLIGHT_MODE_GV9,
#if MAX_GVARS > 9
ITEM_MODEL_FLIGHT_MODE_GV10,
ITEM_MODEL_FLIGHT_MODE_GV11,
ITEM_MODEL_FLIGHT_MODE_GV12,
ITEM_MODEL_FLIGHT_MODE_GV13,
ITEM_MODEL_FLIGHT_MODE_GV14,
ITEM_MODEL_FLIGHT_MODE_GV15,
#endif
#endif
ITEM_MODEL_FLIGHT_MODE_MAX
};
+4
View File
@@ -25,7 +25,11 @@
#define GVAR_MAX 1024
#define GVAR_MIN -GVAR_MAX
#if defined(STM32H7) || defined(STM32H7RS) || defined(STM32H5)
#define MAX_GVARS 15
#else
#define MAX_GVARS 9
#endif
// GVars have one value per flight mode
#define GVAR_VALUE(gv, fm) g_model.flightModeData[fm].gvars[gv]
@@ -48,7 +48,11 @@ static inline void check_yaml_funcs()
{
static_assert(offsetof(ModuleData, ppm) == 4,"");
check_size<ModuleData, 29>();
#if defined(STM32H7) || defined(STM32H7RS) || defined(STM32H5)
static_assert(MAX_GVARS == 15,"");
#else
static_assert(MAX_GVARS == 9,"");
#endif
}
static bool w_semver(void* user, uint8_t* data, uint32_t bitoffs,
@@ -567,7 +567,7 @@ static const struct YamlNode struct_FlightModeData[] = {
YAML_PADDING( 6 ),
YAML_UNSIGNED( "fadeIn", 8 ),
YAML_UNSIGNED( "fadeOut", 8 ),
YAML_ARRAY("gvars", 16, 9, struct_signed_16, gvar_is_active),
YAML_ARRAY("gvars", 16, 15, struct_signed_16, gvar_is_active),
YAML_END
};
static const struct YamlNode struct_GVarData[] = {
@@ -902,11 +902,11 @@ static const struct YamlNode struct_ModelData[] = {
YAML_ARRAY("logicalSw", 72, 64, struct_LogicalSwitchData, NULL),
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_STRUCT("swashR", 64, struct_SwashRingData, swash_is_active),
YAML_ARRAY("flightModeData", 352, 9, struct_FlightModeData, fmd_is_active),
YAML_ARRAY("flightModeData", 448, 9, struct_FlightModeData, fmd_is_active),
YAML_UNSIGNED_CUST( "thrTraceSrc", 8, r_thrSrc, w_thrSrc ),
YAML_CUSTOM("switchWarningState",r_swtchWarn,nullptr),
YAML_ARRAY("switchWarning", 2, 32, struct_swtchWarn, nullptr),
YAML_ARRAY("gvars", 56, 9, struct_GVarData, NULL),
YAML_ARRAY("gvars", 56, 15, struct_GVarData, NULL),
YAML_STRUCT("varioData", 40, struct_VarioData, NULL),
YAML_UNSIGNED_CUST( "rssiSource", 8, r_tele_sensor, w_tele_sensor ),
YAML_STRUCT("rssiAlarms", 0, struct_RssiAlarmData, NULL),
@@ -567,7 +567,7 @@ static const struct YamlNode struct_FlightModeData[] = {
YAML_PADDING( 6 ),
YAML_UNSIGNED( "fadeIn", 8 ),
YAML_UNSIGNED( "fadeOut", 8 ),
YAML_ARRAY("gvars", 16, 9, struct_signed_16, gvar_is_active),
YAML_ARRAY("gvars", 16, 15, struct_signed_16, gvar_is_active),
YAML_END
};
static const struct YamlNode struct_GVarData[] = {
@@ -902,11 +902,11 @@ static const struct YamlNode struct_ModelData[] = {
YAML_ARRAY("logicalSw", 72, 64, struct_LogicalSwitchData, NULL),
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_STRUCT("swashR", 64, struct_SwashRingData, swash_is_active),
YAML_ARRAY("flightModeData", 384, 9, struct_FlightModeData, fmd_is_active),
YAML_ARRAY("flightModeData", 480, 9, struct_FlightModeData, fmd_is_active),
YAML_UNSIGNED_CUST( "thrTraceSrc", 8, r_thrSrc, w_thrSrc ),
YAML_CUSTOM("switchWarningState",r_swtchWarn,nullptr),
YAML_ARRAY("switchWarning", 2, 32, struct_swtchWarn, nullptr),
YAML_ARRAY("gvars", 56, 9, struct_GVarData, NULL),
YAML_ARRAY("gvars", 56, 15, struct_GVarData, NULL),
YAML_STRUCT("varioData", 40, struct_VarioData, NULL),
YAML_UNSIGNED_CUST( "rssiSource", 8, r_tele_sensor, w_tele_sensor ),
YAML_STRUCT("rssiAlarms", 0, struct_RssiAlarmData, NULL),
@@ -567,7 +567,7 @@ static const struct YamlNode struct_FlightModeData[] = {
YAML_PADDING( 6 ),
YAML_UNSIGNED( "fadeIn", 8 ),
YAML_UNSIGNED( "fadeOut", 8 ),
YAML_ARRAY("gvars", 16, 9, struct_signed_16, gvar_is_active),
YAML_ARRAY("gvars", 16, 15, struct_signed_16, gvar_is_active),
YAML_END
};
static const struct YamlNode struct_GVarData[] = {
@@ -902,11 +902,11 @@ static const struct YamlNode struct_ModelData[] = {
YAML_ARRAY("logicalSw", 72, 64, struct_LogicalSwitchData, NULL),
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_STRUCT("swashR", 64, struct_SwashRingData, swash_is_active),
YAML_ARRAY("flightModeData", 384, 9, struct_FlightModeData, fmd_is_active),
YAML_ARRAY("flightModeData", 480, 9, struct_FlightModeData, fmd_is_active),
YAML_UNSIGNED_CUST( "thrTraceSrc", 8, r_thrSrc, w_thrSrc ),
YAML_CUSTOM("switchWarningState",r_swtchWarn,nullptr),
YAML_ARRAY("switchWarning", 2, 32, struct_swtchWarn, nullptr),
YAML_ARRAY("gvars", 56, 9, struct_GVarData, NULL),
YAML_ARRAY("gvars", 56, 15, struct_GVarData, NULL),
YAML_STRUCT("varioData", 40, struct_VarioData, NULL),
YAML_UNSIGNED_CUST( "rssiSource", 8, r_tele_sensor, w_tele_sensor ),
YAML_STRUCT("rssiAlarms", 0, struct_RssiAlarmData, NULL),
@@ -567,7 +567,7 @@ static const struct YamlNode struct_FlightModeData[] = {
YAML_PADDING( 6 ),
YAML_UNSIGNED( "fadeIn", 8 ),
YAML_UNSIGNED( "fadeOut", 8 ),
YAML_ARRAY("gvars", 16, 9, struct_signed_16, gvar_is_active),
YAML_ARRAY("gvars", 16, 15, struct_signed_16, gvar_is_active),
YAML_END
};
static const struct YamlNode struct_GVarData[] = {
@@ -902,11 +902,11 @@ static const struct YamlNode struct_ModelData[] = {
YAML_ARRAY("logicalSw", 72, 64, struct_LogicalSwitchData, NULL),
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_STRUCT("swashR", 64, struct_SwashRingData, swash_is_active),
YAML_ARRAY("flightModeData", 384, 9, struct_FlightModeData, fmd_is_active),
YAML_ARRAY("flightModeData", 480, 9, struct_FlightModeData, fmd_is_active),
YAML_UNSIGNED_CUST( "thrTraceSrc", 8, r_thrSrc, w_thrSrc ),
YAML_CUSTOM("switchWarningState",r_swtchWarn,nullptr),
YAML_ARRAY("switchWarning", 2, 32, struct_swtchWarn, nullptr),
YAML_ARRAY("gvars", 56, 9, struct_GVarData, NULL),
YAML_ARRAY("gvars", 56, 15, struct_GVarData, NULL),
YAML_STRUCT("varioData", 40, struct_VarioData, NULL),
YAML_UNSIGNED_CUST( "rssiSource", 8, r_tele_sensor, w_tele_sensor ),
YAML_STRUCT("rssiAlarms", 0, struct_RssiAlarmData, NULL),