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;