mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-13 03:34:35 +00:00
implemented M4 stats
This commit is contained in:
parent
850a79c9bb
commit
2ef9ebd7bd
@ -39,9 +39,6 @@ DfuMenu::DfuMenu(NavigationView& nav) : nav_ (nav) {
|
||||
}
|
||||
|
||||
void DfuMenu::paint(Painter& painter) {
|
||||
//update child values
|
||||
// if (chThdSelf() == chSysGetIdleThread()) { chThdGetTicks(chThdSelf()) }
|
||||
|
||||
auto now = chTimeNow();
|
||||
auto idle_ticks = chThdGetTicks(chSysGetIdleThread());
|
||||
|
||||
@ -57,20 +54,52 @@ void DfuMenu::paint(Painter& painter) {
|
||||
text_info_line_1.set(to_string_dec_uint(chCoreStatus(), 6));
|
||||
text_info_line_2.set(to_string_dec_uint((uint32_t)get_free_stack_space(), 6));
|
||||
text_info_line_3.set(to_string_dec_uint((time_elapsed - idle_elapsed) / 10, 6));
|
||||
text_info_line_4.set("M4 heap");
|
||||
text_info_line_5.set("M4 stack");
|
||||
text_info_line_6.set("M4 cpu");
|
||||
text_info_line_4.set(to_string_dec_uint(shared_memory.m4_heap_usage, 6));
|
||||
text_info_line_5.set(to_string_dec_uint(shared_memory.m4_stack_usage, 6));
|
||||
text_info_line_6.set(to_string_dec_uint(shared_memory.m4_cpu_usage, 6));
|
||||
text_info_line_7.set(to_string_dec_uint(chTimeNow()/1000, 6));
|
||||
|
||||
auto screen_size = portapack::display.screen_rect().size();
|
||||
|
||||
constexpr auto margin = 5;
|
||||
|
||||
painter.fill_rectangle(
|
||||
{
|
||||
{6 * CHARACTER_WIDTH, 3 * LINE_HEIGHT},
|
||||
{screen_size.width() - 12 * CHARACTER_WIDTH, screen_size.height() - 6 * LINE_HEIGHT}
|
||||
{6 * CHARACTER_WIDTH - margin, 3 * LINE_HEIGHT - margin},
|
||||
{15 * CHARACTER_WIDTH + margin * 2, 9 * LINE_HEIGHT + margin * 2}
|
||||
},
|
||||
ui::Color::black()
|
||||
);
|
||||
|
||||
painter.fill_rectangle(
|
||||
{
|
||||
{5 * CHARACTER_WIDTH - margin, 3 * LINE_HEIGHT - margin},
|
||||
{CHARACTER_WIDTH, 9 * LINE_HEIGHT + margin * 2}
|
||||
},
|
||||
ui::Color::dark_cyan()
|
||||
);
|
||||
|
||||
painter.fill_rectangle(
|
||||
{
|
||||
{21 * CHARACTER_WIDTH + margin, 3 * LINE_HEIGHT - margin},
|
||||
{CHARACTER_WIDTH, 9 * LINE_HEIGHT + margin * 2}
|
||||
},
|
||||
ui::Color::dark_cyan()
|
||||
);
|
||||
|
||||
painter.fill_rectangle(
|
||||
{
|
||||
{5 * CHARACTER_WIDTH - margin, 3 * LINE_HEIGHT - margin - 8},
|
||||
{17 * CHARACTER_WIDTH + margin * 2, 8}
|
||||
},
|
||||
ui::Color::dark_cyan()
|
||||
);
|
||||
|
||||
painter.fill_rectangle(
|
||||
{
|
||||
{5 * CHARACTER_WIDTH - margin, 12 * LINE_HEIGHT + margin},
|
||||
{17 * CHARACTER_WIDTH + margin * 2, 8}
|
||||
},
|
||||
ui::Color::dark_cyan()
|
||||
);
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
||||
|
@ -45,29 +45,25 @@ public:
|
||||
private:
|
||||
NavigationView& nav_;
|
||||
|
||||
Text text_head {{ 6 * CHARACTER_WIDTH, 3 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT }, "DFU Menu"};
|
||||
Text text_head {{ 6 * CHARACTER_WIDTH, 3 * LINE_HEIGHT, 11 * CHARACTER_WIDTH, 1 * LINE_HEIGHT }, "Performance"};
|
||||
|
||||
Labels labels {
|
||||
{ { 6 * CHARACTER_WIDTH, 5 * LINE_HEIGHT }, "M0 heap:", Color::light_grey() },
|
||||
{ { 6 * CHARACTER_WIDTH, 6 * LINE_HEIGHT }, "M0 stack:", Color::light_grey() },
|
||||
{ { 6 * CHARACTER_WIDTH, 7 * LINE_HEIGHT }, "M0 cpu %:", Color::light_grey() },
|
||||
{ { 6 * CHARACTER_WIDTH, 8 * LINE_HEIGHT }, "M4 heap:", Color::light_grey() },
|
||||
{ { 6 * CHARACTER_WIDTH, 9 * LINE_HEIGHT }, "M4 stack:", Color::light_grey() },
|
||||
{ { 6 * CHARACTER_WIDTH,10 * LINE_HEIGHT }, "M4 cpu %:", Color::light_grey() },
|
||||
{ { 6 * CHARACTER_WIDTH,11 * LINE_HEIGHT }, "uptime:", Color::light_grey() }
|
||||
{ { 6 * CHARACTER_WIDTH, 5 * LINE_HEIGHT }, "M0 heap:", Color::dark_cyan() },
|
||||
{ { 6 * CHARACTER_WIDTH, 6 * LINE_HEIGHT }, "M0 stack:", Color::dark_cyan() },
|
||||
{ { 6 * CHARACTER_WIDTH, 7 * LINE_HEIGHT }, "M0 cpu %:", Color::dark_cyan() },
|
||||
{ { 6 * CHARACTER_WIDTH, 8 * LINE_HEIGHT }, "M4 heap:", Color::dark_cyan() },
|
||||
{ { 6 * CHARACTER_WIDTH, 9 * LINE_HEIGHT }, "M4 stack:", Color::dark_cyan() },
|
||||
{ { 6 * CHARACTER_WIDTH,10 * LINE_HEIGHT }, "M4 cpu %:", Color::dark_cyan() },
|
||||
{ { 6 * CHARACTER_WIDTH,11 * LINE_HEIGHT }, "uptime:", Color::dark_cyan() }
|
||||
};
|
||||
|
||||
Text text_info_line_1 {{ 16 * CHARACTER_WIDTH, 5 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT }, ""};
|
||||
Text text_info_line_2 {{ 16 * CHARACTER_WIDTH, 6 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT }, ""};
|
||||
Text text_info_line_3 {{ 16 * CHARACTER_WIDTH, 7 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT }, ""};
|
||||
Text text_info_line_4 {{ 16 * CHARACTER_WIDTH, 8 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT }, ""};
|
||||
Text text_info_line_5 {{ 16 * CHARACTER_WIDTH, 9 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT }, ""};
|
||||
Text text_info_line_6 {{ 16 * CHARACTER_WIDTH,10 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT }, ""};
|
||||
Text text_info_line_7 {{ 16 * CHARACTER_WIDTH,11 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT }, ""};
|
||||
|
||||
// ProgressBar progress {
|
||||
// { 6 * CHARACTER_WIDTH, 5 * LINE_HEIGHT, 16 * CHARACTER_WIDTH, 24 }
|
||||
// };
|
||||
Text text_info_line_1 {{ 15 * CHARACTER_WIDTH, 5 * LINE_HEIGHT, 5 * CHARACTER_WIDTH, 1 * LINE_HEIGHT }, ""};
|
||||
Text text_info_line_2 {{ 15 * CHARACTER_WIDTH, 6 * LINE_HEIGHT, 5 * CHARACTER_WIDTH, 1 * LINE_HEIGHT }, ""};
|
||||
Text text_info_line_3 {{ 15 * CHARACTER_WIDTH, 7 * LINE_HEIGHT, 5 * CHARACTER_WIDTH, 1 * LINE_HEIGHT }, ""};
|
||||
Text text_info_line_4 {{ 15 * CHARACTER_WIDTH, 8 * LINE_HEIGHT, 5 * CHARACTER_WIDTH, 1 * LINE_HEIGHT }, ""};
|
||||
Text text_info_line_5 {{ 15 * CHARACTER_WIDTH, 9 * LINE_HEIGHT, 5 * CHARACTER_WIDTH, 1 * LINE_HEIGHT }, ""};
|
||||
Text text_info_line_6 {{ 15 * CHARACTER_WIDTH,10 * LINE_HEIGHT, 5 * CHARACTER_WIDTH, 1 * LINE_HEIGHT }, ""};
|
||||
Text text_info_line_7 {{ 15 * CHARACTER_WIDTH,11 * LINE_HEIGHT, 5 * CHARACTER_WIDTH, 1 * LINE_HEIGHT }, ""};
|
||||
};
|
||||
|
||||
} /* namespace ui */
|
||||
|
@ -145,14 +145,14 @@ Continuous (Fox-oring)
|
||||
rffc507x::RFFC507x first_if;
|
||||
|
||||
static void event_loop() {
|
||||
ui::Context context;
|
||||
ui::SystemView system_view {
|
||||
static ui::Context context;
|
||||
static ui::SystemView system_view {
|
||||
context,
|
||||
portapack::display.screen_rect()
|
||||
};
|
||||
|
||||
EventDispatcher event_dispatcher { &system_view, context };
|
||||
MessageHandlerRegistration message_handler_display_sleep {
|
||||
static MessageHandlerRegistration message_handler_display_sleep {
|
||||
Message::ID::DisplaySleep,
|
||||
[&event_dispatcher](const Message* const) {
|
||||
event_dispatcher.set_display_sleep(true);
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "bmp_splash.hpp"
|
||||
#include "bmp_modal_warning.hpp"
|
||||
#include "portapack_persistent_memory.hpp"
|
||||
#include "portapack_shared_memory.hpp"
|
||||
|
||||
#include "ui_about_simple.hpp"
|
||||
#include "ui_adsb_rx.hpp"
|
||||
@ -752,11 +753,14 @@ void SystemView::toggle_overlay() {
|
||||
if (overlay_active){
|
||||
this->remove_child(&this->overlay);
|
||||
this->set_dirty();
|
||||
shared_memory.request_m4_performance_counter = 0;
|
||||
}
|
||||
else{
|
||||
this->add_child(&this->overlay);
|
||||
this->set_dirty();
|
||||
shared_memory.request_m4_performance_counter = 1;
|
||||
}
|
||||
|
||||
overlay_active = !overlay_active;
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "event_m4.hpp"
|
||||
#include "debug.hpp"
|
||||
|
||||
#include "portapack_shared_memory.hpp"
|
||||
|
||||
@ -86,6 +87,10 @@ void EventDispatcher::dispatch(const eventmask_t events) {
|
||||
if( events & EVT_MASK_SPECTRUM ) {
|
||||
handle_spectrum();
|
||||
}
|
||||
|
||||
if (shared_memory.request_m4_performance_counter == 0x01) {
|
||||
update_performance_counters();
|
||||
}
|
||||
}
|
||||
|
||||
void EventDispatcher::handle_baseband_queue() {
|
||||
@ -95,6 +100,34 @@ void EventDispatcher::handle_baseband_queue() {
|
||||
}
|
||||
}
|
||||
|
||||
void EventDispatcher::update_performance_counters() {
|
||||
static bool last_paint_state = false;
|
||||
if ((((chTimeNow()>>10) & 0x01) == 0x01) == last_paint_state)
|
||||
return;
|
||||
|
||||
last_paint_state = !last_paint_state;
|
||||
|
||||
auto now = chTimeNow();
|
||||
auto idle_ticks = chThdGetTicks(chSysGetIdleThread());
|
||||
|
||||
static systime_t last_time;
|
||||
static systime_t last_last_time;
|
||||
|
||||
auto time_elapsed = now - last_time;
|
||||
auto idle_elapsed = idle_ticks - last_last_time;
|
||||
|
||||
last_time = now;
|
||||
last_last_time = idle_ticks;
|
||||
|
||||
auto cpu_usage = (time_elapsed - idle_elapsed) / 10;
|
||||
auto free_stack = (uint32_t)get_free_stack_space();
|
||||
auto free_heap = chCoreStatus();
|
||||
|
||||
shared_memory.m4_cpu_usage = cpu_usage;
|
||||
shared_memory.m4_stack_usage = free_stack;
|
||||
shared_memory.m4_heap_usage = free_heap;
|
||||
}
|
||||
|
||||
void EventDispatcher::on_message(const Message* const message) {
|
||||
switch(message->id) {
|
||||
case Message::ID::Shutdown:
|
||||
|
@ -61,6 +61,7 @@ private:
|
||||
void dispatch(const eventmask_t events);
|
||||
|
||||
void handle_baseband_queue();
|
||||
void update_performance_counters();
|
||||
|
||||
void on_message(const Message* const message);
|
||||
void on_message_shutdown(const ShutdownMessage&);
|
||||
|
@ -64,6 +64,11 @@ struct SharedMemory {
|
||||
JammerChannel jammer_channels[24];
|
||||
uint8_t data[512];
|
||||
} bb_data { { { { 0, 0 } }, 0, { 0 } } };
|
||||
|
||||
uint8_t request_m4_performance_counter{ 0 };
|
||||
uint8_t m4_cpu_usage{ 0 };
|
||||
uint16_t m4_stack_usage{ 0 };
|
||||
uint16_t m4_heap_usage{ 0 };
|
||||
};
|
||||
|
||||
extern SharedMemory& shared_memory;
|
||||
|
Loading…
Reference in New Issue
Block a user