Break out BasebandStatsView, add main, RSSI threads.

This commit is contained in:
Jared Boone 2015-10-14 10:59:32 -07:00
parent 7f46f0d071
commit 8f7e26b5c1
5 changed files with 122 additions and 58 deletions

View file

@ -25,45 +25,8 @@
#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.register_handler(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.unregister_handler(Message::ID::BasebandStatistics);
}
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,