mirror of
https://github.com/opentx/opentx.git
synced 2025-07-19 14:25:11 +03:00
Fixes #2380: can't select LS or RS as source in INPUT and MIXERS
This commit is contained in:
parent
5ab974e140
commit
a8a3a7e29a
5 changed files with 45 additions and 16 deletions
|
@ -507,6 +507,21 @@ QString RawSource::toString(const ModelData * model) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RawSource::isPot() const
|
||||||
|
{
|
||||||
|
return (type == SOURCE_TYPE_STICK &&
|
||||||
|
index >= NUM_STICKS &&
|
||||||
|
index < NUM_STICKS+GetCurrentFirmware()->getCapability(Pots));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RawSource::isSlider() const
|
||||||
|
{
|
||||||
|
return (type == SOURCE_TYPE_STICK &&
|
||||||
|
index >= NUM_STICKS+GetCurrentFirmware()->getCapability(Pots) &&
|
||||||
|
index < NUM_STICKS+GetCurrentFirmware()->getCapability(Pots)+GetCurrentFirmware()->getCapability(Sliders));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString SwitchUp(const char sw)
|
QString SwitchUp(const char sw)
|
||||||
{
|
{
|
||||||
const char result[] = {'S', sw, upArrow[0], upArrow[1], upArrow[2], 0};
|
const char result[] = {'S', sw, upArrow[0], upArrow[1], upArrow[2], 0};
|
||||||
|
@ -1016,6 +1031,18 @@ bool GeneralSettings::switchSourceAllowedTaranis(int index) const
|
||||||
return switchConfig[index] != SWITCH_NONE;
|
return switchConfig[index] != SWITCH_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GeneralSettings::isPotAvailable(int index) const
|
||||||
|
{
|
||||||
|
if (index<0 || index>4) return false;
|
||||||
|
return potConfig[index] != POT_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GeneralSettings::isSliderAvailable(int index) const
|
||||||
|
{
|
||||||
|
if (index<0 || index>4) return false;
|
||||||
|
return sliderConfig[index] != SLIDER_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
GeneralSettings::GeneralSettings()
|
GeneralSettings::GeneralSettings()
|
||||||
{
|
{
|
||||||
memset(this, 0, sizeof(GeneralSettings));
|
memset(this, 0, sizeof(GeneralSettings));
|
||||||
|
|
|
@ -346,6 +346,8 @@ class RawSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isTimeBased() const;
|
bool isTimeBased() const;
|
||||||
|
bool isPot() const;
|
||||||
|
bool isSlider() const;
|
||||||
|
|
||||||
RawSourceType type;
|
RawSourceType type;
|
||||||
int index;
|
int index;
|
||||||
|
@ -1204,6 +1206,8 @@ class GeneralSettings {
|
||||||
static SwitchInfo switchInfoFromSwitchPositionTaranis(unsigned int index);
|
static SwitchInfo switchInfoFromSwitchPositionTaranis(unsigned int index);
|
||||||
bool switchPositionAllowedTaranis(int index) const;
|
bool switchPositionAllowedTaranis(int index) const;
|
||||||
bool switchSourceAllowedTaranis(int index) const;
|
bool switchSourceAllowedTaranis(int index) const;
|
||||||
|
bool isPotAvailable(int index) const;
|
||||||
|
bool isSliderAvailable(int index) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RadioData {
|
class RadioData {
|
||||||
|
|
|
@ -576,10 +576,8 @@ int OpenTxFirmware::getCapability(const Capability capability)
|
||||||
case Pots:
|
case Pots:
|
||||||
if (IS_TARANIS_X9E(board))
|
if (IS_TARANIS_X9E(board))
|
||||||
return 4;
|
return 4;
|
||||||
else if (IS_TARANIS_PLUS(board))
|
|
||||||
return 3;
|
|
||||||
else if (IS_TARANIS(board))
|
else if (IS_TARANIS(board))
|
||||||
return 2;
|
return 3; //Taranis has only 2 pots but still has a placeholder in settings for 3 pots
|
||||||
else
|
else
|
||||||
return 3;
|
return 3;
|
||||||
case Sliders:
|
case Sliders:
|
||||||
|
|
|
@ -562,8 +562,11 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const GeneralSetti
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & POPULATE_SOURCES) {
|
if (flags & POPULATE_SOURCES) {
|
||||||
for (int i=0; i<4+GetCurrentFirmware()->getCapability(Pots); i++) {
|
for (int i=0; i<NUM_STICKS+GetCurrentFirmware()->getCapability(Pots)+GetCurrentFirmware()->getCapability(Sliders); i++) {
|
||||||
item = RawSource(SOURCE_TYPE_STICK, i);
|
item = RawSource(SOURCE_TYPE_STICK, i);
|
||||||
|
// skip unavailable pots and sliders
|
||||||
|
if (item.isPot() && !generalSettings.isPotAvailable(i-NUM_STICKS)) continue;
|
||||||
|
if (item.isSlider() && !generalSettings.isSliderAvailable(i-NUM_STICKS-GetCurrentFirmware()->getCapability(Pots))) continue;
|
||||||
b->addItem(item.toString(model), item.toValue());
|
b->addItem(item.toString(model), item.toValue());
|
||||||
if (item == source) b->setCurrentIndex(b->count()-1);
|
if (item == source) b->setCurrentIndex(b->count()-1);
|
||||||
}
|
}
|
||||||
|
@ -938,7 +941,7 @@ void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
|
||||||
SimulatorDialog * sd;
|
SimulatorDialog * sd;
|
||||||
if (IS_TARANIS(board)) {
|
if (IS_TARANIS(board)) {
|
||||||
for (int i=0; i<GetCurrentFirmware()->getCapability(Pots); i++) {
|
for (int i=0; i<GetCurrentFirmware()->getCapability(Pots); i++) {
|
||||||
if (radioData.generalSettings.potConfig[i] != GeneralSettings::POT_NONE) {
|
if (radioData.generalSettings.isPotAvailable(i)) {
|
||||||
flags |= (SIMULATOR_FLAGS_S1 << i);
|
flags |= (SIMULATOR_FLAGS_S1 << i);
|
||||||
if (radioData.generalSettings.potConfig[1] == GeneralSettings::POT_MULTIPOS_SWITCH ) {
|
if (radioData.generalSettings.potConfig[1] == GeneralSettings::POT_MULTIPOS_SWITCH ) {
|
||||||
flags |= (SIMULATOR_FLAGS_S1_MULTI << i);
|
flags |= (SIMULATOR_FLAGS_S1_MULTI << i);
|
||||||
|
|
|
@ -517,15 +517,12 @@ SetupPanel::SetupPanel(QWidget *parent, ModelData & model, GeneralSettings & gen
|
||||||
connect(checkbox, SIGNAL(toggled(bool)), this, SLOT(onBeepCenterToggled(bool)));
|
connect(checkbox, SIGNAL(toggled(bool)), this, SLOT(onBeepCenterToggled(bool)));
|
||||||
centerBeepCheckboxes << checkbox;
|
centerBeepCheckboxes << checkbox;
|
||||||
if (IS_TARANIS(board)) {
|
if (IS_TARANIS(board)) {
|
||||||
if (i >= NUM_STICKS && i < NUM_STICKS + firmware->getCapability(Pots)) {
|
RawSource src(SOURCE_TYPE_STICK, i);
|
||||||
if (generalSettings.potConfig[i-NUM_STICKS] == GeneralSettings::POT_NONE) {
|
if (src.isPot() && !generalSettings.isPotAvailable(i-NUM_STICKS)) {
|
||||||
checkbox->hide();
|
checkbox->hide();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (i >= NUM_STICKS + firmware->getCapability(Pots) && i < analogs) {
|
else if (src.isSlider() && !generalSettings.isSliderAvailable(i-NUM_STICKS-firmware->getCapability(Pots))) {
|
||||||
if (generalSettings.sliderConfig[i-NUM_STICKS-firmware->getCapability(Pots)] == GeneralSettings::SLIDER_NONE) {
|
checkbox->hide();
|
||||||
checkbox->hide();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QWidget::setTabOrder(prevFocus, checkbox);
|
QWidget::setTabOrder(prevFocus, checkbox);
|
||||||
|
@ -592,13 +589,13 @@ SetupPanel::SetupPanel(QWidget *parent, ModelData & model, GeneralSettings & gen
|
||||||
ui->potWarningLayout->addWidget(cb, 0, i+1);
|
ui->potWarningLayout->addWidget(cb, 0, i+1);
|
||||||
connect(cb, SIGNAL(toggled(bool)), this, SLOT(potWarningToggled(bool)));
|
connect(cb, SIGNAL(toggled(bool)), this, SLOT(potWarningToggled(bool)));
|
||||||
potWarningCheckboxes << cb;
|
potWarningCheckboxes << cb;
|
||||||
if (i < firmware->getCapability(Pots)) {
|
if (RawSource(SOURCE_TYPE_STICK,i).isPot()) {
|
||||||
if (generalSettings.potConfig[i] == GeneralSettings::POT_NONE) {
|
if (!generalSettings.isPotAvailable(i)) {
|
||||||
cb->hide();
|
cb->hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (generalSettings.sliderConfig[i-firmware->getCapability(Pots)] == GeneralSettings::SLIDER_NONE) {
|
if (!generalSettings.isSliderAvailable(i-firmware->getCapability(Pots))) {
|
||||||
cb->hide();
|
cb->hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue