From a70587af05cfd5fb5b6d9d4c3fdfa0b31ac7c0b3 Mon Sep 17 00:00:00 2001 From: consti10 Date: Wed, 4 Oct 2023 16:43:10 +0200 Subject: [PATCH 01/81] Fix ui unresponsive after reboot / shutdown command - in the end, the issue was in qml, not anywhere in c++ (async / blocking interface is fine). Leaving the debug messages though. --- app/telemetry/action/impl/cmdsender.cpp | 8 +++++++- app/telemetry/action/ohdaction.cpp | 12 ------------ qml/ui/configpopup/status/PowerActionDialoque.qml | 5 +++-- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/app/telemetry/action/impl/cmdsender.cpp b/app/telemetry/action/impl/cmdsender.cpp index 5647385a1..8200816e2 100644 --- a/app/telemetry/action/impl/cmdsender.cpp +++ b/app/telemetry/action/impl/cmdsender.cpp @@ -67,6 +67,7 @@ bool CmdSender::send_command_long_async(mavlink_command_long_t cmd, RESULT_CB re RunningCommand running_cmd{cmd,result_cb,n_wanted_retransmissions,retransmit_delay}; m_running_commands.push_back(running_cmd); send_command(m_running_commands.back()); + //qDebug()<<"Sent command"<> timed_out_commands{}; { std::lock_guard lock(m_mutex); + //qDebug()<<"CmdSender::handle_timeou::CommandQueue"<running_cmd.retransmit_delay){ qDebug()<<"CMD Timeout"; if(running_cmd.n_transmissions Date: Thu, 5 Oct 2023 00:33:01 +0200 Subject: [PATCH 02/81] move QOpenHD service buttons / dialoque to DEV, tx power - select card manufacturer first --- app/telemetry/settings/documentedparam.cpp | 61 +++++++++---------- qml/qml.qrc | 2 +- .../dev/AppDeveloperStatsPanel.qml | 25 ++++++++ .../QOpenHDServiceDialoque.qml | 4 +- .../openhd_settings/DialoqueChangeTxPower.qml | 38 ++++++------ qml/ui/configpopup/status/ActionsColumn.qml | 22 ------- qml/ui/configpopup/status/PanelStatus.qml | 3 - 7 files changed, 77 insertions(+), 78 deletions(-) rename qml/ui/configpopup/{status => dev}/QOpenHDServiceDialoque.qml (96%) diff --git a/app/telemetry/settings/documentedparam.cpp b/app/telemetry/settings/documentedparam.cpp index d59c728e2..59b0a48ca 100644 --- a/app/telemetry/settings/documentedparam.cpp +++ b/app/telemetry/settings/documentedparam.cpp @@ -84,6 +84,7 @@ static std::vector> get_parameters_list(){ "DEV ONLY - DO NOT TOUCH (LEAVE DISABLED). Sets a wifi param that needs to be investigated." ); { +// ---------- TX POWER - only as placeholders, wizzard is recommended ! // Measurements of @Marcel Essers: //19: 10-12 mW //25: 25-30 mW @@ -95,40 +96,40 @@ static std::vector> get_parameters_list(){ //50: 280- 320 mW //55: 380-400 mW //58: 420-450 mW - auto values_WB_TX_PWR_LEVEL=std::vector{ - {"LOW(~25mW)[22]",22}, - {"MEDIUM [37]",37}, - {"HIGH [53]",53}, - {"MAX1(!DANGER!)[58]",58}, - // Intentionally disabled, since it creates unusably high packet loss - // (e.g. the rf circuit is over-amplified) - //{"MAX2(!DANGER!)[63]",63}, - }; + // NOTE: We now have the tx power wizzard ! + auto values_WB_TX_PWR_INDEX=std::vector{ + {"Unitless [3]",3}, + {"Unitless [6]",6}, + {"Unitless [10]",10}, + {"Unitless [20]",20}, + {"Unitless [40]",40}, + {"Unitless [60]",60}, + {"Unitless [63]",63}, }; + auto values_WB_TX_PWR_INDEX_ARMED=std::vector{ + {"Disabled [0]",0}, + {"Unitless [3]",3}, + {"Unitless [6]",6}, + {"Unitless [10]",10}, + {"Unitless [20]",20}, + {"Unitless [40]",40}, + {"Unitless [60]",60}, + {"Unitless [63]",63}, + }; append_int(ret,openhd::WB_RTL8812AU_TX_PWR_IDX_OVERRIDE, - ImprovedIntSetting(0,63,values_WB_TX_PWR_LEVEL), - "NEW: Recommended to change TX_POWER_I_ARMED instead ! RTL8812AU TX power index (unitless). LOW:default,~25mW, legal in most countries." - " NOTE: Too high power settings can overload your RF circuits and create packet loss/ destroy your card. Read the Wiki before changing the TX Power." - " NOTE2: For high power cards, it is recommended to leave this param default and change TX_POWER_ARMED instead to avoid overheating on the bench." + ImprovedIntSetting(0,63,values_WB_TX_PWR_INDEX), + "Please use the TX POWER wizzard from WB Link to avoid destroying your card ! Unitless Tx power index value applied when the FC is disarmed and no specific armed" + "tx power value is set." ); - } - { - auto values_WB_TX_PWR_LEVEL_ARMED=std::vector{ - {"Disabled[0]",0}, - {"LOW(~25mW)[22]",22}, - {"MEDIUM [37]",37}, - {"HIGH [53]",53}, - {"MAX1(!DANGER!)[58]",58}, - // Intentionally disabled, since it creates unusably high packet loss - // (e.g. the rf circuit is over-amplified) - //{"MAX2(!DANGER!)[63]",63}, - }; append_int(ret,openhd::WB_RTL8812AU_TX_PWR_IDX_ARMED, - ImprovedIntSetting(0,63,values_WB_TX_PWR_LEVEL_ARMED), - "TX Power (in override indices units) that is applied when the FC is armed. When the FC is not armed, TX_POWER_I is applied." - "When this param is disabled, TX_POWER_I is applied regardless if armed or not (default)." - " This helps to avoid overheating of the WIFI card while openhd is powered on the bench / without airflow on the cards." + ImprovedIntSetting(0,63,values_WB_TX_PWR_INDEX_ARMED), + "Please use the TX POWER wizzard from WB Link to avoid destroying your card ! Unitless Tx power index value applied when the FC is armed, off by default" ); + append_only_documented(ret,openhd::WB_TX_POWER_MILLI_WATT, + "Please use the TX POWER wizzard from WB Link to avoid destroying your card ! tx power in mW when FC is disarmed and no specific armed tx power value is set. Actual tx power depends on the manufacturer."); + append_only_documented(ret,openhd::WB_TX_POWER_MILLI_WATT_ARMED, + "Please use the TX POWER wizzard from WB Link to avoid destroying your card ! tx power in mW when FC is armed, off by default. Actual tx power depends on the manufacturer."); } +// ----------------------------------------------------------------------------------------------------------- { auto default_values=std::vector{ {"AUTO (Default)",0}, @@ -196,8 +197,6 @@ static std::vector> get_parameters_list(){ ); append_only_documented(ret,openhd::WB_FREQUENCY,"!!!Editing this param manually without care will result in a broken link!!!"); append_only_documented(ret,openhd::WB_MAX_FEC_BLOCK_SIZE_FOR_PLATFORM,"Developer only, FEC auto internal."); - append_only_documented(ret,openhd::WB_TX_POWER_MILLI_WATT, - "TX power in mW (milli Watt), changing this value might or might not have any effect, depending on your card & driver. 1000mW=1W"); const auto descr_wifi_card="Detected wifi card type used for wifibroadcast."; append_documented_read_only(ret,"WIFI_CARD0",descr_wifi_card); append_documented_read_only(ret,"WIFI_CARD1",descr_wifi_card); diff --git a/qml/qml.qrc b/qml/qml.qrc index 3563af141..71fbeb0ad 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -245,7 +245,6 @@ ui/elements/PillSlider.qml ui/elements/FlightModeSlider.qml ui/elements/ArmDisarmSlider.qml - ui/configpopup/status/QOpenHDServiceDialoque.qml ui/elements/SimpleProgressBar.qml ui/elements/ButtonGreen.qml ui/configpopup/openhd_settings/DialoqueFreqChangeArmed.qml @@ -257,5 +256,6 @@ ui/configpopup/connect/PaneTethering.qml ui/configpopup/connect/GenericInfoPane.qml ui/elements/ButtonSimple.qml + ui/configpopup/dev/QOpenHDServiceDialoque.qml diff --git a/qml/ui/configpopup/dev/AppDeveloperStatsPanel.qml b/qml/ui/configpopup/dev/AppDeveloperStatsPanel.qml index bf4d3abbc..1d80f71f6 100644 --- a/qml/ui/configpopup/dev/AppDeveloperStatsPanel.qml +++ b/qml/ui/configpopup/dev/AppDeveloperStatsPanel.qml @@ -164,5 +164,30 @@ Rectangle { } } } + + RowLayout { + width: parent.width + + Button { + font.capitalization: Font.MixedCase + text: qsTr("DEV-Restart QOpenHD") + onPressed: { + qopenhdservicedialoque.open_dialoque(0) + } + } + Button { + font.capitalization: Font.MixedCase + text: qsTr("DEV-Cancel QOpenHD") + onPressed: { + qopenhdservicedialoque.open_dialoque(1) + } + } + Item { + // Padding + } + } + } + QOpenHDServiceDialoque{ + id: qopenhdservicedialoque } } diff --git a/qml/ui/configpopup/status/QOpenHDServiceDialoque.qml b/qml/ui/configpopup/dev/QOpenHDServiceDialoque.qml similarity index 96% rename from qml/ui/configpopup/status/QOpenHDServiceDialoque.qml rename to qml/ui/configpopup/dev/QOpenHDServiceDialoque.qml index 1a280c2a9..8e3a8d523 100644 --- a/qml/ui/configpopup/status/QOpenHDServiceDialoque.qml +++ b/qml/ui/configpopup/dev/QOpenHDServiceDialoque.qml @@ -49,8 +49,8 @@ Card { cardName: qsTr("QOpenHD") cardBody: Column { - height: powerDialog.height - width: powerDialog.width + height: qopenhdpowerdialoque.height + width: qopenhdpowerdialoque.width Text { text: get_info_text() diff --git a/qml/ui/configpopup/openhd_settings/DialoqueChangeTxPower.qml b/qml/ui/configpopup/openhd_settings/DialoqueChangeTxPower.qml index c4a6d34b1..fcb041c60 100644 --- a/qml/ui/configpopup/openhd_settings/DialoqueChangeTxPower.qml +++ b/qml/ui/configpopup/openhd_settings/DialoqueChangeTxPower.qml @@ -258,20 +258,21 @@ the card driver and/or the linux kernel doesn't support changing it."); Layout.fillWidth: true leftPadding: 12 rightPadding: 12 - text: ("Do you want to set the TX power in armed / disarmed state ?\n"+ -"NOTE: TX power armed is only applied when the FC is armed, TX power disarmed is applied when the FC is disarmed.") + id: card_select_manufcturer_description + text: get_text_select_card_manufacturer() wrapMode: Text.WordWrap } ComboBox { Layout.fillWidth: true leftPadding: 12 rightPadding: 12 - id: comboBoxSelectedArmedDisarmed - model: armed_or_disarmed_model + id: comboBoxCardSelectManufacturer + model: get_model_manufacturer_for_chip_type() textRole: "title" onCurrentIndexChanged: { - if(comboBoxSelectedArmedDisarmed.currentIndex==1)m_change_armed=false; - if(comboBoxSelectedArmedDisarmed.currentIndex==2)m_change_armed=true; + var manufacturer=comboBoxCardSelectManufacturer.model.get(comboBoxCardSelectManufacturer.currentIndex).value; + console.log("Selected manufacturerer "+get_card_chip_type_as_string()+" :"+manufacturer); + m_card_manufacturer_type=manufacturer; } } } @@ -283,21 +284,20 @@ the card driver and/or the linux kernel doesn't support changing it."); Layout.fillWidth: true leftPadding: 12 rightPadding: 12 - id: card_select_manufcturer_description - text: get_text_select_card_manufacturer() + text: ("Do you want to set the TX power in armed / disarmed state ?\n"+ +"NOTE: TX power armed is only applied when the FC is armed, TX power disarmed is applied when the FC is disarmed.") wrapMode: Text.WordWrap } ComboBox { Layout.fillWidth: true leftPadding: 12 rightPadding: 12 - id: comboBoxCardSelectManufacturer - model: get_model_manufacturer_for_chip_type() + id: comboBoxSelectedArmedDisarmed + model: armed_or_disarmed_model textRole: "title" onCurrentIndexChanged: { - var manufacturer=comboBoxCardSelectManufacturer.model.get(comboBoxCardSelectManufacturer.currentIndex).value; - console.log("Selected manufacturerer "+get_card_chip_type_as_string()+" :"+manufacturer); - m_card_manufacturer_type=manufacturer; + if(comboBoxSelectedArmedDisarmed.currentIndex==1)m_change_armed=false; + if(comboBoxSelectedArmedDisarmed.currentIndex==2)m_change_armed=true; } } } @@ -370,10 +370,10 @@ the card driver and/or the linux kernel doesn't support changing it."); Layout.preferredWidth: 140 Layout.alignment: Qt.AlignRight Layout.rightMargin: 12 - text: "Continue" + text: "CONTINUE" onClicked: { - if(comboBoxSelectedArmedDisarmed.currentIndex<=0){ - _qopenhd.show_toast("Please specify armed / disarmed",false); + if(m_card_manufacturer_type<0){ + _qopenhd.show_toast("Please select your card manufacturer",false); }else{ m_curr_index=2; } @@ -396,10 +396,10 @@ the card driver and/or the linux kernel doesn't support changing it."); Layout.preferredWidth: 140 Layout.alignment: Qt.AlignRight Layout.rightMargin: 12 - text: "CONTINUE" + text: "Continue" onClicked: { - if(m_card_manufacturer_type<0){ - _qopenhd.show_toast("Please select your card manufacturer",false); + if(comboBoxSelectedArmedDisarmed.currentIndex<=0){ + _qopenhd.show_toast("Please specify armed / disarmed",false); }else{ m_curr_index=3; } diff --git a/qml/ui/configpopup/status/ActionsColumn.qml b/qml/ui/configpopup/status/ActionsColumn.qml index 6663e63d0..1f9e0e225 100644 --- a/qml/ui/configpopup/status/ActionsColumn.qml +++ b/qml/ui/configpopup/status/ActionsColumn.qml @@ -54,27 +54,5 @@ Item { // Padding } } - - RowLayout { - width: parent.width - - Button { - font.capitalization: Font.MixedCase - text: qsTr("DEV-Restart QOpenHD") - onPressed: { - qopenhdservicedialoque.open_dialoque(0) - } - } - Button { - font.capitalization: Font.MixedCase - text: qsTr("DEV-Cancel QOpenHD") - onPressed: { - qopenhdservicedialoque.open_dialoque(1) - } - } - Item { - // Padding - } - } } } diff --git a/qml/ui/configpopup/status/PanelStatus.qml b/qml/ui/configpopup/status/PanelStatus.qml index 8f650b3d4..a97d93765 100644 --- a/qml/ui/configpopup/status/PanelStatus.qml +++ b/qml/ui/configpopup/status/PanelStatus.qml @@ -74,8 +74,5 @@ Rectangle { PowerActionDialoque{ id: powerDialog } - QOpenHDServiceDialoque{ - id: qopenhdservicedialoque - } } } From c64662416f08963a0cff4613c6f6640adc8ee43b Mon Sep 17 00:00:00 2001 From: consti10 Date: Mon, 9 Oct 2023 15:31:01 +0200 Subject: [PATCH 03/81] add forwarding of user to connect / channel scan when system is not alive update mavlink - show wifi hotspot state in status add pollution chart improve frequency selection --- app/osd/performancehorizonladder.cpp | 16 +- app/telemetry/MavlinkTelemetry.cpp | 9 + app/telemetry/MavlinkTelemetry.h | 1 + app/telemetry/connection/udp_connection.h | 1 + app/telemetry/models/aohdsystem.cpp | 14 +- app/telemetry/models/aohdsystem.h | 4 + app/telemetry/models/wificard.cpp | 8 +- app/telemetry/settings/pollutionhelper.cpp | 36 ++++ app/telemetry/settings/pollutionhelper.h | 33 ++++ .../settings/wblinksettingshelper.cpp | 177 ++++++++++-------- app/telemetry/settings/wblinksettingshelper.h | 16 +- app/telemetry/telemetry.pri | 2 + .../vscommon/rtp/rtpreceiver.cpp | 5 + lib/mavlink-headers | 2 +- qml/qml.qrc | 25 +-- qml/ui/configpopup/ConfigPopup.qml | 11 ++ .../openhd_settings/FreqComboBoxRow.qml | 28 ++- .../MavlinkAllSettingsPanel.qml | 8 +- ...anel.qml => MavlinkOpenHDWBParamPanel.qml} | 74 ++++---- .../openhd_settings/PollutionChartView.qml | 60 ++++++ .../configpopup/status/DialoqueNotAlive.qml | 97 ++++++++++ ...FC.qml => FooterRebootShutdownWarning.qml} | 12 +- qml/ui/configpopup/status/PanelStatus.qml | 42 +++-- .../status/StatusCardBodyOpenHD.qml | 102 ++++++++-- .../configpopup/status/StatusCardsColumn.qml | 20 +- qml/ui/elements/ButtonDisconnected.qml | 13 ++ qml/ui/elements/ButtonSimple.qml | 4 +- 27 files changed, 619 insertions(+), 201 deletions(-) create mode 100644 app/telemetry/settings/pollutionhelper.cpp create mode 100644 app/telemetry/settings/pollutionhelper.h rename qml/ui/configpopup/openhd_settings/{MavlinkExtraWBParamPanel.qml => MavlinkOpenHDWBParamPanel.qml} (93%) create mode 100644 qml/ui/configpopup/openhd_settings/PollutionChartView.qml create mode 100644 qml/ui/configpopup/status/DialoqueNotAlive.qml rename qml/ui/configpopup/status/{StatusCardFooterGenericOHDFC.qml => FooterRebootShutdownWarning.qml} (73%) create mode 100644 qml/ui/elements/ButtonDisconnected.qml diff --git a/app/osd/performancehorizonladder.cpp b/app/osd/performancehorizonladder.cpp index 181d3dbc3..e0889664f 100644 --- a/app/osd/performancehorizonladder.cpp +++ b/app/osd/performancehorizonladder.cpp @@ -14,7 +14,21 @@ PerformanceHorizonLadder::PerformanceHorizonLadder(QQuickItem *parent) PerformanceHorizonLadder::~PerformanceHorizonLadder() { - + if(m_base_node){ + delete m_base_node; + } + if(m_center_indicator){ + delete m_center_indicator; + } + if(m_ladders_geom_node){ + delete m_ladders_geom_node; + } + if(m_tf_node){ + delete m_tf_node; + } + if(m_flat_color_material){ + delete m_flat_color_material; + } } void PerformanceHorizonLadder::setRoll(int roll) { diff --git a/app/telemetry/MavlinkTelemetry.cpp b/app/telemetry/MavlinkTelemetry.cpp index b9bd9d5f5..4b683b91d 100644 --- a/app/telemetry/MavlinkTelemetry.cpp +++ b/app/telemetry/MavlinkTelemetry.cpp @@ -15,6 +15,15 @@ MavlinkTelemetry::MavlinkTelemetry(QObject *parent):QObject(parent) { } +MavlinkTelemetry::~MavlinkTelemetry() +{ + if(m_heartbeat_thread){ + m_heartbeat_thread_run=false; + m_heartbeat_thread->join(); + m_heartbeat_thread=nullptr; + } +} + MavlinkTelemetry &MavlinkTelemetry::instance() { static MavlinkTelemetry instance{}; diff --git a/app/telemetry/MavlinkTelemetry.h b/app/telemetry/MavlinkTelemetry.h index 2cc58666d..575beb110 100644 --- a/app/telemetry/MavlinkTelemetry.h +++ b/app/telemetry/MavlinkTelemetry.h @@ -33,6 +33,7 @@ class MavlinkTelemetry : public QObject Q_OBJECT public: MavlinkTelemetry(QObject *parent = nullptr); + ~MavlinkTelemetry(); static MavlinkTelemetry& instance(); void start(); /** diff --git a/app/telemetry/connection/udp_connection.h b/app/telemetry/connection/udp_connection.h index 9d82e690e..822fe8d7f 100644 --- a/app/telemetry/connection/udp_connection.h +++ b/app/telemetry/connection/udp_connection.h @@ -28,6 +28,7 @@ class UDPConnection void stop(); void send_message(const mavlink_message_t& msg); + private: void process_data(const uint8_t* data,int data_len); void process_mavlink_message(mavlink_message_t msg); diff --git a/app/telemetry/models/aohdsystem.cpp b/app/telemetry/models/aohdsystem.cpp index cef9b43df..beba364e2 100644 --- a/app/telemetry/models/aohdsystem.cpp +++ b/app/telemetry/models/aohdsystem.cpp @@ -223,6 +223,12 @@ bool AOHDSystem::process_message(const mavlink_message_t &msg) } consumed=true; }break; + case MAVLINK_MSG_ID_OPENHD_SYS_STATUS1:{ + mavlink_openhd_sys_status1_t parsed; + mavlink_msg_openhd_sys_status1_decode(&msg,&parsed); + process_sys_status1(parsed); + consumed=true; + }break; default:{ }break; @@ -283,7 +289,7 @@ void AOHDSystem::process_x0(const mavlink_openhd_stats_monitor_mode_wifi_card_t } // TODO: r.n we don't differentiate signal quality per card if(msg.card_index==0){ - set_current_rx_signal_quality(msg.rx_signal_quality); + set_current_rx_signal_quality(msg.rx_signal_quality_adapter); } } @@ -454,6 +460,12 @@ void AOHDSystem::process_x4b(const mavlink_openhd_stats_wb_video_ground_fec_perf } } +void AOHDSystem::process_sys_status1(const mavlink_openhd_sys_status1_t &msg) +{ + set_wifi_hotspot_state(msg.wifi_hotspot_state); + set_wifi_hotspot_frequency(msg.wifi_hotspot_frequency); +} + void AOHDSystem::update_alive() { // NOTE: Since we are really resourcefully with the link, we consider the system alive if any message coming from it has diff --git a/app/telemetry/models/aohdsystem.h b/app/telemetry/models/aohdsystem.h index 10e15b8f5..3a3b8ba77 100644 --- a/app/telemetry/models/aohdsystem.h +++ b/app/telemetry/models/aohdsystem.h @@ -111,6 +111,9 @@ class AOHDSystem : public QObject // L_RO_PROP(int,wb_link_pollution_perc,set_wb_link_pollution_perc,-1) L_RO_PROP(int,wb_link_curr_foreign_pps,set_wb_link_curr_foreign_pps,-1) + // ---------- WIFI HOTSPOT ---------------------- + L_RO_PROP(int,wifi_hotspot_state,set_wifi_hotspot_state,-1) // 0 - not available, 1 - off, 2 - on + L_RO_PROP(int,wifi_hotspot_frequency,set_wifi_hotspot_frequency,-1) private: const bool m_is_air; // either true (for air) or false (for ground) uint8_t get_own_sys_id()const{ @@ -127,6 +130,7 @@ class AOHDSystem : public QObject void process_x3b(const mavlink_openhd_stats_wb_video_air_fec_performance_t& msg); void process_x4(const mavlink_openhd_stats_wb_video_ground_t& msg); void process_x4b(const mavlink_openhd_stats_wb_video_ground_fec_performance_t& msg); + void process_sys_status1(const mavlink_openhd_sys_status1_t& msg); private: std::atomic m_last_heartbeat_ms = -1; std::atomic m_last_message_ms= -1; diff --git a/app/telemetry/models/wificard.cpp b/app/telemetry/models/wificard.cpp index 8be858fb8..5f942ba22 100644 --- a/app/telemetry/models/wificard.cpp +++ b/app/telemetry/models/wificard.cpp @@ -9,13 +9,13 @@ static std::string wifi_card_type_to_string(const int card_type) { switch (card_type) { case 0: - return "RTL88X2AU_OHD"; + return "RTL88X2AU"; case 1: - return "RTL88X2BU_OHD"; + return "RTL88X2BU"; case 2: - return "RTL_88X2AU"; + return "ERR_RTL_88X2AU"; case 3: - return "RTL_88X2BU"; + return "ERR_RTL_88X2BU"; case 4: return "ATHEROS"; case 5: diff --git a/app/telemetry/settings/pollutionhelper.cpp b/app/telemetry/settings/pollutionhelper.cpp new file mode 100644 index 000000000..7c6f5ae9f --- /dev/null +++ b/app/telemetry/settings/pollutionhelper.cpp @@ -0,0 +1,36 @@ +#include "pollutionhelper.h" + +#include + +PollutionHelper::PollutionHelper() +{ + +} + +PollutionHelper& PollutionHelper::instance() +{ + static PollutionHelper instance; + return instance; +} + + +void PollutionHelper::threadsafe_update(const std::vector &values) +{ + std::lock_guard lock(m_pollution_elements_mutex); + m_pollution_elements.clear(); + for(const auto& value:values){ + m_pollution_elements[value.frequency_mhz]=value; + //qDebug()<<"Value:"< PollutionHelper::threadsafe_get_pollution_for_frequency(int frequency) +{ + std::lock_guard lock(m_pollution_elements_mutex); + auto search = m_pollution_elements.find(frequency); + if(search != m_pollution_elements.end()){ + return search->second; + } + //qDebug()<<"Cannot find pollution for "< +#include +#include +#include + + +// Written by telemetry, read by UI +// This atomic behaviour is enough for us - we signal the ui to rebuild itself every time the data changes +// The OpenHD ground unit broadcast the whole pollution set during channel scan, filling it as the scan proceeds. +class PollutionHelper +{ +public: + PollutionHelper(); + static PollutionHelper& instance(); +public: + struct PollutionElement{ + int frequency_mhz; + int width_mhz; + int n_foreign_packets; + }; + void threadsafe_update(const std::vector& values); + std::optional threadsafe_get_pollution_for_frequency(int frequency); +private: + // Written by telemetry, read by UI + std::map m_pollution_elements; + std::mutex m_pollution_elements_mutex; +}; + + +#endif // POLLUTIONHELPER_H diff --git a/app/telemetry/settings/wblinksettingshelper.cpp b/app/telemetry/settings/wblinksettingshelper.cpp index 6b8f99f1b..c0986abdd 100644 --- a/app/telemetry/settings/wblinksettingshelper.cpp +++ b/app/telemetry/settings/wblinksettingshelper.cpp @@ -9,6 +9,8 @@ #include "../action/ohdaction.h" #include "../../util/qopenhd.h" +#include "pollutionhelper.h" + static void tmp_log_result(bool enable,const std::string message){ if(enable){ HUDLogMessagesModel::instance().add_message_info(message.c_str()); @@ -108,20 +110,23 @@ void WBLinkSettingsHelper::process_message_openhd_wifibroadcast_supported_channe void WBLinkSettingsHelper::process_message_openhd_wifibroadcast_analyze_channels_progress(const mavlink_openhd_wifbroadcast_analyze_channels_progress_t &msg) { - std::vector> analyzed_channels; + std::vector analyzed_channels; for(int i=0;i<30;i++){ if(msg.channels_mhz[i]==0){ break; } - analyzed_channels.push_back(std::make_pair(msg.channels_mhz[i],msg.foreign_packets[i])); + PollutionHelper::PollutionElement tmp; + tmp.frequency_mhz=msg.channels_mhz[i]; + tmp.n_foreign_packets=msg.foreign_packets[i]; + analyzed_channels.push_back(tmp); } if(analyzed_channels.size()==0){ qDebug()<<"Perhaps malformed message analyze channels"; return; } - const uint16_t curr_channel_mhz=analyzed_channels[analyzed_channels.size()-1].first; + const uint16_t curr_channel_mhz=analyzed_channels[analyzed_channels.size()-1].frequency_mhz; const uint16_t curr_channel_width_mhz=40; - const uint16_t curr_foreign_packets=analyzed_channels[analyzed_channels.size()-1].second; + const uint16_t curr_foreign_packets=analyzed_channels[analyzed_channels.size()-1].n_foreign_packets; { std::stringstream ss; ss<<"Analyzed "<<(int)curr_channel_mhz<<"@"<<(int)curr_channel_width_mhz; @@ -141,9 +146,7 @@ void WBLinkSettingsHelper::process_message_openhd_wifibroadcast_analyze_channels qDebug()< get_freq_descr(){ std::vector ret{ - FrequencyItem{-1,2312,false,false,false}, - FrequencyItem{-1,2332,false,false,false}, - FrequencyItem{-1,2352,false,false,false}, - FrequencyItem{-1,2372,false,false,false}, - FrequencyItem{-1,2392,false,false,false}, + FrequencyItem{-1,2312,false,false,false,-1}, + FrequencyItem{-1,2332,false,false,false,-1}, + FrequencyItem{-1,2352,false,false,false,-1}, + FrequencyItem{-1,2372,false,false,false,-1}, + FrequencyItem{-1,2392,false,false,false,-1}, // ACTUAL 2G - FrequencyItem{1 ,2412,false,true,false}, - FrequencyItem{5 ,2432,false,true,false}, - FrequencyItem{9 ,2452,false,true,false}, - FrequencyItem{13,2472,false,true,false}, - FrequencyItem{14,2484,false,false,false}, + FrequencyItem{1 ,2412,false,true,false,-1}, + FrequencyItem{5 ,2432,false,true,false,-1}, + FrequencyItem{9 ,2452,false,true,false,-1}, + FrequencyItem{13,2472,false,true,false,-1}, + FrequencyItem{14,2484,false,false,false,-1}, // ACTUAL 2G end - FrequencyItem{-1,2492,false,false,false}, - FrequencyItem{-1,2512,false,false,false}, - FrequencyItem{-1,2532,false,false,false}, - FrequencyItem{-1,2572,false,false,false}, - FrequencyItem{-1,2592,false,false,false}, - FrequencyItem{-1,2612,false,false,false}, - FrequencyItem{-1,2632,false,false,false}, - FrequencyItem{-1,2652,false,false,false}, - FrequencyItem{-1,2672,false,false,false}, - FrequencyItem{-1,2692,false,false,false}, - FrequencyItem{-1, 2712,false,false,false}, + FrequencyItem{-1,2492,false,false,false,-1}, + FrequencyItem{-1,2512,false,false,false,-1}, + FrequencyItem{-1,2532,false,false,false,-1}, + FrequencyItem{-1,2572,false,false,false,-1}, + FrequencyItem{-1,2592,false,false,false,-1}, + FrequencyItem{-1,2612,false,false,false,-1}, + FrequencyItem{-1,2632,false,false,false,-1}, + FrequencyItem{-1,2652,false,false,false,-1}, + FrequencyItem{-1,2672,false,false,false,-1}, + FrequencyItem{-1,2692,false,false,false,-1}, + FrequencyItem{-1, 2712,false,false,false,-1}, // 5G begin - FrequencyItem{ 32,5160,false,false,false}, - FrequencyItem{ 36,5180,false,true ,false}, - FrequencyItem{ 40,5200,false,false,false}, - FrequencyItem{ 44,5220,false,true,false}, - FrequencyItem{ 48,5240,false,false,false}, - FrequencyItem{ 52,5260,true,true ,false}, - FrequencyItem{ 56,5280,true,false,false}, - FrequencyItem{ 60,5300,true,true,false}, - FrequencyItem{ 64,5320,true,false,false}, + FrequencyItem{ 32,5160,false,false,false,-1}, + FrequencyItem{ 36,5180,false,true ,false,-1}, + FrequencyItem{ 40,5200,false,false,false,-1}, + FrequencyItem{ 44,5220,false,true,false,-1}, + FrequencyItem{ 48,5240,false,false,false,-1}, + FrequencyItem{ 52,5260,true,true ,false,-1}, + FrequencyItem{ 56,5280,true,false,false,-1}, + FrequencyItem{ 60,5300,true,true,false,-1}, + FrequencyItem{ 64,5320,true,false,false,-1}, // big break / part that is not allowed - FrequencyItem{100,5500,true,true,false}, - FrequencyItem{104,5520,true,false,false}, - FrequencyItem{108,5540,true,true,false}, - FrequencyItem{112,5560,true,false,false}, - FrequencyItem{116,5580,true,true,false}, - FrequencyItem{120,5600,true,false,false}, - FrequencyItem{124,5620,true,true,false}, - FrequencyItem{128,5640,true,false,false}, - FrequencyItem{132,5660,true,true,false}, - FrequencyItem{136,5680,true,false,false}, - FrequencyItem{140,5700,true,true,false}, - FrequencyItem{144,5720,true,false,false}, + FrequencyItem{100,5500,true,true,false,-1}, + FrequencyItem{104,5520,true,false,false,-1}, + FrequencyItem{108,5540,true,true,false,-1}, + FrequencyItem{112,5560,true,false,false,-1}, + FrequencyItem{116,5580,true,true,false,-1}, + FrequencyItem{120,5600,true,false,false,-1}, + FrequencyItem{124,5620,true,true,false,-1}, + FrequencyItem{128,5640,true,false,false,-1}, + FrequencyItem{132,5660,true,true,false,-1}, + FrequencyItem{136,5680,true,false,false,-1}, + FrequencyItem{140,5700,false,true,false,1}, + FrequencyItem{144,5720,false,false,false,-1}, // Here is the weird break - FrequencyItem{149,5745,false,true,true}, - FrequencyItem{153,5765,false,false,false}, - FrequencyItem{157,5785,false,true,true}, - FrequencyItem{161,5805,false,false,false}, - FrequencyItem{165,5825,false,true,true}, + FrequencyItem{149,5745,false,true,true,2}, + FrequencyItem{153,5765,false,false,false,-1}, + FrequencyItem{157,5785,false,true,true,3}, + FrequencyItem{161,5805,false,false,false,-1}, + FrequencyItem{165,5825,false,true,true,4}, // Depends - FrequencyItem{169,5845,false,false,false}, - FrequencyItem{173,5865,false,true,true}, - FrequencyItem{177,5885,false,false,false}, - FrequencyItem{181,5905,false,false,true} + FrequencyItem{169,5845,false,false,false,-1}, + FrequencyItem{173,5865,false,true,true,5}, + FrequencyItem{177,5885,false,false,false,-1}, + FrequencyItem{181,5905,false,false,true,-1} }; return ret; } @@ -318,7 +322,7 @@ QString WBLinkSettingsHelper::get_frequency_description(int frequency_mhz) int WBLinkSettingsHelper::get_frequency_pollution(int frequency_mhz) { - auto pollution=get_pollution_for_frequency(frequency_mhz); + auto pollution=PollutionHelper::instance().threadsafe_get_pollution_for_frequency(frequency_mhz); if(pollution.has_value()){ return pollution.value().n_foreign_packets; } @@ -343,6 +347,12 @@ bool WBLinkSettingsHelper::get_frequency_reccommended(int frequency_mhz) return frequency_item.recommended; } +int WBLinkSettingsHelper::get_frequency_openhd_race_band(int frequency_mhz) +{ + const auto frequency_item=find_frequency_item(frequency_mhz); + return frequency_item.openhd_raceband; +} + void WBLinkSettingsHelper::set_param_keyframe_interval_async(int keyframe_interval) { change_param_air_async(OHD_COMP_ID_AIR_CAMERA_PRIMARY,"V_KEYFRAME_I",static_cast(keyframe_interval),"KEYFRAME"); @@ -467,28 +477,49 @@ QList WBLinkSettingsHelper::get_supported_frequencies() return ret; } -void WBLinkSettingsHelper::update_pollution(int frequency, int n_foreign_packets) +QList WBLinkSettingsHelper::get_supported_frequencies_filtered(int filter_level) { - std::lock_guard lock(m_pollution_elements_mutex); - auto search = m_pollution_elements.find(frequency); - if(search != m_pollution_elements.end()){ - m_pollution_elements[frequency].n_foreign_packets=n_foreign_packets; - }else{ - PollutionElement element{frequency,40,n_foreign_packets}; - m_pollution_elements.insert({frequency,element}); + auto supported_frequencies=get_supported_frequencies(); + if(filter_level<=0)return supported_frequencies; + QList ret; + for(auto& frequency: supported_frequencies){ + if(filter_level==1){ + // 40Mhz spacing + auto info=find_frequency_item(frequency); + if(info.simple){ + ret.push_back(frequency); + } + } } + return ret; } -std::optional WBLinkSettingsHelper::get_pollution_for_frequency(int frequency) +QStringList WBLinkSettingsHelper::pollution_frequencies_int_to_qstringlist(QList frequencies) { - std::lock_guard lock(m_pollution_elements_mutex); - auto search = m_pollution_elements.find(frequency); - if(search != m_pollution_elements.end()){ - return search->second; + QStringList ret; + for(auto& freq:frequencies){ + std::stringstream ss; + ss< frequencies) +{ + QVariantList ret; + for(auto& freq: frequencies){ + auto pollution=PollutionHelper::instance().threadsafe_get_pollution_for_frequency(freq); + if(pollution.has_value()){ + ret.push_back(static_cast(pollution.value().n_foreign_packets)); + }else{ + ret.push_back(static_cast(0)); + } } - return std::nullopt; + return ret; } + void WBLinkSettingsHelper::signal_ui_rebuild_model_when_possible() { const bool valid_ground_channel_data=has_valid_reported_channel_data(); diff --git a/app/telemetry/settings/wblinksettingshelper.h b/app/telemetry/settings/wblinksettingshelper.h index 0662b747c..260a5028d 100644 --- a/app/telemetry/settings/wblinksettingshelper.h +++ b/app/telemetry/settings/wblinksettingshelper.h @@ -93,11 +93,17 @@ class WBLinkSettingsHelper : public QObject return change_param_ground_only_blocking(PARAM_ID_WB_FREQ,value); } Q_INVOKABLE QList get_supported_frequencies(); + // To not overload the user, we filter the frequencies a bit + Q_INVOKABLE QList get_supported_frequencies_filtered(int filter_level); + Q_INVOKABLE QStringList pollution_frequencies_int_to_qstringlist(QList frequencies); + Q_INVOKABLE QVariantList pollution_frequencies_int_get_pollution(QList frequencies); + Q_INVOKABLE QString get_frequency_description(int frequency_mhz); Q_INVOKABLE int get_frequency_pollution(int frequency_mhz); Q_INVOKABLE bool get_frequency_radar(int frequency_mhz); Q_INVOKABLE bool get_frequency_simplify(int frequency_mhz); Q_INVOKABLE bool get_frequency_reccommended(int frequency_mhz); + Q_INVOKABLE int get_frequency_openhd_race_band(int frequency_mhz); // These params can be changed "on the fly" and are additionally their value(s) are broadcasted // so we can update them completely async, log the result to the user // and use the broadcasted value(s) to update the UI @@ -119,16 +125,6 @@ class WBLinkSettingsHelper : public QObject bool has_valid_reported_channel_data(); std::atomic m_simplify_channels=false; private: - struct PollutionElement{ - int frequency_mhz; - int width_mhz; - int n_foreign_packets; - }; - // Written by telemetry, read by UI - std::map m_pollution_elements; - std::mutex m_pollution_elements_mutex; - void update_pollution(int frequency,int n_foreign_packets); - std::optional get_pollution_for_frequency(int frequency); void signal_ui_rebuild_model_when_possible(); }; diff --git a/app/telemetry/telemetry.pri b/app/telemetry/telemetry.pri index 4341974b7..fe0e7fa3a 100644 --- a/app/telemetry/telemetry.pri +++ b/app/telemetry/telemetry.pri @@ -12,6 +12,7 @@ SOURCES += \ $$PWD/connection/udp_connection.cpp \ $$PWD/models/fcmapmodel.cpp \ $$PWD/settings/documentedparam.cpp \ + $$PWD/settings/pollutionhelper.cpp \ $$PWD/settings/wblinksettingshelper.cpp \ $$PWD/action/impl/xparam.cpp \ app/telemetry/models/aohdsystem.cpp \ @@ -35,6 +36,7 @@ HEADERS += \ $$PWD/connection/tcp_connection.h \ $$PWD/settings/documentedparam.h \ $$PWD/action/impl/xparam.h \ + $$PWD/settings/pollutionhelper.h \ $$PWD/util/geodesi_helper.h \ $$PWD/util/mavlink_enum_to_string.h \ $$PWD//util/openhd_defines.hpp \ diff --git a/app/videostreaming/vscommon/rtp/rtpreceiver.cpp b/app/videostreaming/vscommon/rtp/rtpreceiver.cpp index accf72914..10302f477 100644 --- a/app/videostreaming/vscommon/rtp/rtpreceiver.cpp +++ b/app/videostreaming/vscommon/rtp/rtpreceiver.cpp @@ -212,6 +212,11 @@ void RTPReceiver::nalu_data_callback(const std::chrono::steady_clock::time_point m_out_file->write((const char*)nalu_data,nalu_data_size); m_out_file->flush(); } + /*int random=rand(); + if(random % 10 == 0){ + qDebug()<<"Dropping frame"; + return; + }*/ queue_data(nalu_data,nalu_data_size); } diff --git a/lib/mavlink-headers b/lib/mavlink-headers index 58f77c0c0..48c17d748 160000 --- a/lib/mavlink-headers +++ b/lib/mavlink-headers @@ -1 +1 @@ -Subproject commit 58f77c0c003d241e6324f33a839d262dae497823 +Subproject commit 48c17d748f611d3155dcb98d6d1d7bf121fbd079 diff --git a/qml/qml.qrc b/qml/qml.qrc index 71fbeb0ad..2b68b397a 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -1,33 +1,33 @@ - + ../translations/QOpenHD_en.qm resources/cursors/arrow_512_green.png resources/cursors/arrow_512_transparent.png resources/cursors/arrow_512_white.png resources/cursors/hand_white.png - + ../translations/QOpenHD_de.qm - + ../translations/QOpenHD_ru.qm - + ../translations/QOpenHD_es.qm - + ../translations/QOpenHD_fr.qm - + ../translations/QOpenHD_nl.qm - + ../translations/QOpenHD_ro.qm - + ../translations/QOpenHD_it.qm - + ../translations/QOpenHD_zh.qm @@ -210,7 +210,7 @@ ui/configpopup/qopenhd_settings/AppDevSettingsView.qml ui/configpopup/openhd_settings/MavlinkParamPanel.qml ui/configpopup/openhd_settings/MavlinkParamEditor.qml - ui/configpopup/openhd_settings/MavlinkExtraWBParamPanel.qml + ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml ui/configpopup/openhd_settings/DialoqueFreqChangeGndOnly.qml ui/configpopup/openhd_settings/DialoqueStartAnalyzeChannels.qml @@ -239,7 +239,7 @@ ui/configpopup/connect/PaneCustom.qml ui/elements/ButtonRed.qml ui/elements/ButtonOrange.qml - ui/configpopup/status/StatusCardFooterGenericOHDFC.qml + ui/configpopup/status/FooterRebootShutdownWarning.qml ui/elements/ButtonIconInfoText.qml ui/elements/ButtonIconInfo.qml ui/elements/PillSlider.qml @@ -257,5 +257,8 @@ ui/configpopup/connect/GenericInfoPane.qml ui/elements/ButtonSimple.qml ui/configpopup/dev/QOpenHDServiceDialoque.qml + ui/elements/ButtonDisconnected.qml + ui/configpopup/status/DialoqueNotAlive.qml + ui/configpopup/openhd_settings/PollutionChartView.qml diff --git a/qml/ui/configpopup/ConfigPopup.qml b/qml/ui/configpopup/ConfigPopup.qml index 48a28465c..8d7fe5852 100644 --- a/qml/ui/configpopup/ConfigPopup.qml +++ b/qml/ui/configpopup/ConfigPopup.qml @@ -46,6 +46,17 @@ Rectangle { sidebar.focus = true; } + function user_quidance_open_connect_screen(){ + openSettings(); + mainStackLayout.currentIndex=7; + } + + function user_guidance_open_openhd_settings_find_air_unit_location(){ + openSettings(); + mainStackLayout.currentIndex=2; + mavlinkAllSettingsPanel.user_quidance_animate_channel_scan(); + } + /*Keys.onPressed: (event)=> { console.log("ConfigPopup Key was pressed:"+event); if (event.key == Qt.Key_Return) { diff --git a/qml/ui/configpopup/openhd_settings/FreqComboBoxRow.qml b/qml/ui/configpopup/openhd_settings/FreqComboBoxRow.qml index ff89f9996..33eaa9eec 100644 --- a/qml/ui/configpopup/openhd_settings/FreqComboBoxRow.qml +++ b/qml/ui/configpopup/openhd_settings/FreqComboBoxRow.qml @@ -27,12 +27,14 @@ Rectangle{ property bool m_2G_5G_show: false property bool m_show_radar: false property bool m_show_good_channel: false - property string m_pollution_text: "P:XX" - property color m_pollution_color: "green" + + property int m_openhd_race_band: -1 + color: "transparent" anchors.fill: parent anchors.margins: 6 + // Background Rectangle{ anchors.fill: parent @@ -58,7 +60,7 @@ Rectangle{ text: m_is_2G ? "5.8G" : "2.4G" //color: value > 3000 ? "green" : "#ff8c00" //"orange" color: "#706F1D" // dark green - visible: m_2G_5G_show + visible: m_2G_5G_show && m_openhd_race_band<0 } Text { // Radar icon Layout.alignment: Qt.AlignLeft @@ -71,20 +73,32 @@ Rectangle{ Layout.fillWidth: true // filler } - Text{ // smiley icon - indicates good channel + /*Text{ // smiley icon - indicates good channel Layout.alignment: Qt.AlignRight Layout.preferredWidth: 30 text: qsTr("\uf585") visible: m_show_good_channel font.family: "Font Awesome 5 Free" color: "green" - } + }*/ Text{ + Layout.alignment: Qt.AlignLeft + Layout.preferredWidth: 90 + text: "Default" + font.family: "Font Awesome 5 Free" + color: "green" + visible: m_openhd_race_band==2 + } + + Text{ // recommended / openhd race band channel Layout.alignment: Qt.AlignRight Layout.preferredWidth: 60 - text: m_pollution_text - color: m_pollution_color + text: { + qsTr("OHD "+m_openhd_race_band) + } + visible: m_openhd_race_band>=0 font.family: "Font Awesome 5 Free" + color: "green" } } } diff --git a/qml/ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml b/qml/ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml index 407a37f38..f2275d226 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml +++ b/qml/ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml @@ -26,6 +26,12 @@ Rectangle { //color: "green" color: "transparent" + + function user_quidance_animate_channel_scan(){ + selectItemInStackLayoutBar.currentIndex=0; + xX_WBLinkSettings.user_quidance_animate_channel_scan(); + } + // Tab bar for selecting items in stack layout TabBar { id: selectItemInStackLayoutBar @@ -57,7 +63,7 @@ Rectangle { anchors.bottom: parent.bottom currentIndex: selectItemInStackLayoutBar.currentIndex - MavlinkExtraWBParamPanel{ + MavlinkOpenHDWBParamPanel{ //WBFrequencyPanel{ id: xX_WBLinkSettings } diff --git a/qml/ui/configpopup/openhd_settings/MavlinkExtraWBParamPanel.qml b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml similarity index 93% rename from qml/ui/configpopup/openhd_settings/MavlinkExtraWBParamPanel.qml rename to qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml index fd549678e..e8cdfda41 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkExtraWBParamPanel.qml +++ b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml @@ -14,7 +14,7 @@ import OpenHD 1.0 import "../../../ui" as Ui import "../../elements" -//simport QtCharts 2.0 +import QtCharts 2.0 // This is an extra screen for changing the frequency / channel width - // They both need to match ! @@ -26,6 +26,11 @@ Rectangle{ //color: settings.screen_settings_openhd_parameters_transparent ? "transparent" : "white" //opacity: settings.screen_settings_openhd_parameters_transparent ? 0.2 : 1 + function user_quidance_animate_channel_scan(){ + console.log("User guidance animate channel scan"); + anim_find_air_unit.start() + } + // https://stackoverflow.com/questions/41991438/how-do-i-find-a-particular-listelement-inside-a-listmodel-in-qml // For the models above (model with value) try to find the index of the first item where model[i].value===value function find_index(model,value){ @@ -46,7 +51,7 @@ Rectangle{ ListModel{ id: supported_frequencies_model - ListElement {title: "Unknown"; value:-1; radar: false; recommended: false; pollution: -1} + ListElement {title: "Unknown"; value:-1; radar: false; recommended: false; openhd_raceband_nr: -1} } function show_popup_message(message){ @@ -61,19 +66,20 @@ Rectangle{ for(var i=0;i= 0; }else{ append_this_value=true; } if(append_this_value){ - supported_frequencies_model.append({title: text, value: frequency, radar:radar, recommended: recommended, pollution: v_pollution }) + supported_frequencies_model.append({title: text, value: frequency, radar:radar, recommended: recommended, openhd_raceband_nr: openhd_raceband}) } } var index=find_index(supported_frequencies_model,_wbLinkSettingsHelper.curr_channel_mhz); @@ -98,18 +104,9 @@ Rectangle{ if(_wbLinkSettingsHelper.ui_rebuild_models<=0)return create_list_model_supported(); //update_pollution_graph(); + pollution_chart_view.update(); } - /*property BarCategoryAxis m_bar_category_axis; - function update_pollution_graph(){ - const supported_frequencies=_wbLinkSettingsHelper.get_supported_frequencies(); - m_bar_category_axis.categories.clear(); - for(var i=0;i 100 m_show_radar: radar m_show_good_channel: recommended - m_pollution_text: get_text_pollution(pollution) - m_pollution_color: get_color_pollution(pollution) + m_openhd_race_band: openhd_raceband_nr } highlighted: comboBoxFreq.highlightedIndex === index } @@ -548,23 +544,6 @@ and automatically connect. Otherwise, use the 'FIND AIR UNIT' feature to scan al } } - - /*ChartView { - title: "Bar series" - width: parent.width - height: rowHeight * 3 - legend.alignment: Qt.AlignBottom - antialiasing: true - - PercentBarSeries { - id: hm_bar_series - axisX: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] } - BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } - BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } - BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } - } - }*/ - Rectangle { width: parent.width height: rowHeight @@ -581,11 +560,33 @@ and automatically connect. Otherwise, use the 'FIND AIR UNIT' feature to scan al } } Button{ + id: b_find_air_unit text: "FIND AIR UNIT" enabled: _ohdSystemGround.is_alive onClicked: { dialoqueStartChannelScan.open_channel_scan_dialoque() } + SequentialAnimation { + running: true + loops: 4 + id: anim_find_air_unit + // Expand the button + PropertyAnimation { + target: b_find_air_unit + property: "scale" + to: 1.5 + duration: 200 + easing.type: Easing.InOutQuad + } + // Shrink back to normal + PropertyAnimation { + target: b_find_air_unit + property: "scale" + to: 1.0 + duration: 200 + easing.type: Easing.InOutQuad + } + } } } RowLayout{ @@ -636,6 +637,11 @@ and automatically connect. Otherwise, use the 'FIND AIR UNIT' feature to scan al } } } + PollutionChartView{ + width: parent.width + height: rowHeight * 4; + id: pollution_chart_view + } } } } diff --git a/qml/ui/configpopup/openhd_settings/PollutionChartView.qml b/qml/ui/configpopup/openhd_settings/PollutionChartView.qml new file mode 100644 index 000000000..21dfd6784 --- /dev/null +++ b/qml/ui/configpopup/openhd_settings/PollutionChartView.qml @@ -0,0 +1,60 @@ +import QtQuick 2.0 + +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Dialogs 1.0 +import QtQuick.Controls.Material 2.12 +import QtQuick.Controls.Styles 1.4 + +import Qt.labs.settings 1.0 + +import OpenHD 1.0 + +import "../../../ui" as Ui +import "../../elements" + +import QtCharts 2.0 + +ChartView { + title: "WiFi pollution estimate" + width: parent.width + height: rowHeight * 3 + legend.alignment: Qt.AlignBottom + antialiasing: true + + + function update(){ + update_pollution_graph(); + } + + function update_pollution_graph(){ + //const frequencies_list = _wbLinkSettingsHelper.get_pollution_qstringlist(); + //bar_axis_x.categories=frequencies_list; + //const supported_frequencies = _wbLinkSettingsHelper.get_supported_frequencies(); + const supported_frequencies = _wbLinkSettingsHelper.get_supported_frequencies_filtered(1); + var categories = _wbLinkSettingsHelper.pollution_frequencies_int_to_qstringlist(supported_frequencies); + var values = _wbLinkSettingsHelper.pollution_frequencies_int_get_pollution(supported_frequencies); + bar_axis_x.categories=categories; + bar_set.values=values; + /*const supported_frequencies=_wbLinkSettingsHelper.get_supported_frequencies(); + bar_axis_x.categories.clear(); + for(var i=0;i Date: Tue, 10 Oct 2023 01:49:46 +0200 Subject: [PATCH 04/81] pollution chart improvements --- app/telemetry/settings/pollutionhelper.cpp | 18 +++++++++++++++++- .../DIaloqueStartChannelScan.qml | 7 ++++--- .../MavlinkOpenHDWBParamPanel.qml | 2 +- .../openhd_settings/PollutionChartView.qml | 3 +++ 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/app/telemetry/settings/pollutionhelper.cpp b/app/telemetry/settings/pollutionhelper.cpp index 7c6f5ae9f..0ee7750e7 100644 --- a/app/telemetry/settings/pollutionhelper.cpp +++ b/app/telemetry/settings/pollutionhelper.cpp @@ -13,12 +13,28 @@ PollutionHelper& PollutionHelper::instance() return instance; } +static std::vector normalize(const std::vector &values){ + int max=0; + for(const auto& value:values){ + max=std::max(max,value.n_foreign_packets); + } + if(max==0)return values; + std::vector ret; + for(auto value:values){ + value.n_foreign_packets=value.n_foreign_packets*100 / max; + ret.push_back(value); + } + return ret; + +} void PollutionHelper::threadsafe_update(const std::vector &values) { + const auto normalized=normalize(values); std::lock_guard lock(m_pollution_elements_mutex); m_pollution_elements.clear(); - for(const auto& value:values){ + //for(const auto& value:values){ + for(const auto& value:normalized){ m_pollution_elements[value.frequency_mhz]=value; //qDebug()<<"Value:"< Date: Wed, 11 Oct 2023 19:31:24 +0200 Subject: [PATCH 05/81] seperate logging OpenHD ground / air --- app/logging/logmessagesmodel.cpp | 17 +++-- app/logging/logmessagesmodel.h | 4 +- app/main.cpp | 9 ++- app/telemetry/models/aohdsystem.cpp | 12 ++- app/telemetry/models/camerastreammodel.cpp | 2 +- app/videostreaming/gstreamer/gst_helper.hpp | 2 +- .../vscommon/ExternalDecodeService.hpp | 2 +- qml/qml.qrc | 19 ++--- .../configpopup/log/LogMessagesStatusView.qml | 74 +++---------------- qml/ui/configpopup/log/LogMessagesView.qml | 74 +++++++++++++++++++ 10 files changed, 130 insertions(+), 85 deletions(-) create mode 100644 qml/ui/configpopup/log/LogMessagesView.qml diff --git a/app/logging/logmessagesmodel.cpp b/app/logging/logmessagesmodel.cpp index 91c218b2a..c1db7e0ea 100644 --- a/app/logging/logmessagesmodel.cpp +++ b/app/logging/logmessagesmodel.cpp @@ -7,16 +7,23 @@ #include "hudlogmessagesmodel.h" -LogMessagesModel &LogMessagesModel::instanceOHD() + +LogMessagesModel &LogMessagesModel::instanceGround() +{ + static LogMessagesModel instance; + return instance; +} + +LogMessagesModel &LogMessagesModel::instanceOHDAir() { - static LogMessagesModel* instance=new LogMessagesModel(); - return *instance; + static LogMessagesModel instance; + return instance; } LogMessagesModel &LogMessagesModel::instanceFC() { - static LogMessagesModel* instance_fc=new LogMessagesModel(); - return *instance_fc; + static LogMessagesModel instance; + return instance; } LogMessagesModel::LogMessagesModel(QObject *parent) : diff --git a/app/logging/logmessagesmodel.h b/app/logging/logmessagesmodel.h index 3a5fb9423..578d15e5e 100644 --- a/app/logging/logmessagesmodel.h +++ b/app/logging/logmessagesmodel.h @@ -17,8 +17,8 @@ class LogMessagesModel : public QAbstractListModel { Q_OBJECT public: - // Instance for all OpenHD air / ground messages - static LogMessagesModel& instanceOHD(); + static LogMessagesModel& instanceGround(); + static LogMessagesModel& instanceOHDAir(); // We have a seperate model for the FC log messages static LogMessagesModel& instanceFC(); diff --git a/app/main.cpp b/app/main.cpp index 490b1b38a..feef7100c 100755 --- a/app/main.cpp +++ b/app/main.cpp @@ -272,8 +272,11 @@ int main(int argc, char *argv[]) { engine.rootContext()->setContextProperty("_qrenderstats", &QRenderStats::instance()); - engine.rootContext()->setContextProperty("_ohdlogMessagesModel", &LogMessagesModel::instanceOHD()); - engine.rootContext()->setContextProperty("_fclogMessagesModel", &LogMessagesModel::instanceFC()); + //engine.rootContext()->setContextProperty("_ohdlogMessagesModel", &LogMessagesModel::instanceOHD()); + //engine.rootContext()->setContextProperty("_fclogMessagesModel", &LogMessagesModel::instanceFC()); + engine.rootContext()->setContextProperty("_logGround", &LogMessagesModel::instanceGround()); + engine.rootContext()->setContextProperty("_logOpenhdAir", &LogMessagesModel::instanceOHDAir()); + engine.rootContext()->setContextProperty("_logFC", &LogMessagesModel::instanceFC()); engine.rootContext()->setContextProperty("_hudLogMessagesModel", &HUDLogMessagesModel::instance()); // Telemetry - first all the models @@ -373,7 +376,7 @@ int main(int argc, char *argv[]) { QRenderStats::instance().register_to_root_window(engine); - LogMessagesModel::instanceOHD().addLogMessage("QOpenHD","running"); + LogMessagesModel::instanceGround().addLogMessage("QOpenHD","running"); const int retval = app.exec(); return retval; diff --git a/app/telemetry/models/aohdsystem.cpp b/app/telemetry/models/aohdsystem.cpp index beba364e2..08b0923f5 100644 --- a/app/telemetry/models/aohdsystem.cpp +++ b/app/telemetry/models/aohdsystem.cpp @@ -192,7 +192,11 @@ bool AOHDSystem::process_message(const mavlink_message_t &msg) mavlink_statustext_t parsedMsg; mavlink_msg_statustext_decode(&msg,&parsedMsg); auto tmp=Telemetryutil::statustext_convert(parsedMsg); - LogMessagesModel::instanceOHD().addLogMessage(m_is_air ? "OHD[A]":"OHD[G]",tmp.message.c_str(),tmp.level); + if(m_is_air){ + LogMessagesModel::instanceOHDAir().addLogMessage("OHD[A]",tmp.message.c_str(),tmp.level); + }else{ + LogMessagesModel::instanceGround().addLogMessage("OHD[G]",tmp.message.c_str(),tmp.level); + } // Notify user in HUD of external device connect / disconnect events if(tmp.message.find("External device") != std::string::npos){ HUDLogMessagesModel::instance().add_message(tmp.level,tmp.message.c_str()); @@ -500,6 +504,12 @@ void AOHDSystem::update_alive_status_with_hud_message(bool alive) message << "disconnected"; HUDLogMessagesModel::instance().add_message_warning(message.str().c_str()); } + if(!m_is_air){ + LogMessagesModel::instanceGround().add_message_debug("QOpenHD",message.str().c_str()); + }else{ + LogMessagesModel::instanceOHDAir().add_message_debug("QOpenHD",message.str().c_str()); + } + set_is_alive(alive); } } diff --git a/app/telemetry/models/camerastreammodel.cpp b/app/telemetry/models/camerastreammodel.cpp index baa938b57..e85af8de0 100644 --- a/app/telemetry/models/camerastreammodel.cpp +++ b/app/telemetry/models/camerastreammodel.cpp @@ -74,7 +74,7 @@ void CameraStreamModel::update_mavlink_openhd_stats_wb_video_air(const mavlink_o if(m_n_mismatch_has_been_logged<10){ std::stringstream ss; ss<<"Set/ Measured encoder bitrate mismatch >"< - + ../translations/QOpenHD_en.qm resources/cursors/arrow_512_green.png resources/cursors/arrow_512_transparent.png resources/cursors/arrow_512_white.png resources/cursors/hand_white.png - + ../translations/QOpenHD_de.qm - + ../translations/QOpenHD_ru.qm - + ../translations/QOpenHD_es.qm - + ../translations/QOpenHD_fr.qm - + ../translations/QOpenHD_nl.qm - + ../translations/QOpenHD_ro.qm - + ../translations/QOpenHD_it.qm - + ../translations/QOpenHD_zh.qm @@ -260,5 +260,6 @@ ui/elements/ButtonDisconnected.qml ui/configpopup/status/DialoqueNotAlive.qml ui/configpopup/openhd_settings/PollutionChartView.qml + ui/configpopup/log/LogMessagesView.qml diff --git a/qml/ui/configpopup/log/LogMessagesStatusView.qml b/qml/ui/configpopup/log/LogMessagesStatusView.qml index 49bed9bea..8a408f04f 100644 --- a/qml/ui/configpopup/log/LogMessagesStatusView.qml +++ b/qml/ui/configpopup/log/LogMessagesStatusView.qml @@ -15,7 +15,6 @@ Item { Layout.fillHeight: true Layout.fillWidth: true - property int rowHeight: 64 property int elementHeight: 48 property int elementComboBoxWidth: 300 @@ -24,14 +23,14 @@ Item { id: selectItemInStackLayoutBar width: parent.width TabButton { - text: qsTr("LOG OpenHD Air/Gnd") + text: qsTr("LOG GND") + } + TabButton { + text: qsTr("LOG OpenHD AIR") } TabButton { text: qsTr("LOG FC") } - //TabButton { - // text: qsTr("LOG OpenHD Ground") - //} } // placed right below the top bar @@ -42,66 +41,17 @@ Item { anchors.left: selectItemInStackLayoutBar.left anchors.bottom: parent.bottom currentIndex: selectItemInStackLayoutBar.currentIndex - Rectangle { - color: Qt.rgba(0.2, 0.2, 0.2, 1.0) - Rectangle { - width: parent.width - 24 - height: parent.height - 24 - anchors.centerIn: parent - color: Qt.rgba(0.2, 0.2, 0.2, 1.0) - // Uses the c++ logmessagemodel under app/logging/logmessagesmodel - ListView { - id: logMessagesModelParentListView - width: parent.width - height: parent.height-12 - model: _ohdlogMessagesModel - delegate: - Rectangle { - color: Qt.rgba(0.2, 0.2, 0.2, 1.0) - height: childrenRect.height - width: logMessagesModelParentListView.width //parent.width for some reason we cannot just use parent.width here - - Text { - id: tagView - text: model.tag - color: model.severity_color - anchors { left:parent.left } - } - Text { - text: model.message - color: "#fff" - anchors { left:tagView.right; verticalCenter: tagView.verticalCenter; leftMargin: 5 } - } - } - } + LogMessagesView{ + m_log_model: _logGround + } - // Uses the c++ logmessagemodel under app/logging/logmessagesmodel - ListView { - id: logMessagesModelFCParentListView - width: parent.width - height: parent.height - model: _fclogMessagesModel - delegate: - Rectangle { - color: Qt.rgba(0.2, 0.2, 0.2, 1.0) - height: childrenRect.height - width: logMessagesModelFCParentListView.width //parent.width for some reason we cannot just use parent.width here + LogMessagesView{ + m_log_model: _logOpenhdAir + } - Text { - id: tagViewFC - text: model.tag - color: model.severity_color - anchors { left:parent.left } - } - Text { - text: model.message - anchors { left:tagViewFC.right; verticalCenter: tagViewFC.verticalCenter; leftMargin: 5 } - } - } - } - // TODO Fetch OpenHD log via journalctl + why the fuck is the second tab invisible - } + LogMessagesView{ + m_log_model: _logFC } } } diff --git a/qml/ui/configpopup/log/LogMessagesView.qml b/qml/ui/configpopup/log/LogMessagesView.qml new file mode 100644 index 000000000..e32cf3ffc --- /dev/null +++ b/qml/ui/configpopup/log/LogMessagesView.qml @@ -0,0 +1,74 @@ +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Dialogs 1.0 +import QtQuick.Controls.Material 2.12 + +import Qt.labs.settings 1.0 + +import OpenHD 1.0 + +import "../../../ui" as Ui +import "../../elements" + +// Uses the c++ logmessagemodel under app/logging/logmessagesmodel +Rectangle{ + width: parent.width + height: parent.height + //color: Qt.rgba(0.2, 0.2, 0.2, 1.0) + color: "#eaeaea" + //color: "transparent" + + // Overwritten in implementation + property var m_log_model : _logQOpenHD + + ScrollView{ + width: parent.width + height: parent.height + anchors.top: parent.top + contentHeight: baseLogMessagesView.height + clip: true + //ScrollBar.vertical.policy: ScrollBar.AlwaysOn + ScrollBar.vertical.interactive: true + + ListView { + id: baseLogMessagesView + width: parent.width + //height: parent.height + model: m_log_model + + delegate: + Rectangle { + //color: Qt.rgba(0.2, 0.2, 0.2, 1.0) + //color: "#808080" + //opacity: 0.3 + //color: "#eaeaea" + //color: "#FF0000" + //color: "#D0A197" + //color: "#808080" + color: "white" + radius: 10 + + height: 28 + width: baseLogMessagesView.width //parent.width for some reason we cannot just use parent.width here + + Text { + id: tagViewFC + text: model.tag + color: model.severity_color + anchors { left:parent.left } + verticalAlignment: Text.AlignVCenter + height: parent.height + opacity: 1.0 + } + Text { + text: model.message + anchors { left:tagViewFC.right; verticalCenter: tagViewFC.verticalCenter; leftMargin: 5 } + verticalAlignment: Text.AlignVCenter + height: parent.height + opacity: 1.0 + } + } + } + } +} From c4640785e0348a715fb1ebe83533806e333de8d7 Mon Sep 17 00:00:00 2001 From: consti10 Date: Sun, 15 Oct 2023 22:15:59 +0200 Subject: [PATCH 06/81] wb link settings - better use available space and group things --- app/telemetry/models/aohdsystem.cpp | 26 +- app/telemetry/models/aohdsystem.h | 3 + app/telemetry/models/wificard.h | 2 + .../settings/wblinksettingshelper.cpp | 13 +- app/telemetry/settings/wblinksettingshelper.h | 9 +- qml/main.qml | 4 +- qml/qml.qrc | 3 + .../dev/AppDeveloperStatsPanel.qml | 252 +++++----- .../openhd_settings/ChangeTxPowerPopup.qml | 297 +++++++++++ .../ChannelScanProgressView.qml | 114 +++++ .../DialoqueFreqChangeArmed.qml | 8 +- .../DialoqueFreqChangeGndOnly.qml | 8 +- .../MavlinkAllSettingsPanel.qml | 2 +- .../MavlinkOpenHDWBParamPanel.qml | 33 +- .../MavlinkOpenHDWBParamPanel2.qml | 468 ++++++++++++++++++ .../openhd_settings/PollutionChartView.qml | 120 +++-- 16 files changed, 1155 insertions(+), 207 deletions(-) create mode 100644 qml/ui/configpopup/openhd_settings/ChangeTxPowerPopup.qml create mode 100644 qml/ui/configpopup/openhd_settings/ChannelScanProgressView.qml create mode 100644 qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml diff --git a/app/telemetry/models/aohdsystem.cpp b/app/telemetry/models/aohdsystem.cpp index 08b0923f5..471d759cc 100644 --- a/app/telemetry/models/aohdsystem.cpp +++ b/app/telemetry/models/aohdsystem.cpp @@ -233,8 +233,15 @@ bool AOHDSystem::process_message(const mavlink_message_t &msg) process_sys_status1(parsed); consumed=true; }break; + case MAVLINK_MSG_ID_OPENHD_WIFBROADCAST_GND_OPERATING_MODE:{ + if(m_is_air) qDebug()<<"Message mismatch"; // only ground reports operating mode + mavlink_openhd_wifbroadcast_gnd_operating_mode_t parsed; + mavlink_msg_openhd_wifbroadcast_gnd_operating_mode_decode(&msg,&parsed); + process_op_mode(parsed); + consumed=true; + }break; default:{ - + qDebug()<<"Unknown openhd message type"; }break; /*case MAVLINK_MSG_ID_OPENHD_LOG_MESSAGE:{ mavlink_openhd_log_message_t parsedMsg; @@ -302,17 +309,6 @@ void AOHDSystem::process_x1(const mavlink_openhd_stats_monitor_mode_wifi_link_t set_curr_rx_packet_loss_perc(msg.curr_rx_packet_loss_perc); set_count_tx_inj_error_hint(msg.count_tx_inj_error_hint); set_count_tx_dropped_packets(msg.count_tx_dropped_packets); - // only on ground - /*ABCif(! m_is_air){ - for(int i=0;i=0 && active_tx_idx m_last_heartbeat_ms = -1; std::atomic m_last_message_ms= -1; diff --git a/app/telemetry/models/wificard.h b/app/telemetry/models/wificard.h index 65390f13f..1b0dd89ba 100644 --- a/app/telemetry/models/wificard.h +++ b/app/telemetry/models/wificard.h @@ -22,6 +22,8 @@ class WiFiCard : public QObject L_RO_PROP(QString,tx_power_unit,set_tx_power_unit,"N/A"); L_RO_PROP(QString,tx_power_current_str,set_tx_power_current_str,"N/A"); L_RO_PROP(int,tx_power_armed,set_tx_power_armed,-1) + // Shows disabled if no special armed tx power is set + L_RO_PROP(QString,tx_power_armed_str,set_tx_power_armed_str,"DISABLED") L_RO_PROP(int,tx_power_disarmed,set_tx_power_disarmed,-1) L_RO_PROP(int,n_received_packets_rolling,set_n_received_packets_rolling,0) // A card might have more than one antenna diff --git a/app/telemetry/settings/wblinksettingshelper.cpp b/app/telemetry/settings/wblinksettingshelper.cpp index c0986abdd..6c59897c3 100644 --- a/app/telemetry/settings/wblinksettingshelper.cpp +++ b/app/telemetry/settings/wblinksettingshelper.cpp @@ -33,8 +33,7 @@ WBLinkSettingsHelper& WBLinkSettingsHelper::instance() bool WBLinkSettingsHelper::start_analyze_channels() { if(OHDAction::instance().send_command_analyze_channels_blocking()){ - set_gnd_progress_perc(0); - set_text_for_qml("Analyzing"); + set_analyze_progress_perc(0); return true; } return false; @@ -43,8 +42,8 @@ bool WBLinkSettingsHelper::start_analyze_channels() bool WBLinkSettingsHelper::start_scan_channels(int freq_bands,int channel_widths) { if(OHDAction::instance().send_command_start_scan_channels_blocking(freq_bands,channel_widths)){ - set_gnd_progress_perc(0); - set_text_for_qml("Scanning"); + set_scan_progress_perc(0); + set_scanning_text_for_ui("SCANNING"); return true; } return false; @@ -144,8 +143,6 @@ void WBLinkSettingsHelper::process_message_openhd_wifibroadcast_analyze_channels ss<<(int)msg.progress_perc<<"%"; } qDebug()<ui/configpopup/status/DialoqueNotAlive.qml ui/configpopup/openhd_settings/PollutionChartView.qml ui/configpopup/log/LogMessagesView.qml + ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml + ui/configpopup/openhd_settings/ChannelScanProgressView.qml + ui/configpopup/openhd_settings/ChangeTxPowerPopup.qml diff --git a/qml/ui/configpopup/dev/AppDeveloperStatsPanel.qml b/qml/ui/configpopup/dev/AppDeveloperStatsPanel.qml index 1d80f71f6..cf06d9602 100644 --- a/qml/ui/configpopup/dev/AppDeveloperStatsPanel.qml +++ b/qml/ui/configpopup/dev/AppDeveloperStatsPanel.qml @@ -34,157 +34,153 @@ Rectangle { return ret; } - ColumnLayout { - Layout.fillWidth: true - Layout.minimumHeight: 30 - spacing: 6 - anchors.top: parent.top - anchors.left: parent.left - anchors.margins: 10 + ScrollView{ + width: parent.width + height: parent.height + anchors.centerIn: parent + contentHeight: main_column_layout.height + contentWidth: main_column_layout.width + //ScrollBar.vertical.policy: ScrollBar.AlwaysOn + ScrollBar.vertical.interactive: true - Button { - height: 24 - text: "Restart local OHD service" - onClicked: { - _qopenhd.restart_local_oenhd_service() + + ColumnLayout { + id: main_column_layout + Layout.fillWidth: true + Layout.minimumHeight: 30 + spacing: 6 + anchors.top: parent.top + anchors.left: parent.left + anchors.margins: 10 + + Text { + id: test1 + text: qsTr("Art Horizon mavlink update rate:" + _fcMavlinkSystem.curr_update_rate_mavlink_message_attitude + " Hz") + Layout.leftMargin: 12 } - } - Button { - id: local_ip_button - height: 24 - text: "Show local IP" - onClicked: { - var text = _qopenhd.show_local_ip() - local_ip_button.text = text + Text { + id: tele_in + text: qsTr("Tele in" + _mavlinkTelemetry.telemetry_pps_in + " pps") + Layout.leftMargin: 12 } - } - Button { - id: exp_set_rates - height: 24 - text: "Set Tele rates" - onClicked: { - _mavlinkTelemetry.re_apply_rates() + // air + Text { + id: test2 + text: qsTr("video0 FEC encode: " + _cameraStreamModelPrimary.curr_fec_encode_time_avg_min_max) + Layout.leftMargin: 12 } - } - - Card { - id: infoBox3 - height: 275 - Layout.topMargin: 15 - Layout.leftMargin: 15 - Layout.rightMargin: 15 - width: 480 - cardName: qsTr("Debug") - cardBody: ColumnLayout { - spacing: 6 - Layout.topMargin: 15 - Layout.leftMargin: 15 - Layout.rightMargin: 15 - Text { - id: test1 - text: qsTr("Art Horizon mavlink update rate:" + _fcMavlinkSystem.curr_update_rate_mavlink_message_attitude + " Hz") - Layout.leftMargin: 12 - } - Text { - id: tele_in - text: qsTr("Tele in" + _mavlinkTelemetry.telemetry_pps_in + " pps") - Layout.leftMargin: 12 - } - // air - Text { - id: test2 - text: qsTr("video0 FEC encode: " + _cameraStreamModelPrimary.curr_fec_encode_time_avg_min_max) - Layout.leftMargin: 12 - } - Text { - id: testX - text: qsTr("video0 TX delay: " + _cameraStreamModelPrimary.curr_time_until_tx_min_max_avg) - Layout.leftMargin: 12 - } - Text { - id: test4 - text: qsTr("video0 FEC block length: " + _cameraStreamModelPrimary.curr_fec_block_length_min_max_avg) - Layout.leftMargin: 12 - } - // ground - Text { - id: test3 - 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 - } + Text { + id: testX + text: qsTr("video0 TX delay: " + _cameraStreamModelPrimary.curr_time_until_tx_min_max_avg) + Layout.leftMargin: 12 } - } - - RowLayout { - width: parent.width - height: 200 - visible: _qopenhd.is_linux() - Button { - text: "Sysctl start openhd" - onClicked: { - _qopenhd.sysctl_openhd(0); - } + Text { + id: test4 + text: qsTr("video0 FEC block length: " + _cameraStreamModelPrimary.curr_fec_block_length_min_max_avg) + Layout.leftMargin: 12 + } + // ground + Text { + id: test3 + 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 { - text: "Sysctl stop openhd" + height: 24 + text: "Restart local OHD service" onClicked: { - _qopenhd.sysctl_openhd(1); + _qopenhd.restart_local_oenhd_service() } } Button { - text: "Sysctl enable openhd" + id: local_ip_button + height: 24 + text: "Show local IP" onClicked: { - _qopenhd.sysctl_openhd(2); + var text = _qopenhd.show_local_ip() + local_ip_button.text = text } } Button { - text: "Sysctl disable openhd" + id: exp_set_rates + height: 24 + text: "Set Tele rates" onClicked: { - _qopenhd.sysctl_openhd(3); + _mavlinkTelemetry.re_apply_rates() } } - } - RowLayout { - width: parent.width - - Button { - font.capitalization: Font.MixedCase - text: qsTr("DEV-Restart QOpenHD") - onPressed: { - qopenhdservicedialoque.open_dialoque(0) + RowLayout { + width: parent.width + height: 200 + visible: _qopenhd.is_linux() + Button { + text: "Sysctl start openhd" + onClicked: { + _qopenhd.sysctl_openhd(0); + } + } + Button { + text: "Sysctl stop openhd" + onClicked: { + _qopenhd.sysctl_openhd(1); + } + } + Button { + text: "Sysctl enable openhd" + onClicked: { + _qopenhd.sysctl_openhd(2); + } + } + Button { + text: "Sysctl disable openhd" + onClicked: { + _qopenhd.sysctl_openhd(3); + } } } - Button { - font.capitalization: Font.MixedCase - text: qsTr("DEV-Cancel QOpenHD") - onPressed: { - qopenhdservicedialoque.open_dialoque(1) + + RowLayout { + width: parent.width + + Button { + font.capitalization: Font.MixedCase + text: qsTr("DEV-Restart QOpenHD") + onPressed: { + qopenhdservicedialoque.open_dialoque(0) + } + } + Button { + font.capitalization: Font.MixedCase + text: qsTr("DEV-Cancel QOpenHD") + onPressed: { + qopenhdservicedialoque.open_dialoque(1) + } + } + Item { + // Padding } } - Item { - // Padding - } } } QOpenHDServiceDialoque{ diff --git a/qml/ui/configpopup/openhd_settings/ChangeTxPowerPopup.qml b/qml/ui/configpopup/openhd_settings/ChangeTxPowerPopup.qml new file mode 100644 index 000000000..dc3f86fc1 --- /dev/null +++ b/qml/ui/configpopup/openhd_settings/ChangeTxPowerPopup.qml @@ -0,0 +1,297 @@ +import QtQuick 2.0 + +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Dialogs 1.0 +import QtQuick.Controls.Material 2.12 +import QtQuick.Controls.Styles 1.4 + +import Qt.labs.settings 1.0 + +import OpenHD 1.0 + +import "../../../ui" as Ui +import "../../elements" + +import QtCharts 2.0 + +Rectangle{ + width: parent.width + height: parent.height /2 + anchors.bottom: parent.bottom + anchors.left: parent.left + color: "#8cbfd7f3" + + property bool m_is_air: false + + property int m_user_selected_card_manufacturer: -1; + + function open(){ + if(_fcMavlinkSystem.is_alive && _fcMavlinkSystem.armed){ + _qopenhd.show_toast("WARNING: Changing TX power while armed is not recommended !"); + } + var card_chipset_type=get_chipset_type(); + if(!card_chipset_type==0 || card_chipset_type==1){ + _messageBoxInstance.set_text_and_show("Changing tx power is only possible on openhd supported cards."); + return; + } + visible=true; + enabled=true; + } + + function close(){ + visible=false; + enabled=false; + } + + function get_chipset_type(){ + if(m_is_air){ + return _wifi_card_air.card_type; + } + return _wifi_card_gnd0.card_type; + } + + function get_card_chipset_str(){ + var chipset=get_chipset_type(); + if(chipset==0){ + return "RTL88XXAU"; + }else if(chipset==1){ + return "RTL88XXBU"; + } + return "ERROR"; + } + // Should never show up ! + ListModel{ + id: model_error + ListElement {title: "ERROR"; value: -1} + } + + ListModel{ + id: model_rtl8812au_manufacturers + ListElement {title: "SELECT MANUFACTURER"; value: -1} + ListElement {title: "ASUS"; value: 0} + ListElement {title: "ALIEXPRESS"; value: 1} + ListElement {title: "OTHER"; value: 2} + } + ListModel{ + id: model_rtl8812bu_manufacturers + ListElement {title: "SELECT MANUFACTURER"; value: -1} + ListElement {title: "COMFAST"; value: 0} + ListElement {title: "OTHER"; value: 1} + } + + function get_model_manufacturer_for_chip_type(){ + var chip_type=get_chipset_type(); + if(chip_type==0){ + return model_rtl8812au_manufacturers; + }else if(chip_type==1){ + return model_rtl8812bu_manufacturers; + } + return model_error; + } + + // TX power choices for each chipset / manufacturer + ListModel{ + id: model_rtl8812au_manufacturer_asus_txpower + ListElement {title: "Please select"; value: -1} + ListElement {title: "LOW [22] ~20mW (DEFAULT) "; value: 22} + ListElement {title: "MEDIUM [37] ~100mW "; value: 37} + ListElement {title: "HIGH [53] ~320mW "; value: 53} + ListElement {title: "MAX1 [58] ~420mW (MCS<=2!)"; value: 58} + ListElement {title: "MAX2 [63] ~500mW (MCS<=2!)"; value: 63} + } + ListModel{ + id: model_rtl8812au_manufacturer_aliexpress_hp + ListElement {title: "Please select"; value: -1} + ListElement {title: "LOW [16]"; value: 16} + ListElement {title: "MEDIUM [22]"; value: 22} + ListElement {title: "HIGH [24]"; value: 24} + ListElement {title: "MAX [26]"; value: 26} + } + ListModel{ + id: model_rtl8812au_manufacturer_generic + ListElement {title: "Please select"; value: -1} + ListElement {title: "[22] (DANGER,ARBITRARY)"; value: 22} + ListElement {title: "[37] (DANGER,ARBITRARY)"; value: 37} + ListElement {title: "[53] (DANGER,ARBITRARY)"; value: 53} + ListElement {title: "[58] (DANGER,ARBITRARY)"; value: 58} + ListElement {title: "[63] (DANGER,ARBITRARY)"; value: 63} + } + // RTL8812BU begin + ListModel{ + id: model_rtl8812bu_manufacturer_comfast + ListElement {title: "Please select"; value: -1} + ListElement {title: "~25mW"; value: 25} + ListElement {title: "~100mW"; value: 100} + ListElement {title: "~200mW"; value: 200} + ListElement {title: "~300mW"; value: 300} + } + ListModel{ + id: model_rtl8812bu_manufacturer_generic + ListElement {title: "Please select"; value: -1} + ListElement {title: "25mW (maybe)"; value: 25} + ListElement {title: "100mW (maybe)"; value: 100} + ListElement {title: "<=300mW (maybe)"; value: 300} + ListElement {title: "<=1000mW (maybe)"; value: 1000} + ListElement {title: "<=20000mW (maybe)"; value: 2000} + } + + function get_model_txpower_for_chip_type_manufacturer(){ + var chip_type=get_chipset_type(); + var manufacturer=m_user_selected_card_manufacturer; + if(manufacturer<0){ + return model_error; + } + if(chip_type==0){ + // RTL8812AU + if(manufacturer==0){ + return model_rtl8812au_manufacturer_asus_txpower; + }else if(manufacturer==1){ + return model_rtl8812au_manufacturer_aliexpress_hp; + } + return model_rtl8812au_manufacturer_generic; + }else if(chip_type==1){ + // RTL8812BU + if(m_card_manufacturer_type==0){ + return model_rtl8812bu_manufacturer_comfast; + } + return model_rtl8812bu_manufacturer_generic; + } + return model_error; + } + + + function get_text_wifi_tx_power(){ + // "99 TPI DISARM: XX ARM: XX"; + if(m_is_air){ + if(!_wifi_card_air.alive) return "N/A"; + return ""+_wifi_card_air.tx_power+" "+_wifi_card_air.tx_power_unit+" DISARM:"+_wifi_card_air.tx_power_disarmed+" ARM:"+_wifi_card_air.tx_power_armed + } + if(!_wifi_card_gnd0.alive) return "N/A"; + return ""+_wifi_card_gnd0.tx_power+" "+_wifi_card_gnd0.tx_power_unit+" DISARM:"+_wifi_card_gnd0.tx_power_disarmed+" ARM:"+_wifi_card_gnd0.tx_power_armed + } + + // state 0: current state 1: disarmed state 2: armed + // + function get_current_tx_power_int(state){ + var card = m_is_air ? _wifi_card_air : _wifi_card_gnd0; + if(state==0){ + return card.tx_power; + }else if(state==1){ + return card.tx_power_disarmed; + } + return card.tx_power_armed; + } + function get_tx_power_unit(){ + if(m_is_air) return _wifi_card_air.tx_power_unit; + return _wifi_card_gnd0.tx_power_unit; + } + + ColumnLayout{ + id: bla1 + width: parent.width /3 + anchors.top: parent.top + anchors.left: parent.left + Text{ + text: m_is_air ? "AIR TX Power" : "GND TX power"; + } + Text{ + text: "YOUR CHIPSET:" +get_card_chipset_str() + } + + ComboBox { + Layout.fillWidth: true + leftPadding: 12 + rightPadding: 12 + id: comboBoxCardSelectManufacturer + model: get_model_manufacturer_for_chip_type() + textRole: "title" + onCurrentIndexChanged: { + var manufacturer=comboBoxCardSelectManufacturer.model.get(comboBoxCardSelectManufacturer.currentIndex).value; + m_user_selected_card_manufacturer=manufacturer; + } + } + Text{ + text: "CURRENT:"+get_current_tx_power_int(0)+" "+get_tx_power_unit(); + } + } + + ColumnLayout{ + id: bla2 + width: parent.width /3 + anchors.left: bla1.right + anchors.top: parent.top + Text{ + text: "DISARMED" + } + Text{ + text: ""+get_current_tx_power_int(1)+" "+get_tx_power_unit(); + } + ComboBox { + Layout.fillWidth: true + leftPadding: 12 + rightPadding: 12 + id: combo_box_txpower_disarmed + model: get_model_txpower_for_chip_type_manufacturer() + textRole: "title" + enabled: m_user_selected_card_manufacturer>=0; + } + Button{ + text: "APPLY" + enabled: m_user_selected_card_manufacturer>=0; + } + } + ColumnLayout{ + width: parent.width /3 + anchors.right: parent.right + anchors.top: parent.top + Text{ + text: "ARMED" + } + Text{ + text: { + var power_int=get_current_tx_power_int(2); + if(power_int==0) return "DISABLED"; + return ""+get_current_tx_power_int(2)+" "+get_tx_power_unit(); + } + } + ComboBox { + Layout.fillWidth: true + leftPadding: 12 + rightPadding: 12 + id: combo_box_txpower_armed + model: get_model_txpower_for_chip_type_manufacturer() + textRole: "title" + enabled: m_user_selected_card_manufacturer>=0; + } + + Button{ + text: "APPLY" + enabled: m_user_selected_card_manufacturer>=0; + } + } + + Button{ + text: "CLOSE" + anchors.top: parent.top + anchors.right: parent.right + onClicked: { + close() + } + } + Text{ + width: parent.width + height: parent.height / 2; + anchors.bottom: parent.bottom + anchors.left: parent.left + text: "WARNING: Selecting the wrong manufacturer and applying a tx power can destroy your card !"; + color: "red" + // Only on rtl8812au + //visible: get_chipset_type()==0; + fontSizeMode: Text.Fit + minimumPointSize: 10 + font.pointSize: 60 + } + +} diff --git a/qml/ui/configpopup/openhd_settings/ChannelScanProgressView.qml b/qml/ui/configpopup/openhd_settings/ChannelScanProgressView.qml new file mode 100644 index 000000000..0978d95ba --- /dev/null +++ b/qml/ui/configpopup/openhd_settings/ChannelScanProgressView.qml @@ -0,0 +1,114 @@ +import QtQuick 2.0 + +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Dialogs 1.0 +import QtQuick.Controls.Material 2.12 +import QtQuick.Controls.Styles 1.4 + +import Qt.labs.settings 1.0 + +import OpenHD 1.0 + +import "../../../ui" as Ui +import "../../elements" + +import QtCharts 2.0 + +Rectangle{ + width: parent.width + height: parent.height /2 + anchors.bottom: parent.bottom + anchors.left: parent.left + color: "#8cbfd7f3" + + function open(){ + visible=true + enabled=true + } + + function close(){ + visible=false; + enabled=false; + } + + ListModel{ + id: model_chann_to_scan + ListElement {title: "OpenHD [1-5] only (fast)"; value: 0} + ListElement {title: "All 2.4G channels (slow)"; value: 1} + ListElement {title: "All 5.8G channels (slow)"; value: 2} + } + + GridLayout{ + Layout.fillWidth: true + Layout.fillHeight: true + + ComboBox { + Layout.row: 0 + Layout.column: 0 + Layout.preferredWidth: 400 + Layout.minimumWidth: 100 + id: comboBoxWhichFrequencyToScan + model: model_chann_to_scan + textRole: "title" + Material.background: { + (comboBoxWhichFrequencyToScan.currentIndex===0) ? Material.Green : Material.Orange + } + onCurrentIndexChanged: { + } + enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0 + } + + Button{ + Layout.row: 0 + Layout.column: 1 + text: "START" + enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0 + onClicked: { + var how_many_freq_bands=comboBoxWhichFrequencyToScan.currentIndex + var how_many_bandwidths = 2; + console.log("Initate channel scan "+how_many_freq_bands+","+how_many_bandwidths) + var result = _wbLinkSettingsHelper.start_scan_channels(how_many_freq_bands,how_many_bandwidths) + if(result){ + _qopenhd.show_toast("Channel scan started, please wait",true) + }else{ + console.log("Cannot initiate channel scan"); + _qopenhd.show_toast("Busy,please try again later",true) + } + } + } + SimpleProgressBar{ + Layout.row: 1 + Layout.column: 0 + Layout.fillWidth: true + Layout.preferredHeight: 40 + Layout.preferredWidth: 400 + Layout.minimumWidth: 100 + impl_curr_progress_perc: _wbLinkSettingsHelper.scan_progress_perc + } + ButtonIconInfo{ + Layout.row: 1 + Layout.column: 1 + onClicked: { + _messageBoxInstance.set_text_and_show("Initiate Channel Scan (Find a running air unit). Similar to analogue TX / RX, this listens on each channel for a short time"+ + " to find a running openhd air unit."+ + "Quick if you are only using the 5 OpenHD recommended channels, otherwise"+ + " please specify the generic band and give it some time (There are a ton of possible channels, especially in 5.8G)") + } + } + Text{ + Layout.row: 2 + Layout.column: 0 + text: _wbLinkSettingsHelper.scanning_text_for_ui + } + } + Button{ + anchors.top: parent.top + anchors.right: parent.right + text: "CLOSE" + onClicked: { + close() + } + } +} diff --git a/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeArmed.qml b/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeArmed.qml index a28489a6e..f76ba635f 100644 --- a/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeArmed.qml +++ b/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeArmed.qml @@ -20,11 +20,17 @@ Card { property int m_wanted_frequency: -1 + function close(){ + visible=false; + enabled=false; + } + function initialize_and_show_frequency(frequency){ m_wanted_frequency=frequency m_wanted_channel_width=-1 m_type=0; - dialoqueFreqChangeArmed.visible=true + visible=true; + enabled=true; } function get_card_title_string(){ diff --git a/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeGndOnly.qml b/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeGndOnly.qml index b615df7b2..70e4dddbe 100644 --- a/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeGndOnly.qml +++ b/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeGndOnly.qml @@ -25,11 +25,17 @@ Card { property string m_original_error_message: "" + function close(){ + visible=false; + enabled=false; + } + function initialize_and_show_frequency(frequency,error_message){ m_wanted_frequency=frequency m_index=0 m_original_error_message=error_message; - dialoqueChangeFrequency.visible=true + visible=true; + enabled=true; } property string m_info_string_frequency: "Please use the channel scan to find your air unit, then change frequency."+ diff --git a/qml/ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml b/qml/ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml index f2275d226..41a233cfb 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml +++ b/qml/ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml @@ -63,7 +63,7 @@ Rectangle { anchors.bottom: parent.bottom currentIndex: selectItemInStackLayoutBar.currentIndex - MavlinkOpenHDWBParamPanel{ + MavlinkOpenHDWBParamPanel2{ //WBFrequencyPanel{ id: xX_WBLinkSettings } diff --git a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml index c129d4a75..f53f03a97 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml +++ b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml @@ -335,23 +335,6 @@ and automatically connect. Otherwise, use the 'FIND AIR UNIT' feature to scan al width: parent.width height: rowHeight*(7+4) - DIaloqueStartChannelScan{ - id: dialoqueStartChannelScan - } - DialoqueFreqChangeGndOnly{ - id: dialoqueFreqChangeGndOnly - } - DialoqueFreqChangeArmed{ - id: dialoqueFreqChangeArmed - } - DialoqueStartAnalyzeChannels{ - id: dialoqueAnalyzeChannels - } - - DialoqueChangeTxPower{ - id: txPowerDialoque - } - Column { id:wbParamColumn spacing: 0 @@ -645,4 +628,20 @@ and automatically connect. Otherwise, use the 'FIND AIR UNIT' feature to scan al } } } + DIaloqueStartChannelScan{ + id: dialoqueStartChannelScan + } + DialoqueFreqChangeGndOnly{ + id: dialoqueFreqChangeGndOnly + } + DialoqueFreqChangeArmed{ + id: dialoqueFreqChangeArmed + } + DialoqueStartAnalyzeChannels{ + id: dialoqueAnalyzeChannels + } + + DialoqueChangeTxPower{ + id: txPowerDialoque + } } diff --git a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml new file mode 100644 index 000000000..b14d51b0c --- /dev/null +++ b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml @@ -0,0 +1,468 @@ +import QtQuick 2.0 + +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Dialogs 1.0 +import QtQuick.Controls.Material 2.12 +import QtQuick.Controls.Styles 1.4 + +import Qt.labs.settings 1.0 + +import OpenHD 1.0 + +import "../../../ui" as Ui +import "../../elements" + +import QtCharts 2.0 + +// This is an extra screen for changing the frequency / channel width - +// They both need to match ! +Rectangle{ + width: parent.width + height: parent.height + property color m_background_color: "#8cbfd7f3" + + function user_quidance_animate_channel_scan(){ + console.log("User guidance animate channel scan"); + anim_find_air_unit.start() + } + + // https://stackoverflow.com/questions/41991438/how-do-i-find-a-particular-listelement-inside-a-listmodel-in-qml + // For the models above (model with value) try to find the index of the first item where model[i].value===value + function find_index(model,value){ + for(var i = 0; i < model.count; ++i) if (model.get(i).value===value) return i + return -1 + } + // try and update the combobox to the retrieved value(value != index) + function update_combobox(_combobox,_value){ + var _index=find_index(_combobox.model,_value) + if(_index >= 0){ + _combobox.currentIndex=_index; + } + } + + function fc_is_armed(){ + return _fcMavlinkSystem.armed + } + + ListModel{ + id: supported_frequencies_model + ListElement {title: "Unknown"; value:-1; radar: false; recommended: false; openhd_raceband_nr: -1} + } + + function show_popup_message(message){ + _messageBoxInstance.set_text_and_show(message) + } + + property bool m_simplify_enable:true + function create_list_model_supported(){ + supported_frequencies_model.clear() + //supported_frequencies_model.append({title: "Unknown", value: -1}) + const supported_frequencies=_wbLinkSettingsHelper.get_supported_frequencies(); + for(var i=0;i= 0; + }else{ + append_this_value=true; + } + if(append_this_value){ + supported_frequencies_model.append({title: text, value: frequency, radar:radar, recommended: recommended, openhd_raceband_nr: openhd_raceband}) + } + } + var index=find_index(supported_frequencies_model,_wbLinkSettingsHelper.curr_channel_mhz); + comboBoxFreq.model=supported_frequencies_model + if(index>=0){ + comboBoxFreq.currentIndex=index; + }else{ + comboBoxFreq.currentIndex=0; + console.log("Seems not to be a valid channel "+_wbLinkSettingsHelper.curr_channel_mhz) + } + } + + // We get notified every time we should re-build the model(s) and their current selection + property int m_ui_rebuild_models : _wbLinkSettingsHelper.ui_rebuild_models + onM_ui_rebuild_modelsChanged: { + console.log(" onM_ui_rebuild_modelsChanged: "+_wbLinkSettingsHelper.ui_rebuild_models); + function_rebuild_ui() + } + + function function_rebuild_ui(){ + console.log("function_rebuild_ui:"+_wbLinkSettingsHelper.ui_rebuild_models); + if(_wbLinkSettingsHelper.ui_rebuild_models<=0)return + create_list_model_supported(); + //update_pollution_graph(); + pollution_chart_view.update(); + } + + // + function close_all_dialoques(){ + pollution_chart_view.close() + channel_scan_progress_view.close(); + change_tx_power_popup.close(); + dialoqueFreqChangeGndOnly.close(); + dialoqueFreqChangeArmed.close(); + } + + Component.onCompleted: { + close_all_dialoques(); + } + // + + // ------------------- PART HELPER FOR CURRENT LOSS / POLLUTION / THROTTLE BEGIN ------------------- + // ------------------- PART HELPER FOR CURRENT LOSS / POLLUTION / THROTTLE END ------------------- + + + // Changes either the frequency or channel width + // This one need to be synced, so we have ( a bit complicated, but quite natural for the user) dialoque for the cases where we need to handle errors / show a warning + function change_frequency_sync_otherwise_handle_error(frequency_mhz,ignore_armed_state){ + console.log("change_frequency_sync_otherwise_handle_error: "+"FREQ:"+frequency_mhz+"Mhz"); + // Ground needs to be alive and well + if(!_ohdSystemGround.is_alive){ + _messageBoxInstance.set_text_and_show("Ground unit not alive",5); + return; + } + // Air needs to be alive and well - otherwise we show the "do you want to change gnd only" dialoque + if(!_ohdSystemAir.is_alive){ + var error_message_not_alive="AIR Unit not alive -" + dialoqueFreqChangeGndOnly.initialize_and_show_frequency(frequency_mhz,error_message_not_alive); + return; + } + // FC needs to be disarmed - otherwise show warning + const fc_currently_armed = (_fcMavlinkSystem.is_alive && _fcMavlinkSystem.armed)// || true; + if(fc_currently_armed && ignore_armed_state===false){ + dialoqueFreqChangeArmed.initialize_and_show_frequency(frequency_mhz) + return; + } + var result= _wbLinkSettingsHelper.change_param_air_and_ground_frequency(frequency_mhz); + if(result==0){ + var message="Succesfully set air and ground to FREQUENCY: "+frequency_mhz+"Mhz"; + _messageBoxInstance.set_text_and_show(message,5); + return; + }else if(result==-1){ + // Air unit rejected + _messageBoxInstance.set_text_and_show("Air unit does not support this value",5); + return; + }else if(result==-2){ + // Couldn't reach air unit + var error_message_not_reachable="Couldn't reach air unit -" + dialoqueFreqChangeGndOnly.initialize_and_show_frequency(frequency_mhz,error_message_not_reachable); + return; + } + // Really really bad + _messageBoxInstance.set_text_and_show("Something went wrong - please use 'FIND AIR UNIT' to fix"); + } + + function get_text_wifi_tx_power(air){ + // "99 TPI DISARM: XX ARM: XX"; + if(air){ + if(!_wifi_card_air.alive) return "N/A"; + return ""+_wifi_card_air.tx_power+" "+_wifi_card_air.tx_power_unit+" DISARM:"+_wifi_card_air.tx_power_disarmed+" ARM:"+_wifi_card_air.tx_power_armed + } + if(!_wifi_card_gnd0.alive) return "N/A"; + return ""+_wifi_card_gnd0.tx_power+" "+_wifi_card_gnd0.tx_power_unit+" DISARM:"+_wifi_card_gnd0.tx_power_disarmed+" ARM:"+_wifi_card_gnd0.tx_power_armed + } + + ScrollView { + id:mavlinkExtraWBParamPanel + width: parent.width-24 + height: parent.height-24 + anchors.centerIn: parent + contentHeight: main_column_layout.height + contentWidth: main_column_layout.width + //ScrollBar.vertical.policy: ScrollBar.AlwaysOn + ScrollBar.vertical.interactive: true + + ColumnLayout{ + Layout.fillWidth: true + Layout.fillHeight: true + id: main_column_layout + + + Rectangle { + id: frequency_area_layout_background + color: m_background_color + implicitWidth: frequency_area_layout.implicitWidth+5 + implicitHeight: frequency_area_layout.implicitHeight+5 + radius: 10 + + GridLayout { + id: frequency_area_layout + Layout.fillWidth: true + Layout.fillHeight: true + Layout.margins: 10 + + Text{ + Layout.row: 0 + Layout.column: 0 + text: "FREQUENCY / TOOLKIT" + font.bold: true + } + + ComboBox { + id: comboBoxFreq + model: supported_frequencies_model + textRole: "title" + implicitWidth: elementComboBoxWidth + currentIndex: 0 + delegate: ItemDelegate { + width: comboBoxFreq.width + contentItem: FreqComboBoxRow{ + m_main_text: title + m_selection_tpye: (value===_wbLinkSettingsHelper.curr_channel_mhz) ? 1 : 0 + m_is_2G: value > 3000 + m_2G_5G_show: value > 100 + m_show_radar: radar + m_show_good_channel: recommended + m_openhd_race_band: openhd_raceband_nr + } + highlighted: comboBoxFreq.highlightedIndex === index + } + Layout.row: 1 + Layout.column: 0 + } + Button{ + text: "APPLY" + id: buttonSwitchFreq + //enabled: false + onClicked: { + var selectedValue=supported_frequencies_model.get(comboBoxFreq.currentIndex).value + if(selectedValue<=100){ + _messageBoxInstance.set_text_and_show("Please select a valid frequency",5); + return; + } + change_frequency_sync_otherwise_handle_error(selectedValue,-1,false); + } + //Material.background: fc_is_armed() ? Material.Red : Material.Normal; + enabled: _wbLinkSettingsHelper.ui_rebuild_models>=0 && _ohdSystemGround.is_alive; + Layout.row: 1 + Layout.column: 1 + } + Switch{ + Layout.row: 1 + Layout.column: 2 + text: "SIMPLIFY" + checked: true + onCheckedChanged: { + if(m_simplify_enable!=checked){ + m_simplify_enable=checked; + function_rebuild_ui(); + } + } + } + ButtonIconInfo{ + Layout.row: 1 + Layout.column: 3 + onClicked: { + var text="SIMPLIFY: Show recommended channels only. These channels usually have the least amount of pollution by WiFi APs and most FPV antennas are tuned to those Frequncies.\n"+ + "OpenHD works best on them in most scenarios,and you can use 20Mhz and 40Mhz dynamically without issues (40Mhz spacing by default).\n"+ + "Otherwise, show all channels supported by harware (ADVANCED USERS ONLY).\n"; + _messageBoxInstance.set_text_and_show(text) + } + } + RowLayout{ + Layout.row: 2 + Layout.column: 0 + Layout.fillWidth: true + Layout.fillHeight: true + id: gnd_op_mode_status + //SimpleProgressBar{ + //} + Text{ + text: { + if(!_ohdSystemGround.is_alive)return "GND NOT ALIVE"; + if(_ohdSystemGround.wb_gnd_operating_mode==1){ + return "SCANNING"; + } + if(_ohdSystemGround.wb_gnd_operating_mode==2){ + return "ANALYZING"; + } + if(!_ohdSystemAir.is_alive){ + return _wbLinkSettingsHelper.curr_channel_mhz+"@"+"N/A"+" Mhz (NO AIR)"; + } + return _wbLinkSettingsHelper.curr_channel_mhz+"@"+_wbLinkSettingsHelper.curr_channel_width_mhz+" Mhz"; + } + Layout.row: 1 + Layout.column: 0 + verticalAlignment: Text.AlignVCenter + } + } + Button{ + Layout.row: 2 + Layout.column: 1 + id: b_find_air_unit + text: "SCAN" + enabled: _ohdSystemGround.is_alive + onClicked: { + close_all_dialoques(); + channel_scan_progress_view.open() + } + SequentialAnimation { + running: true + loops: 4 + id: anim_find_air_unit + // Expand the button + PropertyAnimation { + target: b_find_air_unit + property: "scale" + to: 1.5 + duration: 200 + easing.type: Easing.InOutQuad + } + // Shrink back to normal + PropertyAnimation { + target: b_find_air_unit + property: "scale" + to: 1.0 + duration: 200 + easing.type: Easing.InOutQuad + } + } + } + Button{ + Layout.row: 2 + Layout.column: 2 + text: "ANALYZE" + enabled: _ohdSystemGround.is_alive + onClicked: { + close_all_dialoques(); + pollution_chart_view.open() + } + } + ButtonIconInfo{ + Layout.row: 2 + Layout.column: 3 + onClicked: { + var text="SCAN: Scan for a running openhd air unit (required if you switch between different air / ground stations or re-flash the image.)\n"+ + "ANALYZE: Analyze all channels for WiFi pollution. If any of the default openhd channels is not polluted, they should be used."+ + "NOTE: Analogue FPV or other digital FPV systems won't show up during analyze - read the wiki for more info."; + _messageBoxInstance.set_text_and_show(text) + } + } + // Row 3 + RowLayout{ + Layout.row: 3 + Layout.column: 0 + Layout.columnSpan: 3 + Text{ + text:{ + "LOSS %:"+_ohdSystemGround.curr_rx_packet_loss_perc; + } + color: _ohdSystemGround.curr_rx_packet_loss_perc > 5 ? "red" : "black" + } + Text{ + text: { + return "POLLUTION pps:"+_ohdSystemGround.wb_link_curr_foreign_pps + } + color: _ohdSystemGround.wb_link_curr_foreign_pps > 20 ? "red" : "black" + } + Text{ + text: { + return "THROTTLE:"+_ohdSystemAir.curr_n_rate_adjustments + } + color: _ohdSystemAir.curr_n_rate_adjustments > 0 ? "red" : "black" + } + ButtonIconWarning{ + visible: /*_ohdSystemAir.is_alive &&*/ (_ohdSystemGround.curr_rx_packet_loss_perc > 5 || _ohdSystemGround.wb_link_curr_foreign_pps > 20 || _ohdSystemAir.curr_n_rate_adjustments > 0) + onClicked: { + var text="On the bench, if you encounter issues like a high loss , high pollution or throttling, make sure:\n"+ + "1) You are using a channel free of noise and interference (OHD channel 1-5 are a good bet)\n"+ + "2) (RARELY,RTL8812AU only): Your TX card(s) aren't overamplifying the signal and have adequate cooling."; + _messageBoxInstance.set_text_and_show(text) + } + } + } + } + } + Rectangle { + implicitWidth: tx_power_layout.implicitWidth + implicitHeight: tx_power_layout.implicitHeight + id: tx_power_layout_background + color: m_background_color + radius: 10 + + GridLayout { + id: tx_power_layout + Layout.fillWidth: true + Layout.fillHeight: true + Text{ + Layout.row: 0 + Layout.column: 0 + text: "TX POWER" + font.bold: true + } + Text{ + Layout.row: 1 + Layout.column: 0 + text: "AIR" + } + Text{ + Layout.row: 1 + Layout.column: 1 + text: get_text_wifi_tx_power(true) + } + Button{ + Layout.row: 1 + Layout.column: 2 + text: "CHANGE" + enabled: _ohdSystemAir.is_alive + onClicked: { + close_all_dialoques(); + change_tx_power_popup.m_is_air=true; + change_tx_power_popup.open() + } + } + Text{ + Layout.row: 2 + Layout.column: 0 + text: "GND" + } + Text{ + Layout.row: 2 + Layout.column: 1 + text: get_text_wifi_tx_power(false) + } + Button{ + Layout.row: 2 + Layout.column: 2 + text: "CHANGE" + enabled: _ohdSystemGround.is_alive + onClicked: { + close_all_dialoques(); + change_tx_power_popup.m_is_air=false; + change_tx_power_popup.open() + } + } + } + } + } + } + + PollutionChartView{ + id: pollution_chart_view + } + + ChannelScanProgressView{ + id: channel_scan_progress_view + } + + ChangeTxPowerPopup{ + id: change_tx_power_popup + } + + DialoqueFreqChangeGndOnly{ + id: dialoqueFreqChangeGndOnly + } + DialoqueFreqChangeArmed{ + id: dialoqueFreqChangeArmed + } +} diff --git a/qml/ui/configpopup/openhd_settings/PollutionChartView.qml b/qml/ui/configpopup/openhd_settings/PollutionChartView.qml index caf8c8b06..ed3b7aef5 100644 --- a/qml/ui/configpopup/openhd_settings/PollutionChartView.qml +++ b/qml/ui/configpopup/openhd_settings/PollutionChartView.qml @@ -16,48 +16,102 @@ import "../../elements" import QtCharts 2.0 -ChartView { - title: "WiFi pollution estimate" +Rectangle{ width: parent.width - height: rowHeight * 3 - legend.alignment: Qt.AlignBottom - antialiasing: true + height: parent.height /2 + anchors.bottom: parent.bottom + anchors.left: parent.left + color: "#8cbfd7f3" + function open(){ + visible=true + } + + function close(){ + visible=false; + } function update(){ - update_pollution_graph(); + pollution_chart.update_pollution_graph(); } - function update_pollution_graph(){ - //const frequencies_list = _wbLinkSettingsHelper.get_pollution_qstringlist(); - //bar_axis_x.categories=frequencies_list; - //const supported_frequencies = _wbLinkSettingsHelper.get_supported_frequencies(); - const supported_frequencies = _wbLinkSettingsHelper.get_supported_frequencies_filtered(1); - var categories = _wbLinkSettingsHelper.pollution_frequencies_int_to_qstringlist(supported_frequencies); - var values = _wbLinkSettingsHelper.pollution_frequencies_int_get_pollution(supported_frequencies); - bar_axis_x.categories=categories; - bar_set.values=values; - /*const supported_frequencies=_wbLinkSettingsHelper.get_supported_frequencies(); - bar_axis_x.categories.clear(); - for(var i=0;i Date: Sun, 15 Oct 2023 22:50:55 +0200 Subject: [PATCH 07/81] wb link settings - better use available space and group things --- qml/qml.qrc | 9 +- .../DIaloqueStartChannelScan.qml | 211 -------- .../openhd_settings/DialoqueChangeTxPower.qml | 454 ------------------ .../DialoqueStartAnalyzeChannels.qml | 119 ----- .../MavlinkOpenHDWBParamPanel2.qml | 6 +- ...ChartView.qml => PopupAnalyzeChannels.qml} | 0 ...ProgressView.qml => PopupScanChannels.qml} | 0 ...xPowerPopup.qml => PopupTxPowerEditor.qml} | 28 ++ qml/ui/elements/WorkaroundMessageBox.qml | 12 +- 9 files changed, 42 insertions(+), 797 deletions(-) delete mode 100644 qml/ui/configpopup/openhd_settings/DIaloqueStartChannelScan.qml delete mode 100644 qml/ui/configpopup/openhd_settings/DialoqueChangeTxPower.qml delete mode 100644 qml/ui/configpopup/openhd_settings/DialoqueStartAnalyzeChannels.qml rename qml/ui/configpopup/openhd_settings/{PollutionChartView.qml => PopupAnalyzeChannels.qml} (100%) rename qml/ui/configpopup/openhd_settings/{ChannelScanProgressView.qml => PopupScanChannels.qml} (100%) rename qml/ui/configpopup/openhd_settings/{ChangeTxPowerPopup.qml => PopupTxPowerEditor.qml} (86%) diff --git a/qml/qml.qrc b/qml/qml.qrc index bd365b3df..8678af5be 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -213,8 +213,6 @@ ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml ui/configpopup/openhd_settings/DialoqueFreqChangeGndOnly.qml - ui/configpopup/openhd_settings/DialoqueStartAnalyzeChannels.qml - ui/configpopup/openhd_settings/DIaloqueStartChannelScan.qml ui/configpopup/ConfigPopupSidebarButton.qml ui/configpopup/rc/RcInfoScreen.qml ui/configpopup/rc/RcInfoPanel.qml @@ -228,7 +226,6 @@ ui/configpopup/dev/AppDeveloperStatsPanel.qml ui/configpopup/credits/Credits.qml ui/configpopup/connect/ConnectPanel.qml - ui/configpopup/openhd_settings/DialoqueChangeTxPower.qml ui/elements/RestartQOpenHDMessageBox.qml ui/widgets/map/MapWidgetForm.ui.qml ui/widgets/map/MapWidget.qml @@ -259,10 +256,10 @@ ui/configpopup/dev/QOpenHDServiceDialoque.qml ui/elements/ButtonDisconnected.qml ui/configpopup/status/DialoqueNotAlive.qml - ui/configpopup/openhd_settings/PollutionChartView.qml + ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml ui/configpopup/log/LogMessagesView.qml ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml - ui/configpopup/openhd_settings/ChannelScanProgressView.qml - ui/configpopup/openhd_settings/ChangeTxPowerPopup.qml + ui/configpopup/openhd_settings/PopupScanChannels.qml + ui/configpopup/openhd_settings/PopupTxPowerEditor.qml diff --git a/qml/ui/configpopup/openhd_settings/DIaloqueStartChannelScan.qml b/qml/ui/configpopup/openhd_settings/DIaloqueStartChannelScan.qml deleted file mode 100644 index 303540b28..000000000 --- a/qml/ui/configpopup/openhd_settings/DIaloqueStartChannelScan.qml +++ /dev/null @@ -1,211 +0,0 @@ -import QtQuick 2.12 -import QtQuick.Controls 2.12 -import QtQuick.Layouts 1.12 -import QtQuick.Dialogs 1.0 -import QtQuick.Controls.Material 2.12 - -import "../../elements" - -// I fucking hate writing UIs in QT -// Dialoque that initiates a channel scan once the user selected everything correctly / passed all the checks -Card { - id: dialoqueStartChannelScan - width: 360 - height: 340 - z: 5.0 - anchors.centerIn: parent - cardName: qsTr("Find Air Unit") - cardNameColor: "black" - visible: false - - property int m_curr_index: 0 - - function open_channel_scan_dialoque(){ - var is_armed= _fcMavlinkSystem.is_alive && _fcMavlinkSystem.armed - if(is_armed){ - m_curr_index=0; - }else{ - m_curr_index=1; - } - dialoqueStartChannelScan.visible=true - } - - ListModel{ - id: model_chann_2G_or_5G - //ListElement {title: "All 2.4G and 5.8G channels (slow)"; value: 0} - ListElement {title: "OpenHD [1-5] only (fast)"; value: 0} - ListElement {title: "All 2.4G channels (slow)"; value: 1} - ListElement {title: "All 5.8G channels (slow)"; value: 2} - } - - // like dji, we use 20 or 40Mhz bandwidth(s) but never 5 or 10 - ListModel{ - id: model_bandwidth_all_or_20_or_40 - ListElement {title: "20Mhz and 40Mhz (slow)"; value: 0} - ListElement {title: "20Mhz only"; value: 1} - ListElement {title: "40Mhz only"; value: 2} - } - - cardBody: Item{ - height: 200 - width: 320 - // warn if armed dialoque - Item{ - id: dialoque1 - visible: m_curr_index==0 - width: parent.width - height: parent.height - Text{ - text: "WARNING ! Performing a channel scan while armed is not recommended, you'l loose connecion !" - width: parent.width - height: parent.height-100 - leftPadding: 12 - rightPadding: 12 - wrapMode: Text.WordWrap - } - } - // select and then initiate dialoque - Item{ - id: dialoque2 - visible: m_curr_index==1 - width: parent.width - height: parent.height - Text { - id: dialoqueStartChannelScan_text - text: "Initiate Channel Scan (Find a running air unit). Might take more than 1 minute if you are not specifying the generic band below. Otherwise,it'l take - max 30 seconds, usually less" - width: parent.width - height: parent.height-100 - leftPadding: 12 - rightPadding: 12 - wrapMode: Text.WordWrap - - } - ComboBox { - width: parent.width - //height: 100 - anchors.top: dialoqueStartChannelScan_text.bottom - id: comboBoxWhichFrequencyToScan - model: model_chann_2G_or_5G - textRole: "title" - Material.background: { - (comboBoxWhichFrequencyToScan.currentIndex===0) ? Material.Orange : Material.Green - } - onCurrentIndexChanged: { - } - } - /*ComboBox { - width: parent.width - //height: 100 - anchors.top: comboBoxWhichFrequencyToScan.bottom - id: comboBoxWhichChannelWidthsToScan - model: model_bandwidth_all_or_20_or_40 - textRole: "title" - Material.background: { - (comboBoxWhichChannelWidthsToScan.currentIndex===0) ? Material.Orange : Material.Green - } - onCurrentIndexChanged: { - } - }*/ - } - // after initiate dialoque - Item{ - id: dialoque3 - visible: m_curr_index==2 - width: parent.width - height: parent.height - Text{ - id: dialoqueStartChannelScan_text2 - text: "Scanning channels, you can close this dialoque and go back to your OSD screen. PLEASE DO NOT CHANGE SETTINGS WHILE CHANNEL SCAN IS ACTIVE !" - width: parent.width - height: parent.height-100 - leftPadding: 12 - rightPadding: 12 - wrapMode: Text.WordWrap - } - } - - } - hasFooter: true - cardFooter: Item { - anchors.fill: parent - - // First dialoque - RowLayout{ - anchors.fill: parent - visible: m_curr_index==0 - ButtonRed{ - text: "PROCCEED ANYWAY" - /*Layout.fillWidth: true - Layout.preferredWidth: 140 - Layout.alignment: Qt.AlignLeft*/ - Layout.preferredWidth: 140 - Layout.alignment: Qt.AlignLeft - Layout.leftMargin: 12 - onClicked: { - m_curr_index++; - } - } - ButtonGreen{ - text: "CANCEL" - /*Layout.fillWidth: true - Layout.preferredWidth: 140 - Layout.alignment: Qt.AlignRight*/ - Layout.preferredWidth: 140 - Layout.alignment: Qt.AlignRight - Layout.rightMargin: 12 - onClicked: { - dialoqueStartChannelScan.visible=false; - } - } - } - // Second dialoque - RowLayout{ - anchors.fill: parent - visible: m_curr_index==1 - Button{ - Layout.preferredWidth: 140 - Layout.alignment: Qt.AlignLeft - Layout.leftMargin: 12 - text: qsTr("Cancel") - visible: m_curr_index==1 - onPressed: { - dialoqueStartChannelScan.visible=false; - } - } - Button{ - Layout.preferredWidth: 140 - Layout.alignment: Qt.AlignRight - Layout.rightMargin: 12 - text: qsTr("Initiate") - onPressed: { - var how_many_freq_bands=comboBoxWhichFrequencyToScan.currentIndex - // Changed: We now (only) support scanning in 40Mhz mode, since this way, we are quicker and catch both 20Mhz and 40Mhz air unit(s) - //var how_many_bandwidths=comboBoxWhichChannelWidthsToScan.currentIndex - var how_many_bandwidths = 2; - console.log("Initate channel scan "+how_many_freq_bands+","+how_many_bandwidths) - var result = _wbLinkSettingsHelper.start_scan_channels(how_many_freq_bands,how_many_bandwidths) - if(result){ - m_curr_index=2; - }else{ - console.log("Cannot initiate channel scan"); - _qopenhd.show_toast("Busy,please try again later",true) - } - } - } - } - RowLayout{ - anchors.fill: parent - visible: m_curr_index==2 - Button{ - Layout.preferredWidth: 140 - Layout.alignment: Qt.AlignRight - Layout.rightMargin: 12 - text: qsTr("Close") - onPressed: { - dialoqueStartChannelScan.visible=false; - } - } - } - } -} diff --git a/qml/ui/configpopup/openhd_settings/DialoqueChangeTxPower.qml b/qml/ui/configpopup/openhd_settings/DialoqueChangeTxPower.qml deleted file mode 100644 index fcb041c60..000000000 --- a/qml/ui/configpopup/openhd_settings/DialoqueChangeTxPower.qml +++ /dev/null @@ -1,454 +0,0 @@ -import QtQuick 2.12 -import QtQuick.Controls 2.12 -import QtQuick.Layouts 1.12 -import QtQuick.Dialogs 1.0 -import QtQuick.Controls.Material 2.12 - -import "../../elements" - -// I fucking hate writing UIs in QT -// Dialoque that changes the tx power once the user selected everything correctly / passed all the checks -Card { - id: dialoqueTxPower - width: 360 - height: 340 - z: 5.0 - anchors.centerIn: parent - cardName: qsTr("Change TX PWR "+get_is_ground_as_string()) - cardNameColor: "black" - visible: false - - // check if all ground cards use the same chipset - otherwise, this wizard cannot be used - function gnd_check_all_active_cards_are_same_type(){ - var card0_type=_wifi_card_gnd0.card_type; - if(_wifi_card_gnd1.alive && (_wifi_card_gnd1.card_type != card0_type)){ - return false; - } - if(_wifi_card_gnd2.alive && (_wifi_card_gnd2.card_type != card0_type)){ - return false; - } - if(_wifi_card_gnd3.alive && (_wifi_card_gnd3.card_type != card0_type)){ - return false; - } - return true; - } - - function open_tx_power_dialoque(ground){ - var is_armed= _fcMavlinkSystem.is_alive && _fcMavlinkSystem.armed - if(is_armed){ - // User has to click proceed anyways on armed warning - m_curr_index=0; - }else{ - m_curr_index=1; - } - m_is_ground=ground; - m_card_chip_type=-1; - m_card_manufacturer_type=-1 - comboBoxSelectedArmedDisarmed.currentIndex=0 - comboBoxCardSelectTxPower.currentIndex=0 - comboBoxCardSelectManufacturer.currentIndex=0; - // We figure out the chip type automatcally (info from openhd) - var wifi_card_chip_type=-1; - if(m_is_ground){ - // Check if all cards are of the same type - if(!gnd_check_all_active_cards_are_same_type()){ - _messageBoxInstance.set_text_and_show("This wizard is only available when you use the same card(s) on ground. Please unify your gnd station cards. -You can still use the RAW OpenHD AIR / GROUND Parameters to change your tx power."); - return; - } - wifi_card_chip_type=_wifi_card_gnd0.card_type; - //wifi_card_chip_type=1 - }else{ - wifi_card_chip_type=_wifi_card_air.card_type; - } - if(!(wifi_card_chip_type==0 || wifi_card_chip_type==1)){ - _messageBoxInstance.set_text_and_show("Card type unknown / unsupported - please use a supported card. You can still change the tx power manually via the param set, but probably -the card driver and/or the linux kernel doesn't support changing it."); - return; - } - // 0 is RTL8812AU, 1 is RTL8812BU - m_card_chip_type=wifi_card_chip_type; - //m_card_chip_type=0; // RTL8812AU - dialoqueTxPower.visible=true - } - - property int m_curr_index: 0 - - property bool m_is_ground: true - function get_is_ground_as_string(){ - return m_is_ground ? "GND" : "AIR"; - } - - ListModel{ - id: armed_or_disarmed_model - ListElement {title: "NOT SELECTED"; value: -1} - ListElement {title: "DISARMED"; value: 0} - ListElement {title: "ARMED (RECOMMENDED)"; value: 0} - } - property bool m_change_armed: false - function get_change_armed_as_string(){ - return m_change_armed ? "ARMED" : "DISARMED"; - } - - // Chip type is automatically refered from OpenHD - property int m_card_chip_type: -1; - function get_card_chip_type_as_string(){ - if(m_card_chip_type==0) return "RTL88XXAU"; - if(m_card_chip_type==1) return "RTL88XXBU"; - return "UNKNOWN"; - } - - // Manufacturer the user has to select - property int m_card_manufacturer_type: -1 - function get_card_manufacturer_type_as_string(){ - if(m_card_chip_type==0){ - // RTL8812AU - if(m_card_manufacturer_type==0)return "ASUS"; - if(m_card_manufacturer_type==1)return "ALIEXPRESS"; - if(m_card_manufacturer_type==2)return "OTHER"; - }else{ - // RTL8812BU - if(m_card_manufacturer_type==0)return "COMFAST"; - if(m_card_manufacturer_type==1)return "OTHER"; - } - return "UNKNWON"; - } - - ListModel{ - id: plcaeholder_model - ListElement {title: "I should never appear"; value: -1} - } - - ListModel{ - id: model_rtl8812au_manufacturers - ListElement {title: "NOT SELECTED"; value: -1} - ListElement {title: "ASUS"; value: 0} - ListElement {title: "ALIEXPRESS"; value: 1} - ListElement {title: "OTHER"; value: 2} - } - ListModel{ - id: model_rtl8812bu_manufacturers - ListElement {title: "NOT SELECTED"; value: -1} - ListElement {title: "COMFAST"; value: 0} - ListElement {title: "OTHER"; value: 1} - } - - function get_model_manufacturer_for_chip_type(){ - if(m_card_chip_type==0){ - return model_rtl8812au_manufacturers; - }else if(m_card_chip_type==1){ - return model_rtl8812bu_manufacturers; - } - return plcaeholder_model; - } - - property int tx_power_index_or_mw: -1 - - ListModel{ - id: model_rtl8812au_manufacturer_asus_txpower - ListElement {title: "Please select"; value: -1} - ListElement {title: "LOW [22] ~20mW (DEFAULT) "; value: 22} - ListElement {title: "MEDIUM [37] ~100mW "; value: 37} - ListElement {title: "HIGH [53] ~320mW "; value: 53} - ListElement {title: "MAX1 [58] ~420mW (MCS<=2!)"; value: 58} - ListElement {title: "MAX2 [63] ~500mW (MCS<=2!)"; value: 63} - } - ListModel{ - id: model_rtl8812au_manufacturer_aliexpress_hp - ListElement {title: "Please select"; value: -1} - ListElement {title: "LOW [16]"; value: 16} - ListElement {title: "MEDIUM [22]"; value: 22} - ListElement {title: "HIGH [24]"; value: 24} - ListElement {title: "MAX [26]"; value: 26} - } - ListModel{ - id: model_rtl8812au_manufacturer_generic - ListElement {title: "Please select"; value: -1} - ListElement {title: "[22] (DANGER,ARBITRARY)"; value: 22} - ListElement {title: "[37] (DANGER,ARBITRARY)"; value: 37} - ListElement {title: "[53] (DANGER,ARBITRARY)"; value: 53} - ListElement {title: "[58] (DANGER,ARBITRARY)"; value: 58} - ListElement {title: "[63] (DANGER,ARBITRARY)"; value: 63} - } - // RTL8812BU begin - ListModel{ - id: model_rtl8812bu_manufacturer_comfast - ListElement {title: "Please select"; value: -1} - ListElement {title: "~25mW"; value: 25} - ListElement {title: "~100mW"; value: 100} - ListElement {title: "~200mW"; value: 200} - ListElement {title: "~300mW"; value: 300} - } - ListModel{ - id: model_rtl8812bu_manufacturer_generic - ListElement {title: "Please select"; value: -1} - ListElement {title: "25mW (maybe)"; value: 25} - ListElement {title: "100mW (maybe)"; value: 100} - ListElement {title: "<=300mW (maybe)"; value: 300} - ListElement {title: "<=1000mW (maybe)"; value: 1000} - ListElement {title: "<=20000mW (maybe)"; value: 2000} - } - - function get_model_select_tx_power_index_for_card_chip_type_and_manufacturer(){ - if(m_card_chip_type==0){ - // RTL8812AU - if(m_card_manufacturer_type==0){ - return model_rtl8812au_manufacturer_asus_txpower; - }else if(m_card_manufacturer_type==1){ - return model_rtl8812au_manufacturer_aliexpress_hp; - } - return model_rtl8812au_manufacturer_generic; - }else if(m_card_chip_type==1){ - // RTL8812BU - if(m_card_manufacturer_type==0){ - return model_rtl8812bu_manufacturer_comfast; - } - return model_rtl8812bu_manufacturer_generic; - } - return plcaeholder_model; - } - - function get_text_select_card_manufacturer(){ - var ret=""; - ret+="Your chipset: "+get_card_chip_type_as_string()+"\n"; - ret+="Please select your card manufacturer from the list below."; - if(m_card_chip_type==0){ - ret+="\nWARNING: IF YOU SELECT THE WRONG MANUFACTURER,YOU CAN EASILY DESTROY YOUR CARD - this card doesn't take tx power in mW, but a tx power index value "+ - "in arbitrary unit(s) depending on your manufacturer."; - }else if(m_card_chip_type==1){ - ret+="\nINFO: If you select any tx power in mW, depending on your manufacturer, your actual tx power will always be <= than the selected value."; - } - - return ret; - } - - function get_text_select_tx_power(){ - var ret=""; - ret += "Your chipset: "+get_card_chip_type_as_string()+"\n"; - ret += "Selected manufacturer: "+get_card_manufacturer_type_as_string()+"\n"; - ret+="Please select your wanted TX power applied when:\n"+get_change_armed_as_string()+" state"+"\n"; - return ret; - } - - cardBody: Rectangle{ - /*height: 340 - 100 - width: 360-10*/ - color: "orange" - //anchors.centerIn: parent - anchors.fill: parent - Item{ - width: parent.width - height: parent.height - visible: m_curr_index==0 - Text{ - text: ("WARNING ! Changing TX power while FC is armed is not recommended -\n"+ - " Validate / test your setup while disarmed, then set the apropate tx power for armed / disarmed state. !") - width: parent.width - height: parent.height / 2 - leftPadding: 12 - rightPadding: 12 - wrapMode: Text.WordWrap - } - } - ColumnLayout{ - width: parent.width - height: parent.height - visible: m_curr_index==1 - Text{ - Layout.fillWidth: true - leftPadding: 12 - rightPadding: 12 - id: card_select_manufcturer_description - text: get_text_select_card_manufacturer() - wrapMode: Text.WordWrap - } - ComboBox { - Layout.fillWidth: true - leftPadding: 12 - rightPadding: 12 - id: comboBoxCardSelectManufacturer - model: get_model_manufacturer_for_chip_type() - textRole: "title" - onCurrentIndexChanged: { - var manufacturer=comboBoxCardSelectManufacturer.model.get(comboBoxCardSelectManufacturer.currentIndex).value; - console.log("Selected manufacturerer "+get_card_chip_type_as_string()+" :"+manufacturer); - m_card_manufacturer_type=manufacturer; - } - } - } - ColumnLayout{ - width: parent.width - height: parent.height - visible: m_curr_index==2 - Text{ - Layout.fillWidth: true - leftPadding: 12 - rightPadding: 12 - text: ("Do you want to set the TX power in armed / disarmed state ?\n"+ -"NOTE: TX power armed is only applied when the FC is armed, TX power disarmed is applied when the FC is disarmed.") - wrapMode: Text.WordWrap - } - ComboBox { - Layout.fillWidth: true - leftPadding: 12 - rightPadding: 12 - id: comboBoxSelectedArmedDisarmed - model: armed_or_disarmed_model - textRole: "title" - onCurrentIndexChanged: { - if(comboBoxSelectedArmedDisarmed.currentIndex==1)m_change_armed=false; - if(comboBoxSelectedArmedDisarmed.currentIndex==2)m_change_armed=true; - } - } - } - - ColumnLayout{ - width: parent.width - height: parent.height - visible: m_curr_index==3 - Text{ - Layout.fillWidth: true - leftPadding: 12 - rightPadding: 12 - text: get_text_select_tx_power() - wrapMode: Text.WordWrap - } - ComboBox { - Layout.fillWidth: true - leftPadding: 12 - rightPadding: 12 - id: comboBoxCardSelectTxPower - model: get_model_select_tx_power_index_for_card_chip_type_and_manufacturer() - textRole: "title" - onCurrentIndexChanged: { - var tx_power=comboBoxCardSelectTxPower.model.get(comboBoxCardSelectTxPower.currentIndex).value; - tx_power_index_or_mw=tx_power; - console.log("Selected TX power (mW or index)"+tx_power_index_or_mw); - } - } - } - } - hasFooter: true - cardFooter: Item { - anchors.fill: parent - // change though armed - RowLayout{ - anchors.fill: parent - visible: m_curr_index==0 - ButtonRed{ - Layout.preferredWidth: 140 - Layout.alignment: Qt.AlignLeft - Layout.leftMargin: 12 - text: "CONTINUE ANYWAYS" - onClicked: { - m_curr_index=1 - } - } - ButtonGreen{ - Layout.preferredWidth: 140 - Layout.alignment: Qt.AlignRight - Layout.rightMargin: 12 - text: "Cancel" - onClicked: { - txPowerDialoque.visible=false; - } - } - } - RowLayout{ - anchors.fill: parent - visible: m_curr_index==1 - Button{ - Layout.preferredWidth: 140 - Layout.alignment: Qt.AlignLeft - Layout.leftMargin: 12 - text: "CANCEL" - onClicked: { - txPowerDialoque.visible=false; - } - } - Button{ - Layout.preferredWidth: 140 - Layout.alignment: Qt.AlignRight - Layout.rightMargin: 12 - text: "CONTINUE" - onClicked: { - if(m_card_manufacturer_type<0){ - _qopenhd.show_toast("Please select your card manufacturer",false); - }else{ - m_curr_index=2; - } - } - } - } - RowLayout{ - anchors.fill: parent - visible: m_curr_index==2 - Button{ - Layout.preferredWidth: 140 - Layout.alignment: Qt.AlignLeft - Layout.leftMargin: 12 - text: "CANCEL" - onClicked: { - txPowerDialoque.visible=false; - } - } - Button{ - Layout.preferredWidth: 140 - Layout.alignment: Qt.AlignRight - Layout.rightMargin: 12 - text: "Continue" - onClicked: { - if(comboBoxSelectedArmedDisarmed.currentIndex<=0){ - _qopenhd.show_toast("Please specify armed / disarmed",false); - }else{ - m_curr_index=3; - } - } - } - } - RowLayout{ - anchors.fill: parent - visible: m_curr_index==3 - Button{ - Layout.preferredWidth: 140 - Layout.alignment: Qt.AlignLeft - Layout.leftMargin: 12 - text: "CANCEL" - onClicked: { - txPowerDialoque.visible=false; - } - } - Button{ - Layout.preferredWidth: 140 - Layout.alignment: Qt.AlignRight - Layout.rightMargin: 12 - text: "APPLY" - onClicked: { - if(tx_power_index_or_mw<0){ - _qopenhd.show_toast("Please select a valid tx power",false); - return; - } - var success=false - var is_tx_power_index_unit = m_card_chip_type==0; - - success = _wbLinkSettingsHelper.set_param_tx_power(m_is_ground,is_tx_power_index_unit,m_change_armed,tx_power_index_or_mw) - if(success==true){ - txPowerDialoque.visible=false; - var message = "Set TX POWER "+get_change_armed_as_string()+" to "; - if(is_tx_power_index_unit){ - message += ""+tx_power_index_or_mw+" tx power index (unitless)" - }else{ - message += ""+tx_power_index_or_mw+" mW" - } - if(m_change_armed){ - message += "\nNOTE: Only applied once you arm your FC !"; - } - _messageBoxInstance.set_text_and_show(message, 10); - }else{ - _qopenhd.show_toast("Cannot change TX power, please try again",true); - } - } - } - } - } -} diff --git a/qml/ui/configpopup/openhd_settings/DialoqueStartAnalyzeChannels.qml b/qml/ui/configpopup/openhd_settings/DialoqueStartAnalyzeChannels.qml deleted file mode 100644 index 4aa8ce965..000000000 --- a/qml/ui/configpopup/openhd_settings/DialoqueStartAnalyzeChannels.qml +++ /dev/null @@ -1,119 +0,0 @@ -import QtQuick 2.12 -import QtQuick.Controls 2.12 -import QtQuick.Layouts 1.12 -import QtQuick.Dialogs 1.0 -import QtQuick.Controls.Material 2.12 - -import "../../elements" - -// I fucking hate writing UIs in QT -// Dialoque that initiates a channel/frequency analyze once the user selected everything correctly / passed all the checks -Card { - id: dialoqueAnalyzeChannels - width: 360 - height: 340 - z: 5.0 - anchors.centerIn: parent - cardName: qsTr("Analyze Channels") - cardNameColor: "black" - visible: false - - property int m_index: 0 - - function setup_and_show(){ - var is_armed= _fcMavlinkSystem.is_alive && _fcMavlinkSystem.armed - if(is_armed){ - m_index=0; - }else{ - m_index=1; - } - dialoqueAnalyzeChannels.visible=true; - } - - property string m_armed_warning: "WARNING ! Analyze channels while armed is not recommended, you'l loose connection for a significant amount of time !" - - property string m_info_string: "Analyze channels for pollution by wifi access points. -NOTE: This only gives a hint at free channels, using a proper channel analyzer (e.g. on the phone) is recommended. -PLEASE DO NOT CHANGE SETTINGS WHILE ANALYZING." - - - cardBody: Item{ - height: 200 - width: 320 - // Dialoque one - Text { - visible: m_index==0 - text: m_armed_warning - width: parent.width - height: parent.height-100 - leftPadding: 12 - rightPadding: 12 - wrapMode: Text.WordWrap - } - // Dialoque two - Text { - visible: m_index==1 - text: m_info_string - width: parent.width - height: parent.height-100 - leftPadding: 12 - rightPadding: 12 - wrapMode: Text.WordWrap - } - } - hasFooter: true - cardFooter: Item { - anchors.fill: parent - // Dialoque one - RowLayout{ - anchors.fill: parent - visible: m_index==0 - ButtonRed{ - Layout.preferredWidth: 140 - Layout.alignment: Qt.AlignLeft - Layout.leftMargin: 12 - text: qsTr("PROCEED ANYWAY") - onPressed: { - m_index=1 - } - } - ButtonGreen{ - Layout.preferredWidth: 140 - Layout.alignment: Qt.AlignRight - Layout.rightMargin: 12 - text: qsTr("CANCEL") - onPressed: { - dialoqueAnalyzeChannels.visible=false; - } - } - } - // Dialoque 2 - RowLayout{ - anchors.fill: parent - visible: m_index==1 - Button{ - Layout.preferredWidth: 140 - Layout.alignment: Qt.AlignLeft - Layout.leftMargin: 12 - text: qsTr("CANCEL") - onPressed: { - dialoqueAnalyzeChannels.visible=false; - } - } - Button{ - Layout.preferredWidth: 140 - Layout.alignment: Qt.AlignLeft - Layout.leftMargin: 12 - text: qsTr("INITIATE") - onPressed: { - var result=_wbLinkSettingsHelper.start_analyze_channels() - if(result!==true){ - _qopenhd.show_toast("Busy,please try again later",true); - }else{ - dialoqueAnalyzeChannels.visible=false; - } - } - } - } - } -} diff --git a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml index b14d51b0c..02d9595f2 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml +++ b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml @@ -447,15 +447,15 @@ Rectangle{ } } - PollutionChartView{ + PopupAnalyzeChannels{ id: pollution_chart_view } - ChannelScanProgressView{ + PopupScanChannels{ id: channel_scan_progress_view } - ChangeTxPowerPopup{ + PopupTxPowerEditor{ id: change_tx_power_popup } diff --git a/qml/ui/configpopup/openhd_settings/PollutionChartView.qml b/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml similarity index 100% rename from qml/ui/configpopup/openhd_settings/PollutionChartView.qml rename to qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml diff --git a/qml/ui/configpopup/openhd_settings/ChannelScanProgressView.qml b/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml similarity index 100% rename from qml/ui/configpopup/openhd_settings/ChannelScanProgressView.qml rename to qml/ui/configpopup/openhd_settings/PopupScanChannels.qml diff --git a/qml/ui/configpopup/openhd_settings/ChangeTxPowerPopup.qml b/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml similarity index 86% rename from qml/ui/configpopup/openhd_settings/ChangeTxPowerPopup.qml rename to qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml index dc3f86fc1..6fff3ba9a 100644 --- a/qml/ui/configpopup/openhd_settings/ChangeTxPowerPopup.qml +++ b/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml @@ -240,6 +240,20 @@ Rectangle{ Button{ text: "APPLY" enabled: m_user_selected_card_manufacturer>=0; + onClicked: { + var tx_power_index_or_mw = combo_box_txpower_disarmed.model.get(combo_box_txpower_disarmed.currentIndex).value; + if(tx_power_index_or_mw<0){ + _qopenhd.show_toast("Please select a valid tx power",false); + return; + } + var is_tx_power_index_unit = get_chipset_type()==0; + var success = _wbLinkSettingsHelper.set_param_tx_power(m_is_ground,is_tx_power_index_unit,m_change_armed,tx_power_index_or_mw) + if(success==true){ + _qopenhd.show_toast("SUCCESS"); + }else{ + _qopenhd.show_toast("Cannot change TX power, please try again",true); + } + } } } ColumnLayout{ @@ -269,6 +283,20 @@ Rectangle{ Button{ text: "APPLY" enabled: m_user_selected_card_manufacturer>=0; + onClicked: { + var tx_power_index_or_mw = combo_box_txpower_armed.model.get(combo_box_txpower_armed.currentIndex).value; + if(tx_power_index_or_mw<0){ + _qopenhd.show_toast("Please select a valid tx power",false); + return; + } + var is_tx_power_index_unit = get_chipset_type()==0; + var success = _wbLinkSettingsHelper.set_param_tx_power(m_is_ground,is_tx_power_index_unit,m_change_armed,tx_power_index_or_mw) + if(success==true){ + _qopenhd.show_toast("SUCCESS"); + }else{ + _qopenhd.show_toast("Cannot change TX power, please try again",true); + } + } } } diff --git a/qml/ui/elements/WorkaroundMessageBox.qml b/qml/ui/elements/WorkaroundMessageBox.qml index 191fcf253..54063cb21 100644 --- a/qml/ui/elements/WorkaroundMessageBox.qml +++ b/qml/ui/elements/WorkaroundMessageBox.qml @@ -21,14 +21,18 @@ Card { cardName: qsTr("QOpenHD")+(_messageBoxInstance.remaining_time_seconds==-1 ? "" : (" "+_messageBoxInstance.remaining_time_seconds+"s")) cardNameColor: "black" visible: _messageBoxInstance.visible - cardBody: Column { + cardBody: ScrollView { + contentHeight: workaroundMessageBox_text.height + contentWidth: workaroundMessageBox_text.width + ScrollBar.vertical.interactive: true height: 200 - width: 320 + width: 350 + clip:true + anchors.centerIn: parent.Center Text { id: workaroundMessageBox_text + width: 320 text: _messageBoxInstance.text - width: parent.width-24 - height:parent.height leftPadding: 12 rightPadding: 12 wrapMode: Text.WordWrap From eb72ab7af5da92292aee608079a1d724556c5d49 Mon Sep 17 00:00:00 2001 From: consti10 Date: Tue, 17 Oct 2023 18:23:44 +0200 Subject: [PATCH 08/81] connection mode auto --- app/telemetry/MavlinkTelemetry.cpp | 111 ++++--- app/telemetry/MavlinkTelemetry.h | 6 +- app/telemetry/connection/tcp_connection.cpp | 238 ++++++++------- app/telemetry/connection/tcp_connection.h | 28 +- app/telemetry/connection/udp_connection.cpp | 8 + app/telemetry/connection/udp_connection.h | 4 + .../settings/wblinksettingshelper.cpp | 16 +- qml/qml.qrc | 3 + qml/ui/configpopup/ConfigPopup.qml | 60 ++-- qml/ui/configpopup/connect/ConnectPanel.qml | 7 + qml/ui/configpopup/connect/PaneX.qml | 167 ++++++++++ .../MavlinkOpenHDWBParamPanel2.qml | 5 +- .../openhd_settings/PopupAnalyzeChannels.qml | 3 +- .../openhd_settings/PopupScanChannels.qml | 3 +- .../openhd_settings/PopupTxPowerEditor.qml | 59 ++-- qml/ui/configpopup/rc/RcInfoScreen.qml | 4 +- .../status/StatusCardBodyOpenHD.qml | 288 +++++++----------- qml/ui/configpopup/status/StatusCardRow.qml | 77 +++++ qml/ui/elements/TextOrWarningButton.qml | 37 +++ 19 files changed, 730 insertions(+), 394 deletions(-) create mode 100644 qml/ui/configpopup/connect/PaneX.qml create mode 100644 qml/ui/configpopup/status/StatusCardRow.qml create mode 100644 qml/ui/elements/TextOrWarningButton.qml diff --git a/app/telemetry/MavlinkTelemetry.cpp b/app/telemetry/MavlinkTelemetry.cpp index 4b683b91d..1966469b7 100644 --- a/app/telemetry/MavlinkTelemetry.cpp +++ b/app/telemetry/MavlinkTelemetry.cpp @@ -15,6 +15,22 @@ MavlinkTelemetry::MavlinkTelemetry(QObject *parent):QObject(parent) { } +void MavlinkTelemetry::start() +{ + auto cb_udp=[this](mavlink_message_t msg){ + process_mavlink_message(msg); + }; + const auto udp_ip="0.0.0.0"; //"127.0.0.1" + m_udp_connection=std::make_unique(udp_ip,QOPENHD_GROUND_CLIENT_UDP_PORT_IN,cb_udp); + m_udp_connection->start(); + auto cb_tcp=[this](mavlink_message_t msg){ + process_mavlink_message(msg); + }; + m_tcp_connection=std::make_unique(cb_tcp); + m_heartbeat_thread_run=true; + m_heartbeat_thread=std::make_unique(&MavlinkTelemetry::send_heartbeat_loop,this); +} + MavlinkTelemetry::~MavlinkTelemetry() { if(m_heartbeat_thread){ @@ -30,15 +46,6 @@ MavlinkTelemetry &MavlinkTelemetry::instance() return instance; } -void MavlinkTelemetry::start() -{ - QSettings settings; - // By default, we always use UDP / localhost mode. - enable_udp(); - m_heartbeat_thread_run=true; - m_heartbeat_thread=std::make_unique(&MavlinkTelemetry::send_heartbeat_loop,this); -} - bool MavlinkTelemetry::sendMessage(mavlink_message_t msg){ const auto sys_id=QOpenHDMavlinkHelper::get_own_sys_id(); const auto comp_id=QOpenHDMavlinkHelper::get_own_comp_id(); @@ -229,35 +236,6 @@ void MavlinkTelemetry::process_message_timesync(const mavlink_message_t &msg) } -void MavlinkTelemetry::add_tcp_connection_handler(QString ip) -{ - qDebug()<<"MavlinkTelemetry::add_tcp_connection_handler"<(ip.toStdString(),QOPENHD_OPENHD_GROUND_TCP_SERVER_PORT,cb_tcp); - m_tcp_connection->start(); - set_udp_localhost_mode_enabled(false); -} - -void MavlinkTelemetry::enable_udp() -{ - m_tcp_connection=nullptr; - m_udp_connection=nullptr; - // default, udp, passive (like QGC) - auto cb_udp=[this](mavlink_message_t msg){ - process_mavlink_message(msg); - }; - set_udp_localhost_mode_enabled(true); - const auto ip="0.0.0.0"; //"127.0.0.1" - m_udp_connection=std::make_unique(ip,QOPENHD_GROUND_CLIENT_UDP_PORT_IN,cb_udp); - m_udp_connection->start(); -} - void MavlinkTelemetry::ping_all_systems() { mavlink_message_t msg; @@ -285,7 +263,12 @@ void MavlinkTelemetry::re_apply_rates() void MavlinkTelemetry::send_heartbeat_loop() { - mavlink_message_t msg; + while(true){ + qDebug()<<"send_heartbeat_loop"; + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + perform_connection_management(); + } + /*mavlink_message_t msg; mavlink_heartbeat_t heartbeat{}; heartbeat.type=MAV_TYPE_GCS; heartbeat.autopilot=MAV_AUTOPILOT_INVALID; @@ -293,5 +276,55 @@ void MavlinkTelemetry::send_heartbeat_loop() std::this_thread::sleep_for(std::chrono::milliseconds(500)); mavlink_msg_heartbeat_encode(QOpenHDMavlinkHelper::get_own_sys_id(),QOpenHDMavlinkHelper::get_own_comp_id(),&msg,&heartbeat); sendMessage(msg); + }*/ +} + +void MavlinkTelemetry::perform_connection_management() +{ + QSettings settings; + int mavlink_connection_mode=settings.value("mavlink_connection_mode",0).toInt(); + if(mavlink_connection_mode<0 || mavlink_connection_mode>2)mavlink_connection_mode=0; + mavlink_connection_mode=0; + if(mavlink_connection_mode==0){ + // AUTO + if(m_udp_connection->threadsafe_is_alive()){ + // Stop TCP if it is running, we don't need it + m_tcp_connection->stop_receiving(); + set_telemetry_connection_status("AUTO-CONNECTED(UDP,LOCALHOST)"); + }else{ + // UPP is not working, try TCP + const std::string IP_CONSTI_TEST="192.168.178.36"; + //const std::string IP_OPENHD_WIFI_HOTSPOT="192.168.3.1"; + const std::string IP_OPENHD_WIFI_HOTSPOT=IP_CONSTI_TEST; + const std::string IP_OPENHD_ETHERNET_HOTSPOT="192.168.2.1"; + if(m_tcp_connection->try_connect_and_receive(IP_OPENHD_WIFI_HOTSPOT,QOPENHD_OPENHD_GROUND_TCP_SERVER_PORT)){ + set_telemetry_connection_status("AUTO-CONNECTED (WIFI,TCP)"); + }else if(m_tcp_connection->try_connect_and_receive(IP_OPENHD_ETHERNET_HOTSPOT,QOPENHD_OPENHD_GROUND_TCP_SERVER_PORT)){ + set_telemetry_connection_status("AUTO-CONNECTED (ETH,TCP)"); + }else{ + set_telemetry_connection_status("AUTO-NOT CONNECTED"); + } + } + }else if(mavlink_connection_mode==1){ + // Explicit UDP + m_tcp_connection->stop_receiving(); + std::stringstream ss; + ss<<"MANUAL UDP-"<<(m_udp_connection->threadsafe_is_alive() ? "ALIVE" : "NO DATA"); + set_telemetry_connection_status(ss.str().c_str()); + }else if(mavlink_connection_mode==2){ + // Explicit TCP + const std::string user_ip="192.168.178.36"; + const int user_port=5760; + if(m_tcp_connection->m_remote_ip==user_ip && m_tcp_connection->m_remote_port==user_port){ + if(!m_tcp_connection->threadsafe_is_alive()){ + m_tcp_connection->stop_receiving(); + m_tcp_connection->try_connect_and_receive(user_ip,user_port); + } + } + std::stringstream ss; + ss<<"MANUAL TCP -"<<(m_udp_connection->threadsafe_is_alive() ? "CONNECTED" : "WRONG IP?"); + set_telemetry_connection_status(ss.str().c_str()); + }else{ + } } diff --git a/app/telemetry/MavlinkTelemetry.h b/app/telemetry/MavlinkTelemetry.h index 575beb110..e7971c4ac 100644 --- a/app/telemetry/MavlinkTelemetry.h +++ b/app/telemetry/MavlinkTelemetry.h @@ -55,16 +55,13 @@ class MavlinkTelemetry : public QObject Q_INVOKABLE void ping_all_systems(); // re-apply all FC telemetry rate(s) Q_INVOKABLE void re_apply_rates(); - // Switch from UDP to TCP - Q_INVOKABLE void add_tcp_connection_handler(QString ip); - // Back to udp - Q_INVOKABLE void enable_udp(); public: // A couple of stats exposed as QT properties L_RO_PROP(int,telemetry_pps_in,set_telemetry_pps_in,-1) L_RO_PROP(int,telemetry_bps_in,set_telemetry_bps_in,-1) L_RO_PROP(bool,udp_localhost_mode_enabled,set_udp_localhost_mode_enabled,true) // + L_RO_PROP(QString,telemetry_connection_status,set_telemetry_connection_status,"N/A"); private: // We follow the same practice as QGrouncontroll: Listen for incoming data on a specific UDP port, // -> as soon as we got the first packet, we know the address to send data to for bidirectional communication @@ -92,6 +89,7 @@ class MavlinkTelemetry : public QObject std::unique_ptr m_heartbeat_thread; std::atomic_bool m_heartbeat_thread_run; void send_heartbeat_loop(); + void perform_connection_management(); }; #endif // OHDMAVLINKCONNECTION_H diff --git a/app/telemetry/connection/tcp_connection.cpp b/app/telemetry/connection/tcp_connection.cpp index 6892fce02..5b687fafb 100644 --- a/app/telemetry/connection/tcp_connection.cpp +++ b/app/telemetry/connection/tcp_connection.cpp @@ -1,4 +1,5 @@ #include "tcp_connection.h" +#include "util/qopenhdmavlinkhelper.hpp" #ifdef __windows__ #define _WIN32_WINNT 0x0600 //TODO dirty @@ -9,82 +10,152 @@ #include #include #include +#include #endif #include +static int linux_tcp_socket_try_connect(const std::string remote_ip, const int remote_port,const int timeout_seconds){ + qDebug()<<"linux_tcp_socket_try_connect:"<(&remote_addr), sizeof(struct sockaddr_in)); + if(connect_result==0){ + qDebug()<<"Got connection immeiately"; + return sockfd; + } + if ((connect_result== -1) && (errno != EINPROGRESS)) { + qDebug()<<"Didnt get EINPROGRESS"<<(int)connect_result; + close(sockfd); + return -1; + } + // Wait for up to X seconds to connect + fd_set fdset; + struct timeval tv; + FD_ZERO(&fdset); + FD_SET(sockfd, &fdset); + tv.tv_sec = timeout_seconds; + tv.tv_usec = 0; + const int rc= select(sockfd + 1, NULL, &fdset, NULL, &tv); + if(rc!=1){ + qDebug()<<"Timed out or other crap"; + close(sockfd); + return -1; + } + // Check if there are any errors + int so_error; + // data to read + socklen_t len = sizeof(so_error); + getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &so_error, &len); + if (so_error != 0) { + qDebug()<<"Any socket error"; + close(sockfd); + return -1; + } + qDebug()<<"Success"; + return sockfd; +} -TCPConnection::TCPConnection(const std::string remote_ip, const int remote_port, MAV_MSG_CB cb) - :m_remote_ip(remote_ip),m_remote_port(remote_port),m_cb(cb) -{ +static bool linux_send_message(int sockfd,const std::string& dest_ip,const int dest_port,const uint8_t* data,int data_len){ + struct sockaddr_in dest_addr {}; + dest_addr.sin_family = AF_INET; + inet_pton(AF_INET, dest_ip.c_str(), &dest_addr.sin_addr.s_addr); + dest_addr.sin_port = htons(dest_port); +#ifdef MSG_NOSIGNAL + auto flags = MSG_NOSIGNAL; +#else + auto flags = 0; // No MSG_NOSIGNAL available, handle it accordingly +#endif + const auto send_len = sendto( + sockfd, + reinterpret_cast(data), + data_len, + flags, + reinterpret_cast(&dest_addr), + sizeof(dest_addr)); + if (send_len != data_len) { + return false; + } + return true; +} + +TCPConnection::TCPConnection(MAV_MSG_CB cb):m_cb(cb) +{ } TCPConnection::~TCPConnection() { - stop(); + stop_receiving(); } -void TCPConnection::start() +bool TCPConnection::try_connect_and_receive(const std::string remote_ip, const int remote_port) { - m_keep_receiving=true; - m_receive_thread=std::make_unique(&TCPConnection::loop_receive,this); + m_remote_ip=remote_ip; + m_remote_port=remote_port; + m_socket_fd=linux_tcp_socket_try_connect(remote_ip,remote_port,2); + if(m_socket_fd!=-1){ + qDebug()<<"TCP connect success"; + m_keep_receiving=true; + m_receive_thread=std::make_unique(&TCPConnection::receive_until_stopped,this); + return true; + } + return false; } -void TCPConnection::stop() +void TCPConnection::stop_receiving() { - m_keep_receiving=false; + if(m_receive_thread!=nullptr){ + m_keep_receiving=false; #ifdef __windows__ - shutdown(m_socket_fd, SD_BOTH); + shutdown(m_socket_fd, SD_BOTH); - closesocket(m_socket_fd); + closesocket(m_socket_fd); - WSACleanup(); -#else + WSACleanup(); +#else \ // This should interrupt a recv/recvfrom call. - shutdown(m_socket_fd, SHUT_RDWR); - // But on Mac, closing is also needed to stop blocking recv/recvfrom. - close(m_socket_fd); + shutdown(m_socket_fd, SHUT_RDWR); + // But on Mac, closing is also needed to stop blocking recv/recvfrom. + close(m_socket_fd); #endif - if(m_receive_thread){ m_receive_thread->join(); + m_receive_thread=nullptr; } - m_receive_thread=nullptr; } + void TCPConnection::send_message(const mavlink_message_t &msg) { - if(!m_is_connected){ + uint8_t buffer[MAVLINK_MAX_PACKET_LEN]; + const int buffer_len = mavlink_msg_to_send_buffer(buffer, &msg); + if(!m_keep_receiving){ return; // Otherwise sendto blocks } - struct sockaddr_in dest_addr {}; - dest_addr.sin_family = AF_INET; - inet_pton(AF_INET, m_remote_ip.c_str(), &dest_addr.sin_addr.s_addr); - dest_addr.sin_port = htons(m_remote_port); - - uint8_t buffer[MAVLINK_MAX_PACKET_LEN]; - const uint16_t buffer_len = mavlink_msg_to_send_buffer(buffer, &msg); - - // TODO: remove this assert again - assert(buffer_len <= MAVLINK_MAX_PACKET_LEN); - #ifdef MSG_NOSIGNAL - auto flags = MSG_NOSIGNAL; - #else - auto flags = 0; // No MSG_NOSIGNAL available, handle it accordingly - #endif - const auto send_len = sendto( - m_socket_fd, - reinterpret_cast(buffer), - buffer_len, - flags, - reinterpret_cast(&dest_addr), - sizeof(dest_addr)); - - if (send_len != buffer_len) { + if(!linux_send_message(m_socket_fd,m_remote_ip,m_remote_port,buffer,buffer_len)){ qDebug()<<"Cannot send message"; } } +bool TCPConnection::threadsafe_is_alive() +{ + const int32_t now_ms=QOpenHDMavlinkHelper::getTimeMilliseconds();; + const auto elapsed=now_ms-m_last_data_ms; + return elapsed <= 3*1000; +} + void TCPConnection::process_data(const uint8_t *data, int data_len) { for (int i = 0; i < data_len; i++) { @@ -101,72 +172,29 @@ void TCPConnection::process_mavlink_message(mavlink_message_t message) m_cb(message); } -void TCPConnection::loop_receive() -{ - while (m_keep_receiving) { - qDebug()<<"TCP start on "<(&remote_addr), sizeof(struct sockaddr_in)) <0) { - qDebug()<<"Socket connect failed: "<(buffer), sizeof(buffer), 0); + if (recv_len == 0) { + // This can happen when shutdown is called on the socket, + // therefore we check _should_exit again. + continue; + } -void TCPConnection::connect_once() -{ - const bool success=setup_socket(); - if(success){ - // TCP connection established, receive data until error / stop() is called - m_is_connected=true; - // Enough for MTU 1500 bytes. - uint8_t buffer[2048]; - while (m_keep_receiving) { - const auto recv_len = recv(m_socket_fd, reinterpret_cast(buffer), sizeof(buffer), 0); - - if (recv_len == 0) { - // This can happen when shutdown is called on the socket, - // therefore we check _should_exit again. - continue; - } - - if (recv_len < 0) { - // This happens on desctruction when close(_socket_fd) is called, - // therefore be quiet. - // LogErr() << "recvfrom error: " << GET_ERROR(errno); - // Something went wrong, we should try to re-connect in next iteration. - continue; - } - process_data(buffer,recv_len); + if (recv_len < 0) { + // This happens on desctruction when close(_socket_fd) is called, + // therefore be quiet. + // LogErr() << "recvfrom error: " << GET_ERROR(errno); + // Something went wrong, we should try to re-connect in next iteration. + continue; } + process_data(buffer,recv_len); } - m_is_connected=false; } + diff --git a/app/telemetry/connection/tcp_connection.h b/app/telemetry/connection/tcp_connection.h index f735431d2..7bd4a3fa3 100644 --- a/app/telemetry/connection/tcp_connection.h +++ b/app/telemetry/connection/tcp_connection.h @@ -15,28 +15,34 @@ class TCPConnection { public: typedef std::function MAV_MSG_CB; - TCPConnection(const std::string remote_ip,const int remote_port,MAV_MSG_CB cb); + TCPConnection(MAV_MSG_CB cb); ~TCPConnection(); + // This returns after 3 max 3 seconds. + // On success, true is returned and the receive thread is started (runs untl stop_receiving is called) + // Otherwise, return false; + bool try_connect_and_receive(const std::string remote_ip,const int remote_port); - void start(); - void stop(); + // If currently receiving, terminate and clean up + // Otherwise, do nothing + void stop_receiving(); void send_message(const mavlink_message_t& msg); + + bool threadsafe_is_alive(); private: void process_data(const uint8_t* data,int data_len); void process_mavlink_message(mavlink_message_t msg); - void loop_receive(); - bool setup_socket(); - void connect_once(); + void receive_until_stopped(); private: - const std::string m_remote_ip; - const int m_remote_port; - const MAV_MSG_CB m_cb; + MAV_MSG_CB m_cb; int m_socket_fd=-1; mavlink_status_t m_recv_status{}; std::unique_ptr m_receive_thread=nullptr; - std::atomic m_keep_receiving=false; - std::atomic m_is_connected=false; + std::atomic_int32_t m_last_data_ms=0; +public: + std::string m_remote_ip; + int m_remote_port; + std::atomic_bool m_keep_receiving=false; }; #endif // TCPCONNECTION_H diff --git a/app/telemetry/connection/udp_connection.cpp b/app/telemetry/connection/udp_connection.cpp index cbd715760..d134f0566 100644 --- a/app/telemetry/connection/udp_connection.cpp +++ b/app/telemetry/connection/udp_connection.cpp @@ -1,4 +1,5 @@ #include "udp_connection.h" +#include "util/qopenhdmavlinkhelper.hpp" #ifdef __windows__ #define _WIN32_WINNT 0x0600 //TODO dirty @@ -92,6 +93,12 @@ void UDPConnection::send_message(const mavlink_message_t &msg) } } +bool UDPConnection::threadsafe_is_alive(){ + const int32_t now_ms=QOpenHDMavlinkHelper::getTimeMilliseconds();; + const auto elapsed=now_ms-m_last_data_ms; + return elapsed <= 3*1000; +} + void UDPConnection::process_data(const uint8_t *data, int data_len) { for (int i = 0; i < data_len; i++) { @@ -187,6 +194,7 @@ void UDPConnection::connect_once() const std::string remote_ip=inet_ntoa(src_addr.sin_addr); const int remote_port=ntohs(src_addr.sin_port); set_remote(remote_ip,remote_port); + m_last_data_ms=QOpenHDMavlinkHelper::getTimeMilliseconds(); process_data(buffer,recv_len); } } diff --git a/app/telemetry/connection/udp_connection.h b/app/telemetry/connection/udp_connection.h index 822fe8d7f..c08d25a44 100644 --- a/app/telemetry/connection/udp_connection.h +++ b/app/telemetry/connection/udp_connection.h @@ -29,6 +29,9 @@ class UDPConnection void send_message(const mavlink_message_t& msg); + // Returns true if the last received message is not older than X seconds + bool threadsafe_is_alive(); + private: void process_data(const uint8_t* data,int data_len); void process_mavlink_message(mavlink_message_t msg); @@ -57,6 +60,7 @@ class UDPConnection std::atomic m_keep_receiving=false; std::mutex m_remote_nutex; std::optional m_curr_remote; + std::atomic_int32_t m_last_data_ms=0; }; #endif // MUDPLINK_H diff --git a/app/telemetry/settings/wblinksettingshelper.cpp b/app/telemetry/settings/wblinksettingshelper.cpp index 6c59897c3..e3e943e64 100644 --- a/app/telemetry/settings/wblinksettingshelper.cpp +++ b/app/telemetry/settings/wblinksettingshelper.cpp @@ -161,7 +161,21 @@ void WBLinkSettingsHelper::process_message_openhd_wifibroadcast_scan_channels_pr } HUDLogMessagesModel::instance().add_message_info(ss.str().c_str()); qDebug()<ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml ui/configpopup/openhd_settings/PopupScanChannels.qml ui/configpopup/openhd_settings/PopupTxPowerEditor.qml + ui/elements/TextOrWarningButton.qml + ui/configpopup/status/StatusCardRow.qml + ui/configpopup/connect/PaneX.qml diff --git a/qml/ui/configpopup/ConfigPopup.qml b/qml/ui/configpopup/ConfigPopup.qml index 8d7fe5852..2af0d6f00 100644 --- a/qml/ui/configpopup/ConfigPopup.qml +++ b/qml/ui/configpopup/ConfigPopup.qml @@ -48,12 +48,12 @@ Rectangle { function user_quidance_open_connect_screen(){ openSettings(); - mainStackLayout.currentIndex=7; + mainStackLayout.currentIndex=5; } function user_guidance_open_openhd_settings_find_air_unit_location(){ openSettings(); - mainStackLayout.currentIndex=2; + mainStackLayout.currentIndex=1; mavlinkAllSettingsPanel.user_quidance_animate_channel_scan(); } @@ -176,19 +176,20 @@ Rectangle { m_selection_index: 0 } - // QOpenHD Settings - AppSettingsPanel - ConfigPopupSidebarButton{ - id: qopenhd_button - m_icon_text: "\uf013" - m_description_text: "QOpenHD" - m_selection_index: 1 - } - // OpenHD Settings - MavlinkAllSettingsPanel ConfigPopupSidebarButton{ id: openhd_button m_icon_text: "\uf085" m_description_text: "OpenHD" + m_selection_index: 1 + } + + // (QOpenHD Settings - AppSettingsPanel) + // OSD + ConfigPopupSidebarButton{ + id: qopenhd_button + m_icon_text: "\uf013" + m_description_text: "OSD" m_selection_index: 2 } @@ -208,13 +209,22 @@ Rectangle { m_selection_index: 4 } + // We only need the connect panel on android (external device) + // On localhost, QOpenHD "automatically" connects due to udp localhost method + ConfigPopupSidebarButton{ + visible: m_show_connect_option + id: connect_button + m_icon_text: "\uf6ff" + m_description_text: "Connect" + m_selection_index: 5 + } // Credits and copyright ConfigPopupSidebarButton{ id: credits m_icon_text: "\uf005" m_description_text: "Credits" - m_selection_index: 5 + m_selection_index: 6 } // Developer stats @@ -222,19 +232,8 @@ Rectangle { id: developerstats m_icon_text: "\uf0ad" m_description_text: "DEV" - m_selection_index: 6 - } - - // We only need the connect panel on android (external device) - // On localhost, QOpenHD "automatically" connects due to udp localhost method - ConfigPopupSidebarButton{ - visible: m_show_connect_option - id: connect_button - m_icon_text: "\uf6ff" - m_description_text: "Connect" m_selection_index: 7 } - } } @@ -257,12 +256,13 @@ Rectangle { id: statusPanel } - AppSettingsPanel { - id: appSettingsPanel + //this is "openhd" menu + MavlinkAllSettingsPanel { + id: mavlinkAllSettingsPanel } - MavlinkAllSettingsPanel { - id: mavlinkAllSettingsPanel //this is "openhd" menu + AppSettingsPanel { + id: appSettingsPanel } LogMessagesStatusView{ @@ -273,6 +273,10 @@ Rectangle { id: rcInfoPanel } + ConnectPanel{ + id: connectPanel + } + Credits { id: creditspanel } @@ -280,9 +284,7 @@ Rectangle { AppDeveloperStatsPanel { id: appDeveloperStatsPanel } - ConnectPanel{ - id: connectPanel - } + } } diff --git a/qml/ui/configpopup/connect/ConnectPanel.qml b/qml/ui/configpopup/connect/ConnectPanel.qml index 2b85eeb76..de48c9190 100644 --- a/qml/ui/configpopup/connect/ConnectPanel.qml +++ b/qml/ui/configpopup/connect/ConnectPanel.qml @@ -26,6 +26,9 @@ Item { TabBar { id: selectItemInStackLayoutBar width: parent.width + TabButton { + text: qsTr("HMM") + } TabButton { text: qsTr("TCP") } @@ -59,6 +62,10 @@ Item { currentIndex: selectItemInStackLayoutBar.currentIndex + PaneX{ + + } + PaneCustom{ } diff --git a/qml/ui/configpopup/connect/PaneX.qml b/qml/ui/configpopup/connect/PaneX.qml new file mode 100644 index 000000000..52081b32b --- /dev/null +++ b/qml/ui/configpopup/connect/PaneX.qml @@ -0,0 +1,167 @@ +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Dialogs 1.0 +import QtQuick.Controls.Material 2.12 + +import Qt.labs.settings 1.0 + +import OpenHD 1.0 + +import "../../../ui" as Ui +import "../../elements" + +Item { + id: main_item + width: parent.width + height: parent.height + + Rectangle{ + color: "white" + implicitWidth: main_item.width + implicitHeight: main_item.height + } + + Text{ + id: info_text + width: parent.width + height: 200 + anchors.top: parent.top; + anchors.left: parent.left; + text: { + return "Connect QOpenHD (this ground controll aplication) to your ground station."+ + "AUTO: Works for all recommended networking setups\n"+ + "MANUAL: For developers / advanced networking only. Read the wiki for more Info."; + } + } + + ComboBox { + id: connection_mode_dropdown + anchors.top: info_text.bottom; + + width: parent.width + height: 60 + + model: ListModel { + id: font_text + ListElement { text: "AUTO" } + ListElement { text: "MANUAL UDP" } + ListElement { text: "MANUAL TCP" } + } + } + Text{ + id: connection_status + width: parent.width + height: 30 + text: _mavlinkTelemetry.telemetry_connection_status + anchors.top: connection_mode_dropdown.bottom + anchors.left: parent.left + } + + Rectangle{ + width: parent.width + height: 400 + anchors.top: connection_status.bottom + anchors.left: parent.left + + visible: connection_mode_dropdown.currentIndex==0; + + ColumnLayout { + spacing: 6 + Layout.fillWidth: true + Layout.fillHeight: true + + RowLayout { + Button{ + text: "Android Tethering" + Layout.preferredWidth: 180 + onClicked: _qopenhd.android_open_tethering_settings() + } + ButtonIconInfoText { + m_info_text: "1) Connect your phone via high quality USB cable to your ground station.\n\n"+ + "2) enable USB Tethering on your phone.\n\n"+ + "3) Telemetry and video forwarding is started automatically \n\n"+ + " ! Requires a phone and cellular contract that allows USB tethering. !" + } + } + RowLayout { + Button{ + text: "Passive Eth tethering" + Layout.preferredWidth: 180 + //TODO disable active tethering and enable passive when clicking the button + } + ButtonIconInfoText { + m_info_text: "1) Disable ETH_HOTSPOT_E and Enable ETH_PASSIVE_F\n\n"+ + "2) Connect your external device to your ground station via ethernet.\n\n"+ + "3) Select 'share my internet with ...' when the android connection setup pops up\n\n"+ + "Video and telemetry forwarding should start automatically, internet will be forwarded from your phone." + } + } + RowLayout { + Button{ + text: "Active Eth tethering" + Layout.preferredWidth: 180 + //TODO disable passive tethering and enable active when clicking the button + } + ButtonIconInfoText { + m_info_text: "1) Disable ETH_PASSIVE_F and Enable ETH_HOTSPOT_E\n\n"+ + "2) Connect your external device to your ground station via ethernet.\n\n"+ + "You might need to disable wifi and cellular on your phone\n\n"+ + "Video and telemetry forwarding should start automatically, internet will not be available." + } + } + RowLayout { + Button{ + text: "Wifi tethering" + Layout.preferredWidth: 180 + //TODO enable hotspot + } + ButtonIconInfoText { + m_info_text: "1) Enable WIFI_HOTSPOT_E\n\n"+ + "2) Connect to WiFi: openhd pw openhdopenhd\n\n"+ + "3) Press 'Connect' button.\n\n"+ + "NOTE: You cannot use WIFI hotspot during flight (while armed)" + } + } + // padding to bottom + Item { + Layout.fillHeight: true + Layout.fillWidth: true + } + } + } + Rectangle{ + width:parent.width + height: 200 + anchors.top: connection_status.bottom + anchors.left: parent.left + visible: connection_mode_dropdown.currentIndex==1; + + } + Rectangle{ + width: parent.width + height: 200 + anchors.top: connection_status.bottom + anchors.left: parent.left + visible: connection_mode_dropdown.currentIndex==2; + GridLayout { + columns: 2 + TextField { + id: textFieldip + validator: RegExpValidator { + regExp: /^((?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.){0,3}(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])$/ + } + inputMethodHints: Qt.ImhFormattedNumbersOnly + text: "192.168.178.36" //settings.dev_mavlink_tcp_ip + } + Button{ + text: "SAVE" + onClicked: { + + } + } + + } + } + +} diff --git a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml index 02d9595f2..d1532a5c2 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml +++ b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml @@ -21,7 +21,8 @@ import QtCharts 2.0 Rectangle{ width: parent.width height: parent.height - property color m_background_color: "#8cbfd7f3" + //property color m_background_color: "#8cbfd7f3" + property color m_background_color: "#ADD8E6" function user_quidance_animate_channel_scan(){ console.log("User guidance animate channel scan"); @@ -243,7 +244,7 @@ Rectangle{ change_frequency_sync_otherwise_handle_error(selectedValue,-1,false); } //Material.background: fc_is_armed() ? Material.Red : Material.Normal; - enabled: _wbLinkSettingsHelper.ui_rebuild_models>=0 && _ohdSystemGround.is_alive; + enabled: _wbLinkSettingsHelper.ui_rebuild_models>=0 && (_ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0); Layout.row: 1 Layout.column: 1 } diff --git a/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml b/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml index ed3b7aef5..62776abec 100644 --- a/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml +++ b/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml @@ -21,7 +21,8 @@ Rectangle{ height: parent.height /2 anchors.bottom: parent.bottom anchors.left: parent.left - color: "#8cbfd7f3" + //color: "#8cbfd7f3" + color: "#ADD8E6" function open(){ visible=true diff --git a/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml b/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml index 0978d95ba..3cf28d5fe 100644 --- a/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml +++ b/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml @@ -21,7 +21,8 @@ Rectangle{ height: parent.height /2 anchors.bottom: parent.bottom anchors.left: parent.left - color: "#8cbfd7f3" + //color: "#8cbfd7f3" + color: "#ADD8E6" function open(){ visible=true diff --git a/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml b/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml index 6fff3ba9a..bac4aa5fc 100644 --- a/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml +++ b/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml @@ -21,7 +21,8 @@ Rectangle{ height: parent.height /2 anchors.bottom: parent.bottom anchors.left: parent.left - color: "#8cbfd7f3" + //color: "#8cbfd7f3" + color: "#ADD8E6" property bool m_is_air: false @@ -72,7 +73,8 @@ Rectangle{ ListElement {title: "SELECT MANUFACTURER"; value: -1} ListElement {title: "ASUS"; value: 0} ListElement {title: "ALIEXPRESS"; value: 1} - ListElement {title: "OTHER"; value: 2} + ListElement {title: "OpenHD HW"; value: 2} + ListElement {title: "OTHER"; value: 3} } ListModel{ id: model_rtl8812bu_manufacturers @@ -109,9 +111,18 @@ Rectangle{ ListElement {title: "HIGH [24]"; value: 24} ListElement {title: "MAX [26]"; value: 26} } + ListModel{ + id: model_rtl8812au_manufacturer_openhd + ListElement {title: "Please select"; value: -1} + ListElement {title: "LOW [3] ~25mW"; value: 3} + ListElement {title: "MEDIUM [5] ~200mW"; value: 5} + ListElement {title: "HIGH [10] ~1W"; value: 10} + ListElement {title: "MAX [12] ~2W"; value: 12} + } ListModel{ id: model_rtl8812au_manufacturer_generic ListElement {title: "Please select"; value: -1} + ListElement {title: "[10] (DANGER,ARBITRARY)"; value: 10} ListElement {title: "[22] (DANGER,ARBITRARY)"; value: 22} ListElement {title: "[37] (DANGER,ARBITRARY)"; value: 37} ListElement {title: "[53] (DANGER,ARBITRARY)"; value: 53} @@ -137,39 +148,39 @@ Rectangle{ ListElement {title: "<=20000mW (maybe)"; value: 2000} } - function get_model_txpower_for_chip_type_manufacturer(){ + function get_model_txpower_for_chip_type_manufacturer(add_selection_disable){ var chip_type=get_chipset_type(); var manufacturer=m_user_selected_card_manufacturer; if(manufacturer<0){ return model_error; } + var ret; if(chip_type==0){ // RTL8812AU if(manufacturer==0){ - return model_rtl8812au_manufacturer_asus_txpower; + ret=model_rtl8812au_manufacturer_asus_txpower; }else if(manufacturer==1){ - return model_rtl8812au_manufacturer_aliexpress_hp; + ret=model_rtl8812au_manufacturer_aliexpress_hp; + }else if(manufacturer==2){ + ret=model_rtl8812au_manufacturer_openhd; + }else{ + ret=model_rtl8812au_manufacturer_generic; } - return model_rtl8812au_manufacturer_generic; }else if(chip_type==1){ // RTL8812BU if(m_card_manufacturer_type==0){ - return model_rtl8812bu_manufacturer_comfast; + ret= model_rtl8812bu_manufacturer_comfast; + }else{ + ret = model_rtl8812bu_manufacturer_generic; } - return model_rtl8812bu_manufacturer_generic; - } - return model_error; - } - - - function get_text_wifi_tx_power(){ - // "99 TPI DISARM: XX ARM: XX"; - if(m_is_air){ - if(!_wifi_card_air.alive) return "N/A"; - return ""+_wifi_card_air.tx_power+" "+_wifi_card_air.tx_power_unit+" DISARM:"+_wifi_card_air.tx_power_disarmed+" ARM:"+_wifi_card_air.tx_power_armed + }else{ + ret = model_error; } - if(!_wifi_card_gnd0.alive) return "N/A"; - return ""+_wifi_card_gnd0.tx_power+" "+_wifi_card_gnd0.tx_power_unit+" DISARM:"+_wifi_card_gnd0.tx_power_disarmed+" ARM:"+_wifi_card_gnd0.tx_power_armed + // Armed has the extra option of tx power==0, which means the disarmed tx power is applied regardless if armed or not + //if(add_selection_disable){ + // ret.insert(1,{title: "DISABLE", value: 0}); + //} + return ret; } // state 0: current state 1: disarmed state 2: armed @@ -233,7 +244,7 @@ Rectangle{ leftPadding: 12 rightPadding: 12 id: combo_box_txpower_disarmed - model: get_model_txpower_for_chip_type_manufacturer() + model: get_model_txpower_for_chip_type_manufacturer(false) textRole: "title" enabled: m_user_selected_card_manufacturer>=0; } @@ -247,7 +258,7 @@ Rectangle{ return; } var is_tx_power_index_unit = get_chipset_type()==0; - var success = _wbLinkSettingsHelper.set_param_tx_power(m_is_ground,is_tx_power_index_unit,m_change_armed,tx_power_index_or_mw) + var success = _wbLinkSettingsHelper.set_param_tx_power(!m_is_air,is_tx_power_index_unit,false,tx_power_index_or_mw) if(success==true){ _qopenhd.show_toast("SUCCESS"); }else{ @@ -275,7 +286,7 @@ Rectangle{ leftPadding: 12 rightPadding: 12 id: combo_box_txpower_armed - model: get_model_txpower_for_chip_type_manufacturer() + model: get_model_txpower_for_chip_type_manufacturer(true) textRole: "title" enabled: m_user_selected_card_manufacturer>=0; } @@ -290,7 +301,7 @@ Rectangle{ return; } var is_tx_power_index_unit = get_chipset_type()==0; - var success = _wbLinkSettingsHelper.set_param_tx_power(m_is_ground,is_tx_power_index_unit,m_change_armed,tx_power_index_or_mw) + var success = _wbLinkSettingsHelper.set_param_tx_power(!m_is_air,is_tx_power_index_unit,true,tx_power_index_or_mw) if(success==true){ _qopenhd.show_toast("SUCCESS"); }else{ diff --git a/qml/ui/configpopup/rc/RcInfoScreen.qml b/qml/ui/configpopup/rc/RcInfoScreen.qml index df29a61e4..be3027e95 100644 --- a/qml/ui/configpopup/rc/RcInfoScreen.qml +++ b/qml/ui/configpopup/rc/RcInfoScreen.qml @@ -35,7 +35,9 @@ ScrollView { cardName: qsTr("Info") cardBody: Text { - text: qsTr("Enable OpenHD-RC: \n\n1.Set 'ENABLE_JOY_RC' to 'ENABLED',\n2.Connect a joystick\n3.Reboot\n\nYou can use the other screens to validate/debug your setup.\n\n") + text: qsTr("Enable OpenHD-RC: \n\n1. OpenHD GND: Set 'ENABLE_JOY_RC' to 'ENABLED',\n2.Connect a joystick via USB to GND Station\n3.Optionally reboot\n\nYou can use the other screens to validate/debug your setup.\n"+ + "NOTE: Using a seperate RC link (e.g. ExpressLRS) is recommended !\n" + ) height: 24 font.pixelSize: 14 leftPadding: 12 diff --git a/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml b/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml index df0881f8f..bd8bf50d9 100644 --- a/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml +++ b/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml @@ -25,6 +25,9 @@ ColumnLayout { property bool m_is_alive: m_model.is_alive property string m_qopenhd_version: "2.5.1-evo-alpha" + //fucking hell qt + property int m_font_pixel_size: 13 + function get_alive_text(){ return m_is_alive ? "Yes" : "NOT ALIVE !" } @@ -104,206 +107,139 @@ ColumnLayout { property int left_part_preferred_with: 100 - RowLayout{ - Layout.fillWidth: true - Layout.minimumHeight: text_minHeight - Layout.leftMargin: 12 - spacing: 3 - Text { - Layout.preferredWidth: left_part_preferred_with - text: qsTr("OHD Version:") - font.bold: true - } - Text { - text: m_version - color: "green" - visible: !b_version_warning.visible - } - ButtonSimple{ - text: m_version - id: b_version_warning - onClicked: { - var text_warning= m_is_ground ? get_text_qopenhd_openhd_ground_version_mismatch() : get_text_openhd_air_ground_version_mismatch() - _messageBoxInstance.set_text_and_show(text_warning) - } - visible: { - if(m_is_ground){ - // Show if ground reported version is valid and there is a mismatch OpenHD ground / QOpenHD - if(_ohdSystemGround.openhd_version=="N/A"){ - return false; - } - return _ohdSystemGround.openhd_version != m_qopenhd_version; - }else{ - // Show if ground and air reported version is valid and there is a mismatch - if(_ohdSystemGround.openhd_version=="N/A" || _ohdSystemAir.openhd_version=="N/A"){ - return false; - } - return _ohdSystemGround.openhd_version != _ohdSystemAir.openhd_version + StatusCardRow{ + m_left_text: qsTr("Version:") + m_right_text: m_version + m_has_error: { + if(m_is_ground){ + // Show if ground reported version is valid and there is a mismatch OpenHD ground / QOpenHD + if(_ohdSystemGround.openhd_version=="N/A"){ + return false; + } + return _ohdSystemGround.openhd_version != m_qopenhd_version; + }else{ + // Show if ground and air reported version is valid and there is a mismatch + if(_ohdSystemGround.openhd_version=="N/A" || _ohdSystemAir.openhd_version=="N/A"){ + return false; } + return _ohdSystemGround.openhd_version != _ohdSystemAir.openhd_version } - Layout.preferredHeight: text_minHeight - Layout.minimumHeight: text_minHeight - height: text_minHeight } - } - RowLayout{ - Layout.fillWidth: true - Layout.minimumHeight: text_minHeight - Layout.leftMargin: 12 - spacing: 3 - Text { - Layout.preferredWidth: left_part_preferred_with - text: qsTr("Last Ping:") - font.bold: true - } - Text { - text: m_last_ping - color: m_last_ping === "N/A" ? "#DC143C" : "green" + m_error_text: { + var text_warning= m_is_ground ? get_text_qopenhd_openhd_ground_version_mismatch() : get_text_openhd_air_ground_version_mismatch() + return text_warning; } } - RowLayout{ - Layout.fillWidth: true - Layout.minimumHeight: text_minHeight - Layout.leftMargin: 12 - spacing: 3 - Text { - Layout.preferredWidth: left_part_preferred_with - text: qsTr("Alive: ") - font.bold: true - } - Text { - text: get_alive_text() - color: get_alive_text_color() - } + StatusCardRow{ + m_left_text: qsTr("Ping:") + m_right_text: m_last_ping + m_right_text_color: m_last_ping === "N/A" ? "#DC143C" : "green" } - RowLayout{ - Layout.fillWidth: true - Layout.minimumHeight: text_minHeight - Layout.leftMargin: 12 - spacing: 3 - Text { - Layout.preferredWidth: left_part_preferred_with - text: qsTr(m_is_ground ? "OHD Card(s): " : "OHD Card:") - font.bold: true - } - ButtonSimple{ - id: b_unsupported_cards_warning - text: { - if(m_is_ground){ - if(!_ohdSystemGround.is_alive){ - return "N/A"; - } - var alive_count=get_gnd_active_cards(); - if(alive_count==0) return "WAITING"; - if(alive_count==1) return _wifi_card_gnd0.card_type_as_string; - return ""+alive_count+"x ARRAY"; - }else{ - // On air, we always have only one card - if(! _wifi_card_air.alive){ - return "N/A"; - } - return _wifi_card_air.card_type_as_string + StatusCardRow{ + m_left_text: qsTr("Alive: ") + m_right_text: get_alive_text() + m_right_text_color: get_alive_text_color() + } + StatusCardRow{ + m_left_text: qsTr(m_is_ground ? "Link HW: " : "Link HW:") + m_right_text: { + if(m_is_ground){ + if(!_ohdSystemGround.is_alive){ + return "N/A"; } + var alive_count=get_gnd_active_cards(); + if(alive_count==0) return "WAITING"; + if(alive_count==1) return _wifi_card_gnd0.card_type_as_string; + return ""+alive_count+"x ARRAY"; + }else{ + // On air, we always have only one card + if(! _wifi_card_air.alive){ + return "N/A"; + } + return _wifi_card_air.card_type_as_string } - onClicked: { - var show_message_card_unsupported=false; - if(m_is_ground){ - if(_wifi_card_gnd0.alive && !_wifi_card_gnd0.card_type_supported){ - show_message_card_unsupported=true; - } - }else{ - if(_wifi_card_air.alive && ! _wifi_card_air.card_type_supported){ - show_message_card_unsupported=true; - } + } + m_has_error: { + var show_message_card_unsupported=false; + if(m_is_ground){ + if(_wifi_card_gnd0.alive && !_wifi_card_gnd0.card_type_supported){ + show_message_card_unsupported=true; } - if(show_message_card_unsupported){ - var message="Using unsupported card(s) has side effects like non-working frequency changes, no uplink gnd-air or bad range. Be warned !"; - _messageBoxInstance.set_text_and_show(message); + }else{ + if(_wifi_card_air.alive && ! _wifi_card_air.card_type_supported){ + show_message_card_unsupported=true; } } - visible: { - return true; - } - Layout.preferredHeight: text_minHeight - Layout.minimumHeight: text_minHeight + return show_message_card_unsupported; + } + m_error_text: { + var message="Using unsupported card(s) has side effects like non-working frequency changes, no uplink gnd-air or bad range. Be warned !"; + return message; } } - RowLayout{ - Layout.fillWidth: true - Layout.minimumHeight: text_minHeight - Layout.leftMargin: 12 - + StatusCardRow{ visible: m_is_ground - Text{ - Layout.preferredWidth: left_part_preferred_with - text: "Uplink:" - font.bold: true + m_left_text: "Uplink:" + m_right_text: { + return gnd_uplink_state_text() } - Text{ - text: gnd_uplink_state_text() - color: "green" - visible: { - var gnd_up_state=gnd_uplink_state() - if(gnd_up_state===0 || gnd_up_state===1)return true; - return false; - } + m_has_error: { + return m_right_text=="ERROR" } - ButtonSimple{ - text: gnd_uplink_state_text() - onClicked: { - var message="Looks like your uplink (GND to AIR) is not functional - please use a supported card on your GND station"+ - " and make sure passive (listen only) mode is disabled on your ground station." - _messageBoxInstance.set_text_and_show(message) + m_error_text: { + var message="Looks like your uplink (GND to AIR) is not functional - please use a supported card on your GND station"+ + " and make sure passive (listen only) mode is disabled on your ground station." + return message; + } + } + StatusCardRow{ + visible: !m_is_ground + m_left_text: "AIR FC:" + m_right_text: { + var air_fc_sys_id=-1; + if(air_fc_sys_id==-1){ + return "NOT FOUND" } - visible: gnd_uplink_state()===-1; - Layout.preferredHeight: text_minHeight - Layout.minimumHeight: text_minHeight - height: text_minHeight + return ""+air_fc_sys_id; + } + m_right_text_color: { + var air_fc_sys_id=-1; + if(air_fc_sys_id==-1) return "orange"; + return "green"; } } - RowLayout{ - Layout.fillWidth: true - Layout.minimumHeight: text_minHeight - Layout.leftMargin: 12 - - visible: true - Text{ - Layout.preferredWidth: left_part_preferred_with - text: "WiFi Hotspot:" - font.bold: true + StatusCardRow{ + m_left_text: "WiFi HS:" + m_right_text: { + if(!m_model.is_alive || m_model.wifi_hotspot_state<0){ + return "N/A"; + } + if(m_model.wifi_hotspot_state==0){ + return "UNAVAILABLE"; + } + if(m_model.wifi_hotspot_state==1){ + return "DISABLED"; + } + return "ENABLED"; } - ButtonSimple{ - id: b_wifi_hs - text: { - if(!m_model.is_alive || m_model.wifi_hotspot_state<0){ - return "N/A"; - } - if(m_model.wifi_hotspot_state==0){ - return "UNAVAILABLE"; - } - if(m_model.wifi_hotspot_state==1){ - return "DISABLED"; - } - return "ENABLED"; + m_right_text_color: "black"; + m_right_text_color_error: "black"; + m_error_text: { + if(m_model.wifi_hotspot_state==0){ + var message="To use the WiFi hotspot feature on your air / ground unit you need to use a RPI / ROCK with integrated wifi module. " + return message; } - onClicked: { - if(!m_model.is_alive || m_model.wifi_hotspot_state<0){ - return; - } - if(m_model.wifi_hotspot_state==0){ - var message="To use the WiFi hotspot feature on your air / ground unit you need to use a RPI / ROCK with integrated wifi module. " - _messageBoxInstance.set_text_and_show(message) - } - if(m_model.wifi_hotspot_state==1 || m_model.wifi_hotspot_state==2){ - var message="WiFi hotspot is automatically disabled when armed, and enabled when disarmed. To change this behaviour (discouraged) set it to either always off / always on"; - _messageBoxInstance.set_text_and_show(message) - } + if(m_model.wifi_hotspot_state==1 || m_model.wifi_hotspot_state==2){ + var message="WiFi hotspot is automatically disabled when armed, and enabled when disarmed. To change this behaviour (discouraged) set it to either always off / always on"; + return message; } - Layout.preferredHeight: text_minHeight - Layout.minimumHeight: text_minHeight - height: text_minHeight + return "I should not appear"; + } + m_has_error: { + return m_right_text=="UNAVAILABLE"; } } + // Padding Item{ Layout.fillWidth: true diff --git a/qml/ui/configpopup/status/StatusCardRow.qml b/qml/ui/configpopup/status/StatusCardRow.qml new file mode 100644 index 000000000..15f1a2ba7 --- /dev/null +++ b/qml/ui/configpopup/status/StatusCardRow.qml @@ -0,0 +1,77 @@ +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Dialogs 1.1 +import QtQuick.Controls.Material 2.12 + +import Qt.labs.settings 1.0 + +import OpenHD 1.0 + +import "../../../ui" as Ui +import "../../elements" + +// Hard-coded layouting: +// 1/3 for left text (For example VERSION) +// 2/3 for value text +// value text can be color coded red, +// in which case it is clickable +// The general idea behind this element is to be green / pretty when everything is okay +// and red if something is wrong (in which case the user should click on it for more info) +Item { + Layout.minimumWidth: 50 + Layout.minimumHeight: 30 + // + Layout.preferredWidth: 300 + Layout.preferredHeight: 30 + + + id: main_item + property string m_left_text: "LEFT" + + property string m_right_text: "RIFGHT" + + property bool m_has_error: false + + property color m_right_text_color: "green" + property color m_right_text_color_error: "red" + + property string m_error_text: "NONE" + + // For debugging + /*Rectangle{ + implicitWidth: main_item.width + implicitHeight: main_item.height + color: "blue" + border.width: 3 + border.color: "black" + }*/ + + Text{ + id: left_part + width: parent.width/3 + height: parent.height + anchors.left: parent.left + anchors.top: parent.top + text: m_left_text + } + + Text{ + id: right_part + width: parent.width/3*2; + height: parent.height + anchors.left: left_part.right + anchors.top: left_part.top + text: m_right_text + color: m_has_error ? m_right_text_color_error : m_right_text_color + } + MouseArea { + enabled: m_has_error + anchors.fill: parent + onClicked: { + _messageBoxInstance.set_text_and_show(m_error_text) + } + } + + +} diff --git a/qml/ui/elements/TextOrWarningButton.qml b/qml/ui/elements/TextOrWarningButton.qml new file mode 100644 index 000000000..029422160 --- /dev/null +++ b/qml/ui/elements/TextOrWarningButton.qml @@ -0,0 +1,37 @@ +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Controls.Material 2.12 + +import Qt.labs.settings 1.0 + +import OpenHD 1.0 + + +// Shows a green text if everything is okay +// Otherwise, shows a button the user can click on to find out why the given +// warning is showing +Item { + + property bool m_show_warning: false + + property string m_info_text: "BLA" + property string m_warning_text: "HERE A WARNING SHOULD STAND" + + ButtonRed{ + width: parent.width + height: parent.height + onClicked: { + _messageBoxInstance.set_text_and_show(m_warning_text); + } + visible: m_show_warning + } + + Text{ + width: parent.width + height: parent.height + text: m_info_text + color: "green" + } + +} From 3601d65ab34db39a7f4ff187df5f70f368613cfb Mon Sep 17 00:00:00 2001 From: consti10 Date: Thu, 19 Oct 2023 15:12:04 +0200 Subject: [PATCH 09/81] UI stuff --- app/telemetry/MavlinkTelemetry.cpp | 45 +++- app/telemetry/MavlinkTelemetry.h | 6 + app/telemetry/connection/tcp_connection.cpp | 4 +- app/telemetry/models/aohdsystem.cpp | 2 + app/telemetry/models/aohdsystem.h | 2 + app/telemetry/settings/pollutionhelper.cpp | 3 +- app/telemetry/settings/pollutionhelper.h | 1 + .../settings/wblinksettingshelper.cpp | 18 +- app/telemetry/settings/wblinksettingshelper.h | 3 +- app/util/qopenhd.h | 1 + qml/qml.qrc | 28 +-- qml/ui/HUDOverlayGrid.qml | 9 + qml/ui/configpopup/connect/ConnectPanel.qml | 63 +----- .../configpopup/connect/GenericInfoPane.qml | 47 ----- .../connect/PaneConnectionMode.qml | 194 ++++++++++++++++++ qml/ui/configpopup/connect/PaneCustom.qml | 67 ------ qml/ui/configpopup/connect/PaneInfo.qml | 47 ----- qml/ui/configpopup/connect/PaneLocalhost.qml | 52 ----- qml/ui/configpopup/connect/PaneTethering.qml | 102 --------- qml/ui/configpopup/connect/PaneUSBTether.qml | 46 ----- qml/ui/configpopup/connect/PaneWIFI.qml | 45 ---- qml/ui/configpopup/connect/PaneX.qml | 167 --------------- .../MavlinkOpenHDWBParamPanel2.qml | 5 +- .../openhd_settings/MavlinkParamPanel.qml | 9 +- .../openhd_settings/PopupAnalyzeChannels.qml | 94 +++++---- .../openhd_settings/PopupScanChannels.qml | 18 +- .../openhd_settings/PopupTxPowerEditor.qml | 191 +++++++++++------ qml/ui/configpopup/status/PanelStatus.qml | 12 +- .../{ActionsColumn.qml => PingUtilColumn.qml} | 0 .../configpopup/status/QOpenHDVersionCard.qml | 69 ++++--- .../status/StatusCardBodyOpenHD.qml | 43 +++- qml/ui/configpopup/status/StatusCardRow.qml | 91 +++++--- .../configpopup/status/StatusCardsColumn.qml | 148 +++++++------ qml/ui/elements/AppSettings.qml | 3 + 34 files changed, 698 insertions(+), 937 deletions(-) delete mode 100644 qml/ui/configpopup/connect/GenericInfoPane.qml create mode 100644 qml/ui/configpopup/connect/PaneConnectionMode.qml delete mode 100644 qml/ui/configpopup/connect/PaneCustom.qml delete mode 100644 qml/ui/configpopup/connect/PaneInfo.qml delete mode 100644 qml/ui/configpopup/connect/PaneLocalhost.qml delete mode 100644 qml/ui/configpopup/connect/PaneTethering.qml delete mode 100644 qml/ui/configpopup/connect/PaneUSBTether.qml delete mode 100644 qml/ui/configpopup/connect/PaneWIFI.qml delete mode 100644 qml/ui/configpopup/connect/PaneX.qml rename qml/ui/configpopup/status/{ActionsColumn.qml => PingUtilColumn.qml} (100%) diff --git a/app/telemetry/MavlinkTelemetry.cpp b/app/telemetry/MavlinkTelemetry.cpp index 1966469b7..6662035c5 100644 --- a/app/telemetry/MavlinkTelemetry.cpp +++ b/app/telemetry/MavlinkTelemetry.cpp @@ -1,5 +1,6 @@ #include "MavlinkTelemetry.h" +#include "common/openhd-util.hpp" #include "models/aohdsystem.h" #include "models/fcmavlinksystem.h" @@ -17,6 +18,12 @@ MavlinkTelemetry::MavlinkTelemetry(QObject *parent):QObject(parent) void MavlinkTelemetry::start() { + QSettings settings; + int mavlink_connection_mode=settings.value("qopenhd_mavlink_connection_mode",0).toInt(); + if(mavlink_connection_mode<0 || mavlink_connection_mode>2)mavlink_connection_mode=0; + m_connection_mode=mavlink_connection_mode; + QString tcp_manual_ip=settings.value("qopenhd_mavlink_connection_manual_tcp_ip","192.168.178.36").toString(); + m_connction_manual_tcp_ip=std::make_shared(tcp_manual_ip.toStdString()); auto cb_udp=[this](mavlink_message_t msg){ process_mavlink_message(msg); }; @@ -261,6 +268,20 @@ void MavlinkTelemetry::re_apply_rates() FCMsgIntervalHandler::instance().restart(); } +void MavlinkTelemetry::change_telemetry_connection_mode(int mavlink_connection_mode) +{ + if(mavlink_connection_mode<0 || mavlink_connection_mode>2)mavlink_connection_mode=0; + m_connection_mode=mavlink_connection_mode; +} + +bool MavlinkTelemetry::change_manual_tcp_ip(QString ip) +{ + if(!OHDUtil::is_valid_ip(ip.toStdString())){ + return false; + } + m_connction_manual_tcp_ip=std::make_shared(ip.toStdString()); +} + void MavlinkTelemetry::send_heartbeat_loop() { while(true){ @@ -281,10 +302,7 @@ void MavlinkTelemetry::send_heartbeat_loop() void MavlinkTelemetry::perform_connection_management() { - QSettings settings; - int mavlink_connection_mode=settings.value("mavlink_connection_mode",0).toInt(); - if(mavlink_connection_mode<0 || mavlink_connection_mode>2)mavlink_connection_mode=0; - mavlink_connection_mode=0; + const int mavlink_connection_mode=m_connection_mode; if(mavlink_connection_mode==0){ // AUTO if(m_udp_connection->threadsafe_is_alive()){ @@ -292,10 +310,13 @@ void MavlinkTelemetry::perform_connection_management() m_tcp_connection->stop_receiving(); set_telemetry_connection_status("AUTO-CONNECTED(UDP,LOCALHOST)"); }else{ + if(!m_tcp_connection->threadsafe_is_alive()){ + set_telemetry_connection_status("AUTO-CONNECTING"); + } // UPP is not working, try TCP const std::string IP_CONSTI_TEST="192.168.178.36"; - //const std::string IP_OPENHD_WIFI_HOTSPOT="192.168.3.1"; - const std::string IP_OPENHD_WIFI_HOTSPOT=IP_CONSTI_TEST; + const std::string IP_OPENHD_WIFI_HOTSPOT="192.168.3.1"; + //const std::string IP_OPENHD_WIFI_HOTSPOT=IP_CONSTI_TEST; const std::string IP_OPENHD_ETHERNET_HOTSPOT="192.168.2.1"; if(m_tcp_connection->try_connect_and_receive(IP_OPENHD_WIFI_HOTSPOT,QOPENHD_OPENHD_GROUND_TCP_SERVER_PORT)){ set_telemetry_connection_status("AUTO-CONNECTED (WIFI,TCP)"); @@ -313,16 +334,22 @@ void MavlinkTelemetry::perform_connection_management() set_telemetry_connection_status(ss.str().c_str()); }else if(mavlink_connection_mode==2){ // Explicit TCP - const std::string user_ip="192.168.178.36"; + auto tmp=m_connction_manual_tcp_ip; + const std::string user_ip=*tmp; const int user_port=5760; - if(m_tcp_connection->m_remote_ip==user_ip && m_tcp_connection->m_remote_port==user_port){ + if(m_tcp_connection->m_remote_ip!=user_ip || m_tcp_connection->m_remote_port!=user_port){ if(!m_tcp_connection->threadsafe_is_alive()){ m_tcp_connection->stop_receiving(); m_tcp_connection->try_connect_and_receive(user_ip,user_port); } } std::stringstream ss; - ss<<"MANUAL TCP -"<<(m_udp_connection->threadsafe_is_alive() ? "CONNECTED" : "WRONG IP?"); + ss<<"MANUAL TCP -"; + if(m_udp_connection->threadsafe_is_alive()){ + ss<<"CONNECTED"; + }else{ + ss<<"WRONG IP ? ["< as soon as we got the first packet, we know the address to send data to for bidirectional communication @@ -88,6 +92,8 @@ class MavlinkTelemetry : public QObject PacketsPerSecondCalculator m_tele_pps_in; std::unique_ptr m_heartbeat_thread; std::atomic_bool m_heartbeat_thread_run; + std::atomic m_connection_mode; + std::shared_ptr m_connction_manual_tcp_ip; void send_heartbeat_loop(); void perform_connection_management(); }; diff --git a/app/telemetry/connection/tcp_connection.cpp b/app/telemetry/connection/tcp_connection.cpp index 5b687fafb..d252ed6ee 100644 --- a/app/telemetry/connection/tcp_connection.cpp +++ b/app/telemetry/connection/tcp_connection.cpp @@ -160,7 +160,7 @@ void TCPConnection::process_data(const uint8_t *data, int data_len) { for (int i = 0; i < data_len; i++) { mavlink_message_t msg; - uint8_t res = mavlink_parse_char(1, (uint8_t)data[i], &msg, &m_recv_status); + uint8_t res = mavlink_parse_char(1,data[i], &msg, &m_recv_status); if (res) { process_mavlink_message(msg); } @@ -179,7 +179,7 @@ void TCPConnection::receive_until_stopped() // Enough for MTU 1500 bytes. uint8_t buffer[2048]; while (m_keep_receiving) { - const auto recv_len = recv(m_socket_fd, reinterpret_cast(buffer), sizeof(buffer), 0); + const auto recv_len = recv(m_socket_fd, reinterpret_cast(&buffer), sizeof(buffer), 0); if (recv_len == 0) { // This can happen when shutdown is called on the socket, diff --git a/app/telemetry/models/aohdsystem.cpp b/app/telemetry/models/aohdsystem.cpp index 471d759cc..064b714e5 100644 --- a/app/telemetry/models/aohdsystem.cpp +++ b/app/telemetry/models/aohdsystem.cpp @@ -273,6 +273,8 @@ void AOHDSystem::process_onboard_computer_status(const mavlink_onboard_computer_ set_ina219_current_milliamps(msg.storage_usage[3]); set_ram_usage_perc(msg.ram_usage); set_ram_total(msg.ram_total); + int16_t air_reported_sys_id=msg.fan_speed[0]; + set_air_reported_fc_sys_id(air_reported_sys_id); } void AOHDSystem::process_x0(const mavlink_openhd_stats_monitor_mode_wifi_card_t &msg){ diff --git a/app/telemetry/models/aohdsystem.h b/app/telemetry/models/aohdsystem.h index fe25549c6..b62ccfe19 100644 --- a/app/telemetry/models/aohdsystem.h +++ b/app/telemetry/models/aohdsystem.h @@ -116,6 +116,8 @@ class AOHDSystem : public QObject L_RO_PROP(int,wifi_hotspot_frequency,set_wifi_hotspot_frequency,-1) // L_RO_PROP(int,wb_gnd_operating_mode,set_wb_gnd_operating_mode,-1) + // + L_RO_PROP(int,air_reported_fc_sys_id,set_air_reported_fc_sys_id,-1) private: const bool m_is_air; // either true (for air) or false (for ground) uint8_t get_own_sys_id()const{ diff --git a/app/telemetry/settings/pollutionhelper.cpp b/app/telemetry/settings/pollutionhelper.cpp index 0ee7750e7..6dd4d02c4 100644 --- a/app/telemetry/settings/pollutionhelper.cpp +++ b/app/telemetry/settings/pollutionhelper.cpp @@ -21,7 +21,8 @@ static std::vector normalize(const std::vecto if(max==0)return values; std::vector ret; for(auto value:values){ - value.n_foreign_packets=value.n_foreign_packets*100 / max; + value.n_foreign_packets_normalized=value.n_foreign_packets*100 / max; + //value.n_foreign_packets=value.n_foreign_packets*100 / max; ret.push_back(value); } return ret; diff --git a/app/telemetry/settings/pollutionhelper.h b/app/telemetry/settings/pollutionhelper.h index aad2e633f..555de471f 100644 --- a/app/telemetry/settings/pollutionhelper.h +++ b/app/telemetry/settings/pollutionhelper.h @@ -20,6 +20,7 @@ class PollutionHelper int frequency_mhz; int width_mhz; int n_foreign_packets; + int n_foreign_packets_normalized; }; void threadsafe_update(const std::vector& values); std::optional threadsafe_get_pollution_for_frequency(int frequency); diff --git a/app/telemetry/settings/wblinksettingshelper.cpp b/app/telemetry/settings/wblinksettingshelper.cpp index e3e943e64..b393db83b 100644 --- a/app/telemetry/settings/wblinksettingshelper.cpp +++ b/app/telemetry/settings/wblinksettingshelper.cpp @@ -331,15 +331,6 @@ QString WBLinkSettingsHelper::get_frequency_description(int frequency_mhz) return ss.str().c_str(); } -int WBLinkSettingsHelper::get_frequency_pollution(int frequency_mhz) -{ - auto pollution=PollutionHelper::instance().threadsafe_get_pollution_for_frequency(frequency_mhz); - if(pollution.has_value()){ - return pollution.value().n_foreign_packets; - } - return -1; -} - bool WBLinkSettingsHelper::get_frequency_radar(int frequency_mhz) { const auto frequency_item=find_frequency_item(frequency_mhz); @@ -516,13 +507,18 @@ QStringList WBLinkSettingsHelper::pollution_frequencies_int_to_qstringlist(QList return ret; } -QVariantList WBLinkSettingsHelper::pollution_frequencies_int_get_pollution(QList frequencies) +QVariantList WBLinkSettingsHelper::pollution_frequencies_int_get_pollution(QList frequencies,bool normalize) { QVariantList ret; for(auto& freq: frequencies){ auto pollution=PollutionHelper::instance().threadsafe_get_pollution_for_frequency(freq); if(pollution.has_value()){ - ret.push_back(static_cast(pollution.value().n_foreign_packets)); + if(normalize){ + ret.push_back(static_cast(pollution.value().n_foreign_packets_normalized)); + }else{ + ret.push_back(static_cast(pollution.value().n_foreign_packets)); + } + }else{ ret.push_back(static_cast(0)); } diff --git a/app/telemetry/settings/wblinksettingshelper.h b/app/telemetry/settings/wblinksettingshelper.h index 5eedec40e..455b29676 100644 --- a/app/telemetry/settings/wblinksettingshelper.h +++ b/app/telemetry/settings/wblinksettingshelper.h @@ -97,10 +97,9 @@ class WBLinkSettingsHelper : public QObject // To not overload the user, we filter the frequencies a bit Q_INVOKABLE QList get_supported_frequencies_filtered(int filter_level); Q_INVOKABLE QStringList pollution_frequencies_int_to_qstringlist(QList frequencies); - Q_INVOKABLE QVariantList pollution_frequencies_int_get_pollution(QList frequencies); + Q_INVOKABLE QVariantList pollution_frequencies_int_get_pollution(QList frequencies,bool normalize=false); Q_INVOKABLE QString get_frequency_description(int frequency_mhz); - Q_INVOKABLE int get_frequency_pollution(int frequency_mhz); Q_INVOKABLE bool get_frequency_radar(int frequency_mhz); Q_INVOKABLE bool get_frequency_simplify(int frequency_mhz); Q_INVOKABLE bool get_frequency_reccommended(int frequency_mhz); diff --git a/app/util/qopenhd.h b/app/util/qopenhd.h index 3c1b21ec5..1e0c9b11b 100644 --- a/app/util/qopenhd.h +++ b/app/util/qopenhd.h @@ -68,6 +68,7 @@ class QOpenHD : public QObject // Tries to mimic android toast as much as possible // Q_INVOKABLE void show_toast(QString message,bool long_toast=false); + L_RO_PROP(QString,version_string,set_version_string,"2.5.1-alpha"); public: L_RO_PROP(QString,toast_text,set_toast_text,"NONE"); L_RO_PROP(bool,toast_visible,set_toast_visible,false); diff --git a/qml/qml.qrc b/qml/qml.qrc index 55c7539d3..bb7667f7f 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -1,33 +1,33 @@ - + ../translations/QOpenHD_en.qm resources/cursors/arrow_512_green.png resources/cursors/arrow_512_transparent.png resources/cursors/arrow_512_white.png resources/cursors/hand_white.png - + ../translations/QOpenHD_de.qm - + ../translations/QOpenHD_ru.qm - + ../translations/QOpenHD_es.qm - + ../translations/QOpenHD_fr.qm - + ../translations/QOpenHD_nl.qm - + ../translations/QOpenHD_ro.qm - + ../translations/QOpenHD_it.qm - + ../translations/QOpenHD_zh.qm @@ -230,10 +230,7 @@ ui/widgets/map/MapWidgetForm.ui.qml ui/widgets/map/MapWidget.qml ui/configpopup/status/StatusCardsColumn.qml - ui/configpopup/status/ActionsColumn.qml - ui/configpopup/connect/PaneUSBTether.qml - ui/configpopup/connect/PaneWIFI.qml - ui/configpopup/connect/PaneCustom.qml + ui/configpopup/status/PingUtilColumn.qml ui/elements/ButtonRed.qml ui/elements/ButtonOrange.qml ui/configpopup/status/FooterRebootShutdownWarning.qml @@ -249,9 +246,6 @@ ui/configpopup/status/QOpenHDVersionCard.qml ui/elements/CardToast.qml ui/elements/ButtonYellow.qml - ui/configpopup/connect/PaneLocalhost.qml - ui/configpopup/connect/PaneTethering.qml - ui/configpopup/connect/GenericInfoPane.qml ui/elements/ButtonSimple.qml ui/configpopup/dev/QOpenHDServiceDialoque.qml ui/elements/ButtonDisconnected.qml @@ -263,6 +257,6 @@ ui/configpopup/openhd_settings/PopupTxPowerEditor.qml ui/elements/TextOrWarningButton.qml ui/configpopup/status/StatusCardRow.qml - ui/configpopup/connect/PaneX.qml + ui/configpopup/connect/PaneConnectionMode.qml diff --git a/qml/ui/HUDOverlayGrid.qml b/qml/ui/HUDOverlayGrid.qml index 6862716aa..f4779450f 100644 --- a/qml/ui/HUDOverlayGrid.qml +++ b/qml/ui/HUDOverlayGrid.qml @@ -40,11 +40,14 @@ Item { hudOverlayGrid.focus = true; // Receive key events hudOverlayGrid.enabled =true; + // argh + actual_hud_elements.visible=true; } // Opens the config popup and gives it focus function open_config_popup(){ // The HUD becomes not interactable while configpopup is opened hudOverlayGrid.enabled = false; + actual_hud_elements.visible=false; settings_panel.openSettings(); } @@ -247,6 +250,11 @@ Item { color: "transparent" } } + Item{ + id: actual_hud_elements + width: parent.width + height: parent.height + // By default on top row // -------------------------------------------------------------------------- LinkDownRSSIWidget { @@ -460,6 +468,7 @@ Item { UAVTimeWiget{ id: uavtimewidget } + } // Extra element - allows customizing the OSD color(s) and more OSDCustomizer { diff --git a/qml/ui/configpopup/connect/ConnectPanel.qml b/qml/ui/configpopup/connect/ConnectPanel.qml index de48c9190..0ebe6d5f0 100644 --- a/qml/ui/configpopup/connect/ConnectPanel.qml +++ b/qml/ui/configpopup/connect/ConnectPanel.qml @@ -27,29 +27,8 @@ Item { id: selectItemInStackLayoutBar width: parent.width TabButton { - text: qsTr("HMM") + text: qsTr("CONNECT TO OPENHD GND / AIR UNIT") } - TabButton { - text: qsTr("TCP") - } - TabButton{ - text: "Tethering" - } - // TabButton { - // text: qsTr("USB Tether") - // } - // TabButton { - // text: qsTr("(USB) Ethernet passive") - // } - // TabButton { - // text: qsTr("(USB) Ethernet active") - // } - // TabButton { - // text: qsTr("WiFi") - // } - // TabButton { - // text: qsTr("Custom (TCP)") - // } } // placed right below the top bar @@ -61,46 +40,8 @@ Item { anchors.bottom: parent.bottom currentIndex: selectItemInStackLayoutBar.currentIndex - - PaneX{ + PaneConnectionMode{ } - - PaneCustom{ - } - - PaneTethering{ - } - - // PaneUSBTether{ - // id: pane_usb_tether - // } - - // GenericInfoPane{ - // m_info_text: { - // return"1) Make sure ETH_HOTSPOT_E is disabled (Ground param)\n\n"+ - // "2) Enable ETH_PASSIVE_F on your openhd ground unit (Ground param)\n\n"+ - // "3) Connect your external device running QOpenHD to your ground station via ethernet\n(e.g. ethernet port on rpi 4).\n\n"+ - // "4) Make sure to select 'share my internet with ...' when the android connection setup pops up\n\n"+ - // "Video and telemetry forwarding should start automatically, and your GCS can get internet from your phone." - // } - // } - // GenericInfoPane{ - // m_info_text: { - // return "1) Make sure ETH_PASSIVE_F is disabled (Ground param)\n\n"+ - // "2) Enable ETH_HOTSPOT_E on your openhd ground unit (Ground param)\n\n"+ - // "3) Connect your external device running QOpenHD to your ground station via ethernet\n(e.g. ethernet port on rpi 4).\n\n"+ - // "You might have to disable wifi and cellular on your phone !.\n\n"+ - // "Video and telemetry forwarding should start automatically." - // } - // } - - // PaneWIFI{ - // id: wifi - // } - - // PaneCustom{ - // id: pane_custom - // } } } diff --git a/qml/ui/configpopup/connect/GenericInfoPane.qml b/qml/ui/configpopup/connect/GenericInfoPane.qml deleted file mode 100644 index e96d2055b..000000000 --- a/qml/ui/configpopup/connect/GenericInfoPane.qml +++ /dev/null @@ -1,47 +0,0 @@ -import QtQuick 2.12 -import QtQuick.Controls 2.12 -import QtQuick.Layouts 1.12 -import QtQuick.Dialogs 1.0 -import QtQuick.Controls.Material 2.12 - -import Qt.labs.settings 1.0 - -import OpenHD 1.0 - -import "../../../ui" as Ui -import "../../elements" - -Pane { - width: parent.width - height: parent.height - //color: "green" - - property string m_info_text: "I SHOULD NEVER APPEAR" - - ScrollView { - id:mavlinkExtraWBParamPanel - width: parent.width-24 - height: parent.height-24 - anchors.centerIn: parent - contentHeight: mainItem.height - contentWidth: mainItem.width - clip: true - //ScrollBar.vertical.policy: ScrollBar.AlwaysOn - ScrollBar.vertical.interactive: true - ScrollBar.horizontal.interactive: true - - ColumnLayout{ - anchors.fill: parent - id: mainItem - spacing: 6 - - Text{ - Layout.alignment: Qt.AlignTop - width:parent.width - wrapMode: Text.WordWrap - verticalAlignment: Text.AlignTop - text: m_info_text - } - } - } -} diff --git a/qml/ui/configpopup/connect/PaneConnectionMode.qml b/qml/ui/configpopup/connect/PaneConnectionMode.qml new file mode 100644 index 000000000..c93428a88 --- /dev/null +++ b/qml/ui/configpopup/connect/PaneConnectionMode.qml @@ -0,0 +1,194 @@ +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Dialogs 1.0 +import QtQuick.Controls.Material 2.12 + +import Qt.labs.settings 1.0 + +import OpenHD 1.0 + +import "../../../ui" as Ui +import "../../elements" + +Rectangle{ + id: background + width: parent.width + height: parent.height + color: "white" + border.color: "black" + + property bool m_is_air_or_ground_connected: _ohdSystemAir.is_alive || _ohdSystemGround.is_alive + + ScrollView { + id: main_item + width: parent.width + height: parent.height + contentHeight: main_layout.height + contentWidth: main_layout.width + clip: true + //ScrollBar.vertical.policy: ScrollBar.AlwaysOn + ScrollBar.vertical.interactive: true + ScrollBar.horizontal.interactive: true + + + /*Rectangle{ + color: "white" + implicitWidth: parent.width + implicitHeight: parent.height + }*/ + + ColumnLayout{ + id: main_layout + width: main_item.width + //Layout.fillWidth: true + Layout.fillHeight: true + Text{ + Layout.fillWidth: true + Layout.fillHeight: true + id: info_text + text: { + if(m_is_air_or_ground_connected){ + return "You are already connected to your OpenHD GND or AIR unit.\n"+ + " Nothing to do here - use the status view for more info." + } + return "Connect QOpenHD (this ground controll aplication) to your ground station.\n"+ + "AUTO: Works for all recommended networking setups\n"+ + "MANUAL: For developers / advanced networking only. Read the wiki for more Info."; + } + wrapMode: Text.WordWrap + color: m_is_air_or_ground_connected ? "red" : "black" + } + ComboBox { + Layout.fillWidth: false + Layout.fillHeight: true; + Layout.preferredWidth: 200 + + id: connection_mode_dropdown + model: ListModel { + id: font_text + ListElement { text: "AUTO" } + ListElement { text: "MANUAL UDP" } + ListElement { text: "MANUAL TCP" } + } + onCurrentIndexChanged: { + if(currentIndex==0 || currentIndex==1 || currentIndex==2){ + _mavlinkTelemetry.change_telemetry_connection_mode(currentIndex); + } + } + currentIndex: settings.qopenhd_mavlink_connection_mode + } + Text{ + Layout.fillWidth: true + Layout.fillHeight: true; + id: connection_status + text: _mavlinkTelemetry.telemetry_connection_status + } + + // Visible when auto mode is enabled ------------------------------------------------------------------------------------------ + ColumnLayout { + spacing: 6 + Layout.fillWidth: true + Layout.fillHeight: true + visible: connection_mode_dropdown.currentIndex==0; + + RowLayout { + Button{ + text: "Android Tethering" + Layout.preferredWidth: 180 + onClicked: _qopenhd.android_open_tethering_settings() + } + ButtonIconInfoText { + m_info_text: "1) Connect your phone via high quality USB cable to your ground station.\n\n"+ + "2) enable USB Tethering on your phone.\n\n"+ + "3) Telemetry and video forwarding is started automatically \n\n"+ + " ! Requires a phone and cellular contract that allows USB tethering. !" + } + } + RowLayout { + Button{ + text: "Passive Eth tethering" + Layout.preferredWidth: 180 + //TODO disable active tethering and enable passive when clicking the button + } + ButtonIconInfoText { + m_info_text: "1) Disable ETH_HOTSPOT_E and Enable ETH_PASSIVE_F\n\n"+ + "2) Connect your external device to your ground station via ethernet.\n\n"+ + "3) Select 'share my internet with ...' when the android connection setup pops up\n\n"+ + "Video and telemetry forwarding should start automatically, internet will be forwarded from your phone." + } + } + RowLayout { + Button{ + text: "Active Eth tethering" + Layout.preferredWidth: 180 + //TODO disable passive tethering and enable active when clicking the button + } + ButtonIconInfoText { + m_info_text: "1) Disable ETH_PASSIVE_F and Enable ETH_HOTSPOT_E\n\n"+ + "2) Connect your external device to your ground station via ethernet.\n\n"+ + "You might need to disable wifi and cellular on your phone\n\n"+ + "Video and telemetry forwarding should start automatically, internet will not be available." + } + } + RowLayout { + Button{ + text: "Wifi tethering" + Layout.preferredWidth: 180 + //TODO enable hotspot + } + ButtonIconInfoText { + m_info_text: "1) Enable WIFI_HOTSPOT_E\n\n"+ + "2) Connect to WiFi: openhd pw openhdopenhd\n\n"+ + "3) Press 'Connect' button.\n\n"+ + "NOTE: You cannot use WIFI hotspot during flight (while armed)" + } + } + // padding to bottom + Item { + Layout.fillHeight: true + Layout.fillWidth: true + } + } + + // Visible when manual UDP mode is enabled ------------------------------------------------------------------------------------------ + GridLayout{ + Layout.fillWidth: true + Layout.fillHeight: true + visible: connection_mode_dropdown.currentIndex==1; + Text{ + text: "Listening on localhost:5600" + } + } + // Visible when manual TCP mode is enabled ------------------------------------------------------------------------------------------ + GridLayout { + Layout.fillWidth: true + Layout.fillHeight: true + visible: connection_mode_dropdown.currentIndex==2; + columns: 2 + TextField { + id: textFieldip + validator: RegExpValidator { + regExp: /^((?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.){0,3}(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])$/ + } + inputMethodHints: Qt.ImhFormattedNumbersOnly + text: settings.qopenhd_mavlink_connection_manual_tcp_ip + } + Button{ + text: "SAVE" + onClicked: { + if(!_mavlinkTelemetry.change_manual_tcp_ip(textFieldip.text)){ + _qopenhd.toast_text("Please enter a valid ip"); + }else{ + settings.qopenhd_mavlink_connection_manual_tcp_ip=textFieldip.text + } + } + } + } + } + + + } +} + + diff --git a/qml/ui/configpopup/connect/PaneCustom.qml b/qml/ui/configpopup/connect/PaneCustom.qml deleted file mode 100644 index 855fa3ea2..000000000 --- a/qml/ui/configpopup/connect/PaneCustom.qml +++ /dev/null @@ -1,67 +0,0 @@ -import QtQuick 2.12 -import QtQuick.Controls 2.12 -import QtQuick.Layouts 1.12 -import QtQuick.Dialogs 1.0 -import QtQuick.Controls.Material 2.12 - -import Qt.labs.settings 1.0 - -import OpenHD 1.0 - -import "../../../ui" as Ui -import "../../elements" -Rectangle { - width: parent.width - height: parent.height - - Rectangle { - id: innerRect - width: 300 - height: 300 - anchors.centerIn: parent - anchors.horizontalCenterOffset: 70 - ColumnLayout { - spacing: 6 - - RowLayout { - TextField { - id: textFieldip - validator: RegExpValidator { - regExp: /^((?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.){0,3}(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])$/ - } - inputMethodHints: Qt.ImhFormattedNumbersOnly - text: "192.168.178.36" //settings.dev_mavlink_tcp_ip - } - ButtonIconInfoText { - m_info_text: "Connect with a OpenHD Ground Station, via TCP, this will still stream video va UDP for lower latency, after a successful conneciton." - } - } - - Button { - Layout.alignment: Qt.AlignTop - text: "CONNECT TCP" - onClicked: { - var ip_address = textFieldip.text - if (_qopenhd.is_valid_ip(ip_address)) { - _mavlinkTelemetry.add_tcp_connection_handler(ip_address) - } else { - _qopenhd.show_toast("Please enter a valid ip") - } - } - } - - Button { - text: "RE-ENABLE UDP" - onClicked: { - _mavlinkTelemetry.enable_udp() - } - } - - // padding to bottom - Item { - Layout.fillHeight: true - Layout.fillWidth: true - } - } - } -} diff --git a/qml/ui/configpopup/connect/PaneInfo.qml b/qml/ui/configpopup/connect/PaneInfo.qml deleted file mode 100644 index af44a16f9..000000000 --- a/qml/ui/configpopup/connect/PaneInfo.qml +++ /dev/null @@ -1,47 +0,0 @@ -import QtQuick 2.12 -import QtQuick.Controls 2.12 -import QtQuick.Layouts 1.12 -import QtQuick.Dialogs 1.0 -import QtQuick.Controls.Material 2.12 - -import Qt.labs.settings 1.0 - -import OpenHD 1.0 - -import "../../../ui" as Ui -import "../../elements" - -Rectangle{ - width: parent.width - height: parent.height - ColumnLayout{ - anchors.fill: parent - spacing: 6 - Text{ - Layout.fillWidth: true - Layout.alignment: Qt.AlignTop - Layout.preferredHeight: 50 - //width:parent.width - wrapMode: Text.WordWrap - verticalAlignment: Text.AlignTop - text: "When running QOpenHD on an external device (e.g. android phone)\n"+ - "you have to use one of the given choices to connect the device to the OpenHD ground station" - } - Text{ - Layout.preferredHeight: 50 - text: "You are already connected to your ground station - nothing to do." - color: "#706F1D" // dark green - visible: m_is_connected_gnd - } - Text{ - Layout.preferredHeight: 50 - text: "Looks like you are not connected to your ground station - please use one of the given choices to connect." - color: "red" - visible: !m_is_connected_gnd - } - Item{ - Layout.fillHeight: true - // filler - } - } -} diff --git a/qml/ui/configpopup/connect/PaneLocalhost.qml b/qml/ui/configpopup/connect/PaneLocalhost.qml deleted file mode 100644 index b30e78846..000000000 --- a/qml/ui/configpopup/connect/PaneLocalhost.qml +++ /dev/null @@ -1,52 +0,0 @@ -import QtQuick 2.12 -import QtQuick.Controls 2.12 -import QtQuick.Layouts 1.12 -import QtQuick.Dialogs 1.0 -import QtQuick.Controls.Material 2.12 - -import Qt.labs.settings 1.0 - -import OpenHD 1.0 - -import "../../../ui" as Ui -import "../../elements" - -Rectangle { - width: parent.width - height: parent.height - //color: "green" - - property string m_info_text: "Use this mode if you are running QOpenHD on your ground station itself - e.g. if you are using a RPI as ground station and connected -a display via HDMI to your ground station, or x86 and running OpenHD Core and QOpenHD on the same system."+ -"In this mode, QOpenHD uses UDP localhost to communicate with OpenHD core via mavlink (lowest latency and best performance). -However, if you are running QOpenHD as an app on an external device (e.g. your android phone) you have to use the appropiate connection page and its description to -connect QOpenHD to your ground station." - - property bool m_local_mode_enabled: _mavlinkTelemetry.udp_localhost_mode_enabled - - ColumnLayout{ - anchors.fill: parent - - spacing: 6 - Text{ - Layout.fillWidth: true - Layout.preferredHeight: 200 - //Layout.alignment: Qt.AlignTop - //width:parent.width - wrapMode: Text.WordWrap - text: m_info_text - } - Button{ - text: m_local_mode_enabled ? "LOCAL MODE ACTIVE" : "ENABLE LOCAL MODE" - onClicked: { - _mavlinkTelemetry.enable_udp() - } - enabled: !m_local_mode_enabled - } - // filler - Item{ - Layout.fillWidth: true - Layout.fillHeight: true - } - } -} diff --git a/qml/ui/configpopup/connect/PaneTethering.qml b/qml/ui/configpopup/connect/PaneTethering.qml deleted file mode 100644 index a19cbef3b..000000000 --- a/qml/ui/configpopup/connect/PaneTethering.qml +++ /dev/null @@ -1,102 +0,0 @@ -import QtQuick 2.12 -import QtQuick.Controls 2.12 -import QtQuick.Layouts 1.12 -import QtQuick.Dialogs 1.0 -import QtQuick.Controls.Material 2.12 - -import Qt.labs.settings 1.0 - -import OpenHD 1.0 - -import "../../../ui" as Ui -import "../../elements" -Rectangle { - width: parent.width - height: parent.height - property bool m_local_mode_enabled: _mavlinkTelemetry.udp_localhost_mode_enabled - - - Rectangle { - id: innerRect - width: 300 - height: 300 - anchors.centerIn: parent - anchors.horizontalCenterOffset: 40 - ColumnLayout { - spacing: 6 - - RowLayout { - Button{ - text: m_local_mode_enabled ? "LOCAL MODE ACTIVE" : "ENABLE LOCAL MODE" - Layout.preferredWidth: 180 - onClicked: { - _mavlinkTelemetry.enable_udp() - } - enabled: !m_local_mode_enabled - } - ButtonIconInfoText { - m_info_text: "Use this if you are running QOpenHD on your ground station itself and don't use it as a secondary device."+ - "\n\nIt uses UDP localhost to communicate with OpenHD core via mavlink (best performance and latency)." - } - } - RowLayout { - Button{ - text: "Android Tethering" - Layout.preferredWidth: 180 - onClicked: _qopenhd.android_open_tethering_settings() - } - ButtonIconInfoText { - m_info_text: "1) Connect your phone via high quality USB cable to your ground station.\n\n"+ - "2) enable USB Tethering on your phone.\n\n"+ - "3) Telemetry and video forwarding is started automatically \n\n"+ - " ! Requires a phone and cellular contract that allows USB tethering. !" - } - } - RowLayout { - Button{ - text: "Passive Eth tethering" - Layout.preferredWidth: 180 - //TODO disable active tethering and enable passive when clicking the button - } - ButtonIconInfoText { - m_info_text: "1) Disable ETH_HOTSPOT_E and Enable ETH_PASSIVE_F\n\n"+ - "2) Connect your external device to your ground station via ethernet.\n\n"+ - "3) Select 'share my internet with ...' when the android connection setup pops up\n\n"+ - "Video and telemetry forwarding should start automatically, internet will be forwarded from your phone." - } - } - RowLayout { - Button{ - text: "Active Eth tethering" - Layout.preferredWidth: 180 - //TODO disable passive tethering and enable active when clicking the button - } - ButtonIconInfoText { - m_info_text: "1) Disable ETH_PASSIVE_F and Enable ETH_HOTSPOT_E\n\n"+ - "2) Connect your external device to your ground station via ethernet.\n\n"+ - "You might need to disable wifi and cellular on your phone\n\n"+ - "Video and telemetry forwarding should start automatically, internet will not be available." - } - } - RowLayout { - Button{ - text: "Wifi tethering" - Layout.preferredWidth: 180 - //TODO enable hotspot - } - ButtonIconInfoText { - m_info_text: "1) Enable WIFI_HOTSPOT_E\n\n"+ - "2) Connect to WiFi: openhd pw openhdopenhd\n\n"+ - "3) Press 'Connect' button.\n\n"+ - "NOTE: You cannot use WIFI hotspot during flight (while armed)" - } - } - - // padding to bottom - Item { - Layout.fillHeight: true - Layout.fillWidth: true - } - } - } -} diff --git a/qml/ui/configpopup/connect/PaneUSBTether.qml b/qml/ui/configpopup/connect/PaneUSBTether.qml deleted file mode 100644 index c053e15db..000000000 --- a/qml/ui/configpopup/connect/PaneUSBTether.qml +++ /dev/null @@ -1,46 +0,0 @@ -import QtQuick 2.12 -import QtQuick.Controls 2.12 -import QtQuick.Layouts 1.12 -import QtQuick.Dialogs 1.0 -import QtQuick.Controls.Material 2.12 - -import Qt.labs.settings 1.0 - -import OpenHD 1.0 - -import "../../../ui" as Ui -import "../../elements" - -Rectangle { - width: parent.width - height: parent.height - //color: "green" - - property string m_info_text: "1) Connect your phone via high quality USB cable to your ground station.\n\n"+ - "2) enable USB Tethering on your phone.\n\n"+ - "3) Telemetry and video forwarding is started automatically \n\n"+ - " ! Requires a phone and cellular contract that allows USB tethering. !" - - ColumnLayout{ - anchors.fill: parent - anchors.top: parent.top - spacing: 6 - - Text{ - Layout.alignment: Qt.AlignTop - width:parent.width - wrapMode: Text.WordWrap - text: m_info_text - } - Button{ - Layout.alignment: Qt.AlignTop - text: "Open settings" - onClicked: _qopenhd.android_open_tethering_settings() - } - // padding to bottom - Item{ - Layout.fillHeight: true - Layout.fillWidth: true - } - } -} diff --git a/qml/ui/configpopup/connect/PaneWIFI.qml b/qml/ui/configpopup/connect/PaneWIFI.qml deleted file mode 100644 index e765c6ef3..000000000 --- a/qml/ui/configpopup/connect/PaneWIFI.qml +++ /dev/null @@ -1,45 +0,0 @@ -import QtQuick 2.12 -import QtQuick.Controls 2.12 -import QtQuick.Layouts 1.12 -import QtQuick.Dialogs 1.0 -import QtQuick.Controls.Material 2.12 - -import Qt.labs.settings 1.0 - -import OpenHD 1.0 - -import "../../../ui" as Ui -import "../../elements" - -Rectangle { - width: parent.width - height: parent.height - //color: "green" - - property string m_info_text: "1) Make sure WIFI_HOTSPOT_E is enabled (on air or ground unit)\n\n"+ - "2) Connect to WiFi: openhd pw openhdopenhd\n\n"+ - "3) Press 'Connect' button.\n\n"+ - "NOTE: You cannot use WIFI hotspot during flight (while armed)" - - ColumnLayout{ - anchors.fill: parent - - spacing: 6 - Text{ - Layout.alignment: Qt.AlignTop - width:parent.width - wrapMode: Text.WordWrap - text: m_info_text - } - Button{ - Layout.alignment: Qt.AlignTop - text: "Connect Air/Ground Hotspot" - onClicked: _mavlinkTelemetry.add_tcp_connection_handler("192.168.3.1") // ground / air pi address in hotspot mode - } - // padding to bottom - Item{ - Layout.fillHeight: true - Layout.fillWidth: true - } - } -} diff --git a/qml/ui/configpopup/connect/PaneX.qml b/qml/ui/configpopup/connect/PaneX.qml deleted file mode 100644 index 52081b32b..000000000 --- a/qml/ui/configpopup/connect/PaneX.qml +++ /dev/null @@ -1,167 +0,0 @@ -import QtQuick 2.12 -import QtQuick.Controls 2.12 -import QtQuick.Layouts 1.12 -import QtQuick.Dialogs 1.0 -import QtQuick.Controls.Material 2.12 - -import Qt.labs.settings 1.0 - -import OpenHD 1.0 - -import "../../../ui" as Ui -import "../../elements" - -Item { - id: main_item - width: parent.width - height: parent.height - - Rectangle{ - color: "white" - implicitWidth: main_item.width - implicitHeight: main_item.height - } - - Text{ - id: info_text - width: parent.width - height: 200 - anchors.top: parent.top; - anchors.left: parent.left; - text: { - return "Connect QOpenHD (this ground controll aplication) to your ground station."+ - "AUTO: Works for all recommended networking setups\n"+ - "MANUAL: For developers / advanced networking only. Read the wiki for more Info."; - } - } - - ComboBox { - id: connection_mode_dropdown - anchors.top: info_text.bottom; - - width: parent.width - height: 60 - - model: ListModel { - id: font_text - ListElement { text: "AUTO" } - ListElement { text: "MANUAL UDP" } - ListElement { text: "MANUAL TCP" } - } - } - Text{ - id: connection_status - width: parent.width - height: 30 - text: _mavlinkTelemetry.telemetry_connection_status - anchors.top: connection_mode_dropdown.bottom - anchors.left: parent.left - } - - Rectangle{ - width: parent.width - height: 400 - anchors.top: connection_status.bottom - anchors.left: parent.left - - visible: connection_mode_dropdown.currentIndex==0; - - ColumnLayout { - spacing: 6 - Layout.fillWidth: true - Layout.fillHeight: true - - RowLayout { - Button{ - text: "Android Tethering" - Layout.preferredWidth: 180 - onClicked: _qopenhd.android_open_tethering_settings() - } - ButtonIconInfoText { - m_info_text: "1) Connect your phone via high quality USB cable to your ground station.\n\n"+ - "2) enable USB Tethering on your phone.\n\n"+ - "3) Telemetry and video forwarding is started automatically \n\n"+ - " ! Requires a phone and cellular contract that allows USB tethering. !" - } - } - RowLayout { - Button{ - text: "Passive Eth tethering" - Layout.preferredWidth: 180 - //TODO disable active tethering and enable passive when clicking the button - } - ButtonIconInfoText { - m_info_text: "1) Disable ETH_HOTSPOT_E and Enable ETH_PASSIVE_F\n\n"+ - "2) Connect your external device to your ground station via ethernet.\n\n"+ - "3) Select 'share my internet with ...' when the android connection setup pops up\n\n"+ - "Video and telemetry forwarding should start automatically, internet will be forwarded from your phone." - } - } - RowLayout { - Button{ - text: "Active Eth tethering" - Layout.preferredWidth: 180 - //TODO disable passive tethering and enable active when clicking the button - } - ButtonIconInfoText { - m_info_text: "1) Disable ETH_PASSIVE_F and Enable ETH_HOTSPOT_E\n\n"+ - "2) Connect your external device to your ground station via ethernet.\n\n"+ - "You might need to disable wifi and cellular on your phone\n\n"+ - "Video and telemetry forwarding should start automatically, internet will not be available." - } - } - RowLayout { - Button{ - text: "Wifi tethering" - Layout.preferredWidth: 180 - //TODO enable hotspot - } - ButtonIconInfoText { - m_info_text: "1) Enable WIFI_HOTSPOT_E\n\n"+ - "2) Connect to WiFi: openhd pw openhdopenhd\n\n"+ - "3) Press 'Connect' button.\n\n"+ - "NOTE: You cannot use WIFI hotspot during flight (while armed)" - } - } - // padding to bottom - Item { - Layout.fillHeight: true - Layout.fillWidth: true - } - } - } - Rectangle{ - width:parent.width - height: 200 - anchors.top: connection_status.bottom - anchors.left: parent.left - visible: connection_mode_dropdown.currentIndex==1; - - } - Rectangle{ - width: parent.width - height: 200 - anchors.top: connection_status.bottom - anchors.left: parent.left - visible: connection_mode_dropdown.currentIndex==2; - GridLayout { - columns: 2 - TextField { - id: textFieldip - validator: RegExpValidator { - regExp: /^((?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.){0,3}(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])$/ - } - inputMethodHints: Qt.ImhFormattedNumbersOnly - text: "192.168.178.36" //settings.dev_mavlink_tcp_ip - } - Button{ - text: "SAVE" - onClicked: { - - } - } - - } - } - -} diff --git a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml index d1532a5c2..444bf4978 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml +++ b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml @@ -164,13 +164,12 @@ Rectangle{ } function get_text_wifi_tx_power(air){ - // "99 TPI DISARM: XX ARM: XX"; if(air){ if(!_wifi_card_air.alive) return "N/A"; - return ""+_wifi_card_air.tx_power+" "+_wifi_card_air.tx_power_unit+" DISARM:"+_wifi_card_air.tx_power_disarmed+" ARM:"+_wifi_card_air.tx_power_armed + return ""+_wifi_card_air.tx_power+" "+_wifi_card_air.tx_power_unit; } if(!_wifi_card_gnd0.alive) return "N/A"; - return ""+_wifi_card_gnd0.tx_power+" "+_wifi_card_gnd0.tx_power_unit+" DISARM:"+_wifi_card_gnd0.tx_power_disarmed+" ARM:"+_wifi_card_gnd0.tx_power_armed + return ""+_wifi_card_gnd0.tx_power+" "+_wifi_card_gnd0.tx_power_unit; } ScrollView { diff --git a/qml/ui/configpopup/openhd_settings/MavlinkParamPanel.qml b/qml/ui/configpopup/openhd_settings/MavlinkParamPanel.qml index dd1ab86aa..90dfdf41b 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkParamPanel.qml +++ b/qml/ui/configpopup/openhd_settings/MavlinkParamPanel.qml @@ -129,26 +129,21 @@ Rectangle { anchors.leftMargin: 12 Text { anchors.verticalCenter: parent.verticalCenter - //font.pixelSize: 20 width:160 text: model.unique_id font.bold: true - //color: settings.screen_settings_openhd_parameters_transparent ? "green" : "black" + font.pixelSize: 14 color: settings.screen_settings_openhd_parameters_transparent ? settings.color_text : "black" style: settings.screen_settings_openhd_parameters_transparent ? Text.Outline : Text.Normal styleColor: settings.color_glow } Text { width:160 - //font.pixelSize: 20 text: model.extraValue font.bold: true + font.pixelSize: 14 anchors.verticalCenter: parent.verticalCenter color: settings.screen_settings_openhd_parameters_transparent ? settings.color_text : "black" - //background: settings.screen_settings_openhd_parameters_transparent ? "white" : "transparent" - //styleColor: settings.color_glow - //background: "yellow" - //opacity: 1.0 style: settings.screen_settings_openhd_parameters_transparent ? Text.Outline : Text.Normal styleColor: settings.color_glow } diff --git a/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml b/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml index 62776abec..bae67e0e1 100644 --- a/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml +++ b/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml @@ -17,12 +17,14 @@ import "../../elements" import QtCharts 2.0 Rectangle{ - width: parent.width - height: parent.height /2 - anchors.bottom: parent.bottom - anchors.left: parent.left - //color: "#8cbfd7f3" + width: parent.width-12 + height: parent.height*2/3; + anchors.centerIn: parent color: "#ADD8E6" + border.color: "black" + border.width: 3 + + property bool m_normalize_data: false; function open(){ visible=true @@ -40,15 +42,60 @@ Rectangle{ "NOTE: This only gives a hint at free channels, using a proper channel analyzer (e.g. on the phone) is recommended."+ "PLEASE DO NOT CHANGE SETTINGS WHILE ANALYZING." - + RowLayout{ + id: top_elements + Layout.fillWidth: true + Item{ //Spacer + Layout.fillWidth: true + } + Button{ + Layout.alignment: Qt.AlignHCenter + text: "START" + onClicked: { + var result=_wbLinkSettingsHelper.start_analyze_channels() + if(result!==true){ + _qopenhd.show_toast("Busy,please try again later",true); + }else{ + _qopenhd.show_toast("STARTED, THIS MIGHT TAKE A WHILE !"); + } + } + enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0 + } + Switch{ + text: "NORMALIZE" + checked: m_normalize_data + onCheckedChanged: { + m_normalize_data=checked + pollution_chart.update_pollution_graph(); + } + } + ButtonIconInfo{ + Layout.alignment: Qt.AlignHCenter + onClicked: { + _messageBoxInstance.set_text_and_show(m_info_string) + } + } + Item{ //Spacer + Layout.fillWidth: true + } + } + // Argh, need to manually place the button + Button{ + anchors.top: parent.top + anchors.right: parent.right + text: "CLOSE" + onClicked: { + close() + } + } ChartView { + anchors.top: top_elements.bottom title: "WiFi pollution estimate" width: parent.width - height: parent.height + height: parent.height-top_elements.height legend.alignment: Qt.AlignBottom antialiasing: true - anchors.centerIn: parent id: pollution_chart function update_pollution_graph(){ @@ -57,7 +104,7 @@ Rectangle{ //const supported_frequencies = _wbLinkSettingsHelper.get_supported_frequencies(); const supported_frequencies = _wbLinkSettingsHelper.get_supported_frequencies_filtered(1); var categories = _wbLinkSettingsHelper.pollution_frequencies_int_to_qstringlist(supported_frequencies); - var values = _wbLinkSettingsHelper.pollution_frequencies_int_get_pollution(supported_frequencies); + var values = _wbLinkSettingsHelper.pollution_frequencies_int_get_pollution(supported_frequencies,m_normalize_data); bar_axis_x.categories=categories; bar_set.values=values; /*const supported_frequencies=_wbLinkSettingsHelper.get_supported_frequencies(); @@ -84,35 +131,6 @@ Rectangle{ } } } - Button{ - text: "CLOSE" - anchors.top: parent.top - anchors.right: parent.right - onClicked: { - close() - } - } - RowLayout{ - anchors.top: parent.top - anchors.horizontalCenter: parent.horizontalCenter - Button{ - text: "START" - onClicked: { - var result=_wbLinkSettingsHelper.start_analyze_channels() - if(result!==true){ - _qopenhd.show_toast("Busy,please try again later",true); - }else{ - _qopenhd.show_toast("Analyze channels started, please wait"); - } - } - enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0 - } - ButtonIconInfo{ - onClicked: { - _messageBoxInstance.set_text_and_show(m_info_string) - } - } - } } diff --git a/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml b/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml index 3cf28d5fe..92b2824a7 100644 --- a/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml +++ b/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml @@ -17,12 +17,12 @@ import "../../elements" import QtCharts 2.0 Rectangle{ - width: parent.width - height: parent.height /2 - anchors.bottom: parent.bottom - anchors.left: parent.left - //color: "#8cbfd7f3" + width: parent.width-12 + height: parent.height*2/3; + anchors.centerIn: parent color: "#ADD8E6" + border.color: "black" + border.width: 3 function open(){ visible=true @@ -41,7 +41,14 @@ Rectangle{ ListElement {title: "All 5.8G channels (slow)"; value: 2} } + /*Rectangle{ + implicitWidth:main_grid_layout.width + implicitHeight: main_grid_layout.height + color: "#ADD8E6" + }*/ + GridLayout{ + id: main_grid_layout Layout.fillWidth: true Layout.fillHeight: true @@ -102,6 +109,7 @@ Rectangle{ Layout.row: 2 Layout.column: 0 text: _wbLinkSettingsHelper.scanning_text_for_ui + font.pixelSize: 25 } } Button{ diff --git a/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml b/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml index bac4aa5fc..ee83c7a23 100644 --- a/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml +++ b/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml @@ -17,12 +17,12 @@ import "../../elements" import QtCharts 2.0 Rectangle{ - width: parent.width - height: parent.height /2 - anchors.bottom: parent.bottom - anchors.left: parent.left - //color: "#8cbfd7f3" + width: parent.width-12 + height: parent.height*2/3; + anchors.centerIn: parent color: "#ADD8E6" + border.color: "black" + border.width: 3 property bool m_is_air: false @@ -33,7 +33,7 @@ Rectangle{ _qopenhd.show_toast("WARNING: Changing TX power while armed is not recommended !"); } var card_chipset_type=get_chipset_type(); - if(!card_chipset_type==0 || card_chipset_type==1){ + if(!(card_chipset_type==0 || card_chipset_type==1)){ _messageBoxInstance.set_text_and_show("Changing tx power is only possible on openhd supported cards."); return; } @@ -112,13 +112,13 @@ Rectangle{ ListElement {title: "MAX [26]"; value: 26} } ListModel{ - id: model_rtl8812au_manufacturer_openhd - ListElement {title: "Please select"; value: -1} - ListElement {title: "LOW [3] ~25mW"; value: 3} - ListElement {title: "MEDIUM [5] ~200mW"; value: 5} - ListElement {title: "HIGH [10] ~1W"; value: 10} - ListElement {title: "MAX [12] ~2W"; value: 12} - } + id: model_rtl8812au_manufacturer_openhd + ListElement {title: "Please select"; value: -1} + ListElement {title: "LOW [3] ~25mW"; value: 3} + ListElement {title: "MEDIUM [5] ~200mW"; value: 5} + ListElement {title: "HIGH [10] ~1W"; value: 10} + ListElement {title: "MAX [12] ~2W"; value: 12} + } ListModel{ id: model_rtl8812au_manufacturer_generic ListElement {title: "Please select"; value: -1} @@ -168,8 +168,8 @@ Rectangle{ } }else if(chip_type==1){ // RTL8812BU - if(m_card_manufacturer_type==0){ - ret= model_rtl8812bu_manufacturer_comfast; + if(manufacturer==0){ + ret= model_rtl8812bu_manufacturer_comfast; }else{ ret = model_rtl8812bu_manufacturer_generic; } @@ -199,57 +199,80 @@ Rectangle{ return _wifi_card_gnd0.tx_power_unit; } - ColumnLayout{ - id: bla1 - width: parent.width /3 - anchors.top: parent.top - anchors.left: parent.left + GridLayout{ + id: main_row_layout + Layout.fillWidth: true + Layout.fillHeight: true + Layout.leftMargin: 5 + Layout.rightMargin: 5 + //anchors.top: parent.top + //anchors.bottom: parent.bottom + //anchors.left: parent.left + //anchors.right: parent.right + //Layout.minimumWidth: 300 + //Layout.preferredWidth: 600 + Text{ + Layout.row: 0 + Layout.column: 0 text: m_is_air ? "AIR TX Power" : "GND TX power"; + font.bold: true + horizontalAlignment: Qt.AlignHCenter + font.pixelSize: 14 } + // Text{ - text: "YOUR CHIPSET:" +get_card_chipset_str() + Layout.row: 1 + Layout.column: 0 + text: "RF CHIP:\n" +get_card_chipset_str() + horizontalAlignment: Qt.AlignHCenter + font.pixelSize: 14 } - ComboBox { - Layout.fillWidth: true - leftPadding: 12 - rightPadding: 12 + Layout.row: 1 + Layout.column: 1 id: comboBoxCardSelectManufacturer + Layout.minimumWidth: 100 + Layout.preferredWidth: 350 model: get_model_manufacturer_for_chip_type() textRole: "title" onCurrentIndexChanged: { var manufacturer=comboBoxCardSelectManufacturer.model.get(comboBoxCardSelectManufacturer.currentIndex).value; m_user_selected_card_manufacturer=manufacturer; } + font.pixelSize: 14 } - Text{ - text: "CURRENT:"+get_current_tx_power_int(0)+" "+get_tx_power_unit(); - } - } - - ColumnLayout{ - id: bla2 - width: parent.width /3 - anchors.left: bla1.right - anchors.top: parent.top - Text{ - text: "DISARMED" + // FILLER + Item{ + Layout.row: 1 + Layout.column: 3 + Layout.fillWidth: true } + // ---------------- Text{ - text: ""+get_current_tx_power_int(1)+" "+get_tx_power_unit(); + Layout.row: 2 + Layout.column: 0 + text: "DISARMED:\n"+get_current_tx_power_int(1)+" "+get_tx_power_unit(); + Layout.fillWidth: true + horizontalAlignment: Qt.AlignHCenter + font.pixelSize: 14 } ComboBox { + Layout.row: 2 + Layout.column: 1 Layout.fillWidth: true - leftPadding: 12 - rightPadding: 12 + Layout.minimumWidth: 100 + Layout.preferredWidth: 350 id: combo_box_txpower_disarmed model: get_model_txpower_for_chip_type_manufacturer(false) textRole: "title" enabled: m_user_selected_card_manufacturer>=0; + font.pixelSize: 14 } Button{ - text: "APPLY" + Layout.row: 2 + Layout.column: 2 + text: "SAVE" enabled: m_user_selected_card_manufacturer>=0; onClicked: { var tx_power_index_or_mw = combo_box_txpower_disarmed.model.get(combo_box_txpower_disarmed.currentIndex).value; @@ -265,34 +288,43 @@ Rectangle{ _qopenhd.show_toast("Cannot change TX power, please try again",true); } } + font.pixelSize: 14 } - } - ColumnLayout{ - width: parent.width /3 - anchors.right: parent.right - anchors.top: parent.top - Text{ - text: "ARMED" + // FILLER + Item{ + Layout.row: 2 + Layout.column: 3 + Layout.fillWidth: true } + // ---------------- Text{ + Layout.row: 3 + Layout.column: 0 text: { var power_int=get_current_tx_power_int(2); if(power_int==0) return "DISABLED"; - return ""+get_current_tx_power_int(2)+" "+get_tx_power_unit(); + return "ARMED:\n"+get_current_tx_power_int(2)+" "+get_tx_power_unit(); } + Layout.fillWidth: true + horizontalAlignment: Qt.AlignHCenter + font.pixelSize: 14 } ComboBox { + Layout.row: 3 + Layout.column: 1 Layout.fillWidth: true - leftPadding: 12 - rightPadding: 12 + Layout.minimumWidth: 100 + Layout.preferredWidth: 350 id: combo_box_txpower_armed model: get_model_txpower_for_chip_type_manufacturer(true) textRole: "title" enabled: m_user_selected_card_manufacturer>=0; + font.pixelSize: 14 } - Button{ - text: "APPLY" + Layout.row: 3 + Layout.column: 2 + text: "SAVE" enabled: m_user_selected_card_manufacturer>=0; onClicked: { var tx_power_index_or_mw = combo_box_txpower_armed.model.get(combo_box_txpower_armed.currentIndex).value; @@ -308,7 +340,46 @@ Rectangle{ _qopenhd.show_toast("Cannot change TX power, please try again",true); } } + font.pixelSize: 14 + } + // FILLER + Item{ + Layout.row: 3 + Layout.column: 3 + Layout.fillWidth: true } + Text{ + Layout.row: 4 + Layout.column: 0 + text: "CURRENT:\n"+get_current_tx_power_int(0)+" "+get_tx_power_unit(); + horizontalAlignment: Qt.AlignHCenter + font.pixelSize: 14 + } + Text{ + Layout.row: 4 + Layout.column: 1 + Layout.columnSpan: 2 + text: "WARNING: ARMING WILL REDUCE YOUR TX POWER" + visible: { + var txpower_disarmed=get_current_tx_power_int(1); + var txpower_armed=get_current_tx_power_int(2); + if(txpower_armed==0)return false; + return txpower_armed Date: Thu, 19 Oct 2023 15:39:01 +0200 Subject: [PATCH 10/81] UI stuff --- app/telemetry/MavlinkTelemetry.cpp | 2 +- .../connect/PaneConnectionMode.qml | 26 +++++++++---------- .../MavlinkOpenHDWBParamPanel2.qml | 11 ++++---- .../openhd_settings/PopupAnalyzeChannels.qml | 16 ++++++------ 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/app/telemetry/MavlinkTelemetry.cpp b/app/telemetry/MavlinkTelemetry.cpp index 6662035c5..c1966b39f 100644 --- a/app/telemetry/MavlinkTelemetry.cpp +++ b/app/telemetry/MavlinkTelemetry.cpp @@ -285,7 +285,7 @@ bool MavlinkTelemetry::change_manual_tcp_ip(QString ip) void MavlinkTelemetry::send_heartbeat_loop() { while(true){ - qDebug()<<"send_heartbeat_loop"; + //qDebug()<<"send_heartbeat_loop"; std::this_thread::sleep_for(std::chrono::milliseconds(1000)); perform_connection_management(); } diff --git a/qml/ui/configpopup/connect/PaneConnectionMode.qml b/qml/ui/configpopup/connect/PaneConnectionMode.qml index c93428a88..e11300d07 100644 --- a/qml/ui/configpopup/connect/PaneConnectionMode.qml +++ b/qml/ui/configpopup/connect/PaneConnectionMode.qml @@ -105,6 +105,19 @@ Rectangle{ " ! Requires a phone and cellular contract that allows USB tethering. !" } } + RowLayout { + Button{ + text: "Wifi tethering" + Layout.preferredWidth: 180 + //TODO enable hotspot + } + ButtonIconInfoText { + m_info_text: "1) Check status if your air / ground unit supports WiFi hotspot\n\n"+ + "2) Make sure your FC is disarmed\n\n"+ + "3) Connect this device to your AIR / GND unit wifi hotspot.\n\n"+ + "NOTE: It is not recommended to use WiFi hotspot during flight (automatically disabled on arm by default)" + } + } RowLayout { Button{ text: "Passive Eth tethering" @@ -131,19 +144,6 @@ Rectangle{ "Video and telemetry forwarding should start automatically, internet will not be available." } } - RowLayout { - Button{ - text: "Wifi tethering" - Layout.preferredWidth: 180 - //TODO enable hotspot - } - ButtonIconInfoText { - m_info_text: "1) Enable WIFI_HOTSPOT_E\n\n"+ - "2) Connect to WiFi: openhd pw openhdopenhd\n\n"+ - "3) Press 'Connect' button.\n\n"+ - "NOTE: You cannot use WIFI hotspot during flight (while armed)" - } - } // padding to bottom Item { Layout.fillHeight: true diff --git a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml index 444bf4978..6a1513923 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml +++ b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml @@ -19,6 +19,7 @@ import QtCharts 2.0 // This is an extra screen for changing the frequency / channel width - // They both need to match ! Rectangle{ + id: main_background width: parent.width height: parent.height //property color m_background_color: "#8cbfd7f3" @@ -173,9 +174,9 @@ Rectangle{ } ScrollView { - id:mavlinkExtraWBParamPanel - width: parent.width-24 - height: parent.height-24 + id: main_scroll_view + width: parent.width + height: parent.height anchors.centerIn: parent contentHeight: main_column_layout.height contentWidth: main_column_layout.width @@ -191,7 +192,7 @@ Rectangle{ Rectangle { id: frequency_area_layout_background color: m_background_color - implicitWidth: frequency_area_layout.implicitWidth+5 + implicitWidth: main_scroll_view.width implicitHeight: frequency_area_layout.implicitHeight+5 radius: 10 @@ -384,7 +385,7 @@ Rectangle{ } } Rectangle { - implicitWidth: tx_power_layout.implicitWidth + implicitWidth: main_scroll_view.width implicitHeight: tx_power_layout.implicitHeight id: tx_power_layout_background color: m_background_color diff --git a/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml b/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml index bae67e0e1..cb40029fd 100644 --- a/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml +++ b/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml @@ -48,6 +48,14 @@ Rectangle{ Item{ //Spacer Layout.fillWidth: true } + Switch{ + text: "NORMALIZE" + checked: m_normalize_data + onCheckedChanged: { + m_normalize_data=checked + pollution_chart.update_pollution_graph(); + } + } Button{ Layout.alignment: Qt.AlignHCenter text: "START" @@ -61,14 +69,6 @@ Rectangle{ } enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0 } - Switch{ - text: "NORMALIZE" - checked: m_normalize_data - onCheckedChanged: { - m_normalize_data=checked - pollution_chart.update_pollution_graph(); - } - } ButtonIconInfo{ Layout.alignment: Qt.AlignHCenter onClicked: { From b56745bc503c62464e3a3c79df7d612fb5d160ad Mon Sep 17 00:00:00 2001 From: consti10 Date: Thu, 19 Oct 2023 15:50:54 +0200 Subject: [PATCH 11/81] fucking hell, hard code it --- qml/ui/configpopup/status/PanelStatus.qml | 5 ++--- qml/ui/configpopup/status/StatusCardBodyOpenHD.qml | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/qml/ui/configpopup/status/PanelStatus.qml b/qml/ui/configpopup/status/PanelStatus.qml index c2a0382ad..dce530cd6 100644 --- a/qml/ui/configpopup/status/PanelStatus.qml +++ b/qml/ui/configpopup/status/PanelStatus.qml @@ -35,15 +35,14 @@ Rectangle { width: parent.width height: parent.height contentHeight: mainItem.height - //contentWidth: mainItem.width + contentWidth: mainItem.width clip: true //ScrollBar.vertical.policy: ScrollBar.AlwaysOn ScrollBar.vertical.interactive: true Item{ id: mainItem - //width: 1024 - width: parent.width + width: 800 height: 40+400+80 QOpenHDVersionCard{ diff --git a/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml b/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml index 4e87c624e..f5c3ebe9a 100644 --- a/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml +++ b/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml @@ -221,6 +221,7 @@ ColumnLayout { "2) INAV / Betaflight: Nothing needs to be changed, sys id should be 0"; } m_has_error: { + if(!_ohdSystemAir.is_alive)return false; var air_fc_sys_id=_ohdSystemAir.air_reported_fc_sys_id; // We allow 0 (Betaflight / inav / ... ) and 1 (Arupilot) if(air_fc_sys_id==0 || air_fc_sys_id==1)return false; From 32eb5ffe4ca3a34335d8e28e70963c5dd00d3a40 Mon Sep 17 00:00:00 2001 From: consti10 Date: Thu, 19 Oct 2023 16:04:46 +0200 Subject: [PATCH 12/81] pretty fonts --- qml/ui/configpopup/status/StatusCardRow.qml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qml/ui/configpopup/status/StatusCardRow.qml b/qml/ui/configpopup/status/StatusCardRow.qml index a7a7fd70a..132f1de29 100644 --- a/qml/ui/configpopup/status/StatusCardRow.qml +++ b/qml/ui/configpopup/status/StatusCardRow.qml @@ -75,6 +75,8 @@ Item { anchors.top: parent.top text: m_left_text verticalAlignment: Qt.AlignVCenter + font.bold: true + font.pixelSize: 20 } Text{ @@ -87,6 +89,7 @@ Item { verticalAlignment: Qt.AlignVCenter color: m_has_error ? m_right_text_color_error : m_right_text_color visible: !right_part_button.visible + font.pixelSize: 20 } MouseArea { enabled: m_has_error && !m_look_shit_on_error From 68fd8ec1e8e8255ffd6be42156ae5861461b2c52 Mon Sep 17 00:00:00 2001 From: consti10 Date: Thu, 19 Oct 2023 16:58:44 +0200 Subject: [PATCH 13/81] pretty fonts --- .../openhd_settings/FreqComboBoxRow.qml | 10 +++--- .../MavlinkAllSettingsPanel.qml | 36 +++++++++---------- .../MavlinkOpenHDWBParamPanel2.qml | 4 +-- qml/ui/configpopup/status/StatusCardRow.qml | 14 ++++---- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/qml/ui/configpopup/openhd_settings/FreqComboBoxRow.qml b/qml/ui/configpopup/openhd_settings/FreqComboBoxRow.qml index 33eaa9eec..135420d81 100644 --- a/qml/ui/configpopup/openhd_settings/FreqComboBoxRow.qml +++ b/qml/ui/configpopup/openhd_settings/FreqComboBoxRow.qml @@ -24,9 +24,7 @@ Rectangle{ property int m_selection_tpye: 0 property bool m_is_2G: false - property bool m_2G_5G_show: false property bool m_show_radar: false - property bool m_show_good_channel: false property int m_openhd_race_band: -1 @@ -57,10 +55,11 @@ Rectangle{ } Text{ Layout.alignment: Qt.AlignLeft - text: m_is_2G ? "5.8G" : "2.4G" + text: "2.4G" //color: value > 3000 ? "green" : "#ff8c00" //"orange" color: "#706F1D" // dark green - visible: m_2G_5G_show && m_openhd_race_band<0 + visible: m_is_2G + font.pixelSize: comboBoxFreq.font.pixelSize } Text { // Radar icon Layout.alignment: Qt.AlignLeft @@ -68,6 +67,7 @@ Rectangle{ font.family: "Font Awesome 5 Free" color: "red" visible: m_show_radar + font.pixelSize: comboBoxFreq.font.pixelSize } Item{ Layout.fillWidth: true @@ -88,6 +88,7 @@ Rectangle{ font.family: "Font Awesome 5 Free" color: "green" visible: m_openhd_race_band==2 + font.pixelSize: comboBoxFreq.font.pixelSize } Text{ // recommended / openhd race band channel @@ -99,6 +100,7 @@ Rectangle{ visible: m_openhd_race_band>=0 font.family: "Font Awesome 5 Free" color: "green" + font.pixelSize: comboBoxFreq.font.pixelSize } } } diff --git a/qml/ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml b/qml/ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml index 41a233cfb..5ccf7e569 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml +++ b/qml/ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml @@ -34,24 +34,24 @@ Rectangle { // Tab bar for selecting items in stack layout TabBar { - id: selectItemInStackLayoutBar - width: parent.width - TabButton { - text: qsTr("WB Link") - } - TabButton { - text: qsTr("Air Camera 1") - } - TabButton { - text: qsTr("Air Camera 2") - enabled: settings.dev_qopenhd_n_cameras>1 - } - TabButton { - text: qsTr("Air") - } - TabButton { - text: qsTr("Ground") - } + id: selectItemInStackLayoutBar + width: parent.width + TabButton { + text: qsTr("LINK/QUICK") + } + TabButton { + text: qsTr("AIR CAM 1") + } + TabButton { + text: qsTr("AIR CAM 2") + enabled: settings.dev_qopenhd_n_cameras>1 + } + TabButton { + text: qsTr("AIR") + } + TabButton { + text: qsTr("GROUND") + } } // placed right below the top bar diff --git a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml index 6a1513923..93d2fd820 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml +++ b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml @@ -220,10 +220,8 @@ Rectangle{ contentItem: FreqComboBoxRow{ m_main_text: title m_selection_tpye: (value===_wbLinkSettingsHelper.curr_channel_mhz) ? 1 : 0 - m_is_2G: value > 3000 - m_2G_5G_show: value > 100 + m_is_2G: value < 3000 && value > 100 m_show_radar: radar - m_show_good_channel: recommended m_openhd_race_band: openhd_raceband_nr } highlighted: comboBoxFreq.highlightedIndex === index diff --git a/qml/ui/configpopup/status/StatusCardRow.qml b/qml/ui/configpopup/status/StatusCardRow.qml index 132f1de29..cab2b2b71 100644 --- a/qml/ui/configpopup/status/StatusCardRow.qml +++ b/qml/ui/configpopup/status/StatusCardRow.qml @@ -19,13 +19,13 @@ import "../../elements" // The general idea behind this element is to be green / pretty when everything is okay // and red if something is wrong (in which case the user should click on it for more info) Item { - /*Layout.fillWidth: true - Layout.minimumWidth: 50 - Layout.minimumHeight: 30 + //Layout.fillWidth: true + //Layout.minimumWidth: 50 + //Layout.minimumHeight: 30 // - Layout.preferredWidth: 250 - Layout.preferredHeight: 30*/ - Layout.minimumWidth: 250 + //Layout.preferredWidth: 250 + //Layout.preferredHeight: 30 + //Layout.minimumWidth: 250 width: parent.width height: 50 @@ -63,7 +63,7 @@ Item { }*/ // Actual item,centered Item{ - width: 250 + width: 260 height: main_item.height anchors.centerIn: parent From cc6514c02604f56154c703c90c6d4d3333d40f72 Mon Sep 17 00:00:00 2001 From: consti10 Date: Fri, 20 Oct 2023 03:53:29 +0200 Subject: [PATCH 14/81] fix tcp --- app/telemetry/MavlinkTelemetry.cpp | 21 ++++++++++++------- app/telemetry/connection/tcp_connection.cpp | 3 ++- qml/ui/configpopup/log/LogMessagesView.qml | 4 +++- .../openhd_settings/PopupAnalyzeChannels.qml | 6 ------ .../openhd_settings/PopupScanChannels.qml | 2 -- .../configpopup/status/QOpenHDVersionCard.qml | 4 +++- .../status/StatusCardBodyOpenHD.qml | 2 +- 7 files changed, 23 insertions(+), 19 deletions(-) diff --git a/app/telemetry/MavlinkTelemetry.cpp b/app/telemetry/MavlinkTelemetry.cpp index c1966b39f..f3c5267d7 100644 --- a/app/telemetry/MavlinkTelemetry.cpp +++ b/app/telemetry/MavlinkTelemetry.cpp @@ -64,11 +64,12 @@ bool MavlinkTelemetry::sendMessage(mavlink_message_t msg){ // probably a programming error, the message was not packed with the right comp id qDebug()<<"WARN Sending message with comp id:"<threadsafe_is_alive()){ m_udp_connection->send_message(msg); return true; }else{ - if(m_tcp_connection){ + if(m_tcp_connection->threadsafe_is_alive()){ m_tcp_connection->send_message(msg); return true; } @@ -318,12 +319,18 @@ void MavlinkTelemetry::perform_connection_management() const std::string IP_OPENHD_WIFI_HOTSPOT="192.168.3.1"; //const std::string IP_OPENHD_WIFI_HOTSPOT=IP_CONSTI_TEST; const std::string IP_OPENHD_ETHERNET_HOTSPOT="192.168.2.1"; - if(m_tcp_connection->try_connect_and_receive(IP_OPENHD_WIFI_HOTSPOT,QOPENHD_OPENHD_GROUND_TCP_SERVER_PORT)){ - set_telemetry_connection_status("AUTO-CONNECTED (WIFI,TCP)"); - }else if(m_tcp_connection->try_connect_and_receive(IP_OPENHD_ETHERNET_HOTSPOT,QOPENHD_OPENHD_GROUND_TCP_SERVER_PORT)){ - set_telemetry_connection_status("AUTO-CONNECTED (ETH,TCP)"); + if(m_tcp_connection->m_keep_receiving && m_tcp_connection->threadsafe_is_alive()){ + // Already connected + set_telemetry_connection_status("AUTO-CONNECTED"); }else{ - set_telemetry_connection_status("AUTO-NOT CONNECTED"); + m_tcp_connection->stop_receiving(); + if(m_tcp_connection->try_connect_and_receive(IP_OPENHD_WIFI_HOTSPOT,QOPENHD_OPENHD_GROUND_TCP_SERVER_PORT)){ + set_telemetry_connection_status("AUTO-CONNECTED (WIFI,TCP)"); + }else if(m_tcp_connection->try_connect_and_receive(IP_OPENHD_ETHERNET_HOTSPOT,QOPENHD_OPENHD_GROUND_TCP_SERVER_PORT)){ + set_telemetry_connection_status("AUTO-CONNECTED (ETH,TCP)"); + }else{ + set_telemetry_connection_status("AUTO-NOT CONNECTED"); + } } } }else if(mavlink_connection_mode==1){ diff --git a/app/telemetry/connection/tcp_connection.cpp b/app/telemetry/connection/tcp_connection.cpp index d252ed6ee..635024e48 100644 --- a/app/telemetry/connection/tcp_connection.cpp +++ b/app/telemetry/connection/tcp_connection.cpp @@ -103,6 +103,7 @@ TCPConnection::~TCPConnection() bool TCPConnection::try_connect_and_receive(const std::string remote_ip, const int remote_port) { + assert(m_receive_thread==nullptr); m_remote_ip=remote_ip; m_remote_port=remote_port; m_socket_fd=linux_tcp_socket_try_connect(remote_ip,remote_port,2); @@ -158,6 +159,7 @@ bool TCPConnection::threadsafe_is_alive() void TCPConnection::process_data(const uint8_t *data, int data_len) { + m_last_data_ms=QOpenHDMavlinkHelper::getTimeMilliseconds(); for (int i = 0; i < data_len; i++) { mavlink_message_t msg; uint8_t res = mavlink_parse_char(1,data[i], &msg, &m_recv_status); @@ -173,7 +175,6 @@ void TCPConnection::process_mavlink_message(mavlink_message_t message) } - void TCPConnection::receive_until_stopped() { // Enough for MTU 1500 bytes. diff --git a/qml/ui/configpopup/log/LogMessagesView.qml b/qml/ui/configpopup/log/LogMessagesView.qml index e32cf3ffc..418c8d4ea 100644 --- a/qml/ui/configpopup/log/LogMessagesView.qml +++ b/qml/ui/configpopup/log/LogMessagesView.qml @@ -13,6 +13,7 @@ import "../../elements" // Uses the c++ logmessagemodel under app/logging/logmessagesmodel Rectangle{ + id: main_item width: parent.width height: parent.height //color: Qt.rgba(0.2, 0.2, 0.2, 1.0) @@ -27,13 +28,14 @@ Rectangle{ height: parent.height anchors.top: parent.top contentHeight: baseLogMessagesView.height + contentWidth: baseLogMessagesView.width clip: true //ScrollBar.vertical.policy: ScrollBar.AlwaysOn ScrollBar.vertical.interactive: true ListView { id: baseLogMessagesView - width: parent.width + width: main_item.width //height: parent.height model: m_log_model diff --git a/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml b/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml index cb40029fd..8f2d2b1a1 100644 --- a/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml +++ b/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml @@ -107,11 +107,6 @@ Rectangle{ var values = _wbLinkSettingsHelper.pollution_frequencies_int_get_pollution(supported_frequencies,m_normalize_data); bar_axis_x.categories=categories; bar_set.values=values; - /*const supported_frequencies=_wbLinkSettingsHelper.get_supported_frequencies(); - bar_axis_x.categories.clear(); - for(var i=0;i Date: Fri, 20 Oct 2023 11:41:36 +0100 Subject: [PATCH 15/81] Fix betaflight RC channels by uncommenting a couple of lines --- app/telemetry/models/fcmavlinksystem.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/telemetry/models/fcmavlinksystem.cpp b/app/telemetry/models/fcmavlinksystem.cpp index e016a4b5e..781e675a3 100644 --- a/app/telemetry/models/fcmavlinksystem.cpp +++ b/app/telemetry/models/fcmavlinksystem.cpp @@ -232,12 +232,12 @@ bool FCMavlinkSystem::process_message(const mavlink_message_t &msg) break; } case MAVLINK_MSG_ID_RC_CHANNELS_RAW:{ - // Seems to be outdated + // Seems to be outdated. Apart from Betaflight, where this is life //qDebug()<<"Got message RC channels raw"; mavlink_rc_channels_raw_t rc_channels_raw; mavlink_msg_rc_channels_raw_decode(&msg, &rc_channels_raw); - //const auto tmp=Telemetryutil::mavlink_msg_rc_channels_raw_to_array(rc_channels_raw); - //RCChannelsModel::instanceFC().update_all_channels(tmp); + const auto tmp=Telemetryutil::mavlink_msg_rc_channels_raw_to_array(rc_channels_raw); + RCChannelsModel::instanceFC().update_all_channels(tmp); set_rc_rssi_percentage( Telemetryutil::mavlink_rc_rssi_to_percent(rc_channels_raw.rssi)); break; } From ecfd231f1587506221612ed9b611b6c7a00f94c9 Mon Sep 17 00:00:00 2001 From: Pete A Date: Fri, 20 Oct 2023 23:31:31 +0100 Subject: [PATCH 16/81] reinstate a fix that got lost - 0 is valid sysid that betaflight uses --- app/telemetry/models/fcmavlinksystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/telemetry/models/fcmavlinksystem.cpp b/app/telemetry/models/fcmavlinksystem.cpp index 781e675a3..134768b78 100644 --- a/app/telemetry/models/fcmavlinksystem.cpp +++ b/app/telemetry/models/fcmavlinksystem.cpp @@ -494,7 +494,7 @@ std::optional FCMavlinkSystem::get_fc_sys_id() bool FCMavlinkSystem::set_system_id(int sys_id) { - if(sys_id<=0 || sys_id >= UINT8_MAX){ + if(sys_id<0 || sys_id >= UINT8_MAX){ qWarning()<<"Invalid sys id"; return false; } From c55d73eae47931a7f65516c824d094d9d89e0087 Mon Sep 17 00:00:00 2001 From: consti10 Date: Sat, 21 Oct 2023 17:23:20 +0200 Subject: [PATCH 17/81] add stbc / ldpc enable popup, improve UI --- app/telemetry/models/aohdsystem.cpp | 20 --- app/telemetry/models/aohdsystem.h | 1 - .../settings/wblinksettingshelper.cpp | 21 +++ app/telemetry/settings/wblinksettingshelper.h | 1 + qml/qml.qrc | 19 ++- .../connect/PaneConnectionMode.qml | 4 + .../MavlinkOpenHDWBParamPanel2.qml | 77 +++++++-- .../openhd_settings/PopupAnalyzeChannels.qml | 4 + .../openhd_settings/PopupEnableSTBCLDPC.qml | 161 ++++++++++++++++++ .../openhd_settings/PopupScanChannels.qml | 4 + .../openhd_settings/PopupTxPowerEditor.qml | 31 +++- .../status/StatusCardBodyOpenHD.qml | 46 ----- qml/ui/widgets/LinkDownRSSIWidget.qml | 9 - qml/ui/widgets/LinkUpRSSIWidget.qml | 18 -- 14 files changed, 289 insertions(+), 127 deletions(-) create mode 100644 qml/ui/configpopup/openhd_settings/PopupEnableSTBCLDPC.qml diff --git a/app/telemetry/models/aohdsystem.cpp b/app/telemetry/models/aohdsystem.cpp index 064b714e5..4d2bab18a 100644 --- a/app/telemetry/models/aohdsystem.cpp +++ b/app/telemetry/models/aohdsystem.cpp @@ -339,26 +339,6 @@ void AOHDSystem::process_x1(const mavlink_openhd_stats_monitor_mode_wifi_link_t set_wb_short_guard_enabled(bitfield.short_guard); set_curr_rx_last_packet_status_good(bitfield.curr_rx_last_packet_status_good); - if(m_is_air && !bitfield.stbc){ - if(m_stbc_warning_shown)return; - // If your ground unit uses card(s) with 2 antennas, enable STBC on your air unit (transmitting part)." - // "If your air unit uses card(s) with 2 antennas, enable STBC on your ground unit (transmitting part). - /*auto message="Please check: Enable WB_E_STBC on AIR unit IF your rtl8812au TX/RX both have more than one antenna" - " (NOTE: Without 2 populated rf paths, enabling this option results in" - " no connection !!! OpenHD cannot automatically check how many rf paths are populated on your adapter(s). ASUS has 1 external and " - "1 internal antenna (STBC should be used). If you wish to not see this " - "prompt again, you can disable it in QOpenHD - DEV - dev_wb_show_no_stbc_enabled_warning.";*/ - auto message="Please check: STBC is not enabled on your air unit. " - "If your air unit has 2 or more antennas (ONLY IF!), enable STBC to use them both and increase range significantly." - "See the wiki for more info." - "You can disable this prompt by going to QOpenHD - DEV and set dev_wb_show_no_stbc_enabled_warning=off."; - QSettings settings; - const auto dev_wb_show_no_stbc_enabled_warning =settings.value("dev_wb_show_no_stbc_enabled_warning", false).toBool(); - if(!dev_wb_show_no_stbc_enabled_warning){ - WorkaroundMessageBox::makePopupMessage(message,10); - m_stbc_warning_shown=true; - } - } // Feature: Warning if dBm falls below minimum threshold for current MCS index on packets that need to be received // We need to get the mcs index from the other system (aka from air if we are running on ground) since that's whats being injected const int mcs_index_other=m_is_air ? AOHDSystem::instanceGround().m_curr_mcs_index : AOHDSystem::instanceAir().m_curr_mcs_index; diff --git a/app/telemetry/models/aohdsystem.h b/app/telemetry/models/aohdsystem.h index b62ccfe19..f147f49a6 100644 --- a/app/telemetry/models/aohdsystem.h +++ b/app/telemetry/models/aohdsystem.h @@ -155,7 +155,6 @@ class AOHDSystem : public QObject // do not completely pollute the HUD with this error message std::chrono::steady_clock::time_point m_last_tx_error_hud_message=std::chrono::steady_clock::now(); std::chrono::steady_clock::time_point m_last_n_cameras_message=std::chrono::steady_clock::now(); - bool m_stbc_warning_shown=false; void update_alive_status_with_hud_message(bool alive); }; diff --git a/app/telemetry/settings/wblinksettingshelper.cpp b/app/telemetry/settings/wblinksettingshelper.cpp index b393db83b..f41487a0e 100644 --- a/app/telemetry/settings/wblinksettingshelper.cpp +++ b/app/telemetry/settings/wblinksettingshelper.cpp @@ -401,6 +401,27 @@ bool WBLinkSettingsHelper::set_param_tx_power(bool ground,bool is_tx_power_index return result; } +bool WBLinkSettingsHelper::set_param_stbc_ldpc_enable_air_ground() +{ + qDebug()<<"set_param_stbc_ldpc_enable_air_ground"; + const std::string param_id_stbc=openhd::WB_ENABLE_STBC; + const std::string param_id_ldpc=openhd::WB_ENABLE_LDPC; + auto command=XParam::create_cmd_set_int(OHD_SYS_ID_GROUND,OHD_COMP_ID_LINK_PARAM,param_id_stbc,1); + auto result= XParam::instance().try_set_param_blocking(command); + if(!result)return false; + command=XParam::create_cmd_set_int(OHD_SYS_ID_GROUND,OHD_COMP_ID_LINK_PARAM,param_id_ldpc,1); + result= XParam::instance().try_set_param_blocking(command); + if(!result)return false; + // air + command=XParam::create_cmd_set_int(OHD_SYS_ID_AIR,OHD_COMP_ID_LINK_PARAM,param_id_stbc,1); + result= XParam::instance().try_set_param_blocking(command); + if(!result)return false; + command=XParam::create_cmd_set_int(OHD_SYS_ID_AIR,OHD_COMP_ID_LINK_PARAM,param_id_ldpc,1); + result= XParam::instance().try_set_param_blocking(command); + if(!result)return false; + return true; +} + bool WBLinkSettingsHelper::update_supported_channels(const std::vector supported_channels) { std::lock_guard lock(m_supported_channels_mutex); diff --git a/app/telemetry/settings/wblinksettingshelper.h b/app/telemetry/settings/wblinksettingshelper.h index 455b29676..860ffcc78 100644 --- a/app/telemetry/settings/wblinksettingshelper.h +++ b/app/telemetry/settings/wblinksettingshelper.h @@ -113,6 +113,7 @@ class WBLinkSettingsHelper : public QObject Q_INVOKABLE void set_param_air_only_mcs_async(int value); // Extra Q_INVOKABLE bool set_param_tx_power(bool ground,bool is_tx_power_index,bool is_for_armed_state,int value); + Q_INVOKABLE bool set_param_stbc_ldpc_enable_air_ground(); private: struct SupportedChannel{ uint16_t frequency; diff --git a/qml/qml.qrc b/qml/qml.qrc index bb7667f7f..ae881da86 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -1,33 +1,33 @@ - + ../translations/QOpenHD_en.qm resources/cursors/arrow_512_green.png resources/cursors/arrow_512_transparent.png resources/cursors/arrow_512_white.png resources/cursors/hand_white.png - + ../translations/QOpenHD_de.qm - + ../translations/QOpenHD_ru.qm - + ../translations/QOpenHD_es.qm - + ../translations/QOpenHD_fr.qm - + ../translations/QOpenHD_nl.qm - + ../translations/QOpenHD_ro.qm - + ../translations/QOpenHD_it.qm - + ../translations/QOpenHD_zh.qm @@ -258,5 +258,6 @@ ui/elements/TextOrWarningButton.qml ui/configpopup/status/StatusCardRow.qml ui/configpopup/connect/PaneConnectionMode.qml + ui/configpopup/openhd_settings/PopupEnableSTBCLDPC.qml diff --git a/qml/ui/configpopup/connect/PaneConnectionMode.qml b/qml/ui/configpopup/connect/PaneConnectionMode.qml index e11300d07..d2e1fdbdc 100644 --- a/qml/ui/configpopup/connect/PaneConnectionMode.qml +++ b/qml/ui/configpopup/connect/PaneConnectionMode.qml @@ -184,6 +184,10 @@ Rectangle{ } } } + Text{ + Layout.columnSpan: 2 + text: "TCP PORT: 5760" + } } } diff --git a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml index 93d2fd820..04e3bb9ab 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml +++ b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml @@ -25,6 +25,8 @@ Rectangle{ //property color m_background_color: "#8cbfd7f3" property color m_background_color: "#ADD8E6" + property int m_small_width: 200 + function user_quidance_animate_channel_scan(){ console.log("User guidance animate channel scan"); anim_find_air_unit.start() @@ -113,6 +115,16 @@ Rectangle{ change_tx_power_popup.close(); dialoqueFreqChangeGndOnly.close(); dialoqueFreqChangeArmed.close(); + popup_enable_stbc_ldpc.close(); + } + + function get_text_stbc_ldpc(air){ + if(air){ + if(!_ohdSystemAir.is_alive)return "N/A"; + return ""+(_ohdSystemAir.wb_stbc_enabled ? "YES" : "NO")+"/"+(_ohdSystemAir.wb_lpdc_enabled ? "YES" : "NO"); + } + if(!_ohdSystemGround.is_alive)return "N/A"; + return ""+(_ohdSystemGround.wb_stbc_enabled ? "YES" : "NO")+"/"+(_ohdSystemGround.wb_lpdc_enabled ? "YES" : "NO"); } Component.onCompleted: { @@ -306,7 +318,7 @@ Rectangle{ channel_scan_progress_view.open() } SequentialAnimation { - running: true + running: false loops: 4 id: anim_find_air_unit // Expand the button @@ -396,22 +408,18 @@ Rectangle{ Text{ Layout.row: 0 Layout.column: 0 + Layout.columnSpan: 2 text: "TX POWER" font.bold: true } Text{ Layout.row: 1 Layout.column: 0 - text: "AIR" - } - Text{ - Layout.row: 1 - Layout.column: 1 - text: get_text_wifi_tx_power(true) + text: "AIR:\n "+get_text_wifi_tx_power(true) } Button{ Layout.row: 1 - Layout.column: 2 + Layout.column: 1 text: "CHANGE" enabled: _ohdSystemAir.is_alive onClicked: { @@ -423,16 +431,11 @@ Rectangle{ Text{ Layout.row: 2 Layout.column: 0 - text: "GND" - } - Text{ - Layout.row: 2 - Layout.column: 1 - text: get_text_wifi_tx_power(false) + text: "GND:\n"+get_text_wifi_tx_power(false) } Button{ Layout.row: 2 - Layout.column: 2 + Layout.column: 1 text: "CHANGE" enabled: _ohdSystemGround.is_alive onClicked: { @@ -441,6 +444,47 @@ Rectangle{ change_tx_power_popup.open() } } + // STBC / LDPC + Text{ + width: 200 + Layout.row: 0 + Layout.column: 3 + Layout.columnSpan: 2 + text: "ADVANCED (STBC,LDPC)" + font.bold: true + horizontalAlignment: Qt.AlignHCenter + } + Text{ + Layout.row: 1 + Layout.column: 3 + text: "AIR:\n"+get_text_stbc_ldpc(true); + horizontalAlignment: Qt.AlignHCenter + } + Text{ + Layout.row: 2 + Layout.column: 3 + text: "GND:\n"+get_text_stbc_ldpc(false); + horizontalAlignment: Qt.AlignHCenter + } + ButtonIconInfo{ + Layout.row: 1 + Layout.column: 4 + onClicked: { + _messageBoxInstance.set_text_and_show("STBC / LDPC : Greatly increases range, but requires 2 RF paths (2 Antennas) on BOTH your air and ground station."+ + "WARNING: Enabling STBC with the wrong hardware (only 1 antenna / only one rf path) results in no connectivity "+ + "and you need to re-flash your air / ground unit to recover !"); + } + } + Button{ + Layout.row: 2 + Layout.column: 4 + text: "EDIT"; + enabled: true //_ohdSystemAir.is_alive && _ohdSystemGround.is_alive && (_wbLinkSettingsHelper.ui_rebuild_models>=0) && + //(_ohdSystemGround.wb_stbc_enabled!=true || _ohdSystemGround.wb_lpdc_enabled!=true || _ohdSystemAir.wb_stbc_enabled!=true || _ohdSystemAir.wb_lpdc_enabled!=true); + onClicked: { + popup_enable_stbc_ldpc.open() + } + } } } } @@ -457,6 +501,9 @@ Rectangle{ PopupTxPowerEditor{ id: change_tx_power_popup } + PopupEnableSTBCLDPC{ + id: popup_enable_stbc_ldpc + } DialoqueFreqChangeGndOnly{ id: dialoqueFreqChangeGndOnly diff --git a/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml b/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml index 8f2d2b1a1..b4b918395 100644 --- a/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml +++ b/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml @@ -85,6 +85,10 @@ Rectangle{ anchors.right: parent.right text: "CLOSE" onClicked: { + if(_ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==2){ + _qopenhd.show_toast("STILL ANALYZING",); + return; + } close() } } diff --git a/qml/ui/configpopup/openhd_settings/PopupEnableSTBCLDPC.qml b/qml/ui/configpopup/openhd_settings/PopupEnableSTBCLDPC.qml new file mode 100644 index 000000000..1f295b6e1 --- /dev/null +++ b/qml/ui/configpopup/openhd_settings/PopupEnableSTBCLDPC.qml @@ -0,0 +1,161 @@ +import QtQuick 2.0 + +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Dialogs 1.0 +import QtQuick.Controls.Material 2.12 +import QtQuick.Controls.Styles 1.4 + +import Qt.labs.settings 1.0 + +import OpenHD 1.0 + +import "../../../ui" as Ui +import "../../elements" + +Rectangle{ + id: main_background + width: parent.width-12 + height: parent.height*2/3; + anchors.centerIn: parent + color: "#ADD8E6" + border.color: "black" + border.width: 3 + + function open(){ + if(_fcMavlinkSystem.is_alive && _fcMavlinkSystem.armed){ + _qopenhd.show_toast("PLEASE DISARM FIRST"); + return; + } + visible=true; + enabled=true; + } + + function close(){ + visible=false; + enabled=false; + } + + ListModel{ + id: model_n_antennas_air + ListElement {title: "AIR: PLEASE SELECT N RF PATH / ANTENNAS"; value: 0} + ListElement {title: "AIR: 1 RF PATH / ANTENNAS"; value: 1} + ListElement {title: "AIR: 2 RF PATHS / ANTENNAS"; value: 2} + } + ListModel{ + id: model_n_antennas_gnd + ListElement {title: "GND: PLEASE SELECT N RF PATH / ANTENNAS"; value: 0} + ListElement {title: "GND: 1 RF PATH / ANTENNAS"; value: 1} + ListElement {title: "GND: 2 RF PATHS / ANTENNAS"; value: 2} + } + + GridLayout{ + id: main_row_layout + Layout.fillWidth: true + Layout.fillHeight: true + Layout.leftMargin: 5 + Layout.rightMargin: 5 + + Text{ + id: stbc_warning_text + Layout.row: 0 + Layout.column: 0 + text: "WARNING:\n YOU NEED TO REFLASH YOUR AIR / GROUND UNIT\nIF YOU ENABLE STBC / LDPC ON UNSUPPORTED HW"; + color: "red" + width: main_background.width + height: 200 + horizontalAlignment: Qt.AlignHCenter + verticalAlignment: Qt.AlignVCenter + font.pixelSize: 15 + wrapMode: Text.WordWrap + SequentialAnimation { + running: false + loops: 3 + id: anim_warn_user_stbc + // Expand the button + PropertyAnimation { + target: stbc_warning_text + property: "scale" + to: 2.0 + duration: 300 + easing.type: Easing.InOutQuad + } + // Shrink back to normal + PropertyAnimation { + target: stbc_warning_text + property: "scale" + to: 1.0 + duration: 300 + easing.type: Easing.InOutQuad + } + } + } + ComboBox { + Layout.row: 1 + Layout.column: 0 + id: comboBoxNAntennasAir + Layout.minimumWidth: 100 + Layout.preferredWidth: 350 + model: model_n_antennas_air + textRole: "title" + font.pixelSize: 14 + onCurrentIndexChanged: { + if(currentIndex==2){ + anim_warn_user_stbc.start(); + } + } + } + ComboBox { + Layout.row: 2 + Layout.column: 0 + id: comboBoxNAntennasGnd + Layout.minimumWidth: 100 + Layout.preferredWidth: 350 + model: model_n_antennas_gnd + textRole: "title" + font.pixelSize: 14 + onCurrentIndexChanged: { + if(currentIndex==2){ + anim_warn_user_stbc.start(); + } + } + } + Button{ + id: button_enable + Layout.row: 3 + Layout.column: 0 + text: "ENABLE" + visible: comboBoxNAntennasAir.currentIndex==2 && comboBoxNAntennasGnd.currentIndex==2; + font.pixelSize: 14 + onClicked: { + if(_wbLinkSettingsHelper.set_param_stbc_ldpc_enable_air_ground()){ + _qopenhd.show_toast("Success (STBC & LDPC set to ON on both AIR and GND)"); + close(); + }else{ + _qopenhd.show_toast("Something went wrong, please try again"); + } + } + } + Text{ + Layout.row: 4 + Layout.column: 0 + visible: !button_enable.visible + text: "CAN ONLY BE ENABLED IF BOTH AIR AND GN UNIT HAVE 2 RF PATHS / ANTENNAS"; + font.pixelSize: 14 + } + // ---------------- + } + + Button{ + text: "CLOSE" + anchors.top: parent.top + anchors.right: parent.right + onClicked: { + close() + } + } + + +} + diff --git a/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml b/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml index 23bc65268..277c1b461 100644 --- a/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml +++ b/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml @@ -115,6 +115,10 @@ Rectangle{ anchors.right: parent.right text: "CLOSE" onClicked: { + if(_ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==1){ + _qopenhd.show_toast("STILL SCANNING"); + return; + } close() } } diff --git a/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml b/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml index ee83c7a23..ff002798b 100644 --- a/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml +++ b/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml @@ -14,8 +14,6 @@ import OpenHD 1.0 import "../../../ui" as Ui import "../../elements" -import QtCharts 2.0 - Rectangle{ width: parent.width-12 height: parent.height*2/3; @@ -97,7 +95,8 @@ Rectangle{ ListModel{ id: model_rtl8812au_manufacturer_asus_txpower ListElement {title: "Please select"; value: -1} - ListElement {title: "LOW [22] ~20mW (DEFAULT) "; value: 22} + ListElement {title: "LOW [10] ~5mW (DEFAULT) "; value: 10} + ListElement {title: "LOW [22] ~20mW "; value: 22} ListElement {title: "MEDIUM [37] ~100mW "; value: 37} ListElement {title: "HIGH [53] ~320mW "; value: 53} ListElement {title: "MAX1 [58] ~420mW (MCS<=2!)"; value: 58} @@ -106,6 +105,7 @@ Rectangle{ ListModel{ id: model_rtl8812au_manufacturer_aliexpress_hp ListElement {title: "Please select"; value: -1} + ListElement {title: "LOW [10]"; value: 10} ListElement {title: "LOW [16]"; value: 16} ListElement {title: "MEDIUM [22]"; value: 22} ListElement {title: "HIGH [24]"; value: 24} @@ -116,14 +116,16 @@ Rectangle{ ListElement {title: "Please select"; value: -1} ListElement {title: "LOW [3] ~25mW"; value: 3} ListElement {title: "MEDIUM [5] ~200mW"; value: 5} - ListElement {title: "HIGH [10] ~1W"; value: 10} - ListElement {title: "MAX [12] ~2W"; value: 12} + ListElement {title: "HIGH [14] ~800mW"; value: 14} + ListElement {title: "MAX1 [18] >1W"; value: 18} + ListElement {title: "MAX2 [20] >1W"; value: 20} } ListModel{ id: model_rtl8812au_manufacturer_generic ListElement {title: "Please select"; value: -1} ListElement {title: "[10] (DANGER,ARBITRARY)"; value: 10} ListElement {title: "[22] (DANGER,ARBITRARY)"; value: 22} + ListElement {title: "[30] (DANGER,ARBITRARY)"; value: 30} ListElement {title: "[37] (DANGER,ARBITRARY)"; value: 37} ListElement {title: "[53] (DANGER,ARBITRARY)"; value: 53} ListElement {title: "[58] (DANGER,ARBITRARY)"; value: 58} @@ -148,6 +150,12 @@ Rectangle{ ListElement {title: "<=20000mW (maybe)"; value: 2000} } + // Such that we can copy and add the extra value for "NOT ENABLED" + ListModel{ + id: model_txpower_for_chip_type_manufacturer_armed + } + + function get_model_txpower_for_chip_type_manufacturer(add_selection_disable){ var chip_type=get_chipset_type(); var manufacturer=m_user_selected_card_manufacturer; @@ -177,9 +185,14 @@ Rectangle{ ret = model_error; } // Armed has the extra option of tx power==0, which means the disarmed tx power is applied regardless if armed or not - //if(add_selection_disable){ - // ret.insert(1,{title: "DISABLE", value: 0}); - //} + if(add_selection_disable){ + model_txpower_for_chip_type_manufacturer_armed.clear(); + for(var i = 0; i < ret.count; ++i){ + model_txpower_for_chip_type_manufacturer_armed.insert(i,ret.get(i)); + } + model_txpower_for_chip_type_manufacturer_armed.insert(1,{title: "DISABLE [0]", value: 0}); + return model_txpower_for_chip_type_manufacturer_armed; + } return ret; } @@ -302,7 +315,7 @@ Rectangle{ Layout.column: 0 text: { var power_int=get_current_tx_power_int(2); - if(power_int==0) return "DISABLED"; + if(power_int==0) return "ARMED:\nDISABLED"; return "ARMED:\n"+get_current_tx_power_int(2)+" "+get_tx_power_unit(); } Layout.fillWidth: true diff --git a/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml b/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml index 93200fa10..d369e8149 100644 --- a/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml +++ b/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml @@ -32,47 +32,6 @@ ColumnLayout { //fucking hell qt property int m_font_pixel_size: 13 - function get_alive_text(){ - return m_is_alive ? "Yes" : "NOT ALIVE !" - } - function get_alive_text_color(){ - //return m_is_alive ? "green" : "red" - return m_is_alive ? "green" : "black" - } - - function get_cards_text() { - if (!m_is_ground) { - var airCardType = _wifi_card_air.card_type_as_string; - airCardType = airCardType.substring(3); - return airCardType; - } - - - // Ground - var ret = ""; - - if (_wifi_card_gnd0.alive) { - ret += _wifi_card_gnd0.card_type_as_string; - } - if (_wifi_card_gnd1.alive) { - ret += "\n" + _wifi_card_gnd1.card_type_as_string; - } - if (_wifi_card_gnd2.alive) { - ret += "\n" + _wifi_card_gnd2.card_type_as_string; - } - if (_wifi_card_gnd3.alive) { - ret += "\n" + _wifi_card_gnd3.card_type_as_string; - } - - if (ret.length == 0) return "N/A"; - - // Remove the first 3 characters if ret is not "N/A" - if (ret !== "N/A") { - ret = ret.substring(3); - } - - return ret; - } function get_gnd_active_cards(){ var ret=0; if(_wifi_card_gnd0.alive) ret++; @@ -140,11 +99,6 @@ ColumnLayout { m_right_text: m_last_ping m_right_text_color: m_last_ping === "N/A" ? "#DC143C" : "green" } - StatusCardRow{ - m_left_text: qsTr("Alive: ") - m_right_text: get_alive_text() - m_right_text_color: get_alive_text_color() - } StatusCardRow{ m_left_text: qsTr(m_is_ground ? "Link HW: " : "Link HW:") m_right_text: { diff --git a/qml/ui/widgets/LinkDownRSSIWidget.qml b/qml/ui/widgets/LinkDownRSSIWidget.qml index 14938ae40..9e64dbdff 100644 --- a/qml/ui/widgets/LinkDownRSSIWidget.qml +++ b/qml/ui/widgets/LinkDownRSSIWidget.qml @@ -372,15 +372,6 @@ BaseWidget { font.pixelSize: detailPanelFontPixels verticalAlignment: Text.AlignVCenter } - Text { - //Layout.alignment: left - text: "STBC/LPDC/SGI: "+_ohdSystemAir.wb_stbc_enabled+"/"+_ohdSystemAir.wb_lpdc_enabled+"/"+_ohdSystemAir.wb_short_guard_enabled - color: "white" - font.bold: true - height: parent.height - font.pixelSize: detailPanelFontPixels - verticalAlignment: Text.AlignVCenter - } } } diff --git a/qml/ui/widgets/LinkUpRSSIWidget.qml b/qml/ui/widgets/LinkUpRSSIWidget.qml index 38928023f..8a27ecd87 100644 --- a/qml/ui/widgets/LinkUpRSSIWidget.qml +++ b/qml/ui/widgets/LinkUpRSSIWidget.qml @@ -107,15 +107,6 @@ BaseWidget { font.pixelSize: detailPanelFontPixels verticalAlignment: Text.AlignVCenter } - /*Text { - //Layout.alignment: left - text: "GND RX vid0: "+_cameraStreamModelPrimary. - color: "white" - font.bold: true - height: parent.height - font.pixelSize: detailPanelFontPixels - verticalAlignment: Text.AlignVCenter - }*/ Text { //Layout.alignment: left text: "GND RX tele: "+_ohdSystemAir.rx_tele_packets_per_second_and_bits_per_second @@ -134,15 +125,6 @@ BaseWidget { font.pixelSize: detailPanelFontPixels verticalAlignment: Text.AlignVCenter } - Text { - //Layout.alignment: left - text: "STBC/LPDC/SGI: "+_ohdSystemGround.wb_stbc_enabled+"/"+_ohdSystemGround.wb_lpdc_enabled+"/"+_ohdSystemGround.wb_short_guard_enabled - color: "white" - font.bold: true - height: parent.height - font.pixelSize: detailPanelFontPixels - verticalAlignment: Text.AlignVCenter - } } } From bbcca3813946ad7974eac1b942315774c2d6db1a Mon Sep 17 00:00:00 2001 From: consti10 Date: Thu, 26 Oct 2023 15:22:18 +0200 Subject: [PATCH 18/81] add stbc / ldpc enable popup, improve UI --- QOpenHD.pro | 2 -- app/osd/altitudeladder.cpp | 4 +--- app/telemetry/models/fcmavlinksystem.h | 2 +- app/util/qopenhd.h | 2 +- qml/qml.qrc | 2 +- .../MavlinkOpenHDWBParamPanel2.qml | 8 +++++--- .../openhd_settings/PopupEnableSTBCLDPC.qml | 6 +++--- .../openhd_settings/PopupTxPowerEditor.qml | 20 +++++++++++++++++-- 8 files changed, 30 insertions(+), 16 deletions(-) diff --git a/QOpenHD.pro b/QOpenHD.pro index c245d9714..d7b0289ee 100755 --- a/QOpenHD.pro +++ b/QOpenHD.pro @@ -134,7 +134,6 @@ SOURCES += \ app/osd/altitudeladder.cpp \ app/osd/flightpathvector.cpp \ app/osd/aoagauge.cpp \ - app/osd/performancehorizonladder.cpp \ HEADERS += \ app/osd/headingladder.h \ @@ -144,7 +143,6 @@ HEADERS += \ app/osd/flightpathvector.h \ app/osd/debug_overdraw.hpp \ app/osd/aoagauge.h \ - app/osd/performancehorizonladder.h \ RESOURCES += qml/qml.qrc diff --git a/app/osd/altitudeladder.cpp b/app/osd/altitudeladder.cpp index 594935677..c6cf59981 100644 --- a/app/osd/altitudeladder.cpp +++ b/app/osd/altitudeladder.cpp @@ -19,8 +19,6 @@ void AltitudeLadder::paint(QPainter* painter) { setFillColor(QColor::fromRgb(0,255,0,128)); } - QFont font("sans-serif", 10, QFont::Bold, false); - painter->setFont(m_font); auto alt = m_altitude; @@ -121,6 +119,6 @@ void AltitudeLadder::setAltitudeRange(int altitudeRange) { void AltitudeLadder::setFontFamily(QString fontFamily) { m_fontFamily = fontFamily; emit fontFamilyChanged(m_fontFamily); - m_font = QFont(m_fontFamily, 11, QFont::Bold, false); + m_font = QFont(m_fontFamily, 13, QFont::Bold, false); update(); } diff --git a/app/telemetry/models/fcmavlinksystem.h b/app/telemetry/models/fcmavlinksystem.h index 3d7e35cd8..14d7a7455 100644 --- a/app/telemetry/models/fcmavlinksystem.h +++ b/app/telemetry/models/fcmavlinksystem.h @@ -87,7 +87,7 @@ class FCMavlinkSystem : public QObject // roll, pitch and yaw L_RO_PROP(double, pitch, set_pitch, 0) - L_RO_PROP(double, roll, set_roll, 0) + L_RO_PROP(double, roll, set_roll, 20) L_RO_PROP(double, yaw, set_yaw, 0) // mixed L_RO_PROP(double, throttle, set_throttle, 0) diff --git a/app/util/qopenhd.h b/app/util/qopenhd.h index 1e0c9b11b..f23826d4b 100644 --- a/app/util/qopenhd.h +++ b/app/util/qopenhd.h @@ -68,7 +68,7 @@ class QOpenHD : public QObject // Tries to mimic android toast as much as possible // Q_INVOKABLE void show_toast(QString message,bool long_toast=false); - L_RO_PROP(QString,version_string,set_version_string,"2.5.1-alpha"); + L_RO_PROP(QString,version_string,set_version_string,"2.5.2-alpha"); public: L_RO_PROP(QString,toast_text,set_toast_text,"NONE"); L_RO_PROP(bool,toast_visible,set_toast_visible,false); diff --git a/qml/qml.qrc b/qml/qml.qrc index ae881da86..2528562c8 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -187,7 +187,6 @@ video/ExpMainVideoAndroid.qml ui/elements/WorkaroundMessageBox.qml ui/elements/SettingBaseElement.qml - ui/widgets/PerformanceHorizonWidget.qml ui/widgets/WBLinkRateControlWidget.qml ui/widgets/BaseWidgetDefaultUiControlElements.qml resources/cursors/arrow_512_transparent.png @@ -259,5 +258,6 @@ ui/configpopup/status/StatusCardRow.qml ui/configpopup/connect/PaneConnectionMode.qml ui/configpopup/openhd_settings/PopupEnableSTBCLDPC.qml + ui/widgets/PerformanceHorizonWidget2.qml diff --git a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml index 04e3bb9ab..7a2f0617c 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml +++ b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml @@ -366,9 +366,10 @@ Rectangle{ Layout.columnSpan: 3 Text{ text:{ - "LOSS %:"+_ohdSystemGround.curr_rx_packet_loss_perc; + "LOSS %:"+_ohdSystemGround.curr_rx_packet_loss_perc } color: _ohdSystemGround.curr_rx_packet_loss_perc > 5 ? "red" : "black" + verticalAlignment: Qt.AlignVCenter } Text{ text: { @@ -479,8 +480,9 @@ Rectangle{ Layout.row: 2 Layout.column: 4 text: "EDIT"; - enabled: true //_ohdSystemAir.is_alive && _ohdSystemGround.is_alive && (_wbLinkSettingsHelper.ui_rebuild_models>=0) && - //(_ohdSystemGround.wb_stbc_enabled!=true || _ohdSystemGround.wb_lpdc_enabled!=true || _ohdSystemAir.wb_stbc_enabled!=true || _ohdSystemAir.wb_lpdc_enabled!=true); + //enabled: true + enabled: _ohdSystemAir.is_alive && _ohdSystemGround.is_alive && (_wbLinkSettingsHelper.ui_rebuild_models>=0) && + (_ohdSystemGround.wb_stbc_enabled!=true || _ohdSystemGround.wb_lpdc_enabled!=true || _ohdSystemAir.wb_stbc_enabled!=true || _ohdSystemAir.wb_lpdc_enabled!=true); onClicked: { popup_enable_stbc_ldpc.open() } diff --git a/qml/ui/configpopup/openhd_settings/PopupEnableSTBCLDPC.qml b/qml/ui/configpopup/openhd_settings/PopupEnableSTBCLDPC.qml index 1f295b6e1..f5e7f6e7b 100644 --- a/qml/ui/configpopup/openhd_settings/PopupEnableSTBCLDPC.qml +++ b/qml/ui/configpopup/openhd_settings/PopupEnableSTBCLDPC.qml @@ -126,7 +126,7 @@ Rectangle{ Layout.row: 3 Layout.column: 0 text: "ENABLE" - visible: comboBoxNAntennasAir.currentIndex==2 && comboBoxNAntennasGnd.currentIndex==2; + enabled: comboBoxNAntennasAir.currentIndex==2 && comboBoxNAntennasGnd.currentIndex==2; font.pixelSize: 14 onClicked: { if(_wbLinkSettingsHelper.set_param_stbc_ldpc_enable_air_ground()){ @@ -140,8 +140,8 @@ Rectangle{ Text{ Layout.row: 4 Layout.column: 0 - visible: !button_enable.visible - text: "CAN ONLY BE ENABLED IF BOTH AIR AND GN UNIT HAVE 2 RF PATHS / ANTENNAS"; + visible: !button_enable.enabled + text: "CAN ONLY BE ENABLED IF BOTH AIR AND GND UNIT HAVE 2 RF PATHS / ANTENNAS"; font.pixelSize: 14 } // ---------------- diff --git a/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml b/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml index ff002798b..9ee38a2f5 100644 --- a/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml +++ b/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml @@ -303,10 +303,18 @@ Rectangle{ } font.pixelSize: 14 } + ButtonIconInfo{ + Layout.row: 2 + Layout.column: 3 + onClicked: { + _messageBoxInstance.set_text_and_show("TX Power applied when FC is disarmed"); + } + } + // FILLER Item{ Layout.row: 2 - Layout.column: 3 + Layout.column: 4 Layout.fillWidth: true } // ---------------- @@ -355,10 +363,18 @@ 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."); + } + } // FILLER Item{ Layout.row: 3 - Layout.column: 3 + Layout.column: 4 Layout.fillWidth: true } Text{ From a4a7ed699792ec173779e921cf7ef3cea4cf0e19 Mon Sep 17 00:00:00 2001 From: consti10 Date: Thu, 26 Oct 2023 15:22:32 +0200 Subject: [PATCH 19/81] performancehorizonladder - new simple approach --- app/osd/performancehorizonladder.cpp | 234 ------------------- app/osd/performancehorizonladder.h | 47 ---- qml/ui/HUDOverlayGrid.qml | 2 +- qml/ui/widgets/PerformanceHorizonWidget.qml | 98 -------- qml/ui/widgets/PerformanceHorizonWidget2.qml | 122 ++++++++++ 5 files changed, 123 insertions(+), 380 deletions(-) delete mode 100644 app/osd/performancehorizonladder.cpp delete mode 100644 app/osd/performancehorizonladder.h delete mode 100644 qml/ui/widgets/PerformanceHorizonWidget.qml create mode 100644 qml/ui/widgets/PerformanceHorizonWidget2.qml diff --git a/app/osd/performancehorizonladder.cpp b/app/osd/performancehorizonladder.cpp deleted file mode 100644 index e0889664f..000000000 --- a/app/osd/performancehorizonladder.cpp +++ /dev/null @@ -1,234 +0,0 @@ -#include "performancehorizonladder.h" - -#include -#include -#include -#include - -PerformanceHorizonLadder::PerformanceHorizonLadder(QQuickItem *parent) - : QQuickItem(parent) -{ - setFlags(ItemHasContents); - setClip(false); -} - -PerformanceHorizonLadder::~PerformanceHorizonLadder() -{ - if(m_base_node){ - delete m_base_node; - } - if(m_center_indicator){ - delete m_center_indicator; - } - if(m_ladders_geom_node){ - delete m_ladders_geom_node; - } - if(m_tf_node){ - delete m_tf_node; - } - if(m_flat_color_material){ - delete m_flat_color_material; - } -} - -void PerformanceHorizonLadder::setRoll(int roll) { - m_roll = roll; - emit rollChanged(m_roll); - update(); -} - - -void PerformanceHorizonLadder::setPitch(int pitch) { - m_pitch = pitch; - emit pitchChanged(m_pitch); - update(); -} - - -static QSGGeometry* make_rectangle(int height,int width){ - QSGGeometry *geometry = new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), 4); - geometry->setDrawingMode(GL_LINES); - geometry->setLineWidth(10); - geometry->vertexDataAsPoint2D()[0].set(0, 0); - geometry->vertexDataAsPoint2D()[1].set(0,width); - geometry->vertexDataAsPoint2D()[2].set(height,width); - geometry->vertexDataAsPoint2D()[3].set(height,0); - return geometry; -} - -struct Vec2{ - float x=0; - float y=0; -}; -static void append_horizontal_line_with_middle_space(std::vector& buff,float x_off,float width,float y_off,float middle_space,float height){ - const float middle_space_half=middle_space/2; - //left up line - buff.push_back({x_off+0,y_off}); - buff.push_back({x_off+0,y_off+height}); - //left to middle - buff.push_back({x_off+0,y_off}); - buff.push_back({x_off+width/2.0f-middle_space_half,y_off}); - // middle to right - buff.push_back({x_off+width/2.0f+middle_space_half,y_off}); - buff.push_back({x_off+width,y_off}); - // right up - buff.push_back({x_off+width,y_off}); - buff.push_back({x_off+width,y_off+height}); -} -static void append_horizontal_line_with_middle_space_and_dashes(std::vector& buff,float x_off,float width,float y_off,float middle_space,float height){ - const float middle_space_half=middle_space/2; - const float horizontal_line_length=width/2.0f-middle_space_half; - const float dash_length=horizontal_line_length/5.0f; - //left down line - buff.push_back({x_off+0,y_off}); - buff.push_back({x_off+0,y_off-height}); - //left to middle,dashes - int count=0; - for(int i=0;i<3;i++){ - buff.push_back({x_off+dash_length*count,y_off}); - count++; - buff.push_back({x_off+dash_length*count,y_off}); - count++; - } - // middle to right - count=0; - for(int i=0;i<3;i++){ - const float start=x_off+width/2.0f+middle_space_half; - buff.push_back({start+dash_length*count,y_off}); - count++; - buff.push_back({start+dash_length*count,y_off}); - count++; - } - // right down line - buff.push_back({x_off+width,y_off}); - buff.push_back({x_off+width,y_off-height}); -} - -static void append_horizontal_line(std::vector& buff,float x,float y,float width){ - buff.push_back({x,y}); - buff.push_back({x+width,y}); -} - -static std::vector make_circle(int segments,float center_x,float center_y,float radius){ - std::vector vertices; - float step = 6.283185f/segments; - float angle = 0.0f; - - vertices.reserve(segments + 1); - for (int i = 0; i < segments; ++i, angle+=step) { - float vertX = center_x + cosf(angle)*radius; - float vertY = center_y + sinf(angle)*radius; - vertices.push_back({vertX, vertY}); - } - vertices.push_back({center_x+radius, center_y}); - return vertices; -} - -static QSGGeometry* qsggeometry_from_array(const std::vector& vec){ - QSGGeometry *geometry = new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), vec.size()); - for(int i=0;ivertexDataAsPoint2D()[i].set(vec[i].x,vec[i].y); - } - geometry->setDrawingMode(GL_LINES); - geometry->setLineWidth(1); - return geometry; -} - -static QSGGeometry* make_line(int width,int height){ - QSGGeometry *geometry = new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), 2); - geometry->setDrawingMode(GL_LINES); - geometry->setLineWidth(3); - /*geometry->vertexDataAsPoint2D()[0].set(-width/2, 0); //height/2 - geometry->vertexDataAsPoint2D()[1].set(width/2,0);*/ - geometry->vertexDataAsPoint2D()[0].set(0, height/2); //height/2 - geometry->vertexDataAsPoint2D()[1].set(width,height/2); - return geometry; -} - -QSGNode *PerformanceHorizonLadder::updatePaintNode(QSGNode *n, QQuickItem::UpdatePaintNodeData *) -{ - if(!m_base_node){ - m_base_node = new QSGNode(); - m_ladders_geom_node = new QSGGeometryNode(); - m_tf_node = new QSGTransformNode(); - m_center_indicator = new QSGGeometryNode(); - - m_flat_color_material = new QSGFlatColorMaterial(); - m_flat_color_material->setColor(QColor(255, 255, 255)); - - const auto m_width=width(); - const auto m_height=height(); - - { - //auto geometry=make_rectangle(width(),height()); - //auto geometry=make_line(width(),height()); - auto vertices=std::vector(); - // the middle, big line - append_horizontal_line(vertices,0,height()/2,width()); - // lower/ upper lines - const auto l_width=m_width * 0.6f; - const auto l_x_offset= m_width/2.0f-l_width/2.0f; - // upper lines - for(int i=1;i<9;i++){ //9 = 9 times 10 degree - const auto l_y_offset=height()/2.0f-height()/2.0f*i*1.2; - append_horizontal_line_with_middle_space(vertices,l_x_offset,l_width,l_y_offset,width()/4.0f,height()/30.0f); - } - // lower lines - for(int i=1;i<9;i++){ //9 = 9 times 10 degree - const auto l_y_offset=height()/2.0f+height()/2.0f*i*1.2; - append_horizontal_line_with_middle_space_and_dashes(vertices,l_x_offset,l_width,l_y_offset,width()/4.0f,height()/20.0f); - } - //append_horizontal_line_with_middle_space(vertices,width(),width()/2,height()/10,-height()/2); - - auto geometry=qsggeometry_from_array(vertices); - - m_ladders_geom_node->setGeometry(geometry); - m_ladders_geom_node->setFlag(QSGNode::OwnsGeometry); - m_ladders_geom_node->setMaterial(m_flat_color_material); - m_ladders_geom_node->setFlag(QSGNode::OwnsMaterial); - } - { - //auto vertices=std::vector(); - //const auto center_line_width=width()/8; - //append_horizontal_line(vertices,width()/2.0f-center_line_width/2.0f,height()/2,center_line_width); - const auto radius=width()/38; - auto vertices = make_circle(20,width()/2,height()/2,radius); - auto geometry=qsggeometry_from_array(vertices); - geometry->setDrawingMode(GL_LINE_STRIP); - geometry->setLineWidth(1); - m_center_indicator->setGeometry(geometry); - m_center_indicator->setFlag(QSGNode::OwnsGeometry); - m_center_indicator->setMaterial(m_flat_color_material); - m_center_indicator->setFlag(QSGNode::OwnsMaterial); - } - - m_base_node->appendChildNode(m_tf_node); - m_base_node->appendChildNode(m_center_indicator); - m_tf_node->appendChildNode(m_ladders_geom_node); - } - //qDebug()<<"LOOOL"; - - QRectF rect(boundingRect()); - - //QSGGeometry::updateColoredRectGeometry(node->geometry(),rect); - //QSGGeometry::updateTexturedRectGeometry(node->geometry(), rect, texture_coords); - m_ladders_geom_node->markDirty(QSGNode::DirtyGeometry | QSGNode::DirtyMaterial); - - { - auto matrix=QMatrix4x4(); - matrix.setToIdentity(); - matrix.translate(width()/2,height()/2,0); - matrix.rotate(m_roll*-1,QVector3D(0,0,1)); - matrix.translate(-width()/2,-height()/2,0); - - matrix.translate({0.0f,m_pitch*18.0f,0.0f}); - m_tf_node->setMatrix(matrix); - } - - //QTransform transform_centerOfWindow( 1, 0, 0, 1, width()/2, height()/2 ); - //transform_centerOfWindow.rotate(m_pitch*18.0f); - - //QMetaObject::invokeMethod(node, "update", Qt::QueuedConnection); - //return node; - return m_base_node; -} diff --git a/app/osd/performancehorizonladder.h b/app/osd/performancehorizonladder.h deleted file mode 100644 index beb09112c..000000000 --- a/app/osd/performancehorizonladder.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef PERFORMANCEHORIZONLADDER_H -#define PERFORMANCEHORIZONLADDER_H - -#include -#include -#include -//#include "../../../lib/lqtutils_master/lqtutils_prop.h" -#include "lib/lqtutils_master/lqtutils_prop.h" - -#include "horizonladder.h" - -class PerformanceHorizonLadder : public QQuickItem -{ - Q_OBJECT -public: - PerformanceHorizonLadder(QQuickItem *parent = nullptr); - ~ PerformanceHorizonLadder(); - - Q_PROPERTY(int pitch MEMBER m_pitch WRITE setPitch NOTIFY pitchChanged) - Q_PROPERTY(int roll MEMBER m_roll WRITE setRoll NOTIFY rollChanged) - // - void setRoll(int roll); - void setPitch(int pitch); -signals: - void rollChanged(int roll); - void pitchChanged(int pitch); - // QQuickItem interface -protected: - QSGNode *updatePaintNode(QSGNode *n, UpdatePaintNodeData *) override; - -private: - QSGNode *m_base_node=nullptr; - // node for the center indicator, never translated - QSGGeometryNode *m_center_indicator=nullptr; - // node for the ladder lines, translated - QSGGeometryNode *m_ladders_geom_node=nullptr; - QSGTransformNode* m_tf_node=nullptr; - // - QSGFlatColorMaterial *m_flat_color_material=nullptr; -private: - int m_roll; - int m_pitch; -private: - HorizonLadder* m_hl=nullptr; -}; - -#endif // PERFORMANCEHORIZONLADDER_H diff --git a/qml/ui/HUDOverlayGrid.qml b/qml/ui/HUDOverlayGrid.qml index f4779450f..afe49440a 100644 --- a/qml/ui/HUDOverlayGrid.qml +++ b/qml/ui/HUDOverlayGrid.qml @@ -368,7 +368,7 @@ Item { id: horizonWidget } - PerformanceHorizonWidget{ + PerformanceHorizonWidget2{ id: performanceHorizonWidget } diff --git a/qml/ui/widgets/PerformanceHorizonWidget.qml b/qml/ui/widgets/PerformanceHorizonWidget.qml deleted file mode 100644 index e36f74326..000000000 --- a/qml/ui/widgets/PerformanceHorizonWidget.qml +++ /dev/null @@ -1,98 +0,0 @@ -import QtQuick 2.12 -import QtQuick.Controls 2.12 -import QtQuick.Layouts 1.12 -import QtGraphicalEffects 1.12 -import Qt.labs.settings 1.0 - -import OpenHD 1.0 - -BaseWidget { - id: horizonWidget - width: 250 - height: 48 - - visible: settings.show_performance_horizon - - widgetIdentifier: "performance_horizon_widget" - bw_verbose_name: "PERFORMANCE HORIZON" - - defaultHCenter: true - defaultVCenter: true - - hasWidgetDetail: true - - m_show_grid_when_dragging : true - - widgetDetailComponent: ScrollView { - - contentHeight: idBaseWidgetDefaultUiControlElements.height - ScrollBar.horizontal.policy: ScrollBar.AlwaysOff - clip: true - - BaseWidgetDefaultUiControlElements{ - id: idBaseWidgetDefaultUiControlElements - Item { - width: 230 - height: 32 - Text { - text: qsTr("Width") - color: "white" - height: parent.height - font.bold: true - font.pixelSize: detailPanelFontPixels - anchors.left: parent.left - verticalAlignment: Text.AlignVCenter - } - Slider { - id: horizon_width_Slider - orientation: Qt.Horizontal - from: 1 - value: 0 - to: 10 - stepSize: .1 - height: parent.height - anchors.rightMargin: 0 - anchors.right: parent.right - width: parent.width - 96 - - onValueChanged: { - - } - } - } - } - } - - Item { - id: widgetInner - anchors.fill: parent - opacity: bw_current_opacity - - Rectangle { - id: horizonLadder2 - visible: true - width: 400 - height: 300 - //border.width: 2 - //border.color: "green" - //color: "green" - color: "transparent" - - anchors.centerIn: parent - - PerformanceHorizonLadder{ - id: performanceHorizonLadder - width: 400 - height: 300 - anchors.centerIn: parent - - pitch: _fcMavlinkSystem.pitch - roll: _fcMavlinkSystem.roll - - Behavior on pitch {NumberAnimation { duration: settings.smoothing }} - Behavior on roll {NumberAnimation { duration: settings.smoothing }} - } - - } - } -} diff --git a/qml/ui/widgets/PerformanceHorizonWidget2.qml b/qml/ui/widgets/PerformanceHorizonWidget2.qml new file mode 100644 index 000000000..5dbbb307a --- /dev/null +++ b/qml/ui/widgets/PerformanceHorizonWidget2.qml @@ -0,0 +1,122 @@ +import QtQuick 2.15 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtGraphicalEffects 1.12 +import Qt.labs.settings 1.0 +import QtQuick.Shapes 1.0 + +import OpenHD 1.0 + +BaseWidget { + id: horizonWidget + width: 250 + height: 48 + + visible: settings.show_performance_horizon + + widgetIdentifier: "horizon_performance2" + bw_verbose_name: "ARTIFICIAL HORIZON 2" + + defaultHCenter: true + defaultVCenter: true + + hasWidgetDetail: true + widgetDetailHeight: 250+250 + + m_show_grid_when_dragging : true + + widgetDetailComponent: ScrollView { + + contentHeight: idBaseWidgetDefaultUiControlElements.height + ScrollBar.horizontal.policy: ScrollBar.AlwaysOff + clip: true + + BaseWidgetDefaultUiControlElements{ + id: idBaseWidgetDefaultUiControlElements + + show_vertical_lock: true + show_horizontal_lock: true + + } + } + + Item { + id: widgetInner + anchors.fill: parent + opacity: bw_current_opacity + + // actual horizon + Item{ + id: horizon_item + width: parent.width; + height: 4 + anchors.centerIn: parent + // Left line + Rectangle{ + width: parent.width/3 + height: parent.height + anchors.left: parent.left + color: "green" + //color: settings.color_text + //border.color: settings.color_glow + //border.width: 1 + } + // + // Here is the middle, which isn't rotated and therefore not placed in here + // + // Right line + Rectangle{ + width: parent.width/3 + height: parent.height + anchors.right: parent.right + color: "green" + } + transform: [ + // First rotate (roll) + Rotation { + origin.x: horizon_item.width/2; + origin.y: horizon_item.height/2; + //angle: _fcMavlinkSystem.roll*-1 + angle: 0 + }, + // Then translate (pitch) + Translate{ + y: 0 + } + ] + } + // The middle indicator + Rectangle { + id: middle_indicator + height: 20 + width: 20 + radius: width/2; + anchors.centerIn: parent + color: "transparent" + border.color: "green" + border.width: 2 + } + Rectangle{ + id: middle_indicator2 + height: 2; + width: 30 + anchors.centerIn: parent + color: "green" + } + + /*Rectangle{ + width: 3; + height: 2; + color: "green" + anchors.left: middle_indicator.left + anchors.top: middle_indicator.top + }*/ + } + /*Rectangle{ + id: debug_rect + implicitWidth: widgetInner.width + implicitHeight: widgetInner.height + color: "red" + opacity: 0.8 + }*/ +} From e90cd94f377b0dc275c2ea08d9b48a25bcb6b59b Mon Sep 17 00:00:00 2001 From: consti10 Date: Thu, 26 Oct 2023 15:25:57 +0200 Subject: [PATCH 20/81] performancehorizonladder - new simple approach --- app/main.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/main.cpp b/app/main.cpp index feef7100c..38baed1f7 100755 --- a/app/main.cpp +++ b/app/main.cpp @@ -32,7 +32,6 @@ const QVector permissions({"android.permission.INTERNET", #include "osd/horizonladder.h" #include "osd/flightpathvector.h" #include "osd/aoagauge.h" -#include "osd/performancehorizonladder.h" // Video - annyoing ifdef crap is needed for all the different platforms / configurations #include "decodingstatistcs.h" @@ -256,8 +255,6 @@ int main(int argc, char *argv[]) { qmlRegisterType("OpenHD", 1, 0, "HorizonLadder"); qmlRegisterType("OpenHD", 1, 0, "FlightPathVector"); qmlRegisterType("OpenHD", 1, 0, "AoaGauge"); - qmlRegisterType("OpenHD", 1, 0, "PerformanceHorizonLadder"); - QQmlApplicationEngine engine; engine.rootContext()->setContextProperty("_qopenhd", &QOpenHD::instance()); From 7e4b785c39ff68634285ba929dd82496f387cd5b Mon Sep 17 00:00:00 2001 From: consti10 Date: Thu, 26 Oct 2023 23:46:45 +0200 Subject: [PATCH 21/81] small ui improvements --- qml/qml.qrc | 1 + qml/ui/configpopup/status/PanelStatus.qml | 10 +- .../configpopup/status/StatusCardBodyFC.qml | 120 ++++-------------- .../status/StatusCardBodyOpenHD.qml | 5 - qml/ui/configpopup/status/StatusCardRow.qml | 9 +- .../configpopup/status/StatusCardsColumn.qml | 2 +- .../configpopup/status/StatusCardsColumn2.qml | 79 ++++++++++++ .../BaseWidgetDefaultUiControlElements.qml | 2 + qml/ui/widgets/PerformanceHorizonWidget2.qml | 43 +++++-- 9 files changed, 149 insertions(+), 122 deletions(-) create mode 100644 qml/ui/configpopup/status/StatusCardsColumn2.qml diff --git a/qml/qml.qrc b/qml/qml.qrc index 2528562c8..163425e6e 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -259,5 +259,6 @@ ui/configpopup/connect/PaneConnectionMode.qml ui/configpopup/openhd_settings/PopupEnableSTBCLDPC.qml ui/widgets/PerformanceHorizonWidget2.qml + ui/configpopup/status/StatusCardsColumn2.qml diff --git a/qml/ui/configpopup/status/PanelStatus.qml b/qml/ui/configpopup/status/PanelStatus.qml index dce530cd6..edc95f991 100644 --- a/qml/ui/configpopup/status/PanelStatus.qml +++ b/qml/ui/configpopup/status/PanelStatus.qml @@ -43,16 +43,19 @@ Rectangle { Item{ id: mainItem width: 800 - height: 40+400+80 + height: 40+350+80 QOpenHDVersionCard{ id: qopenhdversioncard height: 40 } - StatusCardsColumn{ + + // The 3 status cards (OpenHD AIR & GND, FC) + // next to each other + StatusCardsColumn2{ id: statuscardscolumn width: parent.width - height: 400 + height: 350 anchors.leftMargin: 12 anchors.rightMargin: 12 @@ -61,6 +64,7 @@ Rectangle { anchors.top: qopenhdversioncard.bottom } + PingUtilColumn { id:actionsButtonMenu width: parent.width diff --git a/qml/ui/configpopup/status/StatusCardBodyFC.qml b/qml/ui/configpopup/status/StatusCardBodyFC.qml index 3cb5a33b5..cce41116c 100644 --- a/qml/ui/configpopup/status/StatusCardBodyFC.qml +++ b/qml/ui/configpopup/status/StatusCardBodyFC.qml @@ -12,12 +12,9 @@ import "../../../ui" as Ui import "../../elements" ColumnLayout { - // from https://doc.qt.io/qt-6/qml-qtquick-layouts-rowlayout.html - anchors.fill: parent - spacing: 2 - - property int rowHeight: 64 - property int text_minHeight: 20 + width: parent.width + height: parent.height + spacing: 1 property bool m_is_alive: _fcMavlinkSystem.is_alive function get_alive_text(){ @@ -28,100 +25,29 @@ ColumnLayout { return m_is_alive ? "green" : "black" } - RowLayout{ - Layout.fillWidth: true - Layout.minimumHeight: text_minHeight - spacing: 6 - Text { - text: qsTr("Autopilot:") - height: 24 - font.pixelSize: 14 - font.bold: true - leftPadding: 12 - } - Text { - text: _fcMavlinkSystem.autopilot_type_str - height: 24 - width: 256 - font.pixelSize: 14 - leftPadding: 6 - } + StatusCardRow{ + m_left_text: qsTr("FW:") //Autopilot + m_right_text: _fcMavlinkSystem.autopilot_type_str } - RowLayout{ - Layout.fillWidth: true - Layout.minimumHeight: text_minHeight - spacing: 6 - Text { - text: qsTr("MAV type:") - height: 24 - font.pixelSize: 14 - font.bold: true - leftPadding: 12 - } - Text { - text: _fcMavlinkSystem.mav_type_str - height: 24 - width: 256 - font.pixelSize: 14 - leftPadding: 6 - } + + StatusCardRow{ + m_left_text: qsTr("Ping:") + m_right_text: _fcMavlinkSystem.last_ping_result_flight_ctrl } - RowLayout{ - Layout.fillWidth: true - Layout.minimumHeight: text_minHeight - spacing: 6 - Text { - text: qsTr("Last Ping:") - height: 24 - font.pixelSize: 14 - font.bold: true - leftPadding: 12 - } - Text { - text: _fcMavlinkSystem.last_ping_result_flight_ctrl - height: 24 - width: 256 - font.pixelSize: 14 - leftPadding: 6 - } + + StatusCardRow{ + m_left_text: qsTr("Type:") // MAV type + m_right_text: _fcMavlinkSystem.mav_type_str } - RowLayout{ - Layout.fillWidth: true - Layout.minimumHeight: text_minHeight - spacing: 6 - Text { - text: qsTr("Alive: ") - height: 24 - font.pixelSize: 14 - font.bold: true - leftPadding: 12 - } - Text { - text: get_alive_text() - color: get_alive_text_color() - height: 24 - width: 256 - font.pixelSize: 14 - leftPadding: 6 - } + + StatusCardRow{ + m_left_text: qsTr("Alive:") + m_right_text: get_alive_text(); + m_right_text_color: get_alive_text_color() } - RowLayout{ - Layout.fillWidth: true - Layout.minimumHeight: text_minHeight - spacing: 6 - Text { - text: qsTr("Sys id: ") - height: 24 - font.pixelSize: 14 - font.bold: true - leftPadding: 12 - } - Text { - text: _fcMavlinkSystem.for_osd_sys_id == -1 ? "na" : qsTr(""+_fcMavlinkSystem.for_osd_sys_id) - height: 24 - width: 256 - font.pixelSize: 14 - leftPadding: 6 - } + + StatusCardRow{ + m_left_text: qsTr("SysID:") + m_right_text: _fcMavlinkSystem.for_osd_sys_id == -1 ? "na" : qsTr(""+_fcMavlinkSystem.for_osd_sys_id) } } diff --git a/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml b/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml index d369e8149..9e05c3f79 100644 --- a/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml +++ b/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml @@ -65,11 +65,6 @@ ColumnLayout { return ret; } - property int text_minHeight: 30 - property int column_preferred_height: 50 - - property int left_part_preferred_with: 100 - StatusCardRow{ m_left_text: qsTr("Version:") m_right_text: m_version diff --git a/qml/ui/configpopup/status/StatusCardRow.qml b/qml/ui/configpopup/status/StatusCardRow.qml index cab2b2b71..0ee6a9066 100644 --- a/qml/ui/configpopup/status/StatusCardRow.qml +++ b/qml/ui/configpopup/status/StatusCardRow.qml @@ -27,7 +27,7 @@ Item { //Layout.preferredHeight: 30 //Layout.minimumWidth: 250 width: parent.width - height: 50 + height: 48 id: main_item property string m_left_text: "LEFT" @@ -75,8 +75,10 @@ Item { anchors.top: parent.top text: m_left_text verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignRight font.bold: true - font.pixelSize: 20 + font.pixelSize: 19 + clip: true } Text{ @@ -87,9 +89,10 @@ Item { anchors.top: left_part.top text: m_right_text verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignCenter color: m_has_error ? m_right_text_color_error : m_right_text_color visible: !right_part_button.visible - font.pixelSize: 20 + font.pixelSize: 19 } MouseArea { enabled: m_has_error && !m_look_shit_on_error diff --git a/qml/ui/configpopup/status/StatusCardsColumn.qml b/qml/ui/configpopup/status/StatusCardsColumn.qml index 870ad67fa..4468c360c 100644 --- a/qml/ui/configpopup/status/StatusCardsColumn.qml +++ b/qml/ui/configpopup/status/StatusCardsColumn.qml @@ -79,7 +79,7 @@ Item{ Rectangle{ id: background3 - //width: m_card_width + width: m_card_width height: parent.height anchors.rightMargin: m_padding_between anchors.leftMargin: m_padding_between diff --git a/qml/ui/configpopup/status/StatusCardsColumn2.qml b/qml/ui/configpopup/status/StatusCardsColumn2.qml new file mode 100644 index 000000000..04bc3dac6 --- /dev/null +++ b/qml/ui/configpopup/status/StatusCardsColumn2.qml @@ -0,0 +1,79 @@ +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Controls.Material 2.12 + +import Qt.labs.settings 1.0 + +import OpenHD 1.0 + +import "../../../ui" as Ui +import "../../elements" + +// +// The 3 status cards (OpenHD AIR & GND, FC) +// next to each other +RowLayout{ + width: parent.width + height: parent.height + + property int m_padding_between: 4 + + property int m_card_width: parent.width/3 - (m_padding_between) + + Card { + width: parent.width /3 + height:parent.height + id: groundBox + cardName: qsTr("Ground station") + + //visible: _ohdSystemGround.is_alive + m_style_error: !_ohdSystemGround.is_alive + + cardBody: StatusCardBodyOpenHD{ + m_is_ground: true + } + + hasFooter: true + cardFooter: FooterRebootShutdownWarning{ + m_type: 0 + } + } + Card { + width: parent.width /3 + height:parent.height + id: airBox + cardName: qsTr("Air unit") + //visible: _ohdSystemAir.is_alive + m_style_error: !_ohdSystemAir.is_alive + + cardBody: StatusCardBodyOpenHD{ + m_is_ground: false + } + + hasFooter: true + cardFooter: FooterRebootShutdownWarning{ + m_type: 1 + } + } + + Card { + width: parent.width /3 + height:parent.height + id: fcBox + cardName: qsTr("Flight Controller") + //visible: _fcMavlinkSystem.is_alive + m_style_error: !_fcMavlinkSystem.is_alive + cardBody: StatusCardBodyFC{ + + } + + hasFooter: true + cardFooter: FooterRebootShutdownWarning{ + m_type: 2 + } + } + + +} + diff --git a/qml/ui/widgets/BaseWidgetDefaultUiControlElements.qml b/qml/ui/widgets/BaseWidgetDefaultUiControlElements.qml index 4d4e670fb..2393da157 100644 --- a/qml/ui/widgets/BaseWidgetDefaultUiControlElements.qml +++ b/qml/ui/widgets/BaseWidgetDefaultUiControlElements.qml @@ -17,6 +17,7 @@ ColumnLayout{ // (aka it makes sense that the user wishes to place this widget vertically / horizontally in the center) property bool show_vertical_lock: false property bool show_horizontal_lock: false + property bool show_transparency: true Item { width: parent.width @@ -44,6 +45,7 @@ ColumnLayout{ Item { width: parent.width height: 32 + visible: show_transparency Text { id: opacityTitle text: qsTr("Transparency") diff --git a/qml/ui/widgets/PerformanceHorizonWidget2.qml b/qml/ui/widgets/PerformanceHorizonWidget2.qml index 5dbbb307a..74400f464 100644 --- a/qml/ui/widgets/PerformanceHorizonWidget2.qml +++ b/qml/ui/widgets/PerformanceHorizonWidget2.qml @@ -25,6 +25,13 @@ BaseWidget { m_show_grid_when_dragging : true + //property color line_fill_color: "green" + //property color line_outline_color: "yellow" + //property color middle_element_color: "green" + property color line_fill_color: settings.color_shape + property color line_outline_color: settings.color_glow + property color middle_element_color: settings.color_shape + widgetDetailComponent: ScrollView { contentHeight: idBaseWidgetDefaultUiControlElements.height @@ -36,6 +43,7 @@ BaseWidget { show_vertical_lock: true show_horizontal_lock: true + show_transparency: true } } @@ -43,7 +51,10 @@ BaseWidget { Item { id: widgetInner anchors.fill: parent - opacity: bw_current_opacity + // There is no point in making this one opaque + opacity: 1.0 + //opacity: bw_current_opacity + scale: bw_current_scale // actual horizon Item{ @@ -53,35 +64,40 @@ BaseWidget { anchors.centerIn: parent // Left line Rectangle{ - width: parent.width/3 + id: left_line + width: (parent.width/2) - 20 height: parent.height anchors.left: parent.left - color: "green" - //color: settings.color_text - //border.color: settings.color_glow - //border.width: 1 + color: line_fill_color + border.color: line_outline_color + border.width: 1 + antialiasing: true } // // Here is the middle, which isn't rotated and therefore not placed in here // // Right line Rectangle{ - width: parent.width/3 + id: right_line + width: left_line.width height: parent.height anchors.right: parent.right - color: "green" + color: line_fill_color + border.color: line_outline_color + border.width: 1 + antialiasing: true } transform: [ // First rotate (roll) Rotation { origin.x: horizon_item.width/2; origin.y: horizon_item.height/2; - //angle: _fcMavlinkSystem.roll*-1 - angle: 0 + angle: _fcMavlinkSystem.roll*-1 + //angle: 0 }, // Then translate (pitch) Translate{ - y: 0 + y: _fcMavlinkSystem.pitch*4 } ] } @@ -93,7 +109,8 @@ BaseWidget { radius: width/2; anchors.centerIn: parent color: "transparent" - border.color: "green" + //border.color: "green" + border.color: middle_element_color border.width: 2 } Rectangle{ @@ -101,7 +118,7 @@ BaseWidget { height: 2; width: 30 anchors.centerIn: parent - color: "green" + color: middle_element_color } /*Rectangle{ From ac653fb7f30dd6a686d65723c064493416ab05cc Mon Sep 17 00:00:00 2001 From: consti10 Date: Thu, 26 Oct 2023 23:47:49 +0200 Subject: [PATCH 22/81] accident, was only for debugging --- app/telemetry/models/fcmavlinksystem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/telemetry/models/fcmavlinksystem.h b/app/telemetry/models/fcmavlinksystem.h index 14d7a7455..3d7e35cd8 100644 --- a/app/telemetry/models/fcmavlinksystem.h +++ b/app/telemetry/models/fcmavlinksystem.h @@ -87,7 +87,7 @@ class FCMavlinkSystem : public QObject // roll, pitch and yaw L_RO_PROP(double, pitch, set_pitch, 0) - L_RO_PROP(double, roll, set_roll, 20) + L_RO_PROP(double, roll, set_roll, 0) L_RO_PROP(double, yaw, set_yaw, 0) // mixed L_RO_PROP(double, throttle, set_throttle, 0) From 2bfce26de60844a232a223cfe024ba21a4e57705 Mon Sep 17 00:00:00 2001 From: consti10 Date: Fri, 27 Oct 2023 11:34:11 +0200 Subject: [PATCH 23/81] small UI improvements and rename --- app/util/qopenhd.h | 2 +- qml/qml.qrc | 6 +- .../connect/PaneConnectionMode.qml | 2 + .../MavlinkAllSettingsPanel.qml | 75 +- .../MavlinkOpenHDWBParamPanel.qml | 766 ++++++++---------- .../MavlinkOpenHDWBParamPanel2.qml | 516 ------------ .../AppGeneralSettingsView.qml | 53 +- qml/ui/configpopup/status/PanelStatus.qml | 9 +- .../configpopup/status/StatusCardsColumn.qml | 110 +-- .../configpopup/status/StatusCardsColumn2.qml | 79 -- qml/ui/widgets/WBLinkRateControlWidget.qml | 4 +- 11 files changed, 443 insertions(+), 1179 deletions(-) delete mode 100644 qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml delete mode 100644 qml/ui/configpopup/status/StatusCardsColumn2.qml diff --git a/app/util/qopenhd.h b/app/util/qopenhd.h index f23826d4b..e7388b4d4 100644 --- a/app/util/qopenhd.h +++ b/app/util/qopenhd.h @@ -68,7 +68,7 @@ class QOpenHD : public QObject // Tries to mimic android toast as much as possible // Q_INVOKABLE void show_toast(QString message,bool long_toast=false); - L_RO_PROP(QString,version_string,set_version_string,"2.5.2-alpha"); + L_RO_PROP(QString,version_string,set_version_string,"2.5.2-evo-alpha"); public: L_RO_PROP(QString,toast_text,set_toast_text,"NONE"); L_RO_PROP(bool,toast_visible,set_toast_visible,false); diff --git a/qml/qml.qrc b/qml/qml.qrc index 163425e6e..8afac7f5f 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -209,7 +209,6 @@ ui/configpopup/qopenhd_settings/AppDevSettingsView.qml ui/configpopup/openhd_settings/MavlinkParamPanel.qml ui/configpopup/openhd_settings/MavlinkParamEditor.qml - ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml ui/configpopup/openhd_settings/DialoqueFreqChangeGndOnly.qml ui/configpopup/ConfigPopupSidebarButton.qml @@ -228,7 +227,6 @@ ui/elements/RestartQOpenHDMessageBox.qml ui/widgets/map/MapWidgetForm.ui.qml ui/widgets/map/MapWidget.qml - ui/configpopup/status/StatusCardsColumn.qml ui/configpopup/status/PingUtilColumn.qml ui/elements/ButtonRed.qml ui/elements/ButtonOrange.qml @@ -251,7 +249,7 @@ ui/configpopup/status/DialoqueNotAlive.qml ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml ui/configpopup/log/LogMessagesView.qml - ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml + ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml ui/configpopup/openhd_settings/PopupScanChannels.qml ui/configpopup/openhd_settings/PopupTxPowerEditor.qml ui/elements/TextOrWarningButton.qml @@ -259,6 +257,6 @@ ui/configpopup/connect/PaneConnectionMode.qml ui/configpopup/openhd_settings/PopupEnableSTBCLDPC.qml ui/widgets/PerformanceHorizonWidget2.qml - ui/configpopup/status/StatusCardsColumn2.qml + ui/configpopup/status/StatusCardsColumn.qml diff --git a/qml/ui/configpopup/connect/PaneConnectionMode.qml b/qml/ui/configpopup/connect/PaneConnectionMode.qml index d2e1fdbdc..f05786825 100644 --- a/qml/ui/configpopup/connect/PaneConnectionMode.qml +++ b/qml/ui/configpopup/connect/PaneConnectionMode.qml @@ -41,6 +41,8 @@ Rectangle{ ColumnLayout{ id: main_layout width: main_item.width + anchors.left: parent.left + anchors.leftMargin: 4 //Layout.fillWidth: true Layout.fillHeight: true Text{ diff --git a/qml/ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml b/qml/ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml index 5ccf7e569..00b63a38e 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml +++ b/qml/ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml @@ -29,7 +29,7 @@ Rectangle { function user_quidance_animate_channel_scan(){ selectItemInStackLayoutBar.currentIndex=0; - xX_WBLinkSettings.user_quidance_animate_channel_scan(); + mavlink_openhd_wb_param_panel.user_quidance_animate_channel_scan(); } // Tab bar for selecting items in stack layout @@ -56,45 +56,40 @@ Rectangle { // placed right below the top bar StackLayout { - width: parent.width - height: parent.height-selectItemInStackLayoutBar.height - anchors.top: selectItemInStackLayoutBar.bottom - anchors.left: selectItemInStackLayoutBar.left - anchors.bottom: parent.bottom - currentIndex: selectItemInStackLayoutBar.currentIndex + width: parent.width + height: parent.height-selectItemInStackLayoutBar.height + anchors.top: selectItemInStackLayoutBar.bottom + anchors.left: selectItemInStackLayoutBar.left + anchors.bottom: parent.bottom + currentIndex: selectItemInStackLayoutBar.currentIndex - MavlinkOpenHDWBParamPanel2{ - //WBFrequencyPanel{ - id: xX_WBLinkSettings - } - // MavlinkSetupPiCameraPanel{ - // id: x1_WBPiCameraSettings - // } - MavlinkParamPanel{ - id: x1_AirCameraSettingsPanel - m_name: "CAMERA1" - m_instanceMavlinkSettingsModel: _airCameraSettingsModel - m_instanceCheckIsAvlie: _ohdSystemAir - } - // exp - MavlinkParamPanel{ - id: x1_AirCameraSettingsPanel2 - m_name: "CAMERA2" - m_instanceMavlinkSettingsModel: _airCameraSettingsModel2 - m_instanceCheckIsAvlie: _ohdSystemAir - } - MavlinkParamPanel{ - id: x2_AirSettingsPanel - m_name: "AIR" - m_instanceMavlinkSettingsModel: _ohdSystemAirSettingsModel - m_instanceCheckIsAvlie: _ohdSystemAir - } - MavlinkParamPanel{ - id: x3_GroundSettingsPanel - m_name: "GROUND" - m_instanceMavlinkSettingsModel: _ohdSystemGroundSettings - m_instanceCheckIsAvlie: _ohdSystemGround - } - } + MavlinkOpenHDWBParamPanel{ + id: mavlink_openhd_wb_param_panel + } + MavlinkParamPanel{ + id: x1_AirCameraSettingsPanel + m_name: "CAMERA1" + m_instanceMavlinkSettingsModel: _airCameraSettingsModel + m_instanceCheckIsAvlie: _ohdSystemAir + } + MavlinkParamPanel{ + id: x1_AirCameraSettingsPanel2 + m_name: "CAMERA2" + m_instanceMavlinkSettingsModel: _airCameraSettingsModel2 + m_instanceCheckIsAvlie: _ohdSystemAir + } + MavlinkParamPanel{ + id: x2_AirSettingsPanel + m_name: "AIR" + m_instanceMavlinkSettingsModel: _ohdSystemAirSettingsModel + m_instanceCheckIsAvlie: _ohdSystemAir + } + MavlinkParamPanel{ + id: x3_GroundSettingsPanel + m_name: "GROUND" + m_instanceMavlinkSettingsModel: _ohdSystemGroundSettings + m_instanceCheckIsAvlie: _ohdSystemGround + } + } } diff --git a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml index f53f03a97..2277f4c91 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml +++ b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml @@ -19,12 +19,14 @@ import QtCharts 2.0 // This is an extra screen for changing the frequency / channel width - // They both need to match ! Rectangle{ + id: main_background width: parent.width height: parent.height + //property color m_background_color: "#8cbfd7f3" + //property color m_background_color: "#ADD8E6" + property color m_background_color: "#8cbfd7f3" - //color: "transparent" - //color: settings.screen_settings_openhd_parameters_transparent ? "transparent" : "white" - //opacity: settings.screen_settings_openhd_parameters_transparent ? 0.2 : 1 + property int m_small_width: 200 function user_quidance_animate_channel_scan(){ console.log("User guidance animate channel scan"); @@ -108,158 +110,32 @@ Rectangle{ } // - Component.onCompleted: { - - } - // - - // ------------------- PART HELPER FOR CURRENT LOSS / POLLUTION / THROTTLE BEGIN ------------------- - property bool m_is_ground_and_air_alive: _ohdSystemGround.is_alive && _ohdSystemAir.is_alive - property int m_loss_warning_level: { - if(!_ohdSystemAir.is_alive)return 0; // Info not available - var curr_rx_packet_loss_perc=_ohdSystemGround.curr_rx_packet_loss_perc; - if(curr_rx_packet_loss_perc>=8)return 2; - if(curr_rx_packet_loss_perc>=4)return 1; - return 0; - } - - property int m_pollution_warning_level: { - if(!_ohdSystemGround.is_alive)return 0; // Info not available - var wb_link_curr_foreign_pps=_ohdSystemGround.wb_link_curr_foreign_pps; - if(wb_link_curr_foreign_pps>=50)return 2; - if(wb_link_curr_foreign_pps>=10)return 1; - return 0; - } - - property int m_throttle_warning_level: { - if(!_ohdSystemAir.is_alive)return 0; // Info not available - var throttle=_ohdSystemAir.curr_n_rate_adjustments; - if(throttle>=3)return 2; - if(throttle>=1)return 1; - return 0; - } - function warning_level_to_color(level){ - if(level==2)return "red"; - if(level==1)return "green"; - return "black"; - } - - function get_text_current_loss(){ - if(!_ohdSystemGround.is_alive){ - return "Loss: -1%"; - } - if(!_ohdSystemAir.is_alive){ - return "Loss: -1%"; - } - return "Loss:"+_ohdSystemGround.curr_rx_packet_loss_perc+"%"; - } - - function get_text_current_pollution(){ - if(!_ohdSystemGround.is_alive)return ""; - var wb_link_pollution_perc=_ohdSystemAir.is_alive ? _ohdSystemGround.wb_link_pollution_perc : -1; - var wb_link_pollution_pps = _ohdSystemGround.wb_link_curr_foreign_pps; - return "Pollution:"+wb_link_pollution_perc+" % / "+wb_link_pollution_pps+"pps"; + function close_all_dialoques(){ + pollution_chart_view.close() + channel_scan_progress_view.close(); + change_tx_power_popup.close(); + dialoqueFreqChangeGndOnly.close(); + dialoqueFreqChangeArmed.close(); + popup_enable_stbc_ldpc.close(); } - function get_text_current_throttle(){ - if(!m_is_ground_and_air_alive){ - return ""; - } - var throttle=_ohdSystemAir.curr_n_rate_adjustments; - if(throttle<=-1)return ""; - if(throttle<=0){ - return " Throttle:None" - } - return " Throttle: -"+throttle; - } - // ------------------- PART HELPER FOR CURRENT LOSS / POLLUTION / THROTTLE END ------------------- - - function get_combobox_text_color(element_index,curr_index,frequency){ - if(frequency===_wbLinkSettingsHelper.curr_channel_mhz){ - return "green"; + function get_text_stbc_ldpc(air){ + if(air){ + if(!_ohdSystemAir.is_alive)return "N/A"; + return ""+(_ohdSystemAir.wb_stbc_enabled ? "YES" : "NO")+"/"+(_ohdSystemAir.wb_lpdc_enabled ? "YES" : "NO"); } - if(element_index===curr_index){ - // currently selected in the combobox (but not neccessarily applied in openhd) - return "blue"; - } - return "black"; - } - - function get_color_pollution(pollution){ - if(pollution<=0)return "green"; - if(pollution<=10) return "orange" - return "red"; - } - - function get_text_pollution(pollution){ - if(pollution<=-1)return ""; - if(pollution<=0)return "FREE"; - return "P:"+pollution; - } - function get_text_current_disarmed_armed(pwr_current,pwr_disarmed,pwr_armed){ - var ret= "Curr:"+pwr_current; - if(pwr_armed==0){ // Same power regardless if armed or not - ret += " Armed/Disarmed:"+pwr_disarmed; - }else{ - ret +=" Disarm:"+pwr_disarmed; - ret+=" Arm:"+pwr_armed; - - } - return ret; + if(!_ohdSystemGround.is_alive)return "N/A"; + return ""+(_ohdSystemGround.wb_stbc_enabled ? "YES" : "NO")+"/"+(_ohdSystemGround.wb_lpdc_enabled ? "YES" : "NO"); } - function get_text_tx_power(ground){ - var card= ground ? _wifi_card_gnd0 : _wifi_card_air; - //var card= _wifi_card_gnd0; - var ret = ground ? "TX PWR GND: " : "TX PWR AIR: "; - var card_type=card.card_type; - if(!card.alive){ - ret+="No info"; - return ret; - } - ret+=get_text_current_disarmed_armed(card.tx_power,card.tx_power_disarmed,card.tx_power_armed); - ret+=" "+card.tx_power_unit - return ret; + Component.onCompleted: { + close_all_dialoques(); } + // - property string m_text_warning_nosync_frequency: "WARNING: THIS CHANGES YOUR GROUND UNIT FREQUENCY WITHOUT CHANGING YOUR AIR UNIT FREQUENCY ! -Only enable if you want to quickly change your ground unit's frequency to the already set frequency of a running air unit (And know both frequency and channel width on top of your head)"; - - property string m_text_warning_nosync_chanel_width: "WARNING: THIS CHANGES YOUR GROUND UNIT CHANNEL WIDTH WITHOUT CHANGING YOUR AIR UNIT CHANNEL WIDTH ! -Only enable if you want to quickly change your ground unit's channel width to the already set channel width of a running air unit (And know both frequency and channel width on top of your head)" - - - /*property string more_info_text: "After flashing,openhd uses the same default frequency, and your air and ground unit automatically connect."+ - "If you change the frequency / channel width here, both air and ground unit are set to the new frequency."+ -"If you changed the frequency of your air unit and are using a different Ground unit, use the FIND AIR UNIT feature (channel scan) to switch to the same frequency your air unit is running on."*/ - property string more_info_text: "Here you can easily change the openhd link frequency/bandwidth of you air and ground unit."+ -"After flashing, both air and ground unit start on the same frequency and automatically connect."+ -"If you changed the frequency of your air unit and are using a different Ground unit, use the FIND AIR UNIT feature (channel scan) to switch to the same frequency your air unit is running on." - - property string find_air_unit_text:"Scan all channels for a running Air unit. Might take up to 30seconds to complete (openhd supports a ton of channels, and we need to listen on each of them for a short timespan)" - - property string analyze_channels_text: "Listen for other WIFi packets packets on each frequency for a short amount of time - a lot of foreign packets hint at a polluted channel" - - property string m_info_text_change_frequency: "Frequency in Mhz and channel number. (DFS-RADAR) - also used by commercial plane(s) weather radar (not recommended unless you have ADSB). "+ -" ! OPENHD DOESN'T HAVE ANY RESTRICTIONS ! - It is your responsibility to use channels (frequencies) allowed in your country." - - property string m_info_text_change_channel_width: "A channel width of 40Mhz (40Mhz bandwitdh) gives almost double the bandwidth (2x video bitrate/image quality), but uses 2x 20Mhz channels and therefore the likeliness of "+ -"interference from other stations sending on either of those channels is increased. It also slightly decreases sensitivity. In general, we recommend 40Mhz unless you are flying ultra long range "+ -"or in a highly polluted (urban) environment." - - property string m_info_text_change_tx_power: "Change GND / AIR TX power. Higher AIR TX power results in more range on the downlink (video,telemetry). -Higher GND TX power results in more range on the uplink (mavlink up). You can set different tx power for armed / disarmed state (requres FC), -but it is not possible to change the TX power during flight (due to the risk of misconfiguration / power outage)."+ - " ! OPENHD DOESN'T HAVE ANY RESTRICTIONS ON TX POWER - It is your responsibility to use a tx power allowed in your country. !" - - property string m_warning_text_no_gnd_unit: "GROUND not alive, settings uavailable. Please check status view." - property string m_warning_text_no_air_unit: "NO AIR UNIT - Make sure your air unit hardware is functioning properly. If you freshly flashed your air and ground unit, they use the same frequency -and automatically connect. Otherwise, use the 'FIND AIR UNIT' feature to scan all channels for your air unit." + // ------------------- PART HELPER FOR CURRENT LOSS / POLLUTION / THROTTLE BEGIN ------------------- + // ------------------- PART HELPER FOR CURRENT LOSS / POLLUTION / THROTTLE END ------------------- - property string m_warning_info_text_polluted_channel: "OpenHD is broadcast and works best on a channel free of noise and interference. A high pollution (non-openhd wifi packets) hints at"+ - " a polluted channel, but there are also non-wifi devices that can pollute a channel. You can use the 'analyze channels' feature"+ - " and/or a frequency analyzer on your phone to find the best channel for you - [149] 5745Mhz is a good bet in Europe,"+ - " since it only allows 25mW for normal wifi." // Changes either the frequency or channel width // This one need to be synced, so we have ( a bit complicated, but quite natural for the user) dialoque for the cases where we need to handle errors / show a warning @@ -301,347 +177,367 @@ and automatically connect. Otherwise, use the 'FIND AIR UNIT' feature to scan al _messageBoxInstance.set_text_and_show("Something went wrong - please use 'FIND AIR UNIT' to fix"); } - function get_text_current_frequency(){ - if(!_ohdSystemGround.is_alive)return "N/A"; - var ret=_wbLinkSettingsHelper.curr_channel_mhz+"@"+_wbLinkSettingsHelper.curr_channel_width_mhz+"Mhz"; - if(!_ohdSystemAir.is_alive)ret+=" (GND only)"; - return ret; - } - - function get_text_current_frequency_info(){ - if(!_ohdSystemGround.is_alive){ - if(_ohdSystemAir.is_alive){ - // User is connected directly to the air unit - return "Current frequency of your air unit - you can only change the frequency using / when connected to your ground station." - }else{ - return "You need to connect to your ground station to change the frequency." - } + function get_text_wifi_tx_power(air){ + if(air){ + if(!_wifi_card_air.alive) return "N/A"; + return ""+_wifi_card_air.tx_power+" "+_wifi_card_air.tx_power_unit; } - return "You can change the frequency of both your air and ground unit above - bandwidth is automatically synchronized (broadcast)."; + if(!_wifi_card_gnd0.alive) return "N/A"; + return ""+_wifi_card_gnd0.tx_power+" "+_wifi_card_gnd0.tx_power_unit; } ScrollView { - id:mavlinkExtraWBParamPanel - width: parent.width-24 - height: parent.height-24 + id: main_scroll_view + width: parent.width + height: parent.height anchors.centerIn: parent - contentHeight: mainItem.height - clip: true + contentHeight: main_column_layout.height + contentWidth: main_column_layout.width //ScrollBar.vertical.policy: ScrollBar.AlwaysOn ScrollBar.vertical.interactive: true - Item { - id: mainItem - width: parent.width - height: rowHeight*(7+4) - - Column { - id:wbParamColumn - spacing: 0 - anchors.left: parent.left - anchors.right: parent.right - - Rectangle { - width: parent.width - height: rowHeight - color: "#00000000" - RowLayout{ - anchors.verticalCenter: parent.verticalCenter - Button{ - text: "MORE INFO" - Material.background:Material.LightBlue - onClicked: { - _messageBoxInstance.set_text_and_show(more_info_text) + ColumnLayout{ + Layout.fillWidth: true + Layout.fillHeight: true + id: main_column_layout + + + Rectangle { + id: frequency_area_layout_background + color: m_background_color + implicitWidth: main_scroll_view.width + implicitHeight: frequency_area_layout.implicitHeight+5 + radius: 10 + + GridLayout { + id: frequency_area_layout + Layout.fillWidth: true + Layout.fillHeight: true + Layout.margins: 10 + + Text{ + Layout.row: 0 + Layout.column: 0 + text: "FREQUENCY / TOOLKIT" + font.bold: true + } + + ComboBox { + id: comboBoxFreq + model: supported_frequencies_model + textRole: "title" + implicitWidth: elementComboBoxWidth + currentIndex: 0 + delegate: ItemDelegate { + width: comboBoxFreq.width + contentItem: FreqComboBoxRow{ + m_main_text: title + m_selection_tpye: (value===_wbLinkSettingsHelper.curr_channel_mhz) ? 1 : 0 + m_is_2G: value < 3000 && value > 100 + m_show_radar: radar + m_openhd_race_band: openhd_raceband_nr } + highlighted: comboBoxFreq.highlightedIndex === index } - ButtonIconWarning{ - visible: !_ohdSystemGround.is_alive - onClicked: { - _messageBoxInstance.set_text_and_show(m_warning_text_no_gnd_unit) + Layout.row: 1 + Layout.column: 0 + } + Button{ + text: "APPLY" + id: buttonSwitchFreq + //enabled: false + onClicked: { + var selectedValue=supported_frequencies_model.get(comboBoxFreq.currentIndex).value + if(selectedValue<=100){ + _messageBoxInstance.set_text_and_show("Please select a valid frequency",5); + return; } + change_frequency_sync_otherwise_handle_error(selectedValue,-1,false); } - ButtonIconWarning{ - visible: _ohdSystemGround.is_alive && !_ohdSystemAir.is_alive - onClicked: { - _messageBoxInstance.set_text_and_show(m_warning_text_no_air_unit) + //Material.background: fc_is_armed() ? Material.Red : Material.Normal; + enabled: _wbLinkSettingsHelper.ui_rebuild_models>=0 && (_ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0); + Layout.row: 1 + Layout.column: 1 + } + Switch{ + Layout.row: 1 + Layout.column: 2 + text: "SIMPLIFY" + checked: true + onCheckedChanged: { + if(m_simplify_enable!=checked){ + m_simplify_enable=checked; + function_rebuild_ui(); } } - Text{ - text: get_text_current_loss() - color: warning_level_to_color(m_loss_warning_level) - } - Text{ - text: get_text_current_pollution() - color: warning_level_to_color(m_pollution_warning_level) - } - Text{ - text: get_text_current_throttle() - color: warning_level_to_color(m_throttle_warning_level) - } - ButtonIconWarning{ - visible: m_loss_warning_level>0 || m_pollution_warning_level>0 || m_throttle_warning_level>0; - onClicked: { - _messageBoxInstance.set_text_and_show(m_warning_info_text_polluted_channel) - } + } + ButtonIconInfo{ + Layout.row: 1 + Layout.column: 3 + onClicked: { + var text="SIMPLIFY: Show recommended channels only. These channels usually have the least amount of pollution by WiFi APs and most FPV antennas are tuned to those Frequncies.\n"+ + "OpenHD works best on them in most scenarios,and you can use 20Mhz and 40Mhz dynamically without issues (40Mhz spacing by default).\n"+ + "Otherwise, show all channels supported by harware (ADVANCED USERS ONLY).\n"; + _messageBoxInstance.set_text_and_show(text) } } - } - - - // Changing the wifi frequency, r.n only 5G - Rectangle { - width: parent.width - height: rowHeight - //color: (Positioner.index % 2 == 0) ? "#8cbfd7f3" : "#00000000" - color: "#8cbfd7f3" - RowLayout{ - anchors.verticalCenter: parent.verticalCenter - ButtonIconInfo{ - onClicked: { - _messageBoxInstance.set_text_and_show(m_info_text_change_frequency) - } - } - ComboBox { - id: comboBoxFreq - model: supported_frequencies_model - textRole: "title" - implicitWidth: elementComboBoxWidth - currentIndex: 0 - // Customization - // https://stackoverflow.com/questions/31411844/how-to-limit-the-size-of-drop-down-of-a-combobox-in-qml - /*style: ComboBoxStyle { - id: comboBoxStyle - - // drop-down customization here - property Component __dropDownStyle: MenuStyle { - __maxPopupHeight: Math.max(55, //min value to keep it to a functional size even if it would not look nice - Math.min(400, - //limit the max size so the menu is inside the application bounds - comboBoxStyle.control.Window.height - - mapFromItem(comboBoxStyle.control, 0,0).y - - comboBoxStyle.control.height)) - __menuItemType: "comboboxitem" //not 100% sure if this is needed - } //Component __dropDownStyle: MenuStyle - } //style: ComboBoxStyle */ - delegate: ItemDelegate { - width: comboBoxFreq.width - contentItem: FreqComboBoxRow{ - m_main_text: title - m_selection_tpye: (value===_wbLinkSettingsHelper.curr_channel_mhz) ? 1 : 0 - m_is_2G: value > 3000 - m_2G_5G_show: value > 100 - m_show_radar: radar - m_show_good_channel: recommended - m_openhd_race_band: openhd_raceband_nr + Layout.row: 2 + Layout.column: 0 + Layout.fillWidth: true + Layout.fillHeight: true + id: gnd_op_mode_status + //SimpleProgressBar{ + //} + Text{ + text: { + if(!_ohdSystemGround.is_alive)return "GND NOT ALIVE"; + if(_ohdSystemGround.wb_gnd_operating_mode==1){ + return "SCANNING"; } - highlighted: comboBoxFreq.highlightedIndex === index - } - } - Button{ - text: "APPLY FREQ" - id: buttonSwitchFreq - //enabled: false - onClicked: { - var selectedValue=supported_frequencies_model.get(comboBoxFreq.currentIndex).value - if(selectedValue<=100){ - _messageBoxInstance.set_text_and_show("Please select a valid frequency",5); - return; + if(_ohdSystemGround.wb_gnd_operating_mode==2){ + return "ANALYZING"; } - change_frequency_sync_otherwise_handle_error(selectedValue,-1,false); - } - //Material.background: fc_is_armed() ? Material.Red : Material.Normal; - enabled: _wbLinkSettingsHelper.ui_rebuild_models>=0 && _ohdSystemGround.is_alive; - } - Switch{ - text: "Simplify" - checked: true - onCheckedChanged: { - if(m_simplify_enable!=checked){ - m_simplify_enable=checked; - function_rebuild_ui(); + if(!_ohdSystemAir.is_alive){ + return _wbLinkSettingsHelper.curr_channel_mhz+"@"+"N/A"+" Mhz (NO AIR)"; } + return _wbLinkSettingsHelper.curr_channel_mhz+"@"+_wbLinkSettingsHelper.curr_channel_width_mhz+" Mhz"; } + Layout.row: 1 + Layout.column: 0 + verticalAlignment: Text.AlignVCenter } } - } - Rectangle { - width: parent.width - height: rowHeight - //color: (Positioner.index % 2 == 0) ? "#8cbfd7f3" : "#00000000" - color: "#8cbfd7f3" - - RowLayout{ - anchors.verticalCenter: parent.verticalCenter - ButtonIconInfo{ - onClicked: { - _messageBoxInstance.set_text_and_show(get_text_current_frequency_info()) + Button{ + Layout.row: 2 + Layout.column: 1 + id: b_find_air_unit + text: "SCAN" + enabled: _ohdSystemGround.is_alive + onClicked: { + close_all_dialoques(); + channel_scan_progress_view.open() + } + SequentialAnimation { + running: false + loops: 4 + id: anim_find_air_unit + // Expand the button + PropertyAnimation { + target: b_find_air_unit + property: "scale" + to: 1.5 + duration: 200 + easing.type: Easing.InOutQuad + } + // Shrink back to normal + PropertyAnimation { + target: b_find_air_unit + property: "scale" + to: 1.0 + duration: 200 + easing.type: Easing.InOutQuad } } - //FreqComboBoxRow{ - // m_main_text: _fcM - //} - Text{ - text: "Curr:"+get_text_current_frequency(); + } + Button{ + Layout.row: 2 + Layout.column: 2 + text: "ANALYZE" + enabled: _ohdSystemGround.is_alive + onClicked: { + close_all_dialoques(); + pollution_chart_view.open() } } - } - Rectangle { - width: parent.width - height: rowHeight - //color: (Positioner.index % 2 == 0) ? "#8cbfd7f3" : "#00000000" - color: "#00000000" - + ButtonIconInfo{ + Layout.row: 2 + Layout.column: 3 + onClicked: { + var text="SCAN: Scan for a running openhd air unit (required if you switch between different air / ground stations or re-flash the image.)\n"+ + "ANALYZE: Analyze all channels for WiFi pollution. If any of the default openhd channels is not polluted, they should be used."+ + "NOTE: Analogue FPV or other digital FPV systems won't show up during analyze - read the wiki for more info."; + _messageBoxInstance.set_text_and_show(text) + } + } + // Row 3 RowLayout{ - anchors.verticalCenter: parent.verticalCenter - Layout.preferredWidth: 200 - height: parent.height - ButtonIconInfo{ - onClicked: { - _messageBoxInstance.set_text_and_show(m_info_text_change_tx_power) + Layout.row: 3 + Layout.column: 0 + Layout.columnSpan: 3 + Text{ + text:{ + "LOSS %:"+_ohdSystemGround.curr_rx_packet_loss_perc } + color: _ohdSystemGround.curr_rx_packet_loss_perc > 5 ? "red" : "black" + verticalAlignment: Qt.AlignVCenter } - Button{ - text: "AIR TX PWR" - enabled: _ohdSystemAir.is_alive - onClicked: { - txPowerDialoque.open_tx_power_dialoque(false) + Text{ + text: { + return "POLLUTION pps:"+_ohdSystemGround.wb_link_curr_foreign_pps } + color: _ohdSystemGround.wb_link_curr_foreign_pps > 20 ? "red" : "black" } - Button{ - text: "GND TX PWR" - enabled: _ohdSystemGround.is_alive - onClicked: { - txPowerDialoque.open_tx_power_dialoque(true) + Text{ + text: { + return "THROTTLE:"+_ohdSystemAir.curr_n_rate_adjustments } + color: _ohdSystemAir.curr_n_rate_adjustments > 0 ? "red" : "black" } - ColumnLayout{ - Layout.fillWidth: true - Text{ - text: get_text_tx_power(false) - } - Text{ - text: get_text_tx_power(true) + ButtonIconWarning{ + visible: /*_ohdSystemAir.is_alive &&*/ (_ohdSystemGround.curr_rx_packet_loss_perc > 5 || _ohdSystemGround.wb_link_curr_foreign_pps > 20 || _ohdSystemAir.curr_n_rate_adjustments > 0) + onClicked: { + var text="On the bench, if you encounter issues like a high loss , high pollution or throttling, make sure:\n"+ + "1) You are using a channel free of noise and interference (OHD channel 1-5 are a good bet)\n"+ + "2) (RARELY,RTL8812AU only): Your TX card(s) aren't overamplifying the signal and have adequate cooling."; + _messageBoxInstance.set_text_and_show(text) } } } } - - Rectangle { - width: parent.width - height: rowHeight - //color: (Positioner.index % 2 == 0) ? "#8cbfd7f3" : "#00000000" - color: "#8cbfd7f3" - RowLayout{ - anchors.verticalCenter: parent.verticalCenter - width: parent.width - height: parent.height - RowLayout{ - ButtonIconInfo{ - onClicked: { - _messageBoxInstance.set_text_and_show(find_air_unit_text) - } - } - Button{ - id: b_find_air_unit - text: "FIND AIR UNIT" - enabled: _ohdSystemGround.is_alive - onClicked: { - dialoqueStartChannelScan.open_channel_scan_dialoque() - } - SequentialAnimation { - running: true - loops: 4 - id: anim_find_air_unit - // Expand the button - PropertyAnimation { - target: b_find_air_unit - property: "scale" - to: 1.5 - duration: 200 - easing.type: Easing.InOutQuad - } - // Shrink back to normal - PropertyAnimation { - target: b_find_air_unit - property: "scale" - to: 1.0 - duration: 200 - easing.type: Easing.InOutQuad - } - } - } + } + Rectangle { + implicitWidth: main_scroll_view.width + implicitHeight: tx_power_layout.implicitHeight + id: tx_power_layout_background + color: m_background_color + radius: 10 + + GridLayout { + id: tx_power_layout + Layout.fillWidth: true + Layout.fillHeight: true + Text{ + Layout.row: 0 + Layout.column: 0 + Layout.columnSpan: 2 + text: "TX POWER" + font.bold: true + } + Text{ + Layout.row: 1 + Layout.column: 0 + text: "AIR:\n "+get_text_wifi_tx_power(true) + } + Button{ + Layout.row: 1 + Layout.column: 1 + text: "CHANGE" + enabled: _ohdSystemAir.is_alive + onClicked: { + close_all_dialoques(); + change_tx_power_popup.m_is_air=true; + change_tx_power_popup.open() } - RowLayout{ - ButtonIconInfo{ - onClicked: { - _messageBoxInstance.set_text_and_show(analyze_channels_text) - } - } - Button{ - text: "ANALYZE" - enabled: _ohdSystemGround.is_alive - onClicked: { - dialoqueAnalyzeChannels.setup_and_show(); - } - } + } + Text{ + Layout.row: 2 + Layout.column: 0 + text: "GND:\n"+get_text_wifi_tx_power(false) + } + Button{ + Layout.row: 2 + Layout.column: 1 + text: "CHANGE" + enabled: _ohdSystemGround.is_alive + onClicked: { + close_all_dialoques(); + change_tx_power_popup.m_is_air=false; + change_tx_power_popup.open() } } - } - Rectangle { - width: parent.width - height: rowHeight - //color: (Positioner.index % 2 == 0) ? "#8cbfd7f3" : "#00000000" - //color: "#8cbfd7f3" - color: "#00000000" - - RowLayout{ - anchors.verticalCenter: parent.verticalCenter - width: parent.width - height: parent.height - - Text{ - text: _wbLinkSettingsHelper.text_for_qml - //text: "BLAAAAAAAAAAA" - height: parent.height - Layout.preferredWidth: 50 - Layout.fillWidth: true + // STBC / LDPC + Text{ + width: 200 + Layout.row: 0 + Layout.column: 3 + Layout.columnSpan: 2 + text: "ADVANCED (STBC,LDPC)" + font.bold: true + horizontalAlignment: Qt.AlignHCenter + } + Text{ + Layout.row: 1 + Layout.column: 3 + text: "AIR:\n"+get_text_stbc_ldpc(true); + horizontalAlignment: Qt.AlignHCenter + } + Text{ + Layout.row: 2 + Layout.column: 3 + text: "GND:\n"+get_text_stbc_ldpc(false); + horizontalAlignment: Qt.AlignHCenter + } + ButtonIconInfo{ + Layout.row: 1 + Layout.column: 4 + onClicked: { + _messageBoxInstance.set_text_and_show("STBC / LDPC : Greatly increases range, but requires 2 RF paths (2 Antennas) on BOTH your air and ground station."+ + "WARNING: Enabling STBC with the wrong hardware (only 1 antenna / only one rf path) results in no connectivity "+ + "and you need to re-flash your air / ground unit to recover !"); } - ProgressBar{ - from: 0 - to: 100 - value: _wbLinkSettingsHelper.gnd_progress_perc - height: parent.height - Layout.preferredWidth: 50 - Layout.fillWidth: true - Layout.rightMargin: 15 - Layout.leftMargin: 15 - //indeterminate: true + } + Button{ + Layout.row: 2 + Layout.column: 4 + text: "EDIT"; + //enabled: true + enabled: _ohdSystemAir.is_alive && _ohdSystemGround.is_alive && (_wbLinkSettingsHelper.ui_rebuild_models>=0) && + (_ohdSystemGround.wb_stbc_enabled!=true || _ohdSystemGround.wb_lpdc_enabled!=true || _ohdSystemAir.wb_stbc_enabled!=true || _ohdSystemAir.wb_lpdc_enabled!=true); + onClicked: { + popup_enable_stbc_ldpc.open() } } } - PollutionChartView{ - width: parent.width - height: rowHeight * 4; - id: pollution_chart_view - } } + // + /*Rectangle { + implicitWidth: main_scroll_view.width + implicitHeight: tx_power_layout.implicitHeight + id: rpi_cam_selector_layout_background + color: m_background_color + radius: 10 + + GridLayout { + id: rpi_cam_selector_layout + Layout.fillWidth: true + Layout.fillHeight: true + Text{ + Layout.row: 0 + Layout.column: 0 + Layout.columnSpan: 2 + text: "RPI CAM SELECTOR" + font.bold: true + } + Button{ + Layout.row: 1 + Layout.column: 0 + text: "EDIT" + } + } + }*/ } } - DIaloqueStartChannelScan{ - id: dialoqueStartChannelScan + + PopupAnalyzeChannels{ + id: pollution_chart_view + } + + PopupScanChannels{ + id: channel_scan_progress_view + } + + PopupTxPowerEditor{ + id: change_tx_power_popup + } + PopupEnableSTBCLDPC{ + id: popup_enable_stbc_ldpc } + DialoqueFreqChangeGndOnly{ id: dialoqueFreqChangeGndOnly } DialoqueFreqChangeArmed{ id: dialoqueFreqChangeArmed } - DialoqueStartAnalyzeChannels{ - id: dialoqueAnalyzeChannels - } - - DialoqueChangeTxPower{ - id: txPowerDialoque - } } diff --git a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml deleted file mode 100644 index 7a2f0617c..000000000 --- a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel2.qml +++ /dev/null @@ -1,516 +0,0 @@ -import QtQuick 2.0 - -import QtQuick 2.12 -import QtQuick.Controls 2.12 -import QtQuick.Layouts 1.12 -import QtQuick.Dialogs 1.0 -import QtQuick.Controls.Material 2.12 -import QtQuick.Controls.Styles 1.4 - -import Qt.labs.settings 1.0 - -import OpenHD 1.0 - -import "../../../ui" as Ui -import "../../elements" - -import QtCharts 2.0 - -// This is an extra screen for changing the frequency / channel width - -// They both need to match ! -Rectangle{ - id: main_background - width: parent.width - height: parent.height - //property color m_background_color: "#8cbfd7f3" - property color m_background_color: "#ADD8E6" - - property int m_small_width: 200 - - function user_quidance_animate_channel_scan(){ - console.log("User guidance animate channel scan"); - anim_find_air_unit.start() - } - - // https://stackoverflow.com/questions/41991438/how-do-i-find-a-particular-listelement-inside-a-listmodel-in-qml - // For the models above (model with value) try to find the index of the first item where model[i].value===value - function find_index(model,value){ - for(var i = 0; i < model.count; ++i) if (model.get(i).value===value) return i - return -1 - } - // try and update the combobox to the retrieved value(value != index) - function update_combobox(_combobox,_value){ - var _index=find_index(_combobox.model,_value) - if(_index >= 0){ - _combobox.currentIndex=_index; - } - } - - function fc_is_armed(){ - return _fcMavlinkSystem.armed - } - - ListModel{ - id: supported_frequencies_model - ListElement {title: "Unknown"; value:-1; radar: false; recommended: false; openhd_raceband_nr: -1} - } - - function show_popup_message(message){ - _messageBoxInstance.set_text_and_show(message) - } - - property bool m_simplify_enable:true - function create_list_model_supported(){ - supported_frequencies_model.clear() - //supported_frequencies_model.append({title: "Unknown", value: -1}) - const supported_frequencies=_wbLinkSettingsHelper.get_supported_frequencies(); - for(var i=0;i= 0; - }else{ - append_this_value=true; - } - if(append_this_value){ - supported_frequencies_model.append({title: text, value: frequency, radar:radar, recommended: recommended, openhd_raceband_nr: openhd_raceband}) - } - } - var index=find_index(supported_frequencies_model,_wbLinkSettingsHelper.curr_channel_mhz); - comboBoxFreq.model=supported_frequencies_model - if(index>=0){ - comboBoxFreq.currentIndex=index; - }else{ - comboBoxFreq.currentIndex=0; - console.log("Seems not to be a valid channel "+_wbLinkSettingsHelper.curr_channel_mhz) - } - } - - // We get notified every time we should re-build the model(s) and their current selection - property int m_ui_rebuild_models : _wbLinkSettingsHelper.ui_rebuild_models - onM_ui_rebuild_modelsChanged: { - console.log(" onM_ui_rebuild_modelsChanged: "+_wbLinkSettingsHelper.ui_rebuild_models); - function_rebuild_ui() - } - - function function_rebuild_ui(){ - console.log("function_rebuild_ui:"+_wbLinkSettingsHelper.ui_rebuild_models); - if(_wbLinkSettingsHelper.ui_rebuild_models<=0)return - create_list_model_supported(); - //update_pollution_graph(); - pollution_chart_view.update(); - } - - // - function close_all_dialoques(){ - pollution_chart_view.close() - channel_scan_progress_view.close(); - change_tx_power_popup.close(); - dialoqueFreqChangeGndOnly.close(); - dialoqueFreqChangeArmed.close(); - popup_enable_stbc_ldpc.close(); - } - - function get_text_stbc_ldpc(air){ - if(air){ - if(!_ohdSystemAir.is_alive)return "N/A"; - return ""+(_ohdSystemAir.wb_stbc_enabled ? "YES" : "NO")+"/"+(_ohdSystemAir.wb_lpdc_enabled ? "YES" : "NO"); - } - if(!_ohdSystemGround.is_alive)return "N/A"; - return ""+(_ohdSystemGround.wb_stbc_enabled ? "YES" : "NO")+"/"+(_ohdSystemGround.wb_lpdc_enabled ? "YES" : "NO"); - } - - Component.onCompleted: { - close_all_dialoques(); - } - // - - // ------------------- PART HELPER FOR CURRENT LOSS / POLLUTION / THROTTLE BEGIN ------------------- - // ------------------- PART HELPER FOR CURRENT LOSS / POLLUTION / THROTTLE END ------------------- - - - // Changes either the frequency or channel width - // This one need to be synced, so we have ( a bit complicated, but quite natural for the user) dialoque for the cases where we need to handle errors / show a warning - function change_frequency_sync_otherwise_handle_error(frequency_mhz,ignore_armed_state){ - console.log("change_frequency_sync_otherwise_handle_error: "+"FREQ:"+frequency_mhz+"Mhz"); - // Ground needs to be alive and well - if(!_ohdSystemGround.is_alive){ - _messageBoxInstance.set_text_and_show("Ground unit not alive",5); - return; - } - // Air needs to be alive and well - otherwise we show the "do you want to change gnd only" dialoque - if(!_ohdSystemAir.is_alive){ - var error_message_not_alive="AIR Unit not alive -" - dialoqueFreqChangeGndOnly.initialize_and_show_frequency(frequency_mhz,error_message_not_alive); - return; - } - // FC needs to be disarmed - otherwise show warning - const fc_currently_armed = (_fcMavlinkSystem.is_alive && _fcMavlinkSystem.armed)// || true; - if(fc_currently_armed && ignore_armed_state===false){ - dialoqueFreqChangeArmed.initialize_and_show_frequency(frequency_mhz) - return; - } - var result= _wbLinkSettingsHelper.change_param_air_and_ground_frequency(frequency_mhz); - if(result==0){ - var message="Succesfully set air and ground to FREQUENCY: "+frequency_mhz+"Mhz"; - _messageBoxInstance.set_text_and_show(message,5); - return; - }else if(result==-1){ - // Air unit rejected - _messageBoxInstance.set_text_and_show("Air unit does not support this value",5); - return; - }else if(result==-2){ - // Couldn't reach air unit - var error_message_not_reachable="Couldn't reach air unit -" - dialoqueFreqChangeGndOnly.initialize_and_show_frequency(frequency_mhz,error_message_not_reachable); - return; - } - // Really really bad - _messageBoxInstance.set_text_and_show("Something went wrong - please use 'FIND AIR UNIT' to fix"); - } - - function get_text_wifi_tx_power(air){ - if(air){ - if(!_wifi_card_air.alive) return "N/A"; - return ""+_wifi_card_air.tx_power+" "+_wifi_card_air.tx_power_unit; - } - if(!_wifi_card_gnd0.alive) return "N/A"; - return ""+_wifi_card_gnd0.tx_power+" "+_wifi_card_gnd0.tx_power_unit; - } - - ScrollView { - id: main_scroll_view - width: parent.width - height: parent.height - anchors.centerIn: parent - contentHeight: main_column_layout.height - contentWidth: main_column_layout.width - //ScrollBar.vertical.policy: ScrollBar.AlwaysOn - ScrollBar.vertical.interactive: true - - ColumnLayout{ - Layout.fillWidth: true - Layout.fillHeight: true - id: main_column_layout - - - Rectangle { - id: frequency_area_layout_background - color: m_background_color - implicitWidth: main_scroll_view.width - implicitHeight: frequency_area_layout.implicitHeight+5 - radius: 10 - - GridLayout { - id: frequency_area_layout - Layout.fillWidth: true - Layout.fillHeight: true - Layout.margins: 10 - - Text{ - Layout.row: 0 - Layout.column: 0 - text: "FREQUENCY / TOOLKIT" - font.bold: true - } - - ComboBox { - id: comboBoxFreq - model: supported_frequencies_model - textRole: "title" - implicitWidth: elementComboBoxWidth - currentIndex: 0 - delegate: ItemDelegate { - width: comboBoxFreq.width - contentItem: FreqComboBoxRow{ - m_main_text: title - m_selection_tpye: (value===_wbLinkSettingsHelper.curr_channel_mhz) ? 1 : 0 - m_is_2G: value < 3000 && value > 100 - m_show_radar: radar - m_openhd_race_band: openhd_raceband_nr - } - highlighted: comboBoxFreq.highlightedIndex === index - } - Layout.row: 1 - Layout.column: 0 - } - Button{ - text: "APPLY" - id: buttonSwitchFreq - //enabled: false - onClicked: { - var selectedValue=supported_frequencies_model.get(comboBoxFreq.currentIndex).value - if(selectedValue<=100){ - _messageBoxInstance.set_text_and_show("Please select a valid frequency",5); - return; - } - change_frequency_sync_otherwise_handle_error(selectedValue,-1,false); - } - //Material.background: fc_is_armed() ? Material.Red : Material.Normal; - enabled: _wbLinkSettingsHelper.ui_rebuild_models>=0 && (_ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0); - Layout.row: 1 - Layout.column: 1 - } - Switch{ - Layout.row: 1 - Layout.column: 2 - text: "SIMPLIFY" - checked: true - onCheckedChanged: { - if(m_simplify_enable!=checked){ - m_simplify_enable=checked; - function_rebuild_ui(); - } - } - } - ButtonIconInfo{ - Layout.row: 1 - Layout.column: 3 - onClicked: { - var text="SIMPLIFY: Show recommended channels only. These channels usually have the least amount of pollution by WiFi APs and most FPV antennas are tuned to those Frequncies.\n"+ - "OpenHD works best on them in most scenarios,and you can use 20Mhz and 40Mhz dynamically without issues (40Mhz spacing by default).\n"+ - "Otherwise, show all channels supported by harware (ADVANCED USERS ONLY).\n"; - _messageBoxInstance.set_text_and_show(text) - } - } - RowLayout{ - Layout.row: 2 - Layout.column: 0 - Layout.fillWidth: true - Layout.fillHeight: true - id: gnd_op_mode_status - //SimpleProgressBar{ - //} - Text{ - text: { - if(!_ohdSystemGround.is_alive)return "GND NOT ALIVE"; - if(_ohdSystemGround.wb_gnd_operating_mode==1){ - return "SCANNING"; - } - if(_ohdSystemGround.wb_gnd_operating_mode==2){ - return "ANALYZING"; - } - if(!_ohdSystemAir.is_alive){ - return _wbLinkSettingsHelper.curr_channel_mhz+"@"+"N/A"+" Mhz (NO AIR)"; - } - return _wbLinkSettingsHelper.curr_channel_mhz+"@"+_wbLinkSettingsHelper.curr_channel_width_mhz+" Mhz"; - } - Layout.row: 1 - Layout.column: 0 - verticalAlignment: Text.AlignVCenter - } - } - Button{ - Layout.row: 2 - Layout.column: 1 - id: b_find_air_unit - text: "SCAN" - enabled: _ohdSystemGround.is_alive - onClicked: { - close_all_dialoques(); - channel_scan_progress_view.open() - } - SequentialAnimation { - running: false - loops: 4 - id: anim_find_air_unit - // Expand the button - PropertyAnimation { - target: b_find_air_unit - property: "scale" - to: 1.5 - duration: 200 - easing.type: Easing.InOutQuad - } - // Shrink back to normal - PropertyAnimation { - target: b_find_air_unit - property: "scale" - to: 1.0 - duration: 200 - easing.type: Easing.InOutQuad - } - } - } - Button{ - Layout.row: 2 - Layout.column: 2 - text: "ANALYZE" - enabled: _ohdSystemGround.is_alive - onClicked: { - close_all_dialoques(); - pollution_chart_view.open() - } - } - ButtonIconInfo{ - Layout.row: 2 - Layout.column: 3 - onClicked: { - var text="SCAN: Scan for a running openhd air unit (required if you switch between different air / ground stations or re-flash the image.)\n"+ - "ANALYZE: Analyze all channels for WiFi pollution. If any of the default openhd channels is not polluted, they should be used."+ - "NOTE: Analogue FPV or other digital FPV systems won't show up during analyze - read the wiki for more info."; - _messageBoxInstance.set_text_and_show(text) - } - } - // Row 3 - RowLayout{ - Layout.row: 3 - Layout.column: 0 - Layout.columnSpan: 3 - Text{ - text:{ - "LOSS %:"+_ohdSystemGround.curr_rx_packet_loss_perc - } - color: _ohdSystemGround.curr_rx_packet_loss_perc > 5 ? "red" : "black" - verticalAlignment: Qt.AlignVCenter - } - Text{ - text: { - return "POLLUTION pps:"+_ohdSystemGround.wb_link_curr_foreign_pps - } - color: _ohdSystemGround.wb_link_curr_foreign_pps > 20 ? "red" : "black" - } - Text{ - text: { - return "THROTTLE:"+_ohdSystemAir.curr_n_rate_adjustments - } - color: _ohdSystemAir.curr_n_rate_adjustments > 0 ? "red" : "black" - } - ButtonIconWarning{ - visible: /*_ohdSystemAir.is_alive &&*/ (_ohdSystemGround.curr_rx_packet_loss_perc > 5 || _ohdSystemGround.wb_link_curr_foreign_pps > 20 || _ohdSystemAir.curr_n_rate_adjustments > 0) - onClicked: { - var text="On the bench, if you encounter issues like a high loss , high pollution or throttling, make sure:\n"+ - "1) You are using a channel free of noise and interference (OHD channel 1-5 are a good bet)\n"+ - "2) (RARELY,RTL8812AU only): Your TX card(s) aren't overamplifying the signal and have adequate cooling."; - _messageBoxInstance.set_text_and_show(text) - } - } - } - } - } - Rectangle { - implicitWidth: main_scroll_view.width - implicitHeight: tx_power_layout.implicitHeight - id: tx_power_layout_background - color: m_background_color - radius: 10 - - GridLayout { - id: tx_power_layout - Layout.fillWidth: true - Layout.fillHeight: true - Text{ - Layout.row: 0 - Layout.column: 0 - Layout.columnSpan: 2 - text: "TX POWER" - font.bold: true - } - Text{ - Layout.row: 1 - Layout.column: 0 - text: "AIR:\n "+get_text_wifi_tx_power(true) - } - Button{ - Layout.row: 1 - Layout.column: 1 - text: "CHANGE" - enabled: _ohdSystemAir.is_alive - onClicked: { - close_all_dialoques(); - change_tx_power_popup.m_is_air=true; - change_tx_power_popup.open() - } - } - Text{ - Layout.row: 2 - Layout.column: 0 - text: "GND:\n"+get_text_wifi_tx_power(false) - } - Button{ - Layout.row: 2 - Layout.column: 1 - text: "CHANGE" - enabled: _ohdSystemGround.is_alive - onClicked: { - close_all_dialoques(); - change_tx_power_popup.m_is_air=false; - change_tx_power_popup.open() - } - } - // STBC / LDPC - Text{ - width: 200 - Layout.row: 0 - Layout.column: 3 - Layout.columnSpan: 2 - text: "ADVANCED (STBC,LDPC)" - font.bold: true - horizontalAlignment: Qt.AlignHCenter - } - Text{ - Layout.row: 1 - Layout.column: 3 - text: "AIR:\n"+get_text_stbc_ldpc(true); - horizontalAlignment: Qt.AlignHCenter - } - Text{ - Layout.row: 2 - Layout.column: 3 - text: "GND:\n"+get_text_stbc_ldpc(false); - horizontalAlignment: Qt.AlignHCenter - } - ButtonIconInfo{ - Layout.row: 1 - Layout.column: 4 - onClicked: { - _messageBoxInstance.set_text_and_show("STBC / LDPC : Greatly increases range, but requires 2 RF paths (2 Antennas) on BOTH your air and ground station."+ - "WARNING: Enabling STBC with the wrong hardware (only 1 antenna / only one rf path) results in no connectivity "+ - "and you need to re-flash your air / ground unit to recover !"); - } - } - Button{ - Layout.row: 2 - Layout.column: 4 - text: "EDIT"; - //enabled: true - enabled: _ohdSystemAir.is_alive && _ohdSystemGround.is_alive && (_wbLinkSettingsHelper.ui_rebuild_models>=0) && - (_ohdSystemGround.wb_stbc_enabled!=true || _ohdSystemGround.wb_lpdc_enabled!=true || _ohdSystemAir.wb_stbc_enabled!=true || _ohdSystemAir.wb_lpdc_enabled!=true); - onClicked: { - popup_enable_stbc_ldpc.open() - } - } - } - } - } - } - - PopupAnalyzeChannels{ - id: pollution_chart_view - } - - PopupScanChannels{ - id: channel_scan_progress_view - } - - PopupTxPowerEditor{ - id: change_tx_power_popup - } - PopupEnableSTBCLDPC{ - id: popup_enable_stbc_ldpc - } - - DialoqueFreqChangeGndOnly{ - id: dialoqueFreqChangeGndOnly - } - DialoqueFreqChangeArmed{ - id: dialoqueFreqChangeArmed - } -} diff --git a/qml/ui/configpopup/qopenhd_settings/AppGeneralSettingsView.qml b/qml/ui/configpopup/qopenhd_settings/AppGeneralSettingsView.qml index fd157118d..89a963cba 100755 --- a/qml/ui/configpopup/qopenhd_settings/AppGeneralSettingsView.qml +++ b/qml/ui/configpopup/qopenhd_settings/AppGeneralSettingsView.qml @@ -29,33 +29,6 @@ ScrollView { anchors.left: parent.left anchors.right: parent.right - SettingBaseElement{ - m_short_description: "Mavlink sys id" - m_long_description: "Mavlink sys id of QOpenHD (this Ground control station application). Leave default (255) ! . Change requires restart." - - SpinBox { - id: mavlinkSysIDSpinBox - height: elementHeight - width: 210 - font.pixelSize: 14 - anchors.right: parent.right - anchors.verticalCenter: parent.verticalCenter - from: 1 - to: 255 - stepSize: 1 - anchors.rightMargin: Qt.inputMethod.visible ? 78 : 18 - - value: settings.qopenhd_mavlink_sysid - onValueChanged: { - if(value==100 || value==101){ - // openhd air and ground unit sys id are hard coded, one should never use them - _messageBoxInstance.set_text_and_show("Do not use 100 or 101 for QOpenHD sys id") - } - settings.qopenhd_mavlink_sysid = value - } - } - } - SettingBaseElement{ m_short_description: "Enable speech" m_long_description: "Enable text to speech - events like flight mode change are given as audio messages" @@ -204,6 +177,32 @@ ScrollView { } } } + SettingBaseElement{ + m_short_description: "Mavlink sys id" + m_long_description: "Mavlink sys id of QOpenHD (this Ground control station application). Leave default (255) ! . Change requires restart." + + SpinBox { + id: mavlinkSysIDSpinBox + height: elementHeight + width: 210 + font.pixelSize: 14 + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + from: 1 + to: 255 + stepSize: 1 + anchors.rightMargin: Qt.inputMethod.visible ? 78 : 18 + + value: settings.qopenhd_mavlink_sysid + onValueChanged: { + if(value==100 || value==101){ + // openhd air and ground unit sys id are hard coded, one should never use them + _messageBoxInstance.set_text_and_show("Do not use 100 or 101 for QOpenHD sys id") + } + settings.qopenhd_mavlink_sysid = value + } + } + } SettingBaseElement{ m_short_description: "Hide identity offset lattitude" m_long_description: "Set this to a random value only you know to hide lat identity" diff --git a/qml/ui/configpopup/status/PanelStatus.qml b/qml/ui/configpopup/status/PanelStatus.qml index edc95f991..45fbd54f3 100644 --- a/qml/ui/configpopup/status/PanelStatus.qml +++ b/qml/ui/configpopup/status/PanelStatus.qml @@ -52,15 +52,16 @@ Rectangle { // The 3 status cards (OpenHD AIR & GND, FC) // next to each other - StatusCardsColumn2{ + StatusCardsColumn{ id: statuscardscolumn width: parent.width height: 350 - anchors.leftMargin: 12 - anchors.rightMargin: 12 - anchors.topMargin: 12 + anchors.leftMargin: 4 + anchors.topMargin: 4 + + anchors.left: parent.left anchors.top: qopenhdversioncard.bottom } diff --git a/qml/ui/configpopup/status/StatusCardsColumn.qml b/qml/ui/configpopup/status/StatusCardsColumn.qml index 4468c360c..3513dbda2 100644 --- a/qml/ui/configpopup/status/StatusCardsColumn.qml +++ b/qml/ui/configpopup/status/StatusCardsColumn.qml @@ -13,96 +13,64 @@ import "../../elements" // // The 3 status cards (OpenHD AIR & GND, FC) // next to each other -Item{ +RowLayout{ width: parent.width height: parent.height - property int m_padding_between: 4 + property int m_card_width: parent.width/3; + property int m_card_height: 350 - property int m_card_width: parent.width/3 - (m_padding_between) - - Rectangle{ - id: background1 + Card { width: m_card_width - height: parent.height - anchors.left: parent.left - anchors.leftMargin: m_padding_between - color: "red" - // - Card { - width: parent.width - height:parent.height - id: groundBox - cardName: qsTr("Ground station") + height:m_card_height + id: groundBox + cardName: qsTr("Ground station") - //visible: _ohdSystemGround.is_alive - m_style_error: !_ohdSystemGround.is_alive + //visible: _ohdSystemGround.is_alive + m_style_error: !_ohdSystemGround.is_alive - cardBody: StatusCardBodyOpenHD{ - m_is_ground: true - } + cardBody: StatusCardBodyOpenHD{ + m_is_ground: true + } - hasFooter: true - cardFooter: FooterRebootShutdownWarning{ - m_type: 0 - } + hasFooter: true + cardFooter: FooterRebootShutdownWarning{ + m_type: 0 } } - - Rectangle{ - id: background2 + Card { width: m_card_width - height: parent.height - anchors.left: background1.right - anchors.leftMargin: m_padding_between - color: "green" - // - Card { - width: parent.width - height:parent.height - id: airBox - cardName: qsTr("Air unit") - //visible: _ohdSystemAir.is_alive - m_style_error: !_ohdSystemAir.is_alive - - cardBody: StatusCardBodyOpenHD{ - m_is_ground: false - } - - hasFooter: true - cardFooter: FooterRebootShutdownWarning{ - m_type: 1 - } + height:m_card_height + id: airBox + cardName: qsTr("Air unit") + //visible: _ohdSystemAir.is_alive + m_style_error: !_ohdSystemAir.is_alive + + cardBody: StatusCardBodyOpenHD{ + m_is_ground: false } + hasFooter: true + cardFooter: FooterRebootShutdownWarning{ + m_type: 1 + } } - Rectangle{ - id: background3 + Card { width: m_card_width - height: parent.height - anchors.rightMargin: m_padding_between - anchors.leftMargin: m_padding_between - anchors.right: parent.right - anchors.left: background2.right - color: "orange" - Card { - width: parent.width - height:parent.height - id: fcBox - cardName: qsTr("Flight Controller") - //visible: _fcMavlinkSystem.is_alive - m_style_error: !_fcMavlinkSystem.is_alive - cardBody: StatusCardBodyFC{ + height:m_card_height + id: fcBox + cardName: qsTr("Flight Controller") + //visible: _fcMavlinkSystem.is_alive + m_style_error: !_fcMavlinkSystem.is_alive + cardBody: StatusCardBodyFC{ - } + } - hasFooter: true - cardFooter: FooterRebootShutdownWarning{ - m_type: 2 - } + hasFooter: true + cardFooter: FooterRebootShutdownWarning{ + m_type: 2 } } - } diff --git a/qml/ui/configpopup/status/StatusCardsColumn2.qml b/qml/ui/configpopup/status/StatusCardsColumn2.qml deleted file mode 100644 index 04bc3dac6..000000000 --- a/qml/ui/configpopup/status/StatusCardsColumn2.qml +++ /dev/null @@ -1,79 +0,0 @@ -import QtQuick 2.12 -import QtQuick.Controls 2.12 -import QtQuick.Layouts 1.12 -import QtQuick.Controls.Material 2.12 - -import Qt.labs.settings 1.0 - -import OpenHD 1.0 - -import "../../../ui" as Ui -import "../../elements" - -// -// The 3 status cards (OpenHD AIR & GND, FC) -// next to each other -RowLayout{ - width: parent.width - height: parent.height - - property int m_padding_between: 4 - - property int m_card_width: parent.width/3 - (m_padding_between) - - Card { - width: parent.width /3 - height:parent.height - id: groundBox - cardName: qsTr("Ground station") - - //visible: _ohdSystemGround.is_alive - m_style_error: !_ohdSystemGround.is_alive - - cardBody: StatusCardBodyOpenHD{ - m_is_ground: true - } - - hasFooter: true - cardFooter: FooterRebootShutdownWarning{ - m_type: 0 - } - } - Card { - width: parent.width /3 - height:parent.height - id: airBox - cardName: qsTr("Air unit") - //visible: _ohdSystemAir.is_alive - m_style_error: !_ohdSystemAir.is_alive - - cardBody: StatusCardBodyOpenHD{ - m_is_ground: false - } - - hasFooter: true - cardFooter: FooterRebootShutdownWarning{ - m_type: 1 - } - } - - Card { - width: parent.width /3 - height:parent.height - id: fcBox - cardName: qsTr("Flight Controller") - //visible: _fcMavlinkSystem.is_alive - m_style_error: !_fcMavlinkSystem.is_alive - cardBody: StatusCardBodyFC{ - - } - - hasFooter: true - cardFooter: FooterRebootShutdownWarning{ - m_type: 2 - } - } - - -} - diff --git a/qml/ui/widgets/WBLinkRateControlWidget.qml b/qml/ui/widgets/WBLinkRateControlWidget.qml index c771e4f08..8c785068b 100644 --- a/qml/ui/widgets/WBLinkRateControlWidget.qml +++ b/qml/ui/widgets/WBLinkRateControlWidget.qml @@ -487,10 +487,10 @@ Make the video more stable (less microfreezes) on the cost of less image quality Button{ text: "DESERT" onClicked: { - set_keyframe_interval(8) + set_keyframe_interval(5) set_fec_percentage(10) } - highlighted: m_curr_keyframe_i == 8 && m_curr_fec_perc==10 + highlighted: m_curr_keyframe_i == 5 && m_curr_fec_perc==10 } } } From 41b571c30c3981b7653839d9f9b599d7f35b9f86 Mon Sep 17 00:00:00 2001 From: consti10 Date: Fri, 27 Oct 2023 16:04:29 +0200 Subject: [PATCH 24/81] terminate properly --- app/telemetry/MavlinkTelemetry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/telemetry/MavlinkTelemetry.cpp b/app/telemetry/MavlinkTelemetry.cpp index f3c5267d7..c656f5f6c 100644 --- a/app/telemetry/MavlinkTelemetry.cpp +++ b/app/telemetry/MavlinkTelemetry.cpp @@ -285,7 +285,7 @@ bool MavlinkTelemetry::change_manual_tcp_ip(QString ip) void MavlinkTelemetry::send_heartbeat_loop() { - while(true){ + while(m_heartbeat_thread_run){ //qDebug()<<"send_heartbeat_loop"; std::this_thread::sleep_for(std::chrono::milliseconds(1000)); perform_connection_management(); From e64c397d8268842e3f6bf95c3c4d3036981f5367 Mon Sep 17 00:00:00 2001 From: consti10 Date: Sat, 28 Oct 2023 13:48:30 +0200 Subject: [PATCH 25/81] fix the dialogues --- .../configpopup/connect/PaneConnectionMode.qml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/qml/ui/configpopup/connect/PaneConnectionMode.qml b/qml/ui/configpopup/connect/PaneConnectionMode.qml index f05786825..6bf06c9ab 100644 --- a/qml/ui/configpopup/connect/PaneConnectionMode.qml +++ b/qml/ui/configpopup/connect/PaneConnectionMode.qml @@ -98,7 +98,13 @@ Rectangle{ Button{ text: "Android Tethering" Layout.preferredWidth: 180 - onClicked: _qopenhd.android_open_tethering_settings() + onClicked: { + if(_qopenhd.is_android()){ + _qopenhd.android_open_tethering_settings() + }else{ + _qopenhd.show_toast("Only available on android"); + } + } } ButtonIconInfoText { m_info_text: "1) Connect your phone via high quality USB cable to your ground station.\n\n"+ @@ -112,6 +118,9 @@ Rectangle{ text: "Wifi tethering" Layout.preferredWidth: 180 //TODO enable hotspot + onClicked: { + _messageBoxInstance.set_text_and_show("Please connect:\nWiFi Name: openhd_air/openhd_ground.\n PW: openhdopenhd") + } } ButtonIconInfoText { m_info_text: "1) Check status if your air / ground unit supports WiFi hotspot\n\n"+ @@ -125,6 +134,9 @@ Rectangle{ text: "Passive Eth tethering" Layout.preferredWidth: 180 //TODO disable active tethering and enable passive when clicking the button + onClicked: { + _qopenhd.show_toast("Please read info"); + } } ButtonIconInfoText { m_info_text: "1) Disable ETH_HOTSPOT_E and Enable ETH_PASSIVE_F\n\n"+ @@ -138,6 +150,9 @@ Rectangle{ text: "Active Eth tethering" Layout.preferredWidth: 180 //TODO disable passive tethering and enable active when clicking the button + onClicked: { + _qopenhd.show_toast("Please read info"); + } } ButtonIconInfoText { m_info_text: "1) Disable ETH_PASSIVE_F and Enable ETH_HOTSPOT_E\n\n"+ From 6a3a079280991db1311f2a7274d5eb2167834195 Mon Sep 17 00:00:00 2001 From: consti10 Date: Mon, 30 Oct 2023 11:55:41 +0100 Subject: [PATCH 26/81] add per QQuickPaintedItem font scale --- app/osd/altitudeladder.cpp | 11 +++++- app/osd/altitudeladder.h | 8 +++- app/osd/aoagauge.h | 1 - app/osd/debug_overdraw.hpp | 1 + app/osd/flightpathvector.h | 1 - app/osd/headingladder.cpp | 11 +++++- app/osd/headingladder.h | 9 +++-- app/osd/horizonladder.cpp | 12 +++++- app/osd/horizonladder.h | 6 ++- app/osd/speedladder.cpp | 11 +++++- app/osd/speedladder.h | 8 ++-- qml/ui/HUDOverlayGrid.qml | 2 + qml/ui/elements/OSDCustomizer.qml | 18 +++++++-- qml/ui/widgets/AltitudeWidget.qml | 4 +- qml/ui/widgets/BaseWidget.qml | 37 +++++++++++++------ .../BaseWidgetDefaultUiControlElements.qml | 32 ++++++++++++++++ qml/ui/widgets/HeadingWidget.qml | 2 + qml/ui/widgets/HorizonWidget.qml | 2 + qml/ui/widgets/SpeedWidget.qml | 2 + 19 files changed, 146 insertions(+), 32 deletions(-) diff --git a/app/osd/altitudeladder.cpp b/app/osd/altitudeladder.cpp index c6cf59981..70ada7789 100644 --- a/app/osd/altitudeladder.cpp +++ b/app/osd/altitudeladder.cpp @@ -7,6 +7,8 @@ #include "debug_overdraw.hpp" +static constexpr int DEFAULT_FONT_PIXEL_SIZE=11; + AltitudeLadder::AltitudeLadder(QQuickItem *parent): QQuickPaintedItem(parent) { qDebug() << "AltitudeLadder::AltitudeLadder()"; setRenderTarget(RenderTarget::FramebufferObject); @@ -119,6 +121,13 @@ void AltitudeLadder::setAltitudeRange(int altitudeRange) { void AltitudeLadder::setFontFamily(QString fontFamily) { m_fontFamily = fontFamily; emit fontFamilyChanged(m_fontFamily); - m_font = QFont(m_fontFamily, 13, QFont::Bold, false); + m_font = QFont(m_fontFamily, DEFAULT_FONT_PIXEL_SIZE*m_custom_font_scale, QFont::Bold, false); + update(); +} + +void AltitudeLadder::set_custom_font_scale(double custom_font_scale) +{ + m_custom_font_scale=custom_font_scale; + m_font.setPointSize(DEFAULT_FONT_PIXEL_SIZE*m_custom_font_scale); update(); } diff --git a/app/osd/altitudeladder.h b/app/osd/altitudeladder.h index 74ba3e764..0b5c6ea6e 100644 --- a/app/osd/altitudeladder.h +++ b/app/osd/altitudeladder.h @@ -2,6 +2,8 @@ #include #include +#include "../../../lib/lqtutils_master/lqtutils_prop.h" + class AltitudeLadder : public QQuickPaintedItem { Q_OBJECT Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) @@ -10,7 +12,8 @@ class AltitudeLadder : public QQuickPaintedItem { // actual altitude, unit - less Q_PROPERTY(int altitude MEMBER m_altitude WRITE set_altitude NOTIFY altitude_changed) Q_PROPERTY(QString fontFamily MEMBER m_fontFamily WRITE setFontFamily NOTIFY fontFamilyChanged) - +public: + Q_PROPERTY(double custom_font_scale WRITE set_custom_font_scale) public: explicit AltitudeLadder(QQuickItem* parent = nullptr); @@ -25,6 +28,7 @@ public slots: void setAltitudeRange(int altitudeRange); void set_altitude(double alt); void setFontFamily(QString fontFamily); + void set_custom_font_scale(double custom_font_scale); signals: void colorChanged(QColor color); void glowChanged(QColor glow); @@ -43,4 +47,6 @@ public slots: QString m_fontFamily; QFont m_font; + double m_custom_font_scale=1.0; + }; diff --git a/app/osd/aoagauge.h b/app/osd/aoagauge.h index b9730a7ee..6d1dfb276 100644 --- a/app/osd/aoagauge.h +++ b/app/osd/aoagauge.h @@ -2,7 +2,6 @@ #include #include - class AoaGauge : public QQuickPaintedItem { Q_OBJECT Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) diff --git a/app/osd/debug_overdraw.hpp b/app/osd/debug_overdraw.hpp index 0a3e573b3..d568a71cb 100644 --- a/app/osd/debug_overdraw.hpp +++ b/app/osd/debug_overdraw.hpp @@ -4,4 +4,5 @@ // Such that we can enable / disable the "overdraw debugging" with just a single variable change static constexpr bool ENABLE_DEBUG_OVERDRAW=false; + #endif // DEBUG_OVERDRAW_HPP diff --git a/app/osd/flightpathvector.h b/app/osd/flightpathvector.h index 9f5c97442..e262dabe1 100644 --- a/app/osd/flightpathvector.h +++ b/app/osd/flightpathvector.h @@ -2,7 +2,6 @@ #include #include - class FlightPathVector : public QQuickPaintedItem { Q_OBJECT Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) diff --git a/app/osd/headingladder.cpp b/app/osd/headingladder.cpp index 268fb8476..3e89b97e9 100644 --- a/app/osd/headingladder.cpp +++ b/app/osd/headingladder.cpp @@ -6,6 +6,8 @@ #include "debug_overdraw.hpp" +static constexpr int DEFAULT_FONT_PIXEL_SIZE=11; + HeadingLadder::HeadingLadder(QQuickItem *parent): QQuickPaintedItem(parent) { qDebug() << "HeadingLadder::HeadingLadder()"; setRenderTarget(RenderTarget::FramebufferObject); @@ -235,6 +237,13 @@ void HeadingLadder::setHomeHeading(int homeHeading) { void HeadingLadder::setFontFamily(QString fontFamily) { m_fontFamily = fontFamily; emit fontFamilyChanged(m_fontFamily); - m_font = QFont(m_fontFamily, 11, QFont::Bold, false); + m_font = QFont(m_fontFamily, DEFAULT_FONT_PIXEL_SIZE*m_custom_font_scale, QFont::Bold, false); + update(); +} + +void HeadingLadder::set_custom_font_scale(double custom_font_scale) +{ + m_custom_font_scale=custom_font_scale; + m_font.setPointSize(DEFAULT_FONT_PIXEL_SIZE*m_custom_font_scale); update(); } diff --git a/app/osd/headingladder.h b/app/osd/headingladder.h index b9be2d6f2..341b3ff0a 100644 --- a/app/osd/headingladder.h +++ b/app/osd/headingladder.h @@ -2,6 +2,8 @@ #include #include +#include "../../../lib/lqtutils_master/lqtutils_prop.h" + class HeadingLadder : public QQuickPaintedItem { Q_OBJECT Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) @@ -16,8 +18,8 @@ class HeadingLadder : public QQuickPaintedItem { Q_PROPERTY(QString fontFamily MEMBER m_fontFamily WRITE setFontFamily NOTIFY fontFamilyChanged) - -//show_horizon_heading_ladder +public: + Q_PROPERTY(double custom_font_scale WRITE set_custom_font_scale) public: explicit HeadingLadder(QQuickItem* parent = nullptr); @@ -39,7 +41,7 @@ public slots: void setHomeHeading(int homeHeading); void setFontFamily(QString fontFamily); - + void set_custom_font_scale(double custom_font_scale); signals: void colorChanged(QColor color); void glowChanged(QColor glow); @@ -69,4 +71,5 @@ public slots: QFont m_font; QFont m_fontAwesome = QFont("Font Awesome 5 Free", 14, QFont::Bold, false); + double m_custom_font_scale=1.0; }; diff --git a/app/osd/horizonladder.cpp b/app/osd/horizonladder.cpp index f0d351667..d82e12269 100644 --- a/app/osd/horizonladder.cpp +++ b/app/osd/horizonladder.cpp @@ -5,9 +5,10 @@ #include #include -#include "common/TimeHelper.hpp" #include "debug_overdraw.hpp" +static constexpr int DEFAULT_FONT_PIXEL_SIZE=11; + HorizonLadder::HorizonLadder(QQuickItem *parent): QQuickPaintedItem(parent) { qDebug() << "HorizonLadder::HorizonLadder()"; setRenderTarget(RenderTarget::FramebufferObject); @@ -491,6 +492,13 @@ void HorizonLadder::setShowHorizonHome(bool showHorizonHome) { void HorizonLadder::setFontFamily(QString fontFamily) { m_fontFamily = fontFamily; emit fontFamilyChanged(m_fontFamily); - m_font = QFont(m_fontFamily, 11, QFont::Bold, false); + m_font = QFont(m_fontFamily, DEFAULT_FONT_PIXEL_SIZE*m_custom_font_scale, QFont::Bold, false); + update(); +} + +void HorizonLadder::set_custom_font_scale(double custom_font_scale) +{ + m_custom_font_scale=custom_font_scale; + m_font.setPointSize(DEFAULT_FONT_PIXEL_SIZE*m_custom_font_scale); update(); } diff --git a/app/osd/horizonladder.h b/app/osd/horizonladder.h index d113b7e56..c2c48ff21 100644 --- a/app/osd/horizonladder.h +++ b/app/osd/horizonladder.h @@ -32,7 +32,8 @@ class HorizonLadder : public QQuickPaintedItem { L_RW_PROP(bool,show_center_indicator, set_show_center_indicator, true) // Adjust the stroke strength of the lines, in percent //L_RW_PROP(double,line_stroke_strength_perc, set_line_stroke_strength_perc, 100) - +public: + Q_PROPERTY(double custom_font_scale WRITE set_custom_font_scale) public: explicit HorizonLadder(QQuickItem* parent = nullptr); @@ -61,7 +62,7 @@ public slots: void setShowHorizonHome(bool showHorizonHome); void setFontFamily(QString fontFamily); - + void set_custom_font_scale(double custom_font_scale); signals: void colorChanged(QColor color); void glowChanged(QColor glow); @@ -108,5 +109,6 @@ public slots: QFont m_font; QFont m_fontAwesome = QFont("Font Awesome 5 Free", 15, QFont::Bold, false); + double m_custom_font_scale=1.0; }; #endif //QOPENHD_HORIZON_LADDER diff --git a/app/osd/speedladder.cpp b/app/osd/speedladder.cpp index 0154cb76f..6d0fe86ef 100644 --- a/app/osd/speedladder.cpp +++ b/app/osd/speedladder.cpp @@ -7,6 +7,8 @@ #include "debug_overdraw.hpp" +static constexpr int DEFAULT_FONT_PIXEL_SIZE=11; + SpeedLadder::SpeedLadder(QQuickItem *parent): QQuickPaintedItem(parent) { qDebug() << "SpeedLadder::SpeedLadder()"; setRenderTarget(RenderTarget::FramebufferObject); @@ -129,6 +131,13 @@ void SpeedLadder::setSpeed(int speed) { void SpeedLadder::setFontFamily(QString fontFamily) { m_fontFamily = fontFamily; emit fontFamilyChanged(m_fontFamily); - m_font = QFont(m_fontFamily, 10, QFont::Bold, false); + m_font = QFont(m_fontFamily, DEFAULT_FONT_PIXEL_SIZE*m_custom_font_scale, QFont::Bold, false); + update(); +} + +void SpeedLadder::set_custom_font_scale(double custom_font_scale) +{ + m_custom_font_scale=custom_font_scale; + m_font.setPointSize(DEFAULT_FONT_PIXEL_SIZE*m_custom_font_scale); update(); } diff --git a/app/osd/speedladder.h b/app/osd/speedladder.h index 3b0d772a0..225185480 100644 --- a/app/osd/speedladder.h +++ b/app/osd/speedladder.h @@ -2,6 +2,7 @@ #include #include +#include "../../../lib/lqtutils_master/lqtutils_prop.h" class SpeedLadder : public QQuickPaintedItem { Q_OBJECT @@ -13,7 +14,8 @@ class SpeedLadder : public QQuickPaintedItem { Q_PROPERTY(int speed MEMBER m_speed WRITE setSpeed NOTIFY speedChanged) Q_PROPERTY(QString fontFamily MEMBER m_fontFamily WRITE setFontFamily NOTIFY fontFamilyChanged) - +public: + Q_PROPERTY(double custom_font_scale WRITE set_custom_font_scale) public: explicit SpeedLadder(QQuickItem* parent = nullptr); @@ -31,7 +33,7 @@ public slots: void setSpeed(int speed); void setFontFamily(QString fontFamily); - + void set_custom_font_scale(double custom_font_scale); signals: void colorChanged(QColor color); void glowChanged(QColor glow); @@ -51,5 +53,5 @@ public slots: QString m_fontFamily; QFont m_font; - + double m_custom_font_scale=1.0; }; diff --git a/qml/ui/HUDOverlayGrid.qml b/qml/ui/HUDOverlayGrid.qml index afe49440a..f97e40870 100644 --- a/qml/ui/HUDOverlayGrid.qml +++ b/qml/ui/HUDOverlayGrid.qml @@ -21,6 +21,8 @@ Item { property bool m_show_vertical_center_indicator: false property bool m_show_horizontal_center_indicator: false + //scale: settings.dev_some_scale + //signal settingsButtonClicked property int m_highlight_index : 0 property int m_MAX_ITEM_INDEX: 15 diff --git a/qml/ui/elements/OSDCustomizer.qml b/qml/ui/elements/OSDCustomizer.qml index 7268b3d7f..0cdce625c 100644 --- a/qml/ui/elements/OSDCustomizer.qml +++ b/qml/ui/elements/OSDCustomizer.qml @@ -9,12 +9,13 @@ import "colorwheel" Rectangle { id: osdCustomizer - width: 196 - height: 312 + //width: 196 + //height: 312 + width: 250 + height: 350 color: "#ffeaeaea" - property bool stateVisible: visible states: [ @@ -191,6 +192,17 @@ Rectangle { } } + /*Item{ + height: 60 + width: parent.width - 24 + Slider{ + from: 0.5 + to: 1.5 + value: settings.hud_osd_qquickpainteditem_font_scale + onValueChanged: settings.hud_osd_qquickpainteditem_font_scale=value + } + }*/ + Button { height: 60 width: parent.width - 24 diff --git a/qml/ui/widgets/AltitudeWidget.qml b/qml/ui/widgets/AltitudeWidget.qml index 69296c241..3af92c2e7 100644 --- a/qml/ui/widgets/AltitudeWidget.qml +++ b/qml/ui/widgets/AltitudeWidget.qml @@ -61,7 +61,8 @@ BaseWidget { id: idBaseWidgetDefaultUiControlElements show_vertical_lock: true - show_horizontal_lock: true + //show_horizontal_lock: true + show_quickpainteditem_font_scale: true Item { width: parent.width @@ -192,6 +193,7 @@ BaseWidget { altitudeRange: settings.altitude_ladder_range Behavior on altitude {NumberAnimation { duration: settings.smoothing }} fontFamily: settings.font_text + custom_font_scale: bw_qquickpainteditem_font_scale } } //-----------------------ladder end--------------- diff --git a/qml/ui/widgets/BaseWidget.qml b/qml/ui/widgets/BaseWidget.qml index 24f52cbad..55c1643ba 100644 --- a/qml/ui/widgets/BaseWidget.qml +++ b/qml/ui/widgets/BaseWidget.qml @@ -64,11 +64,34 @@ BaseWidgetForm { settings.sync(); } // Feature persist scale end -------------------------------------------------------------------------------------- - // Feature persist opacity begin + + // Feature persist opacity begin ------------------------------------------------------------------------------------ property string bw_opacity_identifier: "%1_opacity".arg(widgetIdentifier); // Default opacity is 1, the value is persistent property double bw_current_opacity : settings.value(bw_opacity_identifier,1.0); - // Feature persist opacity end + // Updates the current base widget scale (unique per widgetIdentifier) and persist the value for later use + function bw_set_current_opacity(opacity){ + if(opacity <=0 || opacity>1){ + console.warn("perhaps invalid widget opacity"); + } + bw_current_opacity=opacity + settings.setValue(bw_opacity_identifier, bw_current_opacity); + settings.sync(); + } + // Feature persist opacity end -------------------------------------------------------------------------------------- + + // Feature persist 'qquickpainteditem_font_scale' begin ------------------------------------------------------------ + // only for qquick painted items (few) + property string bw_qquickpainteditem_font_scale_identifier: "%1_qquickpainteditem_font_scale".arg(widgetIdentifier); + property double bw_qquickpainteditem_font_scale: settings.value(bw_qquickpainteditem_font_scale_identifier,1.0); + function bw_set_qquickpainteditem_font_scale(scale){ + bw_qquickpainteditem_font_scale=scale; + settings.setValue(bw_qquickpainteditem_font_scale_identifier,bw_qquickpainteditem_font_scale); + settings.sync(); + } + // Feature persist 'qquickpainteditem_font_scale' end -------------------------------------------------------------- + + // Feature: Show grid when dragging property bool m_show_grid_when_dragging: false onDraggingChanged: { @@ -81,16 +104,6 @@ BaseWidgetForm { } } - // Updates the current base widget scale (unique per widgetIdentifier) and persist the value for later use - function bw_set_current_opacity(opacity){ - if(opacity <=0 || opacity>1){ - console.warn("perhaps invalid widget opacity"); - } - bw_current_opacity=opacity - settings.setValue(bw_opacity_identifier, bw_current_opacity); - settings.sync(); - } - // Feature persist opacity end // Added by Consti10 - diff --git a/qml/ui/widgets/BaseWidgetDefaultUiControlElements.qml b/qml/ui/widgets/BaseWidgetDefaultUiControlElements.qml index 2393da157..dfb736eb1 100644 --- a/qml/ui/widgets/BaseWidgetDefaultUiControlElements.qml +++ b/qml/ui/widgets/BaseWidgetDefaultUiControlElements.qml @@ -19,6 +19,8 @@ ColumnLayout{ property bool show_horizontal_lock: false property bool show_transparency: true + property bool show_quickpainteditem_font_scale: false + Item { width: parent.width height: 42 @@ -103,6 +105,36 @@ ColumnLayout{ } } } + Item { + width: parent.width + height: 32 + visible: show_quickpainteditem_font_scale + Text { + text: qsTr("Font Sale: x"+bw_qquickpainteditem_font_scale.toFixed(1)) + color: "white" + height: parent.height + font.bold: true + font.pixelSize: detailPanelFontPixels + anchors.left: parent.left + verticalAlignment: Text.AlignVCenter + } + Slider { + orientation: Qt.Horizontal + from: .5 + value: bw_qquickpainteditem_font_scale + to: 2 + stepSize: .1 + height: parent.height + anchors.rightMargin: 0 + anchors.right: parent.right + width: parent.width - 96 + + onValueChanged: { + bw_set_qquickpainteditem_font_scale(value); + } + } + } + Item { width: 230 diff --git a/qml/ui/widgets/HeadingWidget.qml b/qml/ui/widgets/HeadingWidget.qml index c7653559f..cf7500c21 100644 --- a/qml/ui/widgets/HeadingWidget.qml +++ b/qml/ui/widgets/HeadingWidget.qml @@ -37,6 +37,7 @@ BaseWidget { id: idBaseWidgetDefaultUiControlElements show_vertical_lock: true show_horizontal_lock: true + show_quickpainteditem_font_scale: true Item { width: 230 @@ -120,6 +121,7 @@ BaseWidget { color: settings.color_shape glow: settings.color_glow fontFamily: settings.font_text + custom_font_scale: bw_qquickpainteditem_font_scale } } diff --git a/qml/ui/widgets/HorizonWidget.qml b/qml/ui/widgets/HorizonWidget.qml index 8cad30524..9072afc32 100644 --- a/qml/ui/widgets/HorizonWidget.qml +++ b/qml/ui/widgets/HorizonWidget.qml @@ -35,6 +35,7 @@ BaseWidget { show_vertical_lock: true show_horizontal_lock: true + show_quickpainteditem_font_scale: true Item { width: 230 @@ -402,6 +403,7 @@ BaseWidget { showHorizonHeadingLadder: settings.show_horizon_heading_ladder showHorizonHome: settings.show_horizon_home //you dont want a floating home icon fontFamily: settings.font_text + custom_font_scale: bw_qquickpainteditem_font_scale } Rectangle{ // For debugging the area where the horizon clips // debug diff --git a/qml/ui/widgets/SpeedWidget.qml b/qml/ui/widgets/SpeedWidget.qml index f47601112..c727480ee 100644 --- a/qml/ui/widgets/SpeedWidget.qml +++ b/qml/ui/widgets/SpeedWidget.qml @@ -69,6 +69,7 @@ BaseWidget { show_horizontal_lock: true show_vertical_lock: true + show_quickpainteditem_font_scale: true Item { width: parent.width @@ -252,6 +253,7 @@ BaseWidget { Behavior on speed {NumberAnimation { duration: settings.smoothing }} speed: get_speed_number() fontFamily: settings.font_text + custom_font_scale: bw_qquickpainteditem_font_scale } } From ef4edefafe5dd769e657a4c416b6d80e70acf6ae Mon Sep 17 00:00:00 2001 From: consti10 Date: Tue, 31 Oct 2023 17:29:24 +0100 Subject: [PATCH 27/81] Improve UI: 1) More consistent layouting for the (SCAN,ANALYZE,STBC,TX POWER) elements 2) Analyze progress 3) refactor out the qopenhd frequency list --- app/telemetry/settings/frequencyhelper.cpp | 79 ++++++ app/telemetry/settings/frequencyhelper.h | 24 ++ .../settings/wblinksettingshelper.cpp | 108 ++------ app/telemetry/settings/wblinksettingshelper.h | 2 + app/telemetry/telemetry.pri | 2 + qml/qml.qrc | 19 +- .../openhd_settings/FreqComboBoxRow.qml | 29 +- .../MavlinkOpenHDWBParamPanel.qml | 87 ++++-- .../openhd_settings/PopupAnalyzeChannels.qml | 184 ++++++++----- .../openhd_settings/PopupEnableSTBCLDPC.qml | 24 +- .../openhd_settings/PopupScanChannels.qml | 92 +++++-- .../openhd_settings/PopupTxPowerEditor.qml | 39 ++- qml/ui/elements/SimpleLeftRightText.qml | 30 ++ qml/ui/elements/SimpleProgressBar.qml | 25 +- qml/ui/widgets/VideoBitrateWidgetGeneric.qml | 258 ++++++++++-------- 15 files changed, 661 insertions(+), 341 deletions(-) create mode 100644 app/telemetry/settings/frequencyhelper.cpp create mode 100644 app/telemetry/settings/frequencyhelper.h create mode 100644 qml/ui/elements/SimpleLeftRightText.qml diff --git a/app/telemetry/settings/frequencyhelper.cpp b/app/telemetry/settings/frequencyhelper.cpp new file mode 100644 index 000000000..325679018 --- /dev/null +++ b/app/telemetry/settings/frequencyhelper.cpp @@ -0,0 +1,79 @@ +#include "frequencyhelper.h" + +FrequencyHelper::FrequencyHelper() +{ + +} + +std::vector FrequencyHelper::get_known_frequency_items() +{ + std::vector ret{ + FrequencyItem{-1,2312,false,false,false,-1}, + FrequencyItem{-1,2332,false,false,false,-1}, + FrequencyItem{-1,2352,false,false,false,-1}, + FrequencyItem{-1,2372,false,false,false,-1}, + FrequencyItem{-1,2392,false,false,false,-1}, + // ACTUAL 2G + FrequencyItem{1 ,2412,false,true,false,-1}, + FrequencyItem{5 ,2432,false,true,false,-1}, + FrequencyItem{9 ,2452,false,true,false,-1}, + FrequencyItem{13,2472,false,true,false,-1}, + FrequencyItem{14,2484,false,false,false,-1}, + // ACTUAL 2G end + FrequencyItem{-1,2492,false,false,false,-1}, + FrequencyItem{-1,2512,false,false,false,-1}, + FrequencyItem{-1,2532,false,false,false,-1}, + FrequencyItem{-1,2572,false,false,false,-1}, + FrequencyItem{-1,2592,false,false,false,-1}, + FrequencyItem{-1,2612,false,false,false,-1}, + FrequencyItem{-1,2632,false,false,false,-1}, + FrequencyItem{-1,2652,false,false,false,-1}, + FrequencyItem{-1,2672,false,false,false,-1}, + FrequencyItem{-1,2692,false,false,false,-1}, + FrequencyItem{-1, 2712,false,false,false,-1}, + // 5G begin + FrequencyItem{ 32,5160,false,false,false,-1}, + FrequencyItem{ 36,5180,false,true ,false,-1}, + FrequencyItem{ 40,5200,false,false,false,-1}, + FrequencyItem{ 44,5220,false,true,false,-1}, + FrequencyItem{ 48,5240,false,false,false,-1}, + FrequencyItem{ 52,5260,true,true ,false,-1}, + FrequencyItem{ 56,5280,true,false,false,-1}, + FrequencyItem{ 60,5300,true,true,false,-1}, + FrequencyItem{ 64,5320,true,false,false,-1}, + // big break / part that is not allowed + FrequencyItem{100,5500,true,true,false,-1}, + FrequencyItem{104,5520,true,false,false,-1}, + FrequencyItem{108,5540,true,true,false,-1}, + FrequencyItem{112,5560,true,false,false,-1}, + FrequencyItem{116,5580,true,true,false,-1}, + FrequencyItem{120,5600,true,false,false,-1}, + FrequencyItem{124,5620,true,true,false,-1}, + FrequencyItem{128,5640,true,false,false,-1}, + FrequencyItem{132,5660,true,true,false,-1}, + FrequencyItem{136,5680,true,false,false,-1}, + FrequencyItem{140,5700,false,true,false,1}, + FrequencyItem{144,5720,false,false,false,-1}, + // Here is the weird break + FrequencyItem{149,5745,false,true,true,2}, + FrequencyItem{153,5765,false,false,false,-1}, + FrequencyItem{157,5785,false,true,true,3}, + FrequencyItem{161,5805,false,false,false,-1}, + FrequencyItem{165,5825,false,true,true,4}, + // Depends + FrequencyItem{169,5845,false,false,false,-1}, + FrequencyItem{173,5865,false,true,true,5}, + FrequencyItem{177,5885,false,false,false,-1}, + FrequencyItem{181,5905,false,false,true,-1} + }; + return ret; +} + +FrequencyHelper::FrequencyItem FrequencyHelper::find_frequency_item(const int frequency) +{ + const auto frequency_items=get_known_frequency_items(); + for(const auto& item:frequency_items){ + if(item.frequency==frequency)return item; + } + return FrequencyItem{-1,-1,false,false,false}; +} diff --git a/app/telemetry/settings/frequencyhelper.h b/app/telemetry/settings/frequencyhelper.h new file mode 100644 index 000000000..ee578e514 --- /dev/null +++ b/app/telemetry/settings/frequencyhelper.h @@ -0,0 +1,24 @@ +#ifndef FREQUENCYHELPER_H +#define FREQUENCYHELPER_H + +#include + + + +class FrequencyHelper +{ +public: + FrequencyHelper(); + struct FrequencyItem{ + int channel_nr; + int frequency; + bool radar; + bool simple; + bool recommended; + int openhd_raceband; + }; + static std::vector get_known_frequency_items(); + static FrequencyItem find_frequency_item(const int frequency); +}; + +#endif // FREQUENCYHELPER_H diff --git a/app/telemetry/settings/wblinksettingshelper.cpp b/app/telemetry/settings/wblinksettingshelper.cpp index f41487a0e..3e2afe40f 100644 --- a/app/telemetry/settings/wblinksettingshelper.cpp +++ b/app/telemetry/settings/wblinksettingshelper.cpp @@ -10,6 +10,7 @@ #include "../../util/qopenhd.h" #include "pollutionhelper.h" +#include "frequencyhelper.h" static void tmp_log_result(bool enable,const std::string message){ if(enable){ @@ -139,11 +140,15 @@ void WBLinkSettingsHelper::process_message_openhd_wifibroadcast_analyze_channels ss<<" Foreign packets:"<=100){ ss<<"100%, Done"; + // DONE + set_current_analyze_frequency(-1); }else{ ss<<(int)msg.progress_perc<<"%"; + set_current_analyze_frequency(curr_channel_mhz); } qDebug()< get_freq_descr(){ - std::vector ret{ - FrequencyItem{-1,2312,false,false,false,-1}, - FrequencyItem{-1,2332,false,false,false,-1}, - FrequencyItem{-1,2352,false,false,false,-1}, - FrequencyItem{-1,2372,false,false,false,-1}, - FrequencyItem{-1,2392,false,false,false,-1}, - // ACTUAL 2G - FrequencyItem{1 ,2412,false,true,false,-1}, - FrequencyItem{5 ,2432,false,true,false,-1}, - FrequencyItem{9 ,2452,false,true,false,-1}, - FrequencyItem{13,2472,false,true,false,-1}, - FrequencyItem{14,2484,false,false,false,-1}, - // ACTUAL 2G end - FrequencyItem{-1,2492,false,false,false,-1}, - FrequencyItem{-1,2512,false,false,false,-1}, - FrequencyItem{-1,2532,false,false,false,-1}, - FrequencyItem{-1,2572,false,false,false,-1}, - FrequencyItem{-1,2592,false,false,false,-1}, - FrequencyItem{-1,2612,false,false,false,-1}, - FrequencyItem{-1,2632,false,false,false,-1}, - FrequencyItem{-1,2652,false,false,false,-1}, - FrequencyItem{-1,2672,false,false,false,-1}, - FrequencyItem{-1,2692,false,false,false,-1}, - FrequencyItem{-1, 2712,false,false,false,-1}, - // 5G begin - FrequencyItem{ 32,5160,false,false,false,-1}, - FrequencyItem{ 36,5180,false,true ,false,-1}, - FrequencyItem{ 40,5200,false,false,false,-1}, - FrequencyItem{ 44,5220,false,true,false,-1}, - FrequencyItem{ 48,5240,false,false,false,-1}, - FrequencyItem{ 52,5260,true,true ,false,-1}, - FrequencyItem{ 56,5280,true,false,false,-1}, - FrequencyItem{ 60,5300,true,true,false,-1}, - FrequencyItem{ 64,5320,true,false,false,-1}, - // big break / part that is not allowed - FrequencyItem{100,5500,true,true,false,-1}, - FrequencyItem{104,5520,true,false,false,-1}, - FrequencyItem{108,5540,true,true,false,-1}, - FrequencyItem{112,5560,true,false,false,-1}, - FrequencyItem{116,5580,true,true,false,-1}, - FrequencyItem{120,5600,true,false,false,-1}, - FrequencyItem{124,5620,true,true,false,-1}, - FrequencyItem{128,5640,true,false,false,-1}, - FrequencyItem{132,5660,true,true,false,-1}, - FrequencyItem{136,5680,true,false,false,-1}, - FrequencyItem{140,5700,false,true,false,1}, - FrequencyItem{144,5720,false,false,false,-1}, - // Here is the weird break - FrequencyItem{149,5745,false,true,true,2}, - FrequencyItem{153,5765,false,false,false,-1}, - FrequencyItem{157,5785,false,true,true,3}, - FrequencyItem{161,5805,false,false,false,-1}, - FrequencyItem{165,5825,false,true,true,4}, - // Depends - FrequencyItem{169,5845,false,false,false,-1}, - FrequencyItem{173,5865,false,true,true,5}, - FrequencyItem{177,5885,false,false,false,-1}, - FrequencyItem{181,5905,false,false,true,-1} - }; - return ret; -} - -static FrequencyItem find_frequency_item(const int frequency){ - const auto frequency_items=get_freq_descr(); - for(const auto& item:frequency_items){ - if(item.frequency==frequency)return item; - } - return FrequencyItem{-1,-1,false,false,false}; -} - static std::string spaced_string(int number){ std::stringstream ss; if(number<100)ss<<" "; @@ -312,7 +237,7 @@ static std::string spaced_string(int number){ QString WBLinkSettingsHelper::get_frequency_description(int frequency_mhz) { - const auto frequency_item=find_frequency_item(frequency_mhz); + const auto frequency_item=FrequencyHelper::find_frequency_item(frequency_mhz); std::stringstream ss; const bool is_2g=frequency_mhz<3000; if(is_2g){ @@ -333,25 +258,25 @@ QString WBLinkSettingsHelper::get_frequency_description(int frequency_mhz) bool WBLinkSettingsHelper::get_frequency_radar(int frequency_mhz) { - const auto frequency_item=find_frequency_item(frequency_mhz); + const auto frequency_item=FrequencyHelper::find_frequency_item(frequency_mhz); return frequency_item.radar; } bool WBLinkSettingsHelper::get_frequency_simplify(int frequency_mhz) { - const auto frequency_item=find_frequency_item(frequency_mhz); + const auto frequency_item=FrequencyHelper::find_frequency_item(frequency_mhz); return frequency_item.simple; } bool WBLinkSettingsHelper::get_frequency_reccommended(int frequency_mhz) { - const auto frequency_item=find_frequency_item(frequency_mhz); + const auto frequency_item=FrequencyHelper::find_frequency_item(frequency_mhz); return frequency_item.recommended; } int WBLinkSettingsHelper::get_frequency_openhd_race_band(int frequency_mhz) { - const auto frequency_item=find_frequency_item(frequency_mhz); + const auto frequency_item=FrequencyHelper::find_frequency_item(frequency_mhz); return frequency_item.openhd_raceband; } @@ -508,7 +433,7 @@ QList WBLinkSettingsHelper::get_supported_frequencies_filtered(int filter_l for(auto& frequency: supported_frequencies){ if(filter_level==1){ // 40Mhz spacing - auto info=find_frequency_item(frequency); + auto info=FrequencyHelper::find_frequency_item(frequency); if(info.simple){ ret.push_back(frequency); } @@ -547,6 +472,15 @@ QVariantList WBLinkSettingsHelper::pollution_frequencies_int_get_pollution(QList return ret; } +int WBLinkSettingsHelper::pollution_get_last_scan_pollution_for_frequency(int frequency) +{ + auto tmp=PollutionHelper::instance().threadsafe_get_pollution_for_frequency(frequency); + if(tmp.has_value()){ + return tmp.value().n_foreign_packets; + } + return -1; +} + void WBLinkSettingsHelper::signal_ui_rebuild_model_when_possible() { diff --git a/app/telemetry/settings/wblinksettingshelper.h b/app/telemetry/settings/wblinksettingshelper.h index 860ffcc78..07e666879 100644 --- a/app/telemetry/settings/wblinksettingshelper.h +++ b/app/telemetry/settings/wblinksettingshelper.h @@ -50,6 +50,7 @@ class WBLinkSettingsHelper : public QObject L_RO_PROP(int,scan_progress_perc,set_scan_progress_perc,0) // Analyzing L_RO_PROP(int,analyze_progress_perc,set_analyze_progress_perc,0) + L_RO_PROP(int,current_analyze_frequency,set_current_analyze_frequency,-1); public: void process_message_openhd_wifibroadcast_supported_channels(const mavlink_openhd_wifbroadcast_supported_channels_t& msg); void process_message_openhd_wifibroadcast_analyze_channels_progress(const mavlink_openhd_wifbroadcast_analyze_channels_progress_t& msg); @@ -98,6 +99,7 @@ class WBLinkSettingsHelper : public QObject Q_INVOKABLE QList get_supported_frequencies_filtered(int filter_level); Q_INVOKABLE QStringList pollution_frequencies_int_to_qstringlist(QList frequencies); Q_INVOKABLE QVariantList pollution_frequencies_int_get_pollution(QList frequencies,bool normalize=false); + Q_INVOKABLE int pollution_get_last_scan_pollution_for_frequency(int frequency); Q_INVOKABLE QString get_frequency_description(int frequency_mhz); Q_INVOKABLE bool get_frequency_radar(int frequency_mhz); diff --git a/app/telemetry/telemetry.pri b/app/telemetry/telemetry.pri index fe0e7fa3a..b5669b9c7 100644 --- a/app/telemetry/telemetry.pri +++ b/app/telemetry/telemetry.pri @@ -12,6 +12,7 @@ SOURCES += \ $$PWD/connection/udp_connection.cpp \ $$PWD/models/fcmapmodel.cpp \ $$PWD/settings/documentedparam.cpp \ + $$PWD/settings/frequencyhelper.cpp \ $$PWD/settings/pollutionhelper.cpp \ $$PWD/settings/wblinksettingshelper.cpp \ $$PWD/action/impl/xparam.cpp \ @@ -36,6 +37,7 @@ HEADERS += \ $$PWD/connection/tcp_connection.h \ $$PWD/settings/documentedparam.h \ $$PWD/action/impl/xparam.h \ + $$PWD/settings/frequencyhelper.h \ $$PWD/settings/pollutionhelper.h \ $$PWD/util/geodesi_helper.h \ $$PWD/util/mavlink_enum_to_string.h \ diff --git a/qml/qml.qrc b/qml/qml.qrc index 8afac7f5f..4b21def5a 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -1,33 +1,33 @@ - + ../translations/QOpenHD_en.qm resources/cursors/arrow_512_green.png resources/cursors/arrow_512_transparent.png resources/cursors/arrow_512_white.png resources/cursors/hand_white.png - + ../translations/QOpenHD_de.qm - + ../translations/QOpenHD_ru.qm - + ../translations/QOpenHD_es.qm - + ../translations/QOpenHD_fr.qm - + ../translations/QOpenHD_nl.qm - + ../translations/QOpenHD_ro.qm - + ../translations/QOpenHD_it.qm - + ../translations/QOpenHD_zh.qm @@ -258,5 +258,6 @@ ui/configpopup/openhd_settings/PopupEnableSTBCLDPC.qml ui/widgets/PerformanceHorizonWidget2.qml ui/configpopup/status/StatusCardsColumn.qml + ui/elements/SimpleLeftRightText.qml diff --git a/qml/ui/configpopup/openhd_settings/FreqComboBoxRow.qml b/qml/ui/configpopup/openhd_settings/FreqComboBoxRow.qml index 135420d81..56c5eeee2 100644 --- a/qml/ui/configpopup/openhd_settings/FreqComboBoxRow.qml +++ b/qml/ui/configpopup/openhd_settings/FreqComboBoxRow.qml @@ -28,6 +28,8 @@ Rectangle{ property int m_openhd_race_band: -1 + property int m_pollution_pps: -1 + color: "transparent" anchors.fill: parent @@ -83,14 +85,13 @@ Rectangle{ }*/ Text{ Layout.alignment: Qt.AlignLeft - Layout.preferredWidth: 90 + Layout.preferredWidth: 60 text: "Default" font.family: "Font Awesome 5 Free" color: "green" visible: m_openhd_race_band==2 font.pixelSize: comboBoxFreq.font.pixelSize } - Text{ // recommended / openhd race band channel Layout.alignment: Qt.AlignRight Layout.preferredWidth: 60 @@ -102,5 +103,29 @@ Rectangle{ color: "green" font.pixelSize: comboBoxFreq.font.pixelSize } + // Channel occupancy estimate + Item{ + Layout.preferredWidth: parent.height + Layout.preferredHeight: parent.height + height: parent.height + width: height + Layout.alignment: Qt.AlignRight + Rectangle{// Channel occupancy estimate + height: parent.height * 2/3; + width: height + radius: width + anchors.centerIn: parent + color: { + if(m_pollution_pps<0){ + return "gray" + } + if(m_pollution_pps<1)return "green"; + if(m_pollution_pps<20) return "orange"; + return "red"; + } + border.width: 2 + border.color: "black" + } + } } } diff --git a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml index 2277f4c91..a43cc4acf 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml +++ b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml @@ -53,7 +53,12 @@ Rectangle{ ListModel{ id: supported_frequencies_model - ListElement {title: "Unknown"; value:-1; radar: false; recommended: false; openhd_raceband_nr: -1} + ListElement {title: "Unknown"; value:-1; radar: false; recommended: false; openhd_raceband_nr: -1; pollution_pps: -1} + } + + ListModel{ + id: frequencies_model + ListElement {title: "Unknown"; value:-1; radar: false; recommended: false; openhd_raceband_nr: -1; pollution_pps: -1} } function show_popup_message(message){ @@ -72,6 +77,7 @@ Rectangle{ const radar=_wbLinkSettingsHelper.get_frequency_radar(frequency) const recommended=_wbLinkSettingsHelper.get_frequency_reccommended(frequency) const openhd_raceband=_wbLinkSettingsHelper.get_frequency_openhd_race_band(frequency) + const pollution=_wbLinkSettingsHelper.pollution_get_last_scan_pollution_for_frequency(frequency); var append_this_value=true; if(m_simplify_enable){ // only add if it is a "simple" channel @@ -81,7 +87,7 @@ Rectangle{ append_this_value=true; } if(append_this_value){ - supported_frequencies_model.append({title: text, value: frequency, radar:radar, recommended: recommended, openhd_raceband_nr: openhd_raceband}) + supported_frequencies_model.append({title: text, value: frequency, radar:radar, recommended: recommended, openhd_raceband_nr: openhd_raceband, pollution_pps: pollution}) } } var index=find_index(supported_frequencies_model,_wbLinkSettingsHelper.curr_channel_mhz); @@ -93,6 +99,10 @@ Rectangle{ console.log("Seems not to be a valid channel "+_wbLinkSettingsHelper.curr_channel_mhz) } } + function create_list_model2(){ + frequencies_model.clear(); + + } // We get notified every time we should re-build the model(s) and their current selection property int m_ui_rebuild_models : _wbLinkSettingsHelper.ui_rebuild_models @@ -106,14 +116,14 @@ Rectangle{ if(_wbLinkSettingsHelper.ui_rebuild_models<=0)return create_list_model_supported(); //update_pollution_graph(); - pollution_chart_view.update(); + popup_analyze_channels.update(); } // function close_all_dialoques(){ - pollution_chart_view.close() - channel_scan_progress_view.close(); - change_tx_power_popup.close(); + popup_analyze_channels.close() + popup_scan_channels.close(); + popup_change_tx_power.close(); dialoqueFreqChangeGndOnly.close(); dialoqueFreqChangeArmed.close(); popup_enable_stbc_ldpc.close(); @@ -195,6 +205,7 @@ Rectangle{ contentWidth: main_column_layout.width //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) ColumnLayout{ Layout.fillWidth: true @@ -236,11 +247,42 @@ Rectangle{ m_is_2G: value < 3000 && value > 100 m_show_radar: radar m_openhd_race_band: openhd_raceband_nr + m_pollution_pps: pollution_pps } highlighted: comboBoxFreq.highlightedIndex === index } Layout.row: 1 Layout.column: 0 + /*displayText: { + if(!_ohdSystemGround.is_alive)return "GND NOT ALIVE"; + if(_ohdSystemGround.wb_gnd_operating_mode==1){ + return "SCANNING"; + } + if(_ohdSystemGround.wb_gnd_operating_mode==2){ + return "ANALYZING"; + } + if(!_ohdSystemAir.is_alive){ + return _wbLinkSettingsHelper.curr_channel_mhz+"@"+"N/A"+" Mhz (NO AIR)"; + } + return _wbLinkSettingsHelper.curr_channel_mhz+"@"+_wbLinkSettingsHelper.curr_channel_width_mhz+" Mhz"; + } + onCurrentIndexChanged: { + console.log("Index changed:"+currentIndex); + if(currentIndex<0)return; + var frequency_mhz=supported_frequencies_model.get(currentIndex).value + console.log("Selected frequency: "+frequency_mhz); + if(_wbLinkSettingsHelper.curr_channel_mhz==frequency_mhz){ + console.log("Already at frequency "+frequency_mhz); + return; + } + if(!_ohdSystemAir.is_alive){ + var error_message_not_alive="AIR Unit not alive -" + dialoqueFreqChangeGndOnly.initialize_and_show_frequency(frequency_mhz,error_message_not_alive); + return; + } + // Change the freuquency + } + enabled: _ohdSystemGround.is_alive*/ } Button{ text: "APPLY" @@ -255,13 +297,15 @@ Rectangle{ change_frequency_sync_otherwise_handle_error(selectedValue,-1,false); } //Material.background: fc_is_armed() ? Material.Red : Material.Normal; - enabled: _wbLinkSettingsHelper.ui_rebuild_models>=0 && (_ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0); + enabled: _wbLinkSettingsHelper.ui_rebuild_models>=0 && (_ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0) && + (_wbLinkSettingsHelper.curr_channel_mhz!=comboBoxFreq.currentValue); Layout.row: 1 Layout.column: 1 } Switch{ Layout.row: 1 Layout.column: 2 + Layout.columnSpan: 1 text: "SIMPLIFY" checked: true onCheckedChanged: { @@ -316,7 +360,7 @@ Rectangle{ enabled: _ohdSystemGround.is_alive onClicked: { close_all_dialoques(); - channel_scan_progress_view.open() + popup_scan_channels.open() } SequentialAnimation { running: false @@ -347,7 +391,7 @@ Rectangle{ enabled: _ohdSystemGround.is_alive onClicked: { close_all_dialoques(); - pollution_chart_view.open() + popup_analyze_channels.open() } } ButtonIconInfo{ @@ -422,12 +466,12 @@ Rectangle{ Button{ Layout.row: 1 Layout.column: 1 - text: "CHANGE" + text: "EDIT" enabled: _ohdSystemAir.is_alive onClicked: { close_all_dialoques(); - change_tx_power_popup.m_is_air=true; - change_tx_power_popup.open() + popup_change_tx_power.m_is_air=true; + popup_change_tx_power.open() } } Text{ @@ -438,12 +482,12 @@ Rectangle{ Button{ Layout.row: 2 Layout.column: 1 - text: "CHANGE" + text: "EDIT" enabled: _ohdSystemGround.is_alive onClicked: { close_all_dialoques(); - change_tx_power_popup.m_is_air=false; - change_tx_power_popup.open() + popup_change_tx_power.m_is_air=false; + popup_change_tx_power.open() } } // STBC / LDPC @@ -481,10 +525,11 @@ Rectangle{ Layout.row: 2 Layout.column: 4 text: "EDIT"; - //enabled: true - enabled: _ohdSystemAir.is_alive && _ohdSystemGround.is_alive && (_wbLinkSettingsHelper.ui_rebuild_models>=0) && - (_ohdSystemGround.wb_stbc_enabled!=true || _ohdSystemGround.wb_lpdc_enabled!=true || _ohdSystemAir.wb_stbc_enabled!=true || _ohdSystemAir.wb_lpdc_enabled!=true); + enabled: true + //enabled: _ohdSystemAir.is_alive && _ohdSystemGround.is_alive && (_wbLinkSettingsHelper.ui_rebuild_models>=0) && + // (_ohdSystemGround.wb_stbc_enabled!=true || _ohdSystemGround.wb_lpdc_enabled!=true || _ohdSystemAir.wb_stbc_enabled!=true || _ohdSystemAir.wb_lpdc_enabled!=true); onClicked: { + close_all_dialoques(); popup_enable_stbc_ldpc.open() } } @@ -520,15 +565,15 @@ Rectangle{ } PopupAnalyzeChannels{ - id: pollution_chart_view + id: popup_analyze_channels } PopupScanChannels{ - id: channel_scan_progress_view + id: popup_scan_channels } PopupTxPowerEditor{ - id: change_tx_power_popup + id: popup_change_tx_power } PopupEnableSTBCLDPC{ id: popup_enable_stbc_ldpc diff --git a/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml b/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml index b4b918395..da187a13a 100644 --- a/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml +++ b/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml @@ -17,14 +17,18 @@ import "../../elements" import QtCharts 2.0 Rectangle{ - width: parent.width-12 - height: parent.height*2/3; + id: main_background + //width: parent.width-12 + //height: parent.height*2/3; + width: parent.width + height: parent.height anchors.centerIn: parent color: "#ADD8E6" border.color: "black" border.width: 3 property bool m_normalize_data: false; + property int m_chart_view_minimum_width: 1280-200; function open(){ visible=true @@ -38,26 +42,57 @@ Rectangle{ pollution_chart.update_pollution_graph(); } - property string m_info_string: "Analyze channels for pollution by wifi access points."+ -"NOTE: This only gives a hint at free channels, using a proper channel analyzer (e.g. on the phone) is recommended."+ -"PLEASE DO NOT CHANGE SETTINGS WHILE ANALYZING." + property string m_info_string: "Analyze channels for pollution by wifi access points.\n"+ +"NOTE: This only gives a hint at free channels, using a proper channel analyzer (e.g. on the phone) is recommended !\n"+ +"In short: Any frequency with red bars (small or big) should not be used, unless there are no options / other reasons to do so." - RowLayout{ + GridLayout{ id: top_elements - Layout.fillWidth: true - Item{ //Spacer + //width: parent.width + anchors.left: parent.left + anchors.leftMargin: 5 + anchors.right: parent.right + anchors.rightMargin: 5 + + + Text{ // TITLE + Layout.row: 0 + Layout.column: 0 + Layout.columnSpan: 3 Layout.fillWidth: true + Layout.preferredHeight: 50 + Layout.minimumHeight: 20 + text: "ANALYZE CHANNELS (POLLUTION)"; + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter } - Switch{ - text: "NORMALIZE" - checked: m_normalize_data - onCheckedChanged: { - m_normalize_data=checked - pollution_chart.update_pollution_graph(); + + Button{ + Layout.row: 0 + Layout.column: 3 + Layout.alignment: Qt.AlignRight + text: "CLOSE" + onClicked: { + if(_ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==2){ + _qopenhd.show_toast("STILL ANALYZING, PLEASE WAIT ...",); + return; + } + close() } } + SimpleProgressBar{ + Layout.row: 1 + Layout.column: 0 + Layout.preferredWidth: 400 + Layout.minimumWidth: 100 + Layout.preferredHeight: 40 + impl_curr_progress_perc: _wbLinkSettingsHelper.analyze_progress_perc + impl_show_progress_text: true + } Button{ - Layout.alignment: Qt.AlignHCenter + Layout.row: 1 + Layout.column: 1 + Layout.alignment: Qt.AlignLeft text: "START" onClicked: { var result=_wbLinkSettingsHelper.start_analyze_channels() @@ -69,66 +104,91 @@ Rectangle{ } enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0 } + Text{ + Layout.row: 2 + Layout.column: 0 + Layout.preferredWidth: 200 + Layout.minimumWidth: 50 + text: { + if(_wbLinkSettingsHelper.current_analyze_frequency<=0){ + return ""; + } + return "Analyzed "+_wbLinkSettingsHelper.current_analyze_frequency+" Mhz ..."; + } + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + } + + Switch{ + Layout.row: 2 + Layout.column: 1 + text: "NORMALIZE" + checked: m_normalize_data + onCheckedChanged: { + m_normalize_data=checked + pollution_chart.update_pollution_graph(); + } + } ButtonIconInfo{ - Layout.alignment: Qt.AlignHCenter + Layout.row: 2 + Layout.column: 2 + Layout.alignment: Qt.AlignLeft onClicked: { _messageBoxInstance.set_text_and_show(m_info_string) } } - Item{ //Spacer + // Filler + Item{ Layout.fillWidth: true } } - // Argh, need to manually place the button - Button{ - anchors.top: parent.top + + ScrollView{ + anchors.top: top_elements.bottom + anchors.bottom: parent.bottom + anchors.left: parent.left anchors.right: parent.right - text: "CLOSE" - onClicked: { - if(_ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==2){ - _qopenhd.show_toast("STILL ANALYZING",); - return; + contentWidth: pollution_chart.width + ScrollBar.horizontal.interactive: true + + ChartView { + id: pollution_chart + title: "WiFi pollution estimate" + width: main_background.width>m_chart_view_minimum_width ? main_background.width : m_chart_view_minimum_width; + height: parent.height + legend.alignment: Qt.AlignBottom + antialiasing: true + + function update_pollution_graph(){ + //const frequencies_list = _wbLinkSettingsHelper.get_pollution_qstringlist(); + //bar_axis_x.categories=frequencies_list; + //const supported_frequencies = _wbLinkSettingsHelper.get_supported_frequencies(); + const supported_frequencies = _wbLinkSettingsHelper.get_supported_frequencies_filtered(1); + var categories = _wbLinkSettingsHelper.pollution_frequencies_int_to_qstringlist(supported_frequencies); + var values = _wbLinkSettingsHelper.pollution_frequencies_int_get_pollution(supported_frequencies,m_normalize_data); + bar_axis_x.categories=categories; + bar_set.values=values; } - close() - } - } - ChartView { - anchors.top: top_elements.bottom - title: "WiFi pollution estimate" - width: parent.width - height: parent.height-top_elements.height - legend.alignment: Qt.AlignBottom - antialiasing: true - - id: pollution_chart - - function update_pollution_graph(){ - //const frequencies_list = _wbLinkSettingsHelper.get_pollution_qstringlist(); - //bar_axis_x.categories=frequencies_list; - //const supported_frequencies = _wbLinkSettingsHelper.get_supported_frequencies(); - const supported_frequencies = _wbLinkSettingsHelper.get_supported_frequencies_filtered(1); - var categories = _wbLinkSettingsHelper.pollution_frequencies_int_to_qstringlist(supported_frequencies); - var values = _wbLinkSettingsHelper.pollution_frequencies_int_get_pollution(supported_frequencies,m_normalize_data); - bar_axis_x.categories=categories; - bar_set.values=values; - } - BarSeries { - id: hm_bar_series - axisX: BarCategoryAxis { - id: bar_axis_x - categories: ["DUMMY0", "DUMMY1", "DUMMY3", "DUMMY4" ] - //min: "0" - //max: "500" - } - BarSet { - id: bar_set - label: "Pollution (pps)"; - values: [5,10,3,100] - //values: [0,0,0,0] - color: "red" + BarSeries { + id: hm_bar_series + axisX: BarCategoryAxis { + id: bar_axis_x + categories: ["DUMMY0", "DUMMY1", "DUMMY3", "DUMMY4" ] + //min: "0" + //max: "500" + } + BarSet { + id: bar_set + label: "Pollution (pps)"; + values: [5,10,3,100] + //values: [0,0,0,0] + color: "red" + } } } } + + } diff --git a/qml/ui/configpopup/openhd_settings/PopupEnableSTBCLDPC.qml b/qml/ui/configpopup/openhd_settings/PopupEnableSTBCLDPC.qml index f5e7f6e7b..e9ba0a982 100644 --- a/qml/ui/configpopup/openhd_settings/PopupEnableSTBCLDPC.qml +++ b/qml/ui/configpopup/openhd_settings/PopupEnableSTBCLDPC.qml @@ -16,8 +16,10 @@ import "../../elements" Rectangle{ id: main_background - width: parent.width-12 - height: parent.height*2/3; + //width: parent.width-12 + //height: parent.height*2/3; + width: parent.width + height: parent.height anchors.centerIn: parent color: "#ADD8E6" border.color: "black" @@ -52,10 +54,9 @@ Rectangle{ GridLayout{ id: main_row_layout - Layout.fillWidth: true - Layout.fillHeight: true - Layout.leftMargin: 5 - Layout.rightMargin: 5 + anchors.fill: parent + anchors.leftMargin: 10 + anchors.rightMargin: 10 Text{ id: stbc_warning_text @@ -96,7 +97,7 @@ Rectangle{ Layout.column: 0 id: comboBoxNAntennasAir Layout.minimumWidth: 100 - Layout.preferredWidth: 350 + Layout.preferredWidth: 450 model: model_n_antennas_air textRole: "title" font.pixelSize: 14 @@ -111,7 +112,7 @@ Rectangle{ Layout.column: 0 id: comboBoxNAntennasGnd Layout.minimumWidth: 100 - Layout.preferredWidth: 350 + Layout.preferredWidth: 450 model: model_n_antennas_gnd textRole: "title" font.pixelSize: 14 @@ -144,6 +145,13 @@ Rectangle{ text: "CAN ONLY BE ENABLED IF BOTH AIR AND GND UNIT HAVE 2 RF PATHS / ANTENNAS"; font.pixelSize: 14 } + Item{ // Filler + Layout.row: 5 + Layout.column: 0 + Layout.columnSpan: 3 + Layout.fillWidth: true + Layout.fillHeight: true + } // ---------------- } diff --git a/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml b/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml index 277c1b461..04e70941b 100644 --- a/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml +++ b/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml @@ -15,8 +15,10 @@ import "../../../ui" as Ui import "../../elements" Rectangle{ - width: parent.width-12 - height: parent.height*2/3; + //width: parent.width-12 + //height: parent.height*2/3; + width: parent.width + height: parent.height anchors.centerIn: parent color: "#ADD8E6" border.color: "black" @@ -47,27 +49,48 @@ Rectangle{ GridLayout{ id: main_grid_layout - Layout.fillWidth: true - Layout.fillHeight: true + anchors.fill: parent + anchors.leftMargin: 10 + anchors.rightMargin: 10 - ComboBox { + Text{ // TITLE Layout.row: 0 Layout.column: 0 - Layout.preferredWidth: 400 - Layout.minimumWidth: 100 - id: comboBoxWhichFrequencyToScan - model: model_chann_to_scan - textRole: "title" - Material.background: { - (comboBoxWhichFrequencyToScan.currentIndex===0) ? Material.Green : Material.Orange - } - onCurrentIndexChanged: { - } - enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0 + Layout.columnSpan: 2 + Layout.fillWidth: true + Layout.preferredHeight: 50 + Layout.minimumHeight: 20 + text: "SCAN (FIND AIR UNIT)"; + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter } Button{ + Layout.alignment: Qt.AlignRight Layout.row: 0 + Layout.column: 3 + text: "CLOSE" + onClicked: { + if(_ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==1){ + _qopenhd.show_toast("STILL SCANNING,PLEASE WAIT ..."); + return; + } + close() + } + } + + + SimpleProgressBar{ + Layout.row: 1 + Layout.column: 0 + Layout.preferredWidth: 400 + Layout.minimumWidth: 100 + Layout.preferredHeight: 40 + impl_curr_progress_perc: _wbLinkSettingsHelper.scan_progress_perc + impl_show_progress_text: true + } + Button{ + Layout.row: 1 Layout.column: 1 text: "START" enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0 @@ -84,17 +107,23 @@ Rectangle{ } } } - SimpleProgressBar{ - Layout.row: 1 + ComboBox { + Layout.row: 2 Layout.column: 0 - Layout.fillWidth: true - Layout.preferredHeight: 40 Layout.preferredWidth: 400 Layout.minimumWidth: 100 - impl_curr_progress_perc: _wbLinkSettingsHelper.scan_progress_perc + id: comboBoxWhichFrequencyToScan + model: model_chann_to_scan + textRole: "title" + Material.background: { + (comboBoxWhichFrequencyToScan.currentIndex===0) ? Material.Green : Material.Orange + } + onCurrentIndexChanged: { + } + enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0 } ButtonIconInfo{ - Layout.row: 1 + Layout.row: 2 Layout.column: 1 onClicked: { _messageBoxInstance.set_text_and_show("Initiate Channel Scan (Find a running air unit). Similar to analogue TX / RX, this listens on each channel for a short time"+ @@ -104,15 +133,27 @@ Rectangle{ } } Text{ - Layout.row: 2 + Layout.row: 3 Layout.column: 0 text: _wbLinkSettingsHelper.scanning_text_for_ui font.pixelSize: 25 } + Item{ // Filler + Layout.row: 4 + Layout.column: 0 + Layout.columnSpan: 3 + Layout.fillWidth: true + Layout.fillHeight: true + } } - Button{ + /*Button{ + //Layout.alignment: Qt.AlignRight + //Layout.row: 0 + //Layout.column: 3 anchors.top: parent.top anchors.right: parent.right + anchors.topMargin: 5 + anchors.rightMargin: 10 text: "CLOSE" onClicked: { if(_ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==1){ @@ -121,5 +162,6 @@ Rectangle{ } close() } - } + }*/ + } diff --git a/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml b/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml index 9ee38a2f5..30a5fb1a8 100644 --- a/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml +++ b/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml @@ -15,13 +15,17 @@ import "../../../ui" as Ui import "../../elements" Rectangle{ - width: parent.width-12 - height: parent.height*2/3; + //width: parent.width-12 + //height: parent.height*2/3; + width: parent.width + height: parent.height anchors.centerIn: parent color: "#ADD8E6" border.color: "black" border.width: 3 + property int m_margin: 10 + property bool m_is_air: false property int m_user_selected_card_manufacturer: -1; @@ -214,10 +218,9 @@ Rectangle{ GridLayout{ id: main_row_layout - Layout.fillWidth: true - Layout.fillHeight: true - Layout.leftMargin: 5 - Layout.rightMargin: 5 + anchors.fill: parent + anchors.leftMargin: m_margin + anchors.rightMargin: m_margin //anchors.top: parent.top //anchors.bottom: parent.bottom //anchors.left: parent.left @@ -225,13 +228,17 @@ Rectangle{ //Layout.minimumWidth: 300 //Layout.preferredWidth: 600 - Text{ + Text{ // TITLE Layout.row: 0 Layout.column: 0 + Layout.columnSpan: 2 + Layout.fillWidth: true + Layout.preferredHeight: 50 + Layout.minimumHeight: 20 text: m_is_air ? "AIR TX Power" : "GND TX power"; - font.bold: true + verticalAlignment: Qt.AlignVCenter horizontalAlignment: Qt.AlignHCenter - font.pixelSize: 14 + font.pixelSize: 18 } // Text{ @@ -371,12 +378,6 @@ Rectangle{ "if armed or not."); } } - // FILLER - Item{ - Layout.row: 3 - Layout.column: 4 - Layout.fillWidth: true - } Text{ Layout.row: 4 Layout.column: 0 @@ -408,6 +409,13 @@ Rectangle{ verticalAlignment: Qt.AlignBottom font.pixelSize: 14 } + Item{ // Filler + Layout.row: 6 + Layout.column: 0 + Layout.columnSpan: 3 + Layout.fillWidth: true + Layout.fillHeight: true + } // ---------------- } @@ -415,6 +423,7 @@ Rectangle{ text: "CLOSE" anchors.top: parent.top anchors.right: parent.right + anchors.rightMargin: m_margin onClicked: { close() } diff --git a/qml/ui/elements/SimpleLeftRightText.qml b/qml/ui/elements/SimpleLeftRightText.qml new file mode 100644 index 000000000..87784663b --- /dev/null +++ b/qml/ui/elements/SimpleLeftRightText.qml @@ -0,0 +1,30 @@ +import QtQuick 2.12 + +Item { + width: parent.width + height: 24 + + property string m_left_text: "FILL ME" + property string m_right_text: "FILL ME" + + property color m_right_text_color: "white" + + Text { + text: m_left_text + color: "white" + font.bold: true + height: parent.height + font.pixelSize: detailPanelFontPixels + anchors.left: parent.left + verticalAlignment: Text.AlignVCenter + } + Text { + text: m_right_text + color: m_right_text_color; + font.bold: true; + height: parent.height + font.pixelSize: detailPanelFontPixels; + anchors.right: parent.right + verticalAlignment: Text.AlignVCenter + } +} diff --git a/qml/ui/elements/SimpleProgressBar.qml b/qml/ui/elements/SimpleProgressBar.qml index 0f2fdaa46..9179e6cae 100644 --- a/qml/ui/elements/SimpleProgressBar.qml +++ b/qml/ui/elements/SimpleProgressBar.qml @@ -8,6 +8,8 @@ Item { // Color of the bar property color impl_curr_color: "blue" + property bool impl_show_progress_text: false + Rectangle{ id: progress_background color: impl_curr_color @@ -20,14 +22,33 @@ Item { } + Text{ + width: parent.width + height: parent.height + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + text: { + var ret="PROGRESS"; + if(impl_curr_progress_perc>=0 && impl_curr_progress_perc<=100){ + ret += ": "+impl_curr_progress_perc+"%"; + }else{ + ret += " "; + } + return ret; + } + color: "white" + visible: impl_show_progress_text + } + Rectangle{ id: progress_bar - opacity: 1.0 + opacity: impl_show_progress_text ? 0.5 : 1.0 width: progress_background.width * (impl_curr_progress_perc / 100.0) height: parent.height anchors.left: parent.left color: impl_curr_color - } + + } diff --git a/qml/ui/widgets/VideoBitrateWidgetGeneric.qml b/qml/ui/widgets/VideoBitrateWidgetGeneric.qml index f4a1899ac..dc0a5ed87 100644 --- a/qml/ui/widgets/VideoBitrateWidgetGeneric.qml +++ b/qml/ui/widgets/VideoBitrateWidgetGeneric.qml @@ -7,6 +7,7 @@ import QtQuick.Shapes 1.0 import Qt.labs.settings 1.0 import OpenHD 1.0 +import "../elements" // Generic since we use the same widget for primary and secondary camera (allbei with different values, of course) BaseWidget { @@ -58,6 +59,55 @@ BaseWidget { return m_camera_stream_model.total_n_tx_dropped_frames+":"+m_camera_stream_model.count_blocks_lost; } + // Complicated + // Set to true if the camera is currently doing recordng (the UI element(s) turn red in this case) + property bool m_camera_is_currently_recording: m_is_for_primary_camera ? _cameraStreamModelPrimary.air_recording_active : _cameraStreamModelSecondary.air_recording_active + + // THIS IS A MAVLINK PARAM, SYNCHRONIZATION THEREFORE IS HARD AND HERE NOT WORTH IT + property int m_camera_recording_mode: -1 + + function try_set_recording_mode(mode){ + var camera_idx=m_is_for_primary_camera ? 0 : 1; + console.log("try_set_recording_mode "+camera_idx+" "+mode) + var camModel=_airCameraSettingsModel; + var camString="CAM1" + if(camera_idx===2){ + camModel=_airCameraSettingsModel2; + camString="CAM2" + } + if(!_ohdSystemAir.is_alive){ + _hudLogMessagesModel.signalAddLogMessage(6,"Air unit not alive, cannot set recording for "+camString) + return; + } + if(mode===0){ //mode off + var result=camModel.try_update_parameter_int("V_AIR_RECORDING",0)==="" + if(result){ + _hudLogMessagesModel.signalAddLogMessage(6,"recording "+camString+" disabled") + m_camera_recording_mode=0; + }else{ + _hudLogMessagesModel.signalAddLogMessage(6,"update "+camString+" failed") + } + } + if(mode===1){ //mode on + var result=camModel.try_update_parameter_int("V_AIR_RECORDING",1)==="" + if(result){ + _hudLogMessagesModel.signalAddLogMessage(6,"recording "+camString+" enabled") + m_camera_recording_mode=1; + }else{ + _hudLogMessagesModel.signalAddLogMessage(6,"update "+camString+" failed") + } + } + if(mode==2){ //mode auto + var result=camModel.try_update_parameter_int("V_AIR_RECORDING",2)==="" + if(result){ + _hudLogMessagesModel.signalAddLogMessage(6,"recording "+camString+" auto enabled") + m_camera_recording_mode=2; + }else{ + _hudLogMessagesModel.signalAddLogMessage(6,"update "+camString+" failed") + } + } + } + //----------------------------- DETAIL BELOW ---------------------------------- @@ -82,116 +132,16 @@ BaseWidget { ColumnLayout{ width:200 - Item { - width: parent.width - height: 32 - Text { - text: qsTr("Set(Enc):") - color: "white" - font.bold: true - height: parent.height - font.pixelSize: detailPanelFontPixels - anchors.left: parent.left - verticalAlignment: Text.AlignVCenter - } - Text { - text: m_camera_stream_model.curr_set_video_format_and_codec - color: "white"; - font.bold: true; - height: parent.height - font.pixelSize: detailPanelFontPixels; - anchors.right: parent.right - verticalAlignment: Text.AlignVCenter - } - } - Item { - width: parent.width - height: 32 - Text { - text: qsTr("Set(Enc):") - color: "white" - font.bold: true - height: parent.height - font.pixelSize: detailPanelFontPixels - anchors.left: parent.left - verticalAlignment: Text.AlignVCenter - } - Text { - text: m_camera_stream_model.curr_recomended_video_bitrate_string - color: "white"; - font.bold: true; - height: parent.height - font.pixelSize: detailPanelFontPixels; - anchors.right: parent.right - verticalAlignment: Text.AlignVCenter - } - } - Item { - width: parent.width - height: 32 - Text { - text: qsTr("Measured(Enc):") - color: "white" - font.bold: true - height: parent.height - font.pixelSize: detailPanelFontPixels - anchors.left: parent.left - verticalAlignment: Text.AlignVCenter - } - Text { - text: m_camera_stream_model.curr_video_measured_encoder_bitrate - color: "white"; - font.bold: true; - height: parent.height - font.pixelSize: detailPanelFontPixels; - anchors.right: parent.right - verticalAlignment: Text.AlignVCenter - } - } - Item { - width: parent.width - height: 32 - Text { - text: qsTr("Injected(+FEC):") - color: "white" - font.bold: true - height: parent.height - font.pixelSize: detailPanelFontPixels - anchors.left: parent.left - verticalAlignment: Text.AlignVCenter - } - Text { - text: m_camera_stream_model.curr_video_injected_bitrate - color: "white"; - font.bold: true; - height: parent.height - font.pixelSize: detailPanelFontPixels; - anchors.right: parent.right - verticalAlignment: Text.AlignVCenter - } - } - Item { - width: parent.width - height: 32 - Text { - text: qsTr("TX Dropped/RX lost:") - color: "white" - font.bold: true - height: parent.height - font.pixelSize: detailPanelFontPixels - anchors.left: parent.left - verticalAlignment: Text.AlignVCenter - } - Text { - text: get_drop_str_tx_rx() - color: "white"; - font.bold: true; - height: parent.height - font.pixelSize: detailPanelFontPixels; - anchors.right: parent.right - verticalAlignment: Text.AlignVCenter - } + + SimpleLeftRightText{ + m_left_text: qsTr("Res@Framerate:") + m_right_text: m_camera_stream_model.curr_set_video_format_and_codec } + + //SimpleLeftRightText{ + // m_left_text: "" + // m_right_text: "" + //} Item{ width: parent.width height: 150 @@ -205,7 +155,7 @@ BaseWidget { // 2 mmal // 3 veye // 4 libcamera - enabled: (m_camera_stream_model.camera_type==1 || m_camera_stream_model.camera_type==2 || m_camera_stream_model.camera_type==4) + //enabled: (m_camera_stream_model.camera_type==1 || m_camera_stream_model.camera_type==2 || m_camera_stream_model.camera_type==4) Button{ text: "480p60(16:9)" onClicked: set_camera_resolution("848x480@60") @@ -238,6 +188,94 @@ BaseWidget { } } } + SimpleLeftRightText{ + m_left_text: qsTr("Bitrate SET:") + m_right_text: m_camera_stream_model.curr_recomended_video_bitrate_string + } + + SimpleLeftRightText{ + m_left_text: qsTr("Bitrate MEASURED:") + m_right_text: m_camera_stream_model.curr_video_measured_encoder_bitrate + } + + SimpleLeftRightText{ + m_left_text: qsTr("Injected(+FEC):") + m_right_text: m_camera_stream_model.curr_video_injected_bitrate + } + + + SimpleLeftRightText{ + m_left_text: qsTr("TX Dropped/RX lost:") + m_right_text: get_drop_str_tx_rx() + } + + Item{ + width: parent.width + height: 32 + Text{ + width: parent.width + height: parent.height + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + text: "AIR RECORDING" + color: "white" + } + } + SimpleLeftRightText{ + m_left_text: qsTr("FREE SPACE:") + m_right_text: { + if(!_ohdSystemAir.is_alive)return "N/A"; + return _ohdSystemAir.curr_space_left_mb+" MB" + } + m_right_text_color: { + if(!_ohdSystemAir.is_alive)return "white" + return (_ohdSystemAir.curr_space_left_mb < 500) ? "red" : "green" + } + } + SimpleLeftRightText{ + m_left_text: qsTr("AIR RECORD:"); + m_right_text: { + if(!_ohdSystemAir.is_alive)return "N/A"; + if(m_camera_recording_mode){ + return "RECORDING"; + } + return "NOT ACTIVE" + } + } + // For camera 1 + Item{ + width: parent.width + height: 50 + //color:"green" + GridLayout{ + width: parent.width + height: parent.height + rows: 1 + columns: 3 + Button{ + text: "OFF" + onClicked: { + try_set_recording_mode(0) + } + highlighted: m_camera_recording_mode==0 + } + Button{ + text: "ON" + onClicked: { + try_set_recording_mode(1) + } + highlighted: m_camera_recording_mode==1 + } + Button{ + text: "AUTO" + onClicked: { + try_set_recording_mode(2) + } + highlighted: m_camera_recording_mode==2 + } + } + } + /*Item{ id: placeholder width:parent.width From 2904ff53dda24d568d68f2f72f2c6812ef59a30d Mon Sep 17 00:00:00 2001 From: Raphael <68374617+raphaelscholle@users.noreply.github.com> Date: Fri, 3 Nov 2023 00:33:00 +0100 Subject: [PATCH 28/81] changing decode pipelines --- systemd/rock3_h264_decode.service | 2 +- systemd/rock3_h265_decode.service | 2 +- systemd/rock3_mjpeg_decode.service | 2 +- systemd/{rock5_qopenhd copy.service => rock3_qopenhd.service} | 2 +- systemd/rock5_h264_decode.service | 2 +- systemd/rock5_h265_decode.service | 2 +- systemd/rock5_mjpeg_decode.service | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) rename systemd/{rock5_qopenhd copy.service => rock3_qopenhd.service} (91%) diff --git a/systemd/rock3_h264_decode.service b/systemd/rock3_h264_decode.service index e0a3c9c90..4e6076330 100644 --- a/systemd/rock3_h264_decode.service +++ b/systemd/rock3_h264_decode.service @@ -5,7 +5,7 @@ Description=rock_h264_decode User=root # Video decode via mpp, started by QOpenHD if needed (and stopped if needed) -ExecStart=/bin/sh -c "gst-launch-1.0 udpsrc port=5600 caps='application/x-rtp, payload=(int)96, clock-rate=(int)90000, media=(string)video, encoding-name=(string)H264' ! rtph264depay ! h264parse ! mppvideodec format=23 fast-mode=true ! queue ! kmssink plane-id=102" +ExecStart=/bin/sh -c "gst-launch-1.0 udpsrc port=5600 caps='application/x-rtp, payload=(int)96, clock-rate=(int)90000, media=(string)video, encoding-name=(string)H264' ! rtph264depay ! h264parse ! mppvideodec format=23 fast-mode=true ! queue ! kmssink plane-id=54 force-modesetting=true" Restart=always RestartSec=2 diff --git a/systemd/rock3_h265_decode.service b/systemd/rock3_h265_decode.service index 5dd2bde9b..e84d50b9e 100644 --- a/systemd/rock3_h265_decode.service +++ b/systemd/rock3_h265_decode.service @@ -5,7 +5,7 @@ Description=rock_h265_decode User=root # Video decode via mpp, started by QOpenHD if needed (and stopped if needed) -ExecStart=/bin/sh -c "gst-launch-1.0 udpsrc port=5600 caps='application/x-rtp, payload=(int)96, clock-rate=(int)90000, media=(string)video, encoding-name=(string)H265' ! rtph265depay ! h265parse ! mppvideodec format=23 fast-mode=true ! queue ! kmssink plane-id=54" +ExecStart=/bin/sh -c "gst-launch-1.0 udpsrc port=5600 caps='application/x-rtp, payload=(int)96, clock-rate=(int)90000, media=(string)video, encoding-name=(string)H265' ! rtph265depay ! h265parse ! mppvideodec format=23 fast-mode=true ! queue ! kmssink plane-id=54 force-modesetting=true" Restart=always RestartSec=1 diff --git a/systemd/rock3_mjpeg_decode.service b/systemd/rock3_mjpeg_decode.service index 6eae58574..e35c317ef 100644 --- a/systemd/rock3_mjpeg_decode.service +++ b/systemd/rock3_mjpeg_decode.service @@ -5,7 +5,7 @@ Description=rock_mjpeg_decode User=root # Video decode via mpp, started by QOpenHD if needed (and stopped if needed) -ExecStart=/bin/sh -c "gst-launch-1.0 udpsrc port=5600 caps='application/x-rtp, payload=(int)26, clock-rate=(int)90000, media=(string)video, encoding-name=(string)JPEG' ! rtpjpegdepay ! jpegdec ! queue ! kmssink plane-id=54" +ExecStart=/bin/sh -c "gst-launch-1.0 udpsrc port=5600 caps='application/x-rtp, payload=(int)26, clock-rate=(int)90000, media=(string)video, encoding-name=(string)JPEG' ! rtpjpegdepay ! jpegdec ! queue ! kmssink plane-id=54 force-modesetting=true" Restart=always RestartSec=1 diff --git a/systemd/rock5_qopenhd copy.service b/systemd/rock3_qopenhd.service similarity index 91% rename from systemd/rock5_qopenhd copy.service rename to systemd/rock3_qopenhd.service index ea8303487..d8bfe7c9a 100644 --- a/systemd/rock5_qopenhd copy.service +++ b/systemd/rock3_qopenhd.service @@ -6,7 +6,7 @@ After=multi-user.target Type=simple Environment="QT_QPA_EGLFS_KMS_ATOMIC=1" Environment="QT_LOGGING_RULES=qt.qpa.egl*=true" -Environment="QT_QPA_EGLFS_KMS_PLANE_INDEX=5" +Environment="QT_QPA_EGLFS_KMS_PLANE_INDEX=1" Environment="QT_QPA_EGLFS_FORCE888=1" Environment="QT_QPA_EGLFS_SWAPINTERVAL=0" Environment="QT_QPA_EGLFS_KMS_CONFIG=/usr/local/share/qopenhd/rock_qt_eglfs_kms_config.json" diff --git a/systemd/rock5_h264_decode.service b/systemd/rock5_h264_decode.service index f465d0bf5..4e6076330 100644 --- a/systemd/rock5_h264_decode.service +++ b/systemd/rock5_h264_decode.service @@ -5,7 +5,7 @@ Description=rock_h264_decode User=root # Video decode via mpp, started by QOpenHD if needed (and stopped if needed) -ExecStart=/bin/sh -c "gst-launch-1.0 udpsrc port=5600 caps='application/x-rtp, payload=(int)96, clock-rate=(int)90000, media=(string)video, encoding-name=(string)H264' ! rtph264depay ! h264parse ! mppvideodec format=23 fast-mode=true ! queue ! kmssink plane-id=54" +ExecStart=/bin/sh -c "gst-launch-1.0 udpsrc port=5600 caps='application/x-rtp, payload=(int)96, clock-rate=(int)90000, media=(string)video, encoding-name=(string)H264' ! rtph264depay ! h264parse ! mppvideodec format=23 fast-mode=true ! queue ! kmssink plane-id=54 force-modesetting=true" Restart=always RestartSec=2 diff --git a/systemd/rock5_h265_decode.service b/systemd/rock5_h265_decode.service index dae7589fd..e84d50b9e 100644 --- a/systemd/rock5_h265_decode.service +++ b/systemd/rock5_h265_decode.service @@ -5,7 +5,7 @@ Description=rock_h265_decode User=root # Video decode via mpp, started by QOpenHD if needed (and stopped if needed) -ExecStart=/bin/sh -c "gst-launch-1.0 udpsrc port=5600 caps='application/x-rtp, payload=(int)96, clock-rate=(int)90000, media=(string)video, encoding-name=(string)H265' ! rtph265depay ! h265parse ! mppvideodec format=23 fast-mode=true ! queue ! kmssink plane-id=102" +ExecStart=/bin/sh -c "gst-launch-1.0 udpsrc port=5600 caps='application/x-rtp, payload=(int)96, clock-rate=(int)90000, media=(string)video, encoding-name=(string)H265' ! rtph265depay ! h265parse ! mppvideodec format=23 fast-mode=true ! queue ! kmssink plane-id=54 force-modesetting=true" Restart=always RestartSec=1 diff --git a/systemd/rock5_mjpeg_decode.service b/systemd/rock5_mjpeg_decode.service index d9460e7f1..e35c317ef 100644 --- a/systemd/rock5_mjpeg_decode.service +++ b/systemd/rock5_mjpeg_decode.service @@ -5,7 +5,7 @@ Description=rock_mjpeg_decode User=root # Video decode via mpp, started by QOpenHD if needed (and stopped if needed) -ExecStart=/bin/sh -c "gst-launch-1.0 udpsrc port=5600 caps='application/x-rtp, payload=(int)26, clock-rate=(int)90000, media=(string)video, encoding-name=(string)JPEG' ! rtpjpegdepay ! jpegdec ! queue ! kmssink plane-id=102" +ExecStart=/bin/sh -c "gst-launch-1.0 udpsrc port=5600 caps='application/x-rtp, payload=(int)26, clock-rate=(int)90000, media=(string)video, encoding-name=(string)JPEG' ! rtpjpegdepay ! jpegdec ! queue ! kmssink plane-id=54 force-modesetting=true" Restart=always RestartSec=1 From 2145e31bd507d393d9f836256825bc5986104ddd Mon Sep 17 00:00:00 2001 From: consti10 Date: Fri, 3 Nov 2023 01:17:32 +0100 Subject: [PATCH 29/81] Improve UI: 1) More consistent layouting for the (SCAN,ANALYZE,STBC,TX POWER) elements 2) Analyze progress 3) refactor out the qopenhd frequency list --- app/main.cpp | 4 + app/telemetry/settings/frequencyhelper.cpp | 203 ++++--- app/telemetry/settings/frequencyhelper.h | 39 +- app/telemetry/settings/pollutionhelper.cpp | 42 +- app/telemetry/settings/pollutionhelper.h | 13 +- .../settings/wblinksettingshelper.cpp | 144 +---- app/telemetry/settings/wblinksettingshelper.h | 25 - app/telemetry/settings/wifi_channel.h | 252 +++++++++ app/telemetry/telemetry.pri | 1 + qml/qml.qrc | 20 +- .../DialoqueFreqChangeAirGnd.qml | 124 ++++ .../DialoqueFreqChangeArmed.qml | 86 --- .../DialoqueFreqChangeGndOnly.qml | 2 +- .../MavlinkOpenHDWBParamPanel.qml | 528 ++++++++---------- .../openhd_settings/PopupAnalyzeChannels.qml | 278 +++++---- .../openhd_settings/PopupEnableSTBCLDPC.qml | 105 ++-- .../openhd_settings/PopupScanChannels.qml | 135 ++--- .../openhd_settings/PopupTxPowerEditor.qml | 39 +- 18 files changed, 1105 insertions(+), 935 deletions(-) create mode 100644 app/telemetry/settings/wifi_channel.h create mode 100644 qml/ui/configpopup/openhd_settings/DialoqueFreqChangeAirGnd.qml delete mode 100644 qml/ui/configpopup/openhd_settings/DialoqueFreqChangeArmed.qml diff --git a/app/main.cpp b/app/main.cpp index 38baed1f7..95fedff4a 100755 --- a/app/main.cpp +++ b/app/main.cpp @@ -26,6 +26,8 @@ const QVector permissions({"android.permission.INTERNET", #include "telemetry/models/rcchannelsmodel.h" #include "telemetry/settings/mavlinksettingsmodel.h" #include "telemetry/settings/wblinksettingshelper.h" +#include "telemetry/settings/frequencyhelper.h" +#include "telemetry/settings/pollutionhelper.h" #include "osd/speedladder.h" #include "osd/altitudeladder.h" #include "osd/headingladder.h" @@ -282,6 +284,8 @@ int main(int argc, char *argv[]) { engine.rootContext()->setContextProperty("_ohdSystemAirSettingsModel", &MavlinkSettingsModel::instanceAir()); engine.rootContext()->setContextProperty("_ohdSystemGroundSettings", &MavlinkSettingsModel::instanceGround()); engine.rootContext()->setContextProperty("_wbLinkSettingsHelper", &WBLinkSettingsHelper::instance()); + engine.rootContext()->setContextProperty("_frequencyHelper", &FrequencyHelper::instance()); + engine.rootContext()->setContextProperty("_pollutionHelper", &PollutionHelper::instance()); engine.rootContext()->setContextProperty("_fcMavlinkSystem", &FCMavlinkSystem::instance()); engine.rootContext()->setContextProperty("_fcMavlinkAction", &FCAction::instance()); engine.rootContext()->setContextProperty("_fcMavlinkMissionItemsModel", &FCMavlinkMissionItemsModel::instance()); diff --git a/app/telemetry/settings/frequencyhelper.cpp b/app/telemetry/settings/frequencyhelper.cpp index 325679018..22928cb97 100644 --- a/app/telemetry/settings/frequencyhelper.cpp +++ b/app/telemetry/settings/frequencyhelper.cpp @@ -1,79 +1,150 @@ #include "frequencyhelper.h" +#include "wifi_channel.h" -FrequencyHelper::FrequencyHelper() +FrequencyHelper::FrequencyHelper(QObject *parent) : QObject{parent} { } -std::vector FrequencyHelper::get_known_frequency_items() +FrequencyHelper &FrequencyHelper::instance() { - std::vector ret{ - FrequencyItem{-1,2312,false,false,false,-1}, - FrequencyItem{-1,2332,false,false,false,-1}, - FrequencyItem{-1,2352,false,false,false,-1}, - FrequencyItem{-1,2372,false,false,false,-1}, - FrequencyItem{-1,2392,false,false,false,-1}, - // ACTUAL 2G - FrequencyItem{1 ,2412,false,true,false,-1}, - FrequencyItem{5 ,2432,false,true,false,-1}, - FrequencyItem{9 ,2452,false,true,false,-1}, - FrequencyItem{13,2472,false,true,false,-1}, - FrequencyItem{14,2484,false,false,false,-1}, - // ACTUAL 2G end - FrequencyItem{-1,2492,false,false,false,-1}, - FrequencyItem{-1,2512,false,false,false,-1}, - FrequencyItem{-1,2532,false,false,false,-1}, - FrequencyItem{-1,2572,false,false,false,-1}, - FrequencyItem{-1,2592,false,false,false,-1}, - FrequencyItem{-1,2612,false,false,false,-1}, - FrequencyItem{-1,2632,false,false,false,-1}, - FrequencyItem{-1,2652,false,false,false,-1}, - FrequencyItem{-1,2672,false,false,false,-1}, - FrequencyItem{-1,2692,false,false,false,-1}, - FrequencyItem{-1, 2712,false,false,false,-1}, - // 5G begin - FrequencyItem{ 32,5160,false,false,false,-1}, - FrequencyItem{ 36,5180,false,true ,false,-1}, - FrequencyItem{ 40,5200,false,false,false,-1}, - FrequencyItem{ 44,5220,false,true,false,-1}, - FrequencyItem{ 48,5240,false,false,false,-1}, - FrequencyItem{ 52,5260,true,true ,false,-1}, - FrequencyItem{ 56,5280,true,false,false,-1}, - FrequencyItem{ 60,5300,true,true,false,-1}, - FrequencyItem{ 64,5320,true,false,false,-1}, - // big break / part that is not allowed - FrequencyItem{100,5500,true,true,false,-1}, - FrequencyItem{104,5520,true,false,false,-1}, - FrequencyItem{108,5540,true,true,false,-1}, - FrequencyItem{112,5560,true,false,false,-1}, - FrequencyItem{116,5580,true,true,false,-1}, - FrequencyItem{120,5600,true,false,false,-1}, - FrequencyItem{124,5620,true,true,false,-1}, - FrequencyItem{128,5640,true,false,false,-1}, - FrequencyItem{132,5660,true,true,false,-1}, - FrequencyItem{136,5680,true,false,false,-1}, - FrequencyItem{140,5700,false,true,false,1}, - FrequencyItem{144,5720,false,false,false,-1}, - // Here is the weird break - FrequencyItem{149,5745,false,true,true,2}, - FrequencyItem{153,5765,false,false,false,-1}, - FrequencyItem{157,5785,false,true,true,3}, - FrequencyItem{161,5805,false,false,false,-1}, - FrequencyItem{165,5825,false,true,true,4}, - // Depends - FrequencyItem{169,5845,false,false,false,-1}, - FrequencyItem{173,5865,false,true,true,5}, - FrequencyItem{177,5885,false,false,false,-1}, - FrequencyItem{181,5905,false,false,true,-1} - }; + static FrequencyHelper instance{}; + return instance; +} + +QList FrequencyHelper::get_frequencies(bool openhd_bands_only) +{ + QList ret; + if(openhd_bands_only){ + auto tmp=openhd::get_openhd_channels_1_to_5(); + for(auto& channel:tmp){ + ret.push_back(channel.frequency); + } + }else{ + 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); + } + } + } return ret; } -FrequencyHelper::FrequencyItem FrequencyHelper::find_frequency_item(const int frequency) +QList FrequencyHelper::get_frequencies_all_40Mhz() +{ + QList ret; + const auto frequency_items=openhd::get_all_channels_2G_5G(); + for(auto& item:frequency_items){ + if(item.space==openhd::WifiSpace::G2_4){ + if(item.is_legal_at_least_one_country){ + ret.push_back(item.frequency); + } + }else{ + if(item.is_legal_at_least_one_country && item.in_40Mhz_ht40_plus){ + ret.push_back(item.frequency); + } + } + } + return ret; +} + +bool FrequencyHelper::get_frequency_radar(int frequency_mhz) +{ + if(frequency_mhz>=5260 && frequency_mhz<=5680){ + return true; + } + return false; +} + +int FrequencyHelper::get_frequency_openhd_race_band(int frequency_mhz) { - const auto frequency_items=get_known_frequency_items(); - for(const auto& item:frequency_items){ - if(item.frequency==frequency)return item; + // 5700,5745,5785,5825,5865 + if(frequency_mhz==5700){ + return 1; + } + if(frequency_mhz==5745){ + return 2; + } + if(frequency_mhz==5785){ + return 3; + } + if(frequency_mhz==5825){ + return 4; + } + if(frequency_mhz==5865){ + return 5; } - return FrequencyItem{-1,-1,false,false,false}; + return -1; +} + +int FrequencyHelper::get_frequency_channel_nr(int frequency_mhz) +{ + const auto frequency_item=openhd::channel_from_frequency(frequency_mhz); + if(frequency_item.has_value()){ + return frequency_item.value().channel; + } + return -1; +} + +bool FrequencyHelper::set_hw_supported_frequencies_threadsafe(const std::vector supported_channels) +{ + std::lock_guard lock(m_supported_channels_mutex); + if(m_supported_channels!=supported_channels){ + m_supported_channels=supported_channels; + return true; + } + return false; +} + +bool FrequencyHelper::has_valid_supported_frequencies_data() +{ + std::lock_guard lock(m_supported_channels_mutex); + return !m_supported_channels.empty(); +} + +bool FrequencyHelper::hw_supports_frequency_threadsafe(int frequency_mhz) +{ + std::lock_guard lock(m_supported_channels_mutex); + for(const auto supported_freq: m_supported_channels){ + if(supported_freq==frequency_mhz)return true; + } + return false; +} + + +static std::string spaced_string(int number){ + std::stringstream ss; + if(number<100)ss<<" "; + if(number<10)ss<<" "; + ss<channel)<<"] "; + ss< FrequencyHelper::filter_frequencies(QList frequencies, int filter_level) +{ + QList ret; + for(const auto& element:frequencies){ + if(filter_level==2){ + if(element> 3000){ + ret.push_back(element); + } + }else if(filter_level==1){ + if(element< 3000){ + ret.push_back(element); + } + }else{ + ret.push_back(element); + } + } + return ret; } diff --git a/app/telemetry/settings/frequencyhelper.h b/app/telemetry/settings/frequencyhelper.h index ee578e514..20d8fc5a2 100644 --- a/app/telemetry/settings/frequencyhelper.h +++ b/app/telemetry/settings/frequencyhelper.h @@ -1,24 +1,39 @@ #ifndef FREQUENCYHELPER_H #define FREQUENCYHELPER_H +#include "qlist.h" +#include +#include #include -class FrequencyHelper +class FrequencyHelper : public QObject { + Q_OBJECT public: - FrequencyHelper(); - struct FrequencyItem{ - int channel_nr; - int frequency; - bool radar; - bool simple; - bool recommended; - int openhd_raceband; - }; - static std::vector get_known_frequency_items(); - static FrequencyItem find_frequency_item(const int frequency); + explicit FrequencyHelper(QObject *parent = nullptr); + static FrequencyHelper &instance(); + + Q_INVOKABLE QList get_frequencies(bool openhd_bands_only); + Q_INVOKABLE QList get_frequencies_all_40Mhz(); + + Q_INVOKABLE bool get_frequency_radar(int frequency_mhz); + Q_INVOKABLE int get_frequency_openhd_race_band(int frequency_mhz); + Q_INVOKABLE int get_frequency_channel_nr(int frequency_mhz); + // -------------- + Q_INVOKABLE bool hw_supports_frequency_threadsafe(int frequency_mhz); + // + Q_INVOKABLE QString get_frequency_description(int frequency_mhz); + + Q_INVOKABLE QList filter_frequencies(QList frequencies,int filter_level); +public: + bool set_hw_supported_frequencies_threadsafe(const std::vector supported_channels); + bool has_valid_supported_frequencies_data(); +private: + // Written by telemetry, read by UI + std::mutex m_supported_channels_mutex; + std::vector m_supported_channels; }; #endif // FREQUENCYHELPER_H diff --git a/app/telemetry/settings/pollutionhelper.cpp b/app/telemetry/settings/pollutionhelper.cpp index 6dd4d02c4..d2b46fedb 100644 --- a/app/telemetry/settings/pollutionhelper.cpp +++ b/app/telemetry/settings/pollutionhelper.cpp @@ -1,8 +1,9 @@ #include "pollutionhelper.h" #include +#include -PollutionHelper::PollutionHelper() +PollutionHelper::PollutionHelper(QObject *parent) : QObject{parent} { } @@ -51,3 +52,42 @@ std::optional PollutionHelper::threadsafe_get //qDebug()<<"Cannot find pollution for "< frequencies) +{ + QStringList ret; + for(auto& freq:frequencies){ + std::stringstream ss; + ss< frequencies, bool normalize) +{ + QVariantList ret; + for(auto& freq: frequencies){ + auto pollution=threadsafe_get_pollution_for_frequency(freq); + if(pollution.has_value()){ + if(normalize){ + ret.push_back(static_cast(pollution.value().n_foreign_packets_normalized)); + }else{ + ret.push_back(static_cast(pollution.value().n_foreign_packets)); + } + + }else{ + ret.push_back(static_cast(0)); + } + } + return ret; +} + +int PollutionHelper::pollution_get_last_scan_pollution_for_frequency(int frequency) +{ + auto tmp=threadsafe_get_pollution_for_frequency(frequency); + if(tmp.has_value()){ + return tmp.value().n_foreign_packets; + } + return -1; +} diff --git a/app/telemetry/settings/pollutionhelper.h b/app/telemetry/settings/pollutionhelper.h index 555de471f..7b5bbd2c0 100644 --- a/app/telemetry/settings/pollutionhelper.h +++ b/app/telemetry/settings/pollutionhelper.h @@ -4,16 +4,19 @@ #include #include #include +#include #include - +#include +#include // Written by telemetry, read by UI // This atomic behaviour is enough for us - we signal the ui to rebuild itself every time the data changes // The OpenHD ground unit broadcast the whole pollution set during channel scan, filling it as the scan proceeds. -class PollutionHelper +class PollutionHelper: public QObject { + Q_OBJECT public: - PollutionHelper(); + explicit PollutionHelper(QObject *parent = nullptr); static PollutionHelper& instance(); public: struct PollutionElement{ @@ -24,6 +27,10 @@ class PollutionHelper }; void threadsafe_update(const std::vector& values); std::optional threadsafe_get_pollution_for_frequency(int frequency); +public: + Q_INVOKABLE QStringList pollution_frequencies_int_to_qstringlist(QList frequencies); + Q_INVOKABLE QVariantList pollution_frequencies_int_get_pollution(QList frequencies,bool normalize=false); + Q_INVOKABLE int pollution_get_last_scan_pollution_for_frequency(int frequency); private: // Written by telemetry, read by UI std::map m_pollution_elements; diff --git a/app/telemetry/settings/wblinksettingshelper.cpp b/app/telemetry/settings/wblinksettingshelper.cpp index 3e2afe40f..69ac4cdc5 100644 --- a/app/telemetry/settings/wblinksettingshelper.cpp +++ b/app/telemetry/settings/wblinksettingshelper.cpp @@ -86,11 +86,6 @@ void WBLinkSettingsHelper::validate_and_set_air_channel_width_mhz(int channel_wi set_curr_air_channel_width_mhz(channel_width_mhz); } -void WBLinkSettingsHelper::set_simplify_channels(bool enable) -{ - m_simplify_channels=enable; -} - void WBLinkSettingsHelper::process_message_openhd_wifibroadcast_supported_channels(const mavlink_openhd_wifbroadcast_supported_channels_t &msg) { std::vector channels; @@ -102,7 +97,7 @@ void WBLinkSettingsHelper::process_message_openhd_wifibroadcast_supported_channe qDebug()<<"No valid channels from ground station - should never happen"; return; } - if(update_supported_channels(channels)){ + if(FrequencyHelper::instance().set_hw_supported_frequencies_threadsafe(channels)){ qDebug()<<"Supported channels changed"; signal_ui_rebuild_model_when_possible(); } @@ -227,59 +222,6 @@ bool WBLinkSettingsHelper::change_param_ground_only_blocking(QString param_id, i return false; } -static std::string spaced_string(int number){ - std::stringstream ss; - if(number<100)ss<<" "; - if(number<10)ss<<" "; - ss<(keyframe_interval),"KEYFRAME"); @@ -347,22 +289,6 @@ bool WBLinkSettingsHelper::set_param_stbc_ldpc_enable_air_ground() return true; } -bool WBLinkSettingsHelper::update_supported_channels(const std::vector supported_channels) -{ - std::lock_guard lock(m_supported_channels_mutex); - if(m_supported_channels!=supported_channels){ - m_supported_channels=supported_channels; - return true; - } - return false; -} - -bool WBLinkSettingsHelper::has_valid_reported_channel_data() -{ - std::lock_guard lock(m_supported_channels_mutex); - return !m_supported_channels.empty(); -} - void WBLinkSettingsHelper::change_param_air_async(const int comp_id,const std::string param_id,std::variant param_value,const std::string tag) { mavlink_param_ext_set_t command; @@ -415,76 +341,10 @@ void WBLinkSettingsHelper::change_param_air_channel_width_async(int value, bool change_param_air_async(OHD_COMP_ID_LINK_PARAM,PARAM_ID_WB_CHANNEL_WIDTH,static_cast(value),"BWIDTH"); } -QList WBLinkSettingsHelper::get_supported_frequencies() -{ - std::lock_guard lock(m_supported_channels_mutex); - QList ret; - for(auto& channel:m_supported_channels){ - ret.push_back(channel); - } - return ret; -} - -QList WBLinkSettingsHelper::get_supported_frequencies_filtered(int filter_level) -{ - auto supported_frequencies=get_supported_frequencies(); - if(filter_level<=0)return supported_frequencies; - QList ret; - for(auto& frequency: supported_frequencies){ - if(filter_level==1){ - // 40Mhz spacing - auto info=FrequencyHelper::find_frequency_item(frequency); - if(info.simple){ - ret.push_back(frequency); - } - } - } - return ret; -} - -QStringList WBLinkSettingsHelper::pollution_frequencies_int_to_qstringlist(QList frequencies) -{ - QStringList ret; - for(auto& freq:frequencies){ - std::stringstream ss; - ss< frequencies,bool normalize) -{ - QVariantList ret; - for(auto& freq: frequencies){ - auto pollution=PollutionHelper::instance().threadsafe_get_pollution_for_frequency(freq); - if(pollution.has_value()){ - if(normalize){ - ret.push_back(static_cast(pollution.value().n_foreign_packets_normalized)); - }else{ - ret.push_back(static_cast(pollution.value().n_foreign_packets)); - } - - }else{ - ret.push_back(static_cast(0)); - } - } - return ret; -} - -int WBLinkSettingsHelper::pollution_get_last_scan_pollution_for_frequency(int frequency) -{ - auto tmp=PollutionHelper::instance().threadsafe_get_pollution_for_frequency(frequency); - if(tmp.has_value()){ - return tmp.value().n_foreign_packets; - } - return -1; -} - void WBLinkSettingsHelper::signal_ui_rebuild_model_when_possible() { - const bool valid_ground_channel_data=has_valid_reported_channel_data(); + const bool valid_ground_channel_data=FrequencyHelper::instance().has_valid_supported_frequencies_data(); if(m_curr_channel_mhz>0 && m_curr_channel_width_mhz>0 && valid_ground_channel_data){ qDebug()<<"Signal UI Ready & should rebuild "< get_supported_frequencies(); - // To not overload the user, we filter the frequencies a bit - Q_INVOKABLE QList get_supported_frequencies_filtered(int filter_level); - Q_INVOKABLE QStringList pollution_frequencies_int_to_qstringlist(QList frequencies); - Q_INVOKABLE QVariantList pollution_frequencies_int_get_pollution(QList frequencies,bool normalize=false); - Q_INVOKABLE int pollution_get_last_scan_pollution_for_frequency(int frequency); - - Q_INVOKABLE QString get_frequency_description(int frequency_mhz); - Q_INVOKABLE bool get_frequency_radar(int frequency_mhz); - Q_INVOKABLE bool get_frequency_simplify(int frequency_mhz); - Q_INVOKABLE bool get_frequency_reccommended(int frequency_mhz); - Q_INVOKABLE int get_frequency_openhd_race_band(int frequency_mhz); // These params can be changed "on the fly" and are additionally their value(s) are broadcasted // so we can update them completely async, log the result to the user // and use the broadcasted value(s) to update the UI @@ -116,17 +102,6 @@ class WBLinkSettingsHelper : public QObject // Extra Q_INVOKABLE bool set_param_tx_power(bool ground,bool is_tx_power_index,bool is_for_armed_state,int value); Q_INVOKABLE bool set_param_stbc_ldpc_enable_air_ground(); -private: - struct SupportedChannel{ - uint16_t frequency; - int n_foreign_packets; - }; - // Written by telemetry, read by UI - std::mutex m_supported_channels_mutex; - std::vector m_supported_channels; - bool update_supported_channels(const std::vector supported_channels); - bool has_valid_reported_channel_data(); - std::atomic m_simplify_channels=false; private: void signal_ui_rebuild_model_when_possible(); }; diff --git a/app/telemetry/settings/wifi_channel.h b/app/telemetry/settings/wifi_channel.h new file mode 100644 index 000000000..3319ec25d --- /dev/null +++ b/app/telemetry/settings/wifi_channel.h @@ -0,0 +1,252 @@ +// +// Created by consti10 on 11.12.22. +// + +#ifndef OPENHD_OPENHD_OHD_INTERFACE_INC_WIFI_CHANNEL_H_ +#define OPENHD_OPENHD_OHD_INTERFACE_INC_WIFI_CHANNEL_H_ + +#include +#include +#include +#include + + +namespace OHDUtil{ +template +static void vec_append(std::vector& dest, const std::vector& src) { + dest.insert(dest.end(), src.begin(), src.end()); +} +} + +// USefully links: +// https://www.bundesnetzagentur.de/SharedDocs/Downloads/DE/Sachgebiete/Telekommunikation/Unternehmen_Institutionen/Frequenzen/20190705_Frequenzplan_EntwurfStandMai.pdf?__blob=publicationFile&v=1 +// https://en.wikipedia.org/wiki/List_of_WLAN_channels +// https://www.arubanetworks.com/vrd/OutdoorMIMOVRD/wwhelp/wwhimpl/common/html/wwhelp.htm#context=OutdoorMIMOVRD&file=AppA.html + +// NOTE: DO NOT USE CHANNEL NUMBERS ANYWHERE IN CODE - USE FREQUENCIES IN MHZ, SINCE THEY ARE UNIQUE +namespace openhd { + +enum class WifiSpace { G2_4, G5_8 }; + +// Wifi channel and the corresponding frequency, in mHz. +// "standard" : listed under wikipedia or not. +struct WifiChannel { + // frequency in mhz, recommended to use + uint32_t frequency; + // channel corresponding to this frequency, error-prone compared to the frequency since often defined incorrectly and/or for the non-standard AR9271 frequencies there is no standard channel number + int channel; + // weather this is a channel in the 2.4G space or 5.8G space + WifiSpace space; + // weather this channel is listed under wikipedia or not. + // Channels not listed under wikipedia might still work on some cards, given the driver has been modified. generally, they are not legally usable in most countries though. + bool is_standard; + // Weather this channel is legal in at least one country + bool is_legal_at_least_one_country; + // Weather it is legal in at least one country to use 40Mhz on this wifi channel + bool is_legal_any_country_40Mhz; + // Weather we (should / have to, otherwise driver crashes) use HT40+ or HT40- when doing 40Mhz on this channel + bool in_40Mhz_ht40_plus; + // weather this channel is used by openhd or not. + [[nodiscard]] std::string to_string() const { + std::stringstream ss; + ss << (int)frequency << "Mhz [" << channel << "] " + << (space == WifiSpace::G2_4 ? "2.4G" : "5.8G") + << (is_standard ? "" : "nonstandard"); + return ss.str(); + } +}; + +static std::vector get_channels_2G() { + return std::vector{ + // These are not valid 2.4G wifi channel(s) but some cards aparently can do them, too From https://github.com/OpenHD/linux/blob/092115ae6a980feaa09722690891d99da3afb55c/drivers/net/wireless/ath/ath9k/common-init.c#L39 + // NOTE: In OpenHD we never use the channel number (since it is prone to errors, even in the linux kernel) but rather use the frequency in mhz, which is well-defined. Also read https://yo3iiu.ro/blog/?p=1301 + // NOTE: OpenHD does not use channel width <20Mhz, so we ignore a couple of channels here + WifiChannel{2312, -1, WifiSpace::G2_4, false, false, false}, + //WifiChannel{2317, -1, WifiSpace::G2_4, false}, + //WifiChannel{2322, -1, WifiSpace::G2_4, false}, + //WifiChannel{2327, -1, WifiSpace::G2_4, false}, + WifiChannel{2332, -1, WifiSpace::G2_4, false, false, false}, + //WifiChannel{2337, -1, WifiSpace::G2_4, false}, + //WifiChannel{2342, -1, WifiSpace::G2_4, false}, + //WifiChannel{2347, -1, WifiSpace::G2_4, false}, + WifiChannel{2352, -1, WifiSpace::G2_4, false, false, false}, + //WifiChannel{2357, -1, WifiSpace::G2_4, false}, + //WifiChannel{2362, -1, WifiSpace::G2_4, false}, + //WifiChannel{2367, -1, WifiSpace::G2_4, false}, + WifiChannel{2372, -1, WifiSpace::G2_4, false, false, false}, + //WifiChannel{2377, -1, WifiSpace::G2_4, false}, + //WifiChannel{2382, -1, WifiSpace::G2_4, false}, + //WifiChannel{2387, -1, WifiSpace::G2_4, false}, + WifiChannel{2392, -1, WifiSpace::G2_4, false, false, false}, + //WifiChannel{2397, -1, WifiSpace::G2_4, false}, + //WifiChannel{2402, -1, WifiSpace::G2_4, false}, + //WifiChannel{2407, -1, WifiSpace::G2_4, false}, + // Now to the standard Wi-Fi channel(s) + // https://en.wikipedia.org/wiki/List_of_WLAN_channels#2.4_GHz_(802.11b/g/n/ax) + WifiChannel{2412, 1, WifiSpace::G2_4, true, true, true, true}, + //WifiChannel{2417, 2, WifiSpace::G2_4, true}, + //WifiChannel{2422, 3, WifiSpace::G2_4, true}, + //WifiChannel{2427, 4, WifiSpace::G2_4, true}, + WifiChannel{2432, 5, WifiSpace::G2_4, true, true, true, false}, + //WifiChannel{2437, 6, WifiSpace::G2_4, true}, + //WifiChannel{2442, 7, WifiSpace::G2_4, true}, + //WifiChannel{2447, 8, WifiSpace::G2_4, true}, + WifiChannel{2452, 9, WifiSpace::G2_4, true, true, true, true}, + //WifiChannel{2457, 10, WifiSpace::G2_4, true}, + //WifiChannel{2462, 11, WifiSpace::G2_4, true}, + //WifiChannel{2467, 12, WifiSpace::G2_4, true}, + WifiChannel{2472, 13, WifiSpace::G2_4, true, true, true, false}, + // until here it is consistent (5Mhz increments) + // this one is neither allowed in EU nor USA + // (only in Japan under 11b) + WifiChannel{2484, 14, WifiSpace::G2_4, true, true, false}, + // and these are all not valid wlan channels, but the AR9271 can do them anyways + //WifiChannel{2487, -1, WifiSpace::G2_4, false}, + //WifiChannel{2489, -1, WifiSpace::G2_4, false}, + WifiChannel{2492, -1, WifiSpace::G2_4, false, false, false}, + //WifiChannel{2494, -1, WifiSpace::G2_4, false}, + //WifiChannel{2497, -1, WifiSpace::G2_4, false}, + //WifiChannel{2499, -1, WifiSpace::G2_4, false}, + WifiChannel{2512, -1, WifiSpace::G2_4, false, false, false}, + //WifiChannel{2532, -1, WifiSpace::G2_4, false}, + //WifiChannel{2572, -1, WifiSpace::G2_4, false}, + //WifiChannel{2592, -1, WifiSpace::G2_4, false}, + WifiChannel{2612, -1, WifiSpace::G2_4, false, false, false}, + //WifiChannel{2632, -1, WifiSpace::G2_4, false}, + //WifiChannel{2652, -1, WifiSpace::G2_4, false}, + //WifiChannel{2672, -1, WifiSpace::G2_4, false}, + WifiChannel{2692, -1, WifiSpace::G2_4, false, false, false}, + WifiChannel{2712, -1, WifiSpace::G2_4, false, false, false}, + //WifiChannel{2732, -1, WifiSpace::G2_4, false}, + }; +} + + +static std::vector get_channels_5G(){ + return std::vector{ + // https://en.wikipedia.org/wiki/List_of_WLAN_channels#5_GHz_(802.11a/h/j/n/ac/ax) + WifiChannel{5180, 36, WifiSpace::G5_8, true, true, true, true}, + WifiChannel{5200, 40, WifiSpace::G5_8, true, true, true, false}, + WifiChannel{5220, 44, WifiSpace::G5_8, true, true, true, true}, + WifiChannel{5240, 48, WifiSpace::G5_8, true, true, true, false}, + WifiChannel{5260, 52, WifiSpace::G5_8, true, true, true, true}, + WifiChannel{5280, 56, WifiSpace::G5_8, true, true, true, false}, + WifiChannel{5300, 60, WifiSpace::G5_8, true, true, true, true}, + WifiChannel{5320, 64, WifiSpace::G5_8, true, true, true, false}, + // These channel(s) are not valid Wi-Fi channels in all countries + WifiChannel{5340, 68, WifiSpace::G5_8, true, false, false}, // (Only on 20Mhz allowed in some) + WifiChannel{5360, 72, WifiSpace::G5_8, true, false, false}, + WifiChannel{5380, 76, WifiSpace::G5_8, true, false, false}, + WifiChannel{5400, 80, WifiSpace::G5_8, true, false, false}, + WifiChannel{5420, 84, WifiSpace::G5_8, true, false, false}, + WifiChannel{5440, 88, WifiSpace::G5_8, true, false, false}, + WifiChannel{5460, 92, WifiSpace::G5_8, true, false, false}, + WifiChannel{5480, 96, WifiSpace::G5_8, true, false, false}, + // part often disabled end + WifiChannel{5500, 100, WifiSpace::G5_8, true, true, true, true}, + WifiChannel{5520, 104, WifiSpace::G5_8, true, true, true, false}, + WifiChannel{5540, 108, WifiSpace::G5_8, true, true, true, true}, + WifiChannel{5560, 112, WifiSpace::G5_8, true, true, true, false}, + WifiChannel{5580, 116, WifiSpace::G5_8, true, true, true, true}, + WifiChannel{5600, 120, WifiSpace::G5_8, true, true, true, false}, + WifiChannel{5620, 124, WifiSpace::G5_8, true, true, true, true}, + WifiChannel{5640, 128, WifiSpace::G5_8, true, true, true, false}, + WifiChannel{5660, 132, WifiSpace::G5_8, true, true, true, true}, + WifiChannel{5680, 136, WifiSpace::G5_8, true, true, true, false}, + WifiChannel{5700, 140, WifiSpace::G5_8, true, true, true, true}, + WifiChannel{5720, 144, WifiSpace::G5_8, true, true, true, false}, + // There is a gap not usable in between 5720 and 5745 Mhz + // For some reason, there is a 25Mhz jump here. Weird stuff ... + WifiChannel{5745, 149, WifiSpace::G5_8, true, true, true, true}, + WifiChannel{5765, 153, WifiSpace::G5_8, true, true, true, false}, + WifiChannel{5785, 157, WifiSpace::G5_8, true, true, true, true}, + WifiChannel{5805, 161, WifiSpace::G5_8, true, true, true, false}, + WifiChannel{5825, 165, WifiSpace::G5_8, true, true, true, true}, + // starting from here, often disabled territory begins again + WifiChannel{5845, 169, WifiSpace::G5_8, true, true, true, false}, + WifiChannel{5865, 173, WifiSpace::G5_8, true, true, true, true}, + // This one (177) is listed in wikipedia, but not valid in any country - but it works on rtl8812bu + WifiChannel{5885, 177, WifiSpace::G5_8, true, true, true, false}, + // this one does not work on bu, au no idea - for now, hide it + WifiChannel{5905, 181, WifiSpace::G5_8, true, false, false, true}, + }; +}; +// Returns all Wi-Fi channels 5G that are legal in any country +static std::vector get_channels_5G_legal_at_least_one_country(){ + const auto channels=get_channels_5G(); + std::vector ret; + for(auto& channel:channels){ + if(channel.is_legal_at_least_one_country){ + ret.push_back(channel); + } + } + return ret; +} +// Returns all Wi-Fi channels 2.4G that are legal in at least one country +static std::vector get_channels_2G_legal_at_least_one_country(){ + const auto channels=get_channels_2G(); + std::vector ret; + for(auto& channel:channels){ + if(channel.is_legal_at_least_one_country){ + ret.push_back(channel); + } + } + return ret; +} + + +static std::vector get_all_channels_2G_5G() { + std::vector channels{}; + OHDUtil::vec_append(channels, get_channels_2G()); + OHDUtil::vec_append(channels, get_channels_5G()); + return channels; +} + +static std::vector get_all_channel_frequencies(const std::vector& channels) { + std::vector frequencies{}; + frequencies.reserve(channels.size()); + for (const auto& channel : channels) { + frequencies.push_back(channel.frequency); + } + return frequencies; +} + +// Returns the corresponding Wi-Fi Channel if there is one +// since the mavlink setting is an int, this might not always be possible (and the frequency is then 100% not possible) and therefore should be discarded / fixed +static std::optional channel_from_frequency(uint32_t frequency) { + const auto channels = get_all_channels_2G_5G(); + for (const auto& channel : channels) { + if (channel.frequency == frequency) { + return channel; + } + } + return std::nullopt; +} + +static WifiSpace get_space_from_frequency(uint32_t frequency){ + auto channel= channel_from_frequency(frequency); + if(!channel.has_value()){ + return WifiSpace::G5_8; + } + return channel.value().space; +} + +static std::vector frequencies_to_channels(const std::vector& frequencies){ + std::vector ret; + auto channels=get_all_channels_2G_5G(); + for(const auto freq:frequencies){ + auto tmp= channel_from_frequency(freq); + if(tmp.has_value()){ + ret.push_back(tmp.value()); + } + } + return ret; +} + +static std::vector get_openhd_channels_1_to_5(){ + std::vector frequencies={5700,5745,5785,5825,5865}; + return frequencies_to_channels(frequencies); +} + +} +#endif // OPENHD_OPENHD_OHD_INTERFACE_INC_WIFI_CHANNEL_H_ diff --git a/app/telemetry/telemetry.pri b/app/telemetry/telemetry.pri index b5669b9c7..468f00337 100644 --- a/app/telemetry/telemetry.pri +++ b/app/telemetry/telemetry.pri @@ -39,6 +39,7 @@ HEADERS += \ $$PWD/action/impl/xparam.h \ $$PWD/settings/frequencyhelper.h \ $$PWD/settings/pollutionhelper.h \ + $$PWD/settings/wifi_channel.h \ $$PWD/util/geodesi_helper.h \ $$PWD/util/mavlink_enum_to_string.h \ $$PWD//util/openhd_defines.hpp \ diff --git a/qml/qml.qrc b/qml/qml.qrc index 4b21def5a..94655f70c 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -1,33 +1,33 @@ - + ../translations/QOpenHD_en.qm resources/cursors/arrow_512_green.png resources/cursors/arrow_512_transparent.png resources/cursors/arrow_512_white.png resources/cursors/hand_white.png - + ../translations/QOpenHD_de.qm - + ../translations/QOpenHD_ru.qm - + ../translations/QOpenHD_es.qm - + ../translations/QOpenHD_fr.qm - + ../translations/QOpenHD_nl.qm - + ../translations/QOpenHD_ro.qm - + ../translations/QOpenHD_it.qm - + ../translations/QOpenHD_zh.qm @@ -238,7 +238,7 @@ ui/elements/ArmDisarmSlider.qml ui/elements/SimpleProgressBar.qml ui/elements/ButtonGreen.qml - ui/configpopup/openhd_settings/DialoqueFreqChangeArmed.qml + ui/configpopup/openhd_settings/DialoqueFreqChangeAirGnd.qml ui/configpopup/openhd_settings/FreqComboBoxRow.qml ui/configpopup/status/QOpenHDVersionCard.qml ui/elements/CardToast.qml diff --git a/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeAirGnd.qml b/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeAirGnd.qml new file mode 100644 index 000000000..9dc43f634 --- /dev/null +++ b/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeAirGnd.qml @@ -0,0 +1,124 @@ +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Dialogs 1.0 +import QtQuick.Controls.Material 2.12 + +import "../../elements" + +// Dialoque that is shown to the user when the FC is armed and he wants to change frequency +// Once the user clicks the warning away, proceed as if FC is not armed +Card { + id: dialoqueFreqChangeAirGnd + width: 360 + height: 340 + z: 5.0 + anchors.centerIn: parent + cardName: get_card_title_string() + cardNameColor: "black" + visible: false + + property int m_wanted_frequency: -1 + + property bool m_fc_is_armed: true + + function close(){ + visible=false; + enabled=false; + } + + function initialize_and_show_frequency(frequency){ + m_wanted_frequency=frequency + visible=true; + enabled=true; + // Show warning if + if(_fcMavlinkSystem.is_alive && _fcMavlinkSystem.armed){ + m_fc_is_armed=true; + }else{ + m_fc_is_armed=false; + } + } + + function get_card_title_string(){ + return "Frequency "+m_wanted_frequency+"Mhz" + } + + function get_card_body_string(){ + const channel_nr=_frequencyHelper.get_frequency_channel_nr(m_wanted_frequency); + const channel_nr_openhd=_frequencyHelper.get_frequency_openhd_race_band(m_wanted_frequency); + return "Set AIR and GROUND to CHANNEL ["+channel_nr+"]\n"+ + "("+m_wanted_frequency+" Mhz) ?"; + + } + + cardBody: Item{ + height: 200 + width: 320 + + Text{ + id: description + width: parent.width + height: parent.height /2; + leftPadding: 12 + rightPadding: 12 + wrapMode: Text.WordWrap + text: get_card_body_string(); + } + Text{ + anchors.top: description.bottom + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + leftPadding: 12 + rightPadding: 12 + wrapMode: Text.WordWrap + text: "WARNING !\n CHANGING FREQUENCY WHILE ARMED IS NOT RECOMMENDED !"; + color: "red" + visible: m_fc_is_armed + } + } + hasFooter: true + cardFooter: Item { + anchors.fill: parent + RowLayout{ + anchors.fill: parent + + Button{ + Layout.preferredWidth: 150 + text: "CANCEL" + onPressed: { + dialoqueFreqChangeAirGnd.visible=false; + } + } + + Button{ + Layout.preferredWidth: 150 + text: "YES"; + Material.accent: m_fc_is_armed ? Material.Red : Material.Grey + highlighted: m_fc_is_armed ? true : false; + + onPressed: { + var result= _wbLinkSettingsHelper.change_param_air_and_ground_frequency(m_wanted_frequency); + if(result==0){ + _qopenhd.show_toast("SUCCESS"); + dialoqueFreqChangeAirGnd.visible=false; + return; + }else if(result==-1){ + // Air unit rejected + _qopenhd.show_toast("ERROR - AIR REJECTED"); + return; + }else if(result==-2){ + // Couldn't reach air unit + var error_message_not_reachable="Couldn't reach air unit -"; + _qopenhd.show_toast("ERROR -COULDN'T REACH AIR"); + return; + } + // Really really bad + _messageBoxInstance.set_text_and_show("Something went wrong - please use 'FIND AIR UNIT' to fix"); + dialoqueFreqChangeAirGnd.visible=false; + } + } + } + } +} + diff --git a/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeArmed.qml b/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeArmed.qml deleted file mode 100644 index f76ba635f..000000000 --- a/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeArmed.qml +++ /dev/null @@ -1,86 +0,0 @@ -import QtQuick 2.12 -import QtQuick.Controls 2.12 -import QtQuick.Layouts 1.12 -import QtQuick.Dialogs 1.0 -import QtQuick.Controls.Material 2.12 - -import "../../elements" - -// Dialoque that is shown to the user when the FC is armed and he wants to change frequency -// Once the user clicks the warning away, proceed as if FC is not armed -Card { - id: dialoqueFreqChangeArmed - width: 360 - height: 340 - z: 5.0 - anchors.centerIn: parent - cardName: get_card_title_string() - cardNameColor: "black" - visible: false - - property int m_wanted_frequency: -1 - - function close(){ - visible=false; - enabled=false; - } - - function initialize_and_show_frequency(frequency){ - m_wanted_frequency=frequency - m_wanted_channel_width=-1 - m_type=0; - visible=true; - enabled=true; - } - - function get_card_title_string(){ - return "Frequency "+m_wanted_frequency+"Mhz" - } - - function get_card_body_string(){ - return "WARNING ! Changing frequency while armed is not recommended - while unlikely, changing them needs synchronization and therefore can fail, -after which you have to perform a channel scan to reconnect to your air unit."; - } - - cardBody: Item{ - height: 200 - width: 320 - - Text{ - width: parent.width - height: parent.height - leftPadding: 12 - rightPadding: 12 - wrapMode: Text.WordWrap - text: get_card_body_string(); - } - } - hasFooter: true - cardFooter: Item { - anchors.fill: parent - RowLayout{ - anchors.fill: parent - ButtonRed{ - Layout.preferredWidth: 180 - Layout.alignment: Qt.AlignLeft - Layout.leftMargin: 12 - text: qsTr("CONTINUE ANYWAY") - onPressed: { - dialoqueFreqChangeArmed.visible=false - // Call function from MavlinkExtraWBParamPanel - change_frequency_sync_otherwise_handle_error(m_wanted_frequency,true/*ignore armed state*/) - } - } - ButtonGreen{ - Layout.preferredWidth: 140 - Layout.alignment: Qt.AlignRight - Layout.rightMargin: 12 - text: qsTr("Okay") - onPressed: { - dialoqueFreqChangeArmed.visible=false - } - } - } - } -} - diff --git a/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeGndOnly.qml b/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeGndOnly.qml index 70e4dddbe..ed2162fde 100644 --- a/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeGndOnly.qml +++ b/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeGndOnly.qml @@ -40,7 +40,7 @@ Card { property string m_info_string_frequency: "Please use the channel scan to find your air unit, then change frequency."+ "Otherwise, you can manually change your ground station frequency,"+ -"leaving your air unit untouched - thiis can be quicker than a channel scan if you know your air unit frequency." +"leaving your air unit untouched - this can be quicker than a channel scan if you know your air unit frequency." property string m_info_ground_only: "WARNING: This changes your ground unit frequency without changing your air unit frequency !" diff --git a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml index a43cc4acf..38a7b83e2 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml +++ b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml @@ -39,70 +39,56 @@ Rectangle{ for(var i = 0; i < model.count; ++i) if (model.get(i).value===value) return i return -1 } - // try and update the combobox to the retrieved value(value != index) - function update_combobox(_combobox,_value){ - var _index=find_index(_combobox.model,_value) - if(_index >= 0){ - _combobox.currentIndex=_index; - } - } function fc_is_armed(){ return _fcMavlinkSystem.armed } ListModel{ - id: supported_frequencies_model - ListElement {title: "Unknown"; value:-1; radar: false; recommended: false; openhd_raceband_nr: -1; pollution_pps: -1} + id: frequencies_model_all + ListElement {title: "Unknown"; value_frequency_mhz:-1} } - ListModel{ - id: frequencies_model - ListElement {title: "Unknown"; value:-1; radar: false; recommended: false; openhd_raceband_nr: -1; pollution_pps: -1} + id: frequencies_model_openhd_channels_only + ListElement {title: "Unknown"; value_frequency_mhz:-1} } - function show_popup_message(message){ - _messageBoxInstance.set_text_and_show(message) + function create_list_models_frequency(){ + frequencies_model_all.clear(); + const frequencies_all=_frequencyHelper.get_frequencies(false); + for(var i=0;i= 0; + function update_frequency_combobox(){ + if(m_simplify_enable){ + comboBoxFreq.model=frequencies_model_openhd_channels_only; + }else{ + comboBoxFreq.model=frequencies_model_all; + } + if(_wbLinkSettingsHelper.curr_channel_mhz>0){ + var index=find_index(comboBoxFreq.model,_wbLinkSettingsHelper.curr_channel_mhz); + if(index>=0){ + comboBoxFreq.currentIndex=index; }else{ - append_this_value=true; - } - if(append_this_value){ - supported_frequencies_model.append({title: text, value: frequency, radar:radar, recommended: recommended, openhd_raceband_nr: openhd_raceband, pollution_pps: pollution}) + comboBoxFreq.currentIndex=0; + console.log("Seems not to be a valid channel "+_wbLinkSettingsHelper.curr_channel_mhz) } - } - var index=find_index(supported_frequencies_model,_wbLinkSettingsHelper.curr_channel_mhz); - comboBoxFreq.model=supported_frequencies_model - if(index>=0){ - comboBoxFreq.currentIndex=index; }else{ - comboBoxFreq.currentIndex=0; - console.log("Seems not to be a valid channel "+_wbLinkSettingsHelper.curr_channel_mhz) + comboBoxFreq.currentIndex=-1; } } - function create_list_model2(){ - frequencies_model.clear(); - - } // We get notified every time we should re-build the model(s) and their current selection property int m_ui_rebuild_models : _wbLinkSettingsHelper.ui_rebuild_models @@ -112,10 +98,9 @@ Rectangle{ } function function_rebuild_ui(){ + update_frequency_combobox(); console.log("function_rebuild_ui:"+_wbLinkSettingsHelper.ui_rebuild_models); if(_wbLinkSettingsHelper.ui_rebuild_models<=0)return - create_list_model_supported(); - //update_pollution_graph(); popup_analyze_channels.update(); } @@ -125,7 +110,7 @@ Rectangle{ popup_scan_channels.close(); popup_change_tx_power.close(); dialoqueFreqChangeGndOnly.close(); - dialoqueFreqChangeArmed.close(); + dialoqueFreqChangeAirGnd.close(); popup_enable_stbc_ldpc.close(); } @@ -140,51 +125,8 @@ Rectangle{ Component.onCompleted: { close_all_dialoques(); - } - // - - // ------------------- PART HELPER FOR CURRENT LOSS / POLLUTION / THROTTLE BEGIN ------------------- - // ------------------- PART HELPER FOR CURRENT LOSS / POLLUTION / THROTTLE END ------------------- - - - // Changes either the frequency or channel width - // This one need to be synced, so we have ( a bit complicated, but quite natural for the user) dialoque for the cases where we need to handle errors / show a warning - function change_frequency_sync_otherwise_handle_error(frequency_mhz,ignore_armed_state){ - console.log("change_frequency_sync_otherwise_handle_error: "+"FREQ:"+frequency_mhz+"Mhz"); - // Ground needs to be alive and well - if(!_ohdSystemGround.is_alive){ - _messageBoxInstance.set_text_and_show("Ground unit not alive",5); - return; - } - // Air needs to be alive and well - otherwise we show the "do you want to change gnd only" dialoque - if(!_ohdSystemAir.is_alive){ - var error_message_not_alive="AIR Unit not alive -" - dialoqueFreqChangeGndOnly.initialize_and_show_frequency(frequency_mhz,error_message_not_alive); - return; - } - // FC needs to be disarmed - otherwise show warning - const fc_currently_armed = (_fcMavlinkSystem.is_alive && _fcMavlinkSystem.armed)// || true; - if(fc_currently_armed && ignore_armed_state===false){ - dialoqueFreqChangeArmed.initialize_and_show_frequency(frequency_mhz) - return; - } - var result= _wbLinkSettingsHelper.change_param_air_and_ground_frequency(frequency_mhz); - if(result==0){ - var message="Succesfully set air and ground to FREQUENCY: "+frequency_mhz+"Mhz"; - _messageBoxInstance.set_text_and_show(message,5); - return; - }else if(result==-1){ - // Air unit rejected - _messageBoxInstance.set_text_and_show("Air unit does not support this value",5); - return; - }else if(result==-2){ - // Couldn't reach air unit - var error_message_not_reachable="Couldn't reach air unit -" - dialoqueFreqChangeGndOnly.initialize_and_show_frequency(frequency_mhz,error_message_not_reachable); - return; - } - // Really really bad - _messageBoxInstance.set_text_and_show("Something went wrong - please use 'FIND AIR UNIT' to fix"); + create_list_models_frequency(); + update_frequency_combobox(); } function get_text_wifi_tx_power(air){ @@ -220,7 +162,7 @@ Rectangle{ implicitHeight: frequency_area_layout.implicitHeight+5 radius: 10 - GridLayout { + ColumnLayout { id: frequency_area_layout Layout.fillWidth: true Layout.fillHeight: true @@ -233,108 +175,29 @@ Rectangle{ font.bold: true } - ComboBox { - id: comboBoxFreq - model: supported_frequencies_model - textRole: "title" - implicitWidth: elementComboBoxWidth - currentIndex: 0 - delegate: ItemDelegate { - width: comboBoxFreq.width - contentItem: FreqComboBoxRow{ - m_main_text: title - m_selection_tpye: (value===_wbLinkSettingsHelper.curr_channel_mhz) ? 1 : 0 - m_is_2G: value < 3000 && value > 100 - m_show_radar: radar - m_openhd_race_band: openhd_raceband_nr - m_pollution_pps: pollution_pps - } - highlighted: comboBoxFreq.highlightedIndex === index - } - Layout.row: 1 - Layout.column: 0 - /*displayText: { - if(!_ohdSystemGround.is_alive)return "GND NOT ALIVE"; - if(_ohdSystemGround.wb_gnd_operating_mode==1){ - return "SCANNING"; - } - if(_ohdSystemGround.wb_gnd_operating_mode==2){ - return "ANALYZING"; - } - if(!_ohdSystemAir.is_alive){ - return _wbLinkSettingsHelper.curr_channel_mhz+"@"+"N/A"+" Mhz (NO AIR)"; - } - return _wbLinkSettingsHelper.curr_channel_mhz+"@"+_wbLinkSettingsHelper.curr_channel_width_mhz+" Mhz"; - } - onCurrentIndexChanged: { - console.log("Index changed:"+currentIndex); - if(currentIndex<0)return; - var frequency_mhz=supported_frequencies_model.get(currentIndex).value - console.log("Selected frequency: "+frequency_mhz); - if(_wbLinkSettingsHelper.curr_channel_mhz==frequency_mhz){ - console.log("Already at frequency "+frequency_mhz); - return; - } - if(!_ohdSystemAir.is_alive){ - var error_message_not_alive="AIR Unit not alive -" - dialoqueFreqChangeGndOnly.initialize_and_show_frequency(frequency_mhz,error_message_not_alive); - return; - } - // Change the freuquency - } - enabled: _ohdSystemGround.is_alive*/ - } - Button{ - text: "APPLY" - id: buttonSwitchFreq - //enabled: false - onClicked: { - var selectedValue=supported_frequencies_model.get(comboBoxFreq.currentIndex).value - if(selectedValue<=100){ - _messageBoxInstance.set_text_and_show("Please select a valid frequency",5); - return; - } - change_frequency_sync_otherwise_handle_error(selectedValue,-1,false); - } - //Material.background: fc_is_armed() ? Material.Red : Material.Normal; - enabled: _wbLinkSettingsHelper.ui_rebuild_models>=0 && (_ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0) && - (_wbLinkSettingsHelper.curr_channel_mhz!=comboBoxFreq.currentValue); - Layout.row: 1 - Layout.column: 1 - } - Switch{ - Layout.row: 1 - Layout.column: 2 - Layout.columnSpan: 1 - text: "SIMPLIFY" - checked: true - onCheckedChanged: { - if(m_simplify_enable!=checked){ - m_simplify_enable=checked; - function_rebuild_ui(); - } - } - } - ButtonIconInfo{ - Layout.row: 1 - Layout.column: 3 - onClicked: { - var text="SIMPLIFY: Show recommended channels only. These channels usually have the least amount of pollution by WiFi APs and most FPV antennas are tuned to those Frequncies.\n"+ - "OpenHD works best on them in most scenarios,and you can use 20Mhz and 40Mhz dynamically without issues (40Mhz spacing by default).\n"+ - "Otherwise, show all channels supported by harware (ADVANCED USERS ONLY).\n"; - _messageBoxInstance.set_text_and_show(text) - } - } RowLayout{ - Layout.row: 2 - Layout.column: 0 - Layout.fillWidth: true - Layout.fillHeight: true - id: gnd_op_mode_status - //SimpleProgressBar{ - //} - Text{ - text: { + ComboBox { + id: comboBoxFreq + //model: supported_frequencies_model + //model: frequencies_model_openhd_channels_only + textRole: "title" + implicitWidth: elementComboBoxWidth + currentIndex: 0 + delegate: ItemDelegate { + width: comboBoxFreq.width + contentItem: FreqComboBoxRow{ + m_main_text: title + m_selection_tpye: (value_frequency_mhz===_wbLinkSettingsHelper.curr_channel_mhz) ? 1 : 0 + m_is_2G: value_frequency_mhz < 3000 && value_frequency_mhz > 100 + m_show_radar: _frequencyHelper.get_frequency_radar(value_frequency_mhz) + m_openhd_race_band: _frequencyHelper.get_frequency_openhd_race_band(value_frequency_mhz) + m_pollution_pps: _pollutionHelper.pollution_get_last_scan_pollution_for_frequency(value_frequency_mhz) + } + highlighted: comboBoxFreq.highlightedIndex === index + } + Layout.row: 1 + Layout.column: 0 + displayText: { if(!_ohdSystemGround.is_alive)return "GND NOT ALIVE"; if(_ohdSystemGround.wb_gnd_operating_mode==1){ return "SCANNING"; @@ -347,86 +210,151 @@ Rectangle{ } return _wbLinkSettingsHelper.curr_channel_mhz+"@"+_wbLinkSettingsHelper.curr_channel_width_mhz+" Mhz"; } + onActivated: { + console.log("onActivated:"+currentIndex); + if(currentIndex<0)return; + const frequency_mhz=comboBoxFreq.model.get(currentIndex).value_frequency_mhz + console.log("Selected frequency: "+frequency_mhz); + if(!_frequencyHelper.hw_supports_frequency_threadsafe(frequency_mhz)){ + _qopenhd.show_toast("your HW does not support "+frequency_mhz+" Mhz"); + return; + } + if(_wbLinkSettingsHelper.curr_channel_mhz==frequency_mhz){ + console.log("Already at frequency "+frequency_mhz); + return; + } + if(!_ohdSystemAir.is_alive){ + var error_message_not_alive="AIR Unit not alive -" + dialoqueFreqChangeGndOnly.initialize_and_show_frequency(frequency_mhz,error_message_not_alive); + return; + } + // Change the freuquency + dialoqueFreqChangeAirGnd.initialize_and_show_frequency(frequency_mhz); + } + enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0; + } + Switch{ Layout.row: 1 - Layout.column: 0 - verticalAlignment: Text.AlignVCenter + Layout.column: 1 + Layout.columnSpan: 1 + text: "SIMPLIFY" + checked: true + onCheckedChanged: { + if(m_simplify_enable!=checked){ + m_simplify_enable=checked; + function_rebuild_ui(); + } + } + } + ButtonIconInfo{ + Layout.row: 1 + Layout.column: 2 + onClicked: { + var text="Please select a channel / frequency free of noise and interference. The current loss / pollution / throttle stats below can help,"+ + "as well as the analyze channels feature or a frequency analyzer on your phone. SIMPLIFY: Show OpenHD standard channels [1-5] only - they "+ + " often are free of wifi pollution and should be used. Only disable SIMPLIFY if you know exactly why." + _messageBoxInstance.set_text_and_show(text) + } } } - Button{ + + + + RowLayout{ Layout.row: 2 - Layout.column: 1 - id: b_find_air_unit - text: "SCAN" - enabled: _ohdSystemGround.is_alive - onClicked: { - close_all_dialoques(); - popup_scan_channels.open() - } - SequentialAnimation { - running: false - loops: 4 - id: anim_find_air_unit - // Expand the button - PropertyAnimation { - target: b_find_air_unit - property: "scale" - to: 1.5 - duration: 200 - easing.type: Easing.InOutQuad + Layout.column: 0 + Layout.columnSpan: 3 + Button{ + Layout.preferredWidth: 150 + id: b_find_air_unit + text: "SCAN" + enabled: _ohdSystemGround.is_alive + onClicked: { + close_all_dialoques(); + popup_scan_channels.open() } - // Shrink back to normal - PropertyAnimation { - target: b_find_air_unit - property: "scale" - to: 1.0 - duration: 200 - easing.type: Easing.InOutQuad + SequentialAnimation { + running: false + loops: 4 + id: anim_find_air_unit + // Expand the button + PropertyAnimation { + target: b_find_air_unit + property: "scale" + to: 1.5 + duration: 200 + easing.type: Easing.InOutQuad + } + // Shrink back to normal + PropertyAnimation { + target: b_find_air_unit + property: "scale" + to: 1.0 + duration: 200 + easing.type: Easing.InOutQuad + } } } - } - Button{ - Layout.row: 2 - Layout.column: 2 - text: "ANALYZE" - enabled: _ohdSystemGround.is_alive - onClicked: { - close_all_dialoques(); - popup_analyze_channels.open() + Item{ // FILLER + Layout.preferredWidth: 50 + Layout.minimumWidth: 0 } - } - ButtonIconInfo{ - Layout.row: 2 - Layout.column: 3 - onClicked: { - var text="SCAN: Scan for a running openhd air unit (required if you switch between different air / ground stations or re-flash the image.)\n"+ - "ANALYZE: Analyze all channels for WiFi pollution. If any of the default openhd channels is not polluted, they should be used."+ - "NOTE: Analogue FPV or other digital FPV systems won't show up during analyze - read the wiki for more info."; - _messageBoxInstance.set_text_and_show(text) + Button{ + Layout.preferredWidth: 150 + text: "ANALYZE" + enabled: _ohdSystemGround.is_alive + onClicked: { + close_all_dialoques(); + popup_analyze_channels.open() + } + } + ButtonIconInfo{ + onClicked: { + var text="SCAN: Similar to analoque channel scan, find a running air unit by checking all possible channels (frequencies).\n\n"+ + "ANALYZE: Analyze channels for WiFi pollution. Read the wiki for more info."; + _messageBoxInstance.set_text_and_show(text) + } } } - // Row 3 RowLayout{ - Layout.row: 3 - Layout.column: 0 - Layout.columnSpan: 3 Text{ + Layout.preferredHeight: 50 + Layout.preferredWidth: 120 text:{ - "LOSS %:"+_ohdSystemGround.curr_rx_packet_loss_perc + "LOSS:\n"+_ohdSystemGround.curr_rx_packet_loss_perc+"%" } color: _ohdSystemGround.curr_rx_packet_loss_perc > 5 ? "red" : "black" verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true } Text{ + Layout.preferredHeight: 50 + Layout.preferredWidth: 120 text: { - return "POLLUTION pps:"+_ohdSystemGround.wb_link_curr_foreign_pps + return "POLLUTION:\n"+_ohdSystemGround.wb_link_curr_foreign_pps+"pps" } color: _ohdSystemGround.wb_link_curr_foreign_pps > 20 ? "red" : "black" + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true } Text{ + Layout.preferredHeight: 50 + Layout.preferredWidth: 120 text: { - return "THROTTLE:"+_ohdSystemAir.curr_n_rate_adjustments + return "THROTTLE:\n"+_ohdSystemAir.curr_n_rate_adjustments } color: _ohdSystemAir.curr_n_rate_adjustments > 0 ? "red" : "black" + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + ButtonIconInfo{ + onClicked: { + var text="High Loss / Pollution / active throttle hint at a polluted channel." + _messageBoxInstance.set_text_and_show(text) + } } ButtonIconWarning{ visible: /*_ohdSystemAir.is_alive &&*/ (_ohdSystemGround.curr_rx_packet_loss_perc > 5 || _ohdSystemGround.wb_link_curr_foreign_pps > 20 || _ohdSystemAir.curr_n_rate_adjustments > 0) @@ -447,25 +375,22 @@ Rectangle{ color: m_background_color radius: 10 - GridLayout { + RowLayout { id: tx_power_layout Layout.fillWidth: true Layout.fillHeight: true Text{ - Layout.row: 0 - Layout.column: 0 - Layout.columnSpan: 2 text: "TX POWER" font.bold: true } Text{ - Layout.row: 1 - Layout.column: 0 + Layout.preferredWidth: 120 text: "AIR:\n "+get_text_wifi_tx_power(true) + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true } Button{ - Layout.row: 1 - Layout.column: 1 text: "EDIT" enabled: _ohdSystemAir.is_alive onClicked: { @@ -475,13 +400,13 @@ Rectangle{ } } Text{ - Layout.row: 2 - Layout.column: 0 + Layout.preferredWidth: 120 text: "GND:\n"+get_text_wifi_tx_power(false) + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true } Button{ - Layout.row: 2 - Layout.column: 1 text: "EDIT" enabled: _ohdSystemGround.is_alive onClicked: { @@ -490,27 +415,50 @@ Rectangle{ popup_change_tx_power.open() } } + } + } + Rectangle { + implicitWidth: main_scroll_view.width + implicitHeight: stbc_ldpc_layout.implicitHeight + id: stbc_ldpc_background + color: m_background_color + radius: 10 + + RowLayout { + id: stbc_ldpc_layout + Layout.fillWidth: true + Layout.fillHeight: true // STBC / LDPC Text{ width: 200 - Layout.row: 0 - Layout.column: 3 - Layout.columnSpan: 2 text: "ADVANCED (STBC,LDPC)" font.bold: true horizontalAlignment: Qt.AlignHCenter } Text{ - Layout.row: 1 - Layout.column: 3 + Layout.preferredWidth: 120 text: "AIR:\n"+get_text_stbc_ldpc(true); + verticalAlignment: Qt.AlignVCenter horizontalAlignment: Qt.AlignHCenter + font.bold: true } Text{ - Layout.row: 2 - Layout.column: 3 + Layout.preferredWidth: 120 text: "GND:\n"+get_text_stbc_ldpc(false); + verticalAlignment: Qt.AlignVCenter horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + + Button{ + text: "EDIT"; + //enabled: true + enabled: _ohdSystemAir.is_alive && _ohdSystemGround.is_alive && (_wbLinkSettingsHelper.ui_rebuild_models>=0) && + (_ohdSystemGround.wb_stbc_enabled!=true || _ohdSystemGround.wb_lpdc_enabled!=true || _ohdSystemAir.wb_stbc_enabled!=true || _ohdSystemAir.wb_lpdc_enabled!=true); + onClicked: { + close_all_dialoques(); + popup_enable_stbc_ldpc.open() + } } ButtonIconInfo{ Layout.row: 1 @@ -521,46 +469,8 @@ Rectangle{ "and you need to re-flash your air / ground unit to recover !"); } } - Button{ - Layout.row: 2 - Layout.column: 4 - text: "EDIT"; - enabled: true - //enabled: _ohdSystemAir.is_alive && _ohdSystemGround.is_alive && (_wbLinkSettingsHelper.ui_rebuild_models>=0) && - // (_ohdSystemGround.wb_stbc_enabled!=true || _ohdSystemGround.wb_lpdc_enabled!=true || _ohdSystemAir.wb_stbc_enabled!=true || _ohdSystemAir.wb_lpdc_enabled!=true); - onClicked: { - close_all_dialoques(); - popup_enable_stbc_ldpc.open() - } - } } } - // - /*Rectangle { - implicitWidth: main_scroll_view.width - implicitHeight: tx_power_layout.implicitHeight - id: rpi_cam_selector_layout_background - color: m_background_color - radius: 10 - - GridLayout { - id: rpi_cam_selector_layout - Layout.fillWidth: true - Layout.fillHeight: true - Text{ - Layout.row: 0 - Layout.column: 0 - Layout.columnSpan: 2 - text: "RPI CAM SELECTOR" - font.bold: true - } - Button{ - Layout.row: 1 - Layout.column: 0 - text: "EDIT" - } - } - }*/ } } @@ -582,7 +492,7 @@ Rectangle{ DialoqueFreqChangeGndOnly{ id: dialoqueFreqChangeGndOnly } - DialoqueFreqChangeArmed{ - id: dialoqueFreqChangeArmed + DialoqueFreqChangeAirGnd{ + id: dialoqueFreqChangeAirGnd } } diff --git a/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml b/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml index da187a13a..223fa488f 100644 --- a/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml +++ b/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml @@ -28,7 +28,10 @@ Rectangle{ border.width: 3 property bool m_normalize_data: false; - property int m_chart_view_minimum_width: 1280-200; + property int m_chart_view_minimum_width: 1280; + property int m_chart_view_minimum_width2: 640; + + property bool m_chart_enlarged: false; function open(){ visible=true @@ -42,153 +45,180 @@ Rectangle{ pollution_chart.update_pollution_graph(); } + ListModel{ + id: model_filter + ListElement {title: "NO FILTER"; value: 0} + ListElement {title: "2.4G ONLY"; value: 1} + ListElement {title: "5.8G ONLY"; value: 2} + } + property string m_info_string: "Analyze channels for pollution by wifi access points.\n"+ "NOTE: This only gives a hint at free channels, using a proper channel analyzer (e.g. on the phone) is recommended !\n"+ "In short: Any frequency with red bars (small or big) should not be used, unless there are no options / other reasons to do so." - GridLayout{ - id: top_elements - //width: parent.width - anchors.left: parent.left - anchors.leftMargin: 5 - anchors.right: parent.right - anchors.rightMargin: 5 - + ColumnLayout{ + id: main_layout + anchors.fill: parent + anchors.leftMargin: 10 + anchors.rightMargin: 10 - Text{ // TITLE - Layout.row: 0 - Layout.column: 0 - Layout.columnSpan: 3 + Item{ Layout.fillWidth: true - Layout.preferredHeight: 50 - Layout.minimumHeight: 20 - text: "ANALYZE CHANNELS (POLLUTION)"; - verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignHCenter - } - - Button{ - Layout.row: 0 - Layout.column: 3 - Layout.alignment: Qt.AlignRight - text: "CLOSE" - onClicked: { - if(_ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==2){ - _qopenhd.show_toast("STILL ANALYZING, PLEASE WAIT ...",); - return; + Layout.preferredHeight: 60 + Text{ // TITLE + anchors.fill: parent + text: "ANALYZE (POLLUTION)"; + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + Button{ + anchors.right: parent.right + anchors.top: parent.top + text: "CLOSE" + onClicked: { + if(_ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==2){ + _qopenhd.show_toast("STILL ANALYZING, PLEASE WAIT ...",); + return; + } + close() } - close() } } - SimpleProgressBar{ - Layout.row: 1 - Layout.column: 0 - Layout.preferredWidth: 400 - Layout.minimumWidth: 100 - Layout.preferredHeight: 40 - impl_curr_progress_perc: _wbLinkSettingsHelper.analyze_progress_perc - impl_show_progress_text: true - } - Button{ - Layout.row: 1 - Layout.column: 1 - Layout.alignment: Qt.AlignLeft - text: "START" - onClicked: { - var result=_wbLinkSettingsHelper.start_analyze_channels() - if(result!==true){ - _qopenhd.show_toast("Busy,please try again later",true); - }else{ - _qopenhd.show_toast("STARTED, THIS MIGHT TAKE A WHILE !"); + RowLayout{ + SimpleProgressBar{ + Layout.preferredWidth: 400 + Layout.minimumWidth: 100 + Layout.preferredHeight: 40 + impl_curr_progress_perc: _wbLinkSettingsHelper.analyze_progress_perc + impl_show_progress_text: true + } + Button{ + Layout.alignment: Qt.AlignLeft + text: "START" + onClicked: { + var result=_wbLinkSettingsHelper.start_analyze_channels() + if(result!==true){ + _qopenhd.show_toast("Busy,please try again later",true); + }else{ + _qopenhd.show_toast("STARTED, THIS MIGHT TAKE A WHILE !"); + } } + enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0 } - enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0 - } - Text{ - Layout.row: 2 - Layout.column: 0 - Layout.preferredWidth: 200 - Layout.minimumWidth: 50 - text: { - if(_wbLinkSettingsHelper.current_analyze_frequency<=0){ - return ""; + ButtonIconInfo{ + Layout.alignment: Qt.AlignLeft + onClicked: { + _messageBoxInstance.set_text_and_show(m_info_string) } - return "Analyzed "+_wbLinkSettingsHelper.current_analyze_frequency+" Mhz ..."; } - verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignHCenter } - - Switch{ - Layout.row: 2 - Layout.column: 1 - text: "NORMALIZE" - checked: m_normalize_data - onCheckedChanged: { - m_normalize_data=checked - pollution_chart.update_pollution_graph(); + RowLayout{ + Text{ + Layout.preferredWidth: 200 + Layout.minimumWidth: 100 + Layout.preferredHeight: 40 + text: { + if(_wbLinkSettingsHelper.current_analyze_frequency<=0){ + return ""; + } + return "Analyzed "+_wbLinkSettingsHelper.current_analyze_frequency+" Mhz ..."; + } + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter } - } - ButtonIconInfo{ - Layout.row: 2 - Layout.column: 2 - Layout.alignment: Qt.AlignLeft - onClicked: { - _messageBoxInstance.set_text_and_show(m_info_string) + ComboBox { + Layout.preferredWidth: 150 + Layout.minimumWidth: 50 + id: comboBoxFilter + model: model_filter + textRole: "title" + onCurrentIndexChanged: { + pollution_chart.update_pollution_graph(); + } + } + Switch{ + text: "NORMALIZE" + checked: m_normalize_data + onCheckedChanged: { + m_normalize_data=checked + pollution_chart.update_pollution_graph(); + } } } - // Filler - Item{ + ScrollView{ + id: chart_scroll_view Layout.fillWidth: true - } - } - - ScrollView{ - anchors.top: top_elements.bottom - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: parent.right - contentWidth: pollution_chart.width - ScrollBar.horizontal.interactive: true - - ChartView { - id: pollution_chart - title: "WiFi pollution estimate" - width: main_background.width>m_chart_view_minimum_width ? main_background.width : m_chart_view_minimum_width; - height: parent.height - legend.alignment: Qt.AlignBottom - antialiasing: true - - function update_pollution_graph(){ - //const frequencies_list = _wbLinkSettingsHelper.get_pollution_qstringlist(); - //bar_axis_x.categories=frequencies_list; - //const supported_frequencies = _wbLinkSettingsHelper.get_supported_frequencies(); - const supported_frequencies = _wbLinkSettingsHelper.get_supported_frequencies_filtered(1); - var categories = _wbLinkSettingsHelper.pollution_frequencies_int_to_qstringlist(supported_frequencies); - var values = _wbLinkSettingsHelper.pollution_frequencies_int_get_pollution(supported_frequencies,m_normalize_data); - bar_axis_x.categories=categories; - bar_set.values=values; - } - - BarSeries { - id: hm_bar_series - axisX: BarCategoryAxis { - id: bar_axis_x - categories: ["DUMMY0", "DUMMY1", "DUMMY3", "DUMMY4" ] - //min: "0" - //max: "500" + Layout.fillHeight: true + contentWidth: pollution_chart.width + ScrollBar.horizontal.interactive: true + + ChartView { + id: pollution_chart + title: "WiFi pollution estimate" + //width: main_background.width>m_chart_view_minimum_width ? main_background.width : m_chart_view_minimum_width; + width: { + const screen_width = main_layout.width; + if(comboBoxFilter.currentIndex==0){ + return screen_width>m_chart_view_minimum_width ? screen_width : m_chart_view_minimum_width; + } + if(comboBoxFilter.currentIndex==1){ + return screen_width + } + return screen_width>m_chart_view_minimum_width2 ? screen_width : m_chart_view_minimum_width2; + } + //width: m_chart_enlarged ? 1280 : main_background.width + height: parent.height + legend.alignment: Qt.AlignBottom + antialiasing: true + + function update_pollution_graph(){ + //const frequencies_list = _wbLinkSettingsHelper.get_pollution_qstringlist(); + //bar_axis_x.categories=frequencies_list; + //const supported_frequencies = _wbLinkSettingsHelper.get_supported_frequencies(); + const all_40Mhz_frequencies_unfiltered=_frequencyHelper.get_frequencies_all_40Mhz(); + const all_40Mhz_frequencies = _frequencyHelper.filter_frequencies(all_40Mhz_frequencies_unfiltered,comboBoxFilter.currentIndex); + var categories = _pollutionHelper.pollution_frequencies_int_to_qstringlist(all_40Mhz_frequencies); + var values = _pollutionHelper.pollution_frequencies_int_get_pollution(all_40Mhz_frequencies,m_normalize_data); + bar_axis_x.categories=categories; + bar_set.values=values; } - BarSet { - id: bar_set - label: "Pollution (pps)"; - values: [5,10,3,100] - //values: [0,0,0,0] - color: "red" + + BarSeries { + id: hm_bar_series + axisX: BarCategoryAxis { + id: bar_axis_x + categories: ["DUMMY0", "DUMMY1", "DUMMY3", "DUMMY4" ] + //min: "0" + //max: "500" + } + BarSet { + id: bar_set + label: "Pollution (pps)"; + values: [5,10,3,100] + //values: [0,0,0,0] + color: "red" + } } } + /*Button{ + anchors.top: pollution_chart.top + anchors.left: pollution_chart.left + text: "ENLARGE" + onClicked: { + m_chart_enlarged = !m_chart_enlarged; + } + }*/ } + // Filler + //Item{ + // Layout.fillWidth: true + // Layout.fillHeight: true + //} } + + } diff --git a/qml/ui/configpopup/openhd_settings/PopupEnableSTBCLDPC.qml b/qml/ui/configpopup/openhd_settings/PopupEnableSTBCLDPC.qml index e9ba0a982..ec850adda 100644 --- a/qml/ui/configpopup/openhd_settings/PopupEnableSTBCLDPC.qml +++ b/qml/ui/configpopup/openhd_settings/PopupEnableSTBCLDPC.qml @@ -52,49 +52,33 @@ Rectangle{ ListElement {title: "GND: 2 RF PATHS / ANTENNAS"; value: 2} } - GridLayout{ + ColumnLayout{ id: main_row_layout anchors.fill: parent anchors.leftMargin: 10 anchors.rightMargin: 10 - Text{ - id: stbc_warning_text - Layout.row: 0 - Layout.column: 0 - text: "WARNING:\n YOU NEED TO REFLASH YOUR AIR / GROUND UNIT\nIF YOU ENABLE STBC / LDPC ON UNSUPPORTED HW"; - color: "red" - width: main_background.width - height: 200 - horizontalAlignment: Qt.AlignHCenter - verticalAlignment: Qt.AlignVCenter - font.pixelSize: 15 - wrapMode: Text.WordWrap - SequentialAnimation { - running: false - loops: 3 - id: anim_warn_user_stbc - // Expand the button - PropertyAnimation { - target: stbc_warning_text - property: "scale" - to: 2.0 - duration: 300 - easing.type: Easing.InOutQuad - } - // Shrink back to normal - PropertyAnimation { - target: stbc_warning_text - property: "scale" - to: 1.0 - duration: 300 - easing.type: Easing.InOutQuad + Item{ + Layout.fillWidth: true + Layout.preferredHeight: 80 + Text{ // TITLE + anchors.fill: parent + text: "ADVANCED - STBC / LDPC" + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + Button{ + text: "CLOSE" + anchors.top: parent.top + anchors.right: parent.right + onClicked: { + close() } } } + ComboBox { - Layout.row: 1 - Layout.column: 0 id: comboBoxNAntennasAir Layout.minimumWidth: 100 Layout.preferredWidth: 450 @@ -108,8 +92,6 @@ Rectangle{ } } ComboBox { - Layout.row: 2 - Layout.column: 0 id: comboBoxNAntennasGnd Layout.minimumWidth: 100 Layout.preferredWidth: 450 @@ -124,8 +106,6 @@ Rectangle{ } Button{ id: button_enable - Layout.row: 3 - Layout.column: 0 text: "ENABLE" enabled: comboBoxNAntennasAir.currentIndex==2 && comboBoxNAntennasGnd.currentIndex==2; font.pixelSize: 14 @@ -139,11 +119,45 @@ Rectangle{ } } Text{ - Layout.row: 4 - Layout.column: 0 + Layout.fillWidth: true + Layout.preferredHeight: 40 visible: !button_enable.enabled text: "CAN ONLY BE ENABLED IF BOTH AIR AND GND UNIT HAVE 2 RF PATHS / ANTENNAS"; font.pixelSize: 14 + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignLeft + } + Text{ + id: stbc_warning_text + text: "WARNING:\n YOU NEED TO REFLASH YOUR AIR / GROUND UNIT\nIF YOU ENABLE STBC / LDPC ON UNSUPPORTED HW"; + color: "red" + Layout.fillWidth: true + height: 200 + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.pixelSize: 15 + wrapMode: Text.WordWrap + SequentialAnimation { + running: false + loops: 3 + id: anim_warn_user_stbc + // Expand the button + PropertyAnimation { + target: stbc_warning_text + property: "scale" + to: 2.0 + duration: 300 + easing.type: Easing.InOutQuad + } + // Shrink back to normal + PropertyAnimation { + target: stbc_warning_text + property: "scale" + to: 1.0 + duration: 300 + easing.type: Easing.InOutQuad + } + } } Item{ // Filler Layout.row: 5 @@ -154,16 +168,5 @@ Rectangle{ } // ---------------- } - - Button{ - text: "CLOSE" - anchors.top: parent.top - anchors.right: parent.right - onClicked: { - close() - } - } - - } diff --git a/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml b/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml index 04e70941b..3b4879578 100644 --- a/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml +++ b/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml @@ -41,75 +41,68 @@ Rectangle{ ListElement {title: "All 5.8G channels (slow)"; value: 2} } - /*Rectangle{ - implicitWidth:main_grid_layout.width - implicitHeight: main_grid_layout.height - color: "#ADD8E6" - }*/ - - GridLayout{ - id: main_grid_layout + ColumnLayout{ anchors.fill: parent anchors.leftMargin: 10 anchors.rightMargin: 10 - Text{ // TITLE - Layout.row: 0 - Layout.column: 0 - Layout.columnSpan: 2 + Item{ Layout.fillWidth: true - Layout.preferredHeight: 50 - Layout.minimumHeight: 20 - text: "SCAN (FIND AIR UNIT)"; - verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignHCenter - } - - Button{ - Layout.alignment: Qt.AlignRight - Layout.row: 0 - Layout.column: 3 - text: "CLOSE" - onClicked: { - if(_ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==1){ - _qopenhd.show_toast("STILL SCANNING,PLEASE WAIT ..."); - return; + Layout.preferredHeight: 80 + Text{ // TITLE + anchors.fill: parent + text: "SCAN (FIND AIR UNIT)"; + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + Button{ + anchors.right: parent.right + anchors.top: parent.top + text: "CLOSE" + onClicked: { + if(_ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==1){ + _qopenhd.show_toast("STILL SCANNING,PLEASE WAIT ..."); + return; + } + close() } - close() } } - - - SimpleProgressBar{ - Layout.row: 1 - Layout.column: 0 - Layout.preferredWidth: 400 - Layout.minimumWidth: 100 - Layout.preferredHeight: 40 - impl_curr_progress_perc: _wbLinkSettingsHelper.scan_progress_perc - impl_show_progress_text: true - } - Button{ - Layout.row: 1 - Layout.column: 1 - text: "START" - enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0 - onClicked: { - var how_many_freq_bands=comboBoxWhichFrequencyToScan.currentIndex - var how_many_bandwidths = 2; - console.log("Initate channel scan "+how_many_freq_bands+","+how_many_bandwidths) - var result = _wbLinkSettingsHelper.start_scan_channels(how_many_freq_bands,how_many_bandwidths) - if(result){ - _qopenhd.show_toast("Channel scan started, please wait",true) - }else{ - console.log("Cannot initiate channel scan"); - _qopenhd.show_toast("Busy,please try again later",true) + RowLayout{ + SimpleProgressBar{ + Layout.preferredWidth: 400 + Layout.minimumWidth: 100 + Layout.preferredHeight: 40 + impl_curr_progress_perc: _wbLinkSettingsHelper.scan_progress_perc + impl_show_progress_text: true + } + Button{ + text: "START" + enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0 + onClicked: { + var how_many_freq_bands=comboBoxWhichFrequencyToScan.currentIndex + var how_many_bandwidths = 2; + console.log("Initate channel scan "+how_many_freq_bands+","+how_many_bandwidths) + var result = _wbLinkSettingsHelper.start_scan_channels(how_many_freq_bands,how_many_bandwidths) + if(result){ + _qopenhd.show_toast("Channel scan started, please wait",true) + }else{ + console.log("Cannot initiate channel scan"); + _qopenhd.show_toast("Busy,please try again later",true) + } + } + } + ButtonIconInfo{ + onClicked: { + _messageBoxInstance.set_text_and_show("Initiate Channel Scan (Find a running air unit). Similar to analogue TX / RX, this listens on each channel for a short time"+ + " to find a running openhd air unit."+ + "Quick if you are only using the 5 OpenHD recommended channels, otherwise"+ + " please specify the generic band and give it some time (There are a ton of possible channels, especially in 5.8G)") } } } ComboBox { - Layout.row: 2 - Layout.column: 0 Layout.preferredWidth: 400 Layout.minimumWidth: 100 id: comboBoxWhichFrequencyToScan @@ -122,16 +115,6 @@ Rectangle{ } enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0 } - ButtonIconInfo{ - Layout.row: 2 - Layout.column: 1 - onClicked: { - _messageBoxInstance.set_text_and_show("Initiate Channel Scan (Find a running air unit). Similar to analogue TX / RX, this listens on each channel for a short time"+ - " to find a running openhd air unit."+ - "Quick if you are only using the 5 OpenHD recommended channels, otherwise"+ - " please specify the generic band and give it some time (There are a ton of possible channels, especially in 5.8G)") - } - } Text{ Layout.row: 3 Layout.column: 0 @@ -146,22 +129,4 @@ Rectangle{ Layout.fillHeight: true } } - /*Button{ - //Layout.alignment: Qt.AlignRight - //Layout.row: 0 - //Layout.column: 3 - anchors.top: parent.top - anchors.right: parent.right - anchors.topMargin: 5 - anchors.rightMargin: 10 - text: "CLOSE" - onClicked: { - if(_ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==1){ - _qopenhd.show_toast("STILL SCANNING"); - return; - } - close() - } - }*/ - } diff --git a/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml b/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml index 30a5fb1a8..2106a5856 100644 --- a/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml +++ b/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml @@ -228,17 +228,28 @@ Rectangle{ //Layout.minimumWidth: 300 //Layout.preferredWidth: 600 - Text{ // TITLE + Item{ Layout.row: 0 Layout.column: 0 - Layout.columnSpan: 2 + Layout.columnSpan: 4 Layout.fillWidth: true - Layout.preferredHeight: 50 - Layout.minimumHeight: 20 - text: m_is_air ? "AIR TX Power" : "GND TX power"; - verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignHCenter - font.pixelSize: 18 + Layout.preferredHeight: 80 + Text{ // TITLE + anchors.fill: parent + text: "TX POWER "+(m_is_air ? "AIR" : "GROUND"); + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + Button{ + text: "CLOSE" + anchors.top: parent.top + anchors.right: parent.right + anchors.rightMargin: m_margin + onClicked: { + close() + } + } } // Text{ @@ -418,16 +429,4 @@ Rectangle{ } // ---------------- } - - Button{ - text: "CLOSE" - anchors.top: parent.top - anchors.right: parent.right - anchors.rightMargin: m_margin - onClicked: { - close() - } - } - - } From 8226822426c1a7aa9c13fde393d121fd3a79036c Mon Sep 17 00:00:00 2001 From: consti10 Date: Fri, 3 Nov 2023 14:11:01 +0100 Subject: [PATCH 30/81] Improve UI: 1) More consistent layouting for the (SCAN,ANALYZE,STBC,TX POWER) elements 2) Analyze progress 3) refactor out the qopenhd frequency list 4) recording on bitrate widget (centralize camera stuff around it) --- app/telemetry/models/camerastreammodel.cpp | 56 +++++++-- app/telemetry/models/camerastreammodel.h | 8 +- .../settings/wblinksettingshelper.cpp | 2 +- qml/ui/elements/AppSettings.qml | 1 + qml/ui/elements/SimpleLeftRightText.qml | 3 +- qml/ui/widgets/VideoBitrateWidgetGeneric.qml | 108 +++++++++++++++--- 6 files changed, 145 insertions(+), 33 deletions(-) diff --git a/app/telemetry/models/camerastreammodel.cpp b/app/telemetry/models/camerastreammodel.cpp index e85af8de0..6c1101612 100644 --- a/app/telemetry/models/camerastreammodel.cpp +++ b/app/telemetry/models/camerastreammodel.cpp @@ -34,6 +34,50 @@ CameraStreamModel &CameraStreamModel::instance(int cam_index) assert(false); } +QString CameraStreamModel::camera_type_to_string(int camera_type) +{ + if(camera_type<=0)return "Unknown"; + if(camera_type==1)return "DUMMY"; + if(camera_type==2)return "RPI_CSI_MMAL"; + if(camera_type==3)return "RPI_CSI_VEYE_V4l2"; + if(camera_type==4)return "RPI_CSI_LIBCAMERA"; + if(camera_type==5)return "JETSON_CSI"; + if(camera_type==6)return "ROCKCHIP_CSI"; + if(camera_type==7)return "ALLWINNER_CSI"; + if(camera_type==8)return "UVC (USB)"; + if(camera_type==9)return "UVC_H264"; + if(camera_type==10)return "IP"; + if(camera_type==11)return "ROCK_HDMI"; + if(camera_type==12)return "CUSTOM UNMANAGED"; + return "ERROR"; +} + +QString CameraStreamModel::camera_status_to_string(int camera_status) +{ + if(camera_status<0)return "N/A"; + if(camera_status==0)return "X"; + if(camera_status==1)return "streaming"; + if(camera_status==2)return "restarting"; + return "ERROR"; +} + +QString CameraStreamModel::camera_codec_to_string(int camera_codec) +{ + if(camera_codec<0)return "ERROR"; + if(camera_codec==0)return "h264"; + if(camera_codec==1)return "h265"; + if(camera_codec==2)return "mjpeg"; + return "ERROR"; +} + +QString CameraStreamModel::camera_recording_mode_to_string(int recording_mode) +{ + if(recording_mode<0)return "n/a"; + if(recording_mode==0)return "not active"; + if(recording_mode==1)return "active"; + return "error"; +} + void CameraStreamModel::update_mavlink_openhd_stats_wb_video_air(const mavlink_openhd_stats_wb_video_air_t &msg) { const auto curr_recommended_bitrate_kbits=msg.curr_recommended_bitrate; @@ -88,6 +132,7 @@ void CameraStreamModel::update_mavlink_openhd_camera_status_air(const mavlink_op set_curr_curr_keyframe_interval(msg.encoding_keyframe_interval); set_air_recording_active(msg.air_recording_active); set_camera_type(msg.cam_type); + set_encoding_codec(msg.encoding_format); { std::stringstream ss; ss<<(int)msg.stream_w<<"x"<<(int)msg.stream_h<<"@"<=std::chrono::seconds(3)){ - m_last_hud_message_camera_status=std::chrono::steady_clock::now(); - std::stringstream log; - log<<(secondary ? "CAM2" : "CAM1"); - log<<" is restarting, please wait"; - HUDLogMessagesModel::instance().add_message_info(log.str().c_str()); - } - } } void CameraStreamModel::update_mavlink_openhd_stats_wb_video_air_fec_performance(const mavlink_openhd_stats_wb_video_air_fec_performance_t &msg) diff --git a/app/telemetry/models/camerastreammodel.h b/app/telemetry/models/camerastreammodel.h index 7531f207e..7263e5ca1 100644 --- a/app/telemetry/models/camerastreammodel.h +++ b/app/telemetry/models/camerastreammodel.h @@ -54,7 +54,8 @@ class CameraStreamModel : public QObject L_RO_PROP(QString,air_tx_packets_per_second_and_bits_per_second,set_air_tx_packets_per_second_and_bits_per_second,"N/A") // UI might change slightly depending on the camera type L_RO_PROP(int,camera_type,set_camera_type,-1) - L_RO_PROP(int,camera_status,set_camera_status,-1) + L_RO_PROP(int,camera_status,set_camera_status,-1) + L_RO_PROP(int,encoding_codec,set_encoding_codec,-1) // // These are generated by the OpenHD ground unit // @@ -64,6 +65,11 @@ class CameraStreamModel : public QObject L_RO_PROP(qint64,count_blocks_recovered,set_count_blocks_recovered,-1) L_RO_PROP(qint64,count_fragments_recovered,set_count_fragments_recovered,-1) L_RO_PROP(QString,curr_fec_decode_time_avg_min_max,set_curr_fec_decode_time_avg_min_max,"avg na, min na, max na") +public: + Q_INVOKABLE QString camera_type_to_string(int camera_type); + Q_INVOKABLE QString camera_status_to_string(int camera_status); + Q_INVOKABLE QString camera_codec_to_string(int camera_codec); + Q_INVOKABLE QString camera_recording_mode_to_string(int recording_mode); // public: // generated by wb / link diff --git a/app/telemetry/settings/wblinksettingshelper.cpp b/app/telemetry/settings/wblinksettingshelper.cpp index 69ac4cdc5..ec14ac3e0 100644 --- a/app/telemetry/settings/wblinksettingshelper.cpp +++ b/app/telemetry/settings/wblinksettingshelper.cpp @@ -319,7 +319,7 @@ void WBLinkSettingsHelper::change_param_air_async(const int comp_id,const std::s if(std::holds_alternative(param_value)){ ss<(param_value); }else{ - ss<(param_value); + ss<(param_value); } ss<<",please check uplink"; HUDLogMessagesModel::instance().add_message_warning(ss.str().c_str()); diff --git a/qml/ui/elements/AppSettings.qml b/qml/ui/elements/AppSettings.qml index 9217bf5b1..52daf95fb 100644 --- a/qml/ui/elements/AppSettings.qml +++ b/qml/ui/elements/AppSettings.qml @@ -137,6 +137,7 @@ Settings { property bool bitrate_declutter: false property double bitrate_warn: 0 property double bitrate_caution: 0 + property bool camera_bitrate_widget_show_recording: true // property bool qrenderstats_show: false property bool qrenderstats_declutter: false diff --git a/qml/ui/elements/SimpleLeftRightText.qml b/qml/ui/elements/SimpleLeftRightText.qml index 87784663b..2d824585d 100644 --- a/qml/ui/elements/SimpleLeftRightText.qml +++ b/qml/ui/elements/SimpleLeftRightText.qml @@ -2,7 +2,8 @@ import QtQuick 2.12 Item { width: parent.width - height: 24 + //height: 24 + height: 20 property string m_left_text: "FILL ME" property string m_right_text: "FILL ME" diff --git a/qml/ui/widgets/VideoBitrateWidgetGeneric.qml b/qml/ui/widgets/VideoBitrateWidgetGeneric.qml index dc0a5ed87..051b49f3b 100644 --- a/qml/ui/widgets/VideoBitrateWidgetGeneric.qml +++ b/qml/ui/widgets/VideoBitrateWidgetGeneric.qml @@ -29,7 +29,7 @@ BaseWidget { hasWidgetDetail: true hasWidgetAction: true - widgetActionHeight: 400 + widgetActionHeight: 450 property var m_camera_stream_model: m_is_for_primary_camera ? _cameraStreamModelPrimary : _cameraStreamModelSecondary @@ -108,6 +108,17 @@ BaseWidget { } } + ListModel{ + id: resolutions_model + ListElement {title: "480p60(16:9)"; value: "848x480@60"} + ListElement {title: "480p60(4:3)"; value: "640x480@60"} + ListElement {title: "720p49(16:9)"; value: "1280x720@49"} + ListElement {title: "720p60(4:3)"; value: "960x720@60"} + ListElement {title: "1080p30(16:9)"; value: "1920x1080@30"} + ListElement {title: "1080p30(4:3)"; value: "1440x1080@30"} + ListElement {title: "1080p49(4:3)"; value: "1440x1080@49"} + } + //----------------------------- DETAIL BELOW ---------------------------------- @@ -120,6 +131,27 @@ BaseWidget { BaseWidgetDefaultUiControlElements{ id: idBaseWidgetDefaultUiControlElements + Item { + width: 230 + height: 32 + Text { + text: qsTr("Show RED recording active") + color: "white" + height: parent.height + font.bold: true + font.pixelSize: detailPanelFontPixels + anchors.left: parent.left + verticalAlignment: Text.AlignVCenter + } + Switch { + width: 32 + height: parent.height + anchors.rightMargin: 6 + anchors.right: parent.right + checked: settings.camera_bitrate_widget_show_recording + onCheckedChanged: settings.camera_bitrate_widget_show_recording = checked + } + } } } @@ -134,15 +166,50 @@ BaseWidget { width:200 SimpleLeftRightText{ - m_left_text: qsTr("Res@Framerate:") - m_right_text: m_camera_stream_model.curr_set_video_format_and_codec + m_left_text: qsTr("Status:") + m_right_text: { + if(!_ohdSystemAir.is_alive)return "no air"; + return _cameraStreamModelPrimary.camera_status_to_string(m_camera_stream_model.camera_status); + } + } + SimpleLeftRightText{ + m_left_text: qsTr("Type:") + m_right_text: { + if(!_ohdSystemAir.is_alive)return "n/a"; + return _cameraStreamModelPrimary.camera_type_to_string(m_camera_stream_model.camera_type); + } + } + SimpleLeftRightText{ + m_left_text: qsTr("Codec:") + m_right_text: { + if(!_ohdSystemAir.is_alive)return "n/a"; + return _cameraStreamModelPrimary.camera_codec_to_string(m_camera_stream_model.encoding_codec); + } } - //SimpleLeftRightText{ - // m_left_text: "" - // m_right_text: "" - //} - Item{ + ComboBox{ + id: resolution_fps_cb + model: resolutions_model + textRole: "title" + width: 200 + Layout.preferredWidth: 200 + Layout.minimumWidth: 200 + height: 50 + currentIndex: 0 + displayText: { + if(!_ohdSystemAir.is_alive)return "Res@fps N/A"; + return m_curr_video_format; + } + onActivated: { + console.log("onActivated:"+currentIndex); + if(currentIndex<0)return; + const resolution=model.get(currentIndex).value + console.log("Selected resolution: "+resolution); + set_camera_resolution(resolution); + } + enabled: _ohdSystemAir.is_alive; + } + /*Item{ width: parent.width height: 150 //color: "green" @@ -187,7 +254,7 @@ BaseWidget { highlighted: m_curr_video_format=="1440x1080@30" } } - } + }*/ SimpleLeftRightText{ m_left_text: qsTr("Bitrate SET:") m_right_text: m_camera_stream_model.curr_recomended_video_bitrate_string @@ -236,10 +303,7 @@ BaseWidget { m_left_text: qsTr("AIR RECORD:"); m_right_text: { if(!_ohdSystemAir.is_alive)return "N/A"; - if(m_camera_recording_mode){ - return "RECORDING"; - } - return "NOT ACTIVE" + return _cameraStreamModelPrimary.camera_recording_mode_to_string(m_camera_stream_model.air_recording_active); } } // For camera 1 @@ -275,12 +339,6 @@ BaseWidget { } } } - - /*Item{ - id: placeholder - width:parent.width - height: 10 - }*/ Item { width: parent.width height: 32 @@ -338,5 +396,17 @@ BaseWidget { style: Text.Outline styleColor: settings.color_glow } + + Rectangle{ + width: 12 + height: width + radius: width + color: "red"; + anchors.right: camera_icon.left + anchors.rightMargin: 2 + anchors.verticalCenter: parent.verticalCenter + visible: settings.camera_bitrate_widget_show_recording && m_camera_is_currently_recording + } + } } From 9fc3d34af1b59655348454ea56bdb81dd0910f35 Mon Sep 17 00:00:00 2001 From: consti10 Date: Mon, 6 Nov 2023 11:14:26 +0100 Subject: [PATCH 31/81] fix secondary video minimize maximize --- qml/main.qml | 20 -- qml/qml.qrc | 1 + qml/ui/HUDOverlayGrid.qml | 405 +++++++++++----------- qml/video/SecondaryVideoGStreamer.qml | 121 +++++-- qml/video/SecondaryVideoGstreamerPane.qml | 22 ++ 5 files changed, 321 insertions(+), 248 deletions(-) create mode 100644 qml/video/SecondaryVideoGstreamerPane.qml diff --git a/qml/main.qml b/qml/main.qml index dfbefe530..4c31079be 100755 --- a/qml/main.qml +++ b/qml/main.qml @@ -93,26 +93,6 @@ ApplicationWindow { } } - // Loads the proper (platform-dependent) video widget for the secondary video, if enabled. - // r.n we only have a gstreamer - qmlglsink implementation for it - Loader { - anchors.fill: parent - z: 2.0 - anchors.bottom: parent.bottom - source: { - if(settings.dev_qopenhd_n_cameras>1){ - // R.N the only implementation for secondary video - if (QOPENHD_ENABLE_GSTREAMER_QMLGLSINK){ - return "../video/SecondaryVideoGStreamer.qml"; - }else{ - console.warn("No secondary video implementation") - } - }else{ - console.debug("Scondary video disabled"); - } - return ""; - } - } ColorPicker { id: colorPicker diff --git a/qml/qml.qrc b/qml/qml.qrc index 94655f70c..7bcddbe5b 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -259,5 +259,6 @@ ui/widgets/PerformanceHorizonWidget2.qml ui/configpopup/status/StatusCardsColumn.qml ui/elements/SimpleLeftRightText.qml + video/SecondaryVideoGstreamerPane.qml diff --git a/qml/ui/HUDOverlayGrid.qml b/qml/ui/HUDOverlayGrid.qml index f97e40870..6cafca85b 100644 --- a/qml/ui/HUDOverlayGrid.qml +++ b/qml/ui/HUDOverlayGrid.qml @@ -13,6 +13,8 @@ import "./widgets/map" import "../resources" as Resources import "./elements" +import "../video" + Item { id: hudOverlayGrid focus: true @@ -199,29 +201,29 @@ Item { } Keys.onPressed: (event)=> { - console.log("HUDOverlayGrid::Key was pressed:"+event); - if (event.key == Qt.Key_Return) { - //console.log("enter was pressed"); - event.accepted = true; - dummy_joystick_enter() - }else if(event.key == Qt.Key_Left){ - //console.log("left was pressed") - event.accepted=true; - dummy_joystick_left(); - }else if(event.key == Qt.Key_Right){ - //console.log("right was pressed") - event.accepted=true; - dummy_joystick_right(); - }else if(event.key == Qt.Key_Up){ - //console.log("up was pressed") - event.accepted=true; - dummy_joystick_up() - }else if(event.key == Qt.Key_Down){ - //console.log("down was pressed") - event.accepted=true; - dummy_joystick_down() - } - } + console.log("HUDOverlayGrid::Key was pressed:"+event); + if (event.key == Qt.Key_Return) { + //console.log("enter was pressed"); + event.accepted = true; + dummy_joystick_enter() + }else if(event.key == Qt.Key_Left){ + //console.log("left was pressed") + event.accepted=true; + dummy_joystick_left(); + }else if(event.key == Qt.Key_Right){ + //console.log("right was pressed") + event.accepted=true; + dummy_joystick_right(); + }else if(event.key == Qt.Key_Up){ + //console.log("up was pressed") + event.accepted=true; + dummy_joystick_up() + }else if(event.key == Qt.Key_Down){ + //console.log("down was pressed") + event.accepted=true; + dummy_joystick_down() + } + } Image { id: settingsButton @@ -252,224 +254,227 @@ Item { color: "transparent" } } + SecondaryVideoGStreamer{ + id: secondary_video + } Item{ id: actual_hud_elements width: parent.width height: parent.height - // By default on top row - // -------------------------------------------------------------------------- - LinkDownRSSIWidget { - id: downlink - m_next_item: record_video_widget - } - RecordVideoWidget { - id: record_video_widget - } - WBLinkRateControlWidget{ - id: wBLinkRateControlWidget - } - // exp - QRenderStatsWidget { - id: qRenderStatsWidget - } - VideoBitrateWidgetPrimary { - id: bitrate1 - } - VideoBitrateWidgetSecondary { - id: bitrate2 - } - SOCStatusWidgetAir { - id: air_status - } - SOCStatusWidgetGround { - id: ground_status - } - LinkUpRSSIWidget { - id: uplink - } - Sidebar{ - id: sidebar - } - // ---------------------------------------------------------------------------- - // TODO SORT ME + // By default on top row + // -------------------------------------------------------------------------- + LinkDownRSSIWidget { + id: downlink + m_next_item: record_video_widget + } + RecordVideoWidget { + id: record_video_widget + } + WBLinkRateControlWidget{ + id: wBLinkRateControlWidget + } + // exp + QRenderStatsWidget { + id: qRenderStatsWidget + } + VideoBitrateWidgetPrimary { + id: bitrate1 + } + VideoBitrateWidgetSecondary { + id: bitrate2 + } + SOCStatusWidgetAir { + id: air_status + } + SOCStatusWidgetGround { + id: ground_status + } + LinkUpRSSIWidget { + id: uplink + } + Sidebar{ + id: sidebar + } + // ---------------------------------------------------------------------------- + // TODO SORT ME - // + 0% cpu - MessageHUD { - id: messageHUD - } + // + 0% cpu + MessageHUD { + id: messageHUD + } - GroundPowerWidget { - id: groundPowerWidget - } + GroundPowerWidget { + id: groundPowerWidget + } - // + 0% cpu - AirBatteryWidget { - id: air_battery - } + // + 0% cpu + AirBatteryWidget { + id: air_battery + } - // + 0% cpu - FlightModeWidget { - id: flight_mode - } + // + 0% cpu + FlightModeWidget { + id: flight_mode + } - // + 0% cpu - GPSWidget { - id: gps - } + // + 0% cpu + GPSWidget { + id: gps + } - // + 0% cpu - HomeDistanceWidget { - id: home_distance - } + // + 0% cpu + HomeDistanceWidget { + id: home_distance + } - // + 0% cpu - FlightTimeWidget { - id: flight_timer - } + // + 0% cpu + FlightTimeWidget { + id: flight_timer + } - // + 0% cpu - FlightDistanceWidget { - id: flight_distance - } + // + 0% cpu + FlightDistanceWidget { + id: flight_distance + } - // + 0% cpu - FlightMahWidget { - id: flight_mah - } + // + 0% cpu + FlightMahWidget { + id: flight_mah + } - // + 0% cpu - FlightMahKmWidget { - id: flight_mah_km - } + // + 0% cpu + FlightMahKmWidget { + id: flight_mah_km + } - // + 0% cpu - ImuTempWidget { - id: imu_temp - } + // + 0% cpu + ImuTempWidget { + id: imu_temp + } - // + 0% cpu - PressTempWidget { - id: press_temp - } - RCRssiWidget { - id: rc_rssi_widget - } + // + 0% cpu + PressTempWidget { + id: press_temp + } + RCRssiWidget { + id: rc_rssi_widget + } - AirspeedTempWidget { - id: airspeed_temp - } + AirspeedTempWidget { + id: airspeed_temp + } - // + 0% cpu - EscTempWidget { - id: esc_temp - } + // + 0% cpu + EscTempWidget { + id: esc_temp + } - // + 12% cpu - HorizonWidget { - id: horizonWidget - } + // + 12% cpu + HorizonWidget { + id: horizonWidget + } - PerformanceHorizonWidget2{ - id: performanceHorizonWidget - } + PerformanceHorizonWidget2{ + id: performanceHorizonWidget + } - // + 7% cpu - FpvWidget { - id: fpvWidget - } + // + 7% cpu + FpvWidget { + id: fpvWidget + } - // + 4% cpu - AltitudeWidget { - id: altitudeWidget - } + // + 4% cpu + AltitudeWidget { + id: altitudeWidget + } - // + 0% cpu - AltitudeSecondWidget { - id: altitudesecondWidget - } + // + 0% cpu + AltitudeSecondWidget { + id: altitudesecondWidget + } - // + 17% cpu - SpeedWidget { - id: speedWidget - } + // + 17% cpu + SpeedWidget { + id: speedWidget + } - SpeedSecondWidget { - id: speedSecondWidget - } + SpeedSecondWidget { + id: speedSecondWidget + } - // +3% cpu - HeadingWidget { - id: headingWidget - } + // +3% cpu + HeadingWidget { + id: headingWidget + } - // + 0% cpu - ArrowWidget { - id: arrowWidget - } + // + 0% cpu + ArrowWidget { + id: arrowWidget + } - // + 0% cpu - ThrottleWidget { - id: throttleWidget - scale: 0.7 - } + // + 0% cpu + ThrottleWidget { + id: throttleWidget + scale: 0.7 + } - // + 0% cpu - ControlWidget { - id: controlWidget - // scale: 0.7 - } + // + 0% cpu + ControlWidget { + id: controlWidget + // scale: 0.7 + } - // + 0% cpu - GPIOWidget { - id: gpioWidget - } + // + 0% cpu + GPIOWidget { + id: gpioWidget + } - // + 3% cpu - VibrationWidget { - id: vibrationWidget - } + // + 3% cpu + VibrationWidget { + id: vibrationWidget + } - VerticalSpeedSimpleWidget{ - id: vssimpleWidget - } - VerticalSpeedGaugeWidget{ - id: vsgaugewidget - } + VerticalSpeedSimpleWidget{ + id: vssimpleWidget + } + VerticalSpeedGaugeWidget{ + id: vsgaugewidget + } - // + 0% cpu - WindWidget { - id: windWidget - } + // + 0% cpu + WindWidget { + id: windWidget + } - // + 3% cpu - RollWidget { - id: rollWidget - } + // + 3% cpu + RollWidget { + id: rollWidget + } - MissionWidget { - id: missionWidget - } + MissionWidget { + id: missionWidget + } - AoaWidget { - id: aoaWidget - } + AoaWidget { + id: aoaWidget + } - MapWidget { - id: mapWidget - } + MapWidget { + id: mapWidget + } - ExampleWidget { - id: exampleWidget - } + ExampleWidget { + id: exampleWidget + } - DistanceSensorWidget{ - id: distancesensorwidget - } + DistanceSensorWidget{ + id: distancesensorwidget + } - UAVTimeWiget{ - id: uavtimewidget - } + UAVTimeWiget{ + id: uavtimewidget + } } // Extra element - allows customizing the OSD color(s) and more diff --git a/qml/video/SecondaryVideoGStreamer.qml b/qml/video/SecondaryVideoGStreamer.qml index 49af6a844..245cc0507 100644 --- a/qml/video/SecondaryVideoGStreamer.qml +++ b/qml/video/SecondaryVideoGStreamer.qml @@ -3,9 +3,6 @@ import QtGraphicalEffects 1.12 import QtQuick.Controls 2.15 import QtQuick.Layouts 1.15 -// QT creator might show "not found" on this import, this is okay, annoying qt specifics -import org.freedesktop.gstreamer.GLVideoItem 1.0; - import OpenHD 1.0 import "../ui/elements" @@ -16,6 +13,7 @@ import "../ui/elements" // Also, it is nice to automatically have all features needed for the secondary video like scaling, resizing ... Item { + visible: settings.dev_qopenhd_n_cameras>1 // We use the full screen since while usually small in the lower left corner, the secondary video can be resized anchors.fill: parent anchors.left: parent.left @@ -41,44 +39,116 @@ Item { // This is for debugging / showing the video widget area at run time Rectangle{ + z: 0.0 id: video_holder width: get_video_width() height: get_video_height() anchors.bottom: parent.bottom - anchors.left: parent.left - color: "red" - visible: popup.visible + //width: get_video_width() + //height: get_video_height() + //anchors.bottom: parent.bottom + //anchors.left: parent.left + //color: "red" + //color: popup.opened ? "red" : "transparent" + color: "gray" + opacity: 0.1 + //visible: popup.visible } - GstGLVideoItem { - id: secondaryVideoGStreamer - objectName: "secondaryVideoGStreamer" - - width: get_video_width() - height: get_video_height() - // We are always anchored to the lower left corner - anchors.bottom: parent.bottom - anchors.left: parent.left + Text{ + anchors.fill: video_holder + text: { + if (QOPENHD_ENABLE_GSTREAMER_QMLGLSINK){ + return "WAITING FOR\nSECONDARY VIDEO"; + } + return "NOT\nAVAILABLE"; + } + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.pixelSize: 12 + color: "black" + } - Component.onCompleted: { - console.log("secondaryVideoGStreamer (Qmlglsink) created") - _secondary_video_gstreamer_qml.check_common_mistakes_then_init(secondaryVideoGStreamer) + Loader { + z: 0.0 + anchors.fill: video_holder + source: { + if(settings.dev_qopenhd_n_cameras>1){ + // R.N the only implementation for secondary video + if (QOPENHD_ENABLE_GSTREAMER_QMLGLSINK){ + return "SecondaryVideoGstreamerPane.qml"; + }else{ + console.warn("No secondary video implementation") + } + }else{ + console.debug("Scondary video disabled"); + } + return ""; } + } + /*Button{ + id: button_maximize + text: "\uf31e"; + width: 24 + height: 24 + anchors.right: video_holder.right + anchors.top: video_holder.top + onClicked: { + console.log("Button clicked"); + has_been_maximized = !has_been_maximized; + } + }*/ + /*Button{ + text:"S" + anchors.right: button_maximize.left + anchors.rightMargin: 2 + anchors.top: button_maximize.top + onClicked: { + popup.open() + } + visible: has_been_maximized + }*/ + Text{ + id: button_maximize + color: "white" + text: "\uf31e" + font.family: "Font Awesome 5 Free" + width: 40 + height: 40 + anchors.right: video_holder.right + anchors.top: video_holder.top + font.pixelSize: 19 + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter MouseArea { anchors.fill: parent onClicked: { - //console.log("Clicked") - // Toggle between maximized and minimized has_been_maximized = !has_been_maximized; } - onPressAndHold: { - console.log("onPressAndHold"); - // open the popup containing the settings + } + } + Text{ + id: button_settings + color: "white" + text: "\uf013" + font.family: "Font Awesome 5 Free" + width: 40 + height: 40 + anchors.right: button_maximize.left + anchors.rightMargin: 2 + anchors.top: button_maximize.top + font.pixelSize: 19 + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + MouseArea { + anchors.fill: parent + onClicked: { popup.open() } } } + property int rowHeight: 64 // This popup allows changing the settings for this element Popup { @@ -88,12 +158,7 @@ Item { width: 500 height: 300 modal: true - //focus: true closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside - /*background: Rectangle { - color: "gray" - border.color: "black" - }*/ Pane{ ColumnLayout { anchors.fill: parent diff --git a/qml/video/SecondaryVideoGstreamerPane.qml b/qml/video/SecondaryVideoGstreamerPane.qml new file mode 100644 index 000000000..4b7b2df0a --- /dev/null +++ b/qml/video/SecondaryVideoGstreamerPane.qml @@ -0,0 +1,22 @@ +import QtQuick 2.12 +import QtGraphicalEffects 1.12 +import QtQuick.Controls 2.15 +import QtQuick.Layouts 1.15 + +// QT creator might show "not found" on this import, this is okay, annoying qt specifics +import org.freedesktop.gstreamer.GLVideoItem 1.0; + +import OpenHD 1.0 + +import "../ui/elements" + +GstGLVideoItem { + id: secondaryVideoGStreamer + objectName: "secondaryVideoGStreamer" + z: 0.0 + + Component.onCompleted: { + console.log("secondaryVideoGStreamer (Qmlglsink) created") + _secondary_video_gstreamer_qml.check_common_mistakes_then_init(secondaryVideoGStreamer) + } +} From ed9ae3c679980285dcc8dc79f5dac0ef9790d607 Mon Sep 17 00:00:00 2001 From: consti10 Date: Mon, 6 Nov 2023 11:29:40 +0100 Subject: [PATCH 32/81] fix secondary video minimize maximize --- qml/ui/HUDOverlayGrid.qml | 4 ++++ qml/video/SecondaryVideoGStreamer.qml | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/qml/ui/HUDOverlayGrid.qml b/qml/ui/HUDOverlayGrid.qml index 6cafca85b..24a974371 100644 --- a/qml/ui/HUDOverlayGrid.qml +++ b/qml/ui/HUDOverlayGrid.qml @@ -254,9 +254,13 @@ Item { color: "transparent" } } + + // Dirty, in between a HUD element and not a HUD element + // placed here because of the focus issue SecondaryVideoGStreamer{ id: secondary_video } + Item{ id: actual_hud_elements width: parent.width diff --git a/qml/video/SecondaryVideoGStreamer.qml b/qml/video/SecondaryVideoGStreamer.qml index 245cc0507..90a530e56 100644 --- a/qml/video/SecondaryVideoGStreamer.qml +++ b/qml/video/SecondaryVideoGStreamer.qml @@ -61,12 +61,12 @@ Item { if (QOPENHD_ENABLE_GSTREAMER_QMLGLSINK){ return "WAITING FOR\nSECONDARY VIDEO"; } - return "NOT\nAVAILABLE"; + return "SECONDARY VIEO\nNOT AVAILABLE\nON THIS PLATFORM"; } verticalAlignment: Qt.AlignVCenter horizontalAlignment: Qt.AlignHCenter - font.pixelSize: 12 - color: "black" + font.pixelSize: 14 + color: "white" } Loader { From 76630edf198b5c36d30ec59d9704d15d010e0951 Mon Sep 17 00:00:00 2001 From: consti10 Date: Mon, 6 Nov 2023 12:01:41 +0100 Subject: [PATCH 33/81] fix secondary video minimize maximize --- qml/video/SecondaryVideoGStreamer.qml | 38 ++++++++++++++++++++------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/qml/video/SecondaryVideoGStreamer.qml b/qml/video/SecondaryVideoGStreamer.qml index 90a530e56..46203e77a 100644 --- a/qml/video/SecondaryVideoGStreamer.qml +++ b/qml/video/SecondaryVideoGStreamer.qml @@ -13,6 +13,7 @@ import "../ui/elements" // Also, it is nice to automatically have all features needed for the secondary video like scaling, resizing ... Item { + id: secondary_video_item visible: settings.dev_qopenhd_n_cameras>1 // We use the full screen since while usually small in the lower left corner, the secondary video can be resized anchors.fill: parent @@ -23,23 +24,29 @@ Item { property bool has_been_maximized: false function get_video_width(){ + var video_width = settings.secondary_video_minimized_width; if(has_been_maximized){ - var maximize_factor = settings.secondary_video_maximize_factor_perc / 100; - return settings.secondary_video_minimized_width * maximize_factor; + const maximize_factor = settings.secondary_video_maximize_factor_perc / 100; + video_width = video_width * maximize_factor; } - return settings.secondary_video_minimized_width; + const screen_width = secondary_video_item.width; + return video_width < screen_width ? video_width : screen_width; + //return video_width; } function get_video_height(){ + var video_height = settings.secondary_video_minimized_height; if(has_been_maximized){ - var maximize_factor = settings.secondary_video_maximize_factor_perc / 100; - return settings.secondary_video_minimized_height * maximize_factor; + const maximize_factor = settings.secondary_video_maximize_factor_perc / 100; + video_height = video_height * maximize_factor; } - return settings.secondary_video_minimized_height; + const screen_height = secondary_video_item.height; + return video_height < screen_height ? video_height : screen_height; + //return video_height; } // This is for debugging / showing the video widget area at run time Rectangle{ - z: 0.0 + z: 1.0 id: video_holder width: get_video_width() height: get_video_height() @@ -53,6 +60,19 @@ Item { color: "gray" opacity: 0.1 //visible: popup.visible + MouseArea { + anchors.fill: parent + onClicked: { + console.log("onClicked"); + has_been_maximized = !has_been_maximized; + } + onPressAndHold: { + console.log("onPressAndHold"); + // open the popup containing the settings + popup.open() + } + } + } Text{ @@ -109,7 +129,7 @@ Item { } visible: has_been_maximized }*/ - Text{ + /*Text{ id: button_maximize color: "white" text: "\uf31e" @@ -147,7 +167,7 @@ Item { popup.open() } } - } + }*/ property int rowHeight: 64 // This popup allows changing the settings for this element From 4906a66bca4b411f54a2efffc4699672fd6202aa Mon Sep 17 00:00:00 2001 From: consti10 Date: Mon, 6 Nov 2023 12:17:23 +0100 Subject: [PATCH 34/81] Flow settings OSD -> Widgets first --- qml/ui/configpopup/ConfigPopup.qml | 4 ---- .../qopenhd_settings/AppDevSettingsView.qml | 1 - .../AppGeneralSettingsView.qml | 1 - .../AppScreenSettingsView.qml | 1 - .../qopenhd_settings/AppSettingsPanel.qml | 20 +++++++------------ .../AppVehicleSettingsView.qml | 1 - .../qopenhd_settings/AppVideoSettingsView.qml | 1 - .../AppWidgetSettingsView.qml | 1 - 8 files changed, 7 insertions(+), 23 deletions(-) diff --git a/qml/ui/configpopup/ConfigPopup.qml b/qml/ui/configpopup/ConfigPopup.qml index 2af0d6f00..c57603de9 100644 --- a/qml/ui/configpopup/ConfigPopup.qml +++ b/qml/ui/configpopup/ConfigPopup.qml @@ -38,10 +38,6 @@ Rectangle { hudOverlayGrid.regain_focus(); } - function showAppSettings(i) { - console.log("TEST show app settings:"+i); - } - function side_bar_regain_focus(){ sidebar.focus = true; } diff --git a/qml/ui/configpopup/qopenhd_settings/AppDevSettingsView.qml b/qml/ui/configpopup/qopenhd_settings/AppDevSettingsView.qml index 535f60caa..6034c8132 100755 --- a/qml/ui/configpopup/qopenhd_settings/AppDevSettingsView.qml +++ b/qml/ui/configpopup/qopenhd_settings/AppDevSettingsView.qml @@ -18,7 +18,6 @@ ScrollView { width: parent.width height: parent.height contentHeight: manageColumn.height - visible: appSettingsBar.currentIndex == 5 clip: true diff --git a/qml/ui/configpopup/qopenhd_settings/AppGeneralSettingsView.qml b/qml/ui/configpopup/qopenhd_settings/AppGeneralSettingsView.qml index 89a963cba..5c4b53972 100755 --- a/qml/ui/configpopup/qopenhd_settings/AppGeneralSettingsView.qml +++ b/qml/ui/configpopup/qopenhd_settings/AppGeneralSettingsView.qml @@ -16,7 +16,6 @@ ScrollView { width: parent.width height: parent.height contentHeight: generalColumn.height - visible: appSettingsBar.currentIndex == 0 clip: true diff --git a/qml/ui/configpopup/qopenhd_settings/AppScreenSettingsView.qml b/qml/ui/configpopup/qopenhd_settings/AppScreenSettingsView.qml index a100bd914..60915821b 100755 --- a/qml/ui/configpopup/qopenhd_settings/AppScreenSettingsView.qml +++ b/qml/ui/configpopup/qopenhd_settings/AppScreenSettingsView.qml @@ -16,7 +16,6 @@ ScrollView { width: parent.width height: parent.height contentHeight: screenColumn.height - visible: appSettingsBar.currentIndex == 3 clip: true diff --git a/qml/ui/configpopup/qopenhd_settings/AppSettingsPanel.qml b/qml/ui/configpopup/qopenhd_settings/AppSettingsPanel.qml index 69c827dcc..3929af780 100755 --- a/qml/ui/configpopup/qopenhd_settings/AppSettingsPanel.qml +++ b/qml/ui/configpopup/qopenhd_settings/AppSettingsPanel.qml @@ -49,8 +49,7 @@ Rectangle { } TabButton { - y: 0 - text: qsTr("General") + text: qsTr("Widgets") width: implicitWidth height: 48 font.pixelSize: 13 @@ -58,14 +57,15 @@ Rectangle { TabButton { y: 0 - text: qsTr("Vehicle") + text: qsTr("General") width: implicitWidth height: 48 font.pixelSize: 13 } TabButton { - text: qsTr("Widgets") + y: 0 + text: qsTr("Vehicle") width: implicitWidth height: 48 font.pixelSize: 13 @@ -104,23 +104,17 @@ Rectangle { anchors.bottom: parent.bottom anchors.bottomMargin: 0 - currentIndex: { - // console.log("index:"+appSettingsBar.currentIndex); - // for future use to set focus for goggle support - showAppSettings(appSettingsBar.currentIndex); + currentIndex: appSettingsBar.currentIndex - return appSettingsBar.currentIndex; + AppWidgetSettingsView{ + id: appWidgetSettingsView } - AppGeneralSettingsView{ id: appGeneralSettingsView } AppVehicleSettingsView{ id: appVehicleSettingsView } - AppWidgetSettingsView{ - id: appWidgetSettingsView - } AppScreenSettingsView{ id: appScreenSettingsView } diff --git a/qml/ui/configpopup/qopenhd_settings/AppVehicleSettingsView.qml b/qml/ui/configpopup/qopenhd_settings/AppVehicleSettingsView.qml index a5c37e09f..ef6956e26 100755 --- a/qml/ui/configpopup/qopenhd_settings/AppVehicleSettingsView.qml +++ b/qml/ui/configpopup/qopenhd_settings/AppVehicleSettingsView.qml @@ -16,7 +16,6 @@ ScrollView { width: parent.width height: parent.height contentHeight: vehicleColumn.height - visible: appSettingsBar.currentIndex == 1 clip: true diff --git a/qml/ui/configpopup/qopenhd_settings/AppVideoSettingsView.qml b/qml/ui/configpopup/qopenhd_settings/AppVideoSettingsView.qml index a38441b32..740d53d1b 100755 --- a/qml/ui/configpopup/qopenhd_settings/AppVideoSettingsView.qml +++ b/qml/ui/configpopup/qopenhd_settings/AppVideoSettingsView.qml @@ -18,7 +18,6 @@ ScrollView { contentHeight: videoColumn.height clip: true - visible: appSettingsBar.currentIndex == 4 Item { anchors.fill: parent diff --git a/qml/ui/configpopup/qopenhd_settings/AppWidgetSettingsView.qml b/qml/ui/configpopup/qopenhd_settings/AppWidgetSettingsView.qml index 406c8b0af..a8a075b9b 100755 --- a/qml/ui/configpopup/qopenhd_settings/AppWidgetSettingsView.qml +++ b/qml/ui/configpopup/qopenhd_settings/AppWidgetSettingsView.qml @@ -16,7 +16,6 @@ ScrollView { width: parent.width height: parent.height contentHeight: widgetColumn.height - visible: appSettingsBar.currentIndex == 2 clip: true From c330b7254e95da88c116a8ca53945dcedd393098 Mon Sep 17 00:00:00 2001 From: consti10 Date: Mon, 6 Nov 2023 13:05:33 +0100 Subject: [PATCH 35/81] Flow settings OSD -> Widgets first, remove record widget (merged into video widget), add categorizer and re-order osd widget on / off settings --- qml/qml.qrc | 3 +- qml/ui/HUDOverlayGrid.qml | 30 +- .../AppGeneralSettingsView.qml | 50 ++ .../qopenhd_settings/AppSettingsPanel.qml | 10 + .../AppWidgetSettingsView.qml | 515 +++++------------- .../AppWidgetStyleSettingsView.qml | 187 +++++++ qml/ui/elements/SettingsHeaderElement.qml | 51 ++ qml/ui/widgets/RecordVideoWidget.qml | 427 --------------- 8 files changed, 437 insertions(+), 836 deletions(-) create mode 100644 qml/ui/configpopup/qopenhd_settings/AppWidgetStyleSettingsView.qml create mode 100644 qml/ui/elements/SettingsHeaderElement.qml delete mode 100644 qml/ui/widgets/RecordVideoWidget.qml diff --git a/qml/qml.qrc b/qml/qml.qrc index 7bcddbe5b..09d76a5bc 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -182,7 +182,6 @@ video/SecondaryVideoGStreamer.qml video/MainVideoQSG.qml ui/widgets/VideoBitrateWidgetSecondary.qml - ui/widgets/RecordVideoWidget.qml ui/widgets/RCRssiWidget.qml video/ExpMainVideoAndroid.qml ui/elements/WorkaroundMessageBox.qml @@ -260,5 +259,7 @@ ui/configpopup/status/StatusCardsColumn.qml ui/elements/SimpleLeftRightText.qml video/SecondaryVideoGstreamerPane.qml + ui/elements/SettingsHeaderElement.qml + ui/configpopup/qopenhd_settings/AppWidgetStyleSettingsView.qml diff --git a/qml/ui/HUDOverlayGrid.qml b/qml/ui/HUDOverlayGrid.qml index 24a974371..1f43ea202 100644 --- a/qml/ui/HUDOverlayGrid.qml +++ b/qml/ui/HUDOverlayGrid.qml @@ -151,20 +151,19 @@ Item { var ret=downlink if(index==0)return settingsButtonHighlight; if(index==1)return downlink; - if(index==2)return record_video_widget; - if(index==3)return wBLinkRateControlWidget; - if(index==4)return qRenderStatsWidget; - if(index==5)return bitrate1; - if(index==6)return bitrate2; - if(index==7)return air_status; - if(index==8)return ground_status; - if(index==9)return uplink; - if(index==10)return air_battery; - if(index==11)return flight_mode; - if(index==12)return throttleWidget; - if(index==13)return missionWidget; - if(index==14)return gps; - if(index==15)return home_distance; + if(index==2)return wBLinkRateControlWidget; + if(index==3)return qRenderStatsWidget; + if(index==4)return bitrate1; + if(index==5)return bitrate2; + if(index==6)return air_status; + if(index==7)return ground_status; + if(index==8)return uplink; + if(index==9)return air_battery; + if(index==10)return flight_mode; + if(index==11)return throttleWidget; + if(index==12)return missionWidget; + if(index==13)return gps; + if(index==14)return home_distance; //if(index==13)return uplink; console.log("Invalid index"); return ret; @@ -272,9 +271,6 @@ Item { id: downlink m_next_item: record_video_widget } - RecordVideoWidget { - id: record_video_widget - } WBLinkRateControlWidget{ id: wBLinkRateControlWidget } diff --git a/qml/ui/configpopup/qopenhd_settings/AppGeneralSettingsView.qml b/qml/ui/configpopup/qopenhd_settings/AppGeneralSettingsView.qml index 5c4b53972..b7a6c13c6 100755 --- a/qml/ui/configpopup/qopenhd_settings/AppGeneralSettingsView.qml +++ b/qml/ui/configpopup/qopenhd_settings/AppGeneralSettingsView.qml @@ -72,6 +72,56 @@ ScrollView { } } + Rectangle { + width: parent.width + height: rowHeight + color: (Positioner.index % 2 == 0) ? "#8cbfd7f3" : "#00000000" + + Text { + text: qsTr("Animation Smoothing,0 to disable") + font.weight: Font.Bold + font.pixelSize: 13 + anchors.leftMargin: 8 + verticalAlignment: Text.AlignVCenter + anchors.verticalCenter: parent.verticalCenter + width: 224 + height: elementHeight + anchors.left: parent.left + } + + Text { + text: Number(settings.smoothing).toLocaleString(Qt.locale(), 'f', 0) + "ms"; + font.pixelSize: 16 + anchors.right: smoothing_Slider.left + anchors.rightMargin: 12 + verticalAlignment: Text.AlignVCenter + anchors.verticalCenter: parent.verticalCenter + width: 32 + height: elementHeight + + } + + Slider { + id: smoothing_Slider + height: elementHeight + width: 210 + font.pixelSize: 14 + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + to : 1000 + from : 0 + stepSize: 25 + anchors.rightMargin: Qt.inputMethod.visible ? 78 : 18 + value: settings.smoothing + + // @disable-check M223 + onValueChanged: { + // @disable-check M222 + settings.smoothing = smoothing_Slider.value + } + } + } + Rectangle { width: parent.width diff --git a/qml/ui/configpopup/qopenhd_settings/AppSettingsPanel.qml b/qml/ui/configpopup/qopenhd_settings/AppSettingsPanel.qml index 3929af780..4c112a200 100755 --- a/qml/ui/configpopup/qopenhd_settings/AppSettingsPanel.qml +++ b/qml/ui/configpopup/qopenhd_settings/AppSettingsPanel.qml @@ -55,6 +55,13 @@ Rectangle { font.pixelSize: 13 } + TabButton { + text: qsTr("Style") + width: implicitWidth + height: 48 + font.pixelSize: 13 + } + TabButton { y: 0 text: qsTr("General") @@ -109,6 +116,9 @@ Rectangle { AppWidgetSettingsView{ id: appWidgetSettingsView } + AppWidgetStyleSettingsView{ + id: appWidgetStyleSettingsView + } AppGeneralSettingsView{ id: appGeneralSettingsView } diff --git a/qml/ui/configpopup/qopenhd_settings/AppWidgetSettingsView.qml b/qml/ui/configpopup/qopenhd_settings/AppWidgetSettingsView.qml index a8a075b9b..993766a0e 100755 --- a/qml/ui/configpopup/qopenhd_settings/AppWidgetSettingsView.qml +++ b/qml/ui/configpopup/qopenhd_settings/AppWidgetSettingsView.qml @@ -28,231 +28,13 @@ ScrollView { anchors.left: parent.left anchors.right: parent.right - Rectangle { - width: parent.width - height: rowHeight - color: (Positioner.index % 2 == 0) ? "#8cbfd7f3" : "#00000000" - - Text { - text: qsTr("Shape Color") - font.weight: Font.Bold - font.pixelSize: 13 - anchors.leftMargin: 8 - verticalAlignment: Text.AlignVCenter - anchors.verticalCenter: parent.verticalCenter - width: 224 - height: elementHeight - anchors.left: parent.left - } - - RoundButton { - //text: "Open" - - height: elementHeight - anchors.right: parent.right - anchors.rightMargin: Qt.inputMethod.visible ? 96 : 36 - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizonatalCenter - onClicked: { - colorPicker.previousColor = settings.color_shape - colorPicker.currentColorType = ColorPicker.ColorType.ShapeColor - colorPicker.visible = true - } - - Rectangle { - anchors.centerIn: parent - width: ((parent.width fetched from @property m_short_description +// Optional info popup -> icon visible when @property m_long_description!=="none" +// actuall seting element -> fill with e.g. your QT settings element, e.g. a Switch +Rectangle { + width: parent.width + height: rowHeight*2 / 3; + //color: "green" + //color: "#8cbfd7f3" + color: (Positioner.index % 2 == 0) ? "#8cbfd7f3" : "#00000000" + + Rectangle{ + width: parent.width + height: 2 + color: "black" + anchors.bottom: parent.bottom + anchors.left: parent.left + } + + property string m_description: "FILL ME" + + + Text { + id: description + text: qsTr(m_description) + font.weight: Font.Bold + font.pixelSize: 13 + anchors.leftMargin: 8 + anchors.rightMargin: 8 + anchors.fill: parent + + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + + } +} diff --git a/qml/ui/widgets/RecordVideoWidget.qml b/qml/ui/widgets/RecordVideoWidget.qml deleted file mode 100644 index c8d1f3147..000000000 --- a/qml/ui/widgets/RecordVideoWidget.qml +++ /dev/null @@ -1,427 +0,0 @@ -import QtQuick 2.12 -import QtQuick.Controls 2.12 -import QtQuick.Layouts 1.12 -import QtGraphicalEffects 1.12 -import QtQuick.Shapes 1.0 - -import Qt.labs.settings 1.0 - -import OpenHD 1.0 - -import "../elements" - -BaseWidget { - // width: 140*settings.recordTextSize/14 - // height: 48 - - function get_width(){ - if(settings.show_minimal_record_widget){ - if(settings.dev_qopenhd_n_cameras>1){ - return 35*2; - } - return 35; - } - return 150; - } - function get_height(){ - if(settings.show_minimal_record_widget){ - return 25; - } - return 48; - } - - width: get_width() - height: get_height() - visible: settings.show_record_widget - - widgetIdentifier: "record_video_widget" - bw_verbose_name: "AIR RECORDING" - - defaultAlignment: 0 - defaultXOffset: 200 - defaultYOffset: 2 - defaultHCenter: false - defaultVCenter: false - - hasWidgetDetail: true - hasWidgetAction: true - widgetActionWidth: 250 - widgetActionHeight: (settings.dev_qopenhd_n_cameras > 1) ? 230 : 130 - widgetDetailWidth:275 - widgetDetailHeight:175 - - // Set to true if the camera is currently doing recordng (the UI element(s) turn red in this case) - property bool m_camera1_is_currently_recording: _cameraStreamModelPrimary.air_recording_active - property bool m_camera2_is_currently_recording: _cameraStreamModelSecondary.air_recording_active - - // THIS IS A MAVLINK PARAM, SYNCHRONIZATION THEREFORE IS HARD AND HERE NOT WORTH IT - property int m_camera1_recording_mode: -1 - property int m_camera2_recording_mode: -1 - - function set_recording_mode_for_camera(cam_idx,mode){ - if(cam_idx===1){ - m_camera1_recording_mode=mode - }else{ - m_camera2_recording_mode=mode - } - } - - function try_set_recording_mode(camera_idx,mode){ - console.log("try_set_recording_mode "+camera_idx+" "+mode) - var camModel=_airCameraSettingsModel; - var camString="CAM1" - if(camera_idx===2){ - camModel=_airCameraSettingsModel2; - camString="CAM2" - } - if(!_ohdSystemAir.is_alive){ - _hudLogMessagesModel.signalAddLogMessage(6,"Air unit not alive, cannot set recording for "+camString) - return; - } - if(mode===0){ //mode off - var result=camModel.try_update_parameter_int("V_AIR_RECORDING",0)==="" - if(result){ - _hudLogMessagesModel.signalAddLogMessage(6,"recording "+camString+" disabled") - set_recording_mode_for_camera(camera_idx,0) - }else{ - _hudLogMessagesModel.signalAddLogMessage(6,"update "+camString+" failed") - } - } - if(mode===1){ //mode on - var result=camModel.try_update_parameter_int("V_AIR_RECORDING",1)==="" - if(result){ - _hudLogMessagesModel.signalAddLogMessage(6,"recording "+camString+" enabled") - set_recording_mode_for_camera(camera_idx,1) - }else{ - _hudLogMessagesModel.signalAddLogMessage(6,"update "+camString+" failed") - } - } - if(mode==2){ //mode auto - var result=camModel.try_update_parameter_int("V_AIR_RECORDING",2)==="" - if(result){ - _hudLogMessagesModel.signalAddLogMessage(6,"recording "+camString+" auto enabled") - set_recording_mode_for_camera(camera_idx,2) - }else{ - _hudLogMessagesModel.signalAddLogMessage(6,"update "+camString+" failed") - } - } - } - - widgetDetailComponent: ScrollView { - - contentHeight: idBaseWidgetDefaultUiControlElements.height - ScrollBar.horizontal.policy: ScrollBar.AlwaysOff - clip: true - - BaseWidgetDefaultUiControlElements{ - id: idBaseWidgetDefaultUiControlElements - - Item { - width: parent.width - height: 32 - Text { - text: qsTr("Minimal Layout") - color: "white" - height: parent.height - font.bold: true - font.pixelSize: detailPanelFontPixels - anchors.left: parent.left - verticalAlignment: Text.AlignVCenter - } - Switch { - height: parent.height - anchors.rightMargin: 0 - anchors.right: parent.right - width: parent.width - 96 - checked: settings.show_minimal_record_widget - onCheckedChanged:{ - if (checked) { - settings.show_minimal_record_widget = true - } - else{ - settings.show_minimal_record_widget = false - } - - } - - } - - } - Item { - //dummy for layout - width: 230 - height: 32 - } - - } - } - - widgetActionComponent: Item{ - - //color:"red" - width: parent.width-30 - height: parent.height - - ColumnLayout{ - id:recID - width: parent.width - height: parent.height - // - Text { - visible:true - id:airVideoSpaceLeft_minimal - text: "Free: "+_ohdSystemAir.curr_space_left_mb+" MB" - color: (_ohdSystemAir.curr_space_left_mb < 500) ? "red" : "green" - elide: Text.ElideNone - wrapMode: Text.NoWrap - font.pixelSize: settings.recordTextSize - font.family: settings.font_text - style: Text.Outline - onTextChanged: { - if (m_camera1_is_currently_recording || m_camera2_is_currently_recording ==true ) { - if (_ohdSystemAir.curr_space_left_mb < 500 && _ohdSystemAir.curr_space_left_mb > 200 && _ohdSystemAir.curr_space_left_mb % 10 == 0) { - _hudLogMessagesModel.signalAddLogMessage(4,"SD-Card getting full.") - } - } - } - } - Text { - text: qsTr("(Air) Record Camera 1"); - color: settings.color_text - elide: Text.ElideNone - wrapMode: Text.NoWrap - horizontalAlignment: Text.AlignLeft - font.pixelSize: settings.recordTextSize - font.family: settings.font_text - style: Text.Outline - styleColor: settings.color_glow - visible: true - } - Item{ - width: parent.width - height: 50 - //color:"green" - GridLayout{ - width: parent.width - height: parent.height - rows: 1 - columns: 3 - Button{ - text: "OFF" - onClicked: { - try_set_recording_mode(1,0) - } - highlighted: m_camera1_recording_mode==0 - } - Button{ - text: "ON" - onClicked: { - try_set_recording_mode(1,1) - } - highlighted: m_camera1_recording_mode==1 - } - Button{ - text: "AUTO" - onClicked: { - try_set_recording_mode(1,2) - } - highlighted: m_camera1_recording_mode==2 - } - } - } - Text { - text: qsTr("(Air) Record Camera 2"); - color: settings.color_text - elide: Text.ElideNone - wrapMode: Text.NoWrap - horizontalAlignment: Text.AlignLeft - font.pixelSize: settings.recordTextSize - font.family: settings.font_text - style: Text.Outline - styleColor: settings.color_glow - visible: settings.dev_qopenhd_n_cameras > 1 - } - Item{ - width: parent.width - height: 50 - //color:"green" - visible: settings.dev_qopenhd_n_cameras > 1 - GridLayout{ - width: parent.width - height: parent.height - rows: 1 - columns: 3 - Button{ - text: "OFF" - onClicked: { - try_set_recording_mode(2,0) - } - highlighted: m_camera2_recording_mode==0 - } - Button{ - text: "ON" - onClicked: { - try_set_recording_mode(2,1) - } - highlighted: m_camera2_recording_mode==1 - } - Button{ - text: "AUTO" - onClicked: { - try_set_recording_mode(2,2) - } - highlighted: m_camera2_recording_mode==2 - } - } - } - } - } - - - Item { - id: recordWidgetBig - visible: !settings.show_minimal_record_widget - anchors.fill: parent - Text { - text: qsTr("Record Video"); - color: settings.color_text - anchors.fill: parent - anchors.topMargin: 5*settings.recordTextSize/12 - verticalAlignment: Text.AlignVCenter - elide: Text.ElideNone - wrapMode: Text.NoWrap - horizontalAlignment: Text.AlignLeft - font.pixelSize: settings.recordTextSize - font.family: settings.font_text - style: Text.Outline - styleColor: settings.color_glow - visible: true - } - Text { - id:record_status_cam1 - text: "CAM1" - color: (m_camera1_is_currently_recording == true) ? "green" : "red" - anchors.fill: parent - anchors.leftMargin: 95*settings.recordTextSize/14 - anchors.topMargin: 5*settings.recordTextSize/12 - verticalAlignment: Text.AlignVCenter - elide: Text.ElideNone - wrapMode: Text.NoWrap - font.pixelSize: settings.recordTextSize - font.family: settings.font_text - style: Text.Outline - styleColor: settings.color_glow - visible: true - } - Text { - id:record_status_cam2 - text: "CAM2" - color: (m_camera2_is_currently_recording == true) ? "green" : "red" - anchors.fill: parent - anchors.leftMargin: 140*settings.recordTextSize/14 - anchors.topMargin: 5*settings.recordTextSize/12 - verticalAlignment: Text.AlignVCenter - elide: Text.ElideNone - wrapMode: Text.NoWrap - font.pixelSize: settings.recordTextSize - font.family: settings.font_text - style: Text.Outline - styleColor: settings.color_glow - visible: settings.dev_qopenhd_n_cameras > 1 - } - Text { - text: qsTr("Free Space"); - color: settings.color_text - anchors.leftMargin: 90 - elide: Text.ElideNone - wrapMode: Text.NoWrap - font.pixelSize: settings.recordTextSize - font.family: settings.font_text - style: Text.Outline - styleColor: settings.color_glow - visible: true - } - Text { - id:airVideoSpaceLeft - text: _ohdSystemAir.curr_space_left_mb+" MB" - color: (_ohdSystemAir.curr_space_left_mb < 500) ? "red" : "green" - anchors.fill: parent - anchors.leftMargin: 95*settings.recordTextSize/14 - anchors.topMargin: -30 - verticalAlignment: Text.AlignVCenter - elide: Text.ElideNone - wrapMode: Text.NoWrap - font.pixelSize: settings.recordTextSize - font.family: settings.font_text - style: Text.Outline - styleColor: settings.color_glow - visible: true - onTextChanged: { - if (m_camera1_is_currently_recording ==true || m_camera2_is_currently_recording ==true ) { - if (_ohdSystemAir.curr_space_left_mb < 500 && _ohdSystemAir.curr_space_left_mb > 200 && _ohdSystemAir.curr_space_left_mb % 10 == 0) { - _hudLogMessagesModel.signalAddLogMessage(4,"SD-Card getting full.") - } - } - } - } } - Item { - id: recordWidgetMinimal - visible: settings.show_minimal_record_widget - anchors.fill: parent - Text { - id:record_status_cam1_min - text: "\uf03d" - font.family: "Font Awesome 5 Free" - color: (m_camera1_is_currently_recording == true) ? "red" : "white" - anchors.fill: parent - anchors.leftMargin: 5*settings.recordTextSize/14 - anchors.topMargin: 5*settings.recordTextSize/12 - verticalAlignment: Text.AlignVCenter - elide: Text.ElideNone - wrapMode: Text.NoWrap - font.pixelSize: settings.recordTextSize*1.5 - style: Text.Outline - styleColor: settings.color_glow - visible: true - } - Text { - id:record_status_cam2_min - text: " \uf03d" - font.family: "Font Awesome 5 Free" - color: (m_camera2_is_currently_recording == true) ? "red" : "white" - anchors.fill: parent - anchors.leftMargin: 25*settings.recordTextSize/14 - anchors.topMargin: 5*settings.recordTextSize/12 - verticalAlignment: Text.AlignVCenter - elide: Text.ElideNone - wrapMode: Text.NoWrap - font.pixelSize: settings.recordTextSize*1.5 - style: Text.Outline - styleColor: settings.color_glow - visible: settings.dev_qopenhd_n_cameras > 1 - } - Text { - id:airVideoSpaceLeft_min - text: _ohdSystemAir.curr_space_left_mb+" MB" - color: (_ohdSystemAir.curr_space_left_mb < 500) ? "red" : "green" - anchors.fill: parent - anchors.leftMargin: 95*settings.recordTextSize/14 - anchors.topMargin: -30 - verticalAlignment: Text.AlignVCenter - elide: Text.ElideNone - wrapMode: Text.NoWrap - font.pixelSize: settings.recordTextSize - font.family: settings.font_text - style: Text.Outline - styleColor: settings.color_glow - visible: !settings.show_minimal_record_widget - onTextChanged: { - if (m_camera1_is_currently_recording ==true || m_camera2_is_currently_recording ==true ) { - if (_ohdSystemAir.curr_space_left_mb < 500 && _ohdSystemAir.curr_space_left_mb > 200 && _ohdSystemAir.curr_space_left_mb % 10 == 0) { - _hudLogMessagesModel.signalAddLogMessage(4,"SD-Card getting full.") - } - } - } - } - } -} From 2254f0f9f7ac1e875cf82ac57e56bf4b6c55f34d Mon Sep 17 00:00:00 2001 From: consti10 Date: Mon, 6 Nov 2023 13:17:45 +0100 Subject: [PATCH 36/81] Flow settings OSD -> Widgets first, remove record widget (merged into video widget), add categorizer and re-order osd widget on / off settings --- qml/ui/HUDOverlayGrid.qml | 1 - .../qopenhd_settings/AppWidgetSettingsView.qml | 2 +- qml/ui/widgets/BaseWidget.qml | 8 -------- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/qml/ui/HUDOverlayGrid.qml b/qml/ui/HUDOverlayGrid.qml index 1f43ea202..feeda9815 100644 --- a/qml/ui/HUDOverlayGrid.qml +++ b/qml/ui/HUDOverlayGrid.qml @@ -269,7 +269,6 @@ Item { // -------------------------------------------------------------------------- LinkDownRSSIWidget { id: downlink - m_next_item: record_video_widget } WBLinkRateControlWidget{ id: wBLinkRateControlWidget diff --git a/qml/ui/configpopup/qopenhd_settings/AppWidgetSettingsView.qml b/qml/ui/configpopup/qopenhd_settings/AppWidgetSettingsView.qml index 993766a0e..22a0d4fca 100755 --- a/qml/ui/configpopup/qopenhd_settings/AppWidgetSettingsView.qml +++ b/qml/ui/configpopup/qopenhd_settings/AppWidgetSettingsView.qml @@ -77,7 +77,7 @@ ScrollView { } SettingBaseElement{ m_short_description: "Show video widget" - m_long_description: "More stats about each camera stream and quick resolution changes." + m_long_description: "More stats about each camera stream, quick resolution changes and quick air recording." Switch { width: 32 height: elementHeight diff --git a/qml/ui/widgets/BaseWidget.qml b/qml/ui/widgets/BaseWidget.qml index 55c1643ba..35d643eab 100644 --- a/qml/ui/widgets/BaseWidget.qml +++ b/qml/ui/widgets/BaseWidget.qml @@ -113,8 +113,6 @@ BaseWidgetForm { property bool disable_dragging: false // --------------------------------------------------------------------- // Custom keyboard KeyNavigation - // Must be also of type BaseWidget - property var m_next_item: // DIRTY function dirty_open_action_popup(){ widgetAction.open() @@ -155,12 +153,6 @@ BaseWidgetForm { // TODO: Go to the next item } } - function set_focus_next_item(){ - if(m_next_item==undefined){ - console.log("Next item undefined") - return; - } - } //layer.enabled: false From aea6fdca0cff7e223a0b7ddd027981f413a08399 Mon Sep 17 00:00:00 2001 From: consti10 Date: Mon, 6 Nov 2023 13:31:52 +0100 Subject: [PATCH 37/81] for now, just do not show the reboot shutdown actions --- qml/ui/configpopup/status/FooterRebootShutdownWarning.qml | 7 +++++-- qml/ui/configpopup/status/StatusCardsColumn.qml | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/qml/ui/configpopup/status/FooterRebootShutdownWarning.qml b/qml/ui/configpopup/status/FooterRebootShutdownWarning.qml index 2d26f2e73..897803c6a 100644 --- a/qml/ui/configpopup/status/FooterRebootShutdownWarning.qml +++ b/qml/ui/configpopup/status/FooterRebootShutdownWarning.qml @@ -14,6 +14,9 @@ Item { anchors.fill: parent property int m_type: 0 // 0 = ground, 1= air, 2=FC + + property bool m_supports_reboot_actions: true + function get_show_power_actions(){ if(m_type==0){ return _ohdSystemGround.is_alive @@ -48,7 +51,7 @@ Item { anchors.fill: parent //visible: get_show_power_actions() Button{ - visible: get_show_power_actions() + visible: get_show_power_actions() && m_supports_reboot_actions Layout.alignment: Qt.AlignLeft Layout.leftMargin: 10 text: qsTr("REBOOT") @@ -57,7 +60,7 @@ Item { } } Button{ - visible: get_show_power_actions() + visible: get_show_power_actions() && m_supports_reboot_actions Layout.alignment: Qt.AlignRight Layout.rightMargin: 10 text: qsTr("SHUTDOWN") diff --git a/qml/ui/configpopup/status/StatusCardsColumn.qml b/qml/ui/configpopup/status/StatusCardsColumn.qml index 3513dbda2..a9b110cfc 100644 --- a/qml/ui/configpopup/status/StatusCardsColumn.qml +++ b/qml/ui/configpopup/status/StatusCardsColumn.qml @@ -69,6 +69,7 @@ RowLayout{ hasFooter: true cardFooter: FooterRebootShutdownWarning{ + m_supports_reboot_actions: false m_type: 2 } } From 7466cf82f3adb8b559a4941f04ba6b40ac305526 Mon Sep 17 00:00:00 2001 From: consti10 Date: Mon, 6 Nov 2023 13:50:41 +0100 Subject: [PATCH 38/81] less spammy on secondary cam --- app/telemetry/models/aohdsystem.cpp | 8 +++----- app/telemetry/models/aohdsystem.h | 2 ++ qml/ui/widgets/VideoBitrateWidgetSecondary.qml | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/telemetry/models/aohdsystem.cpp b/app/telemetry/models/aohdsystem.cpp index 4d2bab18a..309554d6e 100644 --- a/app/telemetry/models/aohdsystem.cpp +++ b/app/telemetry/models/aohdsystem.cpp @@ -139,18 +139,16 @@ bool AOHDSystem::process_message(const mavlink_message_t &msg) CameraStreamModel::instance(0).update_mavlink_openhd_camera_status_air(parsedMsg); }else if(msg.compid==OHD_COMP_ID_AIR_CAMERA_SECONDARY){ CameraStreamModel::instance(1).update_mavlink_openhd_camera_status_air(parsedMsg); + set_dirty_air_has_secondary_cam(true); // Feature - tell user to enable 2 cameras in qopenhd set_n_openhd_cameras(2); const int value_in_qopenhd=QOpenHDVideoHelper::get_qopenhd_n_cameras(); if(value_in_qopenhd!=2){ const auto elapsed=std::chrono::steady_clock::now()-m_last_n_cameras_message; - if(elapsed>std::chrono::seconds(10)){ - auto message="QOpenHD is not configured for dual cam usage, go to QOpenHD settings / General to configure your GCS to show secondary camera screen"; - qDebug()<std::chrono::seconds(5)){ + LogMessagesModel::instanceGround().add_message_debug("QOpenHD","Please enable 2 camera control"); m_last_n_cameras_message=std::chrono::steady_clock::now(); } - HUDLogMessagesModel::instance().add_message_info("QOpenHD only shows 1 camera"); } } diff --git a/app/telemetry/models/aohdsystem.h b/app/telemetry/models/aohdsystem.h index f147f49a6..e132c687f 100644 --- a/app/telemetry/models/aohdsystem.h +++ b/app/telemetry/models/aohdsystem.h @@ -118,6 +118,8 @@ class AOHDSystem : public QObject L_RO_PROP(int,wb_gnd_operating_mode,set_wb_gnd_operating_mode,-1) // L_RO_PROP(int,air_reported_fc_sys_id,set_air_reported_fc_sys_id,-1) + // + L_RO_PROP(bool,dirty_air_has_secondary_cam,set_dirty_air_has_secondary_cam,false) private: const bool m_is_air; // either true (for air) or false (for ground) uint8_t get_own_sys_id()const{ diff --git a/qml/ui/widgets/VideoBitrateWidgetSecondary.qml b/qml/ui/widgets/VideoBitrateWidgetSecondary.qml index d3c9e7216..3850bbc99 100644 --- a/qml/ui/widgets/VideoBitrateWidgetSecondary.qml +++ b/qml/ui/widgets/VideoBitrateWidgetSecondary.qml @@ -10,6 +10,6 @@ import OpenHD 1.0 VideoBitrateWidgetGeneric{ m_is_for_primary_camera: false - visible: settings.show_bitrate && settings.dev_qopenhd_n_cameras==2 - + // Also show it if air has a seconary cam + visible: (settings.show_bitrate && settings.dev_qopenhd_n_cameras>1) || (settings.show_bitrate && _ohdSystemAir.dirty_air_has_secondary_cam) } From d249f0f60d241028873ff912fec82d80e92aa585 Mon Sep 17 00:00:00 2001 From: consti10 Date: Mon, 6 Nov 2023 14:08:41 +0100 Subject: [PATCH 39/81] less spammy on secondary cam --- qml/ui/widgets/VideoBitrateWidgetGeneric.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qml/ui/widgets/VideoBitrateWidgetGeneric.qml b/qml/ui/widgets/VideoBitrateWidgetGeneric.qml index 051b49f3b..0df6c0a7e 100644 --- a/qml/ui/widgets/VideoBitrateWidgetGeneric.qml +++ b/qml/ui/widgets/VideoBitrateWidgetGeneric.qml @@ -261,7 +261,7 @@ BaseWidget { } SimpleLeftRightText{ - m_left_text: qsTr("Bitrate MEASURED:") + m_left_text: qsTr("MEASURED:") m_right_text: m_camera_stream_model.curr_video_measured_encoder_bitrate } From 9c4216f6d691f9dd963de87e08462c22ac714ab0 Mon Sep 17 00:00:00 2001 From: consti10 Date: Tue, 7 Nov 2023 15:08:09 +0100 Subject: [PATCH 40/81] delete unused, add filler --- qml/ui/configpopup/log/LogMessagesStatusView.qml | 1 - .../openhd_settings/MavlinkOpenHDWBParamPanel.qml | 10 +++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/qml/ui/configpopup/log/LogMessagesStatusView.qml b/qml/ui/configpopup/log/LogMessagesStatusView.qml index 8a408f04f..a90be3110 100644 --- a/qml/ui/configpopup/log/LogMessagesStatusView.qml +++ b/qml/ui/configpopup/log/LogMessagesStatusView.qml @@ -17,7 +17,6 @@ Item { property int rowHeight: 64 property int elementHeight: 48 - property int elementComboBoxWidth: 300 // Tab bar for selecting items in stack layout TabBar { id: selectItemInStackLayoutBar diff --git a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml index 38a7b83e2..17bd50434 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml +++ b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml @@ -264,6 +264,10 @@ Rectangle{ Layout.row: 2 Layout.column: 0 Layout.columnSpan: 3 + Item{ // FILLER + Layout.preferredWidth: 30 + Layout.minimumWidth: 0 + } Button{ Layout.preferredWidth: 150 id: b_find_air_unit @@ -296,7 +300,7 @@ Rectangle{ } } Item{ // FILLER - Layout.preferredWidth: 50 + Layout.preferredWidth: 30 Layout.minimumWidth: 0 } Button{ @@ -308,6 +312,10 @@ Rectangle{ popup_analyze_channels.open() } } + Item{ // FILLER + Layout.preferredWidth: 30 + Layout.minimumWidth: 0 + } ButtonIconInfo{ onClicked: { var text="SCAN: Similar to analoque channel scan, find a running air unit by checking all possible channels (frequencies).\n\n"+ From 37bf5f4533739354cc1c702b80266cdc8659e1b7 Mon Sep 17 00:00:00 2001 From: consti10 Date: Tue, 7 Nov 2023 15:13:04 +0100 Subject: [PATCH 41/81] pack the left bar into a scroll view, such that it is at least navigatable on too small screens --- qml/ui/configpopup/ConfigPopup.qml | 129 +++++++++++++++-------------- 1 file changed, 68 insertions(+), 61 deletions(-) diff --git a/qml/ui/configpopup/ConfigPopup.qml b/qml/ui/configpopup/ConfigPopup.qml index c57603de9..6037d6ac5 100644 --- a/qml/ui/configpopup/ConfigPopup.qml +++ b/qml/ui/configpopup/ConfigPopup.qml @@ -158,82 +158,89 @@ Rectangle { _qopenhd.show_toast("No joystick navigation for this panel"); } } - - Column { + ScrollView{ width: parent.width + height: parent.height + contentHeight: navigation_buttons_column.height + Column { + id: navigation_buttons_column + width: parent.width - anchors.top: parent.top + anchors.top: parent.top - // Status - ConfigPopupSidebarButton{ - id: power - m_icon_text: "\uf21e" //"\uf011" - m_description_text: "Status" - m_selection_index: 0 - } + // Status + ConfigPopupSidebarButton{ + id: power + m_icon_text: "\uf21e" //"\uf011" + m_description_text: "Status" + m_selection_index: 0 + } - // OpenHD Settings - MavlinkAllSettingsPanel - ConfigPopupSidebarButton{ - id: openhd_button - m_icon_text: "\uf085" - m_description_text: "OpenHD" - m_selection_index: 1 - } + // OpenHD Settings - MavlinkAllSettingsPanel + ConfigPopupSidebarButton{ + id: openhd_button + m_icon_text: "\uf085" + m_description_text: "OpenHD" + m_selection_index: 1 + } - // (QOpenHD Settings - AppSettingsPanel) - // OSD - ConfigPopupSidebarButton{ - id: qopenhd_button - m_icon_text: "\uf013" - m_description_text: "OSD" - m_selection_index: 2 - } + // (QOpenHD Settings - AppSettingsPanel) + // OSD + ConfigPopupSidebarButton{ + id: qopenhd_button + m_icon_text: "\uf013" + m_description_text: "OSD" + m_selection_index: 2 + } - // Log - ConfigPopupSidebarButton{ - id: log_button - m_icon_text: "\uf0c9" - m_description_text: "Log" - m_selection_index: 3 - } + // Log + ConfigPopupSidebarButton{ + id: log_button + m_icon_text: "\uf0c9" + m_description_text: "Log" + m_selection_index: 3 + } - // RC - ConfigPopupSidebarButton{ - id: rc - m_icon_text: "\uf11b" - m_description_text: "RC" - m_selection_index: 4 - } + // RC + ConfigPopupSidebarButton{ + id: rc + m_icon_text: "\uf11b" + m_description_text: "RC" + m_selection_index: 4 + } - // We only need the connect panel on android (external device) - // On localhost, QOpenHD "automatically" connects due to udp localhost method - ConfigPopupSidebarButton{ - visible: m_show_connect_option - id: connect_button - m_icon_text: "\uf6ff" - m_description_text: "Connect" - m_selection_index: 5 - } + // We only need the connect panel on android (external device) + // On localhost, QOpenHD "automatically" connects due to udp localhost method + ConfigPopupSidebarButton{ + visible: m_show_connect_option + id: connect_button + m_icon_text: "\uf6ff" + m_description_text: "Connect" + m_selection_index: 5 + } - // Credits and copyright - ConfigPopupSidebarButton{ - id: credits - m_icon_text: "\uf005" - m_description_text: "Credits" - m_selection_index: 6 - } + // Credits and copyright + ConfigPopupSidebarButton{ + id: credits + m_icon_text: "\uf005" + m_description_text: "Credits" + m_selection_index: 6 + } - // Developer stats - ConfigPopupSidebarButton{ - id: developerstats - m_icon_text: "\uf0ad" - m_description_text: "DEV" - m_selection_index: 7 + // Developer stats + ConfigPopupSidebarButton{ + id: developerstats + m_icon_text: "\uf0ad" + m_description_text: "DEV" + m_selection_index: 7 + } } } } + + StackLayout { id: mainStackLayout anchors.bottom: parent.bottom From 310b388e0e0d8d9406422b12195b23eb8a73e74c Mon Sep 17 00:00:00 2001 From: consti10 Date: Tue, 7 Nov 2023 15:16:40 +0100 Subject: [PATCH 42/81] pack the left bar into a scroll view, such that it is at least navigatable on too small screens --- qml/ui/configpopup/ConfigPopup.qml | 2 -- 1 file changed, 2 deletions(-) diff --git a/qml/ui/configpopup/ConfigPopup.qml b/qml/ui/configpopup/ConfigPopup.qml index 6037d6ac5..cdc9f3175 100644 --- a/qml/ui/configpopup/ConfigPopup.qml +++ b/qml/ui/configpopup/ConfigPopup.qml @@ -165,9 +165,7 @@ Rectangle { Column { id: navigation_buttons_column width: parent.width - anchors.top: parent.top - // Status ConfigPopupSidebarButton{ id: power From a5d79c8df85b763ed591a75cd24f02e780a51f97 Mon Sep 17 00:00:00 2001 From: consti10 Date: Tue, 7 Nov 2023 15:33:25 +0100 Subject: [PATCH 43/81] android - log warning if permissions are missing (only) --- app/main.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/app/main.cpp b/app/main.cpp index 95fedff4a..f3741c4f4 100755 --- a/app/main.cpp +++ b/app/main.cpp @@ -170,6 +170,22 @@ static void write_platform_context_properties(QQmlApplicationEngine& engine){ #endif } +static void android_check_permissions(){ +#if defined(__android__) + qDebug()<<"Android request permissions"; + for(const QString &permission : permissions) { + auto result = QtAndroid::checkPermission(permission); + if (result == QtAndroid::PermissionResult::Denied) { + auto resultHash = QtAndroid::requestPermissionsSync(QStringList({permission})); + if (resultHash[permission] == QtAndroid::PermissionResult::Denied) { + LogMessagesModel::instanceGround().add_message_warn("QOpenHD","Android - missing permissions"); + return; + } + } + } +#endif +} + int main(int argc, char *argv[]) { @@ -235,20 +251,8 @@ int main(int argc, char *argv[]) { applePlatform->registerNotifications(); #endif - QOpenHD::instance().keep_screen_on(true); -#if defined(__android__) - qDebug()<<"Android request permissions"; - for(const QString &permission : permissions) { - auto result = QtAndroid::checkPermission(permission); - if (result == QtAndroid::PermissionResult::Denied) { - auto resultHash = QtAndroid::requestPermissionsSync(QStringList({permission})); - if (resultHash[permission] == QtAndroid::PermissionResult::Denied) { - return 0; - } - } - } -#endif - + QOpenHD::instance().keep_screen_on(true); + android_check_permissions(); load_fonts(); qmlRegisterType("OpenHD", 1, 0, "SpeedLadder"); From 904203cd7800df19807a7c1aa77d6a476f041068 Mon Sep 17 00:00:00 2001 From: consti10 Date: Tue, 7 Nov 2023 15:51:18 +0100 Subject: [PATCH 44/81] slightly bigger param editor --- qml/ui/configpopup/openhd_settings/MavlinkParamEditor.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qml/ui/configpopup/openhd_settings/MavlinkParamEditor.qml b/qml/ui/configpopup/openhd_settings/MavlinkParamEditor.qml index d1a0ce459..f1cbf6add 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkParamEditor.qml +++ b/qml/ui/configpopup/openhd_settings/MavlinkParamEditor.qml @@ -20,7 +20,7 @@ import "../../elements" // Aligned to the right, and width can be set by total_width property manually Rectangle{ - property int total_width: 300 + property int total_width: 400 width: total_width height: parent.height From 98824a240e5037376333c4efe3d29aba641b0902 Mon Sep 17 00:00:00 2001 From: consti10 Date: Wed, 8 Nov 2023 14:00:24 +0100 Subject: [PATCH 45/81] tx power - reset the selection model(s) to fix bug @Ivan --- qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml | 5 +++++ .../configpopup/qopenhd_settings/AppWidgetSettingsView.qml | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml b/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml index 2106a5856..8434f0eb7 100644 --- a/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml +++ b/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml @@ -39,6 +39,11 @@ Rectangle{ _messageBoxInstance.set_text_and_show("Changing tx power is only possible on openhd supported cards."); return; } + // The user has to enter the card type every time - otherwise, we have issues with air and ground + comboBoxCardSelectManufacturer.currentIndex=0; + combo_box_txpower_disarmed.currentIndex=0; + combo_box_txpower_armed.currentIndex=0; + m_user_selected_card_manufacturer=-1; visible=true; enabled=true; } diff --git a/qml/ui/configpopup/qopenhd_settings/AppWidgetSettingsView.qml b/qml/ui/configpopup/qopenhd_settings/AppWidgetSettingsView.qml index 22a0d4fca..3db130e67 100755 --- a/qml/ui/configpopup/qopenhd_settings/AppWidgetSettingsView.qml +++ b/qml/ui/configpopup/qopenhd_settings/AppWidgetSettingsView.qml @@ -1189,7 +1189,7 @@ ScrollView { width: parent.width height: rowHeight color: (Positioner.index % 2 == 0) ? "#8cbfd7f3" : "#00000000" - + enabled: false // Not yet functional Text { text: qsTr("Show Sidebar ProofOfConcept") font.weight: Font.Bold @@ -1247,6 +1247,7 @@ ScrollView { width: parent.width height: rowHeight color: (Positioner.index % 2 == 0) ? "#8cbfd7f3" : "#00000000" + enabled: false // Not yet functional Text { text: qsTr("Show GPIO") From e884881cc0f672b1d12edad8631d9b2bcd67e0cb Mon Sep 17 00:00:00 2001 From: consti10 Date: Fri, 10 Nov 2023 15:32:26 +0100 Subject: [PATCH 46/81] tx power - whitelist for less confusion, add 720p60 16:9 to drop down selector @Ivan --- app/telemetry/settings/documentedparam.cpp | 10 + .../openhd_settings/PopupTxPowerEditor.qml | 282 +++++++++--------- qml/ui/widgets/VideoBitrateWidgetGeneric.qml | 16 +- 3 files changed, 156 insertions(+), 152 deletions(-) diff --git a/app/telemetry/settings/documentedparam.cpp b/app/telemetry/settings/documentedparam.cpp index 59b0a48ca..f4fb3fda1 100644 --- a/app/telemetry/settings/documentedparam.cpp +++ b/app/telemetry/settings/documentedparam.cpp @@ -707,6 +707,16 @@ static std::map get_whitelisted_params() ret["CONFIG_BOOT_AIR"]=nullptr; ret[openhd::WB_MAX_FEC_BLOCK_SIZE_FOR_PLATFORM]=nullptr; ret[openhd::WB_DEV_AIR_SET_HIGH_RETRANSMIT_COUNT]=nullptr; + // TX POWER Whitelisted, since they should be changed from the quick wizzard + ret[openhd::WB_TX_POWER_MILLI_WATT]=nullptr; + ret[openhd::WB_TX_POWER_MILLI_WATT_ARMED]=nullptr; + ret[openhd::WB_RTL8812AU_TX_PWR_IDX_OVERRIDE]=nullptr; + ret[openhd::WB_RTL8812AU_TX_PWR_IDX_ARMED]=nullptr; + // STBC / LDPC - Whitelisted, since they should be changed from the quick wizzard + ret[openhd::WB_ENABLE_LDPC]=nullptr; + ret[openhd::WB_ENABLE_STBC]=nullptr; + // Whitelisted since normally it should not be changed / has no effect anyways + ret[openhd::WB_ENABLE_SHORT_GUARD]=nullptr; //ret[""]=nullptr; return ret; } diff --git a/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml b/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml index 8434f0eb7..4a23d3ac3 100644 --- a/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml +++ b/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml @@ -72,7 +72,7 @@ Rectangle{ // Should never show up ! ListModel{ id: model_error - ListElement {title: "ERROR"; value: -1} + ListElement {title: "PLEASE SELECT MANUFACTURER"; value: -1} } ListModel{ @@ -221,7 +221,7 @@ Rectangle{ return _wifi_card_gnd0.tx_power_unit; } - GridLayout{ + ColumnLayout{ id: main_row_layout anchors.fill: parent anchors.leftMargin: m_margin @@ -256,156 +256,157 @@ Rectangle{ } } } - // - Text{ - Layout.row: 1 - Layout.column: 0 - text: "RF CHIP:\n" +get_card_chipset_str() - horizontalAlignment: Qt.AlignHCenter - font.pixelSize: 14 - } - ComboBox { - Layout.row: 1 - Layout.column: 1 - id: comboBoxCardSelectManufacturer - Layout.minimumWidth: 100 - Layout.preferredWidth: 350 - model: get_model_manufacturer_for_chip_type() - textRole: "title" - onCurrentIndexChanged: { - var manufacturer=comboBoxCardSelectManufacturer.model.get(comboBoxCardSelectManufacturer.currentIndex).value; - m_user_selected_card_manufacturer=manufacturer; - } - font.pixelSize: 14 - } - // FILLER - Item{ - Layout.row: 1 - Layout.column: 3 + RowLayout{ Layout.fillWidth: true + Text{ + Layout.minimumWidth: 100 + Layout.preferredWidth: 250 + text: "RF CHIP:\n" +get_card_chipset_str() + horizontalAlignment: Qt.AlignHCenter + font.pixelSize: 14 + } + ComboBox { + id: comboBoxCardSelectManufacturer + Layout.minimumWidth: 100 + Layout.preferredWidth: 350 + model: get_model_manufacturer_for_chip_type() + textRole: "title" + onCurrentIndexChanged: { + var manufacturer=comboBoxCardSelectManufacturer.model.get(comboBoxCardSelectManufacturer.currentIndex).value; + m_user_selected_card_manufacturer=manufacturer; + } + font.pixelSize: 14 + } + // FILLER + Item{ + Layout.row: 1 + Layout.column: 3 + Layout.fillWidth: true + } } - // ---------------- - Text{ - Layout.row: 2 - Layout.column: 0 - text: "DISARMED:\n"+get_current_tx_power_int(1)+" "+get_tx_power_unit(); - Layout.fillWidth: true - horizontalAlignment: Qt.AlignHCenter - font.pixelSize: 14 - } - ComboBox { - Layout.row: 2 - Layout.column: 1 + RowLayout{ Layout.fillWidth: true - Layout.minimumWidth: 100 - Layout.preferredWidth: 350 - id: combo_box_txpower_disarmed - model: get_model_txpower_for_chip_type_manufacturer(false) - textRole: "title" - enabled: m_user_selected_card_manufacturer>=0; - font.pixelSize: 14 - } - Button{ - Layout.row: 2 - Layout.column: 2 - text: "SAVE" - enabled: m_user_selected_card_manufacturer>=0; - onClicked: { - var tx_power_index_or_mw = combo_box_txpower_disarmed.model.get(combo_box_txpower_disarmed.currentIndex).value; - if(tx_power_index_or_mw<0){ - _qopenhd.show_toast("Please select a valid tx power",false); - return; + Text{ + Layout.minimumWidth: 100 + Layout.preferredWidth: 250 + text: "DISARMED:\n"+get_current_tx_power_int(1)+" "+get_tx_power_unit(); + horizontalAlignment: Qt.AlignHCenter + font.pixelSize: 14 + } + ComboBox { + Layout.minimumWidth: 100 + Layout.preferredWidth: 350 + id: combo_box_txpower_disarmed + model: get_model_txpower_for_chip_type_manufacturer(false) + textRole: "title" + enabled: m_user_selected_card_manufacturer>=0; + font.pixelSize: 14 + onActivated: { + console.log("onActivated: index:"+currentIndex+ " level:"+currentValue); } - var is_tx_power_index_unit = get_chipset_type()==0; - var success = _wbLinkSettingsHelper.set_param_tx_power(!m_is_air,is_tx_power_index_unit,false,tx_power_index_or_mw) - if(success==true){ - _qopenhd.show_toast("SUCCESS"); - }else{ - _qopenhd.show_toast("Cannot change TX power, please try again",true); + } + Button{ + text: "SAVE" + enabled: m_user_selected_card_manufacturer>=0; + onClicked: { + var tx_power_index_or_mw = combo_box_txpower_disarmed.model.get(combo_box_txpower_disarmed.currentIndex).value; + if(tx_power_index_or_mw<0){ + _qopenhd.show_toast("Please select a valid tx power",false); + return; + } + var is_tx_power_index_unit = get_chipset_type()==0; + var success = _wbLinkSettingsHelper.set_param_tx_power(!m_is_air,is_tx_power_index_unit,false,tx_power_index_or_mw) + if(success==true){ + _qopenhd.show_toast("SUCCESS"); + }else{ + _qopenhd.show_toast("Cannot change TX power, please try again",true); + } } + font.pixelSize: 14 } - font.pixelSize: 14 - } - ButtonIconInfo{ - Layout.row: 2 - Layout.column: 3 - onClicked: { - _messageBoxInstance.set_text_and_show("TX Power applied when FC is disarmed"); + ButtonIconInfo{ + onClicked: { + _messageBoxInstance.set_text_and_show("TX Power applied when FC is disarmed"); + } } - } - // FILLER - Item{ - Layout.row: 2 - Layout.column: 4 - Layout.fillWidth: true - } - // ---------------- - Text{ - Layout.row: 3 - Layout.column: 0 - text: { - var power_int=get_current_tx_power_int(2); - if(power_int==0) return "ARMED:\nDISABLED"; - return "ARMED:\n"+get_current_tx_power_int(2)+" "+get_tx_power_unit(); + // FILLER + Item{ + Layout.row: 2 + Layout.column: 4 + Layout.fillWidth: true } - Layout.fillWidth: true - horizontalAlignment: Qt.AlignHCenter - font.pixelSize: 14 } - ComboBox { - Layout.row: 3 - Layout.column: 1 + + RowLayout{ Layout.fillWidth: true - Layout.minimumWidth: 100 - Layout.preferredWidth: 350 - id: combo_box_txpower_armed - model: get_model_txpower_for_chip_type_manufacturer(true) - textRole: "title" - enabled: m_user_selected_card_manufacturer>=0; - font.pixelSize: 14 - } - Button{ - Layout.row: 3 - Layout.column: 2 - text: "SAVE" - enabled: m_user_selected_card_manufacturer>=0; - onClicked: { - var tx_power_index_or_mw = combo_box_txpower_armed.model.get(combo_box_txpower_armed.currentIndex).value; - if(tx_power_index_or_mw<0){ - _qopenhd.show_toast("Please select a valid tx power",false); - return; + Text{ + Layout.minimumWidth: 100 + Layout.preferredWidth: 250 + text: { + var power_int=get_current_tx_power_int(2); + if(power_int==0) return "ARMED:\nDISABLED"; + return "ARMED:\n"+get_current_tx_power_int(2)+" "+get_tx_power_unit(); } - var is_tx_power_index_unit = get_chipset_type()==0; - var success = _wbLinkSettingsHelper.set_param_tx_power(!m_is_air,is_tx_power_index_unit,true,tx_power_index_or_mw) - if(success==true){ - _qopenhd.show_toast("SUCCESS"); - }else{ - _qopenhd.show_toast("Cannot change TX power, please try again",true); + horizontalAlignment: Qt.AlignHCenter + font.pixelSize: 14 + } + ComboBox { + Layout.minimumWidth: 100 + Layout.preferredWidth: 350 + id: combo_box_txpower_armed + model: get_model_txpower_for_chip_type_manufacturer(true) + textRole: "title" + enabled: m_user_selected_card_manufacturer>=0; + font.pixelSize: 14 + } + Button{ + Layout.row: 3 + Layout.column: 2 + text: "SAVE" + enabled: m_user_selected_card_manufacturer>=0; + onClicked: { + var tx_power_index_or_mw = combo_box_txpower_armed.model.get(combo_box_txpower_armed.currentIndex).value; + if(tx_power_index_or_mw<0){ + _qopenhd.show_toast("Please select a valid tx power",false); + return; + } + var is_tx_power_index_unit = get_chipset_type()==0; + var success = _wbLinkSettingsHelper.set_param_tx_power(!m_is_air,is_tx_power_index_unit,true,tx_power_index_or_mw) + if(success==true){ + _qopenhd.show_toast("SUCCESS"); + }else{ + _qopenhd.show_toast("Cannot change TX power, please try again",true); + } } + font.pixelSize: 14 } - 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."); + 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."); + } } } + Text{ - Layout.row: 4 - Layout.column: 0 - text: "CURRENT:\n"+get_current_tx_power_int(0)+" "+get_tx_power_unit(); + Layout.fillWidth: true + Layout.minimumHeight: 50 + text: "WARNING: Selecting the wrong manufacturer and applying a tx power\n can destroy your card !\n"; + color: "red" + //style: Text.Outline + //styleColor: "black" + wrapMode: Text.WordWrap + font.pixelSize: 18 + verticalAlignment: Qt.AlignVCenter horizontalAlignment: Qt.AlignHCenter - font.pixelSize: 14 } Text{ - Layout.row: 4 - Layout.column: 1 - Layout.columnSpan: 2 + Layout.fillWidth: true text: "WARNING: ARMING WILL REDUCE YOUR TX POWER" + //visible: true visible: { var txpower_disarmed=get_current_tx_power_int(1); var txpower_armed=get_current_tx_power_int(2); @@ -413,22 +414,13 @@ Rectangle{ return txpower_armed Date: Mon, 13 Nov 2023 17:18:37 +0100 Subject: [PATCH 47/81] Always disable Qt::AA_DisableHighDpiScaling, vertical speed: fix arrow, style: add @Norbert green --- app/main.cpp | 5 +- qml/qml.qrc | 19 +- qml/ui/configpopup/ConfigPopup.qml | 19 +- .../MavlinkAllSettingsPanel.qml | 1 + .../openhd_settings/OpenHDQuickPanel.qml | 317 ++++++++++++++++++ .../AppWidgetStyleSettingsView.qml | 52 ++- qml/ui/widgets/VerticalSpeedSimpleWidget.qml | 26 +- 7 files changed, 398 insertions(+), 41 deletions(-) create mode 100644 qml/ui/configpopup/openhd_settings/OpenHDQuickPanel.qml diff --git a/app/main.cpp b/app/main.cpp index f3741c4f4..8062b3f3c 100755 --- a/app/main.cpp +++ b/app/main.cpp @@ -195,15 +195,16 @@ int main(int argc, char *argv[]) { QSettings settings; - const int screen_custom_font_dpi = settings.value("screen_custom_font_dpi").toInt(); + /*const int screen_custom_font_dpi = settings.value("screen_custom_font_dpi").toInt(); if (screen_custom_font_dpi) { QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); const std::string font_dpi_s = std::to_string(screen_custom_font_dpi); qputenv("QT_FONT_DPI", QByteArray(font_dpi_s.c_str(), font_dpi_s.length())); } else { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - } + }*/ //QCoreApplication::setAttribute(Qt::AA_UseOpenGLES); + QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); // From https://stackoverflow.com/questions/63473541/how-to-dynamically-toggle-vsync-in-a-qt-application-at-runtime // Get rid of VSYNC if possible. Might / might not work. On my ubuntu nvidia & intel laptop, this at least seems to diff --git a/qml/qml.qrc b/qml/qml.qrc index 09d76a5bc..a55592295 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -1,33 +1,33 @@ - + ../translations/QOpenHD_en.qm resources/cursors/arrow_512_green.png resources/cursors/arrow_512_transparent.png resources/cursors/arrow_512_white.png resources/cursors/hand_white.png - + ../translations/QOpenHD_de.qm - + ../translations/QOpenHD_ru.qm - + ../translations/QOpenHD_es.qm - + ../translations/QOpenHD_fr.qm - + ../translations/QOpenHD_nl.qm - + ../translations/QOpenHD_ro.qm - + ../translations/QOpenHD_it.qm - + ../translations/QOpenHD_zh.qm @@ -261,5 +261,6 @@ video/SecondaryVideoGstreamerPane.qml ui/elements/SettingsHeaderElement.qml ui/configpopup/qopenhd_settings/AppWidgetStyleSettingsView.qml + ui/configpopup/openhd_settings/OpenHDQuickPanel.qml diff --git a/qml/ui/configpopup/ConfigPopup.qml b/qml/ui/configpopup/ConfigPopup.qml index cdc9f3175..0c8ad91ca 100644 --- a/qml/ui/configpopup/ConfigPopup.qml +++ b/qml/ui/configpopup/ConfigPopup.qml @@ -19,9 +19,13 @@ import "status" // Contains the selector on the left and a stack view for the panels on the right Rectangle { id: settings_form - - // The connect is only needed when qopenhd is not running on the ground system itself (e.g. android) - property bool m_show_connect_option: true // _qopenhd.is_android() + //width: 1280 + //height: 720 + anchors.fill: parent + //width: parent.width * settings.screen_settings_overlay_size_percent / 100; + //height: parent.height * settings.screen_settings_overlay_size_percent / 100; + z: 4.0 + color: "transparent" // size of the elements in the left bar - e.g. what allows switching between all the tabs property int left_sidebar_elements_height: 46 @@ -64,14 +68,6 @@ Rectangle { } }*/ - //anchors.fill: parent - width: parent.width * settings.screen_settings_overlay_size_percent / 100; - height: parent.height * settings.screen_settings_overlay_size_percent / 100; - - z: 4.0 - - color: "transparent" - Rectangle { id: spacerTopSpacer width: 132 @@ -210,7 +206,6 @@ Rectangle { // We only need the connect panel on android (external device) // On localhost, QOpenHD "automatically" connects due to udp localhost method ConfigPopupSidebarButton{ - visible: m_show_connect_option id: connect_button m_icon_text: "\uf6ff" m_description_text: "Connect" diff --git a/qml/ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml b/qml/ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml index 00b63a38e..71eef0109 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml +++ b/qml/ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml @@ -64,6 +64,7 @@ Rectangle { currentIndex: selectItemInStackLayoutBar.currentIndex MavlinkOpenHDWBParamPanel{ + //OpenHDQuickPanel{ id: mavlink_openhd_wb_param_panel } MavlinkParamPanel{ diff --git a/qml/ui/configpopup/openhd_settings/OpenHDQuickPanel.qml b/qml/ui/configpopup/openhd_settings/OpenHDQuickPanel.qml new file mode 100644 index 000000000..edf497fba --- /dev/null +++ b/qml/ui/configpopup/openhd_settings/OpenHDQuickPanel.qml @@ -0,0 +1,317 @@ +import QtQuick 2.0 + +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Dialogs 1.0 +import QtQuick.Controls.Material 2.12 +import QtQuick.Controls.Styles 1.4 + +import Qt.labs.settings 1.0 + +import OpenHD 1.0 + +import "../../../ui" as Ui +import "../../elements" + +import QtCharts 2.0 + +// This is an extra screen for changing the frequency / channel width - +// They both need to match ! +Rectangle{ + id: main_background + width: parent.width + height: parent.height + //property color m_background_color: "#8cbfd7f3" + //property color m_background_color: "#ADD8E6" + property color m_background_color: "#8cbfd7f3" + + property int m_small_width: 200 + + function user_quidance_animate_channel_scan(){ + console.log("User guidance animate channel scan"); + anim_find_air_unit.start() + } + + // https://stackoverflow.com/questions/41991438/how-do-i-find-a-particular-listelement-inside-a-listmodel-in-qml + // For the models above (model with value) try to find the index of the first item where model[i].value===value + function find_index(model,value){ + for(var i = 0; i < model.count; ++i) if (model.get(i).value===value) return i + return -1 + } + + function fc_is_armed(){ + return _fcMavlinkSystem.armed + } + + ListModel{ + id: frequencies_model_all + ListElement {title: "Unknown"; value_frequency_mhz:-1} + } + ListModel{ + id: frequencies_model_openhd_channels_only + ListElement {title: "Unknown"; value_frequency_mhz:-1} + } + + function create_list_models_frequency(){ + frequencies_model_all.clear(); + const frequencies_all=_frequencyHelper.get_frequencies(false); + for(var i=0;i0){ + var index=find_index(comboBoxFreq.model,_wbLinkSettingsHelper.curr_channel_mhz); + if(index>=0){ + comboBoxFreq.currentIndex=index; + }else{ + comboBoxFreq.currentIndex=0; + console.log("Seems not to be a valid channel "+_wbLinkSettingsHelper.curr_channel_mhz) + } + }else{ + comboBoxFreq.currentIndex=-1; + } + } + + // We get notified every time we should re-build the model(s) and their current selection + property int m_ui_rebuild_models : _wbLinkSettingsHelper.ui_rebuild_models + onM_ui_rebuild_modelsChanged: { + console.log(" onM_ui_rebuild_modelsChanged: "+_wbLinkSettingsHelper.ui_rebuild_models); + function_rebuild_ui() + } + + function function_rebuild_ui(){ + update_frequency_combobox(); + console.log("function_rebuild_ui:"+_wbLinkSettingsHelper.ui_rebuild_models); + if(_wbLinkSettingsHelper.ui_rebuild_models<=0)return + popup_analyze_channels.update(); + } + + // + function close_all_dialoques(){ + popup_analyze_channels.close() + popup_scan_channels.close(); + popup_change_tx_power.close(); + dialoqueFreqChangeGndOnly.close(); + dialoqueFreqChangeAirGnd.close(); + popup_enable_stbc_ldpc.close(); + } + + function get_text_stbc_ldpc(air){ + if(air){ + if(!_ohdSystemAir.is_alive)return "N/A"; + return ""+(_ohdSystemAir.wb_stbc_enabled ? "YES" : "NO")+"/"+(_ohdSystemAir.wb_lpdc_enabled ? "YES" : "NO"); + } + if(!_ohdSystemGround.is_alive)return "N/A"; + return ""+(_ohdSystemGround.wb_stbc_enabled ? "YES" : "NO")+"/"+(_ohdSystemGround.wb_lpdc_enabled ? "YES" : "NO"); + } + + Component.onCompleted: { + close_all_dialoques(); + create_list_models_frequency(); + update_frequency_combobox(); + } + + function get_text_wifi_tx_power(air){ + if(air){ + if(!_wifi_card_air.alive) return "N/A"; + return ""+_wifi_card_air.tx_power+" "+_wifi_card_air.tx_power_unit; + } + if(!_wifi_card_gnd0.alive) return "N/A"; + return ""+_wifi_card_gnd0.tx_power+" "+_wifi_card_gnd0.tx_power_unit; + } + + ScrollView { + id: main_scroll_view + width: parent.width + height: parent.height + anchors.centerIn: parent + contentHeight: main_column_layout.height + //contentWidth: main_column_layout.width + //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) + + Column{ + width: parent.width + height: 900 + id: main_column_layout + + Text{ + width: parent.width + height: 50 + text: "FREQUENCY / TOOLKIT" + font.bold: true + horizontalAlignment: Qt.AlignHCenter + verticalAlignment: Qt.AlignVCenter + } + + Row{ + width: parent.width + height: 50 + ComboBox { + id: comboBoxFreq + //model: supported_frequencies_model + //model: frequencies_model_openhd_channels_only + textRole: "title" + implicitWidth: elementComboBoxWidth + currentIndex: 0 + delegate: ItemDelegate { + width: comboBoxFreq.width + contentItem: FreqComboBoxRow{ + m_main_text: title + m_selection_tpye: (value_frequency_mhz===_wbLinkSettingsHelper.curr_channel_mhz) ? 1 : 0 + m_is_2G: value_frequency_mhz < 3000 && value_frequency_mhz > 100 + m_show_radar: _frequencyHelper.get_frequency_radar(value_frequency_mhz) + m_openhd_race_band: _frequencyHelper.get_frequency_openhd_race_band(value_frequency_mhz) + m_pollution_pps: _pollutionHelper.pollution_get_last_scan_pollution_for_frequency(value_frequency_mhz) + } + highlighted: comboBoxFreq.highlightedIndex === index + } + Layout.row: 1 + Layout.column: 0 + displayText: { + if(!_ohdSystemGround.is_alive)return "NO FREQUENCY"; // GND NOT ALIVE + if(_ohdSystemGround.wb_gnd_operating_mode==1){ + return "SCANNING"; + } + if(_ohdSystemGround.wb_gnd_operating_mode==2){ + return "ANALYZING"; + } + if(!_ohdSystemAir.is_alive){ + return _wbLinkSettingsHelper.curr_channel_mhz+"@"+"N/A"+" Mhz (NO AIR)"; + } + return _wbLinkSettingsHelper.curr_channel_mhz+"@"+_wbLinkSettingsHelper.curr_channel_width_mhz+" Mhz"; + } + onActivated: { + console.log("onActivated:"+currentIndex); + if(currentIndex<0)return; + const frequency_mhz=comboBoxFreq.model.get(currentIndex).value_frequency_mhz + console.log("Selected frequency: "+frequency_mhz); + if(!_frequencyHelper.hw_supports_frequency_threadsafe(frequency_mhz)){ + _qopenhd.show_toast("your HW does not support "+frequency_mhz+" Mhz"); + return; + } + if(_wbLinkSettingsHelper.curr_channel_mhz==frequency_mhz){ + console.log("Already at frequency "+frequency_mhz); + return; + } + if(!_ohdSystemAir.is_alive){ + var error_message_not_alive="AIR Unit not alive -" + dialoqueFreqChangeGndOnly.initialize_and_show_frequency(frequency_mhz,error_message_not_alive); + return; + } + // Change the freuquency + dialoqueFreqChangeAirGnd.initialize_and_show_frequency(frequency_mhz); + } + enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0; + } + Switch{ + Layout.row: 1 + Layout.column: 1 + Layout.columnSpan: 1 + text: "SIMPLIFY" + checked: true + onCheckedChanged: { + if(m_simplify_enable!=checked){ + m_simplify_enable=checked; + function_rebuild_ui(); + } + } + } + } + + Row{ + width: parent.width + height: 50 + Button{ + Layout.preferredWidth: 150 + id: b_find_air_unit + text: "SCAN" + enabled: _ohdSystemGround.is_alive + onClicked: { + close_all_dialoques(); + popup_scan_channels.open() + } + SequentialAnimation { + running: false + loops: 4 + id: anim_find_air_unit + // Expand the button + PropertyAnimation { + target: b_find_air_unit + property: "scale" + to: 1.5 + duration: 200 + easing.type: Easing.InOutQuad + } + // Shrink back to normal + PropertyAnimation { + target: b_find_air_unit + property: "scale" + to: 1.0 + duration: 200 + easing.type: Easing.InOutQuad + } + } + } + Button{ + Layout.preferredWidth: 150 + text: "ANALYZE" + enabled: _ohdSystemGround.is_alive + onClicked: { + close_all_dialoques(); + popup_analyze_channels.open() + } + } + } + + Row{ + width: parent.width + height: 50 + Text{ + text: "TX POWER AIR" + } + } + } + } + + PopupAnalyzeChannels{ + id: popup_analyze_channels + } + + PopupScanChannels{ + id: popup_scan_channels + } + + PopupTxPowerEditor{ + id: popup_change_tx_power + } + PopupEnableSTBCLDPC{ + id: popup_enable_stbc_ldpc + } + + DialoqueFreqChangeGndOnly{ + id: dialoqueFreqChangeGndOnly + } + DialoqueFreqChangeAirGnd{ + id: dialoqueFreqChangeAirGnd + } +} diff --git a/qml/ui/configpopup/qopenhd_settings/AppWidgetStyleSettingsView.qml b/qml/ui/configpopup/qopenhd_settings/AppWidgetStyleSettingsView.qml index 41f9bc24f..51fa05f76 100644 --- a/qml/ui/configpopup/qopenhd_settings/AppWidgetStyleSettingsView.qml +++ b/qml/ui/configpopup/qopenhd_settings/AppWidgetStyleSettingsView.qml @@ -28,6 +28,56 @@ ScrollView { anchors.left: parent.left anchors.right: parent.right + //SettingBaseElement + Rectangle { + width: parent.width + height: rowHeight + color: (Positioner.index % 2 == 0) ? "#8cbfd7f3" : "#00000000" + RowLayout{ + anchors.fill: parent + anchors.leftMargin: 8 + anchors.rightMargin: 8 + Text{ + Layout.alignment: Qt.AlignLeft + text: "PRESETS\nColor/Font" + font.weight: Font.Bold + font.pixelSize: 13 + } + Item{ // filler + Layout.fillWidth: true + Layout.fillHeight: true + } + Button{ + text: "GREEN\n@Norbert" + Layout.alignment: Qt.AlignRight + Layout.leftMargin: 10 + Layout.rightMargin: 10 + onClicked: { + settings.color_caution="yellow" + settings.color_glow="black" + settings.color_shape="#ff14ff00" + settings.color_text="#ff05ff00" + settings.color_warn="red" + //settings.font_text="Quicksand" + } + } + Button{ + text: "RESET" + Layout.alignment: Qt.AlignRight + Layout.leftMargin: 10 + Layout.rightMargin: 10 + onClicked: { + settings.color_shape="white" + settings.color_text= "white" + settings.color_glow= "black" + settings.color_warn= "red" + settings.color_caution= "yellow" + settings.font_text= "Sans Serif" + } + } + } + } + Rectangle { width: parent.width height: rowHeight @@ -181,7 +231,7 @@ ScrollView { anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizonatalCenter } - } + } } } } diff --git a/qml/ui/widgets/VerticalSpeedSimpleWidget.qml b/qml/ui/widgets/VerticalSpeedSimpleWidget.qml index 207013fe0..9576654f0 100644 --- a/qml/ui/widgets/VerticalSpeedSimpleWidget.qml +++ b/qml/ui/widgets/VerticalSpeedSimpleWidget.qml @@ -136,6 +136,7 @@ BaseWidget { id: widgetInner anchors.fill: parent opacity: bw_current_opacity + scale: bw_current_scale Text { id: speedtext @@ -144,32 +145,23 @@ BaseWidget { color: settings.color_text font.pixelSize: 14 font.family: settings.font_text - transform: Scale { - origin.x: 12 - origin.y: 12 - xScale: bw_current_scale - yScale: bw_current_scale - } - text: get_text_vertical_speed() + text: get_text_vertical_speed(); horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter style: Text.Outline styleColor: settings.color_glow } + // This is an 'icon' indication movement up / down Text{ + height: parent.height + width: parent.width / 3; anchors.right: speedtext.left anchors.bottom: speedtext.bottom - color: settings.color_text - font.pixelSize: 28 - font.family: settings.font_text - transform: Scale { - origin.x: 12 - origin.y: 12 - xScale: bw_current_scale - yScale: bw_current_scale - } + color: settings.color_shape + font.pixelSize: 14 + font.family: "Font Awesome 5 Free" text: get_text_icon_vertical_speed() - horizontalAlignment: Text.AlignHCenter + horizontalAlignment: Text.AlignRight verticalAlignment: Text.AlignVCenter style: Text.Outline styleColor: settings.color_glow From 6ef727202cc20ae1c7e3db395257a7a9e5579247 Mon Sep 17 00:00:00 2001 From: consti10 Date: Tue, 14 Nov 2023 01:32:16 +0100 Subject: [PATCH 48/81] status: fill width, openhd quick: center elements (fix usability on low res screens) --- qml/qml.qrc | 22 +- .../MavlinkOpenHDWBParamPanel.qml | 553 +++++++++--------- .../openhd_settings/OpenHDQuickPanel.qml | 62 +- .../status/FooterRebootShutdownWarning.qml | 11 +- qml/ui/configpopup/status/PanelStatus.qml | 31 +- .../configpopup/status/StatusCardsColumn.qml | 6 +- qml/ui/elements/BaseHeaderItem.qml | 28 + qml/ui/elements/ButtonIconConnect.qml | 13 + qml/ui/elements/ButtonIconInfo2.qml | 12 + qml/ui/elements/CardBasic.qml | 8 + 10 files changed, 422 insertions(+), 324 deletions(-) create mode 100644 qml/ui/elements/BaseHeaderItem.qml create mode 100644 qml/ui/elements/ButtonIconConnect.qml create mode 100644 qml/ui/elements/ButtonIconInfo2.qml create mode 100644 qml/ui/elements/CardBasic.qml diff --git a/qml/qml.qrc b/qml/qml.qrc index a55592295..6a259d6c2 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -1,33 +1,33 @@ - + ../translations/QOpenHD_en.qm resources/cursors/arrow_512_green.png resources/cursors/arrow_512_transparent.png resources/cursors/arrow_512_white.png resources/cursors/hand_white.png - + ../translations/QOpenHD_de.qm - + ../translations/QOpenHD_ru.qm - + ../translations/QOpenHD_es.qm - + ../translations/QOpenHD_fr.qm - + ../translations/QOpenHD_nl.qm - + ../translations/QOpenHD_ro.qm - + ../translations/QOpenHD_it.qm - + ../translations/QOpenHD_zh.qm @@ -262,5 +262,9 @@ ui/elements/SettingsHeaderElement.qml ui/configpopup/qopenhd_settings/AppWidgetStyleSettingsView.qml ui/configpopup/openhd_settings/OpenHDQuickPanel.qml + ui/elements/BaseHeaderItem.qml + ui/elements/ButtonIconInfo2.qml + ui/elements/CardBasic.qml + ui/elements/ButtonIconConnect.qml diff --git a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml index 17bd50434..b81f2a540 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml +++ b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml @@ -144,340 +144,317 @@ Rectangle{ height: parent.height anchors.centerIn: parent contentHeight: main_column_layout.height - contentWidth: main_column_layout.width + //contentWidth: main_column_layout.width //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) ColumnLayout{ - Layout.fillWidth: true - Layout.fillHeight: true + width: main_scroll_view.width id: main_column_layout + Layout.margins: 10 + BaseHeaderItem{ + m_text: "FREQUENCY / TOOLKIT" + } - Rectangle { - id: frequency_area_layout_background - color: m_background_color - implicitWidth: main_scroll_view.width - implicitHeight: frequency_area_layout.implicitHeight+5 - radius: 10 - - ColumnLayout { - id: frequency_area_layout + RowLayout{ + Layout.fillWidth: true + Item{ // FILLER Layout.fillWidth: true - Layout.fillHeight: true - Layout.margins: 10 - - Text{ - Layout.row: 0 - Layout.column: 0 - text: "FREQUENCY / TOOLKIT" - font.bold: true + } + ComboBox { + Layout.alignment: Qt.AlignCenter + Layout.preferredWidth: elementComboBoxWidth + id: comboBoxFreq + //model: supported_frequencies_model + //model: frequencies_model_openhd_channels_only + textRole: "title" + implicitWidth: elementComboBoxWidth + currentIndex: 0 + delegate: ItemDelegate { + width: comboBoxFreq.width + contentItem: FreqComboBoxRow{ + m_main_text: title + m_selection_tpye: (value_frequency_mhz===_wbLinkSettingsHelper.curr_channel_mhz) ? 1 : 0 + m_is_2G: value_frequency_mhz < 3000 && value_frequency_mhz > 100 + m_show_radar: _frequencyHelper.get_frequency_radar(value_frequency_mhz) + m_openhd_race_band: _frequencyHelper.get_frequency_openhd_race_band(value_frequency_mhz) + m_pollution_pps: _pollutionHelper.pollution_get_last_scan_pollution_for_frequency(value_frequency_mhz) + } + highlighted: comboBoxFreq.highlightedIndex === index } - - RowLayout{ - ComboBox { - id: comboBoxFreq - //model: supported_frequencies_model - //model: frequencies_model_openhd_channels_only - textRole: "title" - implicitWidth: elementComboBoxWidth - currentIndex: 0 - delegate: ItemDelegate { - width: comboBoxFreq.width - contentItem: FreqComboBoxRow{ - m_main_text: title - m_selection_tpye: (value_frequency_mhz===_wbLinkSettingsHelper.curr_channel_mhz) ? 1 : 0 - m_is_2G: value_frequency_mhz < 3000 && value_frequency_mhz > 100 - m_show_radar: _frequencyHelper.get_frequency_radar(value_frequency_mhz) - m_openhd_race_band: _frequencyHelper.get_frequency_openhd_race_band(value_frequency_mhz) - m_pollution_pps: _pollutionHelper.pollution_get_last_scan_pollution_for_frequency(value_frequency_mhz) - } - highlighted: comboBoxFreq.highlightedIndex === index - } - Layout.row: 1 - Layout.column: 0 - displayText: { - if(!_ohdSystemGround.is_alive)return "GND NOT ALIVE"; - if(_ohdSystemGround.wb_gnd_operating_mode==1){ - return "SCANNING"; - } - if(_ohdSystemGround.wb_gnd_operating_mode==2){ - return "ANALYZING"; - } - if(!_ohdSystemAir.is_alive){ - return _wbLinkSettingsHelper.curr_channel_mhz+"@"+"N/A"+" Mhz (NO AIR)"; - } - return _wbLinkSettingsHelper.curr_channel_mhz+"@"+_wbLinkSettingsHelper.curr_channel_width_mhz+" Mhz"; - } - onActivated: { - console.log("onActivated:"+currentIndex); - if(currentIndex<0)return; - const frequency_mhz=comboBoxFreq.model.get(currentIndex).value_frequency_mhz - console.log("Selected frequency: "+frequency_mhz); - if(!_frequencyHelper.hw_supports_frequency_threadsafe(frequency_mhz)){ - _qopenhd.show_toast("your HW does not support "+frequency_mhz+" Mhz"); - return; - } - if(_wbLinkSettingsHelper.curr_channel_mhz==frequency_mhz){ - console.log("Already at frequency "+frequency_mhz); - return; - } - if(!_ohdSystemAir.is_alive){ - var error_message_not_alive="AIR Unit not alive -" - dialoqueFreqChangeGndOnly.initialize_and_show_frequency(frequency_mhz,error_message_not_alive); - return; - } - // Change the freuquency - dialoqueFreqChangeAirGnd.initialize_and_show_frequency(frequency_mhz); - } - enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0; + displayText: { + if(!_ohdSystemGround.is_alive)return "GND NOT ALIVE"; + if(_ohdSystemGround.wb_gnd_operating_mode==1){ + return "SCANNING"; } - Switch{ - Layout.row: 1 - Layout.column: 1 - Layout.columnSpan: 1 - text: "SIMPLIFY" - checked: true - onCheckedChanged: { - if(m_simplify_enable!=checked){ - m_simplify_enable=checked; - function_rebuild_ui(); - } - } + if(_ohdSystemGround.wb_gnd_operating_mode==2){ + return "ANALYZING"; } - ButtonIconInfo{ - Layout.row: 1 - Layout.column: 2 - onClicked: { - var text="Please select a channel / frequency free of noise and interference. The current loss / pollution / throttle stats below can help,"+ - "as well as the analyze channels feature or a frequency analyzer on your phone. SIMPLIFY: Show OpenHD standard channels [1-5] only - they "+ - " often are free of wifi pollution and should be used. Only disable SIMPLIFY if you know exactly why." - _messageBoxInstance.set_text_and_show(text) - } + if(!_ohdSystemAir.is_alive){ + return _wbLinkSettingsHelper.curr_channel_mhz+"@"+"N/A"+" Mhz (NO AIR)"; } + return _wbLinkSettingsHelper.curr_channel_mhz+"@"+_wbLinkSettingsHelper.curr_channel_width_mhz+" Mhz"; } - - - - RowLayout{ - Layout.row: 2 - Layout.column: 0 - Layout.columnSpan: 3 - Item{ // FILLER - Layout.preferredWidth: 30 - Layout.minimumWidth: 0 + onActivated: { + console.log("onActivated:"+currentIndex); + if(currentIndex<0)return; + const frequency_mhz=comboBoxFreq.model.get(currentIndex).value_frequency_mhz + console.log("Selected frequency: "+frequency_mhz); + if(!_frequencyHelper.hw_supports_frequency_threadsafe(frequency_mhz)){ + _qopenhd.show_toast("your HW does not support "+frequency_mhz+" Mhz"); + return; } - Button{ - Layout.preferredWidth: 150 - id: b_find_air_unit - text: "SCAN" - enabled: _ohdSystemGround.is_alive - onClicked: { - close_all_dialoques(); - popup_scan_channels.open() - } - SequentialAnimation { - running: false - loops: 4 - id: anim_find_air_unit - // Expand the button - PropertyAnimation { - target: b_find_air_unit - property: "scale" - to: 1.5 - duration: 200 - easing.type: Easing.InOutQuad - } - // Shrink back to normal - PropertyAnimation { - target: b_find_air_unit - property: "scale" - to: 1.0 - duration: 200 - easing.type: Easing.InOutQuad - } - } + if(_wbLinkSettingsHelper.curr_channel_mhz==frequency_mhz){ + console.log("Already at frequency "+frequency_mhz); + return; } - Item{ // FILLER - Layout.preferredWidth: 30 - Layout.minimumWidth: 0 + if(!_ohdSystemAir.is_alive){ + var error_message_not_alive="AIR Unit not alive -" + dialoqueFreqChangeGndOnly.initialize_and_show_frequency(frequency_mhz,error_message_not_alive); + return; } - Button{ - Layout.preferredWidth: 150 - text: "ANALYZE" - enabled: _ohdSystemGround.is_alive - onClicked: { - close_all_dialoques(); - popup_analyze_channels.open() - } + // Change the freuquency + dialoqueFreqChangeAirGnd.initialize_and_show_frequency(frequency_mhz); + } + enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0; + } + Switch{ + Layout.alignment: Qt.AlignCenter + text: "SIMPLIFY" + checked: true + onCheckedChanged: { + if(m_simplify_enable!=checked){ + m_simplify_enable=checked; + function_rebuild_ui(); + } + } + } + Item{ // FILLER + Layout.fillWidth: true + } + ButtonIconInfo2{ + Layout.alignment: Qt.AlignRight + onClicked: { + var text="Please select a channel / frequency free of noise and interference. The current loss / pollution / throttle stats below can help,"+ + "as well as the analyze channels feature or a frequency analyzer on your phone. SIMPLIFY: Show OpenHD standard channels [1-5] only - they "+ + " often are free of wifi pollution and should be used. Only disable SIMPLIFY if you know exactly why." + _messageBoxInstance.set_text_and_show(text) + } + } + } + + RowLayout{ + Layout.fillWidth: true + Item{ // FILLER + Layout.fillWidth: true + } + Button{ + Layout.alignment: Qt.AlignCenter + Layout.preferredWidth: 150 + id: b_find_air_unit + text: "SCAN" + enabled: _ohdSystemGround.is_alive + onClicked: { + close_all_dialoques(); + popup_scan_channels.open() + } + SequentialAnimation { + running: false + loops: 4 + id: anim_find_air_unit + // Expand the button + PropertyAnimation { + target: b_find_air_unit + property: "scale" + to: 1.5 + duration: 200 + easing.type: Easing.InOutQuad } - Item{ // FILLER - Layout.preferredWidth: 30 - Layout.minimumWidth: 0 + // Shrink back to normal + PropertyAnimation { + target: b_find_air_unit + property: "scale" + to: 1.0 + duration: 200 + easing.type: Easing.InOutQuad } - ButtonIconInfo{ + } + } + Button{ + Layout.alignment: Qt.AlignCenter + Layout.preferredWidth: 150 + text: "ANALYZE" + enabled: _ohdSystemGround.is_alive + onClicked: { + close_all_dialoques(); + popup_analyze_channels.open() + } + } + Item{ // FILLER + Layout.fillWidth: true + } + /*ButtonIconInfo{ onClicked: { var text="SCAN: Similar to analoque channel scan, find a running air unit by checking all possible channels (frequencies).\n\n"+ "ANALYZE: Analyze channels for WiFi pollution. Read the wiki for more info."; _messageBoxInstance.set_text_and_show(text) } - } + }*/ + } + RowLayout{ + Layout.fillWidth: true + Item{ // FILLER + Layout.fillWidth: true + } + Text{ + Layout.preferredHeight: 50 + Layout.preferredWidth: 120 + text:{ + "LOSS:\n"+_ohdSystemGround.curr_rx_packet_loss_perc+"%" } - RowLayout{ - Text{ - Layout.preferredHeight: 50 - Layout.preferredWidth: 120 - text:{ - "LOSS:\n"+_ohdSystemGround.curr_rx_packet_loss_perc+"%" - } - color: _ohdSystemGround.curr_rx_packet_loss_perc > 5 ? "red" : "black" - verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignHCenter - font.bold: true - } - Text{ - Layout.preferredHeight: 50 - Layout.preferredWidth: 120 - text: { - return "POLLUTION:\n"+_ohdSystemGround.wb_link_curr_foreign_pps+"pps" - } - color: _ohdSystemGround.wb_link_curr_foreign_pps > 20 ? "red" : "black" - verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignHCenter - font.bold: true - } - Text{ - Layout.preferredHeight: 50 - Layout.preferredWidth: 120 - text: { - return "THROTTLE:\n"+_ohdSystemAir.curr_n_rate_adjustments - } - color: _ohdSystemAir.curr_n_rate_adjustments > 0 ? "red" : "black" - verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignHCenter - font.bold: true - } - ButtonIconInfo{ + color: _ohdSystemGround.curr_rx_packet_loss_perc > 5 ? "red" : "black" + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + Text{ + Layout.preferredHeight: 50 + Layout.preferredWidth: 120 + text: { + return "POLLUTION:\n"+_ohdSystemGround.wb_link_curr_foreign_pps+"pps" + } + color: _ohdSystemGround.wb_link_curr_foreign_pps > 20 ? "red" : "black" + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + Text{ + Layout.preferredHeight: 50 + Layout.preferredWidth: 120 + text: { + return "THROTTLE:\n"+_ohdSystemAir.curr_n_rate_adjustments + } + color: _ohdSystemAir.curr_n_rate_adjustments > 0 ? "red" : "black" + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + Item{ // FILLER + Layout.fillWidth: true + } + /*ButtonIconInfo{ onClicked: { var text="High Loss / Pollution / active throttle hint at a polluted channel." _messageBoxInstance.set_text_and_show(text) } } ButtonIconWarning{ - visible: /*_ohdSystemAir.is_alive &&*/ (_ohdSystemGround.curr_rx_packet_loss_perc > 5 || _ohdSystemGround.wb_link_curr_foreign_pps > 20 || _ohdSystemAir.curr_n_rate_adjustments > 0) + visible: (_ohdSystemGround.curr_rx_packet_loss_perc > 5 || _ohdSystemGround.wb_link_curr_foreign_pps > 20 || _ohdSystemAir.curr_n_rate_adjustments > 0) onClicked: { var text="On the bench, if you encounter issues like a high loss , high pollution or throttling, make sure:\n"+ "1) You are using a channel free of noise and interference (OHD channel 1-5 are a good bet)\n"+ "2) (RARELY,RTL8812AU only): Your TX card(s) aren't overamplifying the signal and have adequate cooling."; _messageBoxInstance.set_text_and_show(text) } - } - } - } + }*/ + } + + BaseHeaderItem{ + m_text: "TX POWER" } - Rectangle { - implicitWidth: main_scroll_view.width - implicitHeight: tx_power_layout.implicitHeight - id: tx_power_layout_background - color: m_background_color - radius: 10 - - RowLayout { - id: tx_power_layout + + RowLayout { + id: tx_power_layout + Layout.fillWidth: true + Layout.fillHeight: true + + Item{ // FILLER Layout.fillWidth: true - Layout.fillHeight: true - Text{ - text: "TX POWER" - font.bold: true - } - Text{ - Layout.preferredWidth: 120 - text: "AIR:\n "+get_text_wifi_tx_power(true) - verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignHCenter - font.bold: true - } - Button{ - text: "EDIT" - enabled: _ohdSystemAir.is_alive - onClicked: { - close_all_dialoques(); - popup_change_tx_power.m_is_air=true; - popup_change_tx_power.open() - } - } - Text{ - Layout.preferredWidth: 120 - text: "GND:\n"+get_text_wifi_tx_power(false) - verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignHCenter - font.bold: true + } + Text{ + Layout.preferredWidth: 120 + text: "AIR:\n "+get_text_wifi_tx_power(true) + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + Button{ + text: "EDIT" + enabled: _ohdSystemAir.is_alive + onClicked: { + close_all_dialoques(); + popup_change_tx_power.m_is_air=true; + popup_change_tx_power.open() } - Button{ - text: "EDIT" - enabled: _ohdSystemGround.is_alive - onClicked: { - close_all_dialoques(); - popup_change_tx_power.m_is_air=false; - popup_change_tx_power.open() - } + } + Text{ + Layout.preferredWidth: 120 + text: "GND:\n"+get_text_wifi_tx_power(false) + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + Button{ + text: "EDIT" + enabled: _ohdSystemGround.is_alive + onClicked: { + close_all_dialoques(); + popup_change_tx_power.m_is_air=false; + popup_change_tx_power.open() } } - } - Rectangle { - implicitWidth: main_scroll_view.width - implicitHeight: stbc_ldpc_layout.implicitHeight - id: stbc_ldpc_background - color: m_background_color - radius: 10 - - RowLayout { - id: stbc_ldpc_layout + Item{ // FILLER Layout.fillWidth: true - Layout.fillHeight: true - // STBC / LDPC - Text{ - width: 200 - text: "ADVANCED (STBC,LDPC)" - font.bold: true - horizontalAlignment: Qt.AlignHCenter - } - Text{ - Layout.preferredWidth: 120 - text: "AIR:\n"+get_text_stbc_ldpc(true); - verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignHCenter - font.bold: true - } - Text{ - Layout.preferredWidth: 120 - text: "GND:\n"+get_text_stbc_ldpc(false); - verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignHCenter - font.bold: true - } + } + } - Button{ - text: "EDIT"; - //enabled: true - enabled: _ohdSystemAir.is_alive && _ohdSystemGround.is_alive && (_wbLinkSettingsHelper.ui_rebuild_models>=0) && - (_ohdSystemGround.wb_stbc_enabled!=true || _ohdSystemGround.wb_lpdc_enabled!=true || _ohdSystemAir.wb_stbc_enabled!=true || _ohdSystemAir.wb_lpdc_enabled!=true); - onClicked: { - close_all_dialoques(); - popup_enable_stbc_ldpc.open() - } - } - ButtonIconInfo{ - Layout.row: 1 - Layout.column: 4 - onClicked: { - _messageBoxInstance.set_text_and_show("STBC / LDPC : Greatly increases range, but requires 2 RF paths (2 Antennas) on BOTH your air and ground station."+ - "WARNING: Enabling STBC with the wrong hardware (only 1 antenna / only one rf path) results in no connectivity "+ - "and you need to re-flash your air / ground unit to recover !"); - } + BaseHeaderItem{ + m_text: "ADVANCED (STBC,LDPC)" + } + + RowLayout { + id: stbc_ldpc_layout + Layout.fillWidth: true + Layout.fillHeight: true + Item{ // FILLER + Layout.fillWidth: true + } + Text{ + Layout.preferredWidth: 120 + text: "AIR:\n"+get_text_stbc_ldpc(true); + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + Text{ + Layout.preferredWidth: 120 + text: "GND:\n"+get_text_stbc_ldpc(false); + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + Button{ + text: "EDIT"; + //enabled: true + enabled: _ohdSystemAir.is_alive && _ohdSystemGround.is_alive && (_wbLinkSettingsHelper.ui_rebuild_models>=0) && + (_ohdSystemGround.wb_stbc_enabled!=true || _ohdSystemGround.wb_lpdc_enabled!=true || _ohdSystemAir.wb_stbc_enabled!=true || _ohdSystemAir.wb_lpdc_enabled!=true); + onClicked: { + close_all_dialoques(); + popup_enable_stbc_ldpc.open() } } + Item{ // FILLER + Layout.fillWidth: true + } + /*ButtonIconInfo{ + onClicked: { + _messageBoxInstance.set_text_and_show("STBC / LDPC : Greatly increases range, but requires 2 RF paths (2 Antennas) on BOTH your air and ground station."+ + "WARNING: Enabling STBC with the wrong hardware (only 1 antenna / only one rf path) results in no connectivity "+ + "and you need to re-flash your air / ground unit to recover !"); + } + }*/ } } } diff --git a/qml/ui/configpopup/openhd_settings/OpenHDQuickPanel.qml b/qml/ui/configpopup/openhd_settings/OpenHDQuickPanel.qml index edf497fba..327fc3281 100644 --- a/qml/ui/configpopup/openhd_settings/OpenHDQuickPanel.qml +++ b/qml/ui/configpopup/openhd_settings/OpenHDQuickPanel.qml @@ -149,23 +149,23 @@ Rectangle{ ScrollBar.vertical.interactive: true visible: (!popup_analyze_channels.visible && !popup_enable_stbc_ldpc.visible && !popup_change_tx_power.visible && !popup_scan_channels.visible) - Column{ - width: parent.width - height: 900 - id: main_column_layout + Column{ + spacing: 0 + anchors.left: parent.left + anchors.right: parent.right + id: main_colum_layout Text{ width: parent.width - height: 50 + height: rowHeight text: "FREQUENCY / TOOLKIT" font.bold: true horizontalAlignment: Qt.AlignHCenter verticalAlignment: Qt.AlignVCenter } - Row{ width: parent.width - height: 50 + height: rowHeight ComboBox { id: comboBoxFreq //model: supported_frequencies_model @@ -188,7 +188,7 @@ Rectangle{ Layout.row: 1 Layout.column: 0 displayText: { - if(!_ohdSystemGround.is_alive)return "NO FREQUENCY"; // GND NOT ALIVE + if(!_ohdSystemGround.is_alive)return "GND NOT ALIVE"; if(_ohdSystemGround.wb_gnd_operating_mode==1){ return "SCANNING"; } @@ -237,10 +237,9 @@ Rectangle{ } } } - Row{ width: parent.width - height: 50 + height: rowHeight Button{ Layout.preferredWidth: 150 id: b_find_air_unit @@ -282,14 +281,51 @@ Rectangle{ } } } - + Text{ + width: parent.width + height: rowHeight + text: "TX POWER" + font.bold: true + horizontalAlignment: Qt.AlignHCenter + verticalAlignment: Qt.AlignVCenter + } Row{ width: parent.width - height: 50 + height: rowHeight Text{ - text: "TX POWER AIR" + Layout.preferredWidth: 120 + text: "AIR:\n "+get_text_wifi_tx_power(true) + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + Button{ + text: "EDIT" + enabled: _ohdSystemAir.is_alive + onClicked: { + close_all_dialoques(); + popup_change_tx_power.m_is_air=true; + popup_change_tx_power.open() + } + } + Text{ + Layout.preferredWidth: 120 + text: "GND:\n"+get_text_wifi_tx_power(false) + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + Button{ + text: "EDIT" + enabled: _ohdSystemGround.is_alive + onClicked: { + close_all_dialoques(); + popup_change_tx_power.m_is_air=false; + popup_change_tx_power.open() + } } } + } } diff --git a/qml/ui/configpopup/status/FooterRebootShutdownWarning.qml b/qml/ui/configpopup/status/FooterRebootShutdownWarning.qml index 897803c6a..8a6d582b8 100644 --- a/qml/ui/configpopup/status/FooterRebootShutdownWarning.qml +++ b/qml/ui/configpopup/status/FooterRebootShutdownWarning.qml @@ -68,7 +68,8 @@ Item { open_power_action_dialoque(m_type,false) } } - ButtonIconWarning{ + ButtonIconConnect{ + m_type_wired: m_type==0 ? true : false; visible: !get_show_power_actions() Layout.alignment: Qt.AlignCenter height:12 @@ -76,5 +77,13 @@ Item { open_warning(); } } + /*ButtonIconWarning{ + visible: !get_show_power_actions() + Layout.alignment: Qt.AlignCenter + height:12 + onPressed: { + open_warning(); + } + }*/ } } diff --git a/qml/ui/configpopup/status/PanelStatus.qml b/qml/ui/configpopup/status/PanelStatus.qml index 45fbd54f3..79b8aa87b 100644 --- a/qml/ui/configpopup/status/PanelStatus.qml +++ b/qml/ui/configpopup/status/PanelStatus.qml @@ -30,25 +30,37 @@ Rectangle { powerDialog.open_dialoque(system,reboot) } + TabBar { + // This screen doesn't tab, but we use the tab bar element for a consistent style + id: selectItemInStackLayoutBar + width: parent.width + TabButton { + text: qsTr("SYSTEM STATUS") + } + } + ScrollView { - id:mavlinkExtraWBParamPanel + /*id:mavlinkExtraWBParamPanel width: parent.width height: parent.height contentHeight: mainItem.height contentWidth: mainItem.width clip: true //ScrollBar.vertical.policy: ScrollBar.AlwaysOn + ScrollBar.vertical.interactive: true*/ + width: parent.width + anchors.top: selectItemInStackLayoutBar.bottom + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + clip: true ScrollBar.vertical.interactive: true + contentHeight: mainItem.height Item{ id: mainItem - width: 800 - height: 40+350+80 - - QOpenHDVersionCard{ - id: qopenhdversioncard - height: 40 - } + width: mainRect.width + height: 350+80 // The 3 status cards (OpenHD AIR & GND, FC) // next to each other @@ -57,12 +69,11 @@ Rectangle { width: parent.width height: 350 - anchors.leftMargin: 4 anchors.topMargin: 4 anchors.left: parent.left - anchors.top: qopenhdversioncard.bottom + // anchors.top: qopenhdversioncard.bottom } diff --git a/qml/ui/configpopup/status/StatusCardsColumn.qml b/qml/ui/configpopup/status/StatusCardsColumn.qml index a9b110cfc..1de4f7c6d 100644 --- a/qml/ui/configpopup/status/StatusCardsColumn.qml +++ b/qml/ui/configpopup/status/StatusCardsColumn.qml @@ -13,13 +13,13 @@ import "../../elements" // // The 3 status cards (OpenHD AIR & GND, FC) // next to each other -RowLayout{ +Row{ width: parent.width height: parent.height - property int m_card_width: parent.width/3; + property int m_card_width: parent.width/3-3; property int m_card_height: 350 - + padding: 3 Card { width: m_card_width height:m_card_height diff --git a/qml/ui/elements/BaseHeaderItem.qml b/qml/ui/elements/BaseHeaderItem.qml new file mode 100644 index 000000000..15867b6f6 --- /dev/null +++ b/qml/ui/elements/BaseHeaderItem.qml @@ -0,0 +1,28 @@ +import QtQuick 2.12 +import QtQuick.Layouts 1.12 + +Item { + Layout.fillWidth: true + Layout.preferredHeight: 32 + + property string m_text: "FILL ME" + + Rectangle{ + width: parent.width + height: 2 + color: "black" + anchors.bottom: parent.bottom + } + + Text{ + text: qsTr(m_text) + font.weight: Font.Bold + font.pixelSize: 13 + anchors.leftMargin: 8 + anchors.rightMargin: 8 + anchors.fill: parent + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + } + +} diff --git a/qml/ui/elements/ButtonIconConnect.qml b/qml/ui/elements/ButtonIconConnect.qml new file mode 100644 index 000000000..480fa55bd --- /dev/null +++ b/qml/ui/elements/ButtonIconConnect.qml @@ -0,0 +1,13 @@ +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Dialogs 1.0 +import QtQuick.Controls.Material 2.12 + +// Connect - either wired (wired icon) or wireless (wireless icon) +Button { + property bool m_type_wired: false + text: m_type_wired ? "\uf6ff" : "\uf1eb" + font.family: "Font Awesome 5 Free" + font.pixelSize: 14 + //highlighted: true +} diff --git a/qml/ui/elements/ButtonIconInfo2.qml b/qml/ui/elements/ButtonIconInfo2.qml new file mode 100644 index 000000000..8c416e53b --- /dev/null +++ b/qml/ui/elements/ButtonIconInfo2.qml @@ -0,0 +1,12 @@ +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Dialogs 1.0 +import QtQuick.Controls.Material 2.12 + +// Info icon, no blue color +Button { + //text: "INFO" + text: "\uf05a" + font.family: "Font Awesome 5 Free" + //highlighted: true +} diff --git a/qml/ui/elements/CardBasic.qml b/qml/ui/elements/CardBasic.qml new file mode 100644 index 000000000..4593aa0f8 --- /dev/null +++ b/qml/ui/elements/CardBasic.qml @@ -0,0 +1,8 @@ +import QtQuick 2.12 + +Rectangle { + radius: 6 + color: "white" + border.width: 1 + border.color: "#3a000000" +} From 92ecd9853bab0bd0c4199ce5a38c5827c7a71f46 Mon Sep 17 00:00:00 2001 From: consti10 Date: Tue, 14 Nov 2023 11:33:07 +0100 Subject: [PATCH 49/81] finalize: Everything is usable up to minimum resolution (480p 16:9) --- app/main.cpp | 16 ++++-- app/telemetry/settings/frequencyhelper.cpp | 14 ++++- app/telemetry/settings/frequencyhelper.h | 4 +- app/util/qrenderstats.cpp | 8 +-- app/util/qrenderstats.h | 7 ++- qml/main.qml | 7 +++ .../dev/AppDeveloperStatsPanel.qml | 45 ++++++++------- .../MavlinkOpenHDWBParamPanel.qml | 57 +++++++++++-------- .../openhd_settings/PopupAnalyzeChannels.qml | 2 +- .../openhd_settings/PopupTxPowerEditor.qml | 26 +++------ qml/ui/configpopup/status/PanelStatus.qml | 14 +---- .../status/StatusCardBodyOpenHD.qml | 2 +- .../configpopup/status/StatusCardsColumn.qml | 12 ++-- qml/ui/elements/AppSettings.qml | 2 + qml/ui/elements/BaseHeaderItem.qml | 5 ++ 15 files changed, 122 insertions(+), 99 deletions(-) diff --git a/app/main.cpp b/app/main.cpp index 8062b3f3c..bfec3a8b9 100755 --- a/app/main.cpp +++ b/app/main.cpp @@ -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[]) { @@ -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__) diff --git a/app/telemetry/settings/frequencyhelper.cpp b/app/telemetry/settings/frequencyhelper.cpp index 22928cb97..543a798dc 100644 --- a/app/telemetry/settings/frequencyhelper.cpp +++ b/app/telemetry/settings/frequencyhelper.cpp @@ -12,10 +12,10 @@ FrequencyHelper &FrequencyHelper::instance() return instance; } -QList FrequencyHelper::get_frequencies(bool openhd_bands_only) +QList FrequencyHelper::get_frequencies(int filter) { QList 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); @@ -24,7 +24,15 @@ QList 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); + } + } } } } diff --git a/app/telemetry/settings/frequencyhelper.h b/app/telemetry/settings/frequencyhelper.h index 20d8fc5a2..ce30d5f28 100644 --- a/app/telemetry/settings/frequencyhelper.h +++ b/app/telemetry/settings/frequencyhelper.h @@ -14,8 +14,8 @@ class FrequencyHelper : public QObject public: explicit FrequencyHelper(QObject *parent = nullptr); static FrequencyHelper &instance(); - - Q_INVOKABLE QList 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 get_frequencies(int filter); Q_INVOKABLE QList get_frequencies_all_40Mhz(); Q_INVOKABLE bool get_frequency_radar(int frequency_mhz); diff --git a/app/util/qrenderstats.cpp b/app/util/qrenderstats.cpp index 05813d729..5b96cea1c 100644 --- a/app/util/qrenderstats.cpp +++ b/app/util/qrenderstats.cpp @@ -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<0){ var index=find_index(comboBoxFreq.model,_wbLinkSettingsHelper.curr_channel_mhz); if(index>=0){ @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml b/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml index 223fa488f..ce1887729 100644 --- a/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml +++ b/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml @@ -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; diff --git a/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml b/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml index 4a23d3ac3..763f0256e 100644 --- a/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml +++ b/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml @@ -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){ @@ -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 @@ -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 @@ -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 @@ -329,11 +326,8 @@ Rectangle{ _messageBoxInstance.set_text_and_show("TX Power applied when FC is disarmed"); } } - // FILLER Item{ - Layout.row: 2 - Layout.column: 4 Layout.fillWidth: true } } @@ -341,8 +335,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: { var power_int=get_current_tx_power_int(2); if(power_int==0) return "ARMED:\nDISABLED"; @@ -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: { @@ -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."); diff --git a/qml/ui/configpopup/status/PanelStatus.qml b/qml/ui/configpopup/status/PanelStatus.qml index 79b8aa87b..b0cbca935 100644 --- a/qml/ui/configpopup/status/PanelStatus.qml +++ b/qml/ui/configpopup/status/PanelStatus.qml @@ -40,14 +40,6 @@ Rectangle { } ScrollView { - /*id:mavlinkExtraWBParamPanel - width: parent.width - height: parent.height - contentHeight: mainItem.height - contentWidth: mainItem.width - clip: true - //ScrollBar.vertical.policy: ScrollBar.AlwaysOn - ScrollBar.vertical.interactive: true*/ width: parent.width anchors.top: selectItemInStackLayoutBar.bottom anchors.left: parent.left @@ -68,21 +60,19 @@ Rectangle { id: statuscardscolumn width: parent.width height: 350 - anchors.leftMargin: 4 anchors.topMargin: 4 - + anchors.rightMargin: 4 anchors.left: parent.left + anchors.right: parent.right // anchors.top: qopenhdversioncard.bottom } - PingUtilColumn { id:actionsButtonMenu width: parent.width height: 80 anchors.top: statuscardscolumn.bottom - } } } diff --git a/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml b/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml index 9e05c3f79..8e42b7365 100644 --- a/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml +++ b/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml @@ -11,7 +11,7 @@ import OpenHD 1.0 import "../../../ui" as Ui import "../../elements" -ColumnLayout { +Column { //Layout.fillWidth: true //Layout.fillHeight: true // from https://doc.qt.io/qt-6/qml-qtquick-layouts-rowlayout.html diff --git a/qml/ui/configpopup/status/StatusCardsColumn.qml b/qml/ui/configpopup/status/StatusCardsColumn.qml index 1de4f7c6d..9768c5c75 100644 --- a/qml/ui/configpopup/status/StatusCardsColumn.qml +++ b/qml/ui/configpopup/status/StatusCardsColumn.qml @@ -14,12 +14,14 @@ import "../../elements" // The 3 status cards (OpenHD AIR & GND, FC) // next to each other Row{ - width: parent.width - height: parent.height + id: status_cards_row + property int m_spacing_px: 3 + + property int m_card_width: (parent.width-4*m_spacing_px)/3; + property int m_card_height: status_cards_row.height + + spacing: m_spacing_px - property int m_card_width: parent.width/3-3; - property int m_card_height: 350 - padding: 3 Card { width: m_card_width height:m_card_height diff --git a/qml/ui/elements/AppSettings.qml b/qml/ui/elements/AppSettings.qml index 52daf95fb..f40ca06ce 100644 --- a/qml/ui/elements/AppSettings.qml +++ b/qml/ui/elements/AppSettings.qml @@ -407,4 +407,6 @@ Settings { property int qopenhd_mavlink_connection_mode: 0; property string qopenhd_mavlink_connection_manual_tcp_ip: "192.168.178.36" + + property int qopenhd_frequency_filter_selection: 0; } diff --git a/qml/ui/elements/BaseHeaderItem.qml b/qml/ui/elements/BaseHeaderItem.qml index 15867b6f6..a8c3eee66 100644 --- a/qml/ui/elements/BaseHeaderItem.qml +++ b/qml/ui/elements/BaseHeaderItem.qml @@ -7,6 +7,11 @@ Item { property string m_text: "FILL ME" + Rectangle{ + anchors.fill: parent + color: "#8cbfd7f3" + } + Rectangle{ width: parent.width height: 2 From 9dc6628d78582cf8449d78821258f43aaad100ab Mon Sep 17 00:00:00 2001 From: consti10 Date: Tue, 14 Nov 2023 11:51:48 +0100 Subject: [PATCH 50/81] exp for android - re-enable high dpi scaling --- app/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/main.cpp b/app/main.cpp index bfec3a8b9..1331cfad6 100755 --- a/app/main.cpp +++ b/app/main.cpp @@ -204,16 +204,16 @@ int main(int argc, char *argv[]) { QSettings settings; - /*const int screen_custom_font_dpi = settings.value("screen_custom_font_dpi").toInt(); + const int screen_custom_font_dpi = settings.value("screen_custom_font_dpi").toInt(); if (screen_custom_font_dpi) { QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); const std::string font_dpi_s = std::to_string(screen_custom_font_dpi); qputenv("QT_FONT_DPI", QByteArray(font_dpi_s.c_str(), font_dpi_s.length())); } else { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - }*/ + } //QCoreApplication::setAttribute(Qt::AA_UseOpenGLES); - QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); + //QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); // From https://stackoverflow.com/questions/63473541/how-to-dynamically-toggle-vsync-in-a-qt-application-at-runtime // Get rid of VSYNC if possible. Might / might not work. On my ubuntu nvidia & intel laptop, this at least seems to From a66db5bd78cb55371c8c7419e9b9de793b13b5df Mon Sep 17 00:00:00 2001 From: consti10 Date: Tue, 14 Nov 2023 12:50:59 +0100 Subject: [PATCH 51/81] exp -set before writing the AA flag / screen scale --- app/main.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/app/main.cpp b/app/main.cpp index 1331cfad6..cb70badb7 100755 --- a/app/main.cpp +++ b/app/main.cpp @@ -186,21 +186,18 @@ 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[]) { QCoreApplication::setOrganizationName("OpenHD"); QCoreApplication::setOrganizationDomain("openhd"); QCoreApplication::setApplicationName("QOpenHD"); + {// Original screen resoluton before setting anything + const auto screen=QGuiApplication::primaryScreen(); + if(screen){ + const auto actual_size=screen->size(); + QRenderStats::instance().set_screen_width_height(actual_size.width(),actual_size.height()); + } + } QSettings settings; @@ -247,7 +244,12 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); // Customize cursor if needed QOpenHD::instance().customize_cursor_from_settings(); - write_screen_resolutions(app); + { // This includes dpi adjustment + QScreen* screen=app.primaryScreen(); + if(screen){ + QRenderStats::instance().set_display_width_height(screen->size().width(),screen->size().height()); + } + } QOpenHDVideoHelper::reset_qopenhd_switch_primary_secondary(); #if defined(__ios__) From 683bf9eb967ad695cf1a09fe55953d054049891c Mon Sep 17 00:00:00 2001 From: consti10 Date: Tue, 14 Nov 2023 12:55:32 +0100 Subject: [PATCH 52/81] exp -set before writing the AA flag / screen scale --- app/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/main.cpp b/app/main.cpp index cb70badb7..690d7a88e 100755 --- a/app/main.cpp +++ b/app/main.cpp @@ -192,11 +192,13 @@ int main(int argc, char *argv[]) { QCoreApplication::setOrganizationDomain("openhd"); QCoreApplication::setApplicationName("QOpenHD"); {// Original screen resoluton before setting anything + QApplication a(argc, argv); const auto screen=QGuiApplication::primaryScreen(); if(screen){ const auto actual_size=screen->size(); QRenderStats::instance().set_screen_width_height(actual_size.width(),actual_size.height()); } + // a is deleted again } QSettings settings; From 07fa49d3b10205215786e2b24c2d11923db358be Mon Sep 17 00:00:00 2001 From: consti10 Date: Tue, 14 Nov 2023 16:02:05 +0100 Subject: [PATCH 53/81] wb link rate widget - use combobox instead of buttons --- app/main.cpp | 2 +- qml/qml.qrc | 1 + .../AppScreenSettingsView.qml | 8 +- qml/ui/elements/SmallHeaderInfoRow.qml | 27 ++ qml/ui/widgets/VideoBitrateWidgetGeneric.qml | 2 +- qml/ui/widgets/WBLinkRateControlWidget.qml | 332 ++++++------------ 6 files changed, 146 insertions(+), 226 deletions(-) create mode 100644 qml/ui/elements/SmallHeaderInfoRow.qml diff --git a/app/main.cpp b/app/main.cpp index 690d7a88e..9aded53b7 100755 --- a/app/main.cpp +++ b/app/main.cpp @@ -192,7 +192,7 @@ int main(int argc, char *argv[]) { QCoreApplication::setOrganizationDomain("openhd"); QCoreApplication::setApplicationName("QOpenHD"); {// Original screen resoluton before setting anything - QApplication a(argc, argv); + //QApplication a(argc, argv); const auto screen=QGuiApplication::primaryScreen(); if(screen){ const auto actual_size=screen->size(); diff --git a/qml/qml.qrc b/qml/qml.qrc index 6a259d6c2..366439aba 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -266,5 +266,6 @@ ui/elements/ButtonIconInfo2.qml ui/elements/CardBasic.qml ui/elements/ButtonIconConnect.qml + ui/elements/SmallHeaderInfoRow.qml diff --git a/qml/ui/configpopup/qopenhd_settings/AppScreenSettingsView.qml b/qml/ui/configpopup/qopenhd_settings/AppScreenSettingsView.qml index 60915821b..f7446c79c 100755 --- a/qml/ui/configpopup/qopenhd_settings/AppScreenSettingsView.qml +++ b/qml/ui/configpopup/qopenhd_settings/AppScreenSettingsView.qml @@ -51,18 +51,18 @@ ScrollView { anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter from : 0.3 - to : 2.0 + to : 2.5 // Important: Looks as without .1 steps, we can get rendering artfacts stepSize: .1 anchors.rightMargin: Qt.inputMethod.visible ? 78 : 18 value: settings.global_scale - // @disable-check M223 onValueChanged: { - // @disable-check M222 + if(settings.global_scale != value){ + _restartqopenhdmessagebox.show(); + } settings.global_scale = value - //_messageBoxInstance.set_text_and_show("Please restart QOpenHD !") } } } diff --git a/qml/ui/elements/SmallHeaderInfoRow.qml b/qml/ui/elements/SmallHeaderInfoRow.qml new file mode 100644 index 000000000..0bda70f74 --- /dev/null +++ b/qml/ui/elements/SmallHeaderInfoRow.qml @@ -0,0 +1,27 @@ +import QtQuick 2.12 + +Item { + width: parent.width + height: 40 + + property string m_text: "FILL ME" + property string m_info_text: "FILL ME" + + Text{ + anchors.fill: parent + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignLeft + text: m_text + font.pixelSize: 18 + font.bold: true + color: "white" + } + ButtonIconInfo{ + anchors.right: parent.right + width: parent.height + height: parent.height + onClicked: { + _messageBoxInstance.set_text_and_show(m_info_text) + } + } +} diff --git a/qml/ui/widgets/VideoBitrateWidgetGeneric.qml b/qml/ui/widgets/VideoBitrateWidgetGeneric.qml index d9cec249a..d82eefc8d 100644 --- a/qml/ui/widgets/VideoBitrateWidgetGeneric.qml +++ b/qml/ui/widgets/VideoBitrateWidgetGeneric.qml @@ -196,7 +196,7 @@ BaseWidget { Layout.preferredWidth: 200 Layout.minimumWidth: 200 height: 50 - currentIndex: 0 + currentIndex: -1 displayText: { if(!_ohdSystemAir.is_alive)return "Res@fps N/A"; return m_curr_video_format; diff --git a/qml/ui/widgets/WBLinkRateControlWidget.qml b/qml/ui/widgets/WBLinkRateControlWidget.qml index 8c785068b..4c98404ec 100644 --- a/qml/ui/widgets/WBLinkRateControlWidget.qml +++ b/qml/ui/widgets/WBLinkRateControlWidget.qml @@ -48,6 +48,24 @@ BaseWidget { //property bool m_is_armed: true property bool m_is_armed: _fcMavlinkSystem.armed + property int m_row_height: 50 + + + ListModel{ + id: mcs_model + ListElement {title: "MCS0 "; value: 0} + ListElement {title: "MCS1 "; value: 1} + ListElement {title: "MCS2 (DEFAULT)"; value: 2} + ListElement {title: "MCS3 (EXPERIMENTAL)"; value: 3} + ListElement {title: "MCS4 (EXPERIMENTAL)"; value: 4} + } + ListModel{ + id: stability_model + ListElement {title: "30%:2 POLLUTED"; value_fec: 30; value_keyframe: 2} + ListElement {title: "30%:3 CITY"; value_fec: 30; value_keyframe: 3} + ListElement {title: "20%:5 DEFAULT"; value_fec: 20; value_keyframe: 5} + //ListElement {title: "10%:5 DESERT"; value_fec: 10; value_keyframe: 5} + } function get_text_channel(){ if(!settings.wb_link_rate_control_widget_show_frequency){ @@ -142,6 +160,34 @@ BaseWidget { } _wbLinkSettingsHelper.change_param_air_channel_width_async(channel_width_mhz,true); } + function get_rate_for_mcs(mcs,is_40mhz){ + if(is_40mhz){ + if(mcs==0) return 7.4; + if(mcs==1) return 15.3; + if(mcs==2) return 22.6; + if(mcs==3) return 25; + if(mcs==4) return 30; + } + if(mcs==0) return 4.7; + if(mcs==1) return 9.8; + if(mcs==2) return 13; + if(mcs==3) return 16.2; + if(mcs==4) return 20; + return -1; + } + function get_mcs_combobox_text(mcs){ + for(var i = 0; i < mcs_model.count; ++i) { + if (mcs_model.get(i).value==mcs) return mcs_model.get(i).title + } + return "MCS "+m_curr_mcs_index; + } + + function get_fec_keyframe_combobox_text(fec,keyframe){ + for(var i = 0; i < stability_model.count; ++i) { + if (stability_model.get(i).value_fec==fec && stability_model.get(i).value_keyframe==keyframe) return stability_model.get(i).title + } + return "FEC:"+fec+"% : KEY:"+keyframe+" ?"; + } property string m_DESCRIPTION_CHANNEL_WIDTH: " A higher bandwidth / 40Mhz channel width increases the bitrate significantly, but also increases interference and reduces the maximum range."+ @@ -264,237 +310,83 @@ Make the video more stable (less microfreezes) on the cost of less image quality width: parent.width height: parent.height - ColumnLayout { - width: m_widget_action_w -32 - height: m_widget_action_h-32 - spacing: 20 + Column { + width: m_widget_action_w-32 + //height: m_widget_action_h + //spacing: 20 - Rectangle{ + SmallHeaderInfoRow{ + m_text: "Range vs Bitrate" + m_info_text: m_DESCRIPTION_CHANNEL_WIDTH + } + Row{ width: parent.width - height: 50 - Layout.fillWidth: true - //color: "#13142e" - //border.width: 5 - //radius: 10 - //color: "green" - color: "black" - ColumnLayout{ - width: parent.width - height: parent.height - spacing: 1 - Rectangle { - height: 32 - width: parent.width - id: itemDescriptionRangeQuality - //color: "green" - color: "black" - Text { - id: simpleDescriptionRangeQuality - text: "Trade range/image quality" - color: "white" - font.bold: true - font.pixelSize: detailPanelFontPixels - anchors.left: parent.left - } - Button{ - height: 32 - width: 32 - text: "\uf05a" - anchors.left: simpleDescriptionRangeQuality.right - anchors.top: simpleDescriptionRangeQuality.top - Material.background:Material.LightBlue - anchors.leftMargin: 5 - onClicked: { - _messageBoxInstance.set_text_and_show(m_DESCRIPTION_CHANNEL_WIDTH) - } - } + height: m_row_height + spacing: 20 + enabled: _ohdSystemAir.is_alive; + Button{ + text: "20Mhz" + onClicked: { + set_channel_width_async(20) } - Item{ - width: parent.width - height: 20 - GridLayout{ - width: parent.width - height: parent.height - rows: 2 - columns: 2 - Button{ - text: "20Mhz" - onClicked: { - set_channel_width_async(20) - } - highlighted: m_curr_channel_width==20 - } - Button{ - text: "40Mhz" - onClicked: { - set_channel_width_async(40) - } - highlighted: m_curr_channel_width==40 - } - } + highlighted: m_curr_channel_width==20 + } + Button{ + text: "40Mhz" + onClicked: { + set_channel_width_async(40) } + highlighted: m_curr_channel_width==40 } } - - Rectangle{ - id: areaMCS + SmallHeaderInfoRow{ + m_text: "Range vs Bitrate" + m_info_text: m_DESCRIPTION_MCS + } + ComboBox{ width: parent.width - height: parent.height /3; - //color: "red" - color: "black" - ColumnLayout{ - width: parent.width - height: parent.height - spacing: 1 - Item { - height: 32 - width: parent.width - id: itemDescriptionMCS - Text { - id: simpleDescription - text: "Trade range/image quality" - color: "white" - font.bold: true - font.pixelSize: detailPanelFontPixels - anchors.left: parent.left - } - Button{ - height: 32 - width: 32 - text: "\uf05a" - anchors.left: simpleDescription.right - anchors.top: simpleDescription.top - Material.background:Material.LightBlue - anchors.leftMargin: 5 - onClicked: { - _messageBoxInstance.set_text_and_show(m_DESCRIPTION_MCS) - } - } - } - - Rectangle{ - width: parent.width - height: 100; - id: itemMcsChoices - //color: "green" - color: "black" - GridLayout{ - width: parent.width - height: parent.height - rows: 3 - columns: 2 - Button{ - text: "MCS0" - onClicked: { - set_air_only_mcs(0) - } - highlighted: m_curr_mcs_index==0 - } - Button{ - text: "MCS1" - onClicked: { - set_air_only_mcs(1) - } - highlighted: m_curr_mcs_index==1 - } - Button{ - text: "MCS2\n(DEFAULT)" - onClicked: { - set_air_only_mcs(2) - } - highlighted: m_curr_mcs_index==2 - } - Button{ - text: "MCS3" - onClicked: { - set_air_only_mcs(3) - } - highlighted: m_curr_mcs_index==3 - } - } - } + height: m_row_height + id: mcs_cb + model: mcs_model + textRole: "title" + currentIndex: -1 + displayText: { + if(!_ohdSystemAir.is_alive)return "AIR NOT ALIVE"; + return get_mcs_combobox_text(m_curr_mcs_index); + //return "MCS "+m_curr_mcs_index+" / "+get_rate_for_mcs(m_curr_mcs_index,m_curr_channel_width==40)+" MBit/s" } + onActivated: { + console.log("onActivated:"+currentIndex); + if(currentIndex<0)return; + const mcs=model.get(currentIndex).value + set_air_only_mcs(mcs) + } + enabled: _ohdSystemAir.is_alive; + } + SmallHeaderInfoRow{ + m_text: "Stability vs Bitrate" + m_info_text:m_DESCRIPTION_STABILITY } - Rectangle{ - id: areaKeyframe + ComboBox{ width: parent.width - height: parent.height /3; - //color: "green" - color: "black" - ColumnLayout{ - width: parent.width - height: parent.height - spacing: 5 - Item { - height: 32 - width: parent.width - id: itemDescriptionKeyframe - //anchors.top: itemMcsChoices.bottom - Text { - id: simpleDescriptionKeyframe - text: "Trade Quality/Stability" - color: "white" - font.bold: true - font.pixelSize: detailPanelFontPixels - anchors.left: parent.left - } - Button{ - height: 32 - width: 32 - text: "\uf05a" - anchors.left: simpleDescriptionKeyframe.right - anchors.top: simpleDescriptionKeyframe.top - Material.background:Material.LightBlue - anchors.leftMargin: 5 - onClicked: { - _messageBoxInstance.set_text_and_show(m_DESCRIPTION_STABILITY) - } - } - } - Item{ - width: parent.width - height: parent.height -32; - //color: "green" - GridLayout{ - width: parent.width - height: parent.height - rows: 2 - columns: 2 - Button{ - text: "POLLUTED" - onClicked: { - set_keyframe_interval(2) - set_fec_percentage(30) - } - highlighted: m_curr_keyframe_i == 2 && m_curr_fec_perc==30 - } - Button{ - text: "CITY" - onClicked: { - set_keyframe_interval(3) - set_fec_percentage(20) - } - highlighted: m_curr_keyframe_i == 3 && m_curr_fec_perc==20 - } - Button{ - text: "DEFAULT" - onClicked: { - set_keyframe_interval(5) - set_fec_percentage(20) - } - highlighted: m_curr_keyframe_i == 5 && m_curr_fec_perc==20 - } - Button{ - text: "DESERT" - onClicked: { - set_keyframe_interval(5) - set_fec_percentage(10) - } - highlighted: m_curr_keyframe_i == 5 && m_curr_fec_perc==10 - } - } - } + height: m_row_height + id: pollution_cb + model: stability_model + textRole: "title" + currentIndex: -1 + displayText: { + if(!_ohdSystemAir.is_alive)return "AIR NOT ALIVE"; + return get_fec_keyframe_combobox_text(m_curr_fec_perc,m_curr_keyframe_i) + } + onActivated: { + console.log("onActivated:"+currentIndex); + if(currentIndex<0)return; + const fec=model.get(currentIndex).value_fec + const key=model.get(currentIndex).value_keyframe + set_fec_percentage(fec) + set_keyframe_interval(key) } + enabled: _ohdSystemAir.is_alive; } } } From 54576da20bfc898cec5ff0d090b09269c8247213 Mon Sep 17 00:00:00 2001 From: consti10 Date: Tue, 14 Nov 2023 16:44:06 +0100 Subject: [PATCH 54/81] slightly decrease the default size of the artificial horizon --- qml/ui/widgets/HorizonWidget.qml | 4 ++-- qml/ui/widgets/WBLinkRateControlWidget.qml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/qml/ui/widgets/HorizonWidget.qml b/qml/ui/widgets/HorizonWidget.qml index 9072afc32..c697546d5 100644 --- a/qml/ui/widgets/HorizonWidget.qml +++ b/qml/ui/widgets/HorizonWidget.qml @@ -372,8 +372,8 @@ BaseWidget { // Note: By the width / height we also controll the clipping area (since the horizon is double drawn, into a texture, then onto the screen). // Ideally, we want to reduce the "overdraw" to save GPU resources, e.g. make this area as small as possible / as less pixels as possible. - width: 600 * settings.horizon_clip_area_scale - height: 600 * settings.horizon_clip_area_scale + width: 400 * settings.horizon_clip_area_scale + height: 400 * settings.horizon_clip_area_scale //width: applicationWindow.width *0.8 * settings.horizon_clip_area_scale //height: applicationWindow.height *0.8 * settings.horizon_clip_area_scale clip: false diff --git a/qml/ui/widgets/WBLinkRateControlWidget.qml b/qml/ui/widgets/WBLinkRateControlWidget.qml index 4c98404ec..3aaef3a72 100644 --- a/qml/ui/widgets/WBLinkRateControlWidget.qml +++ b/qml/ui/widgets/WBLinkRateControlWidget.qml @@ -53,8 +53,8 @@ BaseWidget { ListModel{ id: mcs_model - ListElement {title: "MCS0 "; value: 0} - ListElement {title: "MCS1 "; value: 1} + ListElement {title: "MCS0 (LONG RANGE)"; value: 0} + ListElement {title: "MCS1 (RANGE)"; value: 1} ListElement {title: "MCS2 (DEFAULT)"; value: 2} ListElement {title: "MCS3 (EXPERIMENTAL)"; value: 3} ListElement {title: "MCS4 (EXPERIMENTAL)"; value: 4} From 38b32439ff6e0de0ddd783928b0f8d3734bb2d23 Mon Sep 17 00:00:00 2001 From: consti10 Date: Wed, 15 Nov 2023 00:45:17 +0100 Subject: [PATCH 55/81] horizon ladder - scale home icon, restart qopenhd box - decrease size, status - slightly smaller text / ratio (OK on 480p), video / wb link rate widget style improvments neccessary due to change to ComboBox --- app/main.cpp | 23 +++-- app/osd/horizonladder.cpp | 4 +- app/osd/horizonladder.h | 2 +- app/util/qopenhd.cpp | 7 +- app/util/qrenderstats.h | 4 +- qml/main.qml | 4 +- .../qopenhd_settings/AppDevSettingsView.qml | 2 +- qml/ui/configpopup/status/StatusCardRow.qml | 8 +- qml/ui/elements/RestartQOpenHDMessageBox.qml | 4 +- qml/ui/elements/SmallHeaderInfoRow.qml | 6 +- qml/ui/widgets/VideoBitrateWidgetGeneric.qml | 2 +- qml/ui/widgets/WBLinkRateControlWidget.qml | 87 ++++++++++++------- 12 files changed, 90 insertions(+), 63 deletions(-) diff --git a/app/main.cpp b/app/main.cpp index 9aded53b7..a9bb3e342 100755 --- a/app/main.cpp +++ b/app/main.cpp @@ -202,6 +202,7 @@ int main(int argc, char *argv[]) { } QSettings settings; + qDebug()<<"Storing settings at ["< Date: Wed, 15 Nov 2023 15:26:49 +0100 Subject: [PATCH 56/81] make restart dialoque even smaller --- qml/ui/elements/RestartQOpenHDMessageBox.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qml/ui/elements/RestartQOpenHDMessageBox.qml b/qml/ui/elements/RestartQOpenHDMessageBox.qml index fcfbfd550..457c348f5 100644 --- a/qml/ui/elements/RestartQOpenHDMessageBox.qml +++ b/qml/ui/elements/RestartQOpenHDMessageBox.qml @@ -11,8 +11,8 @@ import OpenHD 1.0 // See corresponding .cpp for more info Card { id: restartqopenhdmessagebox - width: 320 - height: 240 + width: 300 + height: 200 z: 6.0 anchors.centerIn: parent cardName: qsTr("QOpenHD") From 69a9de5102f7cf30cdc34754f06f0ade620dd05a Mon Sep 17 00:00:00 2001 From: consti10 Date: Wed, 15 Nov 2023 15:44:25 +0100 Subject: [PATCH 57/81] fix " " --- qml/ui/configpopup/status/StatusCardBodyOpenHD.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml b/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml index 8e42b7365..8994b341f 100644 --- a/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml +++ b/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml @@ -95,7 +95,7 @@ Column { m_right_text_color: m_last_ping === "N/A" ? "#DC143C" : "green" } StatusCardRow{ - m_left_text: qsTr(m_is_ground ? "Link HW: " : "Link HW:") + m_left_text: qsTr(m_is_ground ? "Link HW:" : "Link HW:") m_right_text: { if(m_is_ground){ if(!_ohdSystemGround.is_alive){ From 2a39c4344d2efc75e1363d47082be1bd3a3e8211 Mon Sep 17 00:00:00 2001 From: consti10 Date: Wed, 15 Nov 2023 16:17:00 +0100 Subject: [PATCH 58/81] show restart dialoque when changed --- .../configpopup/qopenhd_settings/AppScreenSettingsView.qml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qml/ui/configpopup/qopenhd_settings/AppScreenSettingsView.qml b/qml/ui/configpopup/qopenhd_settings/AppScreenSettingsView.qml index f7446c79c..5f94586f3 100755 --- a/qml/ui/configpopup/qopenhd_settings/AppScreenSettingsView.qml +++ b/qml/ui/configpopup/qopenhd_settings/AppScreenSettingsView.qml @@ -146,7 +146,11 @@ ScrollView { } } onCurrentIndexChanged: { - settings.screen_custom_font_dpi = font_dpi.get(currentIndex).value + const value_fdpi = font_dpi.get(currentIndex).value + if(settings.screen_custom_font_dpi != value_fdpi){ + _restartqopenhdmessagebox.show(); + } + settings.screen_custom_font_dpi = value_fdpi } } } From 090bdeee3d76efead658cad060fe5324a7b833df Mon Sep 17 00:00:00 2001 From: Raphael <68374617+raphaelscholle@users.noreply.github.com> Date: Wed, 15 Nov 2023 19:08:17 +0100 Subject: [PATCH 59/81] debug --- .github/workflows/build_package_Rock5.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_package_Rock5.yml b/.github/workflows/build_package_Rock5.yml index 2c083d313..26c8c5665 100644 --- a/.github/workflows/build_package_Rock5.yml +++ b/.github/workflows/build_package_Rock5.yml @@ -1,4 +1,4 @@ -name: build_package_rock5_debian +name: build_package_rock_debian on: push: @@ -6,6 +6,7 @@ on: - "2.5-evo" - "dev-release" - "release" + - "debug" paths-ignore: - '**.md' - '**.asciidoc' From 810447c4a224b0d6d1d5cec64e1db0a415b85bfe Mon Sep 17 00:00:00 2001 From: Raphael <68374617+raphaelscholle@users.noreply.github.com> Date: Wed, 15 Nov 2023 19:30:10 +0100 Subject: [PATCH 60/81] Revert "debug" This reverts commit 090bdeee3d76efead658cad060fe5324a7b833df. --- .github/workflows/build_package_Rock5.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build_package_Rock5.yml b/.github/workflows/build_package_Rock5.yml index 26c8c5665..2c083d313 100644 --- a/.github/workflows/build_package_Rock5.yml +++ b/.github/workflows/build_package_Rock5.yml @@ -1,4 +1,4 @@ -name: build_package_rock_debian +name: build_package_rock5_debian on: push: @@ -6,7 +6,6 @@ on: - "2.5-evo" - "dev-release" - "release" - - "debug" paths-ignore: - '**.md' - '**.asciidoc' From b391a47fa0d5b195b201a5eccfb46fe953a8587b Mon Sep 17 00:00:00 2001 From: consti10 Date: Thu, 16 Nov 2023 11:26:17 +0100 Subject: [PATCH 61/81] status - look less shit on small screens connect - make it look okay --- .../connect/PaneConnectionMode.qml | 52 +++++++++++++++++-- .../AppWidgetStyleSettingsView.qml | 5 +- qml/ui/configpopup/status/StatusCardRow.qml | 11 ++-- 3 files changed, 59 insertions(+), 9 deletions(-) diff --git a/qml/ui/configpopup/connect/PaneConnectionMode.qml b/qml/ui/configpopup/connect/PaneConnectionMode.qml index 6bf06c9ab..efccc7b05 100644 --- a/qml/ui/configpopup/connect/PaneConnectionMode.qml +++ b/qml/ui/configpopup/connect/PaneConnectionMode.qml @@ -60,11 +60,14 @@ Rectangle{ } wrapMode: Text.WordWrap color: m_is_air_or_ground_connected ? "red" : "black" + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter } ComboBox { Layout.fillWidth: false Layout.fillHeight: true; Layout.preferredWidth: 200 + Layout.alignment: Qt.AlignCenter id: connection_mode_dropdown model: ListModel { @@ -81,10 +84,12 @@ Rectangle{ currentIndex: settings.qopenhd_mavlink_connection_mode } Text{ - Layout.fillWidth: true - Layout.fillHeight: true; + Layout.preferredWidth: 200 + Layout.alignment: Qt.AlignCenter id: connection_status text: _mavlinkTelemetry.telemetry_connection_status + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter } // Visible when auto mode is enabled ------------------------------------------------------------------------------------------ @@ -95,9 +100,14 @@ Rectangle{ visible: connection_mode_dropdown.currentIndex==0; RowLayout { + Layout.fillWidth: true + Item{ // filler + Layout.fillWidth: true + } Button{ text: "Android Tethering" Layout.preferredWidth: 180 + Layout.alignment: Qt.AlignCenter onClicked: { if(_qopenhd.is_android()){ _qopenhd.android_open_tethering_settings() @@ -107,16 +117,25 @@ Rectangle{ } } ButtonIconInfoText { + Layout.alignment: Qt.AlignCenter m_info_text: "1) Connect your phone via high quality USB cable to your ground station.\n\n"+ "2) enable USB Tethering on your phone.\n\n"+ "3) Telemetry and video forwarding is started automatically \n\n"+ " ! Requires a phone and cellular contract that allows USB tethering. !" } + Item{ // filler + Layout.fillWidth: true + } } RowLayout { + Layout.fillWidth: true + Item{ // filler + Layout.fillWidth: true + } Button{ text: "Wifi tethering" Layout.preferredWidth: 180 + Layout.alignment: Qt.AlignCenter //TODO enable hotspot onClicked: { _messageBoxInstance.set_text_and_show("Please connect:\nWiFi Name: openhd_air/openhd_ground.\n PW: openhdopenhd") @@ -128,11 +147,18 @@ Rectangle{ "3) Connect this device to your AIR / GND unit wifi hotspot.\n\n"+ "NOTE: It is not recommended to use WiFi hotspot during flight (automatically disabled on arm by default)" } + Item{ // filler + Layout.fillWidth: true + } } RowLayout { + Item{ // filler + Layout.fillWidth: true + } Button{ text: "Passive Eth tethering" Layout.preferredWidth: 180 + Layout.alignment: Qt.AlignCenter //TODO disable active tethering and enable passive when clicking the button onClicked: { _qopenhd.show_toast("Please read info"); @@ -144,11 +170,18 @@ Rectangle{ "3) Select 'share my internet with ...' when the android connection setup pops up\n\n"+ "Video and telemetry forwarding should start automatically, internet will be forwarded from your phone." } + Item{ // filler + Layout.fillWidth: true + } } RowLayout { + Item{ // filler + Layout.fillWidth: true + } Button{ text: "Active Eth tethering" Layout.preferredWidth: 180 + Layout.alignment: Qt.AlignCenter //TODO disable passive tethering and enable active when clicking the button onClicked: { _qopenhd.show_toast("Please read info"); @@ -160,6 +193,9 @@ Rectangle{ "You might need to disable wifi and cellular on your phone\n\n"+ "Video and telemetry forwarding should start automatically, internet will not be available." } + Item{ // filler + Layout.fillWidth: true + } } // padding to bottom Item { @@ -169,13 +205,20 @@ Rectangle{ } // Visible when manual UDP mode is enabled ------------------------------------------------------------------------------------------ - GridLayout{ + RowLayout{ Layout.fillWidth: true Layout.fillHeight: true visible: connection_mode_dropdown.currentIndex==1; + Item{ // filler + Layout.fillWidth: true + } Text{ + Layout.alignment: Qt.AlignCenter text: "Listening on localhost:5600" } + Item{ // filler + Layout.fillWidth: true + } } // Visible when manual TCP mode is enabled ------------------------------------------------------------------------------------------ GridLayout { @@ -184,6 +227,7 @@ Rectangle{ visible: connection_mode_dropdown.currentIndex==2; columns: 2 TextField { + Layout.alignment: Qt.AlignCenter id: textFieldip validator: RegExpValidator { regExp: /^((?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.){0,3}(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])$/ @@ -192,6 +236,7 @@ Rectangle{ text: settings.qopenhd_mavlink_connection_manual_tcp_ip } Button{ + Layout.alignment: Qt.AlignCenter text: "SAVE" onClicked: { if(!_mavlinkTelemetry.change_manual_tcp_ip(textFieldip.text)){ @@ -202,6 +247,7 @@ Rectangle{ } } Text{ + Layout.alignment: Qt.AlignCenter Layout.columnSpan: 2 text: "TCP PORT: 5760" } diff --git a/qml/ui/configpopup/qopenhd_settings/AppWidgetStyleSettingsView.qml b/qml/ui/configpopup/qopenhd_settings/AppWidgetStyleSettingsView.qml index 51fa05f76..9391ded82 100644 --- a/qml/ui/configpopup/qopenhd_settings/AppWidgetStyleSettingsView.qml +++ b/qml/ui/configpopup/qopenhd_settings/AppWidgetStyleSettingsView.qml @@ -39,7 +39,8 @@ ScrollView { anchors.rightMargin: 8 Text{ Layout.alignment: Qt.AlignLeft - text: "PRESETS\nColor/Font" + //text: "PRESETS\nColor/Font" + text: "Presets Color/Font" font.weight: Font.Bold font.pixelSize: 13 } @@ -48,7 +49,7 @@ ScrollView { Layout.fillHeight: true } Button{ - text: "GREEN\n@Norbert" + text: "GREEN-Norbert" Layout.alignment: Qt.AlignRight Layout.leftMargin: 10 Layout.rightMargin: 10 diff --git a/qml/ui/configpopup/status/StatusCardRow.qml b/qml/ui/configpopup/status/StatusCardRow.qml index accf65667..98a77a6bb 100644 --- a/qml/ui/configpopup/status/StatusCardRow.qml +++ b/qml/ui/configpopup/status/StatusCardRow.qml @@ -63,13 +63,13 @@ Item { }*/ // Actual item,centered Item{ - width: 260 + width: parent.width height: main_item.height anchors.centerIn: parent Text{ id: left_part - width: parent.width*0.4 + width: parent.width*0.5 height: parent.height anchors.left: parent.left anchors.top: parent.top @@ -79,6 +79,7 @@ Item { font.bold: true font.pixelSize: 18 clip: true + elide: Text.ElideRight } Text{ @@ -89,10 +90,12 @@ Item { anchors.top: left_part.top text: m_right_text verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignCenter + horizontalAlignment: Qt.AlignHCenter color: m_has_error ? m_right_text_color_error : m_right_text_color visible: !right_part_button.visible font.pixelSize: 18 + clip: true + elide: Text.ElideRight } MouseArea { enabled: m_has_error && !m_look_shit_on_error @@ -103,7 +106,7 @@ Item { } Button{ id: right_part_button - width: parent.width/3*2; + width: parent.width-left_part.width height: parent.height anchors.left: left_part.right anchors.top: left_part.top From 8502c2f77df502260b3c4ba0f0a9834d182c1889 Mon Sep 17 00:00:00 2001 From: consti10 Date: Thu, 16 Nov 2023 12:14:42 +0100 Subject: [PATCH 62/81] use DEF als agreed in chat --- .../openhd_settings/MavlinkOpenHDWBParamPanel.qml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml index 9d4984bc3..5a88e7256 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml +++ b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml @@ -225,13 +225,15 @@ Rectangle{ 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"); + if(currentIndex==1){ + _qopenhd.show_toast("2.4G is almost always polluted by WiFi. Not recommended.") + }else if(currentIndex==2){ + _qopenhd.show_toast("Please watch out for wifi pollution. Using DEF is highly recommended !") } } } TabButton{ - text: "1-5" + text: "DEF" } TabButton{ text: "2.4G" From fd4dae3611f0dc48fb1910be544b5fe372073b58 Mon Sep 17 00:00:00 2001 From: consti10 Date: Thu, 16 Nov 2023 12:17:42 +0100 Subject: [PATCH 63/81] use DEF als agreed in chat --- qml/ui/configpopup/status/StatusCardBodyFC.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qml/ui/configpopup/status/StatusCardBodyFC.qml b/qml/ui/configpopup/status/StatusCardBodyFC.qml index cce41116c..ea8383e97 100644 --- a/qml/ui/configpopup/status/StatusCardBodyFC.qml +++ b/qml/ui/configpopup/status/StatusCardBodyFC.qml @@ -11,7 +11,7 @@ import OpenHD 1.0 import "../../../ui" as Ui import "../../elements" -ColumnLayout { +Column { width: parent.width height: parent.height spacing: 1 From ebaf36b50e3369c943e96396285d236008fb45f8 Mon Sep 17 00:00:00 2001 From: pilotnbr1 Date: Thu, 16 Nov 2023 18:12:30 -0500 Subject: [PATCH 64/81] Convert total distance to Coords and bug fixes --- app/telemetry/models/fcmavlinksystem.cpp | 50 +++++++++++------------- app/telemetry/models/fcmavlinksystem.h | 7 ++-- 2 files changed, 26 insertions(+), 31 deletions(-) diff --git a/app/telemetry/models/fcmavlinksystem.cpp b/app/telemetry/models/fcmavlinksystem.cpp index 134768b78..7a2aaaddb 100644 --- a/app/telemetry/models/fcmavlinksystem.cpp +++ b/app/telemetry/models/fcmavlinksystem.cpp @@ -202,13 +202,28 @@ bool FCMavlinkSystem::process_message(const mavlink_message_t &msg) const double lat=static_cast(global_position_int.lat) / 10000000.0; const double lon=static_cast(global_position_int.lon) / 10000000.0; // This way we could also calculate the flight distance - but aparently, this results in slightly too small values - // (probably could be fixed by using a distance calculation method that is a better fit) - /*if(m_lat!=0.0 && m_lon!=0.0 && m_gps_hdop<20){ - const auto added_distance_m=distance_between(m_lat,m_lon,lat,lon); - total_dist = total_dist + added_distance_m; - //qDebug() << "total distance" << total_dist; - set_flight_distance_m( total_dist); - }*/ + double added_distance_m=0.0; + if(m_lat!=0.0 && m_lon!=0.0 && m_gps_hdop<20){ + // kind of dumb to do this for the first few meters....whatever... + if (m_last_lat==0.0 && m_last_lon==0.0){ + added_distance_m=distance_between(m_lat,m_lon,lat,lon); + } + else { + added_distance_m=distance_between(m_last_lat,m_last_lon,lat,lon); + } + qDebug() << "added_distance_m" << added_distance_m; + if (added_distance_m > 2.0){ + + total_dist = total_dist + added_distance_m; + //qDebug() << "total distance" << total_dist; + //in sitl large distance can still be erroniously generated with hdop<20 + if (m_armed ){ + set_flight_distance_m( total_dist); + set_last_lat(lat); + set_last_lon(lon); + } + } + } set_lat(lat); set_lon(lon); set_boot_time(global_position_int.time_boot_ms); @@ -280,7 +295,6 @@ bool FCMavlinkSystem::process_message(const mavlink_message_t &msg) set_throttle(vfr_hud.throttle); set_air_speed_meter_per_second(vfr_hud.airspeed); set_ground_speed_meter_per_second(vfr_hud.groundspeed); - update_flight_distance_using_groundspeed(); // qDebug() << "Speed- ground " << speed; auto vsi = vfr_hud.climb; set_vertical_speed_indicator_mps(vsi); @@ -521,25 +535,6 @@ void FCMavlinkSystem::updateFlightTimer() { } } -void FCMavlinkSystem::update_flight_distance_using_groundspeed() { - if (m_gps_hdop > 20 || m_lat == 0.0){ - //do not pollute distance if we have bad data - return; - } - if (m_armed==true){ - const auto elapsed_ms = flightTimeStart.elapsed(); - const auto time_diff_ms = elapsed_ms - m_flight_distance_last_time_ms; - m_flight_distance_last_time_ms = elapsed_ms; - const auto time_diff_s =time_diff_ms / 1000.0; - const auto added_distance = m_ground_speed_meter_per_second * time_diff_s; - //qDebug() << "added distance" << added_distance; - total_dist = total_dist + added_distance; - //qDebug() << "total distance" << total_dist; - set_flight_distance_m( total_dist); - } -} - - void FCMavlinkSystem::set_armed(bool armed) { if(m_armed==armed)return; //there has been no change so exit if (armed && !m_armed) { @@ -550,6 +545,7 @@ void FCMavlinkSystem::set_armed(bool armed) { * vehicle is disarmed, causing it to appear to stop in the UI. */ flightTimeStart.start(); + set_flight_distance_m(0.0); //reset the flight distance if (m_home_latitude == 0.0 || m_home_longitude == 0.0) { //LocalMessage::instance()->showMessage("No Home Position in FCMavlinkSystem", 4); // Not needed anymore after we just set the proper rate(s) diff --git a/app/telemetry/models/fcmavlinksystem.h b/app/telemetry/models/fcmavlinksystem.h index 3d7e35cd8..bd9649dc2 100644 --- a/app/telemetry/models/fcmavlinksystem.h +++ b/app/telemetry/models/fcmavlinksystem.h @@ -99,6 +99,8 @@ class FCMavlinkSystem : public QObject // L_RO_PROP(double,lat,set_lat,0.0) L_RO_PROP(double,lon,set_lon,0.0) + L_RO_PROP(double,last_lat,set_last_lat,0.0) + L_RO_PROP(double,last_lon,set_last_lon,0.0) L_RO_PROP(int,satellites_visible,set_satellites_visible,0) L_RO_PROP(double,gps_hdop,set_gps_hdop,-1) L_RO_PROP(double,gps_vdop,set_gps_vdop,-1) @@ -164,9 +166,6 @@ class FCMavlinkSystem : public QObject void calculate_home_course(); // Updates the flight time by increasing the time when armed void updateFlightTimer(); - // Calculates the flght distance (dirty) by taking time delta and current speed into account - // replaced by using distance between lat,lon point(s) (this is a bit more accurate) - void update_flight_distance_using_groundspeed(); // Something something luke void updateVehicleAngles(); // Something somethng luke @@ -202,7 +201,7 @@ class FCMavlinkSystem : public QObject double speed_last_time = 0.0; qint64 m_flight_distance_last_time_ms= 0; - long total_dist= 0; + double total_dist= 0.0; QElapsedTimer totalTime; QElapsedTimer flightTimeStart; From 16a7a6726797ea28a46c29a9b7899e7f1d883426 Mon Sep 17 00:00:00 2001 From: consti10 Date: Fri, 17 Nov 2023 10:49:11 +0100 Subject: [PATCH 65/81] add hide mouse feature small UI improvements --- QOpenHD.pro | 2 + app/main.cpp | 4 +- app/util/mousehelper.cpp | 125 ++++++++++++++++++ app/util/mousehelper.h | 41 ++++++ app/util/qopenhd.cpp | 51 +------ app/util/qopenhd.h | 3 - .../AppScreenSettingsView.qml | 24 +++- .../configpopup/status/StatusCardBodyFC.qml | 7 +- qml/ui/configpopup/status/StatusCardRow.qml | 2 +- qml/ui/elements/AppSettings.qml | 1 + 10 files changed, 201 insertions(+), 59 deletions(-) create mode 100644 app/util/mousehelper.cpp create mode 100644 app/util/mousehelper.h diff --git a/QOpenHD.pro b/QOpenHD.pro index d7b0289ee..3d0ef89d6 100755 --- a/QOpenHD.pro +++ b/QOpenHD.pro @@ -102,6 +102,7 @@ LinuxBuild { SOURCES += \ app/logging/hudlogmessagesmodel.cpp \ app/logging/logmessagesmodel.cpp \ + app/util/mousehelper.cpp \ app/util/qopenhd.cpp \ app/util/WorkaroundMessageBox.cpp \ app/util/qrenderstats.cpp \ @@ -116,6 +117,7 @@ HEADERS += \ app/logging/hudlogmessagesmodel.h \ app/logging/loghelper.h \ app/logging/logmessagesmodel.h \ + app/util/mousehelper.h \ app/util/qopenhd.h \ app/util/WorkaroundMessageBox.h \ app/util/qrenderstats.h \ diff --git a/app/main.cpp b/app/main.cpp index a9bb3e342..19ab95b9e 100755 --- a/app/main.cpp +++ b/app/main.cpp @@ -61,6 +61,7 @@ const QVector permissions({"android.permission.INTERNET", #include "logging/logmessagesmodel.h" #include "logging/hudlogmessagesmodel.h" #include "util/qopenhd.h" +#include "util/mousehelper.h" #include "util/WorkaroundMessageBox.h" #include "util/restartqopenhdmessagebox.h" @@ -243,8 +244,6 @@ int main(int argc, char *argv[]) { } QApplication app(argc, argv); - // Customize cursor if needed - QOpenHD::instance().customize_cursor_from_settings(); { // This includes dpi adjustment QScreen* screen=app.primaryScreen(); if(screen){ @@ -280,6 +279,7 @@ int main(int argc, char *argv[]) { // Needs to be registered first, otherwise we can have threading issue(s) engine.rootContext()->setContextProperty("_messageBoxInstance", &WorkaroundMessageBox::instance()); engine.rootContext()->setContextProperty("_restartqopenhdmessagebox", &RestartQOpenHDMessageBox::instance()); + engine.rootContext()->setContextProperty("_mouseHelper", &MouseHelper::instance()); engine.rootContext()->setContextProperty("_qrenderstats", &QRenderStats::instance()); diff --git a/app/util/mousehelper.cpp b/app/util/mousehelper.cpp new file mode 100644 index 000000000..8faa2610c --- /dev/null +++ b/app/util/mousehelper.cpp @@ -0,0 +1,125 @@ +#include "mousehelper.h" +#include "qdebug.h" +#include "qpixmap.h" + +#include + +static QCursor create_custom_cursor(const int cursor_type,const int cursor_scale){ + assert(cursor_type!=0); + QPixmap pixmap; + if(cursor_type==1){ + pixmap=QPixmap("://resources/cursors/arrow_512_transparent.png"); + }else if(cursor_type==2){ + pixmap=QPixmap("://resources/cursors/arrow_512_white.png"); + }else if(cursor_type==3){ + pixmap=QPixmap("://resources/cursors/arrow_512_green.png"); + }else{ + pixmap=QPixmap("://resources/cursors/hand_white.png"); + } + int size_px= 16; + if(cursor_scale==0){ + size_px =16; + }else if(cursor_scale==1){ + size_px = 32; + }else if(cursor_scale==2){ + size_px=64; + }else if(cursor_scale==3){ + size_px= 128; + } + pixmap = pixmap.scaled(size_px,size_px); + // position is a bit of a mess + QCursor cursor; + // arrow - roughly + if(cursor_type==1 || cursor_type==2 || cursor_type==3){ + cursor=QCursor(pixmap,pixmap.width()/16,pixmap.height()/16); + }else{ + // The hand is a bit different + cursor=QCursor(pixmap,pixmap.width()/3,pixmap.height()/4); + } + return cursor; +} + + +MouseHelper &MouseHelper::instance() +{ + static MouseHelper i; + return i; +} + +MouseHelper::MouseHelper() +{ + m_timer.setSingleShot(true); + m_timer.callOnTimeout([this]() {on_timeout();}); + init_from_settings(); +} + +void MouseHelper::init_from_settings() +{ + QSettings settings; + const int custom_cursor_type=settings.value("custom_cursor_type",0).toInt(); + const int custom_cursor_scale=settings.value("custom_cursor_scale",1).toInt(); + const bool enable_cursor_auto_hide=settings.value("enable_cursor_auto_hide",false).toBool(); + set_active_cursor_type_and_scale(custom_cursor_type,custom_cursor_scale); + set_hide_cursor_inactive_enable(enable_cursor_auto_hide); +} + +void MouseHelper::set_active_cursor_type_and_scale(const int cursor_type, const int cursor_scale) +{ + m_cursor_type=cursor_type; + m_cursor_scale=cursor_scale; + update_cursor_state(); +} + +void MouseHelper::set_hide_cursor_inactive_enable(bool enable) +{ + if(enable){ + QCoreApplication::instance()->installEventFilter(this); + m_enable_hide_cursor_when_inactive=true; + }else{ + QCoreApplication::instance()->removeEventFilter(this); + m_enable_hide_cursor_when_inactive=false; + m_timer.stop(); + m_cursor_state_active=true; + update_cursor_state(); + } +} + +bool MouseHelper::eventFilter(QObject *pWatched, QEvent *pEvent){ + if (pEvent->type() == QEvent::MouseMove){ + on_mouse_event(); + } + return QObject::eventFilter(pWatched, pEvent); +} + +void MouseHelper::on_timeout(){ + if(m_cursor_state_active){ + m_cursor_state_active= false; + update_cursor_state(); + } +} + +void MouseHelper::on_mouse_event(){ + if(!m_cursor_state_active){ + m_cursor_state_active= true; + update_cursor_state(); + } + // restarts the timer if already running + m_timer.start(m_inactivity_duration_msec); +} + +void MouseHelper::update_cursor_state(){ + if(m_cursor_state_active){ + if(m_cursor_type==0){ + // Default application cursor + QApplication::restoreOverrideCursor(); + }else{ + // Install the custom cursor + QApplication::restoreOverrideCursor(); + auto custom_cursor=create_custom_cursor(m_cursor_type,m_cursor_scale); + QApplication::setOverrideCursor(custom_cursor); + } + }else{ + QApplication::restoreOverrideCursor(); + QApplication::setOverrideCursor(Qt::BlankCursor); + } +} diff --git a/app/util/mousehelper.h b/app/util/mousehelper.h new file mode 100644 index 000000000..f65a8d44e --- /dev/null +++ b/app/util/mousehelper.h @@ -0,0 +1,41 @@ +#ifndef QMOUSEHIDER_H +#define QMOUSEHIDER_H + +#include + +#include +#include +#include + +// adds 2 features +// 1) high visibility cursor for people in the field +// 2) cursor auto hide +class MouseHelper : public QObject +{ + Q_OBJECT +public: + static MouseHelper& instance(); + explicit MouseHelper(); + + void init_from_settings(); + // update when settings change + Q_INVOKABLE void set_active_cursor_type_and_scale(const int cursor_type,const int cursor_scale); + // Enable / disable auto hide + Q_INVOKABLE void set_hide_cursor_inactive_enable(bool enable); +private: + const int m_inactivity_duration_msec=3000; + QTimer m_timer; + int m_cursor_type=0; + int m_cursor_scale=1; + bool m_enable_hide_cursor_when_inactive=false; + bool m_cursor_state_active= true; // active by default + + bool eventFilter(QObject *pWatched, QEvent *pEvent) override; + void on_mouse_event(); + void on_timeout(); + void update_cursor_state(); + +}; + + +#endif // QMOUSEHIDER_H diff --git a/app/util/qopenhd.cpp b/app/util/qopenhd.cpp index 8c0056144..1e8ee17d2 100644 --- a/app/util/qopenhd.cpp +++ b/app/util/qopenhd.cpp @@ -26,6 +26,7 @@ #include #endif +#include "mousehelper.h" QOpenHD &QOpenHD::instance() { @@ -231,56 +232,6 @@ QString QOpenHD::show_local_ip() } -void QOpenHD::customize_cursor(const int cursor_type,const int cursor_scale) -{ - QApplication::restoreOverrideCursor(); - // Default 0 - do not change - if(cursor_type==0)return; - qDebug()<<"Custom cursor type:"< 260 ? 260 : parent.width height: main_item.height anchors.centerIn: parent diff --git a/qml/ui/elements/AppSettings.qml b/qml/ui/elements/AppSettings.qml index f40ca06ce..da4324369 100644 --- a/qml/ui/elements/AppSettings.qml +++ b/qml/ui/elements/AppSettings.qml @@ -389,6 +389,7 @@ Settings { property int custom_cursor_type: 0 property int custom_cursor_scale: 1 // arbitrary scale values - higher == bigger, + property bool enable_cursor_auto_hide: false // experimental - mavlink via TCP property bool dev_mavlink_via_tcp: false From c633fd5ff6c2e16888feb174078648969faeefca Mon Sep 17 00:00:00 2001 From: consti10 Date: Fri, 17 Nov 2023 10:56:05 +0100 Subject: [PATCH 66/81] add hide mouse feature --- app/util/mousehelper.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/util/mousehelper.h b/app/util/mousehelper.h index f65a8d44e..c769c83a8 100644 --- a/app/util/mousehelper.h +++ b/app/util/mousehelper.h @@ -16,14 +16,13 @@ class MouseHelper : public QObject public: static MouseHelper& instance(); explicit MouseHelper(); - - void init_from_settings(); // update when settings change Q_INVOKABLE void set_active_cursor_type_and_scale(const int cursor_type,const int cursor_scale); // Enable / disable auto hide Q_INVOKABLE void set_hide_cursor_inactive_enable(bool enable); private: - const int m_inactivity_duration_msec=3000; + void init_from_settings(); + const int m_inactivity_duration_msec=2000; QTimer m_timer; int m_cursor_type=0; int m_cursor_scale=1; From 7ef5d54a9b8a58131ded2b4a1f3a12b20f3681c5 Mon Sep 17 00:00:00 2001 From: consti10 Date: Sat, 18 Nov 2023 17:31:09 +0100 Subject: [PATCH 67/81] rename a bit, font select - update on change --- qml/qml.qrc | 6 +- qml/ui/configpopup/ConfigPopup.qml | 8 +- ...nHDWBParamPanel.qml => LinkQuickPanel.qml} | 15 +- ...SettingsPanel.qml => OHDSettingsPanel.qml} | 3 +- .../openhd_settings/OpenHDQuickPanel.qml | 353 ------------------ .../AppWidgetStyleSettingsView.qml | 2 +- qml/ui/elements/FontSelect.qml | 88 ++++- qml/ui/elements/FontSelectForm.ui.qml | 81 ---- 8 files changed, 97 insertions(+), 459 deletions(-) rename qml/ui/configpopup/openhd_settings/{MavlinkOpenHDWBParamPanel.qml => LinkQuickPanel.qml} (97%) rename qml/ui/configpopup/openhd_settings/{MavlinkAllSettingsPanel.qml => OHDSettingsPanel.qml} (97%) delete mode 100644 qml/ui/configpopup/openhd_settings/OpenHDQuickPanel.qml delete mode 100644 qml/ui/elements/FontSelectForm.ui.qml diff --git a/qml/qml.qrc b/qml/qml.qrc index 366439aba..19dffdd1c 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -127,7 +127,6 @@ osdfonts/Visitor.ttf osdfonts/ZolanMonoOblique.ttf ui/elements/FontSelect.qml - ui/elements/FontSelectForm.ui.qml ui/elements/OSDCustomizer.qml ui/elements/colorwheel/CheckerBoard.qml ui/elements/colorwheel/ColorWheel.qml @@ -208,7 +207,7 @@ ui/configpopup/qopenhd_settings/AppDevSettingsView.qml ui/configpopup/openhd_settings/MavlinkParamPanel.qml ui/configpopup/openhd_settings/MavlinkParamEditor.qml - ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml + ui/configpopup/openhd_settings/OHDSettingsPanel.qml ui/configpopup/openhd_settings/DialoqueFreqChangeGndOnly.qml ui/configpopup/ConfigPopupSidebarButton.qml ui/configpopup/rc/RcInfoScreen.qml @@ -248,7 +247,7 @@ ui/configpopup/status/DialoqueNotAlive.qml ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml ui/configpopup/log/LogMessagesView.qml - ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml + ui/configpopup/openhd_settings/LinkQuickPanel.qml ui/configpopup/openhd_settings/PopupScanChannels.qml ui/configpopup/openhd_settings/PopupTxPowerEditor.qml ui/elements/TextOrWarningButton.qml @@ -261,7 +260,6 @@ video/SecondaryVideoGstreamerPane.qml ui/elements/SettingsHeaderElement.qml ui/configpopup/qopenhd_settings/AppWidgetStyleSettingsView.qml - ui/configpopup/openhd_settings/OpenHDQuickPanel.qml ui/elements/BaseHeaderItem.qml ui/elements/ButtonIconInfo2.qml ui/elements/CardBasic.qml diff --git a/qml/ui/configpopup/ConfigPopup.qml b/qml/ui/configpopup/ConfigPopup.qml index 0c8ad91ca..5a8f6956b 100644 --- a/qml/ui/configpopup/ConfigPopup.qml +++ b/qml/ui/configpopup/ConfigPopup.qml @@ -54,7 +54,7 @@ Rectangle { function user_guidance_open_openhd_settings_find_air_unit_location(){ openSettings(); mainStackLayout.currentIndex=1; - mavlinkAllSettingsPanel.user_quidance_animate_channel_scan(); + ohdSettingsPanel.user_quidance_animate_channel_scan(); } /*Keys.onPressed: (event)=> { @@ -170,7 +170,7 @@ Rectangle { m_selection_index: 0 } - // OpenHD Settings - MavlinkAllSettingsPanel + // OpenHD OHD Settings ConfigPopupSidebarButton{ id: openhd_button m_icon_text: "\uf085" @@ -253,8 +253,8 @@ Rectangle { } //this is "openhd" menu - MavlinkAllSettingsPanel { - id: mavlinkAllSettingsPanel + OHDSettingsPanel { + id: ohdSettingsPanel } AppSettingsPanel { diff --git a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml b/qml/ui/configpopup/openhd_settings/LinkQuickPanel.qml similarity index 97% rename from qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml rename to qml/ui/configpopup/openhd_settings/LinkQuickPanel.qml index 5a88e7256..b6866a31a 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml +++ b/qml/ui/configpopup/openhd_settings/LinkQuickPanel.qml @@ -206,17 +206,6 @@ Rectangle{ } enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0; } - /*Switch{ - Layout.alignment: Qt.AlignCenter - text: "SIMPLIFY" - checked: true - onCheckedChanged: { - if(m_simplify_enable!=checked){ - m_simplify_enable=checked; - function_rebuild_ui(); - } - } - }*/ TabBar{ id: filter_tab_bar Layout.preferredWidth: 200 @@ -249,8 +238,8 @@ Rectangle{ Layout.alignment: Qt.AlignRight onClicked: { var text="Please select a channel / frequency free of noise and interference. The current loss / pollution / throttle stats below can help,"+ - "as well as the analyze channels feature or a frequency analyzer on your phone. SIMPLIFY: Show OpenHD standard channels [1-5] only - they "+ - " often are free of wifi pollution and should be used. Only disable SIMPLIFY if you know exactly why." + "as well as the analyze channels feature or a frequency analyzer on your phone. DEF: Show OpenHD standard channels [1-5] only - they "+ + " often are free of wifi pollution and should be used." _messageBoxInstance.set_text_and_show(text) } } diff --git a/qml/ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml b/qml/ui/configpopup/openhd_settings/OHDSettingsPanel.qml similarity index 97% rename from qml/ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml rename to qml/ui/configpopup/openhd_settings/OHDSettingsPanel.qml index 71eef0109..94e422f0e 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml +++ b/qml/ui/configpopup/openhd_settings/OHDSettingsPanel.qml @@ -63,8 +63,7 @@ Rectangle { anchors.bottom: parent.bottom currentIndex: selectItemInStackLayoutBar.currentIndex - MavlinkOpenHDWBParamPanel{ - //OpenHDQuickPanel{ + LinkQuickPanel{ id: mavlink_openhd_wb_param_panel } MavlinkParamPanel{ diff --git a/qml/ui/configpopup/openhd_settings/OpenHDQuickPanel.qml b/qml/ui/configpopup/openhd_settings/OpenHDQuickPanel.qml deleted file mode 100644 index 327fc3281..000000000 --- a/qml/ui/configpopup/openhd_settings/OpenHDQuickPanel.qml +++ /dev/null @@ -1,353 +0,0 @@ -import QtQuick 2.0 - -import QtQuick 2.12 -import QtQuick.Controls 2.12 -import QtQuick.Layouts 1.12 -import QtQuick.Dialogs 1.0 -import QtQuick.Controls.Material 2.12 -import QtQuick.Controls.Styles 1.4 - -import Qt.labs.settings 1.0 - -import OpenHD 1.0 - -import "../../../ui" as Ui -import "../../elements" - -import QtCharts 2.0 - -// This is an extra screen for changing the frequency / channel width - -// They both need to match ! -Rectangle{ - id: main_background - width: parent.width - height: parent.height - //property color m_background_color: "#8cbfd7f3" - //property color m_background_color: "#ADD8E6" - property color m_background_color: "#8cbfd7f3" - - property int m_small_width: 200 - - function user_quidance_animate_channel_scan(){ - console.log("User guidance animate channel scan"); - anim_find_air_unit.start() - } - - // https://stackoverflow.com/questions/41991438/how-do-i-find-a-particular-listelement-inside-a-listmodel-in-qml - // For the models above (model with value) try to find the index of the first item where model[i].value===value - function find_index(model,value){ - for(var i = 0; i < model.count; ++i) if (model.get(i).value===value) return i - return -1 - } - - function fc_is_armed(){ - return _fcMavlinkSystem.armed - } - - ListModel{ - id: frequencies_model_all - ListElement {title: "Unknown"; value_frequency_mhz:-1} - } - ListModel{ - id: frequencies_model_openhd_channels_only - ListElement {title: "Unknown"; value_frequency_mhz:-1} - } - - function create_list_models_frequency(){ - frequencies_model_all.clear(); - const frequencies_all=_frequencyHelper.get_frequencies(false); - for(var i=0;i0){ - var index=find_index(comboBoxFreq.model,_wbLinkSettingsHelper.curr_channel_mhz); - if(index>=0){ - comboBoxFreq.currentIndex=index; - }else{ - comboBoxFreq.currentIndex=0; - console.log("Seems not to be a valid channel "+_wbLinkSettingsHelper.curr_channel_mhz) - } - }else{ - comboBoxFreq.currentIndex=-1; - } - } - - // We get notified every time we should re-build the model(s) and their current selection - property int m_ui_rebuild_models : _wbLinkSettingsHelper.ui_rebuild_models - onM_ui_rebuild_modelsChanged: { - console.log(" onM_ui_rebuild_modelsChanged: "+_wbLinkSettingsHelper.ui_rebuild_models); - function_rebuild_ui() - } - - function function_rebuild_ui(){ - update_frequency_combobox(); - console.log("function_rebuild_ui:"+_wbLinkSettingsHelper.ui_rebuild_models); - if(_wbLinkSettingsHelper.ui_rebuild_models<=0)return - popup_analyze_channels.update(); - } - - // - function close_all_dialoques(){ - popup_analyze_channels.close() - popup_scan_channels.close(); - popup_change_tx_power.close(); - dialoqueFreqChangeGndOnly.close(); - dialoqueFreqChangeAirGnd.close(); - popup_enable_stbc_ldpc.close(); - } - - function get_text_stbc_ldpc(air){ - if(air){ - if(!_ohdSystemAir.is_alive)return "N/A"; - return ""+(_ohdSystemAir.wb_stbc_enabled ? "YES" : "NO")+"/"+(_ohdSystemAir.wb_lpdc_enabled ? "YES" : "NO"); - } - if(!_ohdSystemGround.is_alive)return "N/A"; - return ""+(_ohdSystemGround.wb_stbc_enabled ? "YES" : "NO")+"/"+(_ohdSystemGround.wb_lpdc_enabled ? "YES" : "NO"); - } - - Component.onCompleted: { - close_all_dialoques(); - create_list_models_frequency(); - update_frequency_combobox(); - } - - function get_text_wifi_tx_power(air){ - if(air){ - if(!_wifi_card_air.alive) return "N/A"; - return ""+_wifi_card_air.tx_power+" "+_wifi_card_air.tx_power_unit; - } - if(!_wifi_card_gnd0.alive) return "N/A"; - return ""+_wifi_card_gnd0.tx_power+" "+_wifi_card_gnd0.tx_power_unit; - } - - ScrollView { - id: main_scroll_view - width: parent.width - height: parent.height - anchors.centerIn: parent - contentHeight: main_column_layout.height - //contentWidth: main_column_layout.width - //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) - - - Column{ - spacing: 0 - anchors.left: parent.left - anchors.right: parent.right - id: main_colum_layout - Text{ - width: parent.width - height: rowHeight - text: "FREQUENCY / TOOLKIT" - font.bold: true - horizontalAlignment: Qt.AlignHCenter - verticalAlignment: Qt.AlignVCenter - } - Row{ - width: parent.width - height: rowHeight - ComboBox { - id: comboBoxFreq - //model: supported_frequencies_model - //model: frequencies_model_openhd_channels_only - textRole: "title" - implicitWidth: elementComboBoxWidth - currentIndex: 0 - delegate: ItemDelegate { - width: comboBoxFreq.width - contentItem: FreqComboBoxRow{ - m_main_text: title - m_selection_tpye: (value_frequency_mhz===_wbLinkSettingsHelper.curr_channel_mhz) ? 1 : 0 - m_is_2G: value_frequency_mhz < 3000 && value_frequency_mhz > 100 - m_show_radar: _frequencyHelper.get_frequency_radar(value_frequency_mhz) - m_openhd_race_band: _frequencyHelper.get_frequency_openhd_race_band(value_frequency_mhz) - m_pollution_pps: _pollutionHelper.pollution_get_last_scan_pollution_for_frequency(value_frequency_mhz) - } - highlighted: comboBoxFreq.highlightedIndex === index - } - Layout.row: 1 - Layout.column: 0 - displayText: { - if(!_ohdSystemGround.is_alive)return "GND NOT ALIVE"; - if(_ohdSystemGround.wb_gnd_operating_mode==1){ - return "SCANNING"; - } - if(_ohdSystemGround.wb_gnd_operating_mode==2){ - return "ANALYZING"; - } - if(!_ohdSystemAir.is_alive){ - return _wbLinkSettingsHelper.curr_channel_mhz+"@"+"N/A"+" Mhz (NO AIR)"; - } - return _wbLinkSettingsHelper.curr_channel_mhz+"@"+_wbLinkSettingsHelper.curr_channel_width_mhz+" Mhz"; - } - onActivated: { - console.log("onActivated:"+currentIndex); - if(currentIndex<0)return; - const frequency_mhz=comboBoxFreq.model.get(currentIndex).value_frequency_mhz - console.log("Selected frequency: "+frequency_mhz); - if(!_frequencyHelper.hw_supports_frequency_threadsafe(frequency_mhz)){ - _qopenhd.show_toast("your HW does not support "+frequency_mhz+" Mhz"); - return; - } - if(_wbLinkSettingsHelper.curr_channel_mhz==frequency_mhz){ - console.log("Already at frequency "+frequency_mhz); - return; - } - if(!_ohdSystemAir.is_alive){ - var error_message_not_alive="AIR Unit not alive -" - dialoqueFreqChangeGndOnly.initialize_and_show_frequency(frequency_mhz,error_message_not_alive); - return; - } - // Change the freuquency - dialoqueFreqChangeAirGnd.initialize_and_show_frequency(frequency_mhz); - } - enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0; - } - Switch{ - Layout.row: 1 - Layout.column: 1 - Layout.columnSpan: 1 - text: "SIMPLIFY" - checked: true - onCheckedChanged: { - if(m_simplify_enable!=checked){ - m_simplify_enable=checked; - function_rebuild_ui(); - } - } - } - } - Row{ - width: parent.width - height: rowHeight - Button{ - Layout.preferredWidth: 150 - id: b_find_air_unit - text: "SCAN" - enabled: _ohdSystemGround.is_alive - onClicked: { - close_all_dialoques(); - popup_scan_channels.open() - } - SequentialAnimation { - running: false - loops: 4 - id: anim_find_air_unit - // Expand the button - PropertyAnimation { - target: b_find_air_unit - property: "scale" - to: 1.5 - duration: 200 - easing.type: Easing.InOutQuad - } - // Shrink back to normal - PropertyAnimation { - target: b_find_air_unit - property: "scale" - to: 1.0 - duration: 200 - easing.type: Easing.InOutQuad - } - } - } - Button{ - Layout.preferredWidth: 150 - text: "ANALYZE" - enabled: _ohdSystemGround.is_alive - onClicked: { - close_all_dialoques(); - popup_analyze_channels.open() - } - } - } - Text{ - width: parent.width - height: rowHeight - text: "TX POWER" - font.bold: true - horizontalAlignment: Qt.AlignHCenter - verticalAlignment: Qt.AlignVCenter - } - Row{ - width: parent.width - height: rowHeight - Text{ - Layout.preferredWidth: 120 - text: "AIR:\n "+get_text_wifi_tx_power(true) - verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignHCenter - font.bold: true - } - Button{ - text: "EDIT" - enabled: _ohdSystemAir.is_alive - onClicked: { - close_all_dialoques(); - popup_change_tx_power.m_is_air=true; - popup_change_tx_power.open() - } - } - Text{ - Layout.preferredWidth: 120 - text: "GND:\n"+get_text_wifi_tx_power(false) - verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignHCenter - font.bold: true - } - Button{ - text: "EDIT" - enabled: _ohdSystemGround.is_alive - onClicked: { - close_all_dialoques(); - popup_change_tx_power.m_is_air=false; - popup_change_tx_power.open() - } - } - } - - } - } - - PopupAnalyzeChannels{ - id: popup_analyze_channels - } - - PopupScanChannels{ - id: popup_scan_channels - } - - PopupTxPowerEditor{ - id: popup_change_tx_power - } - PopupEnableSTBCLDPC{ - id: popup_enable_stbc_ldpc - } - - DialoqueFreqChangeGndOnly{ - id: dialoqueFreqChangeGndOnly - } - DialoqueFreqChangeAirGnd{ - id: dialoqueFreqChangeAirGnd - } -} diff --git a/qml/ui/configpopup/qopenhd_settings/AppWidgetStyleSettingsView.qml b/qml/ui/configpopup/qopenhd_settings/AppWidgetStyleSettingsView.qml index 9391ded82..dc2030770 100644 --- a/qml/ui/configpopup/qopenhd_settings/AppWidgetStyleSettingsView.qml +++ b/qml/ui/configpopup/qopenhd_settings/AppWidgetStyleSettingsView.qml @@ -59,7 +59,7 @@ ScrollView { settings.color_shape="#ff14ff00" settings.color_text="#ff05ff00" settings.color_warn="red" - //settings.font_text="Quicksand" + settings.font_text="Quicksand" } } Button{ diff --git a/qml/ui/elements/FontSelect.qml b/qml/ui/elements/FontSelect.qml index a1c56fa9a..95829c863 100644 --- a/qml/ui/elements/FontSelect.qml +++ b/qml/ui/elements/FontSelect.qml @@ -1,6 +1,92 @@ import QtQuick 2.12 import QtQuick.Controls 2.12 -FontSelectForm { +Item { + property string dummy_listener: settings.font_text + + function update_selection(){ + for (var i = 0; i < fontDropdown.model.count; i++) { + var choice = fontDropdown.model.get(i); + if (choice.text == settings.font_text) { + fontDropdown.currentIndex = i; + } + } + } + + onDummy_listenerChanged: { + update_selection(); + } + + ComboBox { + id: fontDropdown + anchors.fill: parent + font.pixelSize: 14 + + model: ListModel { + id: font_text + ListElement { text: "Sans Serif" } + ListElement { text: "Acme" } + ListElement { text: "Aldrich" } + ListElement { text: "Anonymous Pro" } + ListElement { text: "Archivo" } + ListElement { text: "Archivo Black" } + ListElement { text: "Armata" } + ListElement { text: "Bangers" } + ListElement { text: "Black Ops One" } + ListElement { text: "Bungee" } + ListElement { text: "Carbon" } + ListElement { text: "Chicle" } + ListElement { text: "Digital Counter 7" } + ListElement { text: "Expletus Sans" } + ListElement { text: "Fjalla One" } + ListElement { text: "Fredoka One" } + ListElement { text: "Geostar Fill" } + ListElement { text: "Iceberg" } + ListElement { text: "Iceland" } + ListElement { text: "Jura" } + ListElement { text: "Keania One" } + ListElement { text: "Larabiefont" } + ListElement { text: "LED Display7" } + ListElement { text: "Luckiest Guy" } + ListElement { text: "Merysha" } + ListElement { text: "Nixie One" } + ListElement { text: "Orbitron" } + ListElement { text: "Oxygen" } + ListElement { text: "Passion One" } + ListElement { text: "Quantico" } + ListElement { text: "Quicksand" } + ListElement { text: "Rammetto One" } + ListElement { text: "Rationale" } + ListElement { text: "Righteous" } + ListElement { text: "Roboto Mono" } + ListElement { text: "Russo One" } + ListElement { text: "Share Tech" } + ListElement { text: "Share Tech Mono" } + ListElement { text: "Sigmar One" } + ListElement { text: "Slackey" } + ListElement { text: "Subway Ticker" } + ListElement { text: "Ubuntu Mono" } + ListElement { text: "Visitor TT1 BRK" } + ListElement { text: "Zolan Mono BTN" } + } + + textRole: "text" + // @disable-check M223 + Component.onCompleted: { + + fontDropdown.popup.contentItem.implicitHeight = Qt.binding(function () { + return Math.min(250, fontDropdown.popup.contentItem.contentHeight); + }); + update_selection(); + + } + onCurrentIndexChanged: { + const selected_font=font_text.get(currentIndex).text + if(settings.font_text!=selected_font){ + settings.font_text=selected_font; + console.log("Selected font:"+settings.font_text) + } + } + } } diff --git a/qml/ui/elements/FontSelectForm.ui.qml b/qml/ui/elements/FontSelectForm.ui.qml deleted file mode 100644 index 9129bbe3d..000000000 --- a/qml/ui/elements/FontSelectForm.ui.qml +++ /dev/null @@ -1,81 +0,0 @@ -import QtQuick 2.12 -import QtQuick.Controls 2.12 - -Item { - ComboBox { - id: fontDropdown - anchors.fill: parent - font.pixelSize: 14 - - model: ListModel { - id: font_text - ListElement { text: "Sans Serif" } - ListElement { text: "Acme" } - ListElement { text: "Aldrich" } - ListElement { text: "Anonymous Pro" } - ListElement { text: "Archivo" } - ListElement { text: "Archivo Black" } - ListElement { text: "Armata" } - ListElement { text: "Bangers" } - ListElement { text: "Black Ops One" } - ListElement { text: "Bungee" } - ListElement { text: "Carbon" } - ListElement { text: "Chicle" } - ListElement { text: "Digital Counter 7" } - ListElement { text: "Expletus Sans" } - ListElement { text: "Fjalla One" } - ListElement { text: "Fredoka One" } - ListElement { text: "Geostar Fill" } - ListElement { text: "Iceberg" } - ListElement { text: "Iceland" } - ListElement { text: "Jura" } - ListElement { text: "Keania One" } - ListElement { text: "Larabiefont" } - ListElement { text: "LED Display7" } - ListElement { text: "Luckiest Guy" } - ListElement { text: "Merysha" } - ListElement { text: "Nixie One" } - ListElement { text: "Orbitron" } - ListElement { text: "Oxygen" } - ListElement { text: "Passion One" } - ListElement { text: "Quantico" } - ListElement { text: "Quicksand" } - ListElement { text: "Rammetto One" } - ListElement { text: "Rationale" } - ListElement { text: "Righteous" } - ListElement { text: "Roboto Mono" } - ListElement { text: "Russo One" } - ListElement { text: "Share Tech" } - ListElement { text: "Share Tech Mono" } - ListElement { text: "Sigmar One" } - ListElement { text: "Slackey" } - ListElement { text: "Subway Ticker" } - ListElement { text: "Ubuntu Mono" } - ListElement { text: "Visitor TT1 BRK" } - ListElement { text: "Zolan Mono BTN" } - } - - textRole: "text" - // @disable-check M223 - Component.onCompleted: { - - fontDropdown.popup.contentItem.implicitHeight = Qt.binding(function () { - return Math.min(250, fontDropdown.popup.contentItem.contentHeight); - }); - - // @disable-check M223 - for (var i = 0; i < model.count; i++) { - // @disable-check M222 - var choice = model.get(i); - // @disable-check M223 - if (choice.text == settings.font_text) { - currentIndex = i; - } - } - } - onCurrentIndexChanged: { - settings.font_text = font_text.get(currentIndex).text - console.log(settings.font_text) - } - } -} From 148b32fec52a857e4f222b8df39f700ba68a535b Mon Sep 17 00:00:00 2001 From: consti10 Date: Mon, 20 Nov 2023 17:22:06 +0100 Subject: [PATCH 68/81] throttle - more verbose text, rate control widget highlight currently selected value(s) --- .../configpopup/openhd_settings/LinkQuickPanel.qml | 10 +++++++++- qml/ui/widgets/WBLinkRateControlWidget.qml | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/qml/ui/configpopup/openhd_settings/LinkQuickPanel.qml b/qml/ui/configpopup/openhd_settings/LinkQuickPanel.qml index b6866a31a..da9f5ff7e 100644 --- a/qml/ui/configpopup/openhd_settings/LinkQuickPanel.qml +++ b/qml/ui/configpopup/openhd_settings/LinkQuickPanel.qml @@ -334,7 +334,15 @@ Rectangle{ Layout.preferredHeight: 50 Layout.preferredWidth: 120 text: { - return "THROTTLE:\n"+_ohdSystemAir.curr_n_rate_adjustments + var ret="THROTTLE:\n"; + if(_ohdSystemAir.curr_n_rate_adjustments<=-1){ + ret+="N/A"; + }else if(_ohdSystemAir.curr_n_rate_adjustments==0){ + ret+="NONE"; + }else{ + ret+=("ACTIVE:"+_ohdSystemAir.curr_n_rate_adjustments+"x"); + } + return ret; } color: _ohdSystemAir.curr_n_rate_adjustments > 0 ? "red" : "black" verticalAlignment: Qt.AlignVCenter diff --git a/qml/ui/widgets/WBLinkRateControlWidget.qml b/qml/ui/widgets/WBLinkRateControlWidget.qml index e8540c70e..e9ca37931 100644 --- a/qml/ui/widgets/WBLinkRateControlWidget.qml +++ b/qml/ui/widgets/WBLinkRateControlWidget.qml @@ -379,6 +379,13 @@ Make the video more stable (less microfreezes) on the cost of less image quality const mcs=model.get(currentIndex).value set_air_only_mcs(mcs) } + onDisplayTextChanged: { + for(var i = 0; i < model.count; ++i) { + if (model.get(i).value==m_curr_mcs_index){ + currentIndex=i; + } + } + } enabled: _ohdSystemAir.is_alive; } } @@ -408,6 +415,13 @@ Make the video more stable (less microfreezes) on the cost of less image quality set_fec_percentage(fec) set_keyframe_interval(key) } + onDisplayTextChanged: { + for(var i = 0; i < model.count; ++i) { + if (model.get(i).value_fec==m_curr_fec_perc && model.get(i).value_keyframe==m_curr_keyframe_i){ + currentIndex=i; + } + } + } enabled: _ohdSystemAir.is_alive; } } From 98dd78d26a9fbe65e48740755e1e06ab267e893f Mon Sep 17 00:00:00 2001 From: consti10 Date: Mon, 20 Nov 2023 17:22:45 +0100 Subject: [PATCH 69/81] update version to 2.5.2-beta --- app/util/qopenhd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/util/qopenhd.h b/app/util/qopenhd.h index 63075d413..0d87e2ac6 100644 --- a/app/util/qopenhd.h +++ b/app/util/qopenhd.h @@ -65,7 +65,7 @@ class QOpenHD : public QObject // Tries to mimic android toast as much as possible // Q_INVOKABLE void show_toast(QString message,bool long_toast=false); - L_RO_PROP(QString,version_string,set_version_string,"2.5.2-evo-alpha"); + L_RO_PROP(QString,version_string,set_version_string,"2.5.2-evo-beta"); public: L_RO_PROP(QString,toast_text,set_toast_text,"NONE"); L_RO_PROP(bool,toast_visible,set_toast_visible,false); From 5bda407ada2d340063c0a47af0d152303a75b384 Mon Sep 17 00:00:00 2001 From: Raphael <68374617+raphaelscholle@users.noreply.github.com> Date: Mon, 20 Nov 2023 19:54:27 +0100 Subject: [PATCH 70/81] merge packaging, decode and sidebar changes --- build_chroot.sh | 4 +- package.sh | 49 ++- qml/ui/HUDOverlayGrid.qml | 7 +- qml/ui/widgets/Sidebar.qml | 577 +++++++++++++++++++++++------ systemd/rock3_h264_decode.service | 3 +- systemd/rock3_h265_decode.service | 2 +- systemd/rock3_mjpeg_decode.service | 2 +- systemd/rock3_qopenhd.service | 1 + 8 files changed, 519 insertions(+), 126 deletions(-) diff --git a/build_chroot.sh b/build_chroot.sh index e8a0d4667..481fc4fda 100644 --- a/build_chroot.sh +++ b/build_chroot.sh @@ -14,5 +14,7 @@ git describe --exact-match HEAD >/dev/null 2>&1 echo "Pushing the package to OpenHD dev-release repository" ls -a API_KEY=$(cat cloudsmith_api_key.txt) -cloudsmith push deb --api-key "$API_KEY" openhd/dev-release/debian/bullseye *.deb || exit 1 +cloudsmith push deb --api-key "$API_KEY" openhd/dev-release/debian/bullseye qopenhd_rk3588*.deb || exit 1 +cloudsmith push deb --api-key "$API_KEY" openhd/dev-release/debian/bullseye qopenhd_rk3566*.deb || exit 1 + diff --git a/package.sh b/package.sh index 3488cd167..c0716a702 100755 --- a/package.sh +++ b/package.sh @@ -10,7 +10,6 @@ DISTRO=$3 BUILD_TYPE=$4 -PACKAGE_NAME=qopenhd TMPDIR=/tmp/qopenhd/ rm -rf /tmp/qopenhd/* @@ -55,22 +54,25 @@ if [[ "${DISTRO}" == "bullseye" ]] && [[ "${OS}" == "raspbian" ]] ; then #Raspberry PLATFORM_PACKAGES="-d openhd-userland -d libavcodec-dev -d libavformat-dev -d openhd-qt -d gst-plugins-good -d gst-openhd-plugins -d gstreamer1.0-gl" else -PLATFORM_PACKAGES="-d gstreamer1.0-gl -d qtgstreamer-plugins-qt5 -d gstreamer1.0-qt5 -d libqt5texttospeech5-dev -d qml-module-qt-labs-platform -d git -d libgstreamer-plugins-base1.0-dev -d gstreamer1.0-plugins-good -d libavcodec-dev -d libavformat-dev -d qml-module-qtquick-controls2 -d libqt5concurrent5 -d libqt5core5a -d libqt5dbus5 -d libqt5gui5 -d libqt5help5 -d libqt5location5 -d libqt5location5-plugins -d libqt5multimedia5 -d libqt5multimedia5-plugins -d libqt5multimediagsttools5 -d libqt5multimediawidgets5 -d libqt5network5 -d libqt5opengl5 -d libqt5opengl5-dev -d libqt5positioning5 -d libqt5positioning5-plugins -d libqt5positioningquick5 -d libqt5printsupport5 -d libqt5qml5 -d libqt5quick5 -d libqt5quickparticles5 -d libqt5quickshapes5 -d libqt5quicktest5 -d libqt5quickwidgets5 -d libqt5sensors5 -d libqt5sql5 -d libqt5sql5-sqlite -d libqt5svg5 -d libqt5test5 -d libqt5webchannel5 -d libqt5webkit5 -d libqt5widgets5 -d libqt5x11extras5 -d libqt5xml5 -d openshot-qt -d python3-pyqt5 -d python3-pyqt5.qtopengl -d python3-pyqt5.qtsvg -d python3-pyqt5.qtwebkit -d python3-pyqtgraph -d qml-module-qt-labs-settings -d qml-module-qtgraphicaleffects -d qml-module-qtlocation -d qml-module-qtpositioning -d qml-module-qtquick-controls -d qml-module-qtquick-dialogs -d qml-module-qtquick-extras -d qml-module-qtquick-layouts -d qml-module-qtquick-privatewidgets -d qml-module-qtquick-shapes -d qml-module-qtquick-window2 -d qml-module-qtquick2 -d qt5-gtk-platformtheme -d qt5-qmake -d qt5-qmake-bin -d qt5-qmltooling-plugins -d qtbase5-dev -d qtbase5-dev-tools -d qtchooser -d qtdeclarative5-dev -d qtdeclarative5-dev-tools -d qtpositioning5-dev -d qttranslations5-l10n" +PLATFORM_PACKAGES="-d qml-module-qtcharts -d gstreamer1.0-gl -d qtgstreamer-plugins-qt5 -d gstreamer1.0-qt5 -d libqt5texttospeech5-dev -d qml-module-qt-labs-platform -d git -d libgstreamer-plugins-base1.0-dev -d gstreamer1.0-plugins-good -d libavcodec-dev -d libavformat-dev -d qml-module-qtquick-controls2 -d libqt5concurrent5 -d libqt5core5a -d libqt5dbus5 -d libqt5gui5 -d libqt5help5 -d libqt5location5 -d libqt5location5-plugins -d libqt5multimedia5 -d libqt5multimedia5-plugins -d libqt5multimediagsttools5 -d libqt5multimediawidgets5 -d libqt5network5 -d libqt5opengl5 -d libqt5opengl5-dev -d libqt5positioning5 -d libqt5positioning5-plugins -d libqt5positioningquick5 -d libqt5printsupport5 -d libqt5qml5 -d libqt5quick5 -d libqt5quickparticles5 -d libqt5quickshapes5 -d libqt5quicktest5 -d libqt5quickwidgets5 -d libqt5sensors5 -d libqt5sql5 -d libqt5sql5-sqlite -d libqt5svg5 -d libqt5test5 -d libqt5webchannel5 -d libqt5webkit5 -d libqt5widgets5 -d libqt5x11extras5 -d libqt5xml5 -d openshot-qt -d python3-pyqt5 -d python3-pyqt5.qtopengl -d python3-pyqt5.qtsvg -d python3-pyqt5.qtwebkit -d python3-pyqtgraph -d qml-module-qt-labs-settings -d qml-module-qtgraphicaleffects -d qml-module-qtlocation -d qml-module-qtpositioning -d qml-module-qtquick-controls -d qml-module-qtquick-dialogs -d qml-module-qtquick-extras -d qml-module-qtquick-layouts -d qml-module-qtquick-privatewidgets -d qml-module-qtquick-shapes -d qml-module-qtquick-window2 -d qml-module-qtquick2 -d qt5-gtk-platformtheme -d qt5-qmake -d qt5-qmake-bin -d qt5-qmltooling-plugins -d qtbase5-dev -d qtbase5-dev-tools -d qtchooser -d qtdeclarative5-dev -d qtdeclarative5-dev-tools -d qtpositioning5-dev -d qttranslations5-l10n" fi cp release/QOpenHD /tmp/qopenhd/usr/local/bin/ || exit 1 # copying services if [[ "${PACKAGE_ARCH}" = "armhf" ]]; then +PACKAGE_NAME=qopenhd cp systemd/rpi_qopenhd.service /tmp/qopenhd/etc/systemd/system/qopenhd.service || exit 1 cp systemd/rpi_h264_decode.service /tmp/qopenhd/etc/systemd/system/h264_decode.service || exit 1 elif [[ "${PACKAGE_ARCH}" = "arm64" ]]; then -cp systemd/rock5_qopenhd.service /tmp/qopenhd/etc/systemd/system/qopenhd.service || exit 1 -cp systemd/rock5_h264_decode.service /tmp/qopenhd/etc/systemd/system/h264_decode.service || exit 1 -cp systemd/rock5_h265_decode.service /tmp/qopenhd/etc/systemd/system/h265_decode.service || exit 1 -cp systemd/rock5_mjpeg_decode.service /tmp/qopenhd/etc/systemd/system/mjpeg_decode.service || exit 1 +mkdir -p /tmp/qopenhd/etc/systemd/system/ +cp systemd/rock3_qopenhd.service /tmp/qopenhd/etc/systemd/system/qopenhd.service +cp systemd/rock3_h264_decode.service /tmp/qopenhd/etc/systemd/system/h264_decode.service +cp systemd/rock3_h265_decode.service /tmp/qopenhd/etc/systemd/system/h265_decode.service +PACKAGE_NAME=qopenhd_rk3566 else -echo "X86 doesn't autostart the services" +PACKAGE_NAME=qopenhd +echo "X86 doesn't work with services" fi # The qt_eglfs_kms_config.json file makes sure that qopenhd runs at the res @@ -82,12 +84,31 @@ elif [[ "${PACKAGE_ARCH}" = "arm64" ]]; then cp rock_qt_eglfs_kms_config.json /tmp/qopenhd/usr/local/share/qopenhd/ || exit 1 fi -VERSION="2.5.1-evo-alpha-$(date '+%Y%m%d%H%M')-${VER2}" +VERSION="2.5.3-$(date '+%Y%m%d%H%M')-${VER2}" rm ${PACKAGE_NAME}_${VERSION}_${PACKAGE_ARCH}.deb > /dev/null 2>&1 -ls -a - -fpm -a ${PACKAGE_ARCH} -s dir -t deb -n ${PACKAGE_NAME} -v ${VERSION} -C ${TMPDIR} \ - -p qopenhd_VERSION_ARCH.deb \ - --after-install after-install.sh \ - ${PLATFORM_PACKAGES} || exit 1 +if [[ "${PACKAGE_ARCH}" = "armhf" ]]; then + fpm -a ${PACKAGE_ARCH} -s dir -t deb -n ${PACKAGE_NAME} -v ${VERSION} -C ${TMPDIR} \ + -p qopenhd_VERSION_ARCH.deb \ + --after-install after-install.sh \ + ${PLATFORM_PACKAGES} || exit 1 +elif [[ "${PACKAGE_ARCH}" = "arm64" ]]; then + fpm -a ${PACKAGE_ARCH} -s dir -t deb -n qopenhd_rk3566 -v ${VERSION} -C ${TMPDIR} \ + -p qopenhd_rk3566_VERSION_ARCH.deb \ + --after-install after-install.sh \ + ${PLATFORM_PACKAGES} || exit 1 + #Rock5Package + + rm /tmp/qopenhd/etc/systemd/system/qopenhd.service + rm /tmp/qopenhd/etc/systemd/system/h264_decode.service + rm /tmp/qopenhd/etc/systemd/system/h265_decode.service + + cp systemd/rock5_qopenhd.service /tmp/qopenhd/etc/systemd/system/qopenhd.service + cp systemd/rock5_h264_decode.service /tmp/qopenhd/etc/systemd/system/h264_decode.service + cp systemd/rock5_h265_decode.service /tmp/qopenhd/etc/systemd/system/h265_decode.service + + fpm -a ${PACKAGE_ARCH} -s dir -t deb -n qopenhd_rk3588 -v ${VERSION} -C ${TMPDIR} \ + -p qopenhd_rk3588_VERSION_ARCH.deb \ + --after-install after-install.sh \ + ${PLATFORM_PACKAGES} || exit 1 +fi diff --git a/qml/ui/HUDOverlayGrid.qml b/qml/ui/HUDOverlayGrid.qml index feeda9815..638e92a5d 100644 --- a/qml/ui/HUDOverlayGrid.qml +++ b/qml/ui/HUDOverlayGrid.qml @@ -292,9 +292,6 @@ Item { LinkUpRSSIWidget { id: uplink } - Sidebar{ - id: sidebar - } // ---------------------------------------------------------------------------- // TODO SORT ME @@ -474,6 +471,10 @@ Item { UAVTimeWiget{ id: uavtimewidget } + + Sidebar{ + id: sidebar + } } // Extra element - allows customizing the OSD color(s) and more diff --git a/qml/ui/widgets/Sidebar.qml b/qml/ui/widgets/Sidebar.qml index ff757fab2..5d4e9d97c 100644 --- a/qml/ui/widgets/Sidebar.qml +++ b/qml/ui/widgets/Sidebar.qml @@ -13,25 +13,32 @@ import "../elements" BaseWidget { id: sidebar - y: (applicationWindow.height/2) - (googleUI.height/2) + width: 64 + height: 24 visible: settings.show_sidebar - widgetIdentifier: "sidebar" - bw_verbose_name: "SIDEBAR" + defaultVCenter: true + widgetIdentifier: "sidebar_widget" + bw_verbose_name: "Menu" + defaultHCenter: false + hasWidgetDetail: false + property int secondaryUiWidth: 335 - property int secondaryUiHeight: 335 + property int secondaryUiHeight: 375 property string secondaryUiColor: "#000" - property real secondaryUiOpacity: 0.85 - property int secondaryUizPos: 999 - - + property real secondaryUiOpacity: 0.75 + property string mainDarkColor: "#302f30" + property string highlightColor: "#555" + property int m_control_yaw : settings.control_widget_use_fc_channels ? _rcchannelsmodelfc.control_yaw : _rcchannelsmodelground.control_yaw + property int m_control_roll: settings.control_widget_use_fc_channels ? _rcchannelsmodelfc.control_roll : _rcchannelsmodelground.control_roll + property int m_control_pitch: settings.control_widget_use_fc_channels ? _rcchannelsmodelfc.control_pitch : _rcchannelsmodelground.control_pitch + property int m_control_throttle: settings.control_widget_use_fc_channels ? _rcchannelsmodelfc.control_throttle : _rcchannelsmodelground.control_throttle property int selectedItemIndex: -1 ColumnLayout { id: uiButton width: 32 height: 32 - y: (googleUI.height/2)-(uiButton.height/2) - z: 99 + anchors.verticalCenter: parent.verticalCenter MouseArea { id: mouseArea1 @@ -42,13 +49,12 @@ BaseWidget { googleUI.visible = true linkUI.visible = true uiButton.visible = false - // Perform button action here or emit a signal } Rectangle { width: parent.width height: parent.height - color: "transparent" // Transparent background + color: "transparent" RowLayout { width: parent.width @@ -70,6 +76,8 @@ BaseWidget { ColumnLayout { spacing: 10 visible: true + anchors.verticalCenter: parent.verticalCenter + RowLayout { @@ -78,20 +86,25 @@ BaseWidget { Rectangle { id: googleUI - width: 32 - height: 335 - color: "#302f30" + width: secondaryUiHeight / 8 //number of items + height: secondaryUiHeight + color: highlightColor opacity: 0.7 visible: false - z: 99 + + // Add a property to track the selected item index + property int selectedItemIndex: 0 ListView { width: parent.width height: parent.height focus: true - //snapMode: ListView.SnapOneItem + keyNavigationEnabled: true + interactive: false + model: ListModel { ListElement { text: " \uf1eb"; subText: "link" } + ListElement { text: " \uf11b"; subText: "rc" } ListElement { text: " \uf03d"; subText: "video" } ListElement { text: " \uf030"; subText: "camera" } ListElement { text: " \uf0c7"; subText: "recording" } @@ -102,13 +115,15 @@ BaseWidget { delegate: Item { width: parent.width - height: 48 + height: secondaryUiHeight / 8 //number of items MouseArea { id: mouseArea anchors.fill: parent onClicked: { + // Update the selected item index + googleUI.selectedItemIndex = index; function hideElements() { linkUI.visible = false; @@ -117,45 +132,43 @@ BaseWidget { recordingUI.visible = false; displayUI.visible = false; miscUI.visible = false; + rcUI.visible = false; } - sidebar.selectedItemIndex = index; console.log("Item clicked: " + model.subText) var uiElementName = model.subText + "UI"; - if (model.subText==="back"){ - googleUI.visible=false - uiButton.visible=true + if (model.subText === "back") { + googleUI.visible = false; + uiButton.visible = true; hideElements(); - } - else if (model.subText==="link"){ + } else if (model.subText === "link") { hideElements(); linkUI.visible = true; - } - else if (model.subText==="video"){ + } else if (model.subText === "rc") { + hideElements(); + rcUI.visible = true; + } else if (model.subText === "video") { hideElements(); videoUI.visible = true; - } - else if (model.subText==="camera"){ + } else if (model.subText === "camera") { hideElements(); cameraUI.visible = true; - } - else if (model.subText==="recording"){ + } else if (model.subText === "recording") { hideElements(); recordingUI.visible = true; - } - else if (model.subText==="display"){ + } else if (model.subText === "display") { hideElements(); displayUI.visible = true; - } - else if (model.subText==="drone"){ + } else if (model.subText === "drone") { hideElements(); miscUI.visible = true; } } + Rectangle { width: parent.width height: parent.height - color: index === sidebar.selectedItemIndex ? "#555" : "#302f30" + color: index === googleUI.selectedItemIndex ? highlightColor : mainDarkColor } RowLayout { @@ -164,15 +177,17 @@ BaseWidget { Text { text: model.text - font.pixelSize: 16 + font.pixelSize: secondaryUiHeight / 16 opacity: 1.0 font.family: "Font Awesome 5 Free" color: "white" + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter } Text { text: model.subText visible: false - font.pixelSize: 16 + font.pixelSize: secondaryUiHeight / 16 opacity: 1.0 color: "white" horizontalAlignment: Text.AlignHCenter @@ -194,8 +209,25 @@ BaseWidget { color: secondaryUiColor opacity: secondaryUiOpacity visible: false - z: secondaryUizPos + Rectangle { + id: linkUiHeader + width: secondaryUiWidth + height: secondaryUiHeight/8 + color: highlightColor + opacity: 1.0 + + Text { + anchors.centerIn: parent + text: "LINK" + font.pixelSize: 21 + font.family: "AvantGarde-Medium" + color: "#ffffff" + smooth: true + } + } Item { + anchors.top: parent.top + anchors.topMargin: linkUiHeader.height/2 width: parent.width height: parent.height @@ -204,7 +236,7 @@ BaseWidget { spacing: 5 Text{ - text: "Resilliancy -> Quality" + text: "Range -> Quality" + " (MCS" + _ohdSystemAir.curr_mcs_index + ")" font.pixelSize: 14 font.family: "AvantGarde-Medium" color: "#ffffff" @@ -224,7 +256,7 @@ BaseWidget { } } Text{ - text: "Frequency" + text: "Frequency" + " (" + _ohdSystemGround.curr_channel_mhz + ")" font.pixelSize: 14 font.family: "AvantGarde-Medium" color: "#ffffff" @@ -235,24 +267,24 @@ BaseWidget { model: [ "2312", "2332", "2352", "2372", "2392", "2412", "2432", "2452", "2472", "2492", "2512", "2532", "2572", "2592", "2612", "2632", "2652", "2672", "2692", "2712", "5180", "5200", "5220", "5240", "5260", "5280", "5300", "5320", "5500", "5520", "5540", "5560", "5580", "5600", "5620", "5640", "5660", "5680", "5700", "5745", "5765", "5785", "5805", "5825", "5845", "5865", "5885" ] } Text{ - text: "TX Power" - font.pixelSize: 14 - font.family: "AvantGarde-Medium" - color: "#ffffff" - smooth: true + text: "TX Power Air" + " (" + "TODO" + ")" + font.pixelSize: 14 + font.family: "AvantGarde-Medium" + color: "#ffffff" + smooth: true + } + Slider { + id: txPowerAirSlider + from: 22 + to: 58 + stepSize: 4 + //snapMode: Slider.SnapToStep + value: 22 // Initial value + Material.accent: Material.Grey + onValueChanged: { + // Handle the slider value change here + console.log("TX Power Air Slider:", value) } - Slider { - id: txPowerSlider - from: 22 - to: 58 - stepSize: 4 - //snapMode: Slider.SnapToStep - value: 22 // Initial value - Material.accent: Material.Grey - onValueChanged: { - // Handle the slider value change here - console.log("TX Power Slider:", value) - } } Text{ text: "Bandwith" @@ -279,6 +311,142 @@ BaseWidget { } } } + Rectangle { + id: linkUiFooter + anchors.top: parent.top + anchors.topMargin: secondaryUiHeight-saveText.height-10 + anchors.left: parent.left + anchors.leftMargin: secondaryUiWidth-saveText.width-10 + + + Text { + id: saveText + text: "\uf019" + font.pixelSize: 21 + font.family: "AvantGarde-Medium" + color: "#ffffff" + smooth: true + } + } + } + Rectangle { + id: rcUI + width: secondaryUiWidth + height: secondaryUiHeight + color: secondaryUiColor + opacity: secondaryUiOpacity + visible: false + Rectangle { + id: rcUiHeader + width: secondaryUiWidth + height: secondaryUiHeight/8 + color: highlightColor + opacity: 1.0 + + Text { + anchors.centerIn: parent + text: "OpenHD-RC" + font.pixelSize: 21 + font.family: "AvantGarde-Medium" + color: "#ffffff" + smooth: true + } + } + Item { + anchors.top: parent.top + anchors.topMargin: rcUiHeader.height/2 + width: parent.width + height: parent.height + + Column { + anchors.centerIn: parent + spacing: 5 + + Text{ + text: "Enable RC" + font.pixelSize: 14 + font.family: "AvantGarde-Medium" + color: "#ffffff" + smooth: true + } + Switch { + text: qsTr("") + } + Text{ + text: "Channel 1" + font.pixelSize: 14 + font.family: "AvantGarde-Medium" + color: "#ffffff" + smooth: true + } + ProgressBar { + id: progressBar1 + from: 1000 + to: 2000 + value: m_control_yaw + Material.accent: Material.Grey + } + Text{ + text: "Channel 2" + font.pixelSize: 14 + font.family: "AvantGarde-Medium" + color: "#ffffff" + smooth: true + } + ProgressBar { + id: progressBar2 + from: 1000 + to: 2000 + value: m_control_yaw + Material.accent: Material.Grey + } + Text{ + text: "Channel 3" + font.pixelSize: 14 + font.family: "AvantGarde-Medium" + color: "#ffffff" + smooth: true + } + ProgressBar { + id: progressBar3 + from: 1000 + to: 2000 + value: m_control_yaw + Material.accent: Material.Grey + } + Text{ + text: "Channel 4" + font.pixelSize: 14 + font.family: "AvantGarde-Medium" + color: "#ffffff" + smooth: true + } + ProgressBar { + id: progressBar4 + from: 1000 + to: 2000 + value: m_control_yaw + Material.accent: Material.Grey + } + } + } + Rectangle { + id: rcUiFooter + anchors.top: parent.top + anchors.topMargin: secondaryUiHeight-saveTextRC.height-10 + anchors.left: parent.left + anchors.leftMargin: secondaryUiWidth-saveTextRC.width-10 + + + Text { + id: saveTextRC + text: "\uf019" + font.pixelSize: 21 + font.family: "AvantGarde-Medium" + color: "#ffffff" + smooth: true + } + } } Rectangle { id: videoUI @@ -287,8 +455,25 @@ BaseWidget { color: secondaryUiColor opacity: secondaryUiOpacity visible: false - z: secondaryUizPos + Rectangle { + id: videoUiHeader + width: secondaryUiWidth + height: secondaryUiHeight/8 + color: highlightColor + opacity: 1.0 + + Text { + anchors.centerIn: parent + text: "Video" + font.pixelSize: 21 + font.family: "AvantGarde-Medium" + color: "#ffffff" + smooth: true + } + } Item { + anchors.top: parent.top + anchors.topMargin: videoUiHeader.height/2 width: parent.width height: parent.height @@ -297,26 +482,26 @@ BaseWidget { spacing: 5 ComboBox { - id:raspberryCams + id:raspberryCams3 visible: true width: 200 model: [ "IMX708","IMX462","IMX477" ] } ComboBox { - id:rock5Cams + id:rock5Cams3 visible: false width: 200 model: [ "IMX415","IMX462","IMX708" ] } Text{ - text: "Resolution 480p -> 1080p" + text: "Camera Mode"+ " (" + "1080p,60fps" + ")" font.pixelSize: 14 font.family: "AvantGarde-Medium" color: "#ffffff" smooth: true } Slider { - id: resolutionSlider + id: resolutionSlider3 from: 0 to: 2 stepSize: 1 @@ -328,45 +513,49 @@ BaseWidget { } } Text{ - text: "Framerate 30 -> 60" + text: "Switch Cameras" font.pixelSize: 14 font.family: "AvantGarde-Medium" color: "#ffffff" smooth: true } - Slider { - id: framerateSlider - from: 0 - to: 2 - stepSize: 1 - //snapMode: Slider.SnapToStep - value: 0 // Initial value - Material.accent: Material.Grey - onValueChanged: { - console.log("Framerate Slider:", value) - } - } - Text{ - text: "Bitrate" - font.pixelSize: 14 - font.family: "AvantGarde-Medium" - color: "#ffffff" - smooth: true + Switch { } - Slider { - id: bitrateSlider - from: 2 - to: 18 - stepSize: 2 - //snapMode: Slider.SnapToStep - value: 8 // Initial value - Material.accent: Material.Grey - onValueChanged: { - console.log("Birtate Slider:", value) + TabBar { + id: cameraSwitch + Material.accent: "#fff" + Material.foreground: "white" + background: Rectangle { + implicitWidth: 100 + implicitHeight: 40 + color: secondaryUiColor + } + TabButton { + text: qsTr("Cam1") + } + TabButton { + text: qsTr("Cam2") } } } } + Rectangle { + id: videoUiFooter + anchors.top: parent.top + anchors.topMargin: secondaryUiHeight-saveTextVid.height-10 + anchors.left: parent.left + anchors.leftMargin: secondaryUiWidth-saveTextVid.width-10 + + + Text { + id: saveTextVid + text: "\uf019" + font.pixelSize: 21 + font.family: "AvantGarde-Medium" + color: "#ffffff" + smooth: true + } + } } Rectangle { id: cameraUI @@ -375,9 +564,25 @@ BaseWidget { color: secondaryUiColor opacity: secondaryUiOpacity visible: false - z: secondaryUizPos + Rectangle { + id: cameraUiHeader + width: secondaryUiWidth + height: secondaryUiHeight/8 + color: highlightColor + opacity: 1.0 + Text { + anchors.centerIn: parent + text: "Camera" + font.pixelSize: 21 + font.family: "AvantGarde-Medium" + color: "#ffffff" + smooth: true + } + } Item { + anchors.top: parent.top + anchors.topMargin: cameraUiHeader.height/2 width: parent.width height: parent.height @@ -443,6 +648,23 @@ BaseWidget { } } } + Rectangle { + id: camUiFooter + anchors.top: parent.top + anchors.topMargin: secondaryUiHeight-saveTextCam.height-10 + anchors.left: parent.left + anchors.leftMargin: secondaryUiWidth-saveTextCam.width-10 + + + Text { + id: saveTextCam + text: "\uf019" + font.pixelSize: 21 + font.family: "AvantGarde-Medium" + color: "#ffffff" + smooth: true + } + } } Rectangle { id: recordingUI @@ -451,9 +673,25 @@ BaseWidget { color: secondaryUiColor opacity: secondaryUiOpacity visible: false - z: secondaryUizPos + Rectangle { + id: recordingUiHeader + width: secondaryUiWidth + height: secondaryUiHeight/8 + color: highlightColor + opacity: 1.0 + Text { + anchors.centerIn: parent + text: "Recording" + font.pixelSize: 21 + font.family: "AvantGarde-Medium" + color: "#ffffff" + smooth: true + } + } Item { + anchors.top: parent.top + anchors.topMargin: recordingUiHeader.height/2 width: parent.width height: parent.height @@ -525,11 +763,26 @@ BaseWidget { smooth: true } Switch { - text: qsTr("Enable Recording") } } } + Rectangle { + id: recUiFooter + anchors.top: parent.top + anchors.topMargin: secondaryUiHeight-saveTextRec.height-10 + anchors.left: parent.left + anchors.leftMargin: secondaryUiWidth-saveTextRec.width-10 + + Text { + id: saveTextRec + text: "\uf019" + font.pixelSize: 21 + font.family: "AvantGarde-Medium" + color: "#ffffff" + smooth: true + } + } } Rectangle { id: displayUI @@ -538,9 +791,25 @@ BaseWidget { color: secondaryUiColor opacity: secondaryUiOpacity visible: false - z: secondaryUizPos + Rectangle { + id: displayUiHeader + width: secondaryUiWidth + height: secondaryUiHeight/8 + color: highlightColor + opacity: 1.0 + Text { + anchors.centerIn: parent + text: "Misc" + font.pixelSize: 21 + font.family: "AvantGarde-Medium" + color: "#ffffff" + smooth: true + } + } Item { + anchors.top: parent.top + anchors.topMargin: displayUiHeader.height/2 width: parent.width height: parent.height @@ -595,8 +864,23 @@ BaseWidget { } } } + Rectangle { + id: miscUiFooter + anchors.top: parent.top + anchors.topMargin: secondaryUiHeight-saveTextMisc.height-10 + anchors.left: parent.left + anchors.leftMargin: secondaryUiWidth-saveTextMisc.width-10 + Text { + id: saveTextMisc + text: "\uf019" + font.pixelSize: 21 + font.family: "AvantGarde-Medium" + color: "#ffffff" + smooth: true + } + } } Rectangle { id: miscUI @@ -605,9 +889,25 @@ BaseWidget { color: secondaryUiColor opacity: secondaryUiOpacity visible: false - z: secondaryUizPos + Rectangle { + id: miscUiHeader + width: secondaryUiWidth + height: secondaryUiHeight/8 + color: highlightColor + opacity: 1.0 + Text { + anchors.centerIn: parent + text: "Status " + font.pixelSize: 21 + font.family: "AvantGarde-Medium" + color: "#ffffff" + smooth: true + } + } Item { + anchors.top: parent.top + anchors.topMargin: miscUiHeader.height/2 width: parent.width height: parent.height @@ -636,7 +936,7 @@ BaseWidget { } RowLayout { Text { - text: "Frequency:" + text: "Screen:" font.pixelSize: 14 font.bold: true font.family: "AvantGarde-Medium" @@ -645,7 +945,7 @@ BaseWidget { } Text { - text: "5801" + text: applicationWindow.width + "x" + applicationWindow.height font.pixelSize: 14 font.family: "AvantGarde-Medium" color: "#ffffff" @@ -653,9 +953,10 @@ BaseWidget { } } + RowLayout { Text { - text: "Format:" + text: "Frequency:" font.pixelSize: 14 font.bold: true font.family: "AvantGarde-Medium" @@ -664,7 +965,7 @@ BaseWidget { } Text { - text: "1080p 60fps" + text: _ohdSystemGround.curr_channel_mhz + "Mhz" font.pixelSize: 14 font.family: "AvantGarde-Medium" color: "#ffffff" @@ -674,7 +975,7 @@ BaseWidget { } RowLayout { Text { - text: "Version:" + text: "Wifi-Adapter:" font.pixelSize: 14 font.bold: true font.family: "AvantGarde-Medium" @@ -683,7 +984,34 @@ BaseWidget { } Text { - text: "OpenHD 2.5 evo" + id: wifiMessage + property int wifiCode: _ohdSystemAir.ohd_wifi_type + + function wifiName(code) { + switch (code) { + case 11: return "Asus AC56"; + case 12: return "8812AU CUSTOM"; + case 21: return "88XXBU"; + default: return "unknown"; + } + } + + text: wifiName(wifiCode) + "("+_ohdSystemAir.ohd_wifi_type+")" + Layout.leftMargin: 12 + } + } + RowLayout { + Text { + text: "Format:" + font.pixelSize: 14 + font.bold: true + font.family: "AvantGarde-Medium" + color: "#ffffff" + smooth: true + } + + Text { + text: "1080p 60fps" font.pixelSize: 14 font.family: "AvantGarde-Medium" color: "#ffffff" @@ -693,7 +1021,7 @@ BaseWidget { } RowLayout { Text { - text: "Hardware Ground:" + text: "Version:" font.pixelSize: 14 font.bold: true font.family: "AvantGarde-Medium" @@ -702,7 +1030,7 @@ BaseWidget { } Text { - text: "X86" + text: "OpenHD 2.5 evo" font.pixelSize: 14 font.family: "AvantGarde-Medium" color: "#ffffff" @@ -720,6 +1048,43 @@ BaseWidget { smooth: true } + Text { + id: platformMessage + property int platformCode: _ohdSystemAir.ohd_platform_type + + function platformName(code) { + switch (code) { + case 0: return "unknown"; + case 10: return "X20"; + case 20: return "x86"; + case 30: return "rpi"; + case 31: return "rpi 4"; + case 32: return "rpi 3"; + case 33: return "rpi 2"; + case 34: return "rpi 1"; + case 35: return "rpi 0"; + case 40: return "rock"; + case 41: return "rk3566"; + case 42: return "rock5a"; + case 43: return "rock5b"; + default: return "unknown"; + } + } + + text: platformName(platformCode) + "("+_ohdSystemAir.ohd_platform_type+")" + Layout.leftMargin: 12 + } + } + RowLayout { + Text { + text: "Hardware Ground:" + font.pixelSize: 14 + font.bold: true + font.family: "AvantGarde-Medium" + color: "#ffffff" + smooth: true + } + Text { text: "Core3566" font.pixelSize: 14 @@ -733,7 +1098,11 @@ BaseWidget { Button { id: button text: "Advanced Menu" + + onClicked: { + settings_panel.visible = true } + } } } } diff --git a/systemd/rock3_h264_decode.service b/systemd/rock3_h264_decode.service index 4e6076330..150be5c3a 100644 --- a/systemd/rock3_h264_decode.service +++ b/systemd/rock3_h264_decode.service @@ -5,8 +5,7 @@ Description=rock_h264_decode User=root # Video decode via mpp, started by QOpenHD if needed (and stopped if needed) -ExecStart=/bin/sh -c "gst-launch-1.0 udpsrc port=5600 caps='application/x-rtp, payload=(int)96, clock-rate=(int)90000, media=(string)video, encoding-name=(string)H264' ! rtph264depay ! h264parse ! mppvideodec format=23 fast-mode=true ! queue ! kmssink plane-id=54 force-modesetting=true" - +ExecStart=/bin/sh -c "gst-launch-1.0 udpsrc port=5600 caps='application/x-rtp, payload=(int)96, clock-rate=(int)90000, media=(string)video, encoding-name=(string)H264' ! rtph264depay ! h264parse ! mppvideodec format=23 fast-mode=true ! queue ! kmssink plane-id=54 force-modesetting=false" Restart=always RestartSec=2 diff --git a/systemd/rock3_h265_decode.service b/systemd/rock3_h265_decode.service index e84d50b9e..51a1f50f4 100644 --- a/systemd/rock3_h265_decode.service +++ b/systemd/rock3_h265_decode.service @@ -5,7 +5,7 @@ Description=rock_h265_decode User=root # Video decode via mpp, started by QOpenHD if needed (and stopped if needed) -ExecStart=/bin/sh -c "gst-launch-1.0 udpsrc port=5600 caps='application/x-rtp, payload=(int)96, clock-rate=(int)90000, media=(string)video, encoding-name=(string)H265' ! rtph265depay ! h265parse ! mppvideodec format=23 fast-mode=true ! queue ! kmssink plane-id=54 force-modesetting=true" +ExecStart=/bin/sh -c "gst-launch-1.0 udpsrc port=5600 caps='application/x-rtp, payload=(int)96, clock-rate=(int)90000, media=(string)video, encoding-name=(string)H265' ! rtph265depay ! h265parse ! mppvideodec format=23 fast-mode=true ! queue ! kmssink plane-id=54 force-modesetting=false" Restart=always RestartSec=1 diff --git a/systemd/rock3_mjpeg_decode.service b/systemd/rock3_mjpeg_decode.service index e35c317ef..a281d9362 100644 --- a/systemd/rock3_mjpeg_decode.service +++ b/systemd/rock3_mjpeg_decode.service @@ -5,7 +5,7 @@ Description=rock_mjpeg_decode User=root # Video decode via mpp, started by QOpenHD if needed (and stopped if needed) -ExecStart=/bin/sh -c "gst-launch-1.0 udpsrc port=5600 caps='application/x-rtp, payload=(int)26, clock-rate=(int)90000, media=(string)video, encoding-name=(string)JPEG' ! rtpjpegdepay ! jpegdec ! queue ! kmssink plane-id=54 force-modesetting=true" +ExecStart=/bin/sh -c "gst-launch-1.0 udpsrc port=5600 caps='application/x-rtp, payload=(int)26, clock-rate=(int)90000, media=(string)video, encoding-name=(string)JPEG' ! rtpjpegdepay ! jpegdec ! queue ! kmssink plane-id=54 force-modesetting=false" Restart=always RestartSec=1 diff --git a/systemd/rock3_qopenhd.service b/systemd/rock3_qopenhd.service index d8bfe7c9a..d8c02bd16 100644 --- a/systemd/rock3_qopenhd.service +++ b/systemd/rock3_qopenhd.service @@ -9,6 +9,7 @@ Environment="QT_LOGGING_RULES=qt.qpa.egl*=true" Environment="QT_QPA_EGLFS_KMS_PLANE_INDEX=1" Environment="QT_QPA_EGLFS_FORCE888=1" Environment="QT_QPA_EGLFS_SWAPINTERVAL=0" +Environment="QT_QPA_EGLFS_ALWAYS_SET_MODE=true" Environment="QT_QPA_EGLFS_KMS_CONFIG=/usr/local/share/qopenhd/rock_qt_eglfs_kms_config.json" ExecStart=/usr/local/bin/QOpenHD -platform eglfs User=root From f23a24a6ddf287ded666a77e0603bf740bacb494 Mon Sep 17 00:00:00 2001 From: Raphael <68374617+raphaelscholle@users.noreply.github.com> Date: Mon, 20 Nov 2023 20:01:54 +0100 Subject: [PATCH 71/81] add sidebar stuff --- app/telemetry/models/aohdsystem.h | 4 ++++ qml/ui/widgets/Sidebar.qml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/telemetry/models/aohdsystem.h b/app/telemetry/models/aohdsystem.h index e132c687f..6be2553e0 100644 --- a/app/telemetry/models/aohdsystem.h +++ b/app/telemetry/models/aohdsystem.h @@ -63,6 +63,10 @@ class AOHDSystem : public QObject L_RO_PROP(int,curr_space_left_mb,set_curr_space_left_mb,0) L_RO_PROP(int,ram_usage_perc,set_ram_usage_perc,0) L_RO_PROP(int,ram_total,set_ram_total,0) + L_RO_PROP(int,ohd_platform_type,set_ohd_platform,0) + L_RO_PROP(int,ohd_wifi_type,set_ohd_wifi,0) + L_RO_PROP(int,ohd_cam_type,set_ohd_cam,0) + L_RO_PROP(int,ohd_sys_type,set_ohd_sys_ident,0) // RPI only L_RO_PROP(bool,rpi_undervolt_error,set_rpi_undervolt_error,false) // needs ina219 sensor diff --git a/qml/ui/widgets/Sidebar.qml b/qml/ui/widgets/Sidebar.qml index 5d4e9d97c..fa46a00f7 100644 --- a/qml/ui/widgets/Sidebar.qml +++ b/qml/ui/widgets/Sidebar.qml @@ -1030,7 +1030,7 @@ BaseWidget { } Text { - text: "OpenHD 2.5 evo" + text: "Todo" font.pixelSize: 14 font.family: "AvantGarde-Medium" color: "#ffffff" @@ -1086,7 +1086,7 @@ BaseWidget { } Text { - text: "Core3566" + text: "Todo" font.pixelSize: 14 font.family: "AvantGarde-Medium" color: "#ffffff" From d1bba54d774f688e2b7b6d6ff9aee7a442adc655 Mon Sep 17 00:00:00 2001 From: consti10 Date: Tue, 21 Nov 2023 12:20:41 +0100 Subject: [PATCH 72/81] remove spammy log --- app/videostreaming/avcodec/texturerenderer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/videostreaming/avcodec/texturerenderer.cpp b/app/videostreaming/avcodec/texturerenderer.cpp index 980d93cd7..398f3ec8d 100644 --- a/app/videostreaming/avcodec/texturerenderer.cpp +++ b/app/videostreaming/avcodec/texturerenderer.cpp @@ -103,7 +103,8 @@ int TextureRenderer::queue_new_frame_for_display(AVFrame *src_frame) //std::cout<<"DRMPrimeOut::drmprime_out_display "<width<<"x"<height<<"\n"; if ((src_frame->flags & AV_FRAME_FLAG_CORRUPT) != 0) { //fprintf(stderr, "Discard corrupt frame: fmt=%d, ts=%" PRId64 "\n", src_frame->format, src_frame->pts); - qDebug()<<"Frame corrupt, but forwarding anyways"; + // log removed, can also appear on non corrupted frames + //qDebug()<<"Frame corrupt, but forwarding anyways"; //return 0; } latest_frame_mutex.lock(); From 7b45bba520ccedabcea4017f4573f86f9187637d Mon Sep 17 00:00:00 2001 From: consti10 Date: Tue, 21 Nov 2023 12:27:04 +0100 Subject: [PATCH 73/81] remove spammy log --- app/telemetry/connection/tcp_connection.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/telemetry/connection/tcp_connection.cpp b/app/telemetry/connection/tcp_connection.cpp index 635024e48..68c76c419 100644 --- a/app/telemetry/connection/tcp_connection.cpp +++ b/app/telemetry/connection/tcp_connection.cpp @@ -16,7 +16,7 @@ #include static int linux_tcp_socket_try_connect(const std::string remote_ip, const int remote_port,const int timeout_seconds){ - qDebug()<<"linux_tcp_socket_try_connect:"< Date: Tue, 21 Nov 2023 16:36:53 +0100 Subject: [PATCH 74/81] add 640x480@30 since it is the default res for a lot of usb cameras --- qml/ui/widgets/VideoBitrateWidgetGeneric.qml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qml/ui/widgets/VideoBitrateWidgetGeneric.qml b/qml/ui/widgets/VideoBitrateWidgetGeneric.qml index dc451e5ba..897b36905 100644 --- a/qml/ui/widgets/VideoBitrateWidgetGeneric.qml +++ b/qml/ui/widgets/VideoBitrateWidgetGeneric.qml @@ -110,6 +110,7 @@ BaseWidget { ListModel{ id: resolutions_model + ListElement {title: "480p@30fps (4:3)"; value: "640x480@30"} ListElement {title: "480p@60fps (4:3)"; value: "640x480@60"} ListElement {title: "480p@60fps (16:9)"; value: "848x480@60"} ListElement {title: "720p@49fps (16:9)"; value: "1280x720@49"} @@ -207,7 +208,7 @@ BaseWidget { const resolution=model.get(currentIndex).value console.log("Selected resolution: "+resolution); set_camera_resolution(resolution); - _qopenhd.toast_text("NOTE: OpenHD cannot check if your HW actually supports a given resolution at full frame rate"); + _qopenhd.show_toast("NOTE: OpenHD cannot check if your HW actually supports a given resolution / framerate"); } enabled: _ohdSystemAir.is_alive; } From 583e30ab492b63d7626d3924dab3d5e3ee5c647f Mon Sep 17 00:00:00 2001 From: consti10 Date: Tue, 21 Nov 2023 16:37:06 +0100 Subject: [PATCH 75/81] persist connection mode --- qml/ui/configpopup/connect/PaneConnectionMode.qml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/qml/ui/configpopup/connect/PaneConnectionMode.qml b/qml/ui/configpopup/connect/PaneConnectionMode.qml index efccc7b05..0d4920b92 100644 --- a/qml/ui/configpopup/connect/PaneConnectionMode.qml +++ b/qml/ui/configpopup/connect/PaneConnectionMode.qml @@ -76,9 +76,12 @@ Rectangle{ ListElement { text: "MANUAL UDP" } ListElement { text: "MANUAL TCP" } } - onCurrentIndexChanged: { + onActivated: { if(currentIndex==0 || currentIndex==1 || currentIndex==2){ - _mavlinkTelemetry.change_telemetry_connection_mode(currentIndex); + if(settings.qopenhd_mavlink_connection_mode!=currentIndex){ + _mavlinkTelemetry.change_telemetry_connection_mode(currentIndex); + settings.qopenhd_mavlink_connection_mode=currentIndex; + } } } currentIndex: settings.qopenhd_mavlink_connection_mode From 266ba4b91b65197a1ed35adc323adba9409cd2d5 Mon Sep 17 00:00:00 2001 From: consti10 Date: Tue, 21 Nov 2023 16:52:52 +0100 Subject: [PATCH 76/81] rpi - default to screen scale 0.7 --- app/main.cpp | 9 ++++++++- app/util/qopenhd.cpp | 9 +++++++++ app/util/qopenhd.h | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/main.cpp b/app/main.cpp index 19ab95b9e..ae7f34f9f 100755 --- a/app/main.cpp +++ b/app/main.cpp @@ -204,7 +204,14 @@ int main(int argc, char *argv[]) { QSettings settings; qDebug()<<"Storing settings at ["< Date: Tue, 21 Nov 2023 16:53:05 +0100 Subject: [PATCH 77/81] disable when not usable --- qml/ui/configpopup/openhd_settings/LinkQuickPanel.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/qml/ui/configpopup/openhd_settings/LinkQuickPanel.qml b/qml/ui/configpopup/openhd_settings/LinkQuickPanel.qml index da9f5ff7e..1d0319516 100644 --- a/qml/ui/configpopup/openhd_settings/LinkQuickPanel.qml +++ b/qml/ui/configpopup/openhd_settings/LinkQuickPanel.qml @@ -230,6 +230,7 @@ Rectangle{ TabButton{ text: "5.8G" } + enabled: comboBoxFreq.enabled } Item{ // FILLER Layout.fillWidth: true From aaba432a654760e9a01b4b58022c1ad01c8fad5d Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 21 Nov 2023 19:35:42 +0100 Subject: [PATCH 78/81] color and layout changes for the next release --- .../openhd_settings/LinkQuickPanel.qml | 15 +-- .../openhd_settings/PopupScanChannels.qml | 92 +++++++++++-------- qml/ui/configpopup/status/PanelStatus.qml | 2 +- qml/ui/configpopup/status/StatusCardRow.qml | 8 ++ qml/ui/elements/Card.qml | 2 +- qml/ui/elements/SimpleProgressBar.qml | 2 +- 6 files changed, 72 insertions(+), 49 deletions(-) diff --git a/qml/ui/configpopup/openhd_settings/LinkQuickPanel.qml b/qml/ui/configpopup/openhd_settings/LinkQuickPanel.qml index da9f5ff7e..088d98bcc 100644 --- a/qml/ui/configpopup/openhd_settings/LinkQuickPanel.qml +++ b/qml/ui/configpopup/openhd_settings/LinkQuickPanel.qml @@ -236,6 +236,7 @@ Rectangle{ } ButtonIconInfo2{ Layout.alignment: Qt.AlignRight + visible:false onClicked: { var text="Please select a channel / frequency free of noise and interference. The current loss / pollution / throttle stats below can help,"+ "as well as the analyze channels feature or a frequency analyzer on your phone. DEF: Show OpenHD standard channels [1-5] only - they "+ @@ -317,7 +318,7 @@ Rectangle{ color: _ohdSystemGround.curr_rx_packet_loss_perc > 5 ? "red" : "black" verticalAlignment: Qt.AlignVCenter horizontalAlignment: Qt.AlignHCenter - font.bold: true + font.bold: false } Text{ Layout.preferredHeight: 50 @@ -328,7 +329,7 @@ Rectangle{ color: _ohdSystemGround.wb_link_curr_foreign_pps > 20 ? "red" : "black" verticalAlignment: Qt.AlignVCenter horizontalAlignment: Qt.AlignHCenter - font.bold: true + font.bold: false } Text{ Layout.preferredHeight: 50 @@ -347,7 +348,7 @@ Rectangle{ color: _ohdSystemAir.curr_n_rate_adjustments > 0 ? "red" : "black" verticalAlignment: Qt.AlignVCenter horizontalAlignment: Qt.AlignHCenter - font.bold: true + font.bold: false } Item{ // FILLER Layout.fillWidth: true @@ -386,7 +387,7 @@ Rectangle{ text: "AIR:\n "+get_text_wifi_tx_power(true) verticalAlignment: Qt.AlignVCenter horizontalAlignment: Qt.AlignHCenter - font.bold: true + font.bold: false } Button{ text: "EDIT" @@ -402,7 +403,7 @@ Rectangle{ text: "GND:\n"+get_text_wifi_tx_power(false) verticalAlignment: Qt.AlignVCenter horizontalAlignment: Qt.AlignHCenter - font.bold: true + font.bold: false } Button{ text: "EDIT" @@ -434,14 +435,14 @@ Rectangle{ text: "AIR:\n"+get_text_stbc_ldpc(true); verticalAlignment: Qt.AlignVCenter horizontalAlignment: Qt.AlignHCenter - font.bold: true + font.bold: false } Text{ Layout.preferredWidth: 120 text: "GND:\n"+get_text_stbc_ldpc(false); verticalAlignment: Qt.AlignVCenter horizontalAlignment: Qt.AlignHCenter - font.bold: true + font.bold: false } Button{ text: "EDIT"; diff --git a/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml b/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml index 3b4879578..4e9be56ce 100644 --- a/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml +++ b/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml @@ -17,12 +17,10 @@ import "../../elements" Rectangle{ //width: parent.width-12 //height: parent.height*2/3; - width: parent.width - height: parent.height + width: parent.width - 20 + height: parent.height -20 anchors.centerIn: parent - color: "#ADD8E6" - border.color: "black" - border.width: 3 + color: "#333c4c" function open(){ visible=true @@ -42,40 +40,56 @@ Rectangle{ } ColumnLayout{ + id:channelScanLayout anchors.fill: parent anchors.leftMargin: 10 anchors.rightMargin: 10 - Item{ - Layout.fillWidth: true - Layout.preferredHeight: 80 - Text{ // TITLE - anchors.fill: parent - text: "SCAN (FIND AIR UNIT)"; - verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignHCenter - font.bold: true - } - Button{ - anchors.right: parent.right - anchors.top: parent.top - text: "CLOSE" + BaseHeaderItem{ + m_text: "Find Air Unit" + } + + Item { + id:closeButtonWrapper + Layout.alignment: Qt.AlignTop | Qt.AlignRight + Layout.rightMargin: closeButton.width-channelScanLayout.anchors.rightMargin + Layout.topMargin: (closeButtonWrapper.height-closeButton.height)-1 + + Button { + id:closeButton + text: "X" + height:42 + width:42 + background: Rectangle { + Layout.fillHeight: parent + Layout.fillWidth: parent + color: closeButton.hovered ? "darkgrey" : "lightgrey" + } onClicked: { - if(_ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==1){ - _qopenhd.show_toast("STILL SCANNING,PLEASE WAIT ..."); + if (_ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode == 1) { + _qopenhd.show_toast("STILL SCANNING, PLEASE WAIT ..."); return; } close() } } } + RowLayout{ - SimpleProgressBar{ + id:channelSelectorRow + Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter + ComboBox { Layout.preferredWidth: 400 Layout.minimumWidth: 100 - Layout.preferredHeight: 40 - impl_curr_progress_perc: _wbLinkSettingsHelper.scan_progress_perc - impl_show_progress_text: true + id: comboBoxWhichFrequencyToScan + model: model_chann_to_scan + textRole: "title" + Material.background: { + (comboBoxWhichFrequencyToScan.currentIndex===0) ? "#2b9848" : "#ffae42" + } + onCurrentIndexChanged: { + } + enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0 } Button{ text: "START" @@ -94,6 +108,7 @@ Rectangle{ } } ButtonIconInfo{ + visible:false onClicked: { _messageBoxInstance.set_text_and_show("Initiate Channel Scan (Find a running air unit). Similar to analogue TX / RX, this listens on each channel for a short time"+ " to find a running openhd air unit."+ @@ -102,24 +117,23 @@ Rectangle{ } } } - ComboBox { - Layout.preferredWidth: 400 - Layout.minimumWidth: 100 - id: comboBoxWhichFrequencyToScan - model: model_chann_to_scan - textRole: "title" - Material.background: { - (comboBoxWhichFrequencyToScan.currentIndex===0) ? Material.Green : Material.Orange - } - onCurrentIndexChanged: { - } - enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0 - } + + SimpleProgressBar{ + Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter + Layout.preferredWidth: channelSelectorRow.width + Layout.minimumWidth: 100 + Layout.preferredHeight: 40 + impl_curr_progress_perc: _wbLinkSettingsHelper.scan_progress_perc + impl_show_progress_text: true + } Text{ + visible: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode!=0 + Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter Layout.row: 3 Layout.column: 0 text: _wbLinkSettingsHelper.scanning_text_for_ui - font.pixelSize: 25 + font.pixelSize: 21 + color: "#fff" } Item{ // Filler Layout.row: 4 diff --git a/qml/ui/configpopup/status/PanelStatus.qml b/qml/ui/configpopup/status/PanelStatus.qml index b0cbca935..452d42684 100644 --- a/qml/ui/configpopup/status/PanelStatus.qml +++ b/qml/ui/configpopup/status/PanelStatus.qml @@ -15,7 +15,7 @@ Rectangle { width: parent.width height: parent.height - color: "#eaeaea" + color: "#fff" function voltage_as_string(voltage_mv){ if(voltage_mv===0)return "N/A"; diff --git a/qml/ui/configpopup/status/StatusCardRow.qml b/qml/ui/configpopup/status/StatusCardRow.qml index 0d107d6df..d1119c97a 100644 --- a/qml/ui/configpopup/status/StatusCardRow.qml +++ b/qml/ui/configpopup/status/StatusCardRow.qml @@ -111,6 +111,14 @@ Item { anchors.left: left_part.right anchors.top: left_part.top text: m_right_text + background: Rectangle { + anchors.right: parent.right + anchors.rightMargin: 5 + anchors.left: parent.left + anchors.leftMargin: 5 + opacity: .3 + color: right_part_button.hovered ? "lightgrey" : "transparent" // Only look shit when hovered + } //Material.accent: Material.Red //highlighted: true visible: m_has_error && m_look_shit_on_error diff --git a/qml/ui/elements/Card.qml b/qml/ui/elements/Card.qml index 0905f90b3..bee5a4804 100644 --- a/qml/ui/elements/Card.qml +++ b/qml/ui/elements/Card.qml @@ -93,7 +93,7 @@ Item { Rectangle{ anchors.fill: background - color: "gray" + color: "lightgrey" opacity: 0.6 visible: m_style_error } diff --git a/qml/ui/elements/SimpleProgressBar.qml b/qml/ui/elements/SimpleProgressBar.qml index 9179e6cae..b66468248 100644 --- a/qml/ui/elements/SimpleProgressBar.qml +++ b/qml/ui/elements/SimpleProgressBar.qml @@ -6,7 +6,7 @@ Item { // Progress in [0..100] property double impl_curr_progress_perc: 0 // Color of the bar - property color impl_curr_color: "blue" + property color impl_curr_color: "#39a2f7" property bool impl_show_progress_text: false From f8dd6de3bbc31ec535ee6414de0f5ed9790a8217 Mon Sep 17 00:00:00 2001 From: Consti10 Date: Tue, 21 Nov 2023 21:53:27 +0100 Subject: [PATCH 79/81] bump version code for play --- android/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index f4a2a3979..d8efeeeee 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -1,5 +1,5 @@ - +