From a70587af05cfd5fb5b6d9d4c3fdfa0b31ac7c0b3 Mon Sep 17 00:00:00 2001 From: consti10 Date: Wed, 4 Oct 2023 16:43:10 +0200 Subject: [PATCH 01/21] 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/21] 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/21] 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/21] 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/21] 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/21] 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/21] 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/21] 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/21] 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/21] 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/21] 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/21] 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/21] 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/21] 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: Sat, 21 Oct 2023 17:23:20 +0200 Subject: [PATCH 15/21] 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 16/21] 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 17/21] 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 18/21] 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 19/21] 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 20/21] 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 21/21] 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 } } }