From 154b40d3c9274d47e00412b9df4374792e79d693 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Thu, 9 Jul 2015 11:53:10 -0700 Subject: [PATCH] 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... --- firmware/application/ui_debug.cpp | 35 ++++++++++++++++++++++++++ firmware/application/ui_debug.hpp | 21 ++++++++++++++++ firmware/application/ui_navigation.cpp | 28 --------------------- firmware/application/ui_navigation.hpp | 10 -------- 4 files changed, 56 insertions(+), 38 deletions(-) diff --git a/firmware/application/ui_debug.cpp b/firmware/application/ui_debug.cpp index 28d99abf..a8ba25ef 100644 --- a/firmware/application/ui_debug.cpp +++ b/firmware/application/ui_debug.cpp @@ -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(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, diff --git a/firmware/application/ui_debug.hpp b/firmware/application/ui_debug.hpp index 92fa0c47..3f92fa6d 100644 --- a/firmware/application/ui_debug.hpp +++ b/firmware/application/ui_debug.hpp @@ -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); diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index 5cff1f07..82b92df8 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -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(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() diff --git a/firmware/application/ui_navigation.hpp b/firmware/application/ui_navigation.hpp index 38d3e13a..c0cadbfc 100644 --- a/firmware/application/ui_navigation.hpp +++ b/firmware/application/ui_navigation.hpp @@ -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 {