Skip to content

Commit e473256

Browse files
committed
Merge remote-tracking branch 'Masa/master'
2 parents 93d4908 + d221717 commit e473256

File tree

9 files changed

+202
-38
lines changed

9 files changed

+202
-38
lines changed

Makefile

+2-2
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.0.3
41+
APP_VERSION := 1.0.4U
4242
TARGET := $(notdir $(CURDIR))
4343
BUILD := build
4444
SOURCES := source
@@ -56,7 +56,7 @@ CFLAGS := -g -Wall -O2 -ffunction-sections \
5656

5757
CFLAGS += $(INCLUDE) -D__SWITCH__ -DAPP_VERSION="\"$(APP_VERSION)\""
5858

59-
CXXFLAGS := $(CFLAGS) -fno-exceptions -std=c++20 -Wno-dangling-else
59+
CXXFLAGS := $(CFLAGS) -fno-exceptions -std=c++23 -Wno-dangling-else
6060

6161
ASFLAGS := -g $(ARCH)
6262
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)

config/status-monitor/config.ini.template

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
[status-monitor]
2-
key_combo=L+R+DUP
2+
ultra=true
33
battery_avg_iir_filter=false
44
battery_time_left_refreshrate=60
55

66
[full]
77
refresh_rate=1
88
layer_width_align=left
9+
show_real_freqs=true
10+
show_deltas=true
11+
show_target_freqs=true
912

1013
[mini]
1114
refresh_rate=1
@@ -15,7 +18,7 @@ handheld_font_size=15
1518
docked_font_size=15
1619
real_freqs=true
1720
real_volts=true
18-
show=CPU+GPU+RAM+DRAW+TEMP+FAN+FPS
21+
show=CPU+GPU+RAM+TEMP+FAN+DRAW+FPS
1922
replace_MB_with_RAM_load=true
2023
background_color=#1117
2124
cat_color=#CDEF
@@ -24,16 +27,16 @@ text_color=#FFFF
2427
[micro]
2528
refresh_rate=1
2629
layer_height_align=top
27-
handheld_font_size=17
28-
docked_font_size=17
30+
handheld_font_size=15
31+
docked_font_size=15
2932
text_align=left
3033
real_freqs=true
31-
real_volts=false
32-
show=CPUB+GPU+RAM+BRDB+BATB+FPSE
34+
real_volts=true
35+
show=CPUB+GPU+RAM+BRDB+FPSE
3336
replace_GB_with_RAM_load=true
34-
background_color=#1117
35-
cat_color=#CCCC
36-
text_color=#FFFD
37+
background_color=#1113
38+
cat_color=#BDFF
39+
text_color=#FFFF
3740

3841
[fps-counter]
3942
layer_width_align=left
@@ -53,5 +56,5 @@ fps_counter_color=#4444
5356
border_color=#F77F
5457
dashed_line_color=#8888
5558
main_line_color=#FFFF
56-
rounded_line_color=#F0FF
57-
perfect_line_color=#0C0F
59+
rounded_line_color=#0C0F
60+
perfect_line_color=#F0FF

docs/config.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Colors are provided in RGBA4444 format, which means that each character represen
1111
1212
| Key | Explanation | Possible values | Default Value |
1313
|-----|-------------|-----------------|---------------|
14-
| `key_combo` | Buttons combination that allows exiting Full, Mini and Micro modes; max 4 buttons, otherwise next buttons will be ignored. Combine different buttons with `+` | `A`, `B`, `X`, `Y`, `L`, `R`, `ZL`, `ZR`, `PLUS`, `MINUS`, `DUP`, `DDOWN`, `DLEFT`, `DRIGHT`, `SL`, `SR`, `LSTICK`, `RSTICK`, `UP`, `DOWN`, `LEFT`, `RIGHT` | `L+DDOWN+RSTICK` |
14+
| `key_combo` | Buttons combination that allows exiting Full, Mini, Micro, FPS Graph and FPS Counter modes; max 4 buttons, otherwise next buttons will be ignored. Combine different buttons with `+` | `A`, `B`, `X`, `Y`, `L`, `R`, `ZL`, `ZR`, `PLUS`, `MINUS`, `DUP`, `DDOWN`, `DLEFT`, `DRIGHT`, `SL`, `SR`, `LSTICK`, `RSTICK`, `UP`, `DOWN`, `LEFT`, `RIGHT` | `L+DDOWN+RSTICK` |
1515
| `battery_avg_iir_filter` | Read voltage + current averages directly from fuel gauge, that uses infinite impulse response filter | `true`, `false` | `false` |
1616
| `battery_time_left_refreshrate` | How many seconds must pass to refresh Battery Remaining Time | from `1` to `60` | `60` |
1717

@@ -50,6 +50,7 @@ Colors are provided in RGBA4444 format, which means that each character represen
5050
| `layer_height_align` | On which side of the screen Y axis you want this mode | `top`, `bottom` | `top` |
5151
| `handheld_font_size` | How big should be rendered text in handheld mode | From `8` to `18` | `18` |
5252
| `docked_font_size` | How big should be rendered text in docked mode | From `8` to `18` | `18` |
53+
| `text_align` | How shown text should be aligned | `left`, `center`, `right`| `center` |
5354
| `real_freqs` | This works only if you have sys-clk 2.0.0_rc4+ installed. It shows real frequencies for CPU, GPU and RAM instead of target frequencies | `true`, `false` | `false` |
5455
| `show` | Which data should be rendered. Connect different stats with `+` in any order. | `CPU`, `GPU`, `RAM`, `BRD`, `FAN`, `FPS` | `CPU+GPU+RAM+BRD+FAN+FPS` |
5556
| `replace_GB_with_RAM_load` | This works only if you have sys-clk 2.0.0_rc4+ installed. Instead of RAM total usage it shows RAM load. | `true`, `false` | `true` |
@@ -82,5 +83,5 @@ Colors are provided in RGBA4444 format, which means that each character represen
8283
| `border_color` | Color of rectangle in RGBA4444 format | From `#0000` to `#FFFF` | `#F77F` |
8384
| `dashed_line_color` | Color of dashed line at the center of rectangle in RGBA4444 format | From `#0000` to `#FFFF` | `#8888` |
8485
| `main_line_color` | Color of line representing FPS value on graph in RGBA4444 format | From `#0000` to `#FFFF` | `#FFFF` |
85-
| `rounded_line_color` | Color of line representing FPS value on graph if it's divisble by 10 in RGBA4444 format | From `#0000` to `#FFFF` | `#0C0F` |
86-
| `perfect_line_color` | Color of line representing FPS value on graph if it's divisble by 30 in RGBA4444 format | From `#0000` to `#FFFF` | `#F0FF` |
86+
| `rounded_line_color` | Color of line representing FPS value on graph if it's divisble by 10 in RGBA4444 format | From `#0000` to `#FFFF` | `#F0FF` |
87+
| `perfect_line_color` | Color of line representing FPS value on graph if it's divisble by 30 in RGBA4444 format | From `#0000` to `#FFFF` | `#0C0F` |

docs/modes.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ If game is not launched, it will show always 254.0 value and graph will be empty
106106
If game is not rendering any new frame, graph is not updated.
107107

108108
If line is within rounding error of graph line, it's colored. Average FPS must be between -0.05 and +0.04 of graph line target FPS. So for 30 FPS it's between 29.95 - 30.04 FPS. For 43 FPS it's 42.95 - 43.04 FPS.
109-
If it's in 30 or 60 FPS rounding error range, it's green. Any other FPS graph target is purple.
109+
If it's in display refresh rate or half of it rounding error range, it's green. Any other FPS graph target is purple.
110+
111+
Colors can be changed in config file.
110112

111113
Mode available only with SaltyNX installed.
112114

include/SaltyNX.h

+86
Original file line numberDiff line numberDiff line change
@@ -141,5 +141,91 @@ Result SaltySD_GetSharedMemoryHandle(Handle *retrieve)
141141
}
142142
}
143143

144+
return ret;
145+
}
146+
147+
Result SaltySD_GetDisplayRefreshRate(uint8_t* refreshRate)
148+
{
149+
Result ret = 0;
150+
151+
// Send a command
152+
IpcCommand c;
153+
ipcInitialize(&c);
154+
ipcSendPid(&c);
155+
156+
struct input {
157+
u64 magic;
158+
u64 cmd_id;
159+
u64 zero;
160+
u64 reserved;
161+
} *raw;
162+
163+
raw = (input*)ipcPrepareHeader(&c, sizeof(*raw));
164+
165+
raw->magic = SFCI_MAGIC;
166+
raw->cmd_id = 10;
167+
raw->zero = 0;
168+
169+
ret = ipcDispatch(saltysd_orig);
170+
171+
if (R_SUCCEEDED(ret)) {
172+
IpcParsedCommand r;
173+
ipcParse(&r);
174+
175+
struct output {
176+
u64 magic;
177+
u64 result;
178+
u64 refreshRate;
179+
u64 reserved;
180+
} *resp = (output*)r.Raw;
181+
182+
ret = resp->result;
183+
184+
if (!ret)
185+
{
186+
*refreshRate = (uint8_t)(resp->refreshRate);
187+
}
188+
}
189+
190+
return ret;
191+
}
192+
193+
Result SaltySD_SetDisplayRefreshRate(uint8_t refreshRate)
194+
{
195+
Result ret = 0;
196+
197+
// Send a command
198+
IpcCommand c;
199+
ipcInitialize(&c);
200+
ipcSendPid(&c);
201+
202+
struct input {
203+
u64 magic;
204+
u64 cmd_id;
205+
u64 refreshRate;
206+
u64 reserved;
207+
} *raw;
208+
209+
raw = (input*)ipcPrepareHeader(&c, sizeof(*raw));
210+
211+
raw->magic = SFCI_MAGIC;
212+
raw->cmd_id = 11;
213+
raw->refreshRate = refreshRate;
214+
215+
ret = ipcDispatch(saltysd_orig);
216+
217+
if (R_SUCCEEDED(ret)) {
218+
IpcParsedCommand r;
219+
ipcParse(&r);
220+
221+
struct output {
222+
u64 magic;
223+
u64 result;
224+
u64 reserved[2];
225+
} *resp = (output*)r.Raw;
226+
227+
ret = resp->result;
228+
}
229+
144230
return ret;
145231
}

source/Utils.hpp

+28-9
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,21 @@ uint32_t realGPU_mV = 0;
158158
uint32_t realRAM_mV = 0;
159159
uint32_t realSOC_mV = 0;
160160
uint32_t ramLoad[SysClkRamLoad_EnumMax];
161+
uint8_t refreshRate = 0;
162+
163+
void LoadSharedMemoryAndRefreshRate() {
164+
if (SaltySD_Connect())
165+
return;
166+
167+
SaltySD_GetSharedMemoryHandle(&remoteSharedMemory);
168+
SaltySD_GetDisplayRefreshRate(&refreshRate);
169+
SaltySD_Term();
170+
171+
shmemLoadRemote(&_sharedmemory, remoteSharedMemory, 0x1000, Perm_Rw);
172+
if (!shmemMap(&_sharedmemory))
173+
SharedMemoryUsed = true;
174+
else FPS = 1234;
175+
}
161176

162177
void LoadSharedMemory() {
163178
if (SaltySD_Connect())
@@ -463,7 +478,7 @@ void Misc(void*) {
463478
}
464479
// Interval
465480
mutexUnlock(&mutex_Misc);
466-
svcSleepThread(100'000'000);
481+
svcSleepThread(TeslaFPS < 10 ? (1'000'000'000 / TeslaFPS) : 100'000'000);
467482
}
468483
}
469484

@@ -647,7 +662,9 @@ void formatButtonCombination(std::string& line) {
647662
{"PLUS", "\uE0EF"},
648663
{"MINUS", "\uE0F0"},
649664
{"LSTICK", "\uE104"},
650-
{"RSTICK", "\uE105"}
665+
{"RSTICK", "\uE105"},
666+
{"RS", "\uE105"},
667+
{"LS", "\uE104"}
651668
};
652669
// Remove all spaces from the line
653670
line.erase(std::remove(line.begin(), line.end(), ' '), line.end());
@@ -708,10 +725,12 @@ uint64_t MapButtons(const std::string& buttonCombo) {
708725
{"SR", HidNpadButton_AnySR},
709726
{"LSTICK", HidNpadButton_StickL},
710727
{"RSTICK", HidNpadButton_StickR},
711-
{"UP", HidNpadButton_Up},
712-
{"DOWN", HidNpadButton_Down},
713-
{"LEFT", HidNpadButton_Left},
714-
{"RIGHT", HidNpadButton_Right}
728+
{"LS", HidNpadButton_StickL},
729+
{"RS", HidNpadButton_StickR},
730+
{"UP", HidNpadButton_AnyUp},
731+
{"DOWN", HidNpadButton_AnyDown},
732+
{"LEFT", HidNpadButton_AnyLeft},
733+
{"RIGHT", HidNpadButton_AnyRight}
715734
};
716735

717736
uint64_t comboBitmask = 0;
@@ -947,7 +966,7 @@ void GetConfigSettings(MiniSettings* settings) {
947966
convertStrToRGBA4444("#1117", &(settings -> backgroundColor));
948967
convertStrToRGBA4444("#FFFF", &(settings -> catColor));
949968
convertStrToRGBA4444("#FFFF", &(settings -> textColor));
950-
settings -> show = "CPU+GPU+RAM+DRAW+TEMP+FAN+FPS";
969+
settings -> show = "CPU+GPU+RAM+TEMP+DRAW+FAN+FPS";
951970
settings -> showRAMLoad = true;
952971
settings -> refreshRate = 1;
953972

@@ -991,7 +1010,7 @@ void GetConfigSettings(MiniSettings* settings) {
9911010
settings -> realVolts = !(key.compare("TRUE"));
9921011
}
9931012

994-
long maxFontSize = 32;
1013+
long maxFontSize = 22;
9951014
long minFontSize = 8;
9961015
if (parsedData["mini"].find("handheld_font_size") != parsedData["mini"].end()) {
9971016
key = parsedData["mini"]["handheld_font_size"];
@@ -1127,7 +1146,7 @@ void GetConfigSettings(MicroSettings* settings) {
11271146
settings -> alignTo = 2;
11281147
}
11291148
}
1130-
long maxFontSize = 28;
1149+
long maxFontSize = 18;
11311150
long minFontSize = 8;
11321151
if (parsedData["micro"].find("handheld_font_size") != parsedData["micro"].end()) {
11331152
key = parsedData["micro"]["handheld_font_size"];

source/main.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#define TESLA_INIT_IMPL
22
#include <tesla.hpp>
33
#include "Utils.hpp"
4+
#include <cstdlib>
45

56
static tsl::elm::OverlayFrame* rootFrame = nullptr;
67
static bool skipMain = false;
@@ -229,7 +230,7 @@ class MonitorOverlay : public tsl::Overlay {
229230
SaltySD = CheckPort();
230231

231232
if (SaltySD) {
232-
LoadSharedMemory();
233+
LoadSharedMemoryAndRefreshRate();
233234
}
234235
if (sysclkIpcRunning() && R_SUCCEEDED(sysclkIpcInitialize())) {
235236
uint32_t sysClkApiVer = 0;

0 commit comments

Comments
 (0)