Skip to content

Commit

Permalink
pollution chart improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Consti10 committed Oct 9, 2023
1 parent c646624 commit c9266d7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
18 changes: 17 additions & 1 deletion app/telemetry/settings/pollutionhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,28 @@ PollutionHelper& PollutionHelper::instance()
return instance;
}

static std::vector<PollutionHelper::PollutionElement> normalize(const std::vector<PollutionHelper::PollutionElement> &values){
int max=0;
for(const auto& value:values){
max=std::max(max,value.n_foreign_packets);
}
if(max==0)return values;
std::vector<PollutionHelper::PollutionElement> ret;
for(auto value:values){
value.n_foreign_packets=value.n_foreign_packets*100 / max;
ret.push_back(value);
}
return ret;

}

void PollutionHelper::threadsafe_update(const std::vector<PollutionElement> &values)
{
const auto normalized=normalize(values);
std::lock_guard<std::mutex> lock(m_pollution_elements_mutex);
m_pollution_elements.clear();
for(const auto& value:values){
//for(const auto& value:values){
for(const auto& value:normalized){
m_pollution_elements[value.frequency_mhz]=value;
//qDebug()<<"Value:"<<value.frequency_mhz;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ Card {

ListModel{
id: model_chann_2G_or_5G
ListElement {title: "All 2.4G and 5.8G channels (slow)"; value: 0}
ListElement {title: "All 2.4G channels"; value: 1}
ListElement {title: "All 5.8G channels"; value: 2}
//ListElement {title: "All 2.4G and 5.8G channels (slow)"; value: 0}
ListElement {title: "OpenHD [1-5] only (fast)"; value: 0}
ListElement {title: "All 2.4G channels (slow)"; value: 1}
ListElement {title: "All 5.8G channels (slow)"; value: 2}
}

// like dji, we use 20 or 40Mhz bandwidth(s) but never 5 or 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ and automatically connect. Otherwise, use the 'FIND AIR UNIT' feature to scan al
Item {
id: mainItem
width: parent.width
height: rowHeight*7
height: rowHeight*(7+4)

DIaloqueStartChannelScan{
id: dialoqueStartChannelScan
Expand Down
3 changes: 3 additions & 0 deletions qml/ui/configpopup/openhd_settings/PollutionChartView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,14 @@ ChartView {
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"
}
}
Expand Down

0 comments on commit c9266d7

Please sign in to comment.