feat(EL18): Add AFHDS3 receiver options (#2470)
* Get config after switching model ID * Remember set model ID and change it on the fly * Add AFHDS3 options * Fix compiler warning * Fix box sizing * Apply model config before editing options
This commit is contained in:
@@ -140,6 +140,9 @@ endif()
|
||||
|
||||
if(AFHDS2 OR AFHDS3)
|
||||
add_gui_src(flysky_settings.cpp)
|
||||
if(AFHDS3)
|
||||
add_gui_src(afhds3_options.cpp)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(MULTIMODULE)
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* 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 "afhds3_options.h"
|
||||
#include "opentx.h"
|
||||
|
||||
//#include "checkbox.h"
|
||||
|
||||
static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1),
|
||||
LV_GRID_TEMPLATE_LAST};
|
||||
static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT,
|
||||
LV_GRID_TEMPLATE_LAST};
|
||||
|
||||
#define SET_DIRTY()
|
||||
|
||||
static const char* _analog_outputs[] = { "PWM", "PPM" };
|
||||
static const char* _bus_types[] = { "iBUS", "iBUS2", "SBUS" };
|
||||
static const char* _v1_bus_types[] = { "PWM", "PPM", "SBUS", "iBUS IN", "iBUS OUT" };
|
||||
|
||||
AFHDS3_Options::AFHDS3_Options(uint8_t moduleIdx) : Page(ICON_MODEL_SETUP)
|
||||
{
|
||||
cfg = afhds3::getConfig(moduleIdx);
|
||||
|
||||
std::string title =
|
||||
moduleIdx == INTERNAL_MODULE ? STR_INTERNALRF : STR_EXTERNALRF;
|
||||
title += "\nAFHDS3";
|
||||
|
||||
header.setTitle(title);
|
||||
|
||||
auto form = new FormGroup(&body, rect_t{});
|
||||
form->setFlexLayout();
|
||||
form->padAll(lv_dpx(8));
|
||||
|
||||
FlexGridLayout grid(col_dsc, row_dsc, 2);
|
||||
|
||||
if (cfg->version == 0) {
|
||||
auto vCfg = &cfg->v0;
|
||||
|
||||
auto line = form->newLine(&grid);
|
||||
new StaticText(line, rect_t{}, "PWM frequency");
|
||||
new NumberEdit(line, rect_t{}, 50, 400, GET_SET_DEFAULT(vCfg->PWMFrequency.Frequency));
|
||||
|
||||
line = form->newLine(&grid);
|
||||
new StaticText(line, rect_t{}, "PWM sychronized");
|
||||
new CheckBox(line, rect_t{}, GET_SET_DEFAULT(vCfg->PWMFrequency.Synchronized));
|
||||
|
||||
line = form->newLine(&grid);
|
||||
new StaticText(line, rect_t{}, "Analog output");
|
||||
new Choice(line, rect_t{}, _analog_outputs,
|
||||
afhds3::SES_ANALOG_OUTPUT_PWM, afhds3::SES_ANALOG_OUTPUT_PPM,
|
||||
GET_SET_DEFAULT(vCfg->AnalogOutput));
|
||||
|
||||
line = form->newLine(&grid);
|
||||
new StaticText(line, rect_t{}, "External bus type");
|
||||
new Choice(line, rect_t{}, _bus_types,
|
||||
afhds3::EB_BT_IBUS1, afhds3::EB_BT_SBUS1,
|
||||
GET_SET_DEFAULT(vCfg->ExternalBusType));
|
||||
|
||||
} else {
|
||||
auto vCfg = &cfg->v1;
|
||||
|
||||
auto line = form->newLine(&grid);
|
||||
new StaticText(line, rect_t{}, "PWM frequency");
|
||||
new NumberEdit(line, rect_t{}, 50, 400,
|
||||
GET_DEFAULT(vCfg->PWMFrequenciesV1.PWMFrequencies[0]),
|
||||
[=](int16_t newVal) {
|
||||
for (uint8_t i = 0; i < SES_NB_MAX_CHANNELS; i++) {
|
||||
vCfg->PWMFrequenciesV1.PWMFrequencies[i] = newVal;
|
||||
}
|
||||
});
|
||||
|
||||
line = form->newLine(&grid);
|
||||
new StaticText(line, rect_t{}, "PWM sychronized");
|
||||
new CheckBox(
|
||||
line, rect_t{}, GET_DEFAULT(vCfg->PWMFrequenciesV1.Synchronized),
|
||||
[=](uint8_t newVal) {
|
||||
vCfg->PWMFrequenciesV1.Synchronized = newVal ? 0xFFFFFFFF : 0;
|
||||
});
|
||||
|
||||
for (uint8_t i = 0; i < SES_NPT_NB_MAX_PORTS; i++) {
|
||||
line = form->newLine(&grid);
|
||||
|
||||
std::string portName = "NP";
|
||||
portName += 'A' + i;
|
||||
|
||||
new StaticText(line, rect_t{}, portName.c_str());
|
||||
new Choice(line, rect_t{}, _v1_bus_types, afhds3::SES_NPT_PWM,
|
||||
afhds3::SES_NPT_IBUS1_OUT,
|
||||
GET_SET_DEFAULT(vCfg->NewPortTypes[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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 "page.h"
|
||||
#include "pulses/afhds3_config.h"
|
||||
|
||||
class AFHDS3_Options : public Page
|
||||
{
|
||||
afhds3::Config_u* cfg;
|
||||
|
||||
public:
|
||||
AFHDS3_Options(uint8_t moduleIdx);
|
||||
};
|
||||
@@ -22,6 +22,10 @@
|
||||
#include "flysky_settings.h"
|
||||
#include "opentx.h"
|
||||
|
||||
#if defined(AFHDS3)
|
||||
#include "afhds3_options.h"
|
||||
#endif
|
||||
|
||||
#include "pulses/flysky.h"
|
||||
#include "pulses/afhds3.h"
|
||||
|
||||
@@ -132,50 +136,23 @@ void FlySkySettings::update()
|
||||
new StaticText(line, rect_t{}, STR_TYPE, 0, COLOR_THEME_PRIMARY1);
|
||||
|
||||
auto box = new FormGroup(line, rect_t{});
|
||||
box->setFlexLayout(LV_FLEX_FLOW_ROW);
|
||||
|
||||
new Choice(box, rect_t{}, _afhds3_region, 1, afhds3::LNK_ES_FCC,
|
||||
GET_SET_DEFAULT(md->afhds3.emi));
|
||||
box->setFlexLayout(LV_FLEX_FLOW_ROW_WRAP);
|
||||
lv_obj_set_style_grid_cell_x_align(box->getLvObj(), LV_GRID_ALIGN_STRETCH, 0);
|
||||
|
||||
new Choice(box, rect_t{}, _afhds3_phy_mode, 0, afhds3::PHYMODE_MAX,
|
||||
GET_SET_DEFAULT(md->afhds3.phyMode));
|
||||
|
||||
// // 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);
|
||||
// });
|
||||
new Choice(box, rect_t{}, _afhds3_region,
|
||||
afhds3::LNK_ES_CE, afhds3::LNK_ES_FCC,
|
||||
GET_SET_DEFAULT(md->afhds3.emi));
|
||||
|
||||
// // 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{}, AFHDS3_MIN_FREQ, AFHDS3_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));
|
||||
uint8_t module = moduleIdx;
|
||||
new TextButton(box, rect_t{}, STR_MODULE_OPTIONS,
|
||||
[=]() {
|
||||
afhds3::applyModelConfig(module);
|
||||
new AFHDS3_Options(module);
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user