Skip to content

Commit

Permalink
Level app: coloration of RxSat value (#1969)
Browse files Browse the repository at this point in the history
  • Loading branch information
gullradriel committed Mar 10, 2024
1 parent 3b79549 commit 2ac36d2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
28 changes: 22 additions & 6 deletions firmware/application/apps/ui_level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "baseband_api.hpp"
#include "file.hpp"
#include "oversample.hpp"
#include "ui_font_fixed_8x16.hpp"

using namespace portapack;
using namespace tonekey;
Expand Down Expand Up @@ -162,19 +163,34 @@ 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_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()));
}
// refresh sat
uint8_t rx_sat = ((uint32_t)shared_memory.m4_performance_counter) * 100 / 127;
last_rx_sat = rx_sat;
freq_stats_rx.set("RxSat: " + to_string_dec_uint(rx_sat) + "%");
uint8_t br = 0;
uint8_t bg = 0;
uint8_t bb = 0;
if (rx_sat <= 80) {
bg = (255 * rx_sat) / 80;
bb = 255 - bg;
} else if (rx_sat > 80) {
br = (255 * (rx_sat - 80)) / 20;
bg = 255 - br;
}
Style style_freq_stats_rx{
.font = font::fixed_8x16,
.background = {br, bg, bb},
.foreground = {255, 255, 255},
};
freq_stats_rx.set_style(&style_freq_stats_rx);

} /* on_statistic_updates */

size_t LevelView::change_mode(freqman_index_t new_mod) {
Expand Down
8 changes: 4 additions & 4 deletions firmware/application/apps/ui_level.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ class LevelView : public View {

// RSSI: XX/XX/XXX,dt: XX
Text freq_stats_rssi{
{0 * 8, 3 * 16 + 4, 22 * 8, 14},
{0 * 8, 3 * 16 + 4, 22 * 8, 1 * 16},
};

// Power: -XXX db
Text freq_stats_db{
{0 * 8, 4 * 16 + 4, 14 * 8, 14},
{0 * 8, 4 * 16 + 4, 15 * 8, 1 * 16},
};

OptionsField peak_mode{
Expand Down Expand Up @@ -150,7 +150,7 @@ class LevelView : public View {

// RxSat: XX%
Text freq_stats_rx{
{0 * 8, 5 * 16 + 4, 10 * 8, 14},
{0 * 8, 5 * 16 + 4, 10 * 8, 1 * 16},
};

RSSIGraph rssi_graph{
Expand All @@ -160,7 +160,7 @@ class LevelView : public View {

RSSI rssi{
// 240x320 =>
{240 - 5 * 8, 5 * 16 + 4, 5 * 8, 320 - (5 * 16 + 4)},
{240 - 5 * 8, 6 * 16 + 4, 5 * 8, 320 - (6 * 16 + 4)},
};

void handle_coded_squelch(const uint32_t value);
Expand Down

0 comments on commit 2ac36d2

Please sign in to comment.