fix: hide 'invert' toggle for multipos switches, fix cpn slider/pot invert state (#5160)
This commit is contained in:
@@ -311,7 +311,7 @@ void GeneralSettings::setDefaultControlTypes(Board::Type board)
|
|||||||
Board::InputInfo info = Boards::getInputInfo(i, board);
|
Board::InputInfo info = Boards::getInputInfo(i, board);
|
||||||
inputConfig[i].type = info.type;
|
inputConfig[i].type = info.type;
|
||||||
inputConfig[i].flexType = info.flexType;
|
inputConfig[i].flexType = info.flexType;
|
||||||
inputConfig[i].inverted = info.inverted;
|
inputConfig[i].inverted = false; //info.inverted;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -442,6 +442,16 @@ void HardwarePanel::addFlex(int index)
|
|||||||
AbstractItemModel *mdl = editorItemModels->getItemModel(AbstractItemModel::IMID_FlexSwitches);
|
AbstractItemModel *mdl = editorItemModels->getItemModel(AbstractItemModel::IMID_FlexSwitches);
|
||||||
if (mdl)
|
if (mdl)
|
||||||
mdl->update(AbstractItemModel::IMUE_FunctionSwitches);
|
mdl->update(AbstractItemModel::IMUE_FunctionSwitches);
|
||||||
|
if (generalSettings.isInputMultiPosPot(index)) {
|
||||||
|
invertToggles[index - Boards::getCapability(board, Board::Sticks)]->hide();
|
||||||
|
if (generalSettings.inputConfig[index].inverted) {
|
||||||
|
generalSettings.inputConfig[index].inverted = false;
|
||||||
|
invertToggles[index - Boards::getCapability(board, Board::Sticks)]->updateValue();
|
||||||
|
emit modified();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
invertToggles[index - Boards::getCapability(board, Board::Sticks)]->show();
|
||||||
|
}
|
||||||
emit InputFlexTypeChanged();
|
emit InputFlexTypeChanged();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -452,6 +462,15 @@ void HardwarePanel::addFlex(int index)
|
|||||||
AutoCheckBox *inverted = new AutoCheckBox(this);
|
AutoCheckBox *inverted = new AutoCheckBox(this);
|
||||||
inverted->setField(config.inverted, this);
|
inverted->setField(config.inverted, this);
|
||||||
params->append(inverted);
|
params->append(inverted);
|
||||||
|
if (generalSettings.isInputMultiPosPot(index)) {
|
||||||
|
inverted->hide();
|
||||||
|
if (config.inverted) {
|
||||||
|
config.inverted = false;
|
||||||
|
inverted->updateValue();
|
||||||
|
emit modified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
invertToggles.push_back(inverted);
|
||||||
|
|
||||||
addParams();
|
addParams();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ class QGridLayout;
|
|||||||
class AutoComboBox;
|
class AutoComboBox;
|
||||||
class ExclusiveComboGroup;
|
class ExclusiveComboGroup;
|
||||||
|
|
||||||
|
class AutoCheckBox;
|
||||||
|
|
||||||
class HardwarePanel : public GeneralPanel
|
class HardwarePanel : public GeneralPanel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -58,6 +60,7 @@ class HardwarePanel : public GeneralPanel
|
|||||||
QList<QWidget *> *params;
|
QList<QWidget *> *params;
|
||||||
int row;
|
int row;
|
||||||
ExclusiveComboGroup *exclFlexSwitchesGroup;
|
ExclusiveComboGroup *exclFlexSwitchesGroup;
|
||||||
|
std::vector<AutoCheckBox*> invertToggles;
|
||||||
|
|
||||||
void addStick(int index);
|
void addStick(int index);
|
||||||
void addFlex(int index);
|
void addFlex(int index);
|
||||||
|
|||||||
@@ -92,6 +92,12 @@ HWPots::HWPots(Window* parent) :
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
new StaticText(this, {P_NM_X, -2, 0, 0}, STR_NAME, FONT(XS));
|
||||||
|
new StaticText(this, {P_TYP_X, -2, 0, 0}, STR_TYPE, FONT(XS));
|
||||||
|
new StaticText(this, {P_INV_X, -2, 0, 0}, STR_MENU_INVERT, FONT(XS));
|
||||||
|
|
||||||
|
coord_t yo = EdgeTxStyles::PAGE_LINE_HEIGHT - 2;
|
||||||
|
|
||||||
auto max_pots = adcGetMaxInputs(ADC_INPUT_FLEX);
|
auto max_pots = adcGetMaxInputs(ADC_INPUT_FLEX);
|
||||||
for (int i = 0; i < max_pots; i++) {
|
for (int i = 0; i < max_pots; i++) {
|
||||||
// TODO: check initialised ADC inputs instead!
|
// TODO: check initialised ADC inputs instead!
|
||||||
@@ -102,31 +108,42 @@ HWPots::HWPots(Window* parent) :
|
|||||||
// if (!globalData.flyskygimbals && (i >= (NUM_POTS - 2))) continue;
|
// if (!globalData.flyskygimbals && (i >= (NUM_POTS - 2))) continue;
|
||||||
// #endif
|
// #endif
|
||||||
new StaticText(this,
|
new StaticText(this,
|
||||||
rect_t{P_LBL_X, P_Y(i) + 6, P_LBL_W, EdgeTxStyles::UI_ELEMENT_HEIGHT},
|
rect_t{P_LBL_X, P_Y(i) + yo + PAD_MEDIUM, P_LBL_W, EdgeTxStyles::UI_ELEMENT_HEIGHT},
|
||||||
adcGetInputLabel(ADC_INPUT_FLEX, i));
|
adcGetInputLabel(ADC_INPUT_FLEX, i));
|
||||||
|
|
||||||
new HWInputEdit(this, (char*)analogGetCustomLabel(ADC_INPUT_FLEX, i),
|
new HWInputEdit(this, (char*)analogGetCustomLabel(ADC_INPUT_FLEX, i),
|
||||||
LEN_ANA_NAME, P_NM_X, P_Y(i));
|
LEN_ANA_NAME, P_NM_X, P_Y(i) + yo);
|
||||||
|
|
||||||
auto pot = new Choice(
|
auto pot = new Choice(
|
||||||
this, rect_t{P_TYP_X, P_Y(i) + P_OFST_Y, P_TYP_W, EdgeTxStyles::UI_ELEMENT_HEIGHT},
|
this, rect_t{P_TYP_X, P_Y(i) + P_OFST_Y + yo, P_TYP_W, EdgeTxStyles::UI_ELEMENT_HEIGHT},
|
||||||
STR_POTTYPES, FLEX_NONE, FLEX_SWITCH,
|
STR_POTTYPES, FLEX_NONE, FLEX_SWITCH,
|
||||||
[=]() -> int { return getPotType(i); },
|
[=]() -> int { return getPotType(i); },
|
||||||
[=](int newValue) {
|
[=](int newValue) {
|
||||||
setPotType(i, newValue);
|
setPotType(i, newValue);
|
||||||
switchFixFlexConfig();
|
switchFixFlexConfig();
|
||||||
potsChanged = true;
|
potsChanged = true;
|
||||||
|
invertToggles[i]->show(newValue != FLEX_MULTIPOS);
|
||||||
|
if (newValue == FLEX_MULTIPOS) {
|
||||||
|
setPotInversion(i, 0);
|
||||||
|
invertToggles[i]->update();
|
||||||
|
}
|
||||||
SET_DIRTY();
|
SET_DIRTY();
|
||||||
});
|
});
|
||||||
pot->setAvailableHandler([=](int val) { return isPotTypeAvailable(val); });
|
pot->setAvailableHandler([=](int val) { return isPotTypeAvailable(val); });
|
||||||
|
|
||||||
new ToggleSwitch(
|
auto tgl = new ToggleSwitch(
|
||||||
this, rect_t{P_INV_X, P_Y(i) + P_OFST_Y, P_INV_W, EdgeTxStyles::UI_ELEMENT_HEIGHT},
|
this, rect_t{P_INV_X, P_Y(i) + P_OFST_Y + yo, P_INV_W, EdgeTxStyles::UI_ELEMENT_HEIGHT},
|
||||||
[=]() -> uint8_t { return (uint8_t)getPotInversion(i); },
|
[=]() -> uint8_t { return (uint8_t)getPotInversion(i); },
|
||||||
[=](int8_t newValue) {
|
[=](int8_t newValue) {
|
||||||
setPotInversion(i, newValue);
|
setPotInversion(i, newValue);
|
||||||
SET_DIRTY();
|
SET_DIRTY();
|
||||||
});
|
});
|
||||||
|
tgl->show(!IS_POT_MULTIPOS(i));
|
||||||
|
if (IS_POT_MULTIPOS(i) && getPotInversion(i)) {
|
||||||
|
setPotInversion(i, 0);
|
||||||
|
SET_DIRTY();
|
||||||
|
}
|
||||||
|
invertToggles.push_back(tgl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,15 +209,15 @@ HWSwitches::HWSwitches(Window* parent) :
|
|||||||
{
|
{
|
||||||
auto max_switches = switchGetMaxSwitches();
|
auto max_switches = switchGetMaxSwitches();
|
||||||
for (int i = 0; i < max_switches; i++) {
|
for (int i = 0; i < max_switches; i++) {
|
||||||
new SwitchDynamicLabel(this, i, 2, i * SW_CTRL_H + 2);
|
new SwitchDynamicLabel(this, i, PAD_TINY, i * SW_CTRL_H + PAD_TINY);
|
||||||
new HWInputEdit(this, (char*)switchGetCustomName(i), LEN_SWITCH_NAME,
|
new HWInputEdit(this, (char*)switchGetCustomName(i), LEN_SWITCH_NAME,
|
||||||
SW_CTRL_W + 8, i * SW_CTRL_H + 2);
|
SW_CTRL_W + 8, i * SW_CTRL_H + PAD_TINY);
|
||||||
|
|
||||||
coord_t x = SW_CTRL_W * 2 + 14;
|
coord_t x = SW_CTRL_W * PAD_TINY + 14;
|
||||||
Choice* channel = nullptr;
|
Choice* channel = nullptr;
|
||||||
if (switchIsFlex(i)) {
|
if (switchIsFlex(i)) {
|
||||||
channel = new Choice(
|
channel = new Choice(
|
||||||
this, rect_t{x, i * SW_CTRL_H + 2, SW_CTRL_W, EdgeTxStyles::UI_ELEMENT_HEIGHT}, -1,
|
this, rect_t{x, i * SW_CTRL_H + PAD_TINY, SW_CTRL_W, EdgeTxStyles::UI_ELEMENT_HEIGHT}, -1,
|
||||||
adcGetMaxInputs(ADC_INPUT_FLEX) - 1,
|
adcGetMaxInputs(ADC_INPUT_FLEX) - 1,
|
||||||
[=]() -> int { return switchGetFlexConfig(i); },
|
[=]() -> int { return switchGetFlexConfig(i); },
|
||||||
[=](int newValue) { switchConfigFlex(i, newValue); });
|
[=](int newValue) { switchConfigFlex(i, newValue); });
|
||||||
@@ -215,7 +232,7 @@ HWSwitches::HWSwitches(Window* parent) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto sw_cfg = new Choice(
|
auto sw_cfg = new Choice(
|
||||||
this, rect_t{x, i * SW_CTRL_H + 2, SW_CTRL_W, EdgeTxStyles::UI_ELEMENT_HEIGHT},
|
this, rect_t{x, i * SW_CTRL_H + PAD_TINY, SW_CTRL_W, EdgeTxStyles::UI_ELEMENT_HEIGHT},
|
||||||
STR_SWTYPES, SWITCH_NONE, switchGetMaxType(i),
|
STR_SWTYPES, SWITCH_NONE, switchGetMaxType(i),
|
||||||
[=]() -> int { return SWITCH_CONFIG(i); },
|
[=]() -> int { return SWITCH_CONFIG(i); },
|
||||||
[=](int newValue) {
|
[=](int newValue) {
|
||||||
|
|||||||
@@ -24,14 +24,20 @@
|
|||||||
#include "button.h"
|
#include "button.h"
|
||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
#include "form.h"
|
#include "form.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
struct HWSticks : public Window {
|
class ToggleSwitch;
|
||||||
|
|
||||||
|
class HWSticks : public Window
|
||||||
|
{
|
||||||
|
public:
|
||||||
HWSticks(Window* parent);
|
HWSticks(Window* parent);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct HWPots : public Window {
|
struct HWPots : public Window
|
||||||
|
{
|
||||||
|
public:
|
||||||
HWPots(Window* parent);
|
HWPots(Window* parent);
|
||||||
bool potsChanged;
|
|
||||||
|
|
||||||
// Absolute layout for Pots popup - due to performance issues with lv_textarea
|
// Absolute layout for Pots popup - due to performance issues with lv_textarea
|
||||||
// in a flex layout
|
// in a flex layout
|
||||||
@@ -46,9 +52,15 @@ struct HWPots : public Window {
|
|||||||
static LAYOUT_VAL(P_ROW_H, 36, 72)
|
static LAYOUT_VAL(P_ROW_H, 36, 72)
|
||||||
static LAYOUT_VAL(P_OFST_Y, 0, 36)
|
static LAYOUT_VAL(P_OFST_Y, 0, 36)
|
||||||
#define P_Y(i) (i * P_ROW_H + 2)
|
#define P_Y(i) (i * P_ROW_H + 2)
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool potsChanged;
|
||||||
|
std::vector<ToggleSwitch*> invertToggles;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct HWSwitches : public Window {
|
class HWSwitches : public Window
|
||||||
|
{
|
||||||
|
public:
|
||||||
HWSwitches(Window* parent);
|
HWSwitches(Window* parent);
|
||||||
|
|
||||||
// Absolute layout for Switches popup - due to performance issues with
|
// Absolute layout for Switches popup - due to performance issues with
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ static void _init_menu_tab_array(uint8_t* tab, size_t len)
|
|||||||
auto max_pots = adcGetMaxInputs(ADC_INPUT_FLEX);
|
auto max_pots = adcGetMaxInputs(ADC_INPUT_FLEX);
|
||||||
for (int i = ITEM_RADIO_HARDWARE_POT; i <= ITEM_RADIO_HARDWARE_POT_END; i++) {
|
for (int i = ITEM_RADIO_HARDWARE_POT; i <= ITEM_RADIO_HARDWARE_POT_END; i++) {
|
||||||
uint8_t idx = i - ITEM_RADIO_HARDWARE_POT;
|
uint8_t idx = i - ITEM_RADIO_HARDWARE_POT;
|
||||||
tab[i] = idx < max_pots ? 2 : HIDDEN_ROW;
|
tab[i] = idx < max_pots ? (IS_POT_MULTIPOS(idx) ? 1 : 2) : HIDDEN_ROW;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto max_switches = switchGetMaxSwitches();
|
auto max_switches = switchGetMaxSwitches();
|
||||||
@@ -527,12 +527,17 @@ void menuRadioHardware(event_t event)
|
|||||||
if (checkIncDec_Ret) switchFixFlexConfig();
|
if (checkIncDec_Ret) switchFixFlexConfig();
|
||||||
setPotType(idx, potType);
|
setPotType(idx, potType);
|
||||||
|
|
||||||
// ADC inversion
|
if (!IS_POT_MULTIPOS(idx)) {
|
||||||
flags = menuHorizontalPosition == 2 ? attr : 0;
|
// ADC inversion
|
||||||
bool potinversion = getPotInversion(idx);
|
flags = menuHorizontalPosition == 2 ? attr : 0;
|
||||||
lcdDrawChar(LCD_W - 8, y, potinversion ? 127 : 126, flags);
|
bool potinversion = getPotInversion(idx);
|
||||||
if (flags & (~RIGHT)) potinversion = checkIncDec(event, potinversion, 0, 1, (isModelMenuDisplayed()) ? EE_MODEL : EE_GENERAL);
|
lcdDrawChar(LCD_W - 8, y, potinversion ? 127 : 126, flags);
|
||||||
setPotInversion(idx, potinversion);
|
if (flags & (~RIGHT)) potinversion = checkIncDec(event, potinversion, 0, 1, (isModelMenuDisplayed()) ? EE_MODEL : EE_GENERAL);
|
||||||
|
setPotInversion(idx, potinversion);
|
||||||
|
} else if (getPotInversion(idx)) {
|
||||||
|
setPotInversion(idx, 0);
|
||||||
|
storageDirty(EE_GENERAL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (k <= ITEM_RADIO_HARDWARE_SWITCH_END) {
|
else if (k <= ITEM_RADIO_HARDWARE_SWITCH_END) {
|
||||||
// Switches
|
// Switches
|
||||||
|
|||||||
Reference in New Issue
Block a user