mirror of
https://github.com/opentx/opentx.git
synced 2025-07-17 05:15:18 +03:00
parent
0ac40ab41f
commit
9ec17f6e68
8 changed files with 35 additions and 30 deletions
|
@ -302,7 +302,7 @@ RawSourceRange RawSource::getRange(const ModelData & model, const GeneralSetting
|
|||
break;
|
||||
|
||||
default:
|
||||
result.max = (model.extendedLimits ? 125 : 100);
|
||||
result.max = model.getChannelsMax(true);
|
||||
result.min = -result.max;
|
||||
break;
|
||||
}
|
||||
|
@ -724,7 +724,7 @@ void FuncSwData::clear()
|
|||
QString FuncSwData::funcToString()
|
||||
{
|
||||
ModelData model;
|
||||
if (func >= FuncSafetyCh1 && func <= FuncSafetyCh32)
|
||||
if (func >= FuncOverrideCH1 && func <= FuncOverrideCH32)
|
||||
return QObject::tr("Override %1").arg(RawSource(SOURCE_TYPE_CH, func).toString(model));
|
||||
else if (func == FuncTrainer)
|
||||
return QObject::tr("Trainer");
|
||||
|
@ -1311,9 +1311,9 @@ ModelData ModelData::removeGlobalVars()
|
|||
return result;
|
||||
}
|
||||
|
||||
int ModelData::getChannelsMax()
|
||||
int ModelData::getChannelsMax(bool forceExtendedLimits) const
|
||||
{
|
||||
if (extendedLimits)
|
||||
if (forceExtendedLimits || extendedLimits)
|
||||
return IS_TARANIS(GetCurrentFirmware()->getBoard()) ? 150 : 125;
|
||||
else
|
||||
return 100;
|
||||
|
|
|
@ -727,8 +727,8 @@ class LogicalSwitchData { // Logical Switches data
|
|||
};
|
||||
|
||||
enum AssignFunc {
|
||||
FuncSafetyCh1 = 0,
|
||||
FuncSafetyCh32 = FuncSafetyCh1+C9X_NUM_CHNOUT-1,
|
||||
FuncOverrideCH1 = 0,
|
||||
FuncOverrideCH32 = FuncOverrideCH1+C9X_NUM_CHNOUT-1,
|
||||
FuncTrainer,
|
||||
FuncTrainerRUD,
|
||||
FuncTrainerELE,
|
||||
|
@ -758,7 +758,7 @@ enum AssignFunc {
|
|||
|
||||
class FuncSwData { // Function Switches data
|
||||
public:
|
||||
FuncSwData(AssignFunc func=FuncSafetyCh1) { clear(); this->func = func; }
|
||||
FuncSwData(AssignFunc func=FuncOverrideCH1) { clear(); this->func = func; }
|
||||
RawSwitch swtch;
|
||||
AssignFunc func;
|
||||
int param;
|
||||
|
@ -1049,7 +1049,7 @@ class ModelData {
|
|||
void clearMixes();
|
||||
void clearInputs();
|
||||
|
||||
int getChannelsMax();
|
||||
int getChannelsMax(bool forceExtendedLimits=false) const;
|
||||
|
||||
protected:
|
||||
void removeGlobalVar(int & var);
|
||||
|
|
|
@ -576,7 +576,7 @@ t_Open9xArmFuncSwData_v208::operator FuncSwData ()
|
|||
FuncSwData c9x;
|
||||
c9x.swtch = open9xArmToSwitch(swtch);
|
||||
c9x.func = (AssignFunc)(func);
|
||||
if (c9x.func <= FuncSafetyCh32) {
|
||||
if (c9x.func <= FuncOverrideCH32) {
|
||||
c9x.enabled=param & 0x01;
|
||||
c9x.param = (param>>1)<<1;
|
||||
}
|
||||
|
|
|
@ -1924,10 +1924,10 @@ class ArmCustomFunctionField: public TransformedField {
|
|||
else
|
||||
_active = (fn.enabled ? 1 : 0);
|
||||
|
||||
if (fn.func >= FuncSafetyCh1 && fn.func <= FuncSafetyCh32) {
|
||||
if (fn.func >= FuncOverrideCH1 && fn.func <= FuncOverrideCH32) {
|
||||
if (version >= 216) {
|
||||
*((uint16_t *)_param) = fn.param;
|
||||
*((uint8_t *)(_param+3)) = fn.func - FuncSafetyCh1;
|
||||
*((uint8_t *)(_param+3)) = fn.func - FuncOverrideCH1;
|
||||
}
|
||||
else {
|
||||
*((uint32_t *)_param) = fn.param;
|
||||
|
@ -2012,7 +2012,7 @@ class ArmCustomFunctionField: public TransformedField {
|
|||
value = *((uint32_t *)_param);
|
||||
}
|
||||
|
||||
if (fn.func >= FuncSafetyCh1 && fn.func <= FuncSafetyCh32) {
|
||||
if (fn.func >= FuncOverrideCH1 && fn.func <= FuncOverrideCH32) {
|
||||
fn.func = AssignFunc(fn.func + index);
|
||||
fn.param = (int8_t)value;
|
||||
}
|
||||
|
@ -2123,9 +2123,9 @@ class AvrCustomFunctionField: public TransformedField {
|
|||
_param = fn.param;
|
||||
_active = (fn.enabled ? 1 : 0);
|
||||
|
||||
if (fn.func >= FuncSafetyCh1 && fn.func <= FuncSafetyCh32) {
|
||||
if (fn.func >= FuncOverrideCH1 && fn.func <= FuncOverrideCH32) {
|
||||
if (version >= 216)
|
||||
_union_param = fn.func - FuncSafetyCh1;
|
||||
_union_param = fn.func - FuncOverrideCH1;
|
||||
else if (version >= 213)
|
||||
_active += ((fn.func % 4) << 1);
|
||||
}
|
||||
|
@ -2183,7 +2183,7 @@ class AvrCustomFunctionField: public TransformedField {
|
|||
fn.enabled = (_active & 0x01);
|
||||
}
|
||||
|
||||
if (fn.func >= FuncSafetyCh1 && fn.func <= FuncSafetyCh32) {
|
||||
if (fn.func >= FuncOverrideCH1 && fn.func <= FuncOverrideCH32) {
|
||||
if (version >= 216)
|
||||
fn.func = AssignFunc(fn.func + _union_param);
|
||||
else if (version >= 213)
|
||||
|
|
|
@ -318,11 +318,12 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
|||
|
||||
int index = fswtchFunc[i]->currentIndex();
|
||||
|
||||
if (index>=FuncSafetyCh1 && index<=FuncSafetyCh32) {
|
||||
if (index>=FuncOverrideCH1 && index<=FuncOverrideCH32) {
|
||||
int channelsMax = model.getChannelsMax(true);
|
||||
fswtchParam[i]->setDecimals(0);
|
||||
fswtchParam[i]->setSingleStep(1);
|
||||
fswtchParam[i]->setMinimum(-125);
|
||||
fswtchParam[i]->setMaximum(125);
|
||||
fswtchParam[i]->setMinimum(-channelsMax);
|
||||
fswtchParam[i]->setMaximum(channelsMax);
|
||||
if (modified) {
|
||||
model.funcSw[i].param = fswtchParam[i]->value();
|
||||
}
|
||||
|
@ -590,7 +591,7 @@ void CustomFunctionsPanel::populateFuncCB(QComboBox *b, unsigned int value)
|
|||
b->clear();
|
||||
for (unsigned int i=0; i<FuncCount; i++) {
|
||||
b->addItem(FuncSwData(AssignFunc(i)).funcToString());
|
||||
if (((i>=FuncSafetyCh1 && i<=FuncSafetyCh32) && !firmware->getCapability(SafetyChannelCustomFunction)) ||
|
||||
if (((i>=FuncOverrideCH1 && i<=FuncOverrideCH32) && !firmware->getCapability(SafetyChannelCustomFunction)) ||
|
||||
((i==FuncVolume || i==FuncBackgroundMusic || i==FuncBackgroundMusicPause) && !firmware->getCapability(HasVolume)) ||
|
||||
((i==FuncPlayHaptic) && !firmware->getCapability(Haptic)) ||
|
||||
((i==FuncPlayBoth) && !firmware->getCapability(HasBeeper)) ||
|
||||
|
|
|
@ -11,6 +11,8 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model,
|
|||
ModelPanel(parent, model, generalSettings, firmware),
|
||||
selectedSwitch(0)
|
||||
{
|
||||
int channelsMax = model.getChannelsMax(true);
|
||||
|
||||
QGridLayout * gridLayout = new QGridLayout(this);
|
||||
|
||||
int col = 1;
|
||||
|
@ -48,8 +50,8 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model,
|
|||
gridLayout->addWidget(cswitchSource1[i], i+1, 2);
|
||||
cswitchSource1[i]->setVisible(false);
|
||||
cswitchValue[i] = new QDoubleSpinBox(this);
|
||||
cswitchValue[i]->setMaximum(125);
|
||||
cswitchValue[i]->setMinimum(-125);
|
||||
cswitchValue[i]->setMaximum(channelsMax);
|
||||
cswitchValue[i]->setMinimum(-channelsMax);
|
||||
cswitchValue[i]->setAccelerated(true);
|
||||
cswitchValue[i]->setDecimals(0);
|
||||
cswitchValue[i]->setProperty("index", i);
|
||||
|
@ -66,8 +68,8 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model,
|
|||
cswitchSource2[i]->setVisible(false);
|
||||
cswitchOffset[i] = new QDoubleSpinBox(this);
|
||||
cswitchOffset[i]->setProperty("index",i);
|
||||
cswitchOffset[i]->setMaximum(125);
|
||||
cswitchOffset[i]->setMinimum(-125);
|
||||
cswitchOffset[i]->setMaximum(channelsMax);
|
||||
cswitchOffset[i]->setMinimum(-channelsMax);
|
||||
cswitchOffset[i]->setAccelerated(true);
|
||||
cswitchOffset[i]->setDecimals(0);
|
||||
connect(cswitchOffset[i], SIGNAL(valueChanged(double)), this, SLOT(edited()));
|
||||
|
@ -75,8 +77,8 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model,
|
|||
v2Layout->addWidget(cswitchOffset[i]);
|
||||
cswitchOffset2[i] = new QDoubleSpinBox(this);
|
||||
cswitchOffset2[i]->setProperty("index",i);
|
||||
cswitchOffset2[i]->setMaximum(125);
|
||||
cswitchOffset2[i]->setMinimum(-125);
|
||||
cswitchOffset2[i]->setMaximum(channelsMax);
|
||||
cswitchOffset2[i]->setMinimum(-channelsMax);
|
||||
cswitchOffset2[i]->setAccelerated(true);
|
||||
cswitchOffset2[i]->setDecimals(0);
|
||||
connect(cswitchOffset2[i], SIGNAL(valueChanged(double)), this, SLOT(edited()));
|
||||
|
|
|
@ -4557,7 +4557,7 @@ void menuModelLogicalSwitchOne(uint8_t event)
|
|||
else
|
||||
#endif
|
||||
{
|
||||
v2_min = -125; v2_max = 125;
|
||||
v2_min = -LIMIT_EXT_PERCENT; v2_max = +LIMIT_EXT_PERCENT;
|
||||
lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cs->v2, LEFT|attr);
|
||||
}
|
||||
}
|
||||
|
@ -4853,7 +4853,7 @@ void menuModelLogicalSwitches(uint8_t event)
|
|||
else
|
||||
#endif
|
||||
{
|
||||
v2_min = -125; v2_max = +125;
|
||||
v2_min = -LIMIT_EXT_PERCENT; v2_max = +LIMIT_EXT_PERCENT;
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
@ -4863,7 +4863,7 @@ void menuModelLogicalSwitches(uint8_t event)
|
|||
}
|
||||
else {
|
||||
lcd_outdezAtt(CSW_3RD_COLUMN, y, cs->v2, LEFT|attr2);
|
||||
v2_min = -125; v2_max = 125;
|
||||
v2_min = -LIMIT_EXT_PERCENT; v2_max = +LIMIT_EXT_PERCENT;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -5182,8 +5182,10 @@ void menuModelCustomFunctions(uint8_t event)
|
|||
}
|
||||
#if defined(OVERRIDE_CHANNEL_FUNCTION)
|
||||
else if (func == FUNC_OVERRIDE_CHANNEL) {
|
||||
#if !defined(CPUARM)
|
||||
val_displayed = (int8_t)CFN_PARAM(sd);
|
||||
val_min = -125; val_max = 125;
|
||||
#endif
|
||||
val_min = -LIMIT_EXT_PERCENT; val_max = +LIMIT_EXT_PERCENT;
|
||||
lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -167,7 +167,7 @@ void displayTrims(uint8_t phase)
|
|||
#if !defined(CPUM64) || !defined(FRSKY)
|
||||
int16_t dir = val;
|
||||
bool exttrim = false;
|
||||
if (val < -125 || val > 125) {
|
||||
if (val < TRIM_MIN || val > TRIM_MAX) {
|
||||
exttrim = true;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue