Fixes for FlySkySettings

This commit is contained in:
Raphael Coeffic
2022-06-25 15:37:11 +02:00
committed by Raphael Coeffic
parent c616204cb9
commit 35e14ff83e
3 changed files with 36 additions and 13 deletions
+24 -10
View File
@@ -28,8 +28,8 @@
class FSProtoOpts : public FormGroup
{
std::function<uint8_t()> getMode;
std::function<void(uint8_t)> setMode;
std::function<uint8_t()> _getMode;
std::function<void(uint8_t)> _setMode;
public:
FSProtoOpts(Window* parent, std::function<uint8_t()> getMode,
@@ -39,30 +39,44 @@ public:
FSProtoOpts::FSProtoOpts(Window* parent, std::function<uint8_t()> getMode,
std::function<void(uint8_t)> setMode) :
FormGroup(parent, rect_t{}),
getMode(std::move(getMode)),
setMode(std::move(setMode))
_getMode(std::move(getMode)),
_setMode(std::move(setMode))
{
setFlexLayout(LV_FLEX_FLOW_ROW);
// PPM / PWM
new Choice(
this, rect_t{}, STR_FLYSKY_PULSE_PROTO, 0, 1,
[=]() { return getMode() >> 1; },
[=](int v) { setMode((getMode() & 1) | ((v & 1) << 1)); SET_DIRTY(); });
[=]() -> int { return _getMode() >> 1; },
[=](int v) {
_setMode((_getMode() & 1) | ((v & 1) << 1));
SET_DIRTY();
});
// SBUS / iBUS
new Choice(
this, rect_t{}, STR_FLYSKY_SERIAL_PROTO, 0, 1,
[=]() { return getMode() & 1; },
[=](int v) { setMode((getMode() & 2) | (v & 1)); SET_DIRTY(); });
[=]() -> int { return _getMode() & 1; },
[=](int v) {
_setMode((_getMode() & 2) | (v & 1));
SET_DIRTY();
});
}
FlySkySettings::FlySkySettings(Window* parent, const FlexGridLayout& g,
uint8_t moduleIdx) :
FormGroup(parent, rect_t{}), md(&g_model.moduleData[moduleIdx])
FormGroup(parent, rect_t{}),
moduleIdx(moduleIdx),
md(&g_model.moduleData[moduleIdx]),
grid(g)
{
FlexGridLayout grid(g);
setFlexLayout();
}
void FlySkySettings::update()
{
clear();
// RX options:
auto line = newLine(&grid);
new StaticText(line, rect_t{}, STR_OPTIONS, 0, COLOR_THEME_PRIMARY1);
+3 -1
View File
@@ -28,9 +28,11 @@ struct ModuleData;
class FlySkySettings : public FormGroup, public ModuleOptions
{
uint8_t moduleIdx;
ModuleData* md;
FlexGridLayout grid;
void update() override {}
void update() override;
public:
FlySkySettings(Window* parent, const FlexGridLayout& g, uint8_t moduleIdx);
+9 -2
View File
@@ -138,10 +138,16 @@ void ModuleWindow::updateModule()
FlexGridLayout grid(col_dsc, row_dsc, 2);
clear();
modOpts = nullptr;
chRange = nullptr;
bindButton = nullptr;
rangeButton = nullptr;
registerButton = nullptr;
fsLine = nullptr;
// Module parameters
ModuleData* md = &g_model.moduleData[moduleIdx];
modOpts = nullptr;
if (md->type == MODULE_TYPE_NONE) {
return;
}
@@ -630,8 +636,9 @@ ModulePage::ModulePage(uint8_t moduleIdx) : Page(ICON_MODEL_SETUP)
moduleChoice->setSetValueHandler([=](int32_t newValue) {
setModuleType(moduleIdx, newValue);
subTypeChoice->update();
moduleWindow->updateModule();
subTypeChoice->update();
SET_DIRTY();
});