mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-05 05:04:27 -04:00
implemented M4 stats
This commit is contained in:
parent
850a79c9bb
commit
2ef9ebd7bd
7 changed files with 100 additions and 32 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue