From 2145e31bd507d393d9f836256825bc5986104ddd Mon Sep 17 00:00:00 2001 From: consti10 Date: Fri, 3 Nov 2023 01:17:32 +0100 Subject: [PATCH] Improve UI: 1) More consistent layouting for the (SCAN,ANALYZE,STBC,TX POWER) elements 2) Analyze progress 3) refactor out the qopenhd frequency list --- app/main.cpp | 4 + app/telemetry/settings/frequencyhelper.cpp | 203 ++++--- app/telemetry/settings/frequencyhelper.h | 39 +- app/telemetry/settings/pollutionhelper.cpp | 42 +- app/telemetry/settings/pollutionhelper.h | 13 +- .../settings/wblinksettingshelper.cpp | 144 +---- app/telemetry/settings/wblinksettingshelper.h | 25 - app/telemetry/settings/wifi_channel.h | 252 +++++++++ app/telemetry/telemetry.pri | 1 + qml/qml.qrc | 20 +- .../DialoqueFreqChangeAirGnd.qml | 124 ++++ .../DialoqueFreqChangeArmed.qml | 86 --- .../DialoqueFreqChangeGndOnly.qml | 2 +- .../MavlinkOpenHDWBParamPanel.qml | 528 ++++++++---------- .../openhd_settings/PopupAnalyzeChannels.qml | 278 +++++---- .../openhd_settings/PopupEnableSTBCLDPC.qml | 105 ++-- .../openhd_settings/PopupScanChannels.qml | 135 ++--- .../openhd_settings/PopupTxPowerEditor.qml | 39 +- 18 files changed, 1105 insertions(+), 935 deletions(-) create mode 100644 app/telemetry/settings/wifi_channel.h create mode 100644 qml/ui/configpopup/openhd_settings/DialoqueFreqChangeAirGnd.qml delete mode 100644 qml/ui/configpopup/openhd_settings/DialoqueFreqChangeArmed.qml diff --git a/app/main.cpp b/app/main.cpp index 38baed1f7..95fedff4a 100755 --- a/app/main.cpp +++ b/app/main.cpp @@ -26,6 +26,8 @@ const QVector permissions({"android.permission.INTERNET", #include "telemetry/models/rcchannelsmodel.h" #include "telemetry/settings/mavlinksettingsmodel.h" #include "telemetry/settings/wblinksettingshelper.h" +#include "telemetry/settings/frequencyhelper.h" +#include "telemetry/settings/pollutionhelper.h" #include "osd/speedladder.h" #include "osd/altitudeladder.h" #include "osd/headingladder.h" @@ -282,6 +284,8 @@ int main(int argc, char *argv[]) { engine.rootContext()->setContextProperty("_ohdSystemAirSettingsModel", &MavlinkSettingsModel::instanceAir()); engine.rootContext()->setContextProperty("_ohdSystemGroundSettings", &MavlinkSettingsModel::instanceGround()); engine.rootContext()->setContextProperty("_wbLinkSettingsHelper", &WBLinkSettingsHelper::instance()); + engine.rootContext()->setContextProperty("_frequencyHelper", &FrequencyHelper::instance()); + engine.rootContext()->setContextProperty("_pollutionHelper", &PollutionHelper::instance()); engine.rootContext()->setContextProperty("_fcMavlinkSystem", &FCMavlinkSystem::instance()); engine.rootContext()->setContextProperty("_fcMavlinkAction", &FCAction::instance()); engine.rootContext()->setContextProperty("_fcMavlinkMissionItemsModel", &FCMavlinkMissionItemsModel::instance()); diff --git a/app/telemetry/settings/frequencyhelper.cpp b/app/telemetry/settings/frequencyhelper.cpp index 325679018..22928cb97 100644 --- a/app/telemetry/settings/frequencyhelper.cpp +++ b/app/telemetry/settings/frequencyhelper.cpp @@ -1,79 +1,150 @@ #include "frequencyhelper.h" +#include "wifi_channel.h" -FrequencyHelper::FrequencyHelper() +FrequencyHelper::FrequencyHelper(QObject *parent) : QObject{parent} { } -std::vector FrequencyHelper::get_known_frequency_items() +FrequencyHelper &FrequencyHelper::instance() { - std::vector ret{ - FrequencyItem{-1,2312,false,false,false,-1}, - FrequencyItem{-1,2332,false,false,false,-1}, - FrequencyItem{-1,2352,false,false,false,-1}, - FrequencyItem{-1,2372,false,false,false,-1}, - FrequencyItem{-1,2392,false,false,false,-1}, - // ACTUAL 2G - FrequencyItem{1 ,2412,false,true,false,-1}, - FrequencyItem{5 ,2432,false,true,false,-1}, - FrequencyItem{9 ,2452,false,true,false,-1}, - FrequencyItem{13,2472,false,true,false,-1}, - FrequencyItem{14,2484,false,false,false,-1}, - // ACTUAL 2G end - FrequencyItem{-1,2492,false,false,false,-1}, - FrequencyItem{-1,2512,false,false,false,-1}, - FrequencyItem{-1,2532,false,false,false,-1}, - FrequencyItem{-1,2572,false,false,false,-1}, - FrequencyItem{-1,2592,false,false,false,-1}, - FrequencyItem{-1,2612,false,false,false,-1}, - FrequencyItem{-1,2632,false,false,false,-1}, - FrequencyItem{-1,2652,false,false,false,-1}, - FrequencyItem{-1,2672,false,false,false,-1}, - FrequencyItem{-1,2692,false,false,false,-1}, - FrequencyItem{-1, 2712,false,false,false,-1}, - // 5G begin - FrequencyItem{ 32,5160,false,false,false,-1}, - FrequencyItem{ 36,5180,false,true ,false,-1}, - FrequencyItem{ 40,5200,false,false,false,-1}, - FrequencyItem{ 44,5220,false,true,false,-1}, - FrequencyItem{ 48,5240,false,false,false,-1}, - FrequencyItem{ 52,5260,true,true ,false,-1}, - FrequencyItem{ 56,5280,true,false,false,-1}, - FrequencyItem{ 60,5300,true,true,false,-1}, - FrequencyItem{ 64,5320,true,false,false,-1}, - // big break / part that is not allowed - FrequencyItem{100,5500,true,true,false,-1}, - FrequencyItem{104,5520,true,false,false,-1}, - FrequencyItem{108,5540,true,true,false,-1}, - FrequencyItem{112,5560,true,false,false,-1}, - FrequencyItem{116,5580,true,true,false,-1}, - FrequencyItem{120,5600,true,false,false,-1}, - FrequencyItem{124,5620,true,true,false,-1}, - FrequencyItem{128,5640,true,false,false,-1}, - FrequencyItem{132,5660,true,true,false,-1}, - FrequencyItem{136,5680,true,false,false,-1}, - FrequencyItem{140,5700,false,true,false,1}, - FrequencyItem{144,5720,false,false,false,-1}, - // Here is the weird break - FrequencyItem{149,5745,false,true,true,2}, - FrequencyItem{153,5765,false,false,false,-1}, - FrequencyItem{157,5785,false,true,true,3}, - FrequencyItem{161,5805,false,false,false,-1}, - FrequencyItem{165,5825,false,true,true,4}, - // Depends - FrequencyItem{169,5845,false,false,false,-1}, - FrequencyItem{173,5865,false,true,true,5}, - FrequencyItem{177,5885,false,false,false,-1}, - FrequencyItem{181,5905,false,false,true,-1} - }; + static FrequencyHelper instance{}; + return instance; +} + +QList FrequencyHelper::get_frequencies(bool openhd_bands_only) +{ + QList ret; + if(openhd_bands_only){ + auto tmp=openhd::get_openhd_channels_1_to_5(); + for(auto& channel:tmp){ + ret.push_back(channel.frequency); + } + }else{ + const auto frequency_items=openhd::get_all_channels_2G_5G(); + for(auto& item:frequency_items){ + if(item.is_legal_at_least_one_country){ + ret.push_back(item.frequency); + } + } + } return ret; } -FrequencyHelper::FrequencyItem FrequencyHelper::find_frequency_item(const int frequency) +QList FrequencyHelper::get_frequencies_all_40Mhz() +{ + QList ret; + const auto frequency_items=openhd::get_all_channels_2G_5G(); + for(auto& item:frequency_items){ + if(item.space==openhd::WifiSpace::G2_4){ + if(item.is_legal_at_least_one_country){ + ret.push_back(item.frequency); + } + }else{ + if(item.is_legal_at_least_one_country && item.in_40Mhz_ht40_plus){ + ret.push_back(item.frequency); + } + } + } + return ret; +} + +bool FrequencyHelper::get_frequency_radar(int frequency_mhz) +{ + if(frequency_mhz>=5260 && frequency_mhz<=5680){ + return true; + } + return false; +} + +int FrequencyHelper::get_frequency_openhd_race_band(int frequency_mhz) { - const auto frequency_items=get_known_frequency_items(); - for(const auto& item:frequency_items){ - if(item.frequency==frequency)return item; + // 5700,5745,5785,5825,5865 + if(frequency_mhz==5700){ + return 1; + } + if(frequency_mhz==5745){ + return 2; + } + if(frequency_mhz==5785){ + return 3; + } + if(frequency_mhz==5825){ + return 4; + } + if(frequency_mhz==5865){ + return 5; } - return FrequencyItem{-1,-1,false,false,false}; + return -1; +} + +int FrequencyHelper::get_frequency_channel_nr(int frequency_mhz) +{ + const auto frequency_item=openhd::channel_from_frequency(frequency_mhz); + if(frequency_item.has_value()){ + return frequency_item.value().channel; + } + return -1; +} + +bool FrequencyHelper::set_hw_supported_frequencies_threadsafe(const std::vector supported_channels) +{ + std::lock_guard lock(m_supported_channels_mutex); + if(m_supported_channels!=supported_channels){ + m_supported_channels=supported_channels; + return true; + } + return false; +} + +bool FrequencyHelper::has_valid_supported_frequencies_data() +{ + std::lock_guard lock(m_supported_channels_mutex); + return !m_supported_channels.empty(); +} + +bool FrequencyHelper::hw_supports_frequency_threadsafe(int frequency_mhz) +{ + std::lock_guard lock(m_supported_channels_mutex); + for(const auto supported_freq: m_supported_channels){ + if(supported_freq==frequency_mhz)return true; + } + return false; +} + + +static std::string spaced_string(int number){ + std::stringstream ss; + if(number<100)ss<<" "; + if(number<10)ss<<" "; + ss<channel)<<"] "; + ss< FrequencyHelper::filter_frequencies(QList frequencies, int filter_level) +{ + QList ret; + for(const auto& element:frequencies){ + if(filter_level==2){ + if(element> 3000){ + ret.push_back(element); + } + }else if(filter_level==1){ + if(element< 3000){ + ret.push_back(element); + } + }else{ + ret.push_back(element); + } + } + return ret; } diff --git a/app/telemetry/settings/frequencyhelper.h b/app/telemetry/settings/frequencyhelper.h index ee578e514..20d8fc5a2 100644 --- a/app/telemetry/settings/frequencyhelper.h +++ b/app/telemetry/settings/frequencyhelper.h @@ -1,24 +1,39 @@ #ifndef FREQUENCYHELPER_H #define FREQUENCYHELPER_H +#include "qlist.h" +#include +#include #include -class FrequencyHelper +class FrequencyHelper : public QObject { + Q_OBJECT public: - FrequencyHelper(); - struct FrequencyItem{ - int channel_nr; - int frequency; - bool radar; - bool simple; - bool recommended; - int openhd_raceband; - }; - static std::vector get_known_frequency_items(); - static FrequencyItem find_frequency_item(const int frequency); + explicit FrequencyHelper(QObject *parent = nullptr); + static FrequencyHelper &instance(); + + Q_INVOKABLE QList get_frequencies(bool openhd_bands_only); + Q_INVOKABLE QList get_frequencies_all_40Mhz(); + + Q_INVOKABLE bool get_frequency_radar(int frequency_mhz); + Q_INVOKABLE int get_frequency_openhd_race_band(int frequency_mhz); + Q_INVOKABLE int get_frequency_channel_nr(int frequency_mhz); + // -------------- + Q_INVOKABLE bool hw_supports_frequency_threadsafe(int frequency_mhz); + // + Q_INVOKABLE QString get_frequency_description(int frequency_mhz); + + Q_INVOKABLE QList filter_frequencies(QList frequencies,int filter_level); +public: + bool set_hw_supported_frequencies_threadsafe(const std::vector supported_channels); + bool has_valid_supported_frequencies_data(); +private: + // Written by telemetry, read by UI + std::mutex m_supported_channels_mutex; + std::vector m_supported_channels; }; #endif // FREQUENCYHELPER_H diff --git a/app/telemetry/settings/pollutionhelper.cpp b/app/telemetry/settings/pollutionhelper.cpp index 6dd4d02c4..d2b46fedb 100644 --- a/app/telemetry/settings/pollutionhelper.cpp +++ b/app/telemetry/settings/pollutionhelper.cpp @@ -1,8 +1,9 @@ #include "pollutionhelper.h" #include +#include -PollutionHelper::PollutionHelper() +PollutionHelper::PollutionHelper(QObject *parent) : QObject{parent} { } @@ -51,3 +52,42 @@ std::optional PollutionHelper::threadsafe_get //qDebug()<<"Cannot find pollution for "< frequencies) +{ + QStringList ret; + for(auto& freq:frequencies){ + std::stringstream ss; + ss< frequencies, bool normalize) +{ + QVariantList ret; + for(auto& freq: frequencies){ + auto pollution=threadsafe_get_pollution_for_frequency(freq); + if(pollution.has_value()){ + if(normalize){ + ret.push_back(static_cast(pollution.value().n_foreign_packets_normalized)); + }else{ + ret.push_back(static_cast(pollution.value().n_foreign_packets)); + } + + }else{ + ret.push_back(static_cast(0)); + } + } + return ret; +} + +int PollutionHelper::pollution_get_last_scan_pollution_for_frequency(int frequency) +{ + auto tmp=threadsafe_get_pollution_for_frequency(frequency); + if(tmp.has_value()){ + return tmp.value().n_foreign_packets; + } + return -1; +} diff --git a/app/telemetry/settings/pollutionhelper.h b/app/telemetry/settings/pollutionhelper.h index 555de471f..7b5bbd2c0 100644 --- a/app/telemetry/settings/pollutionhelper.h +++ b/app/telemetry/settings/pollutionhelper.h @@ -4,16 +4,19 @@ #include #include #include +#include #include - +#include +#include // Written by telemetry, read by UI // This atomic behaviour is enough for us - we signal the ui to rebuild itself every time the data changes // The OpenHD ground unit broadcast the whole pollution set during channel scan, filling it as the scan proceeds. -class PollutionHelper +class PollutionHelper: public QObject { + Q_OBJECT public: - PollutionHelper(); + explicit PollutionHelper(QObject *parent = nullptr); static PollutionHelper& instance(); public: struct PollutionElement{ @@ -24,6 +27,10 @@ class PollutionHelper }; void threadsafe_update(const std::vector& values); std::optional threadsafe_get_pollution_for_frequency(int frequency); +public: + Q_INVOKABLE QStringList pollution_frequencies_int_to_qstringlist(QList frequencies); + Q_INVOKABLE QVariantList pollution_frequencies_int_get_pollution(QList frequencies,bool normalize=false); + Q_INVOKABLE int pollution_get_last_scan_pollution_for_frequency(int frequency); private: // Written by telemetry, read by UI std::map m_pollution_elements; diff --git a/app/telemetry/settings/wblinksettingshelper.cpp b/app/telemetry/settings/wblinksettingshelper.cpp index 3e2afe40f..69ac4cdc5 100644 --- a/app/telemetry/settings/wblinksettingshelper.cpp +++ b/app/telemetry/settings/wblinksettingshelper.cpp @@ -86,11 +86,6 @@ void WBLinkSettingsHelper::validate_and_set_air_channel_width_mhz(int channel_wi set_curr_air_channel_width_mhz(channel_width_mhz); } -void WBLinkSettingsHelper::set_simplify_channels(bool enable) -{ - m_simplify_channels=enable; -} - void WBLinkSettingsHelper::process_message_openhd_wifibroadcast_supported_channels(const mavlink_openhd_wifbroadcast_supported_channels_t &msg) { std::vector channels; @@ -102,7 +97,7 @@ void WBLinkSettingsHelper::process_message_openhd_wifibroadcast_supported_channe qDebug()<<"No valid channels from ground station - should never happen"; return; } - if(update_supported_channels(channels)){ + if(FrequencyHelper::instance().set_hw_supported_frequencies_threadsafe(channels)){ qDebug()<<"Supported channels changed"; signal_ui_rebuild_model_when_possible(); } @@ -227,59 +222,6 @@ bool WBLinkSettingsHelper::change_param_ground_only_blocking(QString param_id, i return false; } -static std::string spaced_string(int number){ - std::stringstream ss; - if(number<100)ss<<" "; - if(number<10)ss<<" "; - ss<(keyframe_interval),"KEYFRAME"); @@ -347,22 +289,6 @@ bool WBLinkSettingsHelper::set_param_stbc_ldpc_enable_air_ground() return true; } -bool WBLinkSettingsHelper::update_supported_channels(const std::vector supported_channels) -{ - std::lock_guard lock(m_supported_channels_mutex); - if(m_supported_channels!=supported_channels){ - m_supported_channels=supported_channels; - return true; - } - return false; -} - -bool WBLinkSettingsHelper::has_valid_reported_channel_data() -{ - std::lock_guard lock(m_supported_channels_mutex); - return !m_supported_channels.empty(); -} - void WBLinkSettingsHelper::change_param_air_async(const int comp_id,const std::string param_id,std::variant param_value,const std::string tag) { mavlink_param_ext_set_t command; @@ -415,76 +341,10 @@ void WBLinkSettingsHelper::change_param_air_channel_width_async(int value, bool change_param_air_async(OHD_COMP_ID_LINK_PARAM,PARAM_ID_WB_CHANNEL_WIDTH,static_cast(value),"BWIDTH"); } -QList WBLinkSettingsHelper::get_supported_frequencies() -{ - std::lock_guard lock(m_supported_channels_mutex); - QList ret; - for(auto& channel:m_supported_channels){ - ret.push_back(channel); - } - return ret; -} - -QList WBLinkSettingsHelper::get_supported_frequencies_filtered(int filter_level) -{ - auto supported_frequencies=get_supported_frequencies(); - if(filter_level<=0)return supported_frequencies; - QList ret; - for(auto& frequency: supported_frequencies){ - if(filter_level==1){ - // 40Mhz spacing - auto info=FrequencyHelper::find_frequency_item(frequency); - if(info.simple){ - ret.push_back(frequency); - } - } - } - return ret; -} - -QStringList WBLinkSettingsHelper::pollution_frequencies_int_to_qstringlist(QList frequencies) -{ - QStringList ret; - for(auto& freq:frequencies){ - std::stringstream ss; - ss< frequencies,bool normalize) -{ - QVariantList ret; - for(auto& freq: frequencies){ - auto pollution=PollutionHelper::instance().threadsafe_get_pollution_for_frequency(freq); - if(pollution.has_value()){ - if(normalize){ - ret.push_back(static_cast(pollution.value().n_foreign_packets_normalized)); - }else{ - ret.push_back(static_cast(pollution.value().n_foreign_packets)); - } - - }else{ - ret.push_back(static_cast(0)); - } - } - return ret; -} - -int WBLinkSettingsHelper::pollution_get_last_scan_pollution_for_frequency(int frequency) -{ - auto tmp=PollutionHelper::instance().threadsafe_get_pollution_for_frequency(frequency); - if(tmp.has_value()){ - return tmp.value().n_foreign_packets; - } - return -1; -} - void WBLinkSettingsHelper::signal_ui_rebuild_model_when_possible() { - const bool valid_ground_channel_data=has_valid_reported_channel_data(); + const bool valid_ground_channel_data=FrequencyHelper::instance().has_valid_supported_frequencies_data(); if(m_curr_channel_mhz>0 && m_curr_channel_width_mhz>0 && valid_ground_channel_data){ qDebug()<<"Signal UI Ready & should rebuild "< get_supported_frequencies(); - // To not overload the user, we filter the frequencies a bit - Q_INVOKABLE QList get_supported_frequencies_filtered(int filter_level); - Q_INVOKABLE QStringList pollution_frequencies_int_to_qstringlist(QList frequencies); - Q_INVOKABLE QVariantList pollution_frequencies_int_get_pollution(QList frequencies,bool normalize=false); - Q_INVOKABLE int pollution_get_last_scan_pollution_for_frequency(int frequency); - - Q_INVOKABLE QString get_frequency_description(int frequency_mhz); - Q_INVOKABLE bool get_frequency_radar(int frequency_mhz); - Q_INVOKABLE bool get_frequency_simplify(int frequency_mhz); - Q_INVOKABLE bool get_frequency_reccommended(int frequency_mhz); - Q_INVOKABLE int get_frequency_openhd_race_band(int frequency_mhz); // These params can be changed "on the fly" and are additionally their value(s) are broadcasted // so we can update them completely async, log the result to the user // and use the broadcasted value(s) to update the UI @@ -116,17 +102,6 @@ class WBLinkSettingsHelper : public QObject // Extra Q_INVOKABLE bool set_param_tx_power(bool ground,bool is_tx_power_index,bool is_for_armed_state,int value); Q_INVOKABLE bool set_param_stbc_ldpc_enable_air_ground(); -private: - struct SupportedChannel{ - uint16_t frequency; - int n_foreign_packets; - }; - // Written by telemetry, read by UI - std::mutex m_supported_channels_mutex; - std::vector m_supported_channels; - bool update_supported_channels(const std::vector supported_channels); - bool has_valid_reported_channel_data(); - std::atomic m_simplify_channels=false; private: void signal_ui_rebuild_model_when_possible(); }; diff --git a/app/telemetry/settings/wifi_channel.h b/app/telemetry/settings/wifi_channel.h new file mode 100644 index 000000000..3319ec25d --- /dev/null +++ b/app/telemetry/settings/wifi_channel.h @@ -0,0 +1,252 @@ +// +// Created by consti10 on 11.12.22. +// + +#ifndef OPENHD_OPENHD_OHD_INTERFACE_INC_WIFI_CHANNEL_H_ +#define OPENHD_OPENHD_OHD_INTERFACE_INC_WIFI_CHANNEL_H_ + +#include +#include +#include +#include + + +namespace OHDUtil{ +template +static void vec_append(std::vector& dest, const std::vector& src) { + dest.insert(dest.end(), src.begin(), src.end()); +} +} + +// USefully links: +// https://www.bundesnetzagentur.de/SharedDocs/Downloads/DE/Sachgebiete/Telekommunikation/Unternehmen_Institutionen/Frequenzen/20190705_Frequenzplan_EntwurfStandMai.pdf?__blob=publicationFile&v=1 +// https://en.wikipedia.org/wiki/List_of_WLAN_channels +// https://www.arubanetworks.com/vrd/OutdoorMIMOVRD/wwhelp/wwhimpl/common/html/wwhelp.htm#context=OutdoorMIMOVRD&file=AppA.html + +// NOTE: DO NOT USE CHANNEL NUMBERS ANYWHERE IN CODE - USE FREQUENCIES IN MHZ, SINCE THEY ARE UNIQUE +namespace openhd { + +enum class WifiSpace { G2_4, G5_8 }; + +// Wifi channel and the corresponding frequency, in mHz. +// "standard" : listed under wikipedia or not. +struct WifiChannel { + // frequency in mhz, recommended to use + uint32_t frequency; + // channel corresponding to this frequency, error-prone compared to the frequency since often defined incorrectly and/or for the non-standard AR9271 frequencies there is no standard channel number + int channel; + // weather this is a channel in the 2.4G space or 5.8G space + WifiSpace space; + // weather this channel is listed under wikipedia or not. + // Channels not listed under wikipedia might still work on some cards, given the driver has been modified. generally, they are not legally usable in most countries though. + bool is_standard; + // Weather this channel is legal in at least one country + bool is_legal_at_least_one_country; + // Weather it is legal in at least one country to use 40Mhz on this wifi channel + bool is_legal_any_country_40Mhz; + // Weather we (should / have to, otherwise driver crashes) use HT40+ or HT40- when doing 40Mhz on this channel + bool in_40Mhz_ht40_plus; + // weather this channel is used by openhd or not. + [[nodiscard]] std::string to_string() const { + std::stringstream ss; + ss << (int)frequency << "Mhz [" << channel << "] " + << (space == WifiSpace::G2_4 ? "2.4G" : "5.8G") + << (is_standard ? "" : "nonstandard"); + return ss.str(); + } +}; + +static std::vector get_channels_2G() { + return std::vector{ + // These are not valid 2.4G wifi channel(s) but some cards aparently can do them, too From https://github.com/OpenHD/linux/blob/092115ae6a980feaa09722690891d99da3afb55c/drivers/net/wireless/ath/ath9k/common-init.c#L39 + // NOTE: In OpenHD we never use the channel number (since it is prone to errors, even in the linux kernel) but rather use the frequency in mhz, which is well-defined. Also read https://yo3iiu.ro/blog/?p=1301 + // NOTE: OpenHD does not use channel width <20Mhz, so we ignore a couple of channels here + WifiChannel{2312, -1, WifiSpace::G2_4, false, false, false}, + //WifiChannel{2317, -1, WifiSpace::G2_4, false}, + //WifiChannel{2322, -1, WifiSpace::G2_4, false}, + //WifiChannel{2327, -1, WifiSpace::G2_4, false}, + WifiChannel{2332, -1, WifiSpace::G2_4, false, false, false}, + //WifiChannel{2337, -1, WifiSpace::G2_4, false}, + //WifiChannel{2342, -1, WifiSpace::G2_4, false}, + //WifiChannel{2347, -1, WifiSpace::G2_4, false}, + WifiChannel{2352, -1, WifiSpace::G2_4, false, false, false}, + //WifiChannel{2357, -1, WifiSpace::G2_4, false}, + //WifiChannel{2362, -1, WifiSpace::G2_4, false}, + //WifiChannel{2367, -1, WifiSpace::G2_4, false}, + WifiChannel{2372, -1, WifiSpace::G2_4, false, false, false}, + //WifiChannel{2377, -1, WifiSpace::G2_4, false}, + //WifiChannel{2382, -1, WifiSpace::G2_4, false}, + //WifiChannel{2387, -1, WifiSpace::G2_4, false}, + WifiChannel{2392, -1, WifiSpace::G2_4, false, false, false}, + //WifiChannel{2397, -1, WifiSpace::G2_4, false}, + //WifiChannel{2402, -1, WifiSpace::G2_4, false}, + //WifiChannel{2407, -1, WifiSpace::G2_4, false}, + // Now to the standard Wi-Fi channel(s) + // https://en.wikipedia.org/wiki/List_of_WLAN_channels#2.4_GHz_(802.11b/g/n/ax) + WifiChannel{2412, 1, WifiSpace::G2_4, true, true, true, true}, + //WifiChannel{2417, 2, WifiSpace::G2_4, true}, + //WifiChannel{2422, 3, WifiSpace::G2_4, true}, + //WifiChannel{2427, 4, WifiSpace::G2_4, true}, + WifiChannel{2432, 5, WifiSpace::G2_4, true, true, true, false}, + //WifiChannel{2437, 6, WifiSpace::G2_4, true}, + //WifiChannel{2442, 7, WifiSpace::G2_4, true}, + //WifiChannel{2447, 8, WifiSpace::G2_4, true}, + WifiChannel{2452, 9, WifiSpace::G2_4, true, true, true, true}, + //WifiChannel{2457, 10, WifiSpace::G2_4, true}, + //WifiChannel{2462, 11, WifiSpace::G2_4, true}, + //WifiChannel{2467, 12, WifiSpace::G2_4, true}, + WifiChannel{2472, 13, WifiSpace::G2_4, true, true, true, false}, + // until here it is consistent (5Mhz increments) + // this one is neither allowed in EU nor USA + // (only in Japan under 11b) + WifiChannel{2484, 14, WifiSpace::G2_4, true, true, false}, + // and these are all not valid wlan channels, but the AR9271 can do them anyways + //WifiChannel{2487, -1, WifiSpace::G2_4, false}, + //WifiChannel{2489, -1, WifiSpace::G2_4, false}, + WifiChannel{2492, -1, WifiSpace::G2_4, false, false, false}, + //WifiChannel{2494, -1, WifiSpace::G2_4, false}, + //WifiChannel{2497, -1, WifiSpace::G2_4, false}, + //WifiChannel{2499, -1, WifiSpace::G2_4, false}, + WifiChannel{2512, -1, WifiSpace::G2_4, false, false, false}, + //WifiChannel{2532, -1, WifiSpace::G2_4, false}, + //WifiChannel{2572, -1, WifiSpace::G2_4, false}, + //WifiChannel{2592, -1, WifiSpace::G2_4, false}, + WifiChannel{2612, -1, WifiSpace::G2_4, false, false, false}, + //WifiChannel{2632, -1, WifiSpace::G2_4, false}, + //WifiChannel{2652, -1, WifiSpace::G2_4, false}, + //WifiChannel{2672, -1, WifiSpace::G2_4, false}, + WifiChannel{2692, -1, WifiSpace::G2_4, false, false, false}, + WifiChannel{2712, -1, WifiSpace::G2_4, false, false, false}, + //WifiChannel{2732, -1, WifiSpace::G2_4, false}, + }; +} + + +static std::vector get_channels_5G(){ + return std::vector{ + // https://en.wikipedia.org/wiki/List_of_WLAN_channels#5_GHz_(802.11a/h/j/n/ac/ax) + WifiChannel{5180, 36, WifiSpace::G5_8, true, true, true, true}, + WifiChannel{5200, 40, WifiSpace::G5_8, true, true, true, false}, + WifiChannel{5220, 44, WifiSpace::G5_8, true, true, true, true}, + WifiChannel{5240, 48, WifiSpace::G5_8, true, true, true, false}, + WifiChannel{5260, 52, WifiSpace::G5_8, true, true, true, true}, + WifiChannel{5280, 56, WifiSpace::G5_8, true, true, true, false}, + WifiChannel{5300, 60, WifiSpace::G5_8, true, true, true, true}, + WifiChannel{5320, 64, WifiSpace::G5_8, true, true, true, false}, + // These channel(s) are not valid Wi-Fi channels in all countries + WifiChannel{5340, 68, WifiSpace::G5_8, true, false, false}, // (Only on 20Mhz allowed in some) + WifiChannel{5360, 72, WifiSpace::G5_8, true, false, false}, + WifiChannel{5380, 76, WifiSpace::G5_8, true, false, false}, + WifiChannel{5400, 80, WifiSpace::G5_8, true, false, false}, + WifiChannel{5420, 84, WifiSpace::G5_8, true, false, false}, + WifiChannel{5440, 88, WifiSpace::G5_8, true, false, false}, + WifiChannel{5460, 92, WifiSpace::G5_8, true, false, false}, + WifiChannel{5480, 96, WifiSpace::G5_8, true, false, false}, + // part often disabled end + WifiChannel{5500, 100, WifiSpace::G5_8, true, true, true, true}, + WifiChannel{5520, 104, WifiSpace::G5_8, true, true, true, false}, + WifiChannel{5540, 108, WifiSpace::G5_8, true, true, true, true}, + WifiChannel{5560, 112, WifiSpace::G5_8, true, true, true, false}, + WifiChannel{5580, 116, WifiSpace::G5_8, true, true, true, true}, + WifiChannel{5600, 120, WifiSpace::G5_8, true, true, true, false}, + WifiChannel{5620, 124, WifiSpace::G5_8, true, true, true, true}, + WifiChannel{5640, 128, WifiSpace::G5_8, true, true, true, false}, + WifiChannel{5660, 132, WifiSpace::G5_8, true, true, true, true}, + WifiChannel{5680, 136, WifiSpace::G5_8, true, true, true, false}, + WifiChannel{5700, 140, WifiSpace::G5_8, true, true, true, true}, + WifiChannel{5720, 144, WifiSpace::G5_8, true, true, true, false}, + // There is a gap not usable in between 5720 and 5745 Mhz + // For some reason, there is a 25Mhz jump here. Weird stuff ... + WifiChannel{5745, 149, WifiSpace::G5_8, true, true, true, true}, + WifiChannel{5765, 153, WifiSpace::G5_8, true, true, true, false}, + WifiChannel{5785, 157, WifiSpace::G5_8, true, true, true, true}, + WifiChannel{5805, 161, WifiSpace::G5_8, true, true, true, false}, + WifiChannel{5825, 165, WifiSpace::G5_8, true, true, true, true}, + // starting from here, often disabled territory begins again + WifiChannel{5845, 169, WifiSpace::G5_8, true, true, true, false}, + WifiChannel{5865, 173, WifiSpace::G5_8, true, true, true, true}, + // This one (177) is listed in wikipedia, but not valid in any country - but it works on rtl8812bu + WifiChannel{5885, 177, WifiSpace::G5_8, true, true, true, false}, + // this one does not work on bu, au no idea - for now, hide it + WifiChannel{5905, 181, WifiSpace::G5_8, true, false, false, true}, + }; +}; +// Returns all Wi-Fi channels 5G that are legal in any country +static std::vector get_channels_5G_legal_at_least_one_country(){ + const auto channels=get_channels_5G(); + std::vector ret; + for(auto& channel:channels){ + if(channel.is_legal_at_least_one_country){ + ret.push_back(channel); + } + } + return ret; +} +// Returns all Wi-Fi channels 2.4G that are legal in at least one country +static std::vector get_channels_2G_legal_at_least_one_country(){ + const auto channels=get_channels_2G(); + std::vector ret; + for(auto& channel:channels){ + if(channel.is_legal_at_least_one_country){ + ret.push_back(channel); + } + } + return ret; +} + + +static std::vector get_all_channels_2G_5G() { + std::vector channels{}; + OHDUtil::vec_append(channels, get_channels_2G()); + OHDUtil::vec_append(channels, get_channels_5G()); + return channels; +} + +static std::vector get_all_channel_frequencies(const std::vector& channels) { + std::vector frequencies{}; + frequencies.reserve(channels.size()); + for (const auto& channel : channels) { + frequencies.push_back(channel.frequency); + } + return frequencies; +} + +// Returns the corresponding Wi-Fi Channel if there is one +// since the mavlink setting is an int, this might not always be possible (and the frequency is then 100% not possible) and therefore should be discarded / fixed +static std::optional channel_from_frequency(uint32_t frequency) { + const auto channels = get_all_channels_2G_5G(); + for (const auto& channel : channels) { + if (channel.frequency == frequency) { + return channel; + } + } + return std::nullopt; +} + +static WifiSpace get_space_from_frequency(uint32_t frequency){ + auto channel= channel_from_frequency(frequency); + if(!channel.has_value()){ + return WifiSpace::G5_8; + } + return channel.value().space; +} + +static std::vector frequencies_to_channels(const std::vector& frequencies){ + std::vector ret; + auto channels=get_all_channels_2G_5G(); + for(const auto freq:frequencies){ + auto tmp= channel_from_frequency(freq); + if(tmp.has_value()){ + ret.push_back(tmp.value()); + } + } + return ret; +} + +static std::vector get_openhd_channels_1_to_5(){ + std::vector frequencies={5700,5745,5785,5825,5865}; + return frequencies_to_channels(frequencies); +} + +} +#endif // OPENHD_OPENHD_OHD_INTERFACE_INC_WIFI_CHANNEL_H_ diff --git a/app/telemetry/telemetry.pri b/app/telemetry/telemetry.pri index b5669b9c7..468f00337 100644 --- a/app/telemetry/telemetry.pri +++ b/app/telemetry/telemetry.pri @@ -39,6 +39,7 @@ HEADERS += \ $$PWD/action/impl/xparam.h \ $$PWD/settings/frequencyhelper.h \ $$PWD/settings/pollutionhelper.h \ + $$PWD/settings/wifi_channel.h \ $$PWD/util/geodesi_helper.h \ $$PWD/util/mavlink_enum_to_string.h \ $$PWD//util/openhd_defines.hpp \ diff --git a/qml/qml.qrc b/qml/qml.qrc index 4b21def5a..94655f70c 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -1,33 +1,33 @@ - + ../translations/QOpenHD_en.qm resources/cursors/arrow_512_green.png resources/cursors/arrow_512_transparent.png resources/cursors/arrow_512_white.png resources/cursors/hand_white.png - + ../translations/QOpenHD_de.qm - + ../translations/QOpenHD_ru.qm - + ../translations/QOpenHD_es.qm - + ../translations/QOpenHD_fr.qm - + ../translations/QOpenHD_nl.qm - + ../translations/QOpenHD_ro.qm - + ../translations/QOpenHD_it.qm - + ../translations/QOpenHD_zh.qm @@ -238,7 +238,7 @@ ui/elements/ArmDisarmSlider.qml ui/elements/SimpleProgressBar.qml ui/elements/ButtonGreen.qml - ui/configpopup/openhd_settings/DialoqueFreqChangeArmed.qml + ui/configpopup/openhd_settings/DialoqueFreqChangeAirGnd.qml ui/configpopup/openhd_settings/FreqComboBoxRow.qml ui/configpopup/status/QOpenHDVersionCard.qml ui/elements/CardToast.qml diff --git a/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeAirGnd.qml b/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeAirGnd.qml new file mode 100644 index 000000000..9dc43f634 --- /dev/null +++ b/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeAirGnd.qml @@ -0,0 +1,124 @@ +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Dialogs 1.0 +import QtQuick.Controls.Material 2.12 + +import "../../elements" + +// Dialoque that is shown to the user when the FC is armed and he wants to change frequency +// Once the user clicks the warning away, proceed as if FC is not armed +Card { + id: dialoqueFreqChangeAirGnd + width: 360 + height: 340 + z: 5.0 + anchors.centerIn: parent + cardName: get_card_title_string() + cardNameColor: "black" + visible: false + + property int m_wanted_frequency: -1 + + property bool m_fc_is_armed: true + + function close(){ + visible=false; + enabled=false; + } + + function initialize_and_show_frequency(frequency){ + m_wanted_frequency=frequency + visible=true; + enabled=true; + // Show warning if + if(_fcMavlinkSystem.is_alive && _fcMavlinkSystem.armed){ + m_fc_is_armed=true; + }else{ + m_fc_is_armed=false; + } + } + + function get_card_title_string(){ + return "Frequency "+m_wanted_frequency+"Mhz" + } + + function get_card_body_string(){ + const channel_nr=_frequencyHelper.get_frequency_channel_nr(m_wanted_frequency); + const channel_nr_openhd=_frequencyHelper.get_frequency_openhd_race_band(m_wanted_frequency); + return "Set AIR and GROUND to CHANNEL ["+channel_nr+"]\n"+ + "("+m_wanted_frequency+" Mhz) ?"; + + } + + cardBody: Item{ + height: 200 + width: 320 + + Text{ + id: description + width: parent.width + height: parent.height /2; + leftPadding: 12 + rightPadding: 12 + wrapMode: Text.WordWrap + text: get_card_body_string(); + } + Text{ + anchors.top: description.bottom + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + leftPadding: 12 + rightPadding: 12 + wrapMode: Text.WordWrap + text: "WARNING !\n CHANGING FREQUENCY WHILE ARMED IS NOT RECOMMENDED !"; + color: "red" + visible: m_fc_is_armed + } + } + hasFooter: true + cardFooter: Item { + anchors.fill: parent + RowLayout{ + anchors.fill: parent + + Button{ + Layout.preferredWidth: 150 + text: "CANCEL" + onPressed: { + dialoqueFreqChangeAirGnd.visible=false; + } + } + + Button{ + Layout.preferredWidth: 150 + text: "YES"; + Material.accent: m_fc_is_armed ? Material.Red : Material.Grey + highlighted: m_fc_is_armed ? true : false; + + onPressed: { + var result= _wbLinkSettingsHelper.change_param_air_and_ground_frequency(m_wanted_frequency); + if(result==0){ + _qopenhd.show_toast("SUCCESS"); + dialoqueFreqChangeAirGnd.visible=false; + return; + }else if(result==-1){ + // Air unit rejected + _qopenhd.show_toast("ERROR - AIR REJECTED"); + return; + }else if(result==-2){ + // Couldn't reach air unit + var error_message_not_reachable="Couldn't reach air unit -"; + _qopenhd.show_toast("ERROR -COULDN'T REACH AIR"); + return; + } + // Really really bad + _messageBoxInstance.set_text_and_show("Something went wrong - please use 'FIND AIR UNIT' to fix"); + dialoqueFreqChangeAirGnd.visible=false; + } + } + } + } +} + diff --git a/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeArmed.qml b/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeArmed.qml deleted file mode 100644 index f76ba635f..000000000 --- a/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeArmed.qml +++ /dev/null @@ -1,86 +0,0 @@ -import QtQuick 2.12 -import QtQuick.Controls 2.12 -import QtQuick.Layouts 1.12 -import QtQuick.Dialogs 1.0 -import QtQuick.Controls.Material 2.12 - -import "../../elements" - -// Dialoque that is shown to the user when the FC is armed and he wants to change frequency -// Once the user clicks the warning away, proceed as if FC is not armed -Card { - id: dialoqueFreqChangeArmed - width: 360 - height: 340 - z: 5.0 - anchors.centerIn: parent - cardName: get_card_title_string() - cardNameColor: "black" - visible: false - - property int m_wanted_frequency: -1 - - function close(){ - visible=false; - enabled=false; - } - - function initialize_and_show_frequency(frequency){ - m_wanted_frequency=frequency - m_wanted_channel_width=-1 - m_type=0; - visible=true; - enabled=true; - } - - function get_card_title_string(){ - return "Frequency "+m_wanted_frequency+"Mhz" - } - - function get_card_body_string(){ - return "WARNING ! Changing frequency while armed is not recommended - while unlikely, changing them needs synchronization and therefore can fail, -after which you have to perform a channel scan to reconnect to your air unit."; - } - - cardBody: Item{ - height: 200 - width: 320 - - Text{ - width: parent.width - height: parent.height - leftPadding: 12 - rightPadding: 12 - wrapMode: Text.WordWrap - text: get_card_body_string(); - } - } - hasFooter: true - cardFooter: Item { - anchors.fill: parent - RowLayout{ - anchors.fill: parent - ButtonRed{ - Layout.preferredWidth: 180 - Layout.alignment: Qt.AlignLeft - Layout.leftMargin: 12 - text: qsTr("CONTINUE ANYWAY") - onPressed: { - dialoqueFreqChangeArmed.visible=false - // Call function from MavlinkExtraWBParamPanel - change_frequency_sync_otherwise_handle_error(m_wanted_frequency,true/*ignore armed state*/) - } - } - ButtonGreen{ - Layout.preferredWidth: 140 - Layout.alignment: Qt.AlignRight - Layout.rightMargin: 12 - text: qsTr("Okay") - onPressed: { - dialoqueFreqChangeArmed.visible=false - } - } - } - } -} - diff --git a/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeGndOnly.qml b/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeGndOnly.qml index 70e4dddbe..ed2162fde 100644 --- a/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeGndOnly.qml +++ b/qml/ui/configpopup/openhd_settings/DialoqueFreqChangeGndOnly.qml @@ -40,7 +40,7 @@ Card { property string m_info_string_frequency: "Please use the channel scan to find your air unit, then change frequency."+ "Otherwise, you can manually change your ground station frequency,"+ -"leaving your air unit untouched - thiis can be quicker than a channel scan if you know your air unit frequency." +"leaving your air unit untouched - this can be quicker than a channel scan if you know your air unit frequency." property string m_info_ground_only: "WARNING: This changes your ground unit frequency without changing your air unit frequency !" diff --git a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml index a43cc4acf..38a7b83e2 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml +++ b/qml/ui/configpopup/openhd_settings/MavlinkOpenHDWBParamPanel.qml @@ -39,70 +39,56 @@ Rectangle{ for(var i = 0; i < model.count; ++i) if (model.get(i).value===value) return i return -1 } - // try and update the combobox to the retrieved value(value != index) - function update_combobox(_combobox,_value){ - var _index=find_index(_combobox.model,_value) - if(_index >= 0){ - _combobox.currentIndex=_index; - } - } function fc_is_armed(){ return _fcMavlinkSystem.armed } ListModel{ - id: supported_frequencies_model - ListElement {title: "Unknown"; value:-1; radar: false; recommended: false; openhd_raceband_nr: -1; pollution_pps: -1} + id: frequencies_model_all + ListElement {title: "Unknown"; value_frequency_mhz:-1} } - ListModel{ - id: frequencies_model - ListElement {title: "Unknown"; value:-1; radar: false; recommended: false; openhd_raceband_nr: -1; pollution_pps: -1} + id: frequencies_model_openhd_channels_only + ListElement {title: "Unknown"; value_frequency_mhz:-1} } - function show_popup_message(message){ - _messageBoxInstance.set_text_and_show(message) + function create_list_models_frequency(){ + frequencies_model_all.clear(); + const frequencies_all=_frequencyHelper.get_frequencies(false); + for(var i=0;i= 0; + function update_frequency_combobox(){ + if(m_simplify_enable){ + comboBoxFreq.model=frequencies_model_openhd_channels_only; + }else{ + comboBoxFreq.model=frequencies_model_all; + } + if(_wbLinkSettingsHelper.curr_channel_mhz>0){ + var index=find_index(comboBoxFreq.model,_wbLinkSettingsHelper.curr_channel_mhz); + if(index>=0){ + comboBoxFreq.currentIndex=index; }else{ - append_this_value=true; - } - if(append_this_value){ - supported_frequencies_model.append({title: text, value: frequency, radar:radar, recommended: recommended, openhd_raceband_nr: openhd_raceband, pollution_pps: pollution}) + comboBoxFreq.currentIndex=0; + console.log("Seems not to be a valid channel "+_wbLinkSettingsHelper.curr_channel_mhz) } - } - var index=find_index(supported_frequencies_model,_wbLinkSettingsHelper.curr_channel_mhz); - comboBoxFreq.model=supported_frequencies_model - if(index>=0){ - comboBoxFreq.currentIndex=index; }else{ - comboBoxFreq.currentIndex=0; - console.log("Seems not to be a valid channel "+_wbLinkSettingsHelper.curr_channel_mhz) + comboBoxFreq.currentIndex=-1; } } - function create_list_model2(){ - frequencies_model.clear(); - - } // We get notified every time we should re-build the model(s) and their current selection property int m_ui_rebuild_models : _wbLinkSettingsHelper.ui_rebuild_models @@ -112,10 +98,9 @@ Rectangle{ } function function_rebuild_ui(){ + update_frequency_combobox(); console.log("function_rebuild_ui:"+_wbLinkSettingsHelper.ui_rebuild_models); if(_wbLinkSettingsHelper.ui_rebuild_models<=0)return - create_list_model_supported(); - //update_pollution_graph(); popup_analyze_channels.update(); } @@ -125,7 +110,7 @@ Rectangle{ popup_scan_channels.close(); popup_change_tx_power.close(); dialoqueFreqChangeGndOnly.close(); - dialoqueFreqChangeArmed.close(); + dialoqueFreqChangeAirGnd.close(); popup_enable_stbc_ldpc.close(); } @@ -140,51 +125,8 @@ Rectangle{ Component.onCompleted: { close_all_dialoques(); - } - // - - // ------------------- PART HELPER FOR CURRENT LOSS / POLLUTION / THROTTLE BEGIN ------------------- - // ------------------- PART HELPER FOR CURRENT LOSS / POLLUTION / THROTTLE END ------------------- - - - // Changes either the frequency or channel width - // This one need to be synced, so we have ( a bit complicated, but quite natural for the user) dialoque for the cases where we need to handle errors / show a warning - function change_frequency_sync_otherwise_handle_error(frequency_mhz,ignore_armed_state){ - console.log("change_frequency_sync_otherwise_handle_error: "+"FREQ:"+frequency_mhz+"Mhz"); - // Ground needs to be alive and well - if(!_ohdSystemGround.is_alive){ - _messageBoxInstance.set_text_and_show("Ground unit not alive",5); - return; - } - // Air needs to be alive and well - otherwise we show the "do you want to change gnd only" dialoque - if(!_ohdSystemAir.is_alive){ - var error_message_not_alive="AIR Unit not alive -" - dialoqueFreqChangeGndOnly.initialize_and_show_frequency(frequency_mhz,error_message_not_alive); - return; - } - // FC needs to be disarmed - otherwise show warning - const fc_currently_armed = (_fcMavlinkSystem.is_alive && _fcMavlinkSystem.armed)// || true; - if(fc_currently_armed && ignore_armed_state===false){ - dialoqueFreqChangeArmed.initialize_and_show_frequency(frequency_mhz) - return; - } - var result= _wbLinkSettingsHelper.change_param_air_and_ground_frequency(frequency_mhz); - if(result==0){ - var message="Succesfully set air and ground to FREQUENCY: "+frequency_mhz+"Mhz"; - _messageBoxInstance.set_text_and_show(message,5); - return; - }else if(result==-1){ - // Air unit rejected - _messageBoxInstance.set_text_and_show("Air unit does not support this value",5); - return; - }else if(result==-2){ - // Couldn't reach air unit - var error_message_not_reachable="Couldn't reach air unit -" - dialoqueFreqChangeGndOnly.initialize_and_show_frequency(frequency_mhz,error_message_not_reachable); - return; - } - // Really really bad - _messageBoxInstance.set_text_and_show("Something went wrong - please use 'FIND AIR UNIT' to fix"); + create_list_models_frequency(); + update_frequency_combobox(); } function get_text_wifi_tx_power(air){ @@ -220,7 +162,7 @@ Rectangle{ implicitHeight: frequency_area_layout.implicitHeight+5 radius: 10 - GridLayout { + ColumnLayout { id: frequency_area_layout Layout.fillWidth: true Layout.fillHeight: true @@ -233,108 +175,29 @@ Rectangle{ font.bold: true } - ComboBox { - id: comboBoxFreq - model: supported_frequencies_model - textRole: "title" - implicitWidth: elementComboBoxWidth - currentIndex: 0 - delegate: ItemDelegate { - width: comboBoxFreq.width - contentItem: FreqComboBoxRow{ - m_main_text: title - m_selection_tpye: (value===_wbLinkSettingsHelper.curr_channel_mhz) ? 1 : 0 - m_is_2G: value < 3000 && value > 100 - m_show_radar: radar - m_openhd_race_band: openhd_raceband_nr - m_pollution_pps: pollution_pps - } - highlighted: comboBoxFreq.highlightedIndex === index - } - Layout.row: 1 - Layout.column: 0 - /*displayText: { - if(!_ohdSystemGround.is_alive)return "GND NOT ALIVE"; - if(_ohdSystemGround.wb_gnd_operating_mode==1){ - return "SCANNING"; - } - if(_ohdSystemGround.wb_gnd_operating_mode==2){ - return "ANALYZING"; - } - if(!_ohdSystemAir.is_alive){ - return _wbLinkSettingsHelper.curr_channel_mhz+"@"+"N/A"+" Mhz (NO AIR)"; - } - return _wbLinkSettingsHelper.curr_channel_mhz+"@"+_wbLinkSettingsHelper.curr_channel_width_mhz+" Mhz"; - } - onCurrentIndexChanged: { - console.log("Index changed:"+currentIndex); - if(currentIndex<0)return; - var frequency_mhz=supported_frequencies_model.get(currentIndex).value - console.log("Selected frequency: "+frequency_mhz); - if(_wbLinkSettingsHelper.curr_channel_mhz==frequency_mhz){ - console.log("Already at frequency "+frequency_mhz); - return; - } - if(!_ohdSystemAir.is_alive){ - var error_message_not_alive="AIR Unit not alive -" - dialoqueFreqChangeGndOnly.initialize_and_show_frequency(frequency_mhz,error_message_not_alive); - return; - } - // Change the freuquency - } - enabled: _ohdSystemGround.is_alive*/ - } - Button{ - text: "APPLY" - id: buttonSwitchFreq - //enabled: false - onClicked: { - var selectedValue=supported_frequencies_model.get(comboBoxFreq.currentIndex).value - if(selectedValue<=100){ - _messageBoxInstance.set_text_and_show("Please select a valid frequency",5); - return; - } - change_frequency_sync_otherwise_handle_error(selectedValue,-1,false); - } - //Material.background: fc_is_armed() ? Material.Red : Material.Normal; - enabled: _wbLinkSettingsHelper.ui_rebuild_models>=0 && (_ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0) && - (_wbLinkSettingsHelper.curr_channel_mhz!=comboBoxFreq.currentValue); - Layout.row: 1 - Layout.column: 1 - } - Switch{ - Layout.row: 1 - Layout.column: 2 - Layout.columnSpan: 1 - text: "SIMPLIFY" - checked: true - onCheckedChanged: { - if(m_simplify_enable!=checked){ - m_simplify_enable=checked; - function_rebuild_ui(); - } - } - } - ButtonIconInfo{ - Layout.row: 1 - Layout.column: 3 - onClicked: { - var text="SIMPLIFY: Show recommended channels only. These channels usually have the least amount of pollution by WiFi APs and most FPV antennas are tuned to those Frequncies.\n"+ - "OpenHD works best on them in most scenarios,and you can use 20Mhz and 40Mhz dynamically without issues (40Mhz spacing by default).\n"+ - "Otherwise, show all channels supported by harware (ADVANCED USERS ONLY).\n"; - _messageBoxInstance.set_text_and_show(text) - } - } RowLayout{ - Layout.row: 2 - Layout.column: 0 - Layout.fillWidth: true - Layout.fillHeight: true - id: gnd_op_mode_status - //SimpleProgressBar{ - //} - Text{ - text: { + ComboBox { + id: comboBoxFreq + //model: supported_frequencies_model + //model: frequencies_model_openhd_channels_only + textRole: "title" + implicitWidth: elementComboBoxWidth + currentIndex: 0 + delegate: ItemDelegate { + width: comboBoxFreq.width + contentItem: FreqComboBoxRow{ + m_main_text: title + m_selection_tpye: (value_frequency_mhz===_wbLinkSettingsHelper.curr_channel_mhz) ? 1 : 0 + m_is_2G: value_frequency_mhz < 3000 && value_frequency_mhz > 100 + m_show_radar: _frequencyHelper.get_frequency_radar(value_frequency_mhz) + m_openhd_race_band: _frequencyHelper.get_frequency_openhd_race_band(value_frequency_mhz) + m_pollution_pps: _pollutionHelper.pollution_get_last_scan_pollution_for_frequency(value_frequency_mhz) + } + highlighted: comboBoxFreq.highlightedIndex === index + } + Layout.row: 1 + Layout.column: 0 + displayText: { if(!_ohdSystemGround.is_alive)return "GND NOT ALIVE"; if(_ohdSystemGround.wb_gnd_operating_mode==1){ return "SCANNING"; @@ -347,86 +210,151 @@ Rectangle{ } return _wbLinkSettingsHelper.curr_channel_mhz+"@"+_wbLinkSettingsHelper.curr_channel_width_mhz+" Mhz"; } + onActivated: { + console.log("onActivated:"+currentIndex); + if(currentIndex<0)return; + const frequency_mhz=comboBoxFreq.model.get(currentIndex).value_frequency_mhz + console.log("Selected frequency: "+frequency_mhz); + if(!_frequencyHelper.hw_supports_frequency_threadsafe(frequency_mhz)){ + _qopenhd.show_toast("your HW does not support "+frequency_mhz+" Mhz"); + return; + } + if(_wbLinkSettingsHelper.curr_channel_mhz==frequency_mhz){ + console.log("Already at frequency "+frequency_mhz); + return; + } + if(!_ohdSystemAir.is_alive){ + var error_message_not_alive="AIR Unit not alive -" + dialoqueFreqChangeGndOnly.initialize_and_show_frequency(frequency_mhz,error_message_not_alive); + return; + } + // Change the freuquency + dialoqueFreqChangeAirGnd.initialize_and_show_frequency(frequency_mhz); + } + enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0; + } + Switch{ Layout.row: 1 - Layout.column: 0 - verticalAlignment: Text.AlignVCenter + Layout.column: 1 + Layout.columnSpan: 1 + text: "SIMPLIFY" + checked: true + onCheckedChanged: { + if(m_simplify_enable!=checked){ + m_simplify_enable=checked; + function_rebuild_ui(); + } + } + } + ButtonIconInfo{ + Layout.row: 1 + Layout.column: 2 + onClicked: { + var text="Please select a channel / frequency free of noise and interference. The current loss / pollution / throttle stats below can help,"+ + "as well as the analyze channels feature or a frequency analyzer on your phone. SIMPLIFY: Show OpenHD standard channels [1-5] only - they "+ + " often are free of wifi pollution and should be used. Only disable SIMPLIFY if you know exactly why." + _messageBoxInstance.set_text_and_show(text) + } } } - Button{ + + + + RowLayout{ Layout.row: 2 - Layout.column: 1 - id: b_find_air_unit - text: "SCAN" - enabled: _ohdSystemGround.is_alive - onClicked: { - close_all_dialoques(); - popup_scan_channels.open() - } - SequentialAnimation { - running: false - loops: 4 - id: anim_find_air_unit - // Expand the button - PropertyAnimation { - target: b_find_air_unit - property: "scale" - to: 1.5 - duration: 200 - easing.type: Easing.InOutQuad + Layout.column: 0 + Layout.columnSpan: 3 + Button{ + Layout.preferredWidth: 150 + id: b_find_air_unit + text: "SCAN" + enabled: _ohdSystemGround.is_alive + onClicked: { + close_all_dialoques(); + popup_scan_channels.open() } - // Shrink back to normal - PropertyAnimation { - target: b_find_air_unit - property: "scale" - to: 1.0 - duration: 200 - easing.type: Easing.InOutQuad + SequentialAnimation { + running: false + loops: 4 + id: anim_find_air_unit + // Expand the button + PropertyAnimation { + target: b_find_air_unit + property: "scale" + to: 1.5 + duration: 200 + easing.type: Easing.InOutQuad + } + // Shrink back to normal + PropertyAnimation { + target: b_find_air_unit + property: "scale" + to: 1.0 + duration: 200 + easing.type: Easing.InOutQuad + } } } - } - Button{ - Layout.row: 2 - Layout.column: 2 - text: "ANALYZE" - enabled: _ohdSystemGround.is_alive - onClicked: { - close_all_dialoques(); - popup_analyze_channels.open() + Item{ // FILLER + Layout.preferredWidth: 50 + Layout.minimumWidth: 0 } - } - ButtonIconInfo{ - Layout.row: 2 - Layout.column: 3 - onClicked: { - var text="SCAN: Scan for a running openhd air unit (required if you switch between different air / ground stations or re-flash the image.)\n"+ - "ANALYZE: Analyze all channels for WiFi pollution. If any of the default openhd channels is not polluted, they should be used."+ - "NOTE: Analogue FPV or other digital FPV systems won't show up during analyze - read the wiki for more info."; - _messageBoxInstance.set_text_and_show(text) + Button{ + Layout.preferredWidth: 150 + text: "ANALYZE" + enabled: _ohdSystemGround.is_alive + onClicked: { + close_all_dialoques(); + popup_analyze_channels.open() + } + } + ButtonIconInfo{ + onClicked: { + var text="SCAN: Similar to analoque channel scan, find a running air unit by checking all possible channels (frequencies).\n\n"+ + "ANALYZE: Analyze channels for WiFi pollution. Read the wiki for more info."; + _messageBoxInstance.set_text_and_show(text) + } } } - // Row 3 RowLayout{ - Layout.row: 3 - Layout.column: 0 - Layout.columnSpan: 3 Text{ + Layout.preferredHeight: 50 + Layout.preferredWidth: 120 text:{ - "LOSS %:"+_ohdSystemGround.curr_rx_packet_loss_perc + "LOSS:\n"+_ohdSystemGround.curr_rx_packet_loss_perc+"%" } color: _ohdSystemGround.curr_rx_packet_loss_perc > 5 ? "red" : "black" verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true } Text{ + Layout.preferredHeight: 50 + Layout.preferredWidth: 120 text: { - return "POLLUTION pps:"+_ohdSystemGround.wb_link_curr_foreign_pps + return "POLLUTION:\n"+_ohdSystemGround.wb_link_curr_foreign_pps+"pps" } color: _ohdSystemGround.wb_link_curr_foreign_pps > 20 ? "red" : "black" + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true } Text{ + Layout.preferredHeight: 50 + Layout.preferredWidth: 120 text: { - return "THROTTLE:"+_ohdSystemAir.curr_n_rate_adjustments + return "THROTTLE:\n"+_ohdSystemAir.curr_n_rate_adjustments } color: _ohdSystemAir.curr_n_rate_adjustments > 0 ? "red" : "black" + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + ButtonIconInfo{ + onClicked: { + var text="High Loss / Pollution / active throttle hint at a polluted channel." + _messageBoxInstance.set_text_and_show(text) + } } ButtonIconWarning{ visible: /*_ohdSystemAir.is_alive &&*/ (_ohdSystemGround.curr_rx_packet_loss_perc > 5 || _ohdSystemGround.wb_link_curr_foreign_pps > 20 || _ohdSystemAir.curr_n_rate_adjustments > 0) @@ -447,25 +375,22 @@ Rectangle{ color: m_background_color radius: 10 - GridLayout { + RowLayout { id: tx_power_layout Layout.fillWidth: true Layout.fillHeight: true Text{ - Layout.row: 0 - Layout.column: 0 - Layout.columnSpan: 2 text: "TX POWER" font.bold: true } Text{ - Layout.row: 1 - Layout.column: 0 + Layout.preferredWidth: 120 text: "AIR:\n "+get_text_wifi_tx_power(true) + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true } Button{ - Layout.row: 1 - Layout.column: 1 text: "EDIT" enabled: _ohdSystemAir.is_alive onClicked: { @@ -475,13 +400,13 @@ Rectangle{ } } Text{ - Layout.row: 2 - Layout.column: 0 + Layout.preferredWidth: 120 text: "GND:\n"+get_text_wifi_tx_power(false) + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true } Button{ - Layout.row: 2 - Layout.column: 1 text: "EDIT" enabled: _ohdSystemGround.is_alive onClicked: { @@ -490,27 +415,50 @@ Rectangle{ popup_change_tx_power.open() } } + } + } + Rectangle { + implicitWidth: main_scroll_view.width + implicitHeight: stbc_ldpc_layout.implicitHeight + id: stbc_ldpc_background + color: m_background_color + radius: 10 + + RowLayout { + id: stbc_ldpc_layout + Layout.fillWidth: true + Layout.fillHeight: true // STBC / LDPC Text{ width: 200 - Layout.row: 0 - Layout.column: 3 - Layout.columnSpan: 2 text: "ADVANCED (STBC,LDPC)" font.bold: true horizontalAlignment: Qt.AlignHCenter } Text{ - Layout.row: 1 - Layout.column: 3 + Layout.preferredWidth: 120 text: "AIR:\n"+get_text_stbc_ldpc(true); + verticalAlignment: Qt.AlignVCenter horizontalAlignment: Qt.AlignHCenter + font.bold: true } Text{ - Layout.row: 2 - Layout.column: 3 + Layout.preferredWidth: 120 text: "GND:\n"+get_text_stbc_ldpc(false); + verticalAlignment: Qt.AlignVCenter horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + + Button{ + text: "EDIT"; + //enabled: true + enabled: _ohdSystemAir.is_alive && _ohdSystemGround.is_alive && (_wbLinkSettingsHelper.ui_rebuild_models>=0) && + (_ohdSystemGround.wb_stbc_enabled!=true || _ohdSystemGround.wb_lpdc_enabled!=true || _ohdSystemAir.wb_stbc_enabled!=true || _ohdSystemAir.wb_lpdc_enabled!=true); + onClicked: { + close_all_dialoques(); + popup_enable_stbc_ldpc.open() + } } ButtonIconInfo{ Layout.row: 1 @@ -521,46 +469,8 @@ Rectangle{ "and you need to re-flash your air / ground unit to recover !"); } } - Button{ - Layout.row: 2 - Layout.column: 4 - text: "EDIT"; - enabled: true - //enabled: _ohdSystemAir.is_alive && _ohdSystemGround.is_alive && (_wbLinkSettingsHelper.ui_rebuild_models>=0) && - // (_ohdSystemGround.wb_stbc_enabled!=true || _ohdSystemGround.wb_lpdc_enabled!=true || _ohdSystemAir.wb_stbc_enabled!=true || _ohdSystemAir.wb_lpdc_enabled!=true); - onClicked: { - close_all_dialoques(); - popup_enable_stbc_ldpc.open() - } - } } } - // - /*Rectangle { - implicitWidth: main_scroll_view.width - implicitHeight: tx_power_layout.implicitHeight - id: rpi_cam_selector_layout_background - color: m_background_color - radius: 10 - - GridLayout { - id: rpi_cam_selector_layout - Layout.fillWidth: true - Layout.fillHeight: true - Text{ - Layout.row: 0 - Layout.column: 0 - Layout.columnSpan: 2 - text: "RPI CAM SELECTOR" - font.bold: true - } - Button{ - Layout.row: 1 - Layout.column: 0 - text: "EDIT" - } - } - }*/ } } @@ -582,7 +492,7 @@ Rectangle{ DialoqueFreqChangeGndOnly{ id: dialoqueFreqChangeGndOnly } - DialoqueFreqChangeArmed{ - id: dialoqueFreqChangeArmed + DialoqueFreqChangeAirGnd{ + id: dialoqueFreqChangeAirGnd } } diff --git a/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml b/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml index da187a13a..223fa488f 100644 --- a/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml +++ b/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml @@ -28,7 +28,10 @@ Rectangle{ border.width: 3 property bool m_normalize_data: false; - property int m_chart_view_minimum_width: 1280-200; + property int m_chart_view_minimum_width: 1280; + property int m_chart_view_minimum_width2: 640; + + property bool m_chart_enlarged: false; function open(){ visible=true @@ -42,153 +45,180 @@ Rectangle{ pollution_chart.update_pollution_graph(); } + ListModel{ + id: model_filter + ListElement {title: "NO FILTER"; value: 0} + ListElement {title: "2.4G ONLY"; value: 1} + ListElement {title: "5.8G ONLY"; value: 2} + } + property string m_info_string: "Analyze channels for pollution by wifi access points.\n"+ "NOTE: This only gives a hint at free channels, using a proper channel analyzer (e.g. on the phone) is recommended !\n"+ "In short: Any frequency with red bars (small or big) should not be used, unless there are no options / other reasons to do so." - GridLayout{ - id: top_elements - //width: parent.width - anchors.left: parent.left - anchors.leftMargin: 5 - anchors.right: parent.right - anchors.rightMargin: 5 - + ColumnLayout{ + id: main_layout + anchors.fill: parent + anchors.leftMargin: 10 + anchors.rightMargin: 10 - Text{ // TITLE - Layout.row: 0 - Layout.column: 0 - Layout.columnSpan: 3 + Item{ Layout.fillWidth: true - Layout.preferredHeight: 50 - Layout.minimumHeight: 20 - text: "ANALYZE CHANNELS (POLLUTION)"; - verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignHCenter - } - - Button{ - Layout.row: 0 - Layout.column: 3 - Layout.alignment: Qt.AlignRight - text: "CLOSE" - onClicked: { - if(_ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==2){ - _qopenhd.show_toast("STILL ANALYZING, PLEASE WAIT ...",); - return; + Layout.preferredHeight: 60 + Text{ // TITLE + anchors.fill: parent + text: "ANALYZE (POLLUTION)"; + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + Button{ + anchors.right: parent.right + anchors.top: parent.top + text: "CLOSE" + onClicked: { + if(_ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==2){ + _qopenhd.show_toast("STILL ANALYZING, PLEASE WAIT ...",); + return; + } + close() } - close() } } - SimpleProgressBar{ - Layout.row: 1 - Layout.column: 0 - Layout.preferredWidth: 400 - Layout.minimumWidth: 100 - Layout.preferredHeight: 40 - impl_curr_progress_perc: _wbLinkSettingsHelper.analyze_progress_perc - impl_show_progress_text: true - } - Button{ - Layout.row: 1 - Layout.column: 1 - Layout.alignment: Qt.AlignLeft - text: "START" - onClicked: { - var result=_wbLinkSettingsHelper.start_analyze_channels() - if(result!==true){ - _qopenhd.show_toast("Busy,please try again later",true); - }else{ - _qopenhd.show_toast("STARTED, THIS MIGHT TAKE A WHILE !"); + RowLayout{ + SimpleProgressBar{ + Layout.preferredWidth: 400 + Layout.minimumWidth: 100 + Layout.preferredHeight: 40 + impl_curr_progress_perc: _wbLinkSettingsHelper.analyze_progress_perc + impl_show_progress_text: true + } + Button{ + Layout.alignment: Qt.AlignLeft + text: "START" + onClicked: { + var result=_wbLinkSettingsHelper.start_analyze_channels() + if(result!==true){ + _qopenhd.show_toast("Busy,please try again later",true); + }else{ + _qopenhd.show_toast("STARTED, THIS MIGHT TAKE A WHILE !"); + } } + enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0 } - enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0 - } - Text{ - Layout.row: 2 - Layout.column: 0 - Layout.preferredWidth: 200 - Layout.minimumWidth: 50 - text: { - if(_wbLinkSettingsHelper.current_analyze_frequency<=0){ - return ""; + ButtonIconInfo{ + Layout.alignment: Qt.AlignLeft + onClicked: { + _messageBoxInstance.set_text_and_show(m_info_string) } - return "Analyzed "+_wbLinkSettingsHelper.current_analyze_frequency+" Mhz ..."; } - verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignHCenter } - - Switch{ - Layout.row: 2 - Layout.column: 1 - text: "NORMALIZE" - checked: m_normalize_data - onCheckedChanged: { - m_normalize_data=checked - pollution_chart.update_pollution_graph(); + RowLayout{ + Text{ + Layout.preferredWidth: 200 + Layout.minimumWidth: 100 + Layout.preferredHeight: 40 + text: { + if(_wbLinkSettingsHelper.current_analyze_frequency<=0){ + return ""; + } + return "Analyzed "+_wbLinkSettingsHelper.current_analyze_frequency+" Mhz ..."; + } + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter } - } - ButtonIconInfo{ - Layout.row: 2 - Layout.column: 2 - Layout.alignment: Qt.AlignLeft - onClicked: { - _messageBoxInstance.set_text_and_show(m_info_string) + ComboBox { + Layout.preferredWidth: 150 + Layout.minimumWidth: 50 + id: comboBoxFilter + model: model_filter + textRole: "title" + onCurrentIndexChanged: { + pollution_chart.update_pollution_graph(); + } + } + Switch{ + text: "NORMALIZE" + checked: m_normalize_data + onCheckedChanged: { + m_normalize_data=checked + pollution_chart.update_pollution_graph(); + } } } - // Filler - Item{ + ScrollView{ + id: chart_scroll_view Layout.fillWidth: true - } - } - - ScrollView{ - anchors.top: top_elements.bottom - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: parent.right - contentWidth: pollution_chart.width - ScrollBar.horizontal.interactive: true - - ChartView { - id: pollution_chart - title: "WiFi pollution estimate" - width: main_background.width>m_chart_view_minimum_width ? main_background.width : m_chart_view_minimum_width; - height: parent.height - legend.alignment: Qt.AlignBottom - antialiasing: true - - function update_pollution_graph(){ - //const frequencies_list = _wbLinkSettingsHelper.get_pollution_qstringlist(); - //bar_axis_x.categories=frequencies_list; - //const supported_frequencies = _wbLinkSettingsHelper.get_supported_frequencies(); - const supported_frequencies = _wbLinkSettingsHelper.get_supported_frequencies_filtered(1); - var categories = _wbLinkSettingsHelper.pollution_frequencies_int_to_qstringlist(supported_frequencies); - var values = _wbLinkSettingsHelper.pollution_frequencies_int_get_pollution(supported_frequencies,m_normalize_data); - bar_axis_x.categories=categories; - bar_set.values=values; - } - - BarSeries { - id: hm_bar_series - axisX: BarCategoryAxis { - id: bar_axis_x - categories: ["DUMMY0", "DUMMY1", "DUMMY3", "DUMMY4" ] - //min: "0" - //max: "500" + Layout.fillHeight: true + contentWidth: pollution_chart.width + ScrollBar.horizontal.interactive: true + + ChartView { + id: pollution_chart + title: "WiFi pollution estimate" + //width: main_background.width>m_chart_view_minimum_width ? main_background.width : m_chart_view_minimum_width; + width: { + const screen_width = main_layout.width; + if(comboBoxFilter.currentIndex==0){ + return screen_width>m_chart_view_minimum_width ? screen_width : m_chart_view_minimum_width; + } + if(comboBoxFilter.currentIndex==1){ + return screen_width + } + return screen_width>m_chart_view_minimum_width2 ? screen_width : m_chart_view_minimum_width2; + } + //width: m_chart_enlarged ? 1280 : main_background.width + height: parent.height + legend.alignment: Qt.AlignBottom + antialiasing: true + + function update_pollution_graph(){ + //const frequencies_list = _wbLinkSettingsHelper.get_pollution_qstringlist(); + //bar_axis_x.categories=frequencies_list; + //const supported_frequencies = _wbLinkSettingsHelper.get_supported_frequencies(); + const all_40Mhz_frequencies_unfiltered=_frequencyHelper.get_frequencies_all_40Mhz(); + const all_40Mhz_frequencies = _frequencyHelper.filter_frequencies(all_40Mhz_frequencies_unfiltered,comboBoxFilter.currentIndex); + var categories = _pollutionHelper.pollution_frequencies_int_to_qstringlist(all_40Mhz_frequencies); + var values = _pollutionHelper.pollution_frequencies_int_get_pollution(all_40Mhz_frequencies,m_normalize_data); + bar_axis_x.categories=categories; + bar_set.values=values; } - BarSet { - id: bar_set - label: "Pollution (pps)"; - values: [5,10,3,100] - //values: [0,0,0,0] - color: "red" + + BarSeries { + id: hm_bar_series + axisX: BarCategoryAxis { + id: bar_axis_x + categories: ["DUMMY0", "DUMMY1", "DUMMY3", "DUMMY4" ] + //min: "0" + //max: "500" + } + BarSet { + id: bar_set + label: "Pollution (pps)"; + values: [5,10,3,100] + //values: [0,0,0,0] + color: "red" + } } } + /*Button{ + anchors.top: pollution_chart.top + anchors.left: pollution_chart.left + text: "ENLARGE" + onClicked: { + m_chart_enlarged = !m_chart_enlarged; + } + }*/ } + // Filler + //Item{ + // Layout.fillWidth: true + // Layout.fillHeight: true + //} } + + } diff --git a/qml/ui/configpopup/openhd_settings/PopupEnableSTBCLDPC.qml b/qml/ui/configpopup/openhd_settings/PopupEnableSTBCLDPC.qml index e9ba0a982..ec850adda 100644 --- a/qml/ui/configpopup/openhd_settings/PopupEnableSTBCLDPC.qml +++ b/qml/ui/configpopup/openhd_settings/PopupEnableSTBCLDPC.qml @@ -52,49 +52,33 @@ Rectangle{ ListElement {title: "GND: 2 RF PATHS / ANTENNAS"; value: 2} } - GridLayout{ + ColumnLayout{ id: main_row_layout anchors.fill: parent anchors.leftMargin: 10 anchors.rightMargin: 10 - Text{ - id: stbc_warning_text - Layout.row: 0 - Layout.column: 0 - text: "WARNING:\n YOU NEED TO REFLASH YOUR AIR / GROUND UNIT\nIF YOU ENABLE STBC / LDPC ON UNSUPPORTED HW"; - color: "red" - width: main_background.width - height: 200 - horizontalAlignment: Qt.AlignHCenter - verticalAlignment: Qt.AlignVCenter - font.pixelSize: 15 - wrapMode: Text.WordWrap - SequentialAnimation { - running: false - loops: 3 - id: anim_warn_user_stbc - // Expand the button - PropertyAnimation { - target: stbc_warning_text - property: "scale" - to: 2.0 - duration: 300 - easing.type: Easing.InOutQuad - } - // Shrink back to normal - PropertyAnimation { - target: stbc_warning_text - property: "scale" - to: 1.0 - duration: 300 - easing.type: Easing.InOutQuad + Item{ + Layout.fillWidth: true + Layout.preferredHeight: 80 + Text{ // TITLE + anchors.fill: parent + text: "ADVANCED - STBC / LDPC" + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + Button{ + text: "CLOSE" + anchors.top: parent.top + anchors.right: parent.right + onClicked: { + close() } } } + ComboBox { - Layout.row: 1 - Layout.column: 0 id: comboBoxNAntennasAir Layout.minimumWidth: 100 Layout.preferredWidth: 450 @@ -108,8 +92,6 @@ Rectangle{ } } ComboBox { - Layout.row: 2 - Layout.column: 0 id: comboBoxNAntennasGnd Layout.minimumWidth: 100 Layout.preferredWidth: 450 @@ -124,8 +106,6 @@ Rectangle{ } Button{ id: button_enable - Layout.row: 3 - Layout.column: 0 text: "ENABLE" enabled: comboBoxNAntennasAir.currentIndex==2 && comboBoxNAntennasGnd.currentIndex==2; font.pixelSize: 14 @@ -139,11 +119,45 @@ Rectangle{ } } Text{ - Layout.row: 4 - Layout.column: 0 + Layout.fillWidth: true + Layout.preferredHeight: 40 visible: !button_enable.enabled text: "CAN ONLY BE ENABLED IF BOTH AIR AND GND UNIT HAVE 2 RF PATHS / ANTENNAS"; font.pixelSize: 14 + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignLeft + } + Text{ + id: stbc_warning_text + text: "WARNING:\n YOU NEED TO REFLASH YOUR AIR / GROUND UNIT\nIF YOU ENABLE STBC / LDPC ON UNSUPPORTED HW"; + color: "red" + Layout.fillWidth: true + height: 200 + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.pixelSize: 15 + wrapMode: Text.WordWrap + SequentialAnimation { + running: false + loops: 3 + id: anim_warn_user_stbc + // Expand the button + PropertyAnimation { + target: stbc_warning_text + property: "scale" + to: 2.0 + duration: 300 + easing.type: Easing.InOutQuad + } + // Shrink back to normal + PropertyAnimation { + target: stbc_warning_text + property: "scale" + to: 1.0 + duration: 300 + easing.type: Easing.InOutQuad + } + } } Item{ // Filler Layout.row: 5 @@ -154,16 +168,5 @@ Rectangle{ } // ---------------- } - - Button{ - text: "CLOSE" - anchors.top: parent.top - anchors.right: parent.right - onClicked: { - close() - } - } - - } diff --git a/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml b/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml index 04e70941b..3b4879578 100644 --- a/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml +++ b/qml/ui/configpopup/openhd_settings/PopupScanChannels.qml @@ -41,75 +41,68 @@ Rectangle{ ListElement {title: "All 5.8G channels (slow)"; value: 2} } - /*Rectangle{ - implicitWidth:main_grid_layout.width - implicitHeight: main_grid_layout.height - color: "#ADD8E6" - }*/ - - GridLayout{ - id: main_grid_layout + ColumnLayout{ anchors.fill: parent anchors.leftMargin: 10 anchors.rightMargin: 10 - Text{ // TITLE - Layout.row: 0 - Layout.column: 0 - Layout.columnSpan: 2 + Item{ Layout.fillWidth: true - Layout.preferredHeight: 50 - Layout.minimumHeight: 20 - text: "SCAN (FIND AIR UNIT)"; - verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignHCenter - } - - Button{ - Layout.alignment: Qt.AlignRight - Layout.row: 0 - Layout.column: 3 - text: "CLOSE" - onClicked: { - if(_ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==1){ - _qopenhd.show_toast("STILL SCANNING,PLEASE WAIT ..."); - return; + Layout.preferredHeight: 80 + Text{ // TITLE + anchors.fill: parent + text: "SCAN (FIND AIR UNIT)"; + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + Button{ + anchors.right: parent.right + anchors.top: parent.top + text: "CLOSE" + onClicked: { + if(_ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==1){ + _qopenhd.show_toast("STILL SCANNING,PLEASE WAIT ..."); + return; + } + close() } - close() } } - - - SimpleProgressBar{ - Layout.row: 1 - Layout.column: 0 - Layout.preferredWidth: 400 - Layout.minimumWidth: 100 - Layout.preferredHeight: 40 - impl_curr_progress_perc: _wbLinkSettingsHelper.scan_progress_perc - impl_show_progress_text: true - } - Button{ - Layout.row: 1 - Layout.column: 1 - text: "START" - enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0 - onClicked: { - var how_many_freq_bands=comboBoxWhichFrequencyToScan.currentIndex - var how_many_bandwidths = 2; - console.log("Initate channel scan "+how_many_freq_bands+","+how_many_bandwidths) - var result = _wbLinkSettingsHelper.start_scan_channels(how_many_freq_bands,how_many_bandwidths) - if(result){ - _qopenhd.show_toast("Channel scan started, please wait",true) - }else{ - console.log("Cannot initiate channel scan"); - _qopenhd.show_toast("Busy,please try again later",true) + RowLayout{ + SimpleProgressBar{ + Layout.preferredWidth: 400 + Layout.minimumWidth: 100 + Layout.preferredHeight: 40 + impl_curr_progress_perc: _wbLinkSettingsHelper.scan_progress_perc + impl_show_progress_text: true + } + Button{ + text: "START" + enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0 + onClicked: { + var how_many_freq_bands=comboBoxWhichFrequencyToScan.currentIndex + var how_many_bandwidths = 2; + console.log("Initate channel scan "+how_many_freq_bands+","+how_many_bandwidths) + var result = _wbLinkSettingsHelper.start_scan_channels(how_many_freq_bands,how_many_bandwidths) + if(result){ + _qopenhd.show_toast("Channel scan started, please wait",true) + }else{ + console.log("Cannot initiate channel scan"); + _qopenhd.show_toast("Busy,please try again later",true) + } + } + } + ButtonIconInfo{ + onClicked: { + _messageBoxInstance.set_text_and_show("Initiate Channel Scan (Find a running air unit). Similar to analogue TX / RX, this listens on each channel for a short time"+ + " to find a running openhd air unit."+ + "Quick if you are only using the 5 OpenHD recommended channels, otherwise"+ + " please specify the generic band and give it some time (There are a ton of possible channels, especially in 5.8G)") } } } ComboBox { - Layout.row: 2 - Layout.column: 0 Layout.preferredWidth: 400 Layout.minimumWidth: 100 id: comboBoxWhichFrequencyToScan @@ -122,16 +115,6 @@ Rectangle{ } enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0 } - ButtonIconInfo{ - Layout.row: 2 - Layout.column: 1 - onClicked: { - _messageBoxInstance.set_text_and_show("Initiate Channel Scan (Find a running air unit). Similar to analogue TX / RX, this listens on each channel for a short time"+ - " to find a running openhd air unit."+ - "Quick if you are only using the 5 OpenHD recommended channels, otherwise"+ - " please specify the generic band and give it some time (There are a ton of possible channels, especially in 5.8G)") - } - } Text{ Layout.row: 3 Layout.column: 0 @@ -146,22 +129,4 @@ Rectangle{ Layout.fillHeight: true } } - /*Button{ - //Layout.alignment: Qt.AlignRight - //Layout.row: 0 - //Layout.column: 3 - anchors.top: parent.top - anchors.right: parent.right - anchors.topMargin: 5 - anchors.rightMargin: 10 - text: "CLOSE" - onClicked: { - if(_ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==1){ - _qopenhd.show_toast("STILL SCANNING"); - return; - } - close() - } - }*/ - } diff --git a/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml b/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml index 30a5fb1a8..2106a5856 100644 --- a/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml +++ b/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml @@ -228,17 +228,28 @@ Rectangle{ //Layout.minimumWidth: 300 //Layout.preferredWidth: 600 - Text{ // TITLE + Item{ Layout.row: 0 Layout.column: 0 - Layout.columnSpan: 2 + Layout.columnSpan: 4 Layout.fillWidth: true - Layout.preferredHeight: 50 - Layout.minimumHeight: 20 - text: m_is_air ? "AIR TX Power" : "GND TX power"; - verticalAlignment: Qt.AlignVCenter - horizontalAlignment: Qt.AlignHCenter - font.pixelSize: 18 + Layout.preferredHeight: 80 + Text{ // TITLE + anchors.fill: parent + text: "TX POWER "+(m_is_air ? "AIR" : "GROUND"); + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.bold: true + } + Button{ + text: "CLOSE" + anchors.top: parent.top + anchors.right: parent.right + anchors.rightMargin: m_margin + onClicked: { + close() + } + } } // Text{ @@ -418,16 +429,4 @@ Rectangle{ } // ---------------- } - - Button{ - text: "CLOSE" - anchors.top: parent.top - anchors.right: parent.right - anchors.rightMargin: m_margin - onClicked: { - close() - } - } - - }