Skip to content

Commit

Permalink
rosalina: add battery info in debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
TuxSH committed Aug 2, 2024
1 parent 2ddf5d3 commit 2c49a04
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions sysmodules/rosalina/include/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ typedef struct Menu {
extern u32 menuCombo;
extern bool isHidInitialized;
extern u32 mcuFwVersion;
extern u8 mcuInfoTable[9];
extern bool mcuInfoTableRead;

// From main.c
extern bool isN3DS;
Expand Down
5 changes: 5 additions & 0 deletions sysmodules/rosalina/source/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
u32 menuCombo = 0;
bool isHidInitialized = false;
u32 mcuFwVersion = 0;
u8 mcuInfoTable[9] = {0};
bool mcuInfoTableRead = false;

// libctru redefinition:

Expand Down Expand Up @@ -226,6 +228,9 @@ static Result menuUpdateMcuInfo(void)
mcuFwVersion = SYSTEM_VERSION(major - 0x10, minor, 0);
}

if (!mcuInfoTableRead)
mcuInfoTableRead = R_SUCCEEDED(MCUHWC_ReadRegister(0x7F, mcuInfoTable, sizeof(mcuInfoTable)));

svcCloseHandle(*mcuHwcHandlePtr);
return res;
}
Expand Down
12 changes: 8 additions & 4 deletions sysmodules/rosalina/source/menus.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,18 @@ void RosalinaMenu_ShowDebugInfo(void)
10, posY, COLOR_WHITE, "Kernel version: %lu.%lu-%lu\n",
GET_VERSION_MAJOR(kernelVer), GET_VERSION_MINOR(kernelVer), GET_VERSION_REVISION(kernelVer)
);
if (mcuFwVersion != 0)
if (mcuFwVersion != 0 && mcuInfoTableRead)
{
posY = Draw_DrawFormattedString(
10, posY, COLOR_WHITE, "MCU FW version: %lu.%lu\n",
GET_VERSION_MAJOR(mcuFwVersion), GET_VERSION_MINOR(mcuFwVersion)
10, posY, COLOR_WHITE, "MCU FW version: %lu.%lu (PMIC vendor: %hhu)\n",
GET_VERSION_MAJOR(mcuFwVersion), GET_VERSION_MINOR(mcuFwVersion),
mcuInfoTable[1]
);
posY = Draw_DrawFormattedString(
10, posY, COLOR_WHITE, "Battery: vendor: %hhu gauge IC ver.: %hhu.%hhu RCOMP: %hhu\n",
mcuInfoTable[2], mcuInfoTable[3], mcuInfoTable[4], mcuInfoTable[4]
);
}

if (R_SUCCEEDED(FSUSER_GetSdmcSpeedInfo(&speedInfo)))
{
u32 clkDiv = 1 << (1 + (speedInfo.sdClkCtrl & 0xFF));
Expand Down

0 comments on commit 2c49a04

Please sign in to comment.