feat(color): Add OneBit option to color radios (and Companion!!) (#1994)
* Added OneBit option also to color radios * Try to work around GH repo owner issue Original by @raphaelcoeffic in https://github.com/EdgeTX/edgetx/commit/bf4b5d8c0c1e386d5a4852a80d459540bab98ed3 * Add Companion support for radios with external module * Companion housekeeping - do not display unnecessary hardware section headings * fix: Rebase cleanup * fix: LVGL changes * feat: Move sample mode to a new Ext RF block Co-authored-by: elecpower <neilh713@tpg.com.au> Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
co-authored by
elecpower
Peter Feerick
parent
54aaf5b9d9
commit
2ee75033bb
@@ -497,6 +497,9 @@ int Boards::getCapability(Board::Type board, Board::Capability capability)
|
|||||||
case HasInternalModuleSupport:
|
case HasInternalModuleSupport:
|
||||||
return (IS_STM32(board) && !IS_TARANIS_X9(board));
|
return (IS_STM32(board) && !IS_TARANIS_X9(board));
|
||||||
|
|
||||||
|
case HasExternalModuleSupport:
|
||||||
|
return (IS_STM32(board) && !IS_RADIOMASTER_T8(board));
|
||||||
|
|
||||||
case SportMaxBaudRate:
|
case SportMaxBaudRate:
|
||||||
if (IS_FAMILY_T16(board) || IS_FLYSKY_NV14(board) || IS_TARANIS_X7_ACCESS(board) ||
|
if (IS_FAMILY_T16(board) || IS_FLYSKY_NV14(board) || IS_TARANIS_X7_ACCESS(board) ||
|
||||||
(IS_TARANIS(board) && !IS_TARANIS_XLITE(board) && !IS_TARANIS_X7(board) && !IS_TARANIS_X9LITE(board)))
|
(IS_TARANIS(board) && !IS_TARANIS_XLITE(board) && !IS_TARANIS_X7(board) && !IS_TARANIS_X9LITE(board)))
|
||||||
|
|||||||
@@ -150,6 +150,7 @@ namespace Board {
|
|||||||
HasColorLcd,
|
HasColorLcd,
|
||||||
HasSDCard,
|
HasSDCard,
|
||||||
HasInternalModuleSupport,
|
HasInternalModuleSupport,
|
||||||
|
HasExternalModuleSupport,
|
||||||
SportMaxBaudRate
|
SportMaxBaudRate
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -606,6 +606,38 @@ AbstractStaticItemModel * GeneralSettings::stickDeadZoneItemModel()
|
|||||||
return mdl;
|
return mdl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString GeneralSettings::uartSampleModeToString() const
|
||||||
|
{
|
||||||
|
return uartSampleModeToString(uartSampleMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
QString GeneralSettings::uartSampleModeToString(int value)
|
||||||
|
{
|
||||||
|
switch(value) {
|
||||||
|
case UART_SAMPLE_MODE_NORMAL:
|
||||||
|
return tr("Normal");
|
||||||
|
case UART_SAMPLE_MODE_ONEBIT:
|
||||||
|
return tr("OneBit");
|
||||||
|
default:
|
||||||
|
return CPN_STR_UNKNOWN_ITEM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
AbstractStaticItemModel * GeneralSettings::uartSampleModeItemModel()
|
||||||
|
{
|
||||||
|
AbstractStaticItemModel * mdl = new AbstractStaticItemModel();
|
||||||
|
mdl->setName(AIM_GS_UARTSAMPLEMODE);
|
||||||
|
|
||||||
|
for (int i = 0; i < UART_SAMPLE_MODE_COUNT; i++) {
|
||||||
|
mdl->appendToItemList(uartSampleModeToString(i), i);
|
||||||
|
}
|
||||||
|
|
||||||
|
mdl->loadItemList();
|
||||||
|
return mdl;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TrainerMix
|
TrainerMix
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ constexpr char AIM_GS_BLUETOOTHMODE[] {"gs.bluetoothmode"};
|
|||||||
constexpr char AIM_GS_SERIALMODE[] {"gs.serialmode%1"};
|
constexpr char AIM_GS_SERIALMODE[] {"gs.serialmode%1"};
|
||||||
constexpr char AIM_GS_INTMODULEBAUDRATE[] {"gs.intmodulebaudrate"};
|
constexpr char AIM_GS_INTMODULEBAUDRATE[] {"gs.intmodulebaudrate"};
|
||||||
constexpr char AIM_GS_STICKDEADZONE[] {"gs.stickdeadzone"};
|
constexpr char AIM_GS_STICKDEADZONE[] {"gs.stickdeadzone"};
|
||||||
|
constexpr char AIM_GS_UARTSAMPLEMODE[] {"gs.uartsamplemode"};
|
||||||
constexpr char AIM_TRAINERMIX_MODE[] {"trainermix.mode"};
|
constexpr char AIM_TRAINERMIX_MODE[] {"trainermix.mode"};
|
||||||
constexpr char AIM_TRAINERMIX_SRC[] {"trainermix.src"};
|
constexpr char AIM_TRAINERMIX_SRC[] {"trainermix.src"};
|
||||||
|
|
||||||
@@ -153,6 +154,12 @@ class GeneralSettings {
|
|||||||
SP_COUNT,
|
SP_COUNT,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum UartSampleMode {
|
||||||
|
UART_SAMPLE_MODE_NORMAL,
|
||||||
|
UART_SAMPLE_MODE_ONEBIT,
|
||||||
|
UART_SAMPLE_MODE_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
GeneralSettings() { clear(); }
|
GeneralSettings() { clear(); }
|
||||||
void clear();
|
void clear();
|
||||||
void init();
|
void init();
|
||||||
@@ -274,6 +281,7 @@ class GeneralSettings {
|
|||||||
QString bluetoothModeToString() const;
|
QString bluetoothModeToString() const;
|
||||||
QString serialPortModeToString(int port_nr) const;
|
QString serialPortModeToString(int port_nr) const;
|
||||||
QString internalModuleBaudrateToString() const;
|
QString internalModuleBaudrateToString() const;
|
||||||
|
QString uartSampleModeToString() const;
|
||||||
|
|
||||||
static QString antennaModeToString(int value);
|
static QString antennaModeToString(int value);
|
||||||
static QString bluetoothModeToString(int value);
|
static QString bluetoothModeToString(int value);
|
||||||
@@ -281,9 +289,12 @@ class GeneralSettings {
|
|||||||
static QString moduleBaudrateToString(int value);
|
static QString moduleBaudrateToString(int value);
|
||||||
static FieldRange getPPM_MultiplierRange();
|
static FieldRange getPPM_MultiplierRange();
|
||||||
static FieldRange getTxCurrentCalibration();
|
static FieldRange getTxCurrentCalibration();
|
||||||
|
static QString uartSampleModeToString(int value);
|
||||||
|
|
||||||
static AbstractStaticItemModel * antennaModeItemModel();
|
static AbstractStaticItemModel * antennaModeItemModel();
|
||||||
static AbstractStaticItemModel * bluetoothModeItemModel();
|
static AbstractStaticItemModel * bluetoothModeItemModel();
|
||||||
static AbstractStaticItemModel * serialModeItemModel(int port_nr);
|
static AbstractStaticItemModel * serialModeItemModel(int port_nr);
|
||||||
static AbstractStaticItemModel * internalModuleBaudrateItemModel();
|
static AbstractStaticItemModel * internalModuleBaudrateItemModel();
|
||||||
static AbstractStaticItemModel * stickDeadZoneItemModel();
|
static AbstractStaticItemModel * stickDeadZoneItemModel();
|
||||||
|
static AbstractStaticItemModel * uartSampleModeItemModel();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ HardwarePanel::HardwarePanel(QWidget * parent, GeneralSettings & generalSettings
|
|||||||
int auxmodelid = editorItemModels->registerItemModel(GeneralSettings::serialModeItemModel(GeneralSettings::SP_AUX1));
|
int auxmodelid = editorItemModels->registerItemModel(GeneralSettings::serialModeItemModel(GeneralSettings::SP_AUX1));
|
||||||
int vcpmodelid = editorItemModels->registerItemModel(GeneralSettings::serialModeItemModel(GeneralSettings::SP_VCP));
|
int vcpmodelid = editorItemModels->registerItemModel(GeneralSettings::serialModeItemModel(GeneralSettings::SP_VCP));
|
||||||
int baudmodelid = editorItemModels->registerItemModel(GeneralSettings::internalModuleBaudrateItemModel());
|
int baudmodelid = editorItemModels->registerItemModel(GeneralSettings::internalModuleBaudrateItemModel());
|
||||||
|
int uartmodelid = editorItemModels->registerItemModel(GeneralSettings::uartSampleModeItemModel());
|
||||||
|
|
||||||
id = editorItemModels->registerItemModel(ModuleData::internalModuleItemModel());
|
id = editorItemModels->registerItemModel(ModuleData::internalModuleItemModel());
|
||||||
tabFilteredModels->registerItemModel(new FilteredItemModel(editorItemModels->getItemModel(id)), FIM_INTERNALMODULES);
|
tabFilteredModels->registerItemModel(new FilteredItemModel(editorItemModels->getItemModel(id)), FIM_INTERNALMODULES);
|
||||||
@@ -123,29 +124,26 @@ HardwarePanel::HardwarePanel(QWidget * parent, GeneralSettings & generalSettings
|
|||||||
addParams(row, spnStickDeadZone);
|
addParams(row, spnStickDeadZone);
|
||||||
}
|
}
|
||||||
|
|
||||||
addSection(tr("Pots"), row);
|
|
||||||
|
|
||||||
count = Boards::getCapability(board, Board::Pots);
|
count = Boards::getCapability(board, Board::Pots);
|
||||||
count -= firmware->getCapability(HasFlySkyGimbals) ? 2 : 0;
|
count -= firmware->getCapability(HasFlySkyGimbals) ? 2 : 0;
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
|
addSection(tr("Pots"), row);
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
addPot(i, row);
|
addPot(i, row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addSection(tr("Sliders"), row);
|
|
||||||
|
|
||||||
count = Boards::getCapability(board, Board::Sliders);
|
count = Boards::getCapability(board, Board::Sliders);
|
||||||
if (count) {
|
if (count) {
|
||||||
|
addSection(tr("Sliders"), row);
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
addSlider(i, row);
|
addSlider(i, row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addSection(tr("Switches"), row);
|
|
||||||
|
|
||||||
count = Boards::getCapability(board, Board::Switches);
|
count = Boards::getCapability(board, Board::Switches);
|
||||||
if (count) {
|
if (count) {
|
||||||
|
addSection(tr("Switches"), row);
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
addSwitch(i, row);
|
addSwitch(i, row);
|
||||||
}
|
}
|
||||||
@@ -216,11 +214,20 @@ HardwarePanel::HardwarePanel(QWidget * parent, GeneralSettings & generalSettings
|
|||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Boards::getCapability(board, Board::HasExternalModuleSupport)) {
|
||||||
|
addLabel(tr("Sample Mode"), row, 0);
|
||||||
|
AutoComboBox *uartSampleMode = new AutoComboBox(this);
|
||||||
|
uartSampleMode->setModel(editorItemModels->getItemModel(uartmodelid));
|
||||||
|
uartSampleMode->setField(generalSettings.uartSampleMode);
|
||||||
|
addParams(row, uartSampleMode);
|
||||||
|
}
|
||||||
|
|
||||||
// All values except 0 are mutually exclusive
|
// All values except 0 are mutually exclusive
|
||||||
ExclusiveComboGroup *exclGroup = new ExclusiveComboGroup(
|
ExclusiveComboGroup *exclGroup = new ExclusiveComboGroup(
|
||||||
this, [=](const QVariant &value) { return value == 0; });
|
this, [=](const QVariant &value) { return value == 0; });
|
||||||
|
|
||||||
addSection(tr("Serial port"), row);
|
if (firmware->getCapability(HasAuxSerialMode) || firmware->getCapability(HasAux2SerialMode) || firmware->getCapability(HasVCPSerialMode))
|
||||||
|
addSection(tr("Serial ports"), row);
|
||||||
|
|
||||||
if (firmware->getCapability(HasAuxSerialMode)) {
|
if (firmware->getCapability(HasAuxSerialMode)) {
|
||||||
QString lbl = "AUX1";
|
QString lbl = "AUX1";
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ set(GUI_SRC
|
|||||||
radio_trainer.cpp
|
radio_trainer.cpp
|
||||||
radio_version.cpp
|
radio_version.cpp
|
||||||
hw_intmodule.cpp
|
hw_intmodule.cpp
|
||||||
|
hw_extmodule.cpp
|
||||||
hw_inputs.cpp
|
hw_inputs.cpp
|
||||||
hw_serial.cpp
|
hw_serial.cpp
|
||||||
radio_hardware.cpp
|
radio_hardware.cpp
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* 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 "hw_extmodule.h"
|
||||||
|
|
||||||
|
#include "opentx.h"
|
||||||
|
|
||||||
|
#define SET_DIRTY() storageDirty(EE_GENERAL)
|
||||||
|
|
||||||
|
static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(3),
|
||||||
|
LV_GRID_TEMPLATE_LAST};
|
||||||
|
|
||||||
|
static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST};
|
||||||
|
|
||||||
|
ExternalModuleWindow::ExternalModuleWindow(Window *parent) :
|
||||||
|
FormGroup::Line(parent), lastModule(g_eeGeneral.internalModule)
|
||||||
|
{
|
||||||
|
FlexGridLayout grid(col_dsc, row_dsc, 2);
|
||||||
|
setLayout(&grid);
|
||||||
|
|
||||||
|
new StaticText(this, rect_t{}, STR_SAMPLE_MODE, 0, COLOR_THEME_PRIMARY1);
|
||||||
|
|
||||||
|
auto box = new FormGroup(this, rect_t{});
|
||||||
|
box->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8));
|
||||||
|
lv_obj_set_style_grid_cell_x_align(box->getLvObj(), LV_GRID_ALIGN_STRETCH, 0);
|
||||||
|
|
||||||
|
new Choice(box, rect_t{}, STR_SAMPLE_MODES, 0, UART_SAMPLE_MODE_MAX,
|
||||||
|
getSampleMode, setSampleMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ExternalModuleWindow::getSampleMode() { return g_eeGeneral.uartSampleMode; }
|
||||||
|
|
||||||
|
void ExternalModuleWindow::setSampleMode(int modeValue)
|
||||||
|
{
|
||||||
|
g_eeGeneral.uartSampleMode = modeValue;
|
||||||
|
SET_DIRTY();
|
||||||
|
restartModule(EXTERNAL_MODULE);
|
||||||
|
}
|
||||||
@@ -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"
|
||||||
|
|
||||||
|
class ExternalModuleWindow : public FormGroup::Line
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ExternalModuleWindow(Window* parent);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
uint8_t lastModule = 0;
|
||||||
|
lv_obj_t* br_box = nullptr;
|
||||||
|
|
||||||
|
static int getSampleMode();
|
||||||
|
static void setSampleMode(int modeValue);
|
||||||
|
};
|
||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "hal/adc_driver.h"
|
#include "hal/adc_driver.h"
|
||||||
#include "aux_serial_driver.h"
|
#include "aux_serial_driver.h"
|
||||||
#include "hw_intmodule.h"
|
#include "hw_intmodule.h"
|
||||||
|
#include "hw_extmodule.h"
|
||||||
#include "hw_serial.h"
|
#include "hw_serial.h"
|
||||||
#include "hw_inputs.h"
|
#include "hw_inputs.h"
|
||||||
|
|
||||||
@@ -121,8 +122,14 @@ void RadioHardwarePage::build(FormWindow * window)
|
|||||||
|
|
||||||
#if defined(HARDWARE_INTERNAL_MODULE)
|
#if defined(HARDWARE_INTERNAL_MODULE)
|
||||||
new Subtitle(window, rect_t{}, TR_INTERNALRF, 0, COLOR_THEME_PRIMARY1);
|
new Subtitle(window, rect_t{}, TR_INTERNALRF, 0, COLOR_THEME_PRIMARY1);
|
||||||
auto mod = new InternalModuleWindow(window);
|
auto intMod = new InternalModuleWindow(window);
|
||||||
mod->padLeft(lv_dpx(8));
|
intMod->padLeft(lv_dpx(8));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HARDWARE_EXTERNAL_MODULE)
|
||||||
|
new Subtitle(window, rect_t{}, TR_EXTERNALRF, 0, COLOR_THEME_PRIMARY1);
|
||||||
|
auto extMod = new ExternalModuleWindow(window);
|
||||||
|
extMod->padLeft(lv_dpx(8));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(BLUETOOTH)
|
#if defined(BLUETOOTH)
|
||||||
|
|||||||
@@ -91,6 +91,9 @@ void telemetryPortInit(uint32_t baudrate, uint8_t mode)
|
|||||||
}
|
}
|
||||||
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
||||||
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
|
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
|
||||||
|
if (g_eeGeneral.uartSampleMode == UART_SAMPLE_MODE_ONEBIT) {
|
||||||
|
USART_OneBitMethodCmd(TELEMETRY_USART, ENABLE);
|
||||||
|
}
|
||||||
USART_Init(TELEMETRY_USART, &USART_InitStructure);
|
USART_Init(TELEMETRY_USART, &USART_InitStructure);
|
||||||
|
|
||||||
#if defined(PCBX12S)
|
#if defined(PCBX12S)
|
||||||
|
|||||||
Reference in New Issue
Block a user