Rxsat in Level app (#1959)

* added Rx Saturation

* testing reducing values to uint8_t

* clang format

* refactorisation

* cleanings

* cleanings

* set back request_m4_performance_counter to zero on app exit

---------

Co-authored-by: GullCode <gullradriel@hotmail.com>
This commit is contained in:
gullradriel 2024-03-09 15:26:56 +01:00 committed by GitHub
parent 1fbfdbccf8
commit b5e66387c3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 55 additions and 36 deletions

View File

@ -39,6 +39,8 @@ void LevelView::focus() {
} }
LevelView::~LevelView() { LevelView::~LevelView() {
// reset performance counters request to default
shared_memory.request_m4_performance_counter = 0;
receiver_model.disable(); receiver_model.disable();
baseband::shutdown(); baseband::shutdown();
} }
@ -58,12 +60,16 @@ LevelView::LevelView(NavigationView& nav)
&text_ctcss, &text_ctcss,
&freq_stats_rssi, &freq_stats_rssi,
&freq_stats_db, &freq_stats_db,
&freq_stats_rx,
&audio_mode, &audio_mode,
&peak_mode, &peak_mode,
&rssi, &rssi,
&rssi_graph}); &rssi_graph});
// activate vertical bar mode
rssi.set_vertical_rssi(true); rssi.set_vertical_rssi(true);
// activate counters for RxSat
shared_memory.request_m4_performance_counter = 2;
change_mode(NFM_MODULATION); // Start on AM change_mode(NFM_MODULATION); // Start on AM
field_mode.set_by_value(NFM_MODULATION); // Reflect the mode into the manual selector field_mode.set_by_value(NFM_MODULATION); // Reflect the mode into the manual selector
@ -139,13 +145,15 @@ LevelView::LevelView(NavigationView& nav)
freqman_set_step_option_short(step_mode); freqman_set_step_option_short(step_mode);
freq_stats_rssi.set_style(&Styles::white); freq_stats_rssi.set_style(&Styles::white);
freq_stats_db.set_style(&Styles::white); freq_stats_db.set_style(&Styles::white);
freq_stats_rx.set_style(&Styles::white);
} }
void LevelView::on_statistics_update(const ChannelStatistics& statistics) { void LevelView::on_statistics_update(const ChannelStatistics& statistics) {
static int16_t last_max_db = -1000; static int16_t last_max_db = 0;
static int16_t last_min_rssi = -1000; static uint8_t last_min_rssi = 0;
static int16_t last_avg_rssi = -1000; static uint8_t last_avg_rssi = 0;
static int16_t last_max_rssi = -1000; static uint8_t last_max_rssi = 0;
static uint8_t last_rx_sat = 0;
rssi_graph.add_values(rssi.get_min(), rssi.get_avg(), rssi.get_max(), statistics.max_db); rssi_graph.add_values(rssi.get_min(), rssi.get_avg(), rssi.get_max(), statistics.max_db);
@ -154,12 +162,18 @@ void LevelView::on_statistics_update(const ChannelStatistics& statistics) {
last_max_db = statistics.max_db; last_max_db = statistics.max_db;
freq_stats_db.set("Power: " + to_string_dec_int(statistics.max_db) + " db"); freq_stats_db.set("Power: " + to_string_dec_int(statistics.max_db) + " db");
} }
// refresh sat
uint8_t rx_sat = ((uint32_t)shared_memory.m4_performance_counter) * 100 / 127;
if (last_rx_sat != rx_sat) {
last_rx_sat = rx_sat;
freq_stats_rx.set("RxSat: " + to_string_dec_uint(rx_sat) + "%");
}
// refresh rssi // refresh rssi
if (last_min_rssi != rssi_graph.get_graph_min() || last_avg_rssi != rssi_graph.get_graph_avg() || last_max_rssi != rssi_graph.get_graph_max()) { if (last_min_rssi != rssi_graph.get_graph_min() || last_avg_rssi != rssi_graph.get_graph_avg() || last_max_rssi != rssi_graph.get_graph_max()) {
last_min_rssi = rssi_graph.get_graph_min(); last_min_rssi = rssi_graph.get_graph_min();
last_avg_rssi = rssi_graph.get_graph_avg(); last_avg_rssi = rssi_graph.get_graph_avg();
last_max_rssi = rssi_graph.get_graph_max(); last_max_rssi = rssi_graph.get_graph_max();
freq_stats_rssi.set("RSSI: " + to_string_dec_int(last_min_rssi) + "/" + to_string_dec_int(last_avg_rssi) + "/" + to_string_dec_int(last_max_rssi) + ",dt: " + to_string_dec_int(rssi_graph.get_graph_delta())); freq_stats_rssi.set("RSSI: " + to_string_dec_uint(last_min_rssi) + "/" + to_string_dec_uint(last_avg_rssi) + "/" + to_string_dec_uint(last_max_rssi) + ", dt: " + to_string_dec_uint(rssi_graph.get_graph_delta()));
} }
} /* on_statistic_updates */ } /* on_statistic_updates */

View File

@ -62,8 +62,6 @@ class LevelView : public View {
void on_statistics_update(const ChannelStatistics& statistics); void on_statistics_update(const ChannelStatistics& statistics);
void set_display_freq(int64_t freq); void set_display_freq(int64_t freq);
// TODO: needed?
int32_t db{0};
rf::Frequency freq_ = {0}; rf::Frequency freq_ = {0};
Labels labels{ Labels labels{
@ -138,6 +136,7 @@ class LevelView : public View {
{"peak:5s", 5000}, {"peak:5s", 5000},
{"peak:10s", 10000}, {"peak:10s", 10000},
}}; }};
OptionsField rssi_resolution{ OptionsField rssi_resolution{
{44 + 20 * 8, 4 * 16 + 4}, {44 + 20 * 8, 4 * 16 + 4},
4, 4,
@ -149,9 +148,14 @@ class LevelView : public View {
{"240x", 240}, {"240x", 240},
}}; }};
// RxSat: XX%
Text freq_stats_rx{
{0 * 8, 5 * 16 + 4, 10 * 8, 14},
};
RSSIGraph rssi_graph{ RSSIGraph rssi_graph{
// 240x320 => // 240x320 =>
{0, 5 * 16 + 4, 240 - 5 * 8, 320 - (5 * 16 + 4)}, {0, 6 * 16 + 4, 240 - 5 * 8, 320 - (6 * 16 + 4)},
}; };
RSSI rssi{ RSSI rssi{

View File

@ -163,19 +163,19 @@ void RSSI::paint(Painter& painter) {
} }
} }
int16_t RSSI::get_min() { uint8_t RSSI::get_min() {
return min_; return min_;
} }
int16_t RSSI::get_avg() { uint8_t RSSI::get_avg() {
return avg_; return avg_;
} }
int16_t RSSI::get_max() { uint8_t RSSI::get_max() {
return max_; return max_;
} }
int16_t RSSI::get_delta() { uint8_t RSSI::get_delta() {
return max_ - min_; return max_ - min_;
} }
@ -213,19 +213,19 @@ void RSSI::on_statistics_update(const RSSIStatistics& statistics) {
set_dirty(); set_dirty();
} }
int16_t RSSIGraph::get_graph_min() { uint8_t RSSIGraph::get_graph_min() {
return graph_min_; return graph_min_;
} }
int16_t RSSIGraph::get_graph_avg() { uint8_t RSSIGraph::get_graph_avg() {
return graph_avg_; return graph_avg_;
} }
int16_t RSSIGraph::get_graph_max() { uint8_t RSSIGraph::get_graph_max() {
return graph_max_; return graph_max_;
} }
int16_t RSSIGraph::get_graph_delta() { uint8_t RSSIGraph::get_graph_delta() {
return graph_max_ - graph_min_; return graph_max_ - graph_min_;
} }

View File

@ -50,10 +50,10 @@ class RSSI : public Widget {
} }
// get last used/received min/avg/max/delta // get last used/received min/avg/max/delta
int16_t get_min(); uint8_t get_min();
int16_t get_avg(); uint8_t get_avg();
int16_t get_max(); uint8_t get_max();
int16_t get_delta(); uint8_t get_delta();
void set_vertical_rssi(bool enabled); void set_vertical_rssi(bool enabled);
void set_peak(bool enabled, size_t duration); void set_peak(bool enabled, size_t duration);
@ -63,10 +63,10 @@ class RSSI : public Widget {
bool on_touch(const TouchEvent event) override; bool on_touch(const TouchEvent event) override;
private: private:
int16_t min_ = 0; int8_t min_ = 0;
int16_t avg_ = 0; int8_t avg_ = 0;
int16_t max_ = 0; int8_t max_ = 0;
int16_t peak_ = 0; int8_t peak_ = 0;
size_t peak_duration_ = 0; size_t peak_duration_ = 0;
bool instant_exec_{false}; bool instant_exec_{false};
@ -115,10 +115,10 @@ class RSSIGraph : public Widget {
void on_hide() override; void on_hide() override;
void on_show() override; void on_show() override;
// get whole graph_list min/avg/max/delta // get whole graph_list min/avg/max/delta
int16_t get_graph_min(); uint8_t get_graph_min();
int16_t get_graph_avg(); uint8_t get_graph_avg();
int16_t get_graph_max(); uint8_t get_graph_max();
int16_t get_graph_delta(); uint8_t get_graph_delta();
private: private:
int16_t graph_min_ = 0; int16_t graph_min_ = 0;

View File

@ -861,6 +861,7 @@ NavigationView* SystemView::get_navigation_view() {
} }
void SystemView::toggle_overlay() { void SystemView::toggle_overlay() {
static uint8_t last_perf_counter_status = shared_memory.request_m4_performance_counter;
switch (++overlay_active) { switch (++overlay_active) {
case 1: case 1:
this->add_child(&this->overlay); this->add_child(&this->overlay);
@ -879,7 +880,7 @@ void SystemView::toggle_overlay() {
case 3: case 3:
this->remove_child(&this->overlay2); this->remove_child(&this->overlay2);
this->set_dirty(); this->set_dirty();
shared_memory.request_m4_performance_counter = 0; shared_memory.request_m4_performance_counter = last_perf_counter_status;
overlay_active = 0; overlay_active = 0;
break; break;
} }

View File

@ -22,12 +22,12 @@
#ifndef __RSSI_STATS_COLLECTOR_H__ #ifndef __RSSI_STATS_COLLECTOR_H__
#define __RSSI_STATS_COLLECTOR_H__ #define __RSSI_STATS_COLLECTOR_H__
#include "rssi.hpp"
#include "message.hpp"
#include <cstdint> #include <cstdint>
#include <cstddef> #include <cstddef>
#include "rssi.hpp"
#include "message.hpp"
class RSSIStatisticsCollector { class RSSIStatisticsCollector {
public: public:
template <typename Callback> template <typename Callback>

View File

@ -133,10 +133,10 @@ class Message {
}; };
struct RSSIStatistics { struct RSSIStatistics {
uint32_t accumulator{0}; uint16_t accumulator{0};
uint32_t min{0}; uint8_t min{0};
uint32_t max{0}; uint8_t max{0};
uint32_t count{0}; uint16_t count{0};
}; };
class RSSIStatisticsMessage : public Message { class RSSIStatisticsMessage : public Message {