Skip to content

Commit

Permalink
finalize: Everything is usable up to minimum resolution (480p 16:9)
Browse files Browse the repository at this point in the history
  • Loading branch information
Consti10 committed Nov 14, 2023
1 parent 6ef7272 commit 92ecd98
Show file tree
Hide file tree
Showing 15 changed files with 122 additions and 99 deletions.
16 changes: 10 additions & 6 deletions app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,15 @@ static void android_check_permissions(){
#endif
}

static void write_screen_resolutions(QApplication& app){
const auto actual_size=QGuiApplication::primaryScreen()->size();
QRenderStats::instance().set_screen_width_height(actual_size.width(),actual_size.height());
// This includes dpi adjustment
QScreen* screen=app.primaryScreen();
if(screen){
QRenderStats::instance().set_display_width_height(screen->size().width(),screen->size().height());
}
}

int main(int argc, char *argv[]) {

Expand Down Expand Up @@ -238,12 +247,7 @@ int main(int argc, char *argv[]) {
QApplication app(argc, argv);
// Customize cursor if needed
QOpenHD::instance().customize_cursor_from_settings();
{
QScreen* screen=app.primaryScreen();
if(screen){
QRenderStats::instance().set_display_width_height(screen->size().width(),screen->size().height());
}
}
write_screen_resolutions(app);
QOpenHDVideoHelper::reset_qopenhd_switch_primary_secondary();

#if defined(__ios__)
Expand Down
14 changes: 11 additions & 3 deletions app/telemetry/settings/frequencyhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ FrequencyHelper &FrequencyHelper::instance()
return instance;
}

QList<int> FrequencyHelper::get_frequencies(bool openhd_bands_only)
QList<int> FrequencyHelper::get_frequencies(int filter)
{
QList<int> ret;
if(openhd_bands_only){
if(filter==0){
auto tmp=openhd::get_openhd_channels_1_to_5();
for(auto& channel:tmp){
ret.push_back(channel.frequency);
Expand All @@ -24,7 +24,15 @@ QList<int> FrequencyHelper::get_frequencies(bool openhd_bands_only)
const auto frequency_items=openhd::get_all_channels_2G_5G();
for(auto& item:frequency_items){
if(item.is_legal_at_least_one_country){
ret.push_back(item.frequency);
if(filter==1){
if(item.frequency<3000){
ret.push_back(item.frequency);
}
}else{
if(item.frequency>3000){
ret.push_back(item.frequency);
}
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/telemetry/settings/frequencyhelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class FrequencyHelper : public QObject
public:
explicit FrequencyHelper(QObject *parent = nullptr);
static FrequencyHelper &instance();

Q_INVOKABLE QList<int> get_frequencies(bool openhd_bands_only);
// Filter: 0 - OpenHD 1-5 only, 1= all 2.4G freq, 2 = all 5.8G freq
Q_INVOKABLE QList<int> get_frequencies(int filter);
Q_INVOKABLE QList<int> get_frequencies_all_40Mhz();

Q_INVOKABLE bool get_frequency_radar(int frequency_mhz);
Expand Down
8 changes: 4 additions & 4 deletions app/util/qrenderstats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ void QRenderStats::registerOnWindow(QQuickWindow *window)
connect(window, &QQuickWindow::afterRenderPassRecording, this, &QRenderStats::m_QQuickWindow_afterRenderPassRecording, Qt::DirectConnection);
}

void QRenderStats::set_display_width_height(int width, int height)
void QRenderStats::set_screen_width_height(int width, int height)
{
std::stringstream ss;
ss<<width<<"x"<<height;
set_display_width_height_str(ss.str().c_str());
set_screen_width_height_str(ss.str().c_str());
}

void QRenderStats::set_window_width_height(int width, int height)
void QRenderStats::set_display_width_height(int width, int height)
{
std::stringstream ss;
ss<<width<<"x"<<height;
set_window_width_height_str(ss.str().c_str());
set_display_width_height_str(ss.str().c_str());
}

void QRenderStats::m_QQuickWindow_beforeRendering()
Expand Down
7 changes: 5 additions & 2 deletions app/util/qrenderstats.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
class QRenderStats : public QObject
{
Q_OBJECT
public:
L_RO_PROP(QString, main_render_stats, set_main_render_stats, "NA")
// It can be quite nice for debugging to see what resolution QOpenHD's main window is rendered at
// Resolution of the screen / display itself
L_RO_PROP(QString, display_width_height_str, set_display_width_height_str, "NA")
L_RO_PROP(QString, screen_width_height_str, set_screen_width_height_str, "NA")
// Resolution qopenhd is rendering at
L_RO_PROP(QString, window_width_height_str, set_window_width_height_str, "NA")
L_RO_PROP(int, window_width, set_window_width, -1)
L_RO_PROP(int, window_height, set_window_height, -1)
// Time QT spent "rendering", probably aka creating the GPU command buffer
L_RO_PROP(QString, qt_rendering_time, set_qt_rendering_time, "NA")
// Time QT spent "recording the render pass"
Expand All @@ -32,8 +35,8 @@ class QRenderStats : public QObject
void register_to_root_window(QQmlApplicationEngine& engine);
// Manually regster the QML window
void registerOnWindow(QQuickWindow* window);
void set_screen_width_height(int width,int height);
void set_display_width_height(int width,int height);
void set_window_width_height(int width,int height);
public slots:
void m_QQuickWindow_beforeRendering();
void m_QQuickWindow_afterRendering();
Expand Down
7 changes: 7 additions & 0 deletions qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ ApplicationWindow {
width: (settings.general_screen_rotation == 90 || settings.general_screen_rotation == 270) ? m_window_height : m_window_width
height: (settings.general_screen_rotation == 90 || settings.general_screen_rotation == 270) ? m_window_width : m_window_height

onWidthChanged: {
//_qrenderstats.set_window_width(width)
}
onHeightChanged: {
//_qrenderstats.set_window_height(height)
}

contentOrientation: settings.general_screen_rotation===0 ? Qt.PortraitOrientation : Qt.LandscapeOrientation
contentItem.rotation: settings.general_screen_rotation

Expand Down
45 changes: 24 additions & 21 deletions qml/ui/configpopup/dev/AppDeveloperStatsPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,30 @@ Rectangle {
anchors.top: parent.top
anchors.left: parent.left
anchors.margins: 10

Text{
text: qsTr("QOpenHD version:" + _qopenhd.version_string)
Layout.leftMargin: 12
}
Text {
id: test5
text: qsTr("FEATURES: " + get_features_string())
Layout.leftMargin: 12
}
Text {
id: test6
text: qsTr("Screen resolution: " + _qrenderstats.screen_width_height_str+" ADJ:"+_qrenderstats.display_width_height_str)
Layout.leftMargin: 12
}
Text {
id: test7
text: qsTr("Window resolution: " + _qrenderstats.window_width+"x"+_qrenderstats.window_height)
Layout.leftMargin: 12
}
Text {
id: test8
text: qsTr("You're running on: " + Qt.platform.os)
Layout.leftMargin: 12
}
Text {
id: test1
text: qsTr("Art Horizon mavlink update rate:" + _fcMavlinkSystem.curr_update_rate_mavlink_message_attitude + " Hz")
Expand Down Expand Up @@ -85,26 +108,6 @@ Rectangle {
text: qsTr("video0 FEC decode: " + _cameraStreamModelPrimary.curr_fec_decode_time_avg_min_max)
Layout.leftMargin: 12
}
Text {
id: test5
text: qsTr("FEATURES: " + get_features_string())
Layout.leftMargin: 12
}
Text {
id: test6
text: qsTr("Screen resolution: " + _qrenderstats.display_width_height_str)
Layout.leftMargin: 12
}
Text {
id: test7
text: qsTr("Window resolution: " + _qrenderstats.window_width_height_str)
Layout.leftMargin: 12
}
Text {
id: test8
text: qsTr("You're running on: " + Qt.platform.os)
Layout.leftMargin: 12
}
Button {
height: 24
text: "Restart local OHD service"
Expand Down
57 changes: 33 additions & 24 deletions qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -45,38 +45,24 @@ Rectangle{
}

ListModel{
id: frequencies_model_all
ListElement {title: "Unknown"; value_frequency_mhz:-1}
}
ListModel{
id: frequencies_model_openhd_channels_only
id: frequencies_model
ListElement {title: "Unknown"; value_frequency_mhz:-1}
}

function create_list_models_frequency(){
frequencies_model_all.clear();
const frequencies_all=_frequencyHelper.get_frequencies(false);
frequencies_model.clear();
const filter = filter_tab_bar.currentIndex;
const frequencies_all=_frequencyHelper.get_frequencies(filter);
for(var i=0;i<frequencies_all.length;i++){
const frequency=frequencies_all[i];
const text=_frequencyHelper.get_frequency_description(frequency)
frequencies_model_all.append({title: text, value_frequency_mhz: frequency});
}
frequencies_model_openhd_channels_only.clear();
const frequencies_openhd=_frequencyHelper.get_frequencies(true);
for(var i=0;i<frequencies_openhd.length;i++){
const frequency=frequencies_openhd[i];
const text=_frequencyHelper.get_frequency_description(frequency)
frequencies_model_openhd_channels_only.append({title: text, value_frequency_mhz: frequency});
frequencies_model.append({title: text, value_frequency_mhz: frequency});
}
}

property bool m_simplify_enable:true
function update_frequency_combobox(){
if(m_simplify_enable){
comboBoxFreq.model=frequencies_model_openhd_channels_only;
}else{
comboBoxFreq.model=frequencies_model_all;
}
create_list_models_frequency();
comboBoxFreq.model=frequencies_model;
if(_wbLinkSettingsHelper.curr_channel_mhz>0){
var index=find_index(comboBoxFreq.model,_wbLinkSettingsHelper.curr_channel_mhz);
if(index>=0){
Expand Down Expand Up @@ -148,6 +134,7 @@ Rectangle{
//ScrollBar.vertical.policy: ScrollBar.AlwaysOn
ScrollBar.vertical.interactive: true
visible: (!popup_analyze_channels.visible && !popup_enable_stbc_ldpc.visible && !popup_change_tx_power.visible && !popup_scan_channels.visible)
clip: true

ColumnLayout{
width: main_scroll_view.width
Expand All @@ -167,8 +154,7 @@ Rectangle{
Layout.alignment: Qt.AlignCenter
Layout.preferredWidth: elementComboBoxWidth
id: comboBoxFreq
//model: supported_frequencies_model
//model: frequencies_model_openhd_channels_only
model: frequencies_model
textRole: "title"
implicitWidth: elementComboBoxWidth
currentIndex: 0
Expand Down Expand Up @@ -220,7 +206,7 @@ Rectangle{
}
enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0;
}
Switch{
/*Switch{
Layout.alignment: Qt.AlignCenter
text: "SIMPLIFY"
checked: true
Expand All @@ -230,6 +216,29 @@ Rectangle{
function_rebuild_ui();
}
}
}*/
TabBar{
id: filter_tab_bar
Layout.preferredWidth: 200
currentIndex: settings.qopenhd_frequency_filter_selection
onCurrentIndexChanged: {
if(currentIndex!=settings.qopenhd_frequency_filter_selection){
settings.qopenhd_frequency_filter_selection=currentIndex;
function_rebuild_ui();
if(currentIndex==1 || currentIndex==2){
_qopenhd.show_toast("Please watch out for wifi pollution");
}
}
}
TabButton{
text: "1-5"
}
TabButton{
text: "2.4G"
}
TabButton{
text: "5.8G"
}
}
Item{ // FILLER
Layout.fillWidth: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Rectangle{

property bool m_normalize_data: false;
property int m_chart_view_minimum_width: 1280;
property int m_chart_view_minimum_width2: 640;
property int m_chart_view_minimum_width2: 1280;

property bool m_chart_enlarged: false;

Expand Down
26 changes: 8 additions & 18 deletions qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Rectangle{
property bool m_is_air: false

property int m_user_selected_card_manufacturer: -1;
property int left_text_minimum_width: 100
property int left_text_preferred_width: 100

function open(){
if(_fcMavlinkSystem.is_alive && _fcMavlinkSystem.armed){
Expand Down Expand Up @@ -234,9 +236,6 @@ Rectangle{
//Layout.preferredWidth: 600

Item{
Layout.row: 0
Layout.column: 0
Layout.columnSpan: 4
Layout.fillWidth: true
Layout.preferredHeight: 80
Text{ // TITLE
Expand All @@ -259,8 +258,8 @@ Rectangle{
RowLayout{
Layout.fillWidth: true
Text{
Layout.minimumWidth: 100
Layout.preferredWidth: 250
Layout.minimumWidth: left_text_minimum_width
Layout.preferredWidth: left_text_preferred_width
text: "RF CHIP:\n" +get_card_chipset_str()
horizontalAlignment: Qt.AlignHCenter
font.pixelSize: 14
Expand All @@ -279,16 +278,14 @@ Rectangle{
}
// FILLER
Item{
Layout.row: 1
Layout.column: 3
Layout.fillWidth: true
}
}
RowLayout{
Layout.fillWidth: true
Text{
Layout.minimumWidth: 100
Layout.preferredWidth: 250
Layout.minimumWidth: left_text_minimum_width
Layout.preferredWidth: left_text_preferred_width
text: "DISARMED:\n"+get_current_tx_power_int(1)+" "+get_tx_power_unit();
horizontalAlignment: Qt.AlignHCenter
font.pixelSize: 14
Expand Down Expand Up @@ -329,20 +326,17 @@ Rectangle{
_messageBoxInstance.set_text_and_show("TX Power applied when FC is disarmed");
}
}

// FILLER
Item{
Layout.row: 2
Layout.column: 4
Layout.fillWidth: true
}
}

RowLayout{
Layout.fillWidth: true
Text{
Layout.minimumWidth: 100
Layout.preferredWidth: 250
Layout.minimumWidth: left_text_minimum_width
Layout.preferredWidth: left_text_preferred_width
text: {
var power_int=get_current_tx_power_int(2);
if(power_int==0) return "ARMED:\nDISABLED";
Expand All @@ -361,8 +355,6 @@ Rectangle{
font.pixelSize: 14
}
Button{
Layout.row: 3
Layout.column: 2
text: "SAVE"
enabled: m_user_selected_card_manufacturer>=0;
onClicked: {
Expand All @@ -382,8 +374,6 @@ Rectangle{
font.pixelSize: 14
}
ButtonIconInfo{
Layout.row: 3
Layout.column: 3
onClicked: {
_messageBoxInstance.set_text_and_show("TX Power applied when FC is armed. By default, set to 0 (DISABLE) which means the same tx power (tx power disarmed) is applied regardless"+
"if armed or not.");
Expand Down
Loading

0 comments on commit 92ecd98

Please sign in to comment.