Skip to content

Commit

Permalink
Improve UI:
Browse files Browse the repository at this point in the history
1) More consistent layouting for the (SCAN,ANALYZE,STBC,TX POWER) elements
2) Analyze progress
3) refactor out the qopenhd frequency list
  • Loading branch information
Consti10 committed Oct 31, 2023
1 parent 6a3a079 commit ef4edef
Show file tree
Hide file tree
Showing 15 changed files with 661 additions and 341 deletions.
79 changes: 79 additions & 0 deletions app/telemetry/settings/frequencyhelper.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#include "frequencyhelper.h"

FrequencyHelper::FrequencyHelper()
{

}

std::vector<FrequencyHelper::FrequencyItem> FrequencyHelper::get_known_frequency_items()
{
std::vector<FrequencyItem> ret{
FrequencyItem{-1,2312,false,false,false,-1},
FrequencyItem{-1,2332,false,false,false,-1},
FrequencyItem{-1,2352,false,false,false,-1},
FrequencyItem{-1,2372,false,false,false,-1},
FrequencyItem{-1,2392,false,false,false,-1},
// ACTUAL 2G
FrequencyItem{1 ,2412,false,true,false,-1},
FrequencyItem{5 ,2432,false,true,false,-1},
FrequencyItem{9 ,2452,false,true,false,-1},
FrequencyItem{13,2472,false,true,false,-1},
FrequencyItem{14,2484,false,false,false,-1},
// ACTUAL 2G end
FrequencyItem{-1,2492,false,false,false,-1},
FrequencyItem{-1,2512,false,false,false,-1},
FrequencyItem{-1,2532,false,false,false,-1},
FrequencyItem{-1,2572,false,false,false,-1},
FrequencyItem{-1,2592,false,false,false,-1},
FrequencyItem{-1,2612,false,false,false,-1},
FrequencyItem{-1,2632,false,false,false,-1},
FrequencyItem{-1,2652,false,false,false,-1},
FrequencyItem{-1,2672,false,false,false,-1},
FrequencyItem{-1,2692,false,false,false,-1},
FrequencyItem{-1, 2712,false,false,false,-1},
// 5G begin
FrequencyItem{ 32,5160,false,false,false,-1},
FrequencyItem{ 36,5180,false,true ,false,-1},
FrequencyItem{ 40,5200,false,false,false,-1},
FrequencyItem{ 44,5220,false,true,false,-1},
FrequencyItem{ 48,5240,false,false,false,-1},
FrequencyItem{ 52,5260,true,true ,false,-1},
FrequencyItem{ 56,5280,true,false,false,-1},
FrequencyItem{ 60,5300,true,true,false,-1},
FrequencyItem{ 64,5320,true,false,false,-1},
// big break / part that is not allowed
FrequencyItem{100,5500,true,true,false,-1},
FrequencyItem{104,5520,true,false,false,-1},
FrequencyItem{108,5540,true,true,false,-1},
FrequencyItem{112,5560,true,false,false,-1},
FrequencyItem{116,5580,true,true,false,-1},
FrequencyItem{120,5600,true,false,false,-1},
FrequencyItem{124,5620,true,true,false,-1},
FrequencyItem{128,5640,true,false,false,-1},
FrequencyItem{132,5660,true,true,false,-1},
FrequencyItem{136,5680,true,false,false,-1},
FrequencyItem{140,5700,false,true,false,1},
FrequencyItem{144,5720,false,false,false,-1},
// Here is the weird break
FrequencyItem{149,5745,false,true,true,2},
FrequencyItem{153,5765,false,false,false,-1},
FrequencyItem{157,5785,false,true,true,3},
FrequencyItem{161,5805,false,false,false,-1},
FrequencyItem{165,5825,false,true,true,4},
// Depends
FrequencyItem{169,5845,false,false,false,-1},
FrequencyItem{173,5865,false,true,true,5},
FrequencyItem{177,5885,false,false,false,-1},
FrequencyItem{181,5905,false,false,true,-1}
};
return ret;
}

FrequencyHelper::FrequencyItem FrequencyHelper::find_frequency_item(const int frequency)
{
const auto frequency_items=get_known_frequency_items();
for(const auto& item:frequency_items){
if(item.frequency==frequency)return item;
}
return FrequencyItem{-1,-1,false,false,false};
}
24 changes: 24 additions & 0 deletions app/telemetry/settings/frequencyhelper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef FREQUENCYHELPER_H
#define FREQUENCYHELPER_H

#include <vector>



class FrequencyHelper
{
public:
FrequencyHelper();
struct FrequencyItem{
int channel_nr;
int frequency;
bool radar;
bool simple;
bool recommended;
int openhd_raceband;
};
static std::vector<FrequencyItem> get_known_frequency_items();
static FrequencyItem find_frequency_item(const int frequency);
};

#endif // FREQUENCYHELPER_H
108 changes: 21 additions & 87 deletions app/telemetry/settings/wblinksettingshelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "../../util/qopenhd.h"

#include "pollutionhelper.h"
#include "frequencyhelper.h"

static void tmp_log_result(bool enable,const std::string message){
if(enable){
Expand Down Expand Up @@ -139,11 +140,15 @@ void WBLinkSettingsHelper::process_message_openhd_wifibroadcast_analyze_channels
ss<<" Foreign packets:"<<curr_foreign_packets<<" ";
if(msg.progress_perc>=100){
ss<<"100%, Done";
// DONE
set_current_analyze_frequency(-1);
}else{
ss<<(int)msg.progress_perc<<"%";
set_current_analyze_frequency(curr_channel_mhz);
}
qDebug()<<ss.str().c_str();
PollutionHelper::instance().threadsafe_update(analyzed_channels);
set_analyze_progress_perc(msg.progress_perc);
// signal to the UI to rebuild model
signal_ui_rebuild_model_when_possible();
}
Expand All @@ -168,7 +173,7 @@ void WBLinkSettingsHelper::process_message_openhd_wifibroadcast_scan_channels_pr
set_scanning_text_for_ui(ss2.str().c_str());
}else{
std::stringstream ss2;
ss2<<"Couldn't find air unit";
ss2<<"No air unit found";
set_scanning_text_for_ui(ss2.str().c_str());
}
}else{
Expand Down Expand Up @@ -222,86 +227,6 @@ bool WBLinkSettingsHelper::change_param_ground_only_blocking(QString param_id, i
return false;
}


struct FrequencyItem{
int channel_nr;
int frequency;
bool radar;
bool simple;
bool recommended;
int openhd_raceband;
};
static std::vector<FrequencyItem> get_freq_descr(){
std::vector<FrequencyItem> ret{
FrequencyItem{-1,2312,false,false,false,-1},
FrequencyItem{-1,2332,false,false,false,-1},
FrequencyItem{-1,2352,false,false,false,-1},
FrequencyItem{-1,2372,false,false,false,-1},
FrequencyItem{-1,2392,false,false,false,-1},
// ACTUAL 2G
FrequencyItem{1 ,2412,false,true,false,-1},
FrequencyItem{5 ,2432,false,true,false,-1},
FrequencyItem{9 ,2452,false,true,false,-1},
FrequencyItem{13,2472,false,true,false,-1},
FrequencyItem{14,2484,false,false,false,-1},
// ACTUAL 2G end
FrequencyItem{-1,2492,false,false,false,-1},
FrequencyItem{-1,2512,false,false,false,-1},
FrequencyItem{-1,2532,false,false,false,-1},
FrequencyItem{-1,2572,false,false,false,-1},
FrequencyItem{-1,2592,false,false,false,-1},
FrequencyItem{-1,2612,false,false,false,-1},
FrequencyItem{-1,2632,false,false,false,-1},
FrequencyItem{-1,2652,false,false,false,-1},
FrequencyItem{-1,2672,false,false,false,-1},
FrequencyItem{-1,2692,false,false,false,-1},
FrequencyItem{-1, 2712,false,false,false,-1},
// 5G begin
FrequencyItem{ 32,5160,false,false,false,-1},
FrequencyItem{ 36,5180,false,true ,false,-1},
FrequencyItem{ 40,5200,false,false,false,-1},
FrequencyItem{ 44,5220,false,true,false,-1},
FrequencyItem{ 48,5240,false,false,false,-1},
FrequencyItem{ 52,5260,true,true ,false,-1},
FrequencyItem{ 56,5280,true,false,false,-1},
FrequencyItem{ 60,5300,true,true,false,-1},
FrequencyItem{ 64,5320,true,false,false,-1},
// big break / part that is not allowed
FrequencyItem{100,5500,true,true,false,-1},
FrequencyItem{104,5520,true,false,false,-1},
FrequencyItem{108,5540,true,true,false,-1},
FrequencyItem{112,5560,true,false,false,-1},
FrequencyItem{116,5580,true,true,false,-1},
FrequencyItem{120,5600,true,false,false,-1},
FrequencyItem{124,5620,true,true,false,-1},
FrequencyItem{128,5640,true,false,false,-1},
FrequencyItem{132,5660,true,true,false,-1},
FrequencyItem{136,5680,true,false,false,-1},
FrequencyItem{140,5700,false,true,false,1},
FrequencyItem{144,5720,false,false,false,-1},
// Here is the weird break
FrequencyItem{149,5745,false,true,true,2},
FrequencyItem{153,5765,false,false,false,-1},
FrequencyItem{157,5785,false,true,true,3},
FrequencyItem{161,5805,false,false,false,-1},
FrequencyItem{165,5825,false,true,true,4},
// Depends
FrequencyItem{169,5845,false,false,false,-1},
FrequencyItem{173,5865,false,true,true,5},
FrequencyItem{177,5885,false,false,false,-1},
FrequencyItem{181,5905,false,false,true,-1}
};
return ret;
}

static FrequencyItem find_frequency_item(const int frequency){
const auto frequency_items=get_freq_descr();
for(const auto& item:frequency_items){
if(item.frequency==frequency)return item;
}
return FrequencyItem{-1,-1,false,false,false};
}

static std::string spaced_string(int number){
std::stringstream ss;
if(number<100)ss<<" ";
Expand All @@ -312,7 +237,7 @@ static std::string spaced_string(int number){

QString WBLinkSettingsHelper::get_frequency_description(int frequency_mhz)
{
const auto frequency_item=find_frequency_item(frequency_mhz);
const auto frequency_item=FrequencyHelper::find_frequency_item(frequency_mhz);
std::stringstream ss;
const bool is_2g=frequency_mhz<3000;
if(is_2g){
Expand All @@ -333,25 +258,25 @@ QString WBLinkSettingsHelper::get_frequency_description(int frequency_mhz)

bool WBLinkSettingsHelper::get_frequency_radar(int frequency_mhz)
{
const auto frequency_item=find_frequency_item(frequency_mhz);
const auto frequency_item=FrequencyHelper::find_frequency_item(frequency_mhz);
return frequency_item.radar;
}

bool WBLinkSettingsHelper::get_frequency_simplify(int frequency_mhz)
{
const auto frequency_item=find_frequency_item(frequency_mhz);
const auto frequency_item=FrequencyHelper::find_frequency_item(frequency_mhz);
return frequency_item.simple;
}

bool WBLinkSettingsHelper::get_frequency_reccommended(int frequency_mhz)
{
const auto frequency_item=find_frequency_item(frequency_mhz);
const auto frequency_item=FrequencyHelper::find_frequency_item(frequency_mhz);
return frequency_item.recommended;
}

int WBLinkSettingsHelper::get_frequency_openhd_race_band(int frequency_mhz)
{
const auto frequency_item=find_frequency_item(frequency_mhz);
const auto frequency_item=FrequencyHelper::find_frequency_item(frequency_mhz);
return frequency_item.openhd_raceband;
}

Expand Down Expand Up @@ -508,7 +433,7 @@ QList<int> WBLinkSettingsHelper::get_supported_frequencies_filtered(int filter_l
for(auto& frequency: supported_frequencies){
if(filter_level==1){
// 40Mhz spacing
auto info=find_frequency_item(frequency);
auto info=FrequencyHelper::find_frequency_item(frequency);
if(info.simple){
ret.push_back(frequency);
}
Expand Down Expand Up @@ -547,6 +472,15 @@ QVariantList WBLinkSettingsHelper::pollution_frequencies_int_get_pollution(QList
return ret;
}

int WBLinkSettingsHelper::pollution_get_last_scan_pollution_for_frequency(int frequency)
{
auto tmp=PollutionHelper::instance().threadsafe_get_pollution_for_frequency(frequency);
if(tmp.has_value()){
return tmp.value().n_foreign_packets;
}
return -1;
}


void WBLinkSettingsHelper::signal_ui_rebuild_model_when_possible()
{
Expand Down
2 changes: 2 additions & 0 deletions app/telemetry/settings/wblinksettingshelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class WBLinkSettingsHelper : public QObject
L_RO_PROP(int,scan_progress_perc,set_scan_progress_perc,0)
// Analyzing
L_RO_PROP(int,analyze_progress_perc,set_analyze_progress_perc,0)
L_RO_PROP(int,current_analyze_frequency,set_current_analyze_frequency,-1);
public:
void process_message_openhd_wifibroadcast_supported_channels(const mavlink_openhd_wifbroadcast_supported_channels_t& msg);
void process_message_openhd_wifibroadcast_analyze_channels_progress(const mavlink_openhd_wifbroadcast_analyze_channels_progress_t& msg);
Expand Down Expand Up @@ -98,6 +99,7 @@ class WBLinkSettingsHelper : public QObject
Q_INVOKABLE QList<int> get_supported_frequencies_filtered(int filter_level);
Q_INVOKABLE QStringList pollution_frequencies_int_to_qstringlist(QList<int> frequencies);
Q_INVOKABLE QVariantList pollution_frequencies_int_get_pollution(QList<int> 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);
Expand Down
2 changes: 2 additions & 0 deletions app/telemetry/telemetry.pri
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ SOURCES += \
$$PWD/connection/udp_connection.cpp \
$$PWD/models/fcmapmodel.cpp \
$$PWD/settings/documentedparam.cpp \
$$PWD/settings/frequencyhelper.cpp \
$$PWD/settings/pollutionhelper.cpp \
$$PWD/settings/wblinksettingshelper.cpp \
$$PWD/action/impl/xparam.cpp \
Expand All @@ -36,6 +37,7 @@ HEADERS += \
$$PWD/connection/tcp_connection.h \
$$PWD/settings/documentedparam.h \
$$PWD/action/impl/xparam.h \
$$PWD/settings/frequencyhelper.h \
$$PWD/settings/pollutionhelper.h \
$$PWD/util/geodesi_helper.h \
$$PWD/util/mavlink_enum_to_string.h \
Expand Down
19 changes: 10 additions & 9 deletions qml/qml.qrc
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
<RCC>
<qresource lang="en" prefix="/translations">
<qresource prefix="/translations" lang="en">
<file alias="QOpenHD.qm">../translations/QOpenHD_en.qm</file>
<file>resources/cursors/arrow_512_green.png</file>
<file>resources/cursors/arrow_512_transparent.png</file>
<file>resources/cursors/arrow_512_white.png</file>
<file>resources/cursors/hand_white.png</file>
</qresource>
<qresource lang="de" prefix="/translations">
<qresource prefix="/translations" lang="de">
<file alias="QOpenHD.qm">../translations/QOpenHD_de.qm</file>
</qresource>
<qresource lang="ru" prefix="/translations">
<qresource prefix="/translations" lang="ru">
<file alias="QOpenHD.qm">../translations/QOpenHD_ru.qm</file>
</qresource>
<qresource lang="es" prefix="/translations">
<qresource prefix="/translations" lang="es">
<file alias="QOpenHD.qm">../translations/QOpenHD_es.qm</file>
</qresource>
<qresource lang="fr" prefix="/translations">
<qresource prefix="/translations" lang="fr">
<file alias="QOpenHD.qm">../translations/QOpenHD_fr.qm</file>
</qresource>
<qresource lang="nl" prefix="/translations">
<qresource prefix="/translations" lang="nl">
<file alias="QOpenHD.qm">../translations/QOpenHD_nl.qm</file>
</qresource>
<qresource lang="ro" prefix="/translations">
<qresource prefix="/translations" lang="ro">
<file alias="QOpenHD.qm">../translations/QOpenHD_ro.qm</file>
</qresource>
<qresource lang="it" prefix="/translations">
<qresource prefix="/translations" lang="it">
<file alias="QOpenHD.qm">../translations/QOpenHD_it.qm</file>
</qresource>
<qresource lang="zh" prefix="/translations">
<qresource prefix="/translations" lang="zh">
<file alias="QOpenHD.qm">../translations/QOpenHD_zh.qm</file>
</qresource>
<qresource prefix="/">
Expand Down Expand Up @@ -258,5 +258,6 @@
<file>ui/configpopup/openhd_settings/PopupEnableSTBCLDPC.qml</file>
<file>ui/widgets/PerformanceHorizonWidget2.qml</file>
<file>ui/configpopup/status/StatusCardsColumn.qml</file>
<file>ui/elements/SimpleLeftRightText.qml</file>
</qresource>
</RCC>
Loading

0 comments on commit ef4edef

Please sign in to comment.