mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-09 15:12:35 -04:00
Formatted code (#1007)
* Updated style * Updated files * fixed new line * Updated spacing * File fix WIP * Updated to clang 13 * updated comment style * Removed old comment code
This commit is contained in:
parent
7aca7ce74d
commit
033c4e9a5b
599 changed files with 70746 additions and 66896 deletions
|
@ -23,35 +23,35 @@
|
|||
#include "ch.h"
|
||||
|
||||
uint8_t get_cpu_utilisation_in_percent() {
|
||||
static systime_t last_time = 0;
|
||||
static systime_t last_idle_ticks = 0;
|
||||
static systime_t last_time = 0;
|
||||
static systime_t last_idle_ticks = 0;
|
||||
|
||||
auto now = chTimeNow();
|
||||
auto idle_ticks = chThdGetTicks(chSysGetIdleThread());
|
||||
auto now = chTimeNow();
|
||||
auto idle_ticks = chThdGetTicks(chSysGetIdleThread());
|
||||
|
||||
if (last_time == 0) {
|
||||
last_time = now;
|
||||
last_idle_ticks = idle_ticks;
|
||||
if (last_time == 0) {
|
||||
last_time = now;
|
||||
last_idle_ticks = idle_ticks;
|
||||
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t time_elapsed = now - last_time;
|
||||
int32_t idle_elapsed = idle_ticks - last_idle_ticks;
|
||||
int32_t time_elapsed = now - last_time;
|
||||
int32_t idle_elapsed = idle_ticks - last_idle_ticks;
|
||||
|
||||
int32_t working_ticks = time_elapsed - idle_elapsed;
|
||||
int32_t working_ticks = time_elapsed - idle_elapsed;
|
||||
|
||||
if (working_ticks < 0)
|
||||
working_ticks = 0;
|
||||
if (working_ticks < 0)
|
||||
working_ticks = 0;
|
||||
|
||||
auto utilisation = working_ticks * 100 / time_elapsed;
|
||||
auto utilisation = working_ticks * 100 / time_elapsed;
|
||||
|
||||
last_time = now;
|
||||
last_idle_ticks = idle_ticks;
|
||||
last_time = now;
|
||||
last_idle_ticks = idle_ticks;
|
||||
|
||||
if (utilisation > 100) {
|
||||
return 100;
|
||||
}
|
||||
if (utilisation > 100) {
|
||||
return 100;
|
||||
}
|
||||
|
||||
return (uint8_t) utilisation;
|
||||
return (uint8_t)utilisation;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue