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:
Risto
2022-07-22 11:00:20 +10:00
committed by GitHub
co-authored by elecpower Peter Feerick
parent 54aaf5b9d9
commit 2ee75033bb
10 changed files with 167 additions and 9 deletions
+1
View File
@@ -77,6 +77,7 @@ set(GUI_SRC
radio_trainer.cpp
radio_version.cpp
hw_intmodule.cpp
hw_extmodule.cpp
hw_inputs.cpp
hw_serial.cpp
radio_hardware.cpp
+56
View File
@@ -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);
}
+37
View File
@@ -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);
};
+9 -2
View File
@@ -28,6 +28,7 @@
#include "hal/adc_driver.h"
#include "aux_serial_driver.h"
#include "hw_intmodule.h"
#include "hw_extmodule.h"
#include "hw_serial.h"
#include "hw_inputs.h"
@@ -121,8 +122,14 @@ void RadioHardwarePage::build(FormWindow * window)
#if defined(HARDWARE_INTERNAL_MODULE)
new Subtitle(window, rect_t{}, TR_INTERNALRF, 0, COLOR_THEME_PRIMARY1);
auto mod = new InternalModuleWindow(window);
mod->padLeft(lv_dpx(8));
auto intMod = new InternalModuleWindow(window);
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
#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_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);
#if defined(PCBX12S)