mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-04 23:45:26 +00:00
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:
parent
1fbfdbccf8
commit
b5e66387c3
@ -39,6 +39,8 @@ void LevelView::focus() {
|
||||
}
|
||||
|
||||
LevelView::~LevelView() {
|
||||
// reset performance counters request to default
|
||||
shared_memory.request_m4_performance_counter = 0;
|
||||
receiver_model.disable();
|
||||
baseband::shutdown();
|
||||
}
|
||||
@ -58,12 +60,16 @@ LevelView::LevelView(NavigationView& nav)
|
||||
&text_ctcss,
|
||||
&freq_stats_rssi,
|
||||
&freq_stats_db,
|
||||
&freq_stats_rx,
|
||||
&audio_mode,
|
||||
&peak_mode,
|
||||
&rssi,
|
||||
&rssi_graph});
|
||||
|
||||
// activate vertical bar mode
|
||||
rssi.set_vertical_rssi(true);
|
||||
// activate counters for RxSat
|
||||
shared_memory.request_m4_performance_counter = 2;
|
||||
|
||||
change_mode(NFM_MODULATION); // Start on AM
|
||||
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);
|
||||
freq_stats_rssi.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) {
|
||||
static int16_t last_max_db = -1000;
|
||||
static int16_t last_min_rssi = -1000;
|
||||
static int16_t last_avg_rssi = -1000;
|
||||
static int16_t last_max_rssi = -1000;
|
||||
static int16_t last_max_db = 0;
|
||||
static uint8_t last_min_rssi = 0;
|
||||
static uint8_t last_avg_rssi = 0;
|
||||
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);
|
||||
|
||||
@ -154,12 +162,18 @@ void LevelView::on_statistics_update(const ChannelStatistics& statistics) {
|
||||
last_max_db = statistics.max_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
|
||||
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_avg_rssi = rssi_graph.get_graph_avg();
|
||||
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 */
|
||||
|
||||
|
@ -62,8 +62,6 @@ class LevelView : public View {
|
||||
void on_statistics_update(const ChannelStatistics& statistics);
|
||||
void set_display_freq(int64_t freq);
|
||||
|
||||
// TODO: needed?
|
||||
int32_t db{0};
|
||||
rf::Frequency freq_ = {0};
|
||||
|
||||
Labels labels{
|
||||
@ -138,6 +136,7 @@ class LevelView : public View {
|
||||
{"peak:5s", 5000},
|
||||
{"peak:10s", 10000},
|
||||
}};
|
||||
|
||||
OptionsField rssi_resolution{
|
||||
{44 + 20 * 8, 4 * 16 + 4},
|
||||
4,
|
||||
@ -149,9 +148,14 @@ class LevelView : public View {
|
||||
{"240x", 240},
|
||||
}};
|
||||
|
||||
// RxSat: XX%
|
||||
Text freq_stats_rx{
|
||||
{0 * 8, 5 * 16 + 4, 10 * 8, 14},
|
||||
};
|
||||
|
||||
RSSIGraph rssi_graph{
|
||||
// 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{
|
||||
|
@ -163,19 +163,19 @@ void RSSI::paint(Painter& painter) {
|
||||
}
|
||||
}
|
||||
|
||||
int16_t RSSI::get_min() {
|
||||
uint8_t RSSI::get_min() {
|
||||
return min_;
|
||||
}
|
||||
|
||||
int16_t RSSI::get_avg() {
|
||||
uint8_t RSSI::get_avg() {
|
||||
return avg_;
|
||||
}
|
||||
|
||||
int16_t RSSI::get_max() {
|
||||
uint8_t RSSI::get_max() {
|
||||
return max_;
|
||||
}
|
||||
|
||||
int16_t RSSI::get_delta() {
|
||||
uint8_t RSSI::get_delta() {
|
||||
return max_ - min_;
|
||||
}
|
||||
|
||||
@ -213,19 +213,19 @@ void RSSI::on_statistics_update(const RSSIStatistics& statistics) {
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
int16_t RSSIGraph::get_graph_min() {
|
||||
uint8_t RSSIGraph::get_graph_min() {
|
||||
return graph_min_;
|
||||
}
|
||||
|
||||
int16_t RSSIGraph::get_graph_avg() {
|
||||
uint8_t RSSIGraph::get_graph_avg() {
|
||||
return graph_avg_;
|
||||
}
|
||||
|
||||
int16_t RSSIGraph::get_graph_max() {
|
||||
uint8_t RSSIGraph::get_graph_max() {
|
||||
return graph_max_;
|
||||
}
|
||||
|
||||
int16_t RSSIGraph::get_graph_delta() {
|
||||
uint8_t RSSIGraph::get_graph_delta() {
|
||||
return graph_max_ - graph_min_;
|
||||
}
|
||||
|
||||
|
@ -50,10 +50,10 @@ class RSSI : public Widget {
|
||||
}
|
||||
|
||||
// get last used/received min/avg/max/delta
|
||||
int16_t get_min();
|
||||
int16_t get_avg();
|
||||
int16_t get_max();
|
||||
int16_t get_delta();
|
||||
uint8_t get_min();
|
||||
uint8_t get_avg();
|
||||
uint8_t get_max();
|
||||
uint8_t get_delta();
|
||||
void set_vertical_rssi(bool enabled);
|
||||
void set_peak(bool enabled, size_t duration);
|
||||
|
||||
@ -63,10 +63,10 @@ class RSSI : public Widget {
|
||||
bool on_touch(const TouchEvent event) override;
|
||||
|
||||
private:
|
||||
int16_t min_ = 0;
|
||||
int16_t avg_ = 0;
|
||||
int16_t max_ = 0;
|
||||
int16_t peak_ = 0;
|
||||
int8_t min_ = 0;
|
||||
int8_t avg_ = 0;
|
||||
int8_t max_ = 0;
|
||||
int8_t peak_ = 0;
|
||||
size_t peak_duration_ = 0;
|
||||
bool instant_exec_{false};
|
||||
|
||||
@ -115,10 +115,10 @@ class RSSIGraph : public Widget {
|
||||
void on_hide() override;
|
||||
void on_show() override;
|
||||
// get whole graph_list min/avg/max/delta
|
||||
int16_t get_graph_min();
|
||||
int16_t get_graph_avg();
|
||||
int16_t get_graph_max();
|
||||
int16_t get_graph_delta();
|
||||
uint8_t get_graph_min();
|
||||
uint8_t get_graph_avg();
|
||||
uint8_t get_graph_max();
|
||||
uint8_t get_graph_delta();
|
||||
|
||||
private:
|
||||
int16_t graph_min_ = 0;
|
||||
|
@ -861,6 +861,7 @@ NavigationView* SystemView::get_navigation_view() {
|
||||
}
|
||||
|
||||
void SystemView::toggle_overlay() {
|
||||
static uint8_t last_perf_counter_status = shared_memory.request_m4_performance_counter;
|
||||
switch (++overlay_active) {
|
||||
case 1:
|
||||
this->add_child(&this->overlay);
|
||||
@ -879,7 +880,7 @@ void SystemView::toggle_overlay() {
|
||||
case 3:
|
||||
this->remove_child(&this->overlay2);
|
||||
this->set_dirty();
|
||||
shared_memory.request_m4_performance_counter = 0;
|
||||
shared_memory.request_m4_performance_counter = last_perf_counter_status;
|
||||
overlay_active = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -22,12 +22,12 @@
|
||||
#ifndef __RSSI_STATS_COLLECTOR_H__
|
||||
#define __RSSI_STATS_COLLECTOR_H__
|
||||
|
||||
#include "rssi.hpp"
|
||||
#include "message.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
#include "rssi.hpp"
|
||||
#include "message.hpp"
|
||||
|
||||
class RSSIStatisticsCollector {
|
||||
public:
|
||||
template <typename Callback>
|
||||
|
@ -133,10 +133,10 @@ class Message {
|
||||
};
|
||||
|
||||
struct RSSIStatistics {
|
||||
uint32_t accumulator{0};
|
||||
uint32_t min{0};
|
||||
uint32_t max{0};
|
||||
uint32_t count{0};
|
||||
uint16_t accumulator{0};
|
||||
uint8_t min{0};
|
||||
uint8_t max{0};
|
||||
uint16_t count{0};
|
||||
};
|
||||
|
||||
class RSSIStatisticsMessage : public Message {
|
||||
|
Loading…
Reference in New Issue
Block a user