mirror of
https://github.com/EdgeTX/edgetx.git
synced 2025-07-13 19:40:16 +03:00
parent
65ce8b4602
commit
162ffdb148
6 changed files with 67 additions and 36 deletions
|
@ -3,6 +3,5 @@ Language: Cpp
|
||||||
BasedOnStyle: Google
|
BasedOnStyle: Google
|
||||||
BreakBeforeBraces: Linux
|
BreakBeforeBraces: Linux
|
||||||
BreakConstructorInitializers: AfterColon
|
BreakConstructorInitializers: AfterColon
|
||||||
AccessModifierOffset: 0
|
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,21 @@ void SourceChoice::fillMenu(Menu * menu, const std::function<bool(int16_t)> & fi
|
||||||
if (current >= 0) {
|
if (current >= 0) {
|
||||||
menu->select(current);
|
menu->select(current);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(AUTOSOURCE)
|
||||||
|
menu->setWaitHandler([=]() {
|
||||||
|
int8_t val = getMovedSource(0);
|
||||||
|
if (val) {
|
||||||
|
if (filter && filter(val)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (setValue) {
|
||||||
|
setValue(val);
|
||||||
|
}
|
||||||
|
this->fillMenu(menu);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SourceChoice::openMenu()
|
void SourceChoice::openMenu()
|
||||||
|
|
|
@ -65,13 +65,9 @@ void SwitchChoice::fillMenu(Menu * menu, std::function<bool(int16_t)> filter)
|
||||||
menu->removeLines();
|
menu->removeLines();
|
||||||
|
|
||||||
for (int i = vmin; i <= vmax; ++i) {
|
for (int i = vmin; i <= vmax; ++i) {
|
||||||
if (filter && !filter(i))
|
if (filter && !filter(i)) continue;
|
||||||
continue;
|
if (isValueAvailable && !isValueAvailable(i)) continue;
|
||||||
if (isValueAvailable && !isValueAvailable(i))
|
menu->addLine(getSwitchPositionName(i), [=]() { setValue(i); });
|
||||||
continue;
|
|
||||||
menu->addLine(getSwitchPositionName(i), [=]() {
|
|
||||||
setValue(i);
|
|
||||||
});
|
|
||||||
if (value == i) {
|
if (value == i) {
|
||||||
current = count;
|
current = count;
|
||||||
}
|
}
|
||||||
|
@ -93,6 +89,27 @@ void SwitchChoice::openMenu()
|
||||||
editMode = false;
|
editMode = false;
|
||||||
setFocus(SET_FOCUS_DEFAULT);
|
setFocus(SET_FOCUS_DEFAULT);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
#if defined(AUTOSWITCH)
|
||||||
|
menu->setWaitHandler([=]() {
|
||||||
|
swsrc_t val = 0;
|
||||||
|
swsrc_t swtch = getMovedSwitch();
|
||||||
|
if (swtch) {
|
||||||
|
div_t info = switchInfo(swtch);
|
||||||
|
if (IS_CONFIG_TOGGLE(info.quot)) {
|
||||||
|
if (info.rem != 0) {
|
||||||
|
val = (val == swtch ? swtch - 2 : swtch);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val = swtch;
|
||||||
|
}
|
||||||
|
if (val && (!isValueAvailable || isValueAvailable(val))) {
|
||||||
|
if (setValue) setValue(val);
|
||||||
|
this->fillMenu(menu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
|
|
|
@ -26,11 +26,15 @@
|
||||||
class Menu;
|
class Menu;
|
||||||
bool isSwitchAvailableInMixes(int swtch);
|
bool isSwitchAvailableInMixes(int swtch);
|
||||||
|
|
||||||
class SwitchChoice : public FormField {
|
class SwitchChoice : public FormField
|
||||||
template <class T> friend class MenuToolbar;
|
{
|
||||||
|
template <class T>
|
||||||
|
friend class MenuToolbar;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SwitchChoice(Window * parent, const rect_t & rect, int vmin, int vmax, std::function<int16_t()> getValue, std::function<void(int16_t)> setValue):
|
SwitchChoice(Window* parent, const rect_t& rect, int vmin, int vmax,
|
||||||
|
std::function<int16_t()> getValue,
|
||||||
|
std::function<void(int16_t)> setValue) :
|
||||||
FormField(parent, rect),
|
FormField(parent, rect),
|
||||||
vmin(vmin),
|
vmin(vmin),
|
||||||
vmax(vmax),
|
vmax(vmax),
|
||||||
|
@ -40,20 +44,17 @@ class SwitchChoice : public FormField {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(DEBUG_WINDOWS)
|
#if defined(DEBUG_WINDOWS)
|
||||||
std::string getName() const override
|
std::string getName() const override { return "SwitchChoice"; }
|
||||||
{
|
|
||||||
return "SwitchChoice";
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void paint(BitmapBuffer * dc) override;
|
void paint(BitmapBuffer* dc) override;
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
void onEvent(event_t event) override;
|
void onEvent(event_t event) override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HARDWARE_TOUCH)
|
#if defined(HARDWARE_TOUCH)
|
||||||
bool onTouchEnd(coord_t x, coord_t y) override ;
|
bool onTouchEnd(coord_t x, coord_t y) override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void setAvailableHandler(std::function<bool(int)> handler)
|
void setAvailableHandler(std::function<bool(int)> handler)
|
||||||
|
@ -67,7 +68,7 @@ class SwitchChoice : public FormField {
|
||||||
std::function<int16_t()> getValue;
|
std::function<int16_t()> getValue;
|
||||||
std::function<void(int16_t)> setValue;
|
std::function<void(int16_t)> setValue;
|
||||||
std::function<bool(int)> isValueAvailable = isSwitchAvailableInMixes;
|
std::function<bool(int)> isValueAvailable = isSwitchAvailableInMixes;
|
||||||
void fillMenu(Menu * menu, std::function<bool(int16_t)> condition=nullptr);
|
void fillMenu(Menu* menu, std::function<bool(int16_t)> condition = nullptr);
|
||||||
void openMenu();
|
void openMenu();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -383,7 +383,7 @@ bool isInputRecursive(int index)
|
||||||
#if defined(AUTOSOURCE)
|
#if defined(AUTOSOURCE)
|
||||||
constexpr int MULTIPOS_STEP_SIZE = (2 * RESX) / XPOTS_MULTIPOS_COUNT;
|
constexpr int MULTIPOS_STEP_SIZE = (2 * RESX) / XPOTS_MULTIPOS_COUNT;
|
||||||
|
|
||||||
int8_t getMovedSource(GET_MOVED_SOURCE_PARAMS)
|
int8_t getMovedSource(uint8_t min)
|
||||||
{
|
{
|
||||||
int8_t result = 0;
|
int8_t result = 0;
|
||||||
static tmr10ms_t s_move_last_time = 0;
|
static tmr10ms_t s_move_last_time = 0;
|
||||||
|
|
|
@ -549,8 +549,7 @@ void logicalSwitchesCopyState(uint8_t src, uint8_t dst);
|
||||||
extern swarnstate_t switches_states;
|
extern swarnstate_t switches_states;
|
||||||
swsrc_t getMovedSwitch();
|
swsrc_t getMovedSwitch();
|
||||||
|
|
||||||
#define GET_MOVED_SOURCE_PARAMS uint8_t min
|
int8_t getMovedSource(uint8_t min);
|
||||||
int8_t getMovedSource(GET_MOVED_SOURCE_PARAMS);
|
|
||||||
#define GET_MOVED_SOURCE(min, max) getMovedSource(min)
|
#define GET_MOVED_SOURCE(min, max) getMovedSource(min)
|
||||||
|
|
||||||
#if defined(FLIGHT_MODES)
|
#if defined(FLIGHT_MODES)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue