Flex module setup
This commit is contained in:
committed by
Raphael Coeffic
parent
387514e2a1
commit
0de678af57
@@ -53,6 +53,7 @@ set(GUI_SRC
|
||||
bind_menu_d16.cpp
|
||||
trainer_setup.cpp
|
||||
custom_failsafe.cpp
|
||||
ppm_settings.cpp
|
||||
module_setup.cpp
|
||||
timer_setup.cpp
|
||||
trims_setup.cpp
|
||||
@@ -130,6 +131,18 @@ if(PXX2 OR MULTIMODULE)
|
||||
add_gui_src(radio_spectrum_analyser.cpp)
|
||||
endif()
|
||||
|
||||
if(CROSSFIRE)
|
||||
add_gui_src(crossfire_settings.cpp)
|
||||
endif()
|
||||
|
||||
if(AFHDS2 OR AFHDS3)
|
||||
add_gui_src(flysky_settings.cpp)
|
||||
endif()
|
||||
|
||||
if(MULTIMODULE)
|
||||
add_gui_src(mpm_settings.cpp)
|
||||
endif()
|
||||
|
||||
if(PXX2)
|
||||
add_gui_src(access_settings.cpp)
|
||||
endif()
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
|
||||
#define SET_DIRTY() storageDirty(EE_MODEL)
|
||||
|
||||
namespace pxx2 {
|
||||
|
||||
static void startBindWaitDialog(Window* parent, uint8_t moduleIdx,
|
||||
uint8_t receiverIdx)
|
||||
{
|
||||
@@ -195,7 +197,7 @@ void BindWaitDialog::checkEvents()
|
||||
Dialog::checkEvents();
|
||||
}
|
||||
|
||||
ReceiverButton::ReceiverButton(FormGroup* parent, rect_t rect,
|
||||
ReceiverButton::ReceiverButton(Window* parent, rect_t rect,
|
||||
uint8_t moduleIdx, uint8_t receiverIdx) :
|
||||
TextButton(parent, rect, STR_BIND,
|
||||
std::bind(&ReceiverButton::pressBind, this)),
|
||||
@@ -880,3 +882,5 @@ void RxOptions::writeSettings()
|
||||
state = RO_WriteSettings;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include "textedit.h"
|
||||
#include "numberedit.h"
|
||||
|
||||
namespace pxx2 {
|
||||
|
||||
class BindRxChoiceMenu : public Menu
|
||||
{
|
||||
public:
|
||||
@@ -58,7 +60,7 @@ class BindWaitDialog : public Dialog
|
||||
class ReceiverButton : public TextButton
|
||||
{
|
||||
public:
|
||||
ReceiverButton(FormGroup* parent, rect_t rect, uint8_t moduleIdx,
|
||||
ReceiverButton(Window* parent, rect_t rect, uint8_t moduleIdx,
|
||||
uint8_t receiverIdx);
|
||||
|
||||
uint8_t pressBind();
|
||||
@@ -143,3 +145,5 @@ class RxOptions : public Dialog
|
||||
void update();
|
||||
void writeSettings();
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
@@ -41,7 +41,10 @@ BindChoiceMenu::BindChoiceMenu(Window *parent, uint8_t moduleIdx,
|
||||
[=]() { onSelect(Bind_9_16_TELEM_OFF); });
|
||||
}
|
||||
setTitle(STR_SELECT_MODE);
|
||||
setCancelHandler(onCancel);
|
||||
setCancelHandler([=] {
|
||||
moduleState[moduleIdx].mode = MODULE_MODE_NORMAL;
|
||||
onCancel();
|
||||
});
|
||||
}
|
||||
|
||||
void BindChoiceMenu::onSelect(BindChanMode mode)
|
||||
@@ -64,16 +67,16 @@ void BindChoiceMenu::onSelect(BindChanMode mode)
|
||||
break;
|
||||
}
|
||||
|
||||
ModuleData* md = &g_model.moduleData[moduleIdx];
|
||||
if (isModuleMultimodule(moduleIdx)) {
|
||||
g_model.moduleData[moduleIdx].multi.receiverTelemetryOff =
|
||||
!receiverTelemetry;
|
||||
g_model.moduleData[moduleIdx].multi.receiverHigherChannels =
|
||||
receiverHigherChannels;
|
||||
md->multi.receiverTelemetryOff = !receiverTelemetry;
|
||||
md->multi.receiverHigherChannels = receiverHigherChannels;
|
||||
setMultiBindStatus(moduleIdx, MULTI_BIND_INITIATED);
|
||||
} else {
|
||||
g_model.moduleData[moduleIdx].pxx.receiverTelemetryOff = !receiverTelemetry;
|
||||
g_model.moduleData[moduleIdx].pxx.receiverHigherChannels =
|
||||
receiverHigherChannels;
|
||||
md->pxx.receiverTelemetryOff = !receiverTelemetry;
|
||||
md->pxx.receiverHigherChannels = receiverHigherChannels;
|
||||
}
|
||||
|
||||
moduleState[moduleIdx].mode = MODULE_MODE_BIND;
|
||||
if (onPressHandler) onPressHandler();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "crossfire_settings.h"
|
||||
#include "opentx.h"
|
||||
|
||||
#include "mixer_scheduler.h"
|
||||
|
||||
#define SET_DIRTY() storageDirty(EE_MODEL)
|
||||
|
||||
CrossfireSettings::CrossfireSettings(Window* parent, const FlexGridLayout& g,
|
||||
uint8_t moduleIdx) :
|
||||
FormGroup(parent, rect_t{}), md(&g_model.moduleData[moduleIdx])
|
||||
{
|
||||
FlexGridLayout grid(g);
|
||||
setFlexLayout();
|
||||
|
||||
if (moduleIdx == EXTERNAL_MODULE) {
|
||||
auto line = newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_BAUDRATE, 0, COLOR_THEME_PRIMARY1);
|
||||
new Choice(
|
||||
line, rect_t{}, STR_CRSF_BAUDRATE, 0, CROSSFIRE_MAX_INTERNAL_BAUDRATE,
|
||||
[=]() -> int {
|
||||
return CROSSFIRE_STORE_TO_INDEX(md->crsf.telemetryBaudrate);
|
||||
},
|
||||
[=](int newValue) {
|
||||
md->crsf.telemetryBaudrate = CROSSFIRE_INDEX_TO_STORE(newValue);
|
||||
SET_DIRTY();
|
||||
restartModule(moduleIdx);
|
||||
});
|
||||
} else {
|
||||
// char buf[6];
|
||||
// new StaticText(this, grid.getFieldSlot(2, 1),
|
||||
// getStringAtIndex(buf, STR_CRSF_BAUDRATE,
|
||||
// CROSSFIRE_STORE_TO_INDEX(
|
||||
// g_eeGeneral.internalModuleBaudrate)),
|
||||
// 0, COLOR_THEME_PRIMARY1);
|
||||
}
|
||||
|
||||
auto line = newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_STATUS, 0, COLOR_THEME_PRIMARY1);
|
||||
new DynamicText(line, rect_t{}, [=] {
|
||||
char msg[64] = "";
|
||||
sprintf(msg, "%d Hz %" PRIu32 " Err", 1000000 / getMixerSchedulerPeriod(),
|
||||
telemetryErrors);
|
||||
return std::string(msg);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "form.h"
|
||||
#include "module_setup.h"
|
||||
|
||||
struct ModuleData;
|
||||
|
||||
class CrossfireSettings : public FormGroup, public ModuleOptions
|
||||
{
|
||||
ModuleData* md;
|
||||
|
||||
void update() override {}
|
||||
|
||||
public:
|
||||
CrossfireSettings(Window* parent, const FlexGridLayout& g, uint8_t moduleIdx);
|
||||
};
|
||||
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "flysky_settings.h"
|
||||
#include "opentx.h"
|
||||
|
||||
#include "pulses/flysky.h"
|
||||
|
||||
#define SET_DIRTY() storageDirty(EE_MODEL)
|
||||
|
||||
class FSProtoOpts : public FormGroup
|
||||
{
|
||||
std::function<uint8_t()> getMode;
|
||||
std::function<void(uint8_t)> setMode;
|
||||
|
||||
public:
|
||||
FSProtoOpts(Window* parent, std::function<uint8_t()> getMode,
|
||||
std::function<void(uint8_t)> setMode);
|
||||
};
|
||||
|
||||
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))
|
||||
{
|
||||
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(); });
|
||||
// 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(); });
|
||||
}
|
||||
|
||||
FlySkySettings::FlySkySettings(Window* parent, const FlexGridLayout& g,
|
||||
uint8_t moduleIdx) :
|
||||
FormGroup(parent, rect_t{}), md(&g_model.moduleData[moduleIdx])
|
||||
{
|
||||
FlexGridLayout grid(g);
|
||||
setFlexLayout();
|
||||
|
||||
// RX options:
|
||||
auto line = newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_OPTIONS, 0, COLOR_THEME_PRIMARY1);
|
||||
|
||||
#if defined(AFHDS2)
|
||||
if (isModuleAFHDS2A(moduleIdx)) {
|
||||
new FSProtoOpts(
|
||||
line, [=]() { return md->flysky.mode; },
|
||||
[=](uint8_t v) { md->flysky.mode = v; });
|
||||
|
||||
#if defined(AFHDS2) && defined(PCBNV14)
|
||||
if (getNV14RfFwVersion() >= 0x1000E) {
|
||||
line = newLine(&grid);
|
||||
static const _rf_power = {"Default", "High"};
|
||||
new StaticText(line, rect_t{}, STR_MULTI_RFPOWER);
|
||||
new Choice(line, rect_t{}, _rf_power, 0, 1,
|
||||
GET_DEFAULT(md->flysky.rfPower),
|
||||
[=](int32_t newValue) -> void {
|
||||
md->flysky.rfPower = newValue;
|
||||
resetPulsesAFHDS2();
|
||||
});
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#if defined(AFHDS3)
|
||||
if (isModuleAFHDS3(moduleIdx)) {
|
||||
new FSProtoOpts(
|
||||
line, [=]() { return md->afhds3.mode; },
|
||||
[=](uint8_t v) { md->afhds3.mode = v; });
|
||||
|
||||
// TYPE
|
||||
line = newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_TYPE, 0, COLOR_THEME_PRIMARY1);
|
||||
|
||||
// This is chosen when binding (menu? see stdlcd/model_setup_afhds3.cpp)
|
||||
new StaticText(line, rect_t{},
|
||||
md->afhds3.telemetry ? STR_AFHDS3_ONE_TO_ONE_TELEMETRY
|
||||
: TR_AFHDS3_ONE_TO_MANY,
|
||||
0, COLOR_THEME_PRIMARY1);
|
||||
|
||||
// Status
|
||||
line = newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_MODULE_STATUS, 0, COLOR_THEME_PRIMARY1);
|
||||
new DynamicText(line, rect_t{}, [=] {
|
||||
char msg[64] = "";
|
||||
getModuleStatusString(moduleIdx, msg);
|
||||
return std::string(msg);
|
||||
});
|
||||
|
||||
// Power source
|
||||
line = newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_AFHDS3_POWER_SOURCE, 0,
|
||||
COLOR_THEME_PRIMARY1);
|
||||
new DynamicText(line, rect_t{}, [=] {
|
||||
char msg[64] = "";
|
||||
getModuleSyncStatusString(moduleIdx, msg);
|
||||
return std::string(msg);
|
||||
});
|
||||
|
||||
// RX Freq
|
||||
line = newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_AFHDS3_RX_FREQ, 0, COLOR_THEME_PRIMARY1);
|
||||
auto edit = new NumberEdit(line, rect_t{}, MIN_FREQ, MAX_FREQ,
|
||||
GET_DEFAULT(md->afhds3.rxFreq()));
|
||||
edit->setSetValueHandler(
|
||||
[=](int32_t newValue) { md->afhds3.setRxFreq((uint16_t)newValue); });
|
||||
edit->setSuffix(STR_HZ);
|
||||
|
||||
// Module actual power
|
||||
line = newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_AFHDS3_ACTUAL_POWER, 0,
|
||||
COLOR_THEME_PRIMARY1);
|
||||
new DynamicText(line, rect_t{}, [=] {
|
||||
char msg[64] = "";
|
||||
getStringAtIndex(msg, STR_AFHDS3_POWERS, actualAfhdsRunPower(moduleIdx));
|
||||
return std::string(msg);
|
||||
});
|
||||
|
||||
// Module power
|
||||
line = newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_RF_POWER, 0, COLOR_THEME_PRIMARY1);
|
||||
new Choice(line, rect_t{}, STR_AFHDS3_POWERS,
|
||||
afhds3::RUN_POWER::RUN_POWER_FIRST,
|
||||
afhds3::RUN_POWER::RUN_POWER_LAST,
|
||||
GET_SET_DEFAULT(md->afhds3.runPower));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "form.h"
|
||||
#include "module_setup.h"
|
||||
|
||||
struct ModuleData;
|
||||
|
||||
class FlySkySettings : public FormGroup, public ModuleOptions
|
||||
{
|
||||
ModuleData* md;
|
||||
|
||||
void update() override {}
|
||||
|
||||
public:
|
||||
FlySkySettings(Window* parent, const FlexGridLayout& g, uint8_t moduleIdx);
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -26,3 +26,9 @@
|
||||
struct ModulePage : public Page {
|
||||
ModulePage(uint8_t moduleIdx);
|
||||
};
|
||||
|
||||
class ModuleOptions
|
||||
{
|
||||
public:
|
||||
virtual void update() = 0;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,294 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "mpm_settings.h"
|
||||
#include "opentx.h"
|
||||
|
||||
#include "multi_rfprotos.h"
|
||||
#include "io/multi_protolist.h"
|
||||
|
||||
#define SET_DIRTY() storageDirty(EE_MODEL)
|
||||
|
||||
struct MPMProtoOption : public FormGroup::Line
|
||||
{
|
||||
StaticText* label;
|
||||
Choice* choice;
|
||||
NumberEdit* edit;
|
||||
CheckBox* cb;
|
||||
DynamicNumber<int>* rssi;
|
||||
|
||||
MPMProtoOption(FormGroup* form, FlexGridLayout *layout);
|
||||
void update(const MultiRfProtocols::RfProto* rfProto, ModuleData* md);
|
||||
};
|
||||
|
||||
MPMProtoOption::MPMProtoOption(FormGroup* form, FlexGridLayout *layout) :
|
||||
FormGroup::Line(form, layout)
|
||||
{
|
||||
if (layout) layout->resetPos();
|
||||
label = new StaticText(this, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
||||
|
||||
auto box = new FormGroup(this, rect_t{});
|
||||
box->setFlexLayout(LV_FLEX_FLOW_ROW);
|
||||
|
||||
choice = new Choice(box, rect_t{}, 0, 0, nullptr);
|
||||
edit = new NumberEdit(box, rect_t{}, 0, 0, nullptr);
|
||||
cb = new CheckBox(box, rect_t{}, nullptr, nullptr);
|
||||
rssi = new DynamicNumber<int>(
|
||||
box, rect_t{}, [] { return (int)TELEMETRY_RSSI(); }, 0, "RSSI: ", " db");
|
||||
}
|
||||
|
||||
void MPMProtoOption::update(const MultiRfProtocols::RfProto* rfProto, ModuleData* md)
|
||||
{
|
||||
if (!rfProto || !rfProto->getOptionStr()) {
|
||||
lv_obj_add_flag(lvobj, LV_OBJ_FLAG_HIDDEN);
|
||||
return;
|
||||
}
|
||||
|
||||
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_HIDDEN);
|
||||
|
||||
const char *title = rfProto->getOptionStr();
|
||||
label->setText(title);
|
||||
|
||||
lv_obj_add_flag(choice->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
lv_obj_add_flag(edit->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
lv_obj_add_flag(cb->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
lv_obj_add_flag(rssi->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
|
||||
int8_t min, max;
|
||||
getMultiOptionValues(rfProto->proto, min, max);
|
||||
|
||||
if (title == STR_MULTI_RFPOWER) {
|
||||
choice->setValues(STR_MULTI_POWER);
|
||||
choice->setMin(0);
|
||||
choice->setMax(15);
|
||||
choice->setGetValueHandler(GET_DEFAULT(md->multi.optionValue));
|
||||
choice->setSetValueHandler(SET_DEFAULT(md->multi.optionValue));
|
||||
lv_obj_clear_flag(choice->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
} else if (title == STR_MULTI_TELEMETRY) {
|
||||
choice->setValues(STR_MULTI_TELEMETRY_MODE);
|
||||
choice->setMin(min);
|
||||
choice->setMax(max);
|
||||
choice->setGetValueHandler(GET_DEFAULT(md->multi.optionValue));
|
||||
choice->setSetValueHandler(SET_DEFAULT(md->multi.optionValue));
|
||||
lv_obj_clear_flag(choice->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
} else if (title == STR_MULTI_WBUS) {
|
||||
choice->setValues(STR_MULTI_WBUS_MODE);
|
||||
choice->setMin(0);
|
||||
choice->setMax(1);
|
||||
choice->setGetValueHandler(GET_DEFAULT(md->multi.optionValue));
|
||||
choice->setSetValueHandler(SET_DEFAULT(md->multi.optionValue));
|
||||
lv_obj_clear_flag(choice->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
} else if (rfProto->proto == MODULE_SUBTYPE_MULTI_FS_AFHDS2A) {
|
||||
edit->setMin(50);
|
||||
edit->setMax(400);
|
||||
edit->setGetValueHandler(GET_DEFAULT(50 + 5 * md->multi.optionValue));
|
||||
edit->setSetValueHandler(SET_VALUE(md->multi.optionValue, (newValue - 50) / 5));
|
||||
edit->setStep(5);
|
||||
lv_obj_clear_flag(edit->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
} else if (rfProto->proto == MODULE_SUBTYPE_MULTI_DSM2) {
|
||||
cb->setGetValueHandler([=]() { return md->multi.optionValue & 0x01; });
|
||||
cb->setSetValueHandler([=](int8_t newValue) {
|
||||
md->multi.optionValue = (md->multi.optionValue & 0xFE) + newValue;
|
||||
});
|
||||
lv_obj_clear_flag(cb->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
} else {
|
||||
if (min == 0 && max == 1) {
|
||||
cb->setGetValueHandler(GET_DEFAULT(md->multi.optionValue));
|
||||
cb->setSetValueHandler(SET_DEFAULT(md->multi.optionValue));
|
||||
lv_obj_clear_flag(cb->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
} else {
|
||||
edit->setMin(-128);
|
||||
edit->setMax(127);
|
||||
edit->setGetValueHandler(GET_DEFAULT(md->multi.optionValue));
|
||||
edit->setSetValueHandler(SET_DEFAULT(md->multi.optionValue));
|
||||
lv_obj_clear_flag(edit->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
lv_obj_clear_flag(rssi->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct MPMSubtype : public FormGroup::Line
|
||||
{
|
||||
Choice* choice;
|
||||
|
||||
MPMSubtype(FormGroup* form, FlexGridLayout *layout, uint8_t moduleIdx);
|
||||
void update(const MultiRfProtocols::RfProto* rfProto, ModuleData* md);
|
||||
};
|
||||
|
||||
MPMSubtype::MPMSubtype(FormGroup* form, FlexGridLayout *layout, uint8_t moduleIdx) :
|
||||
FormGroup::Line(form, layout)
|
||||
{
|
||||
if (layout) layout->resetPos();
|
||||
new StaticText(this, rect_t{}, STR_RF_PROTOCOL, 0, COLOR_THEME_PRIMARY1);
|
||||
|
||||
auto md = &g_model.moduleData[moduleIdx];
|
||||
choice = new Choice(
|
||||
this, rect_t{}, 0, 0, [=]() { return md->subType; },
|
||||
[=](int16_t newValue) {
|
||||
md->subType = newValue;
|
||||
resetMultiProtocolsOptions(moduleIdx);
|
||||
SET_DIRTY();
|
||||
});
|
||||
}
|
||||
|
||||
void MPMSubtype::update(const MultiRfProtocols::RfProto* rfProto, ModuleData* md)
|
||||
{
|
||||
if (!rfProto) {
|
||||
lv_obj_add_flag(lvobj, LV_OBJ_FLAG_HIDDEN);
|
||||
return;
|
||||
}
|
||||
|
||||
choice->setValues(rfProto->subProtos);
|
||||
choice->setMax(rfProto->subProtos.size() - 1);
|
||||
|
||||
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_HIDDEN);
|
||||
lv_event_send(choice->getLvObj(), LV_EVENT_VALUE_CHANGED, nullptr);
|
||||
}
|
||||
|
||||
struct MPMServoRate : public FormGroup::Line {
|
||||
MPMServoRate(FormGroup* form, FlexGridLayout* layout, uint8_t moduleIdx);
|
||||
};
|
||||
|
||||
static const char* _servoRates[] = {"22ms", "11ms"};
|
||||
|
||||
MPMServoRate::MPMServoRate(FormGroup* form, FlexGridLayout *layout, uint8_t moduleIdx) :
|
||||
FormGroup::Line(form, layout)
|
||||
{
|
||||
if (layout) layout->resetPos();
|
||||
new StaticText(this, rect_t{}, STR_MULTI_SERVOFREQ, 0, COLOR_THEME_PRIMARY1);
|
||||
|
||||
auto md = &g_model.moduleData[moduleIdx];
|
||||
new Choice(
|
||||
this, rect_t{}, _servoRates, 0, 1,
|
||||
[=]() { return (md->multi.optionValue & 0x02) >> 1; },
|
||||
[=](int16_t newValue) {
|
||||
md->multi.optionValue =
|
||||
(md->multi.optionValue & 0xFD) + (newValue << 1);
|
||||
});
|
||||
}
|
||||
|
||||
struct MPMAutobind : public FormGroup::Line {
|
||||
MPMAutobind(FormGroup* form, FlexGridLayout* layout, uint8_t moduleIdx);
|
||||
};
|
||||
|
||||
MPMAutobind::MPMAutobind(FormGroup* form, FlexGridLayout *layout, uint8_t moduleIdx) :
|
||||
FormGroup::Line(form, layout)
|
||||
{
|
||||
if (layout) layout->resetPos();
|
||||
new StaticText(this, rect_t{}, STR_MULTI_AUTOBIND, 0, COLOR_THEME_PRIMARY1);
|
||||
|
||||
auto md = &g_model.moduleData[moduleIdx];
|
||||
new CheckBox(this, rect_t{}, GET_SET_DEFAULT(md->multi.autoBindMode));
|
||||
}
|
||||
|
||||
struct MPMChannelMap : public FormGroup::Line
|
||||
{
|
||||
MPMChannelMap(FormGroup* form, FlexGridLayout *layout, uint8_t moduleIdx);
|
||||
void update(const MultiRfProtocols::RfProto* rfProto);
|
||||
};
|
||||
|
||||
MPMChannelMap::MPMChannelMap(FormGroup* form, FlexGridLayout *layout, uint8_t moduleIdx) :
|
||||
FormGroup::Line(form, layout)
|
||||
{
|
||||
if (layout) layout->resetPos();
|
||||
new StaticText(this, rect_t{}, STR_DISABLE_CH_MAP, 0, COLOR_THEME_PRIMARY1);
|
||||
|
||||
auto md = &g_model.moduleData[moduleIdx];
|
||||
new CheckBox(this, rect_t{}, GET_SET_DEFAULT(md->multi.disableMapping));
|
||||
}
|
||||
|
||||
void MPMChannelMap::update(const MultiRfProtocols::RfProto* rfProto)
|
||||
{
|
||||
if (rfProto && rfProto->supportsDisableMapping()) {
|
||||
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_HIDDEN);
|
||||
} else {
|
||||
lv_obj_add_flag(lvobj, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
}
|
||||
|
||||
MultimoduleSettings::MultimoduleSettings(Window *parent,
|
||||
const FlexGridLayout &g,
|
||||
uint8_t moduleIdx) :
|
||||
FormGroup(parent, rect_t{}), md(&g_model.moduleData[moduleIdx]),
|
||||
moduleIdx(moduleIdx)
|
||||
{
|
||||
FlexGridLayout grid(g);
|
||||
setFlexLayout();
|
||||
|
||||
// TODO: needs to be placed differently
|
||||
// MultiModuleStatus &status = getMultiModuleStatus(moduleIdx);
|
||||
// if (status.protocolName[0] && status.isValid()) {
|
||||
// new StaticText(this, grid.getFieldSlot(2, 1), status.protocolName, 0,
|
||||
// COLOR_THEME_PRIMARY1);
|
||||
// grid.nextLine();
|
||||
// }
|
||||
|
||||
// Multimodule status
|
||||
auto line = newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_MODULE_STATUS, 0, COLOR_THEME_PRIMARY1);
|
||||
new DynamicText(
|
||||
line, rect_t{},
|
||||
[=] {
|
||||
char msg[64] = "";
|
||||
getModuleStatusString(moduleIdx, msg);
|
||||
return std::string(msg);
|
||||
},
|
||||
COLOR_THEME_PRIMARY1);
|
||||
|
||||
st_line = new MPMSubtype(this, &grid, moduleIdx);
|
||||
// TODO: set event cb on st_line->choice / LV_EVENT_VALUE_CHANGED ?
|
||||
|
||||
opt_line = new MPMProtoOption(this, &grid);
|
||||
sr_line = new MPMServoRate(this, &grid, moduleIdx);
|
||||
ab_line = new MPMAutobind(this, &grid, moduleIdx);
|
||||
|
||||
// Low power mode
|
||||
line = newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_MULTI_LOWPOWER, 0, COLOR_THEME_PRIMARY1);
|
||||
new CheckBox(line, rect_t{}, GET_SET_DEFAULT(md->multi.lowPowerMode));
|
||||
|
||||
// Disable telemetry
|
||||
line = newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_DISABLE_TELEM, 0, COLOR_THEME_PRIMARY1);
|
||||
new CheckBox(line, rect_t{}, GET_SET_DEFAULT(md->multi.disableTelemetry));
|
||||
|
||||
cm_line = new MPMChannelMap(this, &grid, moduleIdx);
|
||||
}
|
||||
|
||||
void MultimoduleSettings::update()
|
||||
{
|
||||
auto mpm_rfprotos = MultiRfProtocols::instance(moduleIdx);
|
||||
auto rfProto = mpm_rfprotos->getProto(md->multi.rfProtocol);
|
||||
|
||||
st_line->update(rfProto, md);
|
||||
opt_line->update(rfProto, md);
|
||||
|
||||
auto multi_proto = md->multi.rfProtocol;
|
||||
if (multi_proto == MODULE_SUBTYPE_MULTI_DSM2) {
|
||||
lv_obj_clear_flag(sr_line->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
lv_obj_add_flag(ab_line->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
} else {
|
||||
lv_obj_add_flag(sr_line->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
lv_obj_clear_flag(ab_line->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
|
||||
cm_line->update(rfProto);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "form.h"
|
||||
#include "module_setup.h"
|
||||
|
||||
struct ModuleData;
|
||||
struct MPMProtoOption;
|
||||
struct MPMSubtype;
|
||||
struct MPMServoRate;
|
||||
struct MPMAutobind;
|
||||
struct MPMChannelMap;
|
||||
|
||||
class MultimoduleSettings : public FormGroup, public ModuleOptions
|
||||
{
|
||||
ModuleData* md;
|
||||
uint8_t moduleIdx;
|
||||
|
||||
MPMSubtype* st_line;
|
||||
MPMProtoOption* opt_line;
|
||||
MPMServoRate* sr_line;
|
||||
MPMAutobind* ab_line;
|
||||
MPMChannelMap* cm_line;
|
||||
|
||||
void update() override;
|
||||
|
||||
public:
|
||||
MultimoduleSettings(Window* parent, const FlexGridLayout& g, uint8_t moduleIdx);
|
||||
};
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ppm_settings.h"
|
||||
#include "opentx.h"
|
||||
|
||||
#define SET_DIRTY() storageDirty(EE_MODEL)
|
||||
|
||||
template <typename T>
|
||||
PpmFrameSettings<T>::PpmFrameSettings(Window* parent, const FlexGridLayout& g, T* ppm) :
|
||||
FormGroup(parent, rect_t{})
|
||||
{
|
||||
setFlexLayout(LV_FLEX_FLOW_ROW);
|
||||
|
||||
// PPM frame length
|
||||
auto edit = new NumberEdit(
|
||||
this, rect_t{}, 125, 35 * PPM_STEP_SIZE + PPM_DEF_PERIOD,
|
||||
GET_DEFAULT(ppm->frameLength * PPM_STEP_SIZE + PPM_DEF_PERIOD),
|
||||
SET_VALUE(ppm->frameLength, (newValue - PPM_DEF_PERIOD) / PPM_STEP_SIZE),
|
||||
0, PREC1);
|
||||
edit->setStep(PPM_STEP_SIZE);
|
||||
edit->setSuffix(STR_MS);
|
||||
|
||||
// PPM frame delay
|
||||
edit = new NumberEdit(this, rect_t{}, 100, 800,
|
||||
GET_DEFAULT(ppm->delay * 50 + 300),
|
||||
SET_VALUE(ppm->delay, (newValue - 300) / 50));
|
||||
edit->setStep(50);
|
||||
edit->setSuffix(STR_US);
|
||||
|
||||
// PPM Polarity
|
||||
new Choice(this, rect_t{}, STR_PPM_POL, 0, 1, GET_SET_DEFAULT(ppm->pulsePol));
|
||||
}
|
||||
|
||||
// explicit instantiation
|
||||
template struct PpmFrameSettings<TrainerModuleData>;
|
||||
|
||||
PpmSettings::PpmSettings(Window* parent, const FlexGridLayout& g, uint8_t moduleIdx) :
|
||||
FormGroup(parent, rect_t{}), md(&g_model.moduleData[moduleIdx])
|
||||
{
|
||||
FlexGridLayout grid(g);
|
||||
setFlexLayout();
|
||||
|
||||
// PPM frame
|
||||
auto line = newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_PPMFRAME, 0, COLOR_THEME_PRIMARY1);
|
||||
new PpmFrameSettings<PpmModule>(line, grid, &md->ppm);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "form.h"
|
||||
|
||||
struct ModuleData;
|
||||
|
||||
class PpmSettings : public FormGroup
|
||||
{
|
||||
ModuleData* md;
|
||||
|
||||
public:
|
||||
PpmSettings(Window* parent, const FlexGridLayout& g, uint8_t moduleIdx);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct PpmFrameSettings : public FormGroup {
|
||||
PpmFrameSettings(Window* parent, const FlexGridLayout& g, T* ppm);
|
||||
};
|
||||
@@ -230,6 +230,7 @@ void TrainerModuleWindow::update()
|
||||
COLOR_THEME_PRIMARY1);
|
||||
|
||||
// PPM frame length
|
||||
// TODO: use PpmFrameSettings<TrainerModuleData>
|
||||
auto edit = new NumberEdit(
|
||||
this, grid.getFieldSlot(3, 0), 125, 35 * 5 + 225,
|
||||
GET_DEFAULT(g_model.trainerData.frameLength * 5 + 225),
|
||||
|
||||
Reference in New Issue
Block a user