mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
Extract baseband stats into separate widget
Also removed baseband saturation indication on red (TX) LED. A saturation indicator needs to live somewhere else, and be thought out a bit more...
This commit is contained in:
parent
7c9fc62f5e
commit
154b40d3c9
@ -25,8 +25,43 @@
|
||||
|
||||
#include "radio.hpp"
|
||||
|
||||
#include "hackrf_hal.hpp"
|
||||
using namespace hackrf::one;
|
||||
|
||||
namespace ui {
|
||||
|
||||
/* BasebandStatsView *****************************************************/
|
||||
|
||||
BasebandStatsView::BasebandStatsView() {
|
||||
add_children({ {
|
||||
&text_used,
|
||||
&text_idle,
|
||||
} });
|
||||
}
|
||||
|
||||
void BasebandStatsView::on_show() {
|
||||
context().message_map[Message::ID::BasebandStatistics] = [this](const Message* const p) {
|
||||
this->on_statistics_update(static_cast<const BasebandStatisticsMessage*>(p)->statistics);
|
||||
};
|
||||
}
|
||||
|
||||
void BasebandStatsView::on_hide() {
|
||||
context().message_map[Message::ID::BasebandStatistics] = nullptr;
|
||||
}
|
||||
|
||||
|
||||
static std::string ticks_to_percent_string(const uint32_t ticks) {
|
||||
const uint32_t percent_x100 = ticks / (base_m4_clk_f / 10000);
|
||||
return
|
||||
to_string_dec_uint(percent_x100 / 100, 3) + "." +
|
||||
to_string_dec_uint(percent_x100 % 100, 2, '0') + "%";
|
||||
}
|
||||
|
||||
void BasebandStatsView::on_statistics_update(const BasebandStatistics& statistics) {
|
||||
text_used.set(ticks_to_percent_string(statistics.baseband_ticks));
|
||||
text_idle.set(ticks_to_percent_string(statistics.idle_ticks));
|
||||
}
|
||||
|
||||
DebugMemoryView::DebugMemoryView(NavigationView& nav) {
|
||||
add_children({ {
|
||||
&text_title,
|
||||
|
@ -32,6 +32,27 @@
|
||||
|
||||
namespace ui {
|
||||
|
||||
class BasebandStatsView : public View {
|
||||
public:
|
||||
BasebandStatsView();
|
||||
|
||||
void on_show() override;
|
||||
void on_hide() override;
|
||||
|
||||
private:
|
||||
Text text_used {
|
||||
{ 0, 0, 7 * 8, 1 * 16 },
|
||||
"",
|
||||
};
|
||||
|
||||
Text text_idle {
|
||||
{ 8 * 8, 0, 7 * 8, 1 * 16 },
|
||||
"",
|
||||
};
|
||||
|
||||
void on_statistics_update(const BasebandStatistics& statistics);
|
||||
};
|
||||
|
||||
class DebugMemoryView : public View {
|
||||
public:
|
||||
DebugMemoryView(NavigationView& nav);
|
||||
|
@ -27,10 +27,6 @@
|
||||
#include "ui_debug.hpp"
|
||||
#include "ui_receiver.hpp"
|
||||
|
||||
#include "hackrf_hal.hpp"
|
||||
#include "hackrf_gpio.hpp"
|
||||
using namespace hackrf::one;
|
||||
|
||||
extern ReceiverModel receiver_model;
|
||||
|
||||
namespace ui {
|
||||
@ -42,36 +38,12 @@ SystemStatusView::SystemStatusView() {
|
||||
&portapack,
|
||||
//&text_app_fifo_n,
|
||||
//&text_baseband_fifo_n,
|
||||
&text_ticks,
|
||||
&rssi,
|
||||
&channel,
|
||||
&audio,
|
||||
} });
|
||||
}
|
||||
|
||||
void SystemStatusView::on_show() {
|
||||
context().message_map[Message::ID::BasebandStatistics] = [this](const Message* const p) {
|
||||
this->on_statistics_update(static_cast<const BasebandStatisticsMessage*>(p)->statistics);
|
||||
};
|
||||
}
|
||||
|
||||
void SystemStatusView::on_hide() {
|
||||
context().message_map[Message::ID::BasebandStatistics] = nullptr;
|
||||
}
|
||||
|
||||
static std::string ticks_to_percent_string(const uint32_t ticks) {
|
||||
const uint32_t percent_x100 = ticks / (base_m4_clk_f / 10000);
|
||||
return
|
||||
to_string_dec_uint(percent_x100 / 100, 3) + "." +
|
||||
to_string_dec_uint(percent_x100 % 100, 2, '0') + "%";
|
||||
}
|
||||
|
||||
void SystemStatusView::on_statistics_update(const BasebandStatistics& statistics) {
|
||||
led_tx.write(statistics.saturation);
|
||||
portapack.set(ticks_to_percent_string(statistics.baseband_ticks));
|
||||
text_ticks.set(ticks_to_percent_string(statistics.idle_ticks));
|
||||
}
|
||||
|
||||
/* Navigation ************************************************************/
|
||||
|
||||
NavigationView::NavigationView()
|
||||
|
@ -39,9 +39,6 @@ class SystemStatusView : public View {
|
||||
public:
|
||||
SystemStatusView();
|
||||
|
||||
void on_show() override;
|
||||
void on_hide() override;
|
||||
|
||||
private:
|
||||
Text portapack {
|
||||
{ 0, 0, 9 * 8, 1 * 16 },
|
||||
@ -58,11 +55,6 @@ private:
|
||||
"---",
|
||||
};
|
||||
*/
|
||||
Text text_ticks {
|
||||
{ 9 * 8, 0, 7 * 8, 1 * 16 },
|
||||
"",
|
||||
};
|
||||
|
||||
RSSI rssi {
|
||||
{ 19 * 8, 0, 11 * 8, 4 },
|
||||
};
|
||||
@ -74,8 +66,6 @@ private:
|
||||
Audio audio {
|
||||
{ 19 * 8, 10, 11 * 8, 4 },
|
||||
};
|
||||
|
||||
void on_statistics_update(const BasebandStatistics& statistics);
|
||||
};
|
||||
|
||||
class NavigationView : public View {
|
||||
|
Loading…
Reference in New Issue
Block a user