mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
Break out BasebandStatsView, add main, RSSI threads.
This commit is contained in:
parent
7f46f0d071
commit
8f7e26b5c1
@ -161,6 +161,7 @@ CPPSRC = main.cpp \
|
|||||||
ui_font_fixed_8x16.cpp \
|
ui_font_fixed_8x16.cpp \
|
||||||
ui_setup.cpp \
|
ui_setup.cpp \
|
||||||
ui_debug.cpp \
|
ui_debug.cpp \
|
||||||
|
ui_baseband_stats_view.cpp \
|
||||||
ui_console.cpp \
|
ui_console.cpp \
|
||||||
ui_receiver.cpp \
|
ui_receiver.cpp \
|
||||||
ui_spectrum.cpp \
|
ui_spectrum.cpp \
|
||||||
|
73
firmware/application/ui_baseband_stats_view.cpp
Normal file
73
firmware/application/ui_baseband_stats_view.cpp
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
||||||
|
*
|
||||||
|
* This file is part of PortaPack.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ui_baseband_stats_view.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "hackrf_hal.hpp"
|
||||||
|
using namespace hackrf::one;
|
||||||
|
|
||||||
|
namespace ui {
|
||||||
|
|
||||||
|
/* BasebandStatsView *****************************************************/
|
||||||
|
|
||||||
|
BasebandStatsView::BasebandStatsView() {
|
||||||
|
add_children({ {
|
||||||
|
&text_stats,
|
||||||
|
} });
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
constexpr size_t decimal_digits = 1;
|
||||||
|
constexpr size_t decimal_factor = decimal_digits * 10;
|
||||||
|
|
||||||
|
const uint32_t percent_x10 = ticks / (base_m4_clk_f / (100 * decimal_factor));
|
||||||
|
const uint32_t percent_x10_clipped = std::min(percent_x10, static_cast<uint32_t>(100 * decimal_factor) - 1);
|
||||||
|
return
|
||||||
|
to_string_dec_uint(percent_x10_clipped / decimal_factor, 2) + "." +
|
||||||
|
to_string_dec_uint(percent_x10_clipped % decimal_factor, decimal_digits, '0');
|
||||||
|
}
|
||||||
|
|
||||||
|
void BasebandStatsView::on_statistics_update(const BasebandStatistics& statistics) {
|
||||||
|
std::string message = ticks_to_percent_string(statistics.idle_ticks)
|
||||||
|
+ " " + ticks_to_percent_string(statistics.main_ticks)
|
||||||
|
+ " " + ticks_to_percent_string(statistics.rssi_ticks)
|
||||||
|
+ " " + ticks_to_percent_string(statistics.baseband_ticks);
|
||||||
|
|
||||||
|
text_stats.set(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace ui */
|
48
firmware/application/ui_baseband_stats_view.hpp
Normal file
48
firmware/application/ui_baseband_stats_view.hpp
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
||||||
|
*
|
||||||
|
* This file is part of PortaPack.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __UI_BASEBAND_STATS_VIEW_H__
|
||||||
|
#define __UI_BASEBAND_STATS_VIEW_H__
|
||||||
|
|
||||||
|
#include "ui_widget.hpp"
|
||||||
|
#include "message.hpp"
|
||||||
|
|
||||||
|
namespace ui {
|
||||||
|
|
||||||
|
class BasebandStatsView : public View {
|
||||||
|
public:
|
||||||
|
BasebandStatsView();
|
||||||
|
|
||||||
|
void on_show() override;
|
||||||
|
void on_hide() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Text text_stats {
|
||||||
|
{ 0 * 8, 0, (4 * 4 + 3) * 8, 1 * 16 },
|
||||||
|
"",
|
||||||
|
};
|
||||||
|
|
||||||
|
void on_statistics_update(const BasebandStatistics& statistics);
|
||||||
|
};
|
||||||
|
|
||||||
|
} /* namespace ui */
|
||||||
|
|
||||||
|
#endif/*__UI_BASEBAND_STATS_VIEW_H__*/
|
@ -25,45 +25,8 @@
|
|||||||
|
|
||||||
#include "radio.hpp"
|
#include "radio.hpp"
|
||||||
|
|
||||||
#include "hackrf_hal.hpp"
|
|
||||||
using namespace hackrf::one;
|
|
||||||
|
|
||||||
namespace ui {
|
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) {
|
DebugMemoryView::DebugMemoryView(NavigationView& nav) {
|
||||||
add_children({ {
|
add_children({ {
|
||||||
&text_title,
|
&text_title,
|
||||||
|
@ -32,27 +32,6 @@
|
|||||||
|
|
||||||
namespace ui {
|
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 {
|
class DebugMemoryView : public View {
|
||||||
public:
|
public:
|
||||||
DebugMemoryView(NavigationView& nav);
|
DebugMemoryView(NavigationView& nav);
|
||||||
|
Loading…
Reference in New Issue
Block a user