Skip to content

Commit ae3d85f

Browse files
committed
Merge remote-tracking branch 'Meha/master'
2 parents fd889a7 + 0d0d106 commit ae3d85f

File tree

8 files changed

+397
-280
lines changed

8 files changed

+397
-280
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ include $(DEVKITPRO)/libnx/switch_rules
3838
# NACP building is skipped as well.
3939
#---------------------------------------------------------------------------------
4040
APP_TITLE := Status Monitor
41-
APP_VERSION := 1.1.3U
41+
APP_VERSION := 1.1.3U+
4242
TARGET := $(notdir $(CURDIR))
4343
BUILD := build
4444
SOURCES := source

config/status-monitor/config.ini.template

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ docked_font_size=15
3232
text_align=left
3333
real_freqs=true
3434
real_volts=true
35-
show=CPUB+GPU+RAM+BRDB+FPSE
36-
;all modules: (CPU CPUB) GPU RAM (BRD BRDM BRDB) FAN PWR (BAT BATE) (FPS FPSE)
35+
show_full_cpu=true
36+
show=CPU+GPU+RAM+BRDB+FPSE
37+
;all modules: CPU GPU RAM (SOC BRD BRDB) FAN (PWR BAT BATB BATE) (FPS FPSE)
3738
replace_GB_with_RAM_load=true
3839
background_color=#1113
3940
cat_color=#BDFF

include/sysclk/clock_manager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ typedef struct
2626
uint32_t ramLoad[SysClkRamLoad_EnumMax];
2727
uint32_t realVolts[4];
2828
uint32_t perfConfId;
29+
uint32_t reserved[8];
2930
} SysClkContext;
3031

3132
#ifdef __cplusplus

source/Utils.hpp

Lines changed: 117 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,22 @@ resolutionCalls* viewportCalls_shared = 0;
164164
uint32_t realCPU_Hz = 0;
165165
uint32_t realGPU_Hz = 0;
166166
uint32_t realRAM_Hz = 0;
167+
uint32_t ramLoad[SysClkRamLoad_EnumMax];
167168
uint32_t realCPU_mV = 0;
168169
uint32_t realGPU_mV = 0;
169170
uint32_t realRAM_mV = 0;
170171
uint32_t realSOC_mV = 0;
171-
uint32_t ramLoad[SysClkRamLoad_EnumMax];
172172
uint8_t refreshRate = 0;
173173

174+
//Tweaks to nvInitialize so it will take less RAM
175+
#define NVDRV_TMEM_SIZE (8 * 0x1000)
176+
char nvdrv_tmem_data[NVDRV_TMEM_SIZE] alignas(0x1000);
177+
178+
Result __nx_nv_create_tmem(TransferMemory *t, u32 *out_size, Permission perm) {
179+
*out_size = NVDRV_TMEM_SIZE;
180+
return tmemCreateFromMemory(t, nvdrv_tmem_data, NVDRV_TMEM_SIZE, perm);
181+
}
182+
174183
int compare (const void* elem1, const void* elem2) {
175184
if ((((resolutionCalls*)(elem1)) -> calls) > (((resolutionCalls*)(elem2)) -> calls)) return -1;
176185
else return 1;
@@ -432,12 +441,12 @@ void Misc(void*) {
432441
realCPU_Hz = sysclkCTX.realFreqs[SysClkModule_CPU];
433442
realGPU_Hz = sysclkCTX.realFreqs[SysClkModule_GPU];
434443
realRAM_Hz = sysclkCTX.realFreqs[SysClkModule_MEM];
444+
ramLoad[SysClkRamLoad_All] = sysclkCTX.ramLoad[SysClkRamLoad_All];
445+
ramLoad[SysClkRamLoad_Cpu] = sysclkCTX.ramLoad[SysClkRamLoad_Cpu];
435446
realCPU_mV = sysclkCTX.realVolts[0];
436447
realGPU_mV = sysclkCTX.realVolts[1];
437448
realRAM_mV = sysclkCTX.realVolts[2];
438449
realSOC_mV = sysclkCTX.realVolts[3];
439-
ramLoad[SysClkRamLoad_All] = sysclkCTX.ramLoad[SysClkRamLoad_All];
440-
ramLoad[SysClkRamLoad_Cpu] = sysclkCTX.ramLoad[SysClkRamLoad_Cpu];
441450
}
442451
}
443452

@@ -503,6 +512,7 @@ void Misc(void*) {
503512
FPSmin = 254;
504513
FPSmax = 0;
505514
}
515+
506516
// Interval
507517
mutexUnlock(&mutex_Misc);
508518
svcSleepThread(TeslaFPS < 10 ? (1'000'000'000 / TeslaFPS) : 100'000'000);
@@ -530,6 +540,60 @@ void Misc2(void*) {
530540
}
531541
}
532542

543+
void Misc3(void*) {
544+
while (!threadexit) {
545+
mutexLock(&mutex_Misc);
546+
547+
if (R_SUCCEEDED(sysclkCheck)) {
548+
SysClkContext sysclkCTX;
549+
if (R_SUCCEEDED(sysclkIpcGetCurrentContext(&sysclkCTX))) {
550+
ramLoad[SysClkRamLoad_All] = sysclkCTX.ramLoad[SysClkRamLoad_All];
551+
ramLoad[SysClkRamLoad_Cpu] = sysclkCTX.ramLoad[SysClkRamLoad_Cpu];
552+
}
553+
}
554+
555+
//Temperatures
556+
if (R_SUCCEEDED(tsCheck)) {
557+
if (hosversionAtLeast(10,0,0)) {
558+
TsSession ts_session;
559+
Result rc = tsOpenSession(&ts_session, TsDeviceCode_LocationExternal);
560+
if (R_SUCCEEDED(rc)) {
561+
tsSessionGetTemperature(&ts_session, &SOC_temperatureF);
562+
tsSessionClose(&ts_session);
563+
}
564+
rc = tsOpenSession(&ts_session, TsDeviceCode_LocationInternal);
565+
if (R_SUCCEEDED(rc)) {
566+
tsSessionGetTemperature(&ts_session, &PCB_temperatureF);
567+
tsSessionClose(&ts_session);
568+
}
569+
}
570+
else {
571+
tsGetTemperatureMilliC(TsLocation_External, &SOC_temperatureC);
572+
tsGetTemperatureMilliC(TsLocation_Internal, &PCB_temperatureC);
573+
}
574+
}
575+
if (R_SUCCEEDED(tcCheck)) tcGetSkinTemperatureMilliC(&skin_temperaturemiliC);
576+
577+
//Fan
578+
if (R_SUCCEEDED(pwmCheck)) {
579+
double temp = 0;
580+
if (R_SUCCEEDED(pwmChannelSessionGetDutyCycle(&g_ICon, &temp))) {
581+
temp *= 10;
582+
temp = trunc(temp);
583+
temp /= 10;
584+
Rotation_Duty = 100.0 - temp;
585+
}
586+
}
587+
588+
//GPU Load
589+
if (R_SUCCEEDED(nvCheck)) nvIoctl(fd, NVGPU_GPU_IOCTL_PMU_GET_GPU_LOAD, &GPU_Load_u);
590+
591+
// Interval
592+
mutexUnlock(&mutex_Misc);
593+
svcSleepThread(1'000'000'000);
594+
}
595+
}
596+
533597
//Check each core for idled ticks in intervals, they cannot read info about other core than they are assigned
534598
//In case of getting more than systemtickfrequency in idle, make it equal to systemtickfrequency to get 0% as output and nothing less
535599
//This is because making each loop also takes time, which is not considered because this will take also additional time
@@ -656,6 +720,36 @@ void EndFPSCounterThread() {
656720
threadexit2 = false;
657721
}
658722

723+
void StartInfoThread() {
724+
threadCreate(&t1, CheckCore0, NULL, NULL, 0x1000, 0x10, 0);
725+
threadCreate(&t2, CheckCore1, NULL, NULL, 0x1000, 0x10, 1);
726+
threadCreate(&t3, CheckCore2, NULL, NULL, 0x1000, 0x10, 2);
727+
threadCreate(&t4, CheckCore3, NULL, NULL, 0x1000, 0x10, 3);
728+
threadCreate(&t7, Misc3, NULL, NULL, 0x1000, 0x3F, -2);
729+
threadStart(&t1);
730+
threadStart(&t2);
731+
threadStart(&t3);
732+
threadStart(&t4);
733+
threadStart(&t7);
734+
}
735+
736+
void EndInfoThread() {
737+
threadexit = true;
738+
threadexit2 = true;
739+
threadWaitForExit(&t1);
740+
threadWaitForExit(&t2);
741+
threadWaitForExit(&t3);
742+
threadWaitForExit(&t4);
743+
threadWaitForExit(&t7);
744+
threadClose(&t1);
745+
threadClose(&t2);
746+
threadClose(&t3);
747+
threadClose(&t4);
748+
threadClose(&t7);
749+
threadexit = false;
750+
threadexit2 = false;
751+
}
752+
659753

660754
// String formatting functions
661755
void removeSpaces(std::string& str) {
@@ -953,6 +1047,7 @@ struct MicroSettings {
9531047
uint8_t refreshRate;
9541048
bool realFrequencies;
9551049
bool realVolts;
1050+
bool showFullCPU;
9561051
size_t handheldFontSize;
9571052
size_t dockedFontSize;
9581053
uint8_t alignTo;
@@ -974,6 +1069,7 @@ struct FpsCounterSettings {
9741069
};
9751070

9761071
struct FpsGraphSettings {
1072+
bool showInfo;
9771073
uint8_t refreshRate;
9781074
uint16_t backgroundColor;
9791075
uint16_t fpsColor;
@@ -1048,7 +1144,7 @@ void GetConfigSettings(MiniSettings* settings) {
10481144
settings -> realVolts = !(key.compare("TRUE"));
10491145
}
10501146

1051-
long maxFontSize = 22;
1147+
long maxFontSize = 32;
10521148
long minFontSize = 8;
10531149
if (parsedData["mini"].find("handheld_font_size") != parsedData["mini"].end()) {
10541150
key = parsedData["mini"]["handheld_font_size"];
@@ -1120,14 +1216,15 @@ void GetConfigSettings(MiniSettings* settings) {
11201216

11211217
void GetConfigSettings(MicroSettings* settings) {
11221218
settings -> realFrequencies = true;
1123-
settings -> realVolts = true;
1124-
settings -> handheldFontSize = 15;
1125-
settings -> dockedFontSize = 15;
1219+
settings -> realVolts = true;
1220+
settings -> showFullCPU = true;
1221+
settings -> handheldFontSize = 12;
1222+
settings -> dockedFontSize = 12;
11261223
settings -> alignTo = 0;
11271224
convertStrToRGBA4444("#1113", &(settings -> backgroundColor));
11281225
convertStrToRGBA4444("#BDFF", &(settings -> catColor));
11291226
convertStrToRGBA4444("#FFFF", &(settings -> textColor));
1130-
settings -> show = "CPUB+GPU+RAM+BRDB+FPSE";
1227+
settings -> show = "CPU+GPU+RAM+BRDB+FPS+BATE";
11311228
settings -> showRAMLoad = true;
11321229
settings -> setPosBottom = false;
11331230
settings -> refreshRate = 1;
@@ -1170,6 +1267,11 @@ void GetConfigSettings(MicroSettings* settings) {
11701267
key = parsedData["micro"]["real_volts"];
11711268
convertToUpper(key);
11721269
settings -> realVolts = !(key.compare("TRUE"));
1270+
}
1271+
if (parsedData["micro"].find("show_full_cpu") != parsedData["micro"].end()) {
1272+
key = parsedData["micro"]["show_full_cpu"];
1273+
convertToUpper(key);
1274+
settings -> showFullCPU = key.compare("FALSE");
11731275
}
11741276
if (parsedData["micro"].find("text_align") != parsedData["micro"].end()) {
11751277
key = parsedData["micro"]["text_align"];
@@ -1184,7 +1286,7 @@ void GetConfigSettings(MicroSettings* settings) {
11841286
settings -> alignTo = 2;
11851287
}
11861288
}
1187-
long maxFontSize = 18;
1289+
long maxFontSize = 32;
11881290
long minFontSize = 8;
11891291
if (parsedData["micro"].find("handheld_font_size") != parsedData["micro"].end()) {
11901292
key = parsedData["micro"]["handheld_font_size"];
@@ -1318,6 +1420,7 @@ void GetConfigSettings(FpsCounterSettings* settings) {
13181420
}
13191421

13201422
void GetConfigSettings(FpsGraphSettings* settings) {
1423+
settings -> showInfo = false;
13211424
settings -> setPos = 0;
13221425
convertStrToRGBA4444("#1117", &(settings -> backgroundColor));
13231426
convertStrToRGBA4444("#4444", &(settings -> fpsColor));
@@ -1420,6 +1523,11 @@ void GetConfigSettings(FpsGraphSettings* settings) {
14201523
if (convertStrToRGBA4444(key, &temp))
14211524
settings -> perfectLineColor = temp;
14221525
}
1526+
if (parsedData["fps-graph"].find("show_info") != parsedData["fps-graph"].end()) {
1527+
key = parsedData["fps-graph"]["show_info"];
1528+
convertToUpper(key);
1529+
settings -> showInfo = !(key.compare("TRUE"));
1530+
}
14231531
}
14241532

14251533
void GetConfigSettings(FullSettings* settings) {

source/modes/Battery.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ class BatteryOverlay : public tsl::Gui {
5454
"Battery Current Flow (%ss AVG): %+.0f mA\n"
5555
"Battery Power Flow%s: %+.3f W\n"
5656
"Battery Remaining Time: %s\n"
57+
"Input Current Limt: %d mA\n"
58+
"VBUS Current Limit: %d mA\n"
59+
"Charge Voltage Limit: %d mV\n"
60+
"Charge Current Limit: %d mA\n"
5761
"Charger Type: %u\n"
5862
"Charger Max Voltage: %u mV\n"
5963
"Charger Max Current: %u mA",
@@ -66,6 +70,10 @@ class BatteryOverlay : public tsl::Gui {
6670
batteryFiltered ? "11.25" : "5", batCurrentAvg,
6771
batteryFiltered ? "" : " (5s AVG)", PowerConsumption,
6872
tempBatTimeEstimate,
73+
_batteryChargeInfoFields.InputCurrentLimit,
74+
_batteryChargeInfoFields.VBUSCurrentLimit,
75+
_batteryChargeInfoFields.ChargeVoltageLimit,
76+
_batteryChargeInfoFields.ChargeCurrentLimit,
6977
ChargerConnected,
7078
ChargerVoltageLimit,
7179
ChargerCurrentLimit

source/modes/FPS_Graph.hpp

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ class com_FPSGraph : public tsl::Gui {
66
FpsGraphSettings settings;
77
ApmPerformanceMode performanceMode = ApmPerformanceMode_Invalid;
88
bool isDocked = false;
9+
uint64_t systemtickfrequency_impl = systemtickfrequency;
10+
uint32_t cnt = 0;
11+
char CPU_Load_c[12] = "";
12+
char GPU_Load_c[12] = "";
13+
char RAM_Load_c[12] = "";
14+
char TEMP_c[32] = "";
915
public:
1016
bool isStarted = false;
1117
com_FPSGraph() {
@@ -37,7 +43,10 @@ class com_FPSGraph : public tsl::Gui {
3743
tsl::hlp::requestForeground(false);
3844
FullMode = false;
3945
TeslaFPS = settings.refreshRate;
46+
systemtickfrequency_impl /= settings.refreshRate;
4047
deactivateOriginalFooter = true;
48+
mutexInit(&mutex_Misc);
49+
StartInfoThread();
4150
}
4251

4352
~com_FPSGraph() {
@@ -48,6 +57,7 @@ class com_FPSGraph : public tsl::Gui {
4857
tsl::hlp::requestForeground(true);
4958
alphabackground = 0xD;
5059
deactivateOriginalFooter = false;
60+
EndInfoThread();
5161
}
5262

5363
struct stats {
@@ -166,6 +176,17 @@ class com_FPSGraph : public tsl::Gui {
166176
last_element--;
167177
}
168178

179+
if (settings.showInfo) {
180+
s16 info_x = base_x+rectangle_width+rectangle_x + 6;
181+
s16 info_y = base_y + 3;
182+
renderer->drawRect(info_x, 0, rectangle_width /2 - 4, rectangle_height + 12, a(settings.backgroundColor));
183+
renderer->drawString("CPU\nGPU\nRAM\nSOC\nPCB\nSKN", false, info_x, info_y+11, 11, renderer->a(settings.borderColor));
184+
185+
renderer->drawString(CPU_Load_c, false, info_x + 40, info_y+11, 11, renderer->a(settings.minFPSTextColor));
186+
renderer->drawString(GPU_Load_c, false, info_x + 40, info_y+22, 11, renderer->a(settings.minFPSTextColor));
187+
renderer->drawString(RAM_Load_c, false, info_x + 40, info_y+33, 11, renderer->a(settings.minFPSTextColor));
188+
renderer->drawString(TEMP_c, false, info_x + 40, info_y+44, 11, renderer->a(settings.minFPSTextColor));
189+
}
169190
});
170191

171192
rootFrame->setContent(Status);
@@ -174,6 +195,10 @@ class com_FPSGraph : public tsl::Gui {
174195
}
175196

176197
virtual void update() override {
198+
cnt++;
199+
if (cnt >= TeslaFPS)
200+
cnt = 0;
201+
177202
///FPS
178203
static float FPSavg_old = 0;
179204
stats temp = {0, false};
@@ -196,7 +221,8 @@ class com_FPSGraph : public tsl::Gui {
196221
}
197222
}
198223
if (FPSavg_old == FPSavg)
199-
return;
224+
//return;
225+
goto read_value;
200226
FPSavg_old = FPSavg;
201227
snprintf(FPSavg_c, sizeof FPSavg_c, "%2.1f", FPSavg);
202228
if (FPSavg < 254) {
@@ -230,7 +256,44 @@ class com_FPSGraph : public tsl::Gui {
230256
isStarted = false;
231257
}
232258
}
259+
260+
read_value:
261+
262+
if (cnt)
263+
return;
264+
265+
mutexLock(&mutex_Misc);
266+
if (hosversionAtLeast(10,0,0)) {
267+
snprintf(TEMP_c, sizeof TEMP_c,
268+
"%2.1f\u00B0C\n%2.1f\u00B0C\n%2d.%d\u00B0C",
269+
SOC_temperatureF, PCB_temperatureF, skin_temperaturemiliC / 1000, (skin_temperaturemiliC / 100) % 10);
270+
}
271+
else {
272+
snprintf(TEMP_c, sizeof TEMP_c,
273+
"%2d.%d\u00B0C\n%2d.%d\u00B0C\n%2d.%d\u00B0C",
274+
SOC_temperatureC / 1000, (SOC_temperatureC / 100) % 10,
275+
PCB_temperatureC / 1000, (PCB_temperatureC % 100) % 10,
276+
skin_temperaturemiliC / 1000, (skin_temperaturemiliC / 100) % 10);
277+
}
278+
279+
if (idletick0 > systemtickfrequency_impl) idletick0 = systemtickfrequency_impl;
280+
if (idletick1 > systemtickfrequency_impl) idletick1 = systemtickfrequency_impl;
281+
if (idletick2 > systemtickfrequency_impl) idletick2 = systemtickfrequency_impl;
282+
if (idletick3 > systemtickfrequency_impl) idletick3 = systemtickfrequency_impl;
283+
double cpu_usage0 = (1.d - ((double)idletick0 / systemtickfrequency_impl)) * 100;
284+
double cpu_usage1 = (1.d - ((double)idletick1 / systemtickfrequency_impl)) * 100;
285+
double cpu_usage2 = (1.d - ((double)idletick2 / systemtickfrequency_impl)) * 100;
286+
double cpu_usage3 = (1.d - ((double)idletick3 / systemtickfrequency_impl)) * 100;
287+
double cpu_usageM = 0;
288+
if (cpu_usage0 > cpu_usageM) cpu_usageM = cpu_usage0;
289+
if (cpu_usage1 > cpu_usageM) cpu_usageM = cpu_usage1;
290+
if (cpu_usage2 > cpu_usageM) cpu_usageM = cpu_usage2;
291+
if (cpu_usage3 > cpu_usageM) cpu_usageM = cpu_usage3;
292+
snprintf(CPU_Load_c, sizeof CPU_Load_c, "%.1f%%", cpu_usageM);
293+
snprintf(GPU_Load_c, sizeof GPU_Load_c, "%d.%d%%", GPU_Load_u / 10, GPU_Load_u % 10);
294+
snprintf(RAM_Load_c, sizeof RAM_Load_c, "%hu.%hhu%%", ramLoad[SysClkRamLoad_All] / 10, ramLoad[SysClkRamLoad_All] % 10);
233295

296+
mutexUnlock(&mutex_Misc);
234297
}
235298
virtual bool handleInput(uint64_t keysDown, uint64_t keysHeld, touchPosition touchInput, JoystickPosition leftJoyStick, JoystickPosition rightJoyStick) override {
236299
if (isKeyComboPressed(keysHeld, keysDown, mappedButtons)) {

0 commit comments

Comments
 (0)