feat: add support for ExpressLRS optional arming method (#5641)
Co-authored-by: elecpower <elecpower@users.noreply.github.com>
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
|
||||
CrossfireSettings::CrossfireSettings(Window* parent, const FlexGridLayout& g,
|
||||
uint8_t moduleIdx) :
|
||||
Window(parent, rect_t{}), md(&g_model.moduleData[moduleIdx])
|
||||
Window(parent, rect_t{}), md(&g_model.moduleData[moduleIdx]), moduleIdx(moduleIdx)
|
||||
{
|
||||
FlexGridLayout grid(g);
|
||||
setFlexLayout();
|
||||
@@ -66,4 +66,39 @@ CrossfireSettings::CrossfireSettings(Window* parent, const FlexGridLayout& g,
|
||||
sprintf(msg, "%d Hz", 1000000 / getMixerSchedulerPeriod());
|
||||
return std::string(msg);
|
||||
});
|
||||
|
||||
moduleIdx = moduleIdx;
|
||||
|
||||
auto armingLine = newLine(grid);
|
||||
lblArmMode = new StaticText(armingLine, rect_t{}, STR_CRSF_ARMING_MODE);
|
||||
auto box = new Window(armingLine, rect_t{});
|
||||
box->padAll(PAD_TINY);
|
||||
box->setFlexLayout(LV_FLEX_FLOW_ROW, PAD_SMALL);
|
||||
choArmMode = new Choice(box, rect_t{}, STR_CRSF_ARMING_MODES, 0, 1, GET_SET_DEFAULT(md->crsf.crsfArmingMode));
|
||||
choArmSwitch = new SwitchChoice(box, rect_t{}, SWSRC_FIRST, SWSRC_LAST, GET_SET_DEFAULT(md->crsf.crsfArmingTrigger));
|
||||
choArmSwitch->setAvailableHandler([=](int sw) { return isSwitchAvailableForArming(sw); });
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void CrossfireSettings::update() {
|
||||
if(CRSF_ELRS_MIN_VER(moduleIdx, 4, 0)) {
|
||||
lblArmMode->show();
|
||||
choArmMode->show();
|
||||
|
||||
if(md->crsf.crsfArmingMode == ARMING_MODE_SWITCH)
|
||||
choArmSwitch->show();
|
||||
else
|
||||
choArmSwitch->hide();
|
||||
} else {
|
||||
lblArmMode->hide();
|
||||
choArmMode->hide();
|
||||
choArmSwitch->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void CrossfireSettings::checkEvents() {
|
||||
update();
|
||||
|
||||
Window::checkEvents();
|
||||
}
|
||||
|
||||
@@ -23,14 +23,20 @@
|
||||
|
||||
#include "window.h"
|
||||
#include "module_setup.h"
|
||||
#include "switchchoice.h"
|
||||
|
||||
struct ModuleData;
|
||||
|
||||
class CrossfireSettings : public Window, public ModuleOptions
|
||||
{
|
||||
ModuleData* md;
|
||||
StaticText *lblArmMode;
|
||||
Choice *choArmMode;
|
||||
SwitchChoice *choArmSwitch;
|
||||
uint8_t moduleIdx;
|
||||
|
||||
void update() override {}
|
||||
void checkEvents() override;
|
||||
void update() override;
|
||||
|
||||
public:
|
||||
CrossfireSettings(Window* parent, const FlexGridLayout& g, uint8_t moduleIdx);
|
||||
|
||||
Reference in New Issue
Block a user