From b3518aeff579d6a168d402192dca56ef91caeaa1 Mon Sep 17 00:00:00 2001 From: Raphael <68374617+raphaelscholle@users.noreply.github.com> Date: Fri, 17 Nov 2023 02:22:55 +0100 Subject: [PATCH] Consti dev (#606) * tx power - reset the selection model(s) to fix bug @Ivan * tx power - whitelist for less confusion, add 720p60 16:9 to drop down selector @Ivan * Always disable Qt::AA_DisableHighDpiScaling, vertical speed: fix arrow, style: add @Norbert green * status: fill width, openhd quick: center elements (fix usability on low res screens) * finalize: Everything is usable up to minimum resolution (480p 16:9) * exp for android - re-enable high dpi scaling * exp -set before writing the AA flag / screen scale * exp -set before writing the AA flag / screen scale * wb link rate widget - use combobox instead of buttons * slightly decrease the default size of the artificial horizon * horizon ladder - scale home icon, restart qopenhd box - decrease size, status - slightly smaller text / ratio (OK on 480p), video / wb link rate widget style improvments neccessary due to change to ComboBox * make restart dialoque even smaller * fix " " * show restart dialoque when changed * debug * Revert "debug" This reverts commit 090bdeee3d76efead658cad060fe5324a7b833df. * status - look less shit on small screens connect - make it look okay * use DEF als agreed in chat * use DEF als agreed in chat * Convert total distance to Coords and bug fixes --------- Co-authored-by: consti10 Co-authored-by: pilotnbr1 --- app/main.cpp | 36 +- app/osd/horizonladder.cpp | 4 +- app/osd/horizonladder.h | 2 +- app/telemetry/models/fcmavlinksystem.cpp | 50 +- app/telemetry/models/fcmavlinksystem.h | 7 +- app/telemetry/settings/documentedparam.cpp | 10 + app/telemetry/settings/frequencyhelper.cpp | 14 +- app/telemetry/settings/frequencyhelper.h | 4 +- app/util/qopenhd.cpp | 7 +- app/util/qrenderstats.cpp | 8 +- app/util/qrenderstats.h | 7 +- qml/main.qml | 7 + qml/qml.qrc | 6 + qml/ui/configpopup/ConfigPopup.qml | 19 +- .../connect/PaneConnectionMode.qml | 52 +- .../dev/AppDeveloperStatsPanel.qml | 45 +- .../MavlinkAllSettingsPanel.qml | 1 + .../MavlinkOpenHDWBParamPanel.qml | 604 +++++++++--------- .../openhd_settings/OpenHDQuickPanel.qml | 353 ++++++++++ .../openhd_settings/PopupAnalyzeChannels.qml | 2 +- .../openhd_settings/PopupTxPowerEditor.qml | 285 ++++----- .../qopenhd_settings/AppDevSettingsView.qml | 2 +- .../AppScreenSettingsView.qml | 14 +- .../AppWidgetSettingsView.qml | 3 +- .../AppWidgetStyleSettingsView.qml | 53 +- .../status/FooterRebootShutdownWarning.qml | 11 +- qml/ui/configpopup/status/PanelStatus.qml | 37 +- .../configpopup/status/StatusCardBodyFC.qml | 2 +- .../status/StatusCardBodyOpenHD.qml | 4 +- qml/ui/configpopup/status/StatusCardRow.qml | 17 +- .../configpopup/status/StatusCardsColumn.qml | 12 +- qml/ui/elements/AppSettings.qml | 2 + qml/ui/elements/BaseHeaderItem.qml | 33 + qml/ui/elements/ButtonIconConnect.qml | 13 + qml/ui/elements/ButtonIconInfo2.qml | 12 + qml/ui/elements/CardBasic.qml | 8 + qml/ui/elements/RestartQOpenHDMessageBox.qml | 4 +- qml/ui/elements/SmallHeaderInfoRow.qml | 27 + qml/ui/widgets/HorizonWidget.qml | 4 +- qml/ui/widgets/VerticalSpeedSimpleWidget.qml | 26 +- qml/ui/widgets/VideoBitrateWidgetGeneric.qml | 20 +- qml/ui/widgets/WBLinkRateControlWidget.qml | 373 +++++------ 42 files changed, 1345 insertions(+), 855 deletions(-) create mode 100644 qml/ui/configpopup/openhd_settings/OpenHDQuickPanel.qml create mode 100644 qml/ui/elements/BaseHeaderItem.qml create mode 100644 qml/ui/elements/ButtonIconConnect.qml create mode 100644 qml/ui/elements/ButtonIconInfo2.qml create mode 100644 qml/ui/elements/CardBasic.qml create mode 100644 qml/ui/elements/SmallHeaderInfoRow.qml diff --git a/app/main.cpp b/app/main.cpp index f3741c4f4..a9bb3e342 100755 --- a/app/main.cpp +++ b/app/main.cpp @@ -186,14 +186,23 @@ static void android_check_permissions(){ #endif } - int main(int argc, char *argv[]) { QCoreApplication::setOrganizationName("OpenHD"); QCoreApplication::setOrganizationDomain("openhd"); QCoreApplication::setApplicationName("QOpenHD"); + {// Original screen resoluton before setting anything + //QApplication a(argc, argv); + const auto screen=QGuiApplication::primaryScreen(); + if(screen){ + const auto actual_size=screen->size(); + QRenderStats::instance().set_screen_width_height(actual_size.width(),actual_size.height()); + } + // a is deleted again + } QSettings settings; + qDebug()<<"Storing settings at ["<size().width(),screen->size().height()); diff --git a/app/osd/horizonladder.cpp b/app/osd/horizonladder.cpp index d82e12269..1b3396c21 100644 --- a/app/osd/horizonladder.cpp +++ b/app/osd/horizonladder.cpp @@ -14,7 +14,8 @@ HorizonLadder::HorizonLadder(QQuickItem *parent): QQuickPaintedItem(parent) { setRenderTarget(RenderTarget::FramebufferObject); //m_font.setPixelSize(14); - m_font.setPointSize(14); + m_font.setPointSize(DEFAULT_FONT_PIXEL_SIZE); + m_fontAwesome.setPointSize(DEFAULT_FONT_PIXEL_SIZE); } void HorizonLadder::paint(QPainter* painter) { @@ -500,5 +501,6 @@ void HorizonLadder::set_custom_font_scale(double custom_font_scale) { m_custom_font_scale=custom_font_scale; m_font.setPointSize(DEFAULT_FONT_PIXEL_SIZE*m_custom_font_scale); + m_fontAwesome.setPointSize(DEFAULT_FONT_PIXEL_SIZE*m_custom_font_scale); update(); } diff --git a/app/osd/horizonladder.h b/app/osd/horizonladder.h index c2c48ff21..4d1045d61 100644 --- a/app/osd/horizonladder.h +++ b/app/osd/horizonladder.h @@ -108,7 +108,7 @@ public slots: QFont m_font; - QFont m_fontAwesome = QFont("Font Awesome 5 Free", 15, QFont::Bold, false); + QFont m_fontAwesome = QFont("Font Awesome 5 Free", 11, QFont::Bold, false); double m_custom_font_scale=1.0; }; #endif //QOPENHD_HORIZON_LADDER diff --git a/app/telemetry/models/fcmavlinksystem.cpp b/app/telemetry/models/fcmavlinksystem.cpp index 134768b78..7a2aaaddb 100644 --- a/app/telemetry/models/fcmavlinksystem.cpp +++ b/app/telemetry/models/fcmavlinksystem.cpp @@ -202,13 +202,28 @@ bool FCMavlinkSystem::process_message(const mavlink_message_t &msg) const double lat=static_cast(global_position_int.lat) / 10000000.0; const double lon=static_cast(global_position_int.lon) / 10000000.0; // This way we could also calculate the flight distance - but aparently, this results in slightly too small values - // (probably could be fixed by using a distance calculation method that is a better fit) - /*if(m_lat!=0.0 && m_lon!=0.0 && m_gps_hdop<20){ - const auto added_distance_m=distance_between(m_lat,m_lon,lat,lon); - total_dist = total_dist + added_distance_m; - //qDebug() << "total distance" << total_dist; - set_flight_distance_m( total_dist); - }*/ + double added_distance_m=0.0; + if(m_lat!=0.0 && m_lon!=0.0 && m_gps_hdop<20){ + // kind of dumb to do this for the first few meters....whatever... + if (m_last_lat==0.0 && m_last_lon==0.0){ + added_distance_m=distance_between(m_lat,m_lon,lat,lon); + } + else { + added_distance_m=distance_between(m_last_lat,m_last_lon,lat,lon); + } + qDebug() << "added_distance_m" << added_distance_m; + if (added_distance_m > 2.0){ + + total_dist = total_dist + added_distance_m; + //qDebug() << "total distance" << total_dist; + //in sitl large distance can still be erroniously generated with hdop<20 + if (m_armed ){ + set_flight_distance_m( total_dist); + set_last_lat(lat); + set_last_lon(lon); + } + } + } set_lat(lat); set_lon(lon); set_boot_time(global_position_int.time_boot_ms); @@ -280,7 +295,6 @@ bool FCMavlinkSystem::process_message(const mavlink_message_t &msg) set_throttle(vfr_hud.throttle); set_air_speed_meter_per_second(vfr_hud.airspeed); set_ground_speed_meter_per_second(vfr_hud.groundspeed); - update_flight_distance_using_groundspeed(); // qDebug() << "Speed- ground " << speed; auto vsi = vfr_hud.climb; set_vertical_speed_indicator_mps(vsi); @@ -521,25 +535,6 @@ void FCMavlinkSystem::updateFlightTimer() { } } -void FCMavlinkSystem::update_flight_distance_using_groundspeed() { - if (m_gps_hdop > 20 || m_lat == 0.0){ - //do not pollute distance if we have bad data - return; - } - if (m_armed==true){ - const auto elapsed_ms = flightTimeStart.elapsed(); - const auto time_diff_ms = elapsed_ms - m_flight_distance_last_time_ms; - m_flight_distance_last_time_ms = elapsed_ms; - const auto time_diff_s =time_diff_ms / 1000.0; - const auto added_distance = m_ground_speed_meter_per_second * time_diff_s; - //qDebug() << "added distance" << added_distance; - total_dist = total_dist + added_distance; - //qDebug() << "total distance" << total_dist; - set_flight_distance_m( total_dist); - } -} - - void FCMavlinkSystem::set_armed(bool armed) { if(m_armed==armed)return; //there has been no change so exit if (armed && !m_armed) { @@ -550,6 +545,7 @@ void FCMavlinkSystem::set_armed(bool armed) { * vehicle is disarmed, causing it to appear to stop in the UI. */ flightTimeStart.start(); + set_flight_distance_m(0.0); //reset the flight distance if (m_home_latitude == 0.0 || m_home_longitude == 0.0) { //LocalMessage::instance()->showMessage("No Home Position in FCMavlinkSystem", 4); // Not needed anymore after we just set the proper rate(s) diff --git a/app/telemetry/models/fcmavlinksystem.h b/app/telemetry/models/fcmavlinksystem.h index 3d7e35cd8..bd9649dc2 100644 --- a/app/telemetry/models/fcmavlinksystem.h +++ b/app/telemetry/models/fcmavlinksystem.h @@ -99,6 +99,8 @@ class FCMavlinkSystem : public QObject // L_RO_PROP(double,lat,set_lat,0.0) L_RO_PROP(double,lon,set_lon,0.0) + L_RO_PROP(double,last_lat,set_last_lat,0.0) + L_RO_PROP(double,last_lon,set_last_lon,0.0) L_RO_PROP(int,satellites_visible,set_satellites_visible,0) L_RO_PROP(double,gps_hdop,set_gps_hdop,-1) L_RO_PROP(double,gps_vdop,set_gps_vdop,-1) @@ -164,9 +166,6 @@ class FCMavlinkSystem : public QObject void calculate_home_course(); // Updates the flight time by increasing the time when armed void updateFlightTimer(); - // Calculates the flght distance (dirty) by taking time delta and current speed into account - // replaced by using distance between lat,lon point(s) (this is a bit more accurate) - void update_flight_distance_using_groundspeed(); // Something something luke void updateVehicleAngles(); // Something somethng luke @@ -202,7 +201,7 @@ class FCMavlinkSystem : public QObject double speed_last_time = 0.0; qint64 m_flight_distance_last_time_ms= 0; - long total_dist= 0; + double total_dist= 0.0; QElapsedTimer totalTime; QElapsedTimer flightTimeStart; diff --git a/app/telemetry/settings/documentedparam.cpp b/app/telemetry/settings/documentedparam.cpp index 59b0a48ca..f4fb3fda1 100644 --- a/app/telemetry/settings/documentedparam.cpp +++ b/app/telemetry/settings/documentedparam.cpp @@ -707,6 +707,16 @@ static std::map get_whitelisted_params() ret["CONFIG_BOOT_AIR"]=nullptr; ret[openhd::WB_MAX_FEC_BLOCK_SIZE_FOR_PLATFORM]=nullptr; ret[openhd::WB_DEV_AIR_SET_HIGH_RETRANSMIT_COUNT]=nullptr; + // TX POWER Whitelisted, since they should be changed from the quick wizzard + ret[openhd::WB_TX_POWER_MILLI_WATT]=nullptr; + ret[openhd::WB_TX_POWER_MILLI_WATT_ARMED]=nullptr; + ret[openhd::WB_RTL8812AU_TX_PWR_IDX_OVERRIDE]=nullptr; + ret[openhd::WB_RTL8812AU_TX_PWR_IDX_ARMED]=nullptr; + // STBC / LDPC - Whitelisted, since they should be changed from the quick wizzard + ret[openhd::WB_ENABLE_LDPC]=nullptr; + ret[openhd::WB_ENABLE_STBC]=nullptr; + // Whitelisted since normally it should not be changed / has no effect anyways + ret[openhd::WB_ENABLE_SHORT_GUARD]=nullptr; //ret[""]=nullptr; return ret; } diff --git a/app/telemetry/settings/frequencyhelper.cpp b/app/telemetry/settings/frequencyhelper.cpp index 22928cb97..543a798dc 100644 --- a/app/telemetry/settings/frequencyhelper.cpp +++ b/app/telemetry/settings/frequencyhelper.cpp @@ -12,10 +12,10 @@ FrequencyHelper &FrequencyHelper::instance() return instance; } -QList FrequencyHelper::get_frequencies(bool openhd_bands_only) +QList FrequencyHelper::get_frequencies(int filter) { QList ret; - if(openhd_bands_only){ + if(filter==0){ auto tmp=openhd::get_openhd_channels_1_to_5(); for(auto& channel:tmp){ ret.push_back(channel.frequency); @@ -24,7 +24,15 @@ QList FrequencyHelper::get_frequencies(bool openhd_bands_only) const auto frequency_items=openhd::get_all_channels_2G_5G(); for(auto& item:frequency_items){ if(item.is_legal_at_least_one_country){ - ret.push_back(item.frequency); + if(filter==1){ + if(item.frequency<3000){ + ret.push_back(item.frequency); + } + }else{ + if(item.frequency>3000){ + ret.push_back(item.frequency); + } + } } } } diff --git a/app/telemetry/settings/frequencyhelper.h b/app/telemetry/settings/frequencyhelper.h index 20d8fc5a2..ce30d5f28 100644 --- a/app/telemetry/settings/frequencyhelper.h +++ b/app/telemetry/settings/frequencyhelper.h @@ -14,8 +14,8 @@ class FrequencyHelper : public QObject public: explicit FrequencyHelper(QObject *parent = nullptr); static FrequencyHelper &instance(); - - Q_INVOKABLE QList get_frequencies(bool openhd_bands_only); + // Filter: 0 - OpenHD 1-5 only, 1= all 2.4G freq, 2 = all 5.8G freq + Q_INVOKABLE QList get_frequencies(int filter); Q_INVOKABLE QList get_frequencies_all_40Mhz(); Q_INVOKABLE bool get_frequency_radar(int frequency_mhz); diff --git a/app/util/qopenhd.cpp b/app/util/qopenhd.cpp index 96eae4655..8c0056144 100644 --- a/app/util/qopenhd.cpp +++ b/app/util/qopenhd.cpp @@ -202,7 +202,7 @@ bool QOpenHD::overwrite_settings_from_backup_file() bool QOpenHD::reset_settings() { -#ifdef __linux__ +/*#ifdef __linux__ QSettings settings; std::string file_name = settings.fileName().toStdString(); int result = remove(file_name.c_str()); @@ -213,7 +213,10 @@ bool QOpenHD::reset_settings() qDebug() << "Error: Failed to delete file" << QString::fromStdString(file_name); return false; #endif - return false; + return false;*/ + QSettings settings; + settings.clear(); + return true; } diff --git a/app/util/qrenderstats.cpp b/app/util/qrenderstats.cpp index 05813d729..5b96cea1c 100644 --- a/app/util/qrenderstats.cpp +++ b/app/util/qrenderstats.cpp @@ -33,18 +33,18 @@ void QRenderStats::registerOnWindow(QQuickWindow *window) connect(window, &QQuickWindow::afterRenderPassRecording, this, &QRenderStats::m_QQuickWindow_afterRenderPassRecording, Qt::DirectConnection); } -void QRenderStats::set_display_width_height(int width, int height) +void QRenderStats::set_screen_width_height(int width, int height) { std::stringstream ss; ss<video/SecondaryVideoGstreamerPane.qml ui/elements/SettingsHeaderElement.qml ui/configpopup/qopenhd_settings/AppWidgetStyleSettingsView.qml + ui/configpopup/openhd_settings/OpenHDQuickPanel.qml + ui/elements/BaseHeaderItem.qml + ui/elements/ButtonIconInfo2.qml + ui/elements/CardBasic.qml + ui/elements/ButtonIconConnect.qml + ui/elements/SmallHeaderInfoRow.qml diff --git a/qml/ui/configpopup/ConfigPopup.qml b/qml/ui/configpopup/ConfigPopup.qml index cdc9f3175..0c8ad91ca 100644 --- a/qml/ui/configpopup/ConfigPopup.qml +++ b/qml/ui/configpopup/ConfigPopup.qml @@ -19,9 +19,13 @@ import "status" // Contains the selector on the left and a stack view for the panels on the right Rectangle { id: settings_form - - // The connect is only needed when qopenhd is not running on the ground system itself (e.g. android) - property bool m_show_connect_option: true // _qopenhd.is_android() + //width: 1280 + //height: 720 + anchors.fill: parent + //width: parent.width * settings.screen_settings_overlay_size_percent / 100; + //height: parent.height * settings.screen_settings_overlay_size_percent / 100; + z: 4.0 + color: "transparent" // size of the elements in the left bar - e.g. what allows switching between all the tabs property int left_sidebar_elements_height: 46 @@ -64,14 +68,6 @@ Rectangle { } }*/ - //anchors.fill: parent - width: parent.width * settings.screen_settings_overlay_size_percent / 100; - height: parent.height * settings.screen_settings_overlay_size_percent / 100; - - z: 4.0 - - color: "transparent" - Rectangle { id: spacerTopSpacer width: 132 @@ -210,7 +206,6 @@ Rectangle { // We only need the connect panel on android (external device) // On localhost, QOpenHD "automatically" connects due to udp localhost method ConfigPopupSidebarButton{ - visible: m_show_connect_option id: connect_button m_icon_text: "\uf6ff" m_description_text: "Connect" diff --git a/qml/ui/configpopup/connect/PaneConnectionMode.qml b/qml/ui/configpopup/connect/PaneConnectionMode.qml index 6bf06c9ab..efccc7b05 100644 --- a/qml/ui/configpopup/connect/PaneConnectionMode.qml +++ b/qml/ui/configpopup/connect/PaneConnectionMode.qml @@ -60,11 +60,14 @@ Rectangle{ } wrapMode: Text.WordWrap color: m_is_air_or_ground_connected ? "red" : "black" + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter } ComboBox { Layout.fillWidth: false Layout.fillHeight: true; Layout.preferredWidth: 200 + Layout.alignment: Qt.AlignCenter id: connection_mode_dropdown model: ListModel { @@ -81,10 +84,12 @@ Rectangle{ currentIndex: settings.qopenhd_mavlink_connection_mode } Text{ - Layout.fillWidth: true - Layout.fillHeight: true; + Layout.preferredWidth: 200 + Layout.alignment: Qt.AlignCenter id: connection_status text: _mavlinkTelemetry.telemetry_connection_status + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter } // Visible when auto mode is enabled ------------------------------------------------------------------------------------------ @@ -95,9 +100,14 @@ Rectangle{ visible: connection_mode_dropdown.currentIndex==0; RowLayout { + Layout.fillWidth: true + Item{ // filler + Layout.fillWidth: true + } Button{ text: "Android Tethering" Layout.preferredWidth: 180 + Layout.alignment: Qt.AlignCenter onClicked: { if(_qopenhd.is_android()){ _qopenhd.android_open_tethering_settings() @@ -107,16 +117,25 @@ Rectangle{ } } ButtonIconInfoText { + Layout.alignment: Qt.AlignCenter m_info_text: "1) Connect your phone via high quality USB cable to your ground station.\n\n"+ "2) enable USB Tethering on your phone.\n\n"+ "3) Telemetry and video forwarding is started automatically \n\n"+ " ! Requires a phone and cellular contract that allows USB tethering. !" } + Item{ // filler + Layout.fillWidth: true + } } RowLayout { + Layout.fillWidth: true + Item{ // filler + Layout.fillWidth: true + } Button{ text: "Wifi tethering" Layout.preferredWidth: 180 + Layout.alignment: Qt.AlignCenter //TODO enable hotspot onClicked: { _messageBoxInstance.set_text_and_show("Please connect:\nWiFi Name: openhd_air/openhd_ground.\n PW: openhdopenhd") @@ -128,11 +147,18 @@ Rectangle{ "3) Connect this device to your AIR / GND unit wifi hotspot.\n\n"+ "NOTE: It is not recommended to use WiFi hotspot during flight (automatically disabled on arm by default)" } + Item{ // filler + Layout.fillWidth: true + } } RowLayout { + Item{ // filler + Layout.fillWidth: true + } Button{ text: "Passive Eth tethering" Layout.preferredWidth: 180 + Layout.alignment: Qt.AlignCenter //TODO disable active tethering and enable passive when clicking the button onClicked: { _qopenhd.show_toast("Please read info"); @@ -144,11 +170,18 @@ Rectangle{ "3) Select 'share my internet with ...' when the android connection setup pops up\n\n"+ "Video and telemetry forwarding should start automatically, internet will be forwarded from your phone." } + Item{ // filler + Layout.fillWidth: true + } } RowLayout { + Item{ // filler + Layout.fillWidth: true + } Button{ text: "Active Eth tethering" Layout.preferredWidth: 180 + Layout.alignment: Qt.AlignCenter //TODO disable passive tethering and enable active when clicking the button onClicked: { _qopenhd.show_toast("Please read info"); @@ -160,6 +193,9 @@ Rectangle{ "You might need to disable wifi and cellular on your phone\n\n"+ "Video and telemetry forwarding should start automatically, internet will not be available." } + Item{ // filler + Layout.fillWidth: true + } } // padding to bottom Item { @@ -169,13 +205,20 @@ Rectangle{ } // Visible when manual UDP mode is enabled ------------------------------------------------------------------------------------------ - GridLayout{ + RowLayout{ Layout.fillWidth: true Layout.fillHeight: true visible: connection_mode_dropdown.currentIndex==1; + Item{ // filler + Layout.fillWidth: true + } Text{ + Layout.alignment: Qt.AlignCenter text: "Listening on localhost:5600" } + Item{ // filler + Layout.fillWidth: true + } } // Visible when manual TCP mode is enabled ------------------------------------------------------------------------------------------ GridLayout { @@ -184,6 +227,7 @@ Rectangle{ visible: connection_mode_dropdown.currentIndex==2; columns: 2 TextField { + Layout.alignment: Qt.AlignCenter id: textFieldip validator: RegExpValidator { regExp: /^((?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.){0,3}(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])$/ @@ -192,6 +236,7 @@ Rectangle{ text: settings.qopenhd_mavlink_connection_manual_tcp_ip } Button{ + Layout.alignment: Qt.AlignCenter text: "SAVE" onClicked: { if(!_mavlinkTelemetry.change_manual_tcp_ip(textFieldip.text)){ @@ -202,6 +247,7 @@ Rectangle{ } } Text{ + Layout.alignment: Qt.AlignCenter Layout.columnSpan: 2 text: "TCP PORT: 5760" } diff --git a/qml/ui/configpopup/dev/AppDeveloperStatsPanel.qml b/qml/ui/configpopup/dev/AppDeveloperStatsPanel.qml index cf06d9602..3ea3a12a6 100644 --- a/qml/ui/configpopup/dev/AppDeveloperStatsPanel.qml +++ b/qml/ui/configpopup/dev/AppDeveloperStatsPanel.qml @@ -52,7 +52,30 @@ Rectangle { anchors.top: parent.top anchors.left: parent.left anchors.margins: 10 - + Text{ + text: qsTr("QOpenHD version:" + _qopenhd.version_string) + Layout.leftMargin: 12 + } + Text { + id: test5 + text: qsTr("FEATURES: " + get_features_string()) + Layout.leftMargin: 12 + } + Text { + id: test6 + text: qsTr("Screen resolution: " + _qrenderstats.screen_width_height_str+" ADJ:"+_qrenderstats.display_width_height_str) + Layout.leftMargin: 12 + } + Text { + id: test7 + text: qsTr("Window resolution: " + _qrenderstats.window_width+"x"+_qrenderstats.window_height) + Layout.leftMargin: 12 + } + Text { + id: test8 + text: qsTr("You're running on: " + Qt.platform.os) + Layout.leftMargin: 12 + } Text { id: test1 text: qsTr("Art Horizon mavlink update rate:" + _fcMavlinkSystem.curr_update_rate_mavlink_message_attitude + " Hz") @@ -85,26 +108,6 @@ Rectangle { text: qsTr("video0 FEC decode: " + _cameraStreamModelPrimary.curr_fec_decode_time_avg_min_max) Layout.leftMargin: 12 } - Text { - id: test5 - text: qsTr("FEATURES: " + get_features_string()) - Layout.leftMargin: 12 - } - Text { - id: test6 - text: qsTr("Screen resolution: " + _qrenderstats.display_width_height_str) - Layout.leftMargin: 12 - } - Text { - id: test7 - text: qsTr("Window resolution: " + _qrenderstats.window_width_height_str) - Layout.leftMargin: 12 - } - Text { - id: test8 - text: qsTr("You're running on: " + Qt.platform.os) - Layout.leftMargin: 12 - } Button { height: 24 text: "Restart local OHD service" diff --git a/qml/ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml b/qml/ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml index 00b63a38e..71eef0109 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml +++ b/qml/ui/configpopup/openhd_settings/MavlinkAllSettingsPanel.qml @@ -64,6 +64,7 @@ Rectangle { currentIndex: selectItemInStackLayoutBar.currentIndex MavlinkOpenHDWBParamPanel{ + //OpenHDQuickPanel{ id: mavlink_openhd_wb_param_panel } MavlinkParamPanel{ diff --git a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml index 17bd50434..5a88e7256 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml +++ b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml @@ -45,38 +45,24 @@ Rectangle{ } ListModel{ - id: frequencies_model_all - ListElement {title: "Unknown"; value_frequency_mhz:-1} - } - ListModel{ - id: frequencies_model_openhd_channels_only + id: frequencies_model ListElement {title: "Unknown"; value_frequency_mhz:-1} } function create_list_models_frequency(){ - frequencies_model_all.clear(); - const frequencies_all=_frequencyHelper.get_frequencies(false); + frequencies_model.clear(); + const filter = filter_tab_bar.currentIndex; + const frequencies_all=_frequencyHelper.get_frequencies(filter); for(var i=0;i0){ var index=find_index(comboBoxFreq.model,_wbLinkSettingsHelper.curr_channel_mhz); if(index>=0){ @@ -144,340 +130,342 @@ Rectangle{ height: parent.height anchors.centerIn: parent contentHeight: main_column_layout.height - contentWidth: main_column_layout.width + //contentWidth: main_column_layout.width //ScrollBar.vertical.policy: ScrollBar.AlwaysOn ScrollBar.vertical.interactive: true visible: (!popup_analyze_channels.visible && !popup_enable_stbc_ldpc.visible && !popup_change_tx_power.visible && !popup_scan_channels.visible) + clip: true ColumnLayout{ - Layout.fillWidth: true - Layout.fillHeight: true + width: main_scroll_view.width id: main_column_layout + Layout.margins: 10 + BaseHeaderItem{ + m_text: "FREQUENCY / TOOLKIT" + } - Rectangle { - id: frequency_area_layout_background - color: m_background_color - implicitWidth: main_scroll_view.width - implicitHeight: frequency_area_layout.implicitHeight+5 - radius: 10 - - ColumnLayout { - id: frequency_area_layout + RowLayout{ + Layout.fillWidth: true + Item{ // FILLER Layout.fillWidth: true - Layout.fillHeight: true - Layout.margins: 10 - - Text{ - Layout.row: 0 - Layout.column: 0 - text: "FREQUENCY / TOOLKIT" - font.bold: true + } + ComboBox { + Layout.alignment: Qt.AlignCenter + Layout.preferredWidth: elementComboBoxWidth + id: comboBoxFreq + model: frequencies_model + textRole: "title" + implicitWidth: elementComboBoxWidth + currentIndex: 0 + delegate: ItemDelegate { + width: comboBoxFreq.width + contentItem: FreqComboBoxRow{ + m_main_text: title + m_selection_tpye: (value_frequency_mhz===_wbLinkSettingsHelper.curr_channel_mhz) ? 1 : 0 + m_is_2G: value_frequency_mhz < 3000 && value_frequency_mhz > 100 + m_show_radar: _frequencyHelper.get_frequency_radar(value_frequency_mhz) + m_openhd_race_band: _frequencyHelper.get_frequency_openhd_race_band(value_frequency_mhz) + m_pollution_pps: _pollutionHelper.pollution_get_last_scan_pollution_for_frequency(value_frequency_mhz) + } + highlighted: comboBoxFreq.highlightedIndex === index } - - RowLayout{ - ComboBox { - id: comboBoxFreq - //model: supported_frequencies_model - //model: frequencies_model_openhd_channels_only - textRole: "title" - implicitWidth: elementComboBoxWidth - currentIndex: 0 - delegate: ItemDelegate { - width: comboBoxFreq.width - contentItem: FreqComboBoxRow{ - m_main_text: title - m_selection_tpye: (value_frequency_mhz===_wbLinkSettingsHelper.curr_channel_mhz) ? 1 : 0 - m_is_2G: value_frequency_mhz < 3000 && value_frequency_mhz > 100 - m_show_radar: _frequencyHelper.get_frequency_radar(value_frequency_mhz) - m_openhd_race_band: _frequencyHelper.get_frequency_openhd_race_band(value_frequency_mhz) - m_pollution_pps: _pollutionHelper.pollution_get_last_scan_pollution_for_frequency(value_frequency_mhz) - } - highlighted: comboBoxFreq.highlightedIndex === index - } - Layout.row: 1 - Layout.column: 0 - displayText: { - if(!_ohdSystemGround.is_alive)return "GND NOT ALIVE"; - if(_ohdSystemGround.wb_gnd_operating_mode==1){ - return "SCANNING"; - } - if(_ohdSystemGround.wb_gnd_operating_mode==2){ - return "ANALYZING"; - } - if(!_ohdSystemAir.is_alive){ - return _wbLinkSettingsHelper.curr_channel_mhz+"@"+"N/A"+" Mhz (NO AIR)"; - } - return _wbLinkSettingsHelper.curr_channel_mhz+"@"+_wbLinkSettingsHelper.curr_channel_width_mhz+" Mhz"; - } - onActivated: { - console.log("onActivated:"+currentIndex); - if(currentIndex<0)return; - const frequency_mhz=comboBoxFreq.model.get(currentIndex).value_frequency_mhz - console.log("Selected frequency: "+frequency_mhz); - if(!_frequencyHelper.hw_supports_frequency_threadsafe(frequency_mhz)){ - _qopenhd.show_toast("your HW does not support "+frequency_mhz+" Mhz"); - return; - } - if(_wbLinkSettingsHelper.curr_channel_mhz==frequency_mhz){ - console.log("Already at frequency "+frequency_mhz); - return; - } - if(!_ohdSystemAir.is_alive){ - var error_message_not_alive="AIR Unit not alive -" - dialoqueFreqChangeGndOnly.initialize_and_show_frequency(frequency_mhz,error_message_not_alive); - return; - } - // Change the freuquency - dialoqueFreqChangeAirGnd.initialize_and_show_frequency(frequency_mhz); - } - enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0; + displayText: { + if(!_ohdSystemGround.is_alive)return "GND NOT ALIVE"; + if(_ohdSystemGround.wb_gnd_operating_mode==1){ + return "SCANNING"; } - Switch{ - Layout.row: 1 - Layout.column: 1 - Layout.columnSpan: 1 - text: "SIMPLIFY" - checked: true - onCheckedChanged: { - if(m_simplify_enable!=checked){ - m_simplify_enable=checked; - function_rebuild_ui(); - } - } + if(_ohdSystemGround.wb_gnd_operating_mode==2){ + return "ANALYZING"; } - ButtonIconInfo{ - Layout.row: 1 - Layout.column: 2 - onClicked: { - var text="Please select a channel / frequency free of noise and interference. The current loss / pollution / throttle stats below can help,"+ - "as well as the analyze channels feature or a frequency analyzer on your phone. SIMPLIFY: Show OpenHD standard channels [1-5] only - they "+ - " often are free of wifi pollution and should be used. Only disable SIMPLIFY if you know exactly why." - _messageBoxInstance.set_text_and_show(text) - } + if(!_ohdSystemAir.is_alive){ + return _wbLinkSettingsHelper.curr_channel_mhz+"@"+"N/A"+" Mhz (NO AIR)"; } + return _wbLinkSettingsHelper.curr_channel_mhz+"@"+_wbLinkSettingsHelper.curr_channel_width_mhz+" Mhz"; } - - - - RowLayout{ - Layout.row: 2 - Layout.column: 0 - Layout.columnSpan: 3 - Item{ // FILLER - Layout.preferredWidth: 30 - Layout.minimumWidth: 0 + onActivated: { + console.log("onActivated:"+currentIndex); + if(currentIndex<0)return; + const frequency_mhz=comboBoxFreq.model.get(currentIndex).value_frequency_mhz + console.log("Selected frequency: "+frequency_mhz); + if(!_frequencyHelper.hw_supports_frequency_threadsafe(frequency_mhz)){ + _qopenhd.show_toast("your HW does not support "+frequency_mhz+" Mhz"); + return; } - Button{ - Layout.preferredWidth: 150 - id: b_find_air_unit - text: "SCAN" - enabled: _ohdSystemGround.is_alive - onClicked: { - close_all_dialoques(); - popup_scan_channels.open() - } - SequentialAnimation { - running: false - loops: 4 - id: anim_find_air_unit - // Expand the button - PropertyAnimation { - target: b_find_air_unit - property: "scale" - to: 1.5 - duration: 200 - easing.type: Easing.InOutQuad - } - // Shrink back to normal - PropertyAnimation { - target: b_find_air_unit - property: "scale" - to: 1.0 - duration: 200 - easing.type: Easing.InOutQuad - } - } + if(_wbLinkSettingsHelper.curr_channel_mhz==frequency_mhz){ + console.log("Already at frequency "+frequency_mhz); + return; } - Item{ // FILLER - Layout.preferredWidth: 30 - Layout.minimumWidth: 0 + if(!_ohdSystemAir.is_alive){ + var error_message_not_alive="AIR Unit not alive -" + dialoqueFreqChangeGndOnly.initialize_and_show_frequency(frequency_mhz,error_message_not_alive); + return; } - Button{ - Layout.preferredWidth: 150 - text: "ANALYZE" - enabled: _ohdSystemGround.is_alive - onClicked: { - close_all_dialoques(); - popup_analyze_channels.open() + // Change the freuquency + dialoqueFreqChangeAirGnd.initialize_and_show_frequency(frequency_mhz); + } + enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0; + } + /*Switch{ + Layout.alignment: Qt.AlignCenter + text: "SIMPLIFY" + checked: true + onCheckedChanged: { + if(m_simplify_enable!=checked){ + m_simplify_enable=checked; + function_rebuild_ui(); + } + } + }*/ + TabBar{ + id: filter_tab_bar + Layout.preferredWidth: 200 + currentIndex: settings.qopenhd_frequency_filter_selection + onCurrentIndexChanged: { + if(currentIndex!=settings.qopenhd_frequency_filter_selection){ + settings.qopenhd_frequency_filter_selection=currentIndex; + function_rebuild_ui(); + if(currentIndex==1){ + _qopenhd.show_toast("2.4G is almost always polluted by WiFi. Not recommended.") + }else if(currentIndex==2){ + _qopenhd.show_toast("Please watch out for wifi pollution. Using DEF is highly recommended !") } } - Item{ // FILLER - Layout.preferredWidth: 30 - Layout.minimumWidth: 0 + } + TabButton{ + text: "DEF" + } + TabButton{ + text: "2.4G" + } + TabButton{ + text: "5.8G" + } + } + Item{ // FILLER + Layout.fillWidth: true + } + ButtonIconInfo2{ + Layout.alignment: Qt.AlignRight + onClicked: { + var text="Please select a channel / frequency free of noise and interference. The current loss / pollution / throttle stats below can help,"+ + "as well as the analyze channels feature or a frequency analyzer on your phone. SIMPLIFY: Show OpenHD standard channels [1-5] only - they "+ + " often are free of wifi pollution and should be used. Only disable SIMPLIFY if you know exactly why." + _messageBoxInstance.set_text_and_show(text) + } + } + } + + RowLayout{ + Layout.fillWidth: true + Item{ // FILLER + Layout.fillWidth: true + } + Button{ + Layout.alignment: Qt.AlignCenter + Layout.preferredWidth: 150 + id: b_find_air_unit + text: "SCAN" + enabled: _ohdSystemGround.is_alive + onClicked: { + close_all_dialoques(); + popup_scan_channels.open() + } + SequentialAnimation { + running: false + loops: 4 + id: anim_find_air_unit + // Expand the button + PropertyAnimation { + target: b_find_air_unit + property: "scale" + to: 1.5 + duration: 200 + easing.type: Easing.InOutQuad + } + // Shrink back to normal + PropertyAnimation { + target: b_find_air_unit + property: "scale" + to: 1.0 + duration: 200 + easing.type: Easing.InOutQuad } - ButtonIconInfo{ + } + } + Button{ + Layout.alignment: Qt.AlignCenter + Layout.preferredWidth: 150 + text: "ANALYZE" + enabled: _ohdSystemGround.is_alive + onClicked: { + close_all_dialoques(); + popup_analyze_channels.open() + } + } + Item{ // FILLER + Layout.fillWidth: true + } + /*ButtonIconInfo{ onClicked: { var text="SCAN: Similar to analoque channel scan, find a running air unit by checking all possible channels (frequencies).\n\n"+ "ANALYZE: Analyze channels for WiFi pollution. Read the wiki for more info."; _messageBoxInstance.set_text_and_show(text) } - } + }*/ + } + RowLayout{ + Layout.fillWidth: true + Item{ // FILLER + Layout.fillWidth: true + } + Text{ + Layout.preferredHeight: 50 + Layout.preferredWidth: 120 + text:{ + "LOSS:\n"+_ohdSystemGround.curr_rx_packet_loss_perc+"%" } - RowLayout{ - Text{ - Layout.preferredHeight: 50 - Layout.preferredWidth: 120 - text:{ - "LOSS:\n"+_ohdSystemGround.curr_rx_packet_loss_perc+"%" - } - color: _ohdSystemGround.curr_rx_packet_loss_perc > 5 ? "red" : "black" - verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignHCenter - font.bold: true - } - Text{ - Layout.preferredHeight: 50 - Layout.preferredWidth: 120 - text: { - return "POLLUTION:\n"+_ohdSystemGround.wb_link_curr_foreign_pps+"pps" - } - color: _ohdSystemGround.wb_link_curr_foreign_pps > 20 ? "red" : "black" - verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignHCenter - font.bold: true - } - Text{ - Layout.preferredHeight: 50 - Layout.preferredWidth: 120 - text: { - return "THROTTLE:\n"+_ohdSystemAir.curr_n_rate_adjustments - } - color: _ohdSystemAir.curr_n_rate_adjustments > 0 ? "red" : "black" - verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignHCenter - font.bold: true - } - ButtonIconInfo{ + color: _ohdSystemGround.curr_rx_packet_loss_perc > 5 ? "red" : "black" + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + Text{ + Layout.preferredHeight: 50 + Layout.preferredWidth: 120 + text: { + return "POLLUTION:\n"+_ohdSystemGround.wb_link_curr_foreign_pps+"pps" + } + color: _ohdSystemGround.wb_link_curr_foreign_pps > 20 ? "red" : "black" + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + Text{ + Layout.preferredHeight: 50 + Layout.preferredWidth: 120 + text: { + return "THROTTLE:\n"+_ohdSystemAir.curr_n_rate_adjustments + } + color: _ohdSystemAir.curr_n_rate_adjustments > 0 ? "red" : "black" + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + Item{ // FILLER + Layout.fillWidth: true + } + /*ButtonIconInfo{ onClicked: { var text="High Loss / Pollution / active throttle hint at a polluted channel." _messageBoxInstance.set_text_and_show(text) } } ButtonIconWarning{ - visible: /*_ohdSystemAir.is_alive &&*/ (_ohdSystemGround.curr_rx_packet_loss_perc > 5 || _ohdSystemGround.wb_link_curr_foreign_pps > 20 || _ohdSystemAir.curr_n_rate_adjustments > 0) + visible: (_ohdSystemGround.curr_rx_packet_loss_perc > 5 || _ohdSystemGround.wb_link_curr_foreign_pps > 20 || _ohdSystemAir.curr_n_rate_adjustments > 0) onClicked: { var text="On the bench, if you encounter issues like a high loss , high pollution or throttling, make sure:\n"+ "1) You are using a channel free of noise and interference (OHD channel 1-5 are a good bet)\n"+ "2) (RARELY,RTL8812AU only): Your TX card(s) aren't overamplifying the signal and have adequate cooling."; _messageBoxInstance.set_text_and_show(text) } - } - } - } + }*/ } - Rectangle { - implicitWidth: main_scroll_view.width - implicitHeight: tx_power_layout.implicitHeight - id: tx_power_layout_background - color: m_background_color - radius: 10 - - RowLayout { - id: tx_power_layout + + BaseHeaderItem{ + m_text: "TX POWER" + } + + RowLayout { + id: tx_power_layout + Layout.fillWidth: true + Layout.fillHeight: true + + Item{ // FILLER Layout.fillWidth: true - Layout.fillHeight: true - Text{ - text: "TX POWER" - font.bold: true - } - Text{ - Layout.preferredWidth: 120 - text: "AIR:\n "+get_text_wifi_tx_power(true) - verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignHCenter - font.bold: true - } - Button{ - text: "EDIT" - enabled: _ohdSystemAir.is_alive - onClicked: { - close_all_dialoques(); - popup_change_tx_power.m_is_air=true; - popup_change_tx_power.open() - } - } - Text{ - Layout.preferredWidth: 120 - text: "GND:\n"+get_text_wifi_tx_power(false) - verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignHCenter - font.bold: true + } + Text{ + Layout.preferredWidth: 120 + text: "AIR:\n "+get_text_wifi_tx_power(true) + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + Button{ + text: "EDIT" + enabled: _ohdSystemAir.is_alive + onClicked: { + close_all_dialoques(); + popup_change_tx_power.m_is_air=true; + popup_change_tx_power.open() } - Button{ - text: "EDIT" - enabled: _ohdSystemGround.is_alive - onClicked: { - close_all_dialoques(); - popup_change_tx_power.m_is_air=false; - popup_change_tx_power.open() - } + } + Text{ + Layout.preferredWidth: 120 + text: "GND:\n"+get_text_wifi_tx_power(false) + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + Button{ + text: "EDIT" + enabled: _ohdSystemGround.is_alive + onClicked: { + close_all_dialoques(); + popup_change_tx_power.m_is_air=false; + popup_change_tx_power.open() } } - } - Rectangle { - implicitWidth: main_scroll_view.width - implicitHeight: stbc_ldpc_layout.implicitHeight - id: stbc_ldpc_background - color: m_background_color - radius: 10 - - RowLayout { - id: stbc_ldpc_layout + Item{ // FILLER Layout.fillWidth: true - Layout.fillHeight: true - // STBC / LDPC - Text{ - width: 200 - text: "ADVANCED (STBC,LDPC)" - font.bold: true - horizontalAlignment: Qt.AlignHCenter - } - Text{ - Layout.preferredWidth: 120 - text: "AIR:\n"+get_text_stbc_ldpc(true); - verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignHCenter - font.bold: true - } - Text{ - Layout.preferredWidth: 120 - text: "GND:\n"+get_text_stbc_ldpc(false); - verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignHCenter - font.bold: true - } + } + } - Button{ - text: "EDIT"; - //enabled: true - enabled: _ohdSystemAir.is_alive && _ohdSystemGround.is_alive && (_wbLinkSettingsHelper.ui_rebuild_models>=0) && - (_ohdSystemGround.wb_stbc_enabled!=true || _ohdSystemGround.wb_lpdc_enabled!=true || _ohdSystemAir.wb_stbc_enabled!=true || _ohdSystemAir.wb_lpdc_enabled!=true); - onClicked: { - close_all_dialoques(); - popup_enable_stbc_ldpc.open() - } - } - ButtonIconInfo{ - Layout.row: 1 - Layout.column: 4 - onClicked: { - _messageBoxInstance.set_text_and_show("STBC / LDPC : Greatly increases range, but requires 2 RF paths (2 Antennas) on BOTH your air and ground station."+ - "WARNING: Enabling STBC with the wrong hardware (only 1 antenna / only one rf path) results in no connectivity "+ - "and you need to re-flash your air / ground unit to recover !"); - } + BaseHeaderItem{ + m_text: "ADVANCED (STBC,LDPC)" + } + + RowLayout { + id: stbc_ldpc_layout + Layout.fillWidth: true + Layout.fillHeight: true + Item{ // FILLER + Layout.fillWidth: true + } + Text{ + Layout.preferredWidth: 120 + text: "AIR:\n"+get_text_stbc_ldpc(true); + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + Text{ + Layout.preferredWidth: 120 + text: "GND:\n"+get_text_stbc_ldpc(false); + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + Button{ + text: "EDIT"; + //enabled: true + enabled: _ohdSystemAir.is_alive && _ohdSystemGround.is_alive && (_wbLinkSettingsHelper.ui_rebuild_models>=0) && + (_ohdSystemGround.wb_stbc_enabled!=true || _ohdSystemGround.wb_lpdc_enabled!=true || _ohdSystemAir.wb_stbc_enabled!=true || _ohdSystemAir.wb_lpdc_enabled!=true); + onClicked: { + close_all_dialoques(); + popup_enable_stbc_ldpc.open() } } + Item{ // FILLER + Layout.fillWidth: true + } + /*ButtonIconInfo{ + onClicked: { + _messageBoxInstance.set_text_and_show("STBC / LDPC : Greatly increases range, but requires 2 RF paths (2 Antennas) on BOTH your air and ground station."+ + "WARNING: Enabling STBC with the wrong hardware (only 1 antenna / only one rf path) results in no connectivity "+ + "and you need to re-flash your air / ground unit to recover !"); + } + }*/ } } } diff --git a/qml/ui/configpopup/openhd_settings/OpenHDQuickPanel.qml b/qml/ui/configpopup/openhd_settings/OpenHDQuickPanel.qml new file mode 100644 index 000000000..327fc3281 --- /dev/null +++ b/qml/ui/configpopup/openhd_settings/OpenHDQuickPanel.qml @@ -0,0 +1,353 @@ +import QtQuick 2.0 + +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Dialogs 1.0 +import QtQuick.Controls.Material 2.12 +import QtQuick.Controls.Styles 1.4 + +import Qt.labs.settings 1.0 + +import OpenHD 1.0 + +import "../../../ui" as Ui +import "../../elements" + +import QtCharts 2.0 + +// This is an extra screen for changing the frequency / channel width - +// They both need to match ! +Rectangle{ + id: main_background + width: parent.width + height: parent.height + //property color m_background_color: "#8cbfd7f3" + //property color m_background_color: "#ADD8E6" + property color m_background_color: "#8cbfd7f3" + + property int m_small_width: 200 + + function user_quidance_animate_channel_scan(){ + console.log("User guidance animate channel scan"); + anim_find_air_unit.start() + } + + // https://stackoverflow.com/questions/41991438/how-do-i-find-a-particular-listelement-inside-a-listmodel-in-qml + // For the models above (model with value) try to find the index of the first item where model[i].value===value + function find_index(model,value){ + for(var i = 0; i < model.count; ++i) if (model.get(i).value===value) return i + return -1 + } + + function fc_is_armed(){ + return _fcMavlinkSystem.armed + } + + ListModel{ + id: frequencies_model_all + ListElement {title: "Unknown"; value_frequency_mhz:-1} + } + ListModel{ + id: frequencies_model_openhd_channels_only + ListElement {title: "Unknown"; value_frequency_mhz:-1} + } + + function create_list_models_frequency(){ + frequencies_model_all.clear(); + const frequencies_all=_frequencyHelper.get_frequencies(false); + for(var i=0;i0){ + var index=find_index(comboBoxFreq.model,_wbLinkSettingsHelper.curr_channel_mhz); + if(index>=0){ + comboBoxFreq.currentIndex=index; + }else{ + comboBoxFreq.currentIndex=0; + console.log("Seems not to be a valid channel "+_wbLinkSettingsHelper.curr_channel_mhz) + } + }else{ + comboBoxFreq.currentIndex=-1; + } + } + + // We get notified every time we should re-build the model(s) and their current selection + property int m_ui_rebuild_models : _wbLinkSettingsHelper.ui_rebuild_models + onM_ui_rebuild_modelsChanged: { + console.log(" onM_ui_rebuild_modelsChanged: "+_wbLinkSettingsHelper.ui_rebuild_models); + function_rebuild_ui() + } + + function function_rebuild_ui(){ + update_frequency_combobox(); + console.log("function_rebuild_ui:"+_wbLinkSettingsHelper.ui_rebuild_models); + if(_wbLinkSettingsHelper.ui_rebuild_models<=0)return + popup_analyze_channels.update(); + } + + // + function close_all_dialoques(){ + popup_analyze_channels.close() + popup_scan_channels.close(); + popup_change_tx_power.close(); + dialoqueFreqChangeGndOnly.close(); + dialoqueFreqChangeAirGnd.close(); + popup_enable_stbc_ldpc.close(); + } + + function get_text_stbc_ldpc(air){ + if(air){ + if(!_ohdSystemAir.is_alive)return "N/A"; + return ""+(_ohdSystemAir.wb_stbc_enabled ? "YES" : "NO")+"/"+(_ohdSystemAir.wb_lpdc_enabled ? "YES" : "NO"); + } + if(!_ohdSystemGround.is_alive)return "N/A"; + return ""+(_ohdSystemGround.wb_stbc_enabled ? "YES" : "NO")+"/"+(_ohdSystemGround.wb_lpdc_enabled ? "YES" : "NO"); + } + + Component.onCompleted: { + close_all_dialoques(); + create_list_models_frequency(); + update_frequency_combobox(); + } + + function get_text_wifi_tx_power(air){ + if(air){ + if(!_wifi_card_air.alive) return "N/A"; + return ""+_wifi_card_air.tx_power+" "+_wifi_card_air.tx_power_unit; + } + if(!_wifi_card_gnd0.alive) return "N/A"; + return ""+_wifi_card_gnd0.tx_power+" "+_wifi_card_gnd0.tx_power_unit; + } + + ScrollView { + id: main_scroll_view + width: parent.width + height: parent.height + anchors.centerIn: parent + contentHeight: main_column_layout.height + //contentWidth: main_column_layout.width + //ScrollBar.vertical.policy: ScrollBar.AlwaysOn + ScrollBar.vertical.interactive: true + visible: (!popup_analyze_channels.visible && !popup_enable_stbc_ldpc.visible && !popup_change_tx_power.visible && !popup_scan_channels.visible) + + + Column{ + spacing: 0 + anchors.left: parent.left + anchors.right: parent.right + id: main_colum_layout + Text{ + width: parent.width + height: rowHeight + text: "FREQUENCY / TOOLKIT" + font.bold: true + horizontalAlignment: Qt.AlignHCenter + verticalAlignment: Qt.AlignVCenter + } + Row{ + width: parent.width + height: rowHeight + ComboBox { + id: comboBoxFreq + //model: supported_frequencies_model + //model: frequencies_model_openhd_channels_only + textRole: "title" + implicitWidth: elementComboBoxWidth + currentIndex: 0 + delegate: ItemDelegate { + width: comboBoxFreq.width + contentItem: FreqComboBoxRow{ + m_main_text: title + m_selection_tpye: (value_frequency_mhz===_wbLinkSettingsHelper.curr_channel_mhz) ? 1 : 0 + m_is_2G: value_frequency_mhz < 3000 && value_frequency_mhz > 100 + m_show_radar: _frequencyHelper.get_frequency_radar(value_frequency_mhz) + m_openhd_race_band: _frequencyHelper.get_frequency_openhd_race_band(value_frequency_mhz) + m_pollution_pps: _pollutionHelper.pollution_get_last_scan_pollution_for_frequency(value_frequency_mhz) + } + highlighted: comboBoxFreq.highlightedIndex === index + } + Layout.row: 1 + Layout.column: 0 + displayText: { + if(!_ohdSystemGround.is_alive)return "GND NOT ALIVE"; + if(_ohdSystemGround.wb_gnd_operating_mode==1){ + return "SCANNING"; + } + if(_ohdSystemGround.wb_gnd_operating_mode==2){ + return "ANALYZING"; + } + if(!_ohdSystemAir.is_alive){ + return _wbLinkSettingsHelper.curr_channel_mhz+"@"+"N/A"+" Mhz (NO AIR)"; + } + return _wbLinkSettingsHelper.curr_channel_mhz+"@"+_wbLinkSettingsHelper.curr_channel_width_mhz+" Mhz"; + } + onActivated: { + console.log("onActivated:"+currentIndex); + if(currentIndex<0)return; + const frequency_mhz=comboBoxFreq.model.get(currentIndex).value_frequency_mhz + console.log("Selected frequency: "+frequency_mhz); + if(!_frequencyHelper.hw_supports_frequency_threadsafe(frequency_mhz)){ + _qopenhd.show_toast("your HW does not support "+frequency_mhz+" Mhz"); + return; + } + if(_wbLinkSettingsHelper.curr_channel_mhz==frequency_mhz){ + console.log("Already at frequency "+frequency_mhz); + return; + } + if(!_ohdSystemAir.is_alive){ + var error_message_not_alive="AIR Unit not alive -" + dialoqueFreqChangeGndOnly.initialize_and_show_frequency(frequency_mhz,error_message_not_alive); + return; + } + // Change the freuquency + dialoqueFreqChangeAirGnd.initialize_and_show_frequency(frequency_mhz); + } + enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0; + } + Switch{ + Layout.row: 1 + Layout.column: 1 + Layout.columnSpan: 1 + text: "SIMPLIFY" + checked: true + onCheckedChanged: { + if(m_simplify_enable!=checked){ + m_simplify_enable=checked; + function_rebuild_ui(); + } + } + } + } + Row{ + width: parent.width + height: rowHeight + Button{ + Layout.preferredWidth: 150 + id: b_find_air_unit + text: "SCAN" + enabled: _ohdSystemGround.is_alive + onClicked: { + close_all_dialoques(); + popup_scan_channels.open() + } + SequentialAnimation { + running: false + loops: 4 + id: anim_find_air_unit + // Expand the button + PropertyAnimation { + target: b_find_air_unit + property: "scale" + to: 1.5 + duration: 200 + easing.type: Easing.InOutQuad + } + // Shrink back to normal + PropertyAnimation { + target: b_find_air_unit + property: "scale" + to: 1.0 + duration: 200 + easing.type: Easing.InOutQuad + } + } + } + Button{ + Layout.preferredWidth: 150 + text: "ANALYZE" + enabled: _ohdSystemGround.is_alive + onClicked: { + close_all_dialoques(); + popup_analyze_channels.open() + } + } + } + Text{ + width: parent.width + height: rowHeight + text: "TX POWER" + font.bold: true + horizontalAlignment: Qt.AlignHCenter + verticalAlignment: Qt.AlignVCenter + } + Row{ + width: parent.width + height: rowHeight + Text{ + Layout.preferredWidth: 120 + text: "AIR:\n "+get_text_wifi_tx_power(true) + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + Button{ + text: "EDIT" + enabled: _ohdSystemAir.is_alive + onClicked: { + close_all_dialoques(); + popup_change_tx_power.m_is_air=true; + popup_change_tx_power.open() + } + } + Text{ + Layout.preferredWidth: 120 + text: "GND:\n"+get_text_wifi_tx_power(false) + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + Button{ + text: "EDIT" + enabled: _ohdSystemGround.is_alive + onClicked: { + close_all_dialoques(); + popup_change_tx_power.m_is_air=false; + popup_change_tx_power.open() + } + } + } + + } + } + + PopupAnalyzeChannels{ + id: popup_analyze_channels + } + + PopupScanChannels{ + id: popup_scan_channels + } + + PopupTxPowerEditor{ + id: popup_change_tx_power + } + PopupEnableSTBCLDPC{ + id: popup_enable_stbc_ldpc + } + + DialoqueFreqChangeGndOnly{ + id: dialoqueFreqChangeGndOnly + } + DialoqueFreqChangeAirGnd{ + id: dialoqueFreqChangeAirGnd + } +} diff --git a/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml b/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml index 223fa488f..ce1887729 100644 --- a/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml +++ b/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml @@ -29,7 +29,7 @@ Rectangle{ property bool m_normalize_data: false; property int m_chart_view_minimum_width: 1280; - property int m_chart_view_minimum_width2: 640; + property int m_chart_view_minimum_width2: 1280; property bool m_chart_enlarged: false; diff --git a/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml b/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml index 2106a5856..763f0256e 100644 --- a/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml +++ b/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml @@ -29,6 +29,8 @@ Rectangle{ property bool m_is_air: false property int m_user_selected_card_manufacturer: -1; + property int left_text_minimum_width: 100 + property int left_text_preferred_width: 100 function open(){ if(_fcMavlinkSystem.is_alive && _fcMavlinkSystem.armed){ @@ -39,6 +41,11 @@ Rectangle{ _messageBoxInstance.set_text_and_show("Changing tx power is only possible on openhd supported cards."); return; } + // The user has to enter the card type every time - otherwise, we have issues with air and ground + comboBoxCardSelectManufacturer.currentIndex=0; + combo_box_txpower_disarmed.currentIndex=0; + combo_box_txpower_armed.currentIndex=0; + m_user_selected_card_manufacturer=-1; visible=true; enabled=true; } @@ -67,7 +74,7 @@ Rectangle{ // Should never show up ! ListModel{ id: model_error - ListElement {title: "ERROR"; value: -1} + ListElement {title: "PLEASE SELECT MANUFACTURER"; value: -1} } ListModel{ @@ -216,7 +223,7 @@ Rectangle{ return _wifi_card_gnd0.tx_power_unit; } - GridLayout{ + ColumnLayout{ id: main_row_layout anchors.fill: parent anchors.leftMargin: m_margin @@ -229,9 +236,6 @@ Rectangle{ //Layout.preferredWidth: 600 Item{ - Layout.row: 0 - Layout.column: 0 - Layout.columnSpan: 4 Layout.fillWidth: true Layout.preferredHeight: 80 Text{ // TITLE @@ -251,156 +255,148 @@ Rectangle{ } } } - // - Text{ - Layout.row: 1 - Layout.column: 0 - text: "RF CHIP:\n" +get_card_chipset_str() - horizontalAlignment: Qt.AlignHCenter - font.pixelSize: 14 - } - ComboBox { - Layout.row: 1 - Layout.column: 1 - id: comboBoxCardSelectManufacturer - Layout.minimumWidth: 100 - Layout.preferredWidth: 350 - model: get_model_manufacturer_for_chip_type() - textRole: "title" - onCurrentIndexChanged: { - var manufacturer=comboBoxCardSelectManufacturer.model.get(comboBoxCardSelectManufacturer.currentIndex).value; - m_user_selected_card_manufacturer=manufacturer; - } - font.pixelSize: 14 - } - // FILLER - Item{ - Layout.row: 1 - Layout.column: 3 - Layout.fillWidth: true - } - // ---------------- - Text{ - Layout.row: 2 - Layout.column: 0 - text: "DISARMED:\n"+get_current_tx_power_int(1)+" "+get_tx_power_unit(); + RowLayout{ Layout.fillWidth: true - horizontalAlignment: Qt.AlignHCenter - font.pixelSize: 14 + Text{ + Layout.minimumWidth: left_text_minimum_width + Layout.preferredWidth: left_text_preferred_width + text: "RF CHIP:\n" +get_card_chipset_str() + horizontalAlignment: Qt.AlignHCenter + font.pixelSize: 14 + } + ComboBox { + id: comboBoxCardSelectManufacturer + Layout.minimumWidth: 100 + Layout.preferredWidth: 350 + model: get_model_manufacturer_for_chip_type() + textRole: "title" + onCurrentIndexChanged: { + var manufacturer=comboBoxCardSelectManufacturer.model.get(comboBoxCardSelectManufacturer.currentIndex).value; + m_user_selected_card_manufacturer=manufacturer; + } + font.pixelSize: 14 + } + // FILLER + Item{ + Layout.fillWidth: true + } } - ComboBox { - Layout.row: 2 - Layout.column: 1 + RowLayout{ Layout.fillWidth: true - Layout.minimumWidth: 100 - Layout.preferredWidth: 350 - id: combo_box_txpower_disarmed - model: get_model_txpower_for_chip_type_manufacturer(false) - textRole: "title" - enabled: m_user_selected_card_manufacturer>=0; - font.pixelSize: 14 - } - Button{ - Layout.row: 2 - Layout.column: 2 - text: "SAVE" - enabled: m_user_selected_card_manufacturer>=0; - onClicked: { - var tx_power_index_or_mw = combo_box_txpower_disarmed.model.get(combo_box_txpower_disarmed.currentIndex).value; - if(tx_power_index_or_mw<0){ - _qopenhd.show_toast("Please select a valid tx power",false); - return; + Text{ + Layout.minimumWidth: left_text_minimum_width + Layout.preferredWidth: left_text_preferred_width + text: "DISARMED:\n"+get_current_tx_power_int(1)+" "+get_tx_power_unit(); + horizontalAlignment: Qt.AlignHCenter + font.pixelSize: 14 + } + ComboBox { + Layout.minimumWidth: 100 + Layout.preferredWidth: 350 + id: combo_box_txpower_disarmed + model: get_model_txpower_for_chip_type_manufacturer(false) + textRole: "title" + enabled: m_user_selected_card_manufacturer>=0; + font.pixelSize: 14 + onActivated: { + console.log("onActivated: index:"+currentIndex+ " level:"+currentValue); } - var is_tx_power_index_unit = get_chipset_type()==0; - var success = _wbLinkSettingsHelper.set_param_tx_power(!m_is_air,is_tx_power_index_unit,false,tx_power_index_or_mw) - if(success==true){ - _qopenhd.show_toast("SUCCESS"); - }else{ - _qopenhd.show_toast("Cannot change TX power, please try again",true); + } + Button{ + text: "SAVE" + enabled: m_user_selected_card_manufacturer>=0; + onClicked: { + var tx_power_index_or_mw = combo_box_txpower_disarmed.model.get(combo_box_txpower_disarmed.currentIndex).value; + if(tx_power_index_or_mw<0){ + _qopenhd.show_toast("Please select a valid tx power",false); + return; + } + var is_tx_power_index_unit = get_chipset_type()==0; + var success = _wbLinkSettingsHelper.set_param_tx_power(!m_is_air,is_tx_power_index_unit,false,tx_power_index_or_mw) + if(success==true){ + _qopenhd.show_toast("SUCCESS"); + }else{ + _qopenhd.show_toast("Cannot change TX power, please try again",true); + } } + font.pixelSize: 14 } - font.pixelSize: 14 - } - ButtonIconInfo{ - Layout.row: 2 - Layout.column: 3 - onClicked: { - _messageBoxInstance.set_text_and_show("TX Power applied when FC is disarmed"); + ButtonIconInfo{ + onClicked: { + _messageBoxInstance.set_text_and_show("TX Power applied when FC is disarmed"); + } } - } - - // FILLER - Item{ - Layout.row: 2 - Layout.column: 4 - Layout.fillWidth: true - } - // ---------------- - Text{ - Layout.row: 3 - Layout.column: 0 - text: { - var power_int=get_current_tx_power_int(2); - if(power_int==0) return "ARMED:\nDISABLED"; - return "ARMED:\n"+get_current_tx_power_int(2)+" "+get_tx_power_unit(); + // FILLER + Item{ + Layout.fillWidth: true } - Layout.fillWidth: true - horizontalAlignment: Qt.AlignHCenter - font.pixelSize: 14 } - ComboBox { - Layout.row: 3 - Layout.column: 1 + + RowLayout{ Layout.fillWidth: true - Layout.minimumWidth: 100 - Layout.preferredWidth: 350 - id: combo_box_txpower_armed - model: get_model_txpower_for_chip_type_manufacturer(true) - textRole: "title" - enabled: m_user_selected_card_manufacturer>=0; - font.pixelSize: 14 - } - Button{ - Layout.row: 3 - Layout.column: 2 - text: "SAVE" - enabled: m_user_selected_card_manufacturer>=0; - onClicked: { - var tx_power_index_or_mw = combo_box_txpower_armed.model.get(combo_box_txpower_armed.currentIndex).value; - if(tx_power_index_or_mw<0){ - _qopenhd.show_toast("Please select a valid tx power",false); - return; + Text{ + Layout.minimumWidth: left_text_minimum_width + Layout.preferredWidth: left_text_preferred_width + text: { + var power_int=get_current_tx_power_int(2); + if(power_int==0) return "ARMED:\nDISABLED"; + return "ARMED:\n"+get_current_tx_power_int(2)+" "+get_tx_power_unit(); } - var is_tx_power_index_unit = get_chipset_type()==0; - var success = _wbLinkSettingsHelper.set_param_tx_power(!m_is_air,is_tx_power_index_unit,true,tx_power_index_or_mw) - if(success==true){ - _qopenhd.show_toast("SUCCESS"); - }else{ - _qopenhd.show_toast("Cannot change TX power, please try again",true); + horizontalAlignment: Qt.AlignHCenter + font.pixelSize: 14 + } + ComboBox { + Layout.minimumWidth: 100 + Layout.preferredWidth: 350 + id: combo_box_txpower_armed + model: get_model_txpower_for_chip_type_manufacturer(true) + textRole: "title" + enabled: m_user_selected_card_manufacturer>=0; + font.pixelSize: 14 + } + Button{ + text: "SAVE" + enabled: m_user_selected_card_manufacturer>=0; + onClicked: { + var tx_power_index_or_mw = combo_box_txpower_armed.model.get(combo_box_txpower_armed.currentIndex).value; + if(tx_power_index_or_mw<0){ + _qopenhd.show_toast("Please select a valid tx power",false); + return; + } + var is_tx_power_index_unit = get_chipset_type()==0; + var success = _wbLinkSettingsHelper.set_param_tx_power(!m_is_air,is_tx_power_index_unit,true,tx_power_index_or_mw) + if(success==true){ + _qopenhd.show_toast("SUCCESS"); + }else{ + _qopenhd.show_toast("Cannot change TX power, please try again",true); + } } + font.pixelSize: 14 } - font.pixelSize: 14 - } - ButtonIconInfo{ - Layout.row: 3 - Layout.column: 3 - onClicked: { - _messageBoxInstance.set_text_and_show("TX Power applied when FC is armed. By default, set to 0 (DISABLE) which means the same tx power (tx power disarmed) is applied regardless"+ - "if armed or not."); + ButtonIconInfo{ + onClicked: { + _messageBoxInstance.set_text_and_show("TX Power applied when FC is armed. By default, set to 0 (DISABLE) which means the same tx power (tx power disarmed) is applied regardless"+ + "if armed or not."); + } } } + Text{ - Layout.row: 4 - Layout.column: 0 - text: "CURRENT:\n"+get_current_tx_power_int(0)+" "+get_tx_power_unit(); + Layout.fillWidth: true + Layout.minimumHeight: 50 + text: "WARNING: Selecting the wrong manufacturer and applying a tx power\n can destroy your card !\n"; + color: "red" + //style: Text.Outline + //styleColor: "black" + wrapMode: Text.WordWrap + font.pixelSize: 18 + verticalAlignment: Qt.AlignVCenter horizontalAlignment: Qt.AlignHCenter - font.pixelSize: 14 } Text{ - Layout.row: 4 - Layout.column: 1 - Layout.columnSpan: 2 + Layout.fillWidth: true text: "WARNING: ARMING WILL REDUCE YOUR TX POWER" + //visible: true visible: { var txpower_disarmed=get_current_tx_power_int(1); var txpower_armed=get_current_tx_power_int(2); @@ -408,22 +404,13 @@ Rectangle{ return txpower_armed