From e97c54374bca1e66e79c9cc7cfe20d6c70eeb3a4 Mon Sep 17 00:00:00 2001 From: Raphael <68374617+raphaelscholle@users.noreply.github.com> Date: Sun, 24 Nov 2024 23:18:53 +0100 Subject: [PATCH] A few sidebar fixes --- app/telemetry/models/camerastreammodel.cpp | 6 +- app/telemetry/settings/frequencyhelper.cpp | 58 ++++++++++++++++++- app/telemetry/settings/frequencyhelper.h | 1 + app/telemetry/settings/wifi_channel.h | 4 ++ .../DialoqueFreqChangeAirGnd.qml | 1 + .../openhd_settings/FreqComboBoxRow.qml | 2 + .../openhd_settings/LinkQuickPanel.qml | 35 ++++++----- qml/ui/sidebar/MavlinkChoiceElement.qml | 12 +--- qml/ui/sidebar/MavlinkChoiceElement2.qml | 25 ++------ qml/ui/sidebar/Panel4Recording.qml | 2 +- 10 files changed, 96 insertions(+), 50 deletions(-) diff --git a/app/telemetry/models/camerastreammodel.cpp b/app/telemetry/models/camerastreammodel.cpp index 9bcd1658a..d56ab56c5 100644 --- a/app/telemetry/models/camerastreammodel.cpp +++ b/app/telemetry/models/camerastreammodel.cpp @@ -63,9 +63,9 @@ QString CameraStreamModel::camera_codec_to_string(int camera_codec) QString CameraStreamModel::camera_recording_mode_to_string(int recording_mode) { - if(recording_mode<0)return "n/a"; - if(recording_mode==0)return "not active"; - if(recording_mode==1)return "active"; + if(recording_mode<0)return " n/a"; + if(recording_mode==0)return " off"; + if(recording_mode==1)return " on"; return "error"; } diff --git a/app/telemetry/settings/frequencyhelper.cpp b/app/telemetry/settings/frequencyhelper.cpp index 582538656..90ae7ca97 100644 --- a/app/telemetry/settings/frequencyhelper.cpp +++ b/app/telemetry/settings/frequencyhelper.cpp @@ -20,6 +20,11 @@ QList FrequencyHelper::get_frequencies(int filter) for(auto& channel:tmp){ ret.push_back(channel.frequency); } + }else if(filter==3){ + auto tmp=openhd::get_openhd_channels_licensed(); + for(auto& channel:tmp){ + ret.push_back(channel.frequency); + } }else{ const auto frequency_items=openhd::get_all_channels_2G_5G(); for(auto& item:frequency_items){ @@ -29,7 +34,7 @@ QList FrequencyHelper::get_frequencies(int filter) ret.push_back(item.frequency); } }else{ - if(item.frequency>3000){ + if(item.frequency>=5180 && item.frequency<=5865){ ret.push_back(item.frequency); } } @@ -107,6 +112,57 @@ int FrequencyHelper::get_frequency_openhd_race_band(int frequency_mhz) } return -1; } +int FrequencyHelper::get_frequency_openhd_licensed_band(int frequency_mhz) +{ + // Frequencies: 5080,5100,5120,5140,5160,5905,5925,5945,5965,5985,6005,6025,6045,6065,6085 + if(frequency_mhz==5080){ + return 1; + } + if(frequency_mhz==5100){ + return 2; + } + if(frequency_mhz==5120){ + return 3; + } + if(frequency_mhz==5140){ + return 4; + } + if(frequency_mhz==5160){ + return 5; + } + if(frequency_mhz==5905){ + return 6; + } + if(frequency_mhz==5925){ + return 7; + } + if(frequency_mhz==5945){ + return 8; + } + if(frequency_mhz==5965){ + return 9; + } + if(frequency_mhz==5985){ + return 10; + } + if(frequency_mhz==6005){ + return 11; + } + if(frequency_mhz==6025){ + return 12; + } + if(frequency_mhz==6045){ + return 13; + } + if(frequency_mhz==6065){ + return 14; + } + if(frequency_mhz==6085){ + return 15; + } + return -1; +} + int FrequencyHelper::get_frequency_channel_nr(int frequency_mhz) { diff --git a/app/telemetry/settings/frequencyhelper.h b/app/telemetry/settings/frequencyhelper.h index 6bcf385ec..71b18f39a 100644 --- a/app/telemetry/settings/frequencyhelper.h +++ b/app/telemetry/settings/frequencyhelper.h @@ -22,6 +22,7 @@ class FrequencyHelper : public QObject Q_INVOKABLE bool get_frequency_radar(int frequency_mhz); Q_INVOKABLE int get_frequency_openhd_race_band(int frequency_mhz); + Q_INVOKABLE int get_frequency_openhd_licensed_band(int frequency_mhz); Q_INVOKABLE int get_frequency_channel_nr(int frequency_mhz); // -------------- Q_INVOKABLE bool hw_supports_frequency_threadsafe(int frequency_mhz); diff --git a/app/telemetry/settings/wifi_channel.h b/app/telemetry/settings/wifi_channel.h index 73bd1c8b8..2acb6c3d4 100644 --- a/app/telemetry/settings/wifi_channel.h +++ b/app/telemetry/settings/wifi_channel.h @@ -282,6 +282,10 @@ static std::vector get_openhd_channels_1_to_7() { std::vector frequencies = {5700, 5745, 5785, 5825, 5865, 5260, 5280}; return frequencies_to_channels(frequencies); } +static std::vector get_openhd_channels_licensed() { + std::vector frequencies = {5080,5100,5120,5140,5160,5905,5925,5945,5965,5985,6005,6025,6045,6065,6085}; + return frequencies_to_channels(frequencies); +} static std::vector filter_ht40plus_only( const std::vector& frequencies) { diff --git a/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeAirGnd.qml b/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeAirGnd.qml index a4b7b4d85..0ed34532e 100644 --- a/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeAirGnd.qml +++ b/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeAirGnd.qml @@ -46,6 +46,7 @@ Card { function get_card_body_string(){ const channel_nr=_frequencyHelper.get_frequency_channel_nr(m_wanted_frequency); const channel_nr_openhd=_frequencyHelper.get_frequency_openhd_race_band(m_wanted_frequency); + const channel_nr_openhd_licensed=_frequencyHelper.get_frequency_openhd_licensed_band(m_wanted_frequency); return "Set AIR and GROUND to CHANNEL ["+channel_nr+"]\n"+ "("+m_wanted_frequency+" Mhz) ?"; diff --git a/qml/ui/configpopup/openhd_settings/FreqComboBoxRow.qml b/qml/ui/configpopup/openhd_settings/FreqComboBoxRow.qml index b4eb997ad..d52a0da0e 100644 --- a/qml/ui/configpopup/openhd_settings/FreqComboBoxRow.qml +++ b/qml/ui/configpopup/openhd_settings/FreqComboBoxRow.qml @@ -27,6 +27,8 @@ Rectangle{ property bool m_show_radar: false property int m_openhd_race_band: -1 + property int m_openhd_licensed_band: -1 + property int m_pollution_pps: -1 diff --git a/qml/ui/configpopup/openhd_settings/LinkQuickPanel.qml b/qml/ui/configpopup/openhd_settings/LinkQuickPanel.qml index 247c1a9fb..fd8f43ee5 100644 --- a/qml/ui/configpopup/openhd_settings/LinkQuickPanel.qml +++ b/qml/ui/configpopup/openhd_settings/LinkQuickPanel.qml @@ -5,7 +5,7 @@ import QtQuick.Controls 2.12 import QtQuick.Layouts 1.12 import QtQuick.Controls.Material 2.12 - + import Qt.labs.settings 1.0 @@ -166,6 +166,7 @@ Rectangle{ 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_openhd_licensed_band: _frequencyHelper.get_frequency_openhd_licensed_band(value_frequency_mhz) m_pollution_pps: _pollutionHelper.pollution_get_last_scan_pollution_for_frequency(value_frequency_mhz) } highlighted: comboBoxFreq.highlightedIndex === index @@ -206,40 +207,42 @@ Rectangle{ } enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0; } - TabBar{ + TabBar { id: filter_tab_bar - width: 200 + width: 350 currentIndex: settings.qopenhd_frequency_filter_selection onCurrentIndexChanged: { - if(currentIndex!=settings.qopenhd_frequency_filter_selection){ - settings.qopenhd_frequency_filter_selection=currentIndex; + if (currentIndex != settings.qopenhd_frequency_filter_selection) { + settings.qopenhd_frequency_filter_selection = currentIndex; + console.log("Tab changed to index:", 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 !") - } } } - TabButton{ - text: "DEF" + TabButton { + text: "OpenHD" + font.capitalization: Font.MixedCase } - TabButton{ + TabButton { text: "2.4G" enabled: { - if(_ohdSystemAir.is_alive && _ohdSystemAir.ohd_platform_type==30){ + if (_ohdSystemAir.is_alive && _ohdSystemAir.ohd_platform_type == 30) { // X20 does not support 2.4G return false; } return true; - } } - TabButton{ + TabButton { text: "5.8G" } enabled: comboBoxFreq.enabled + TabButton { + text: "Custom" + font.capitalization: Font.MixedCase + visible: settings.dev_show_5180mhz_lowband + } } + /*ButtonIconInfo2{ Layout.alignment: Qt.AlignRight visible:false diff --git a/qml/ui/sidebar/MavlinkChoiceElement.qml b/qml/ui/sidebar/MavlinkChoiceElement.qml index 3f483efcc..161167490 100644 --- a/qml/ui/sidebar/MavlinkChoiceElement.qml +++ b/qml/ui/sidebar/MavlinkChoiceElement.qml @@ -26,13 +26,7 @@ BaseJoyEditElement{ property var m_settings_model: _ohdSystemGroundSettings // Int param is much more common, but string param is also possible property bool override_takes_string_param: false - ListModel{ - id: elements_frequency_scan - ListElement {value: 0; verbose:"OHD"} - ListElement {value: 1; verbose:"5.8"} - ListElement {value: 2; verbose:"2.4"} - ListElement {value: 3; verbose:"ALL"} - } + ListModel{ id: elements_model_brightness ListElement {value: 0; verbose:"0%"} @@ -97,7 +91,7 @@ BaseJoyEditElement{ id: elements_model_air_recording ListElement {value: 0; verbose:"ALWAYS\nOFF"} ListElement {value: 1; verbose:"ALWAYS\nON"} - ListElement {value: 2; verbose:"AUTO\n(WHEN ARMED)"} + ListElement {value: 2; verbose:"AUTO\n(WHEN ARMED)"} } ListModel{ id: elements_model_hotspot @@ -156,8 +150,6 @@ BaseJoyEditElement{ property string m_actual_value_string: "" function get_model(){ - }else if(param_id=="FREQUENCY_SCAN"){ - return elements_frequency_scan; if(m_param_id=="BRIGHTNESS"){ return elements_model_brightness; }else if(m_param_id=="SATURATION"){ diff --git a/qml/ui/sidebar/MavlinkChoiceElement2.qml b/qml/ui/sidebar/MavlinkChoiceElement2.qml index de01fb4e5..bdfab8f9d 100644 --- a/qml/ui/sidebar/MavlinkChoiceElement2.qml +++ b/qml/ui/sidebar/MavlinkChoiceElement2.qml @@ -35,7 +35,6 @@ BaseJoyEditElement2{ // EXTRA property string mPARAM_ID_CHANNEL_WIDTH: "CHANNEL_WIDTH" property string mPARAM_ID_FREQUENCY: "FREQUENCY" - property string mPARAM_ID_FREQUENCY_SCAN: "FREQUENCY_SCAN" property string mPARAM_ID_RATE: "RATE" @@ -120,7 +119,8 @@ BaseJoyEditElement2{ property string populate_display_text:"I SHOULD NEVER APPEAR" function populate(){ - if(m_param_id==mPARAM_ID_CHANNEL_WIDTH || m_param_id==mPARAM_ID_FREQUENCY || mPARAM_ID_FREQUENCY_SCAN || m_param_id==mPARAM_ID_RATE){ + // Don't mind those 3 + if(m_param_id==mPARAM_ID_CHANNEL_WIDTH || m_param_id==mPARAM_ID_FREQUENCY || m_param_id==mPARAM_ID_RATE){ return; } // First, check if the system is alive @@ -189,7 +189,7 @@ BaseJoyEditElement2{ function user_selected_value(value_new){ // A few need to be handled specially - if(m_param_id==mPARAM_ID_FREQUENCY || m_param_id==mPARAM_ID_FREQUENCY_SCAN){ + if(m_param_id==mPARAM_ID_FREQUENCY){ if(_fcMavlinkSystem.armed){ if(settings.dev_allow_freq_change_when_armed){ // okay @@ -204,11 +204,6 @@ BaseJoyEditElement2{ _qopenhd.set_busy_for_milliseconds(2000,"CHANGING FREQUENCY"); _wbLinkSettingsHelper.change_param_air_and_ground_frequency(value_new) return; - }else if(m_param_id==mPARAM_ID_FREQUENCY_SCAN){ - const frequency_scan=value_new; - _qopenhd.set_busy_for_milliseconds(2000,"Starting scan"); - //PLATZHALTER - return; }else if(m_param_id==mPARAM_ID_CHANNEL_WIDTH){ const channel_width_mhz=value_new; if(!_ohdSystemAir.is_alive){ @@ -247,13 +242,8 @@ BaseJoyEditElement2{ onCurr_bandwidth_mhzChanged: { extra_populate(); } - property bool curr_frequency_scan: (_ohdSystemGround.wb_gnd_operating_mode == 0) - onCurr_frequency_scanChanged: { - extra_populate(); - } - function extra_populate(){ - if(!(m_param_id==mPARAM_ID_CHANNEL_WIDTH || m_param_id==mPARAM_ID_FREQUENCY || mPARAM_ID_FREQUENCY_SCAN || m_param_id==mPARAM_ID_RATE )){ + if(!(m_param_id==mPARAM_ID_CHANNEL_WIDTH || m_param_id==mPARAM_ID_FREQUENCY || m_param_id==mPARAM_ID_RATE)){ return; } // First, check if the system is alive @@ -263,10 +253,6 @@ BaseJoyEditElement2{ populate_display_text="N/A"; return; } - if(m_param_id==mPARAM_ID_FREQUENCY_SCAN){ - populate_display_text="Debug"; - return; - } if(m_param_id==mPARAM_ID_FREQUENCY){ if(curr_channel_mhz<=0){ m_param_exists=false; @@ -293,4 +279,5 @@ BaseJoyEditElement2{ m_param_exists=true; } } -} \ No newline at end of file + +} diff --git a/qml/ui/sidebar/Panel4Recording.qml b/qml/ui/sidebar/Panel4Recording.qml index 6ac267790..ea69a5305 100644 --- a/qml/ui/sidebar/Panel4Recording.qml +++ b/qml/ui/sidebar/Panel4Recording.qml @@ -51,7 +51,7 @@ SideBarBasePanel { anchors.centerIn: parent anchors.leftMargin: 40 text: { - var tmp = " Status"; + var tmp = " Status"; if (!_ohdSystemAir.is_alive) { return tmp + " disabled "; }