From da66af3f8a91a027dbcfe2e158f53ea86fb2ec6a Mon Sep 17 00:00:00 2001 From: TuxSH <1922548+TuxSH@users.noreply.github.com> Date: Fri, 4 Jul 2025 00:17:11 +0200 Subject: [PATCH] sysmenu: fix luminance calculation, and allow going above preset 5 in many cases. Unlike SetLuminanceLevel, SetLuminance doesn't check if preset <= 5, and actually allows the lumiance levels provisioned for the "brightness boost mode" (brighter when adapter is plugged in), even when the feature is disabled (it is disabled for anything but the OG model, iirc). --- sysmodules/rosalina/source/luminance.c | 10 ++++++++-- sysmodules/rosalina/source/menus/sysconfig.c | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/sysmodules/rosalina/source/luminance.c b/sysmodules/rosalina/source/luminance.c index cc127870..0cd89edb 100644 --- a/sysmodules/rosalina/source/luminance.c +++ b/sysmodules/rosalina/source/luminance.c @@ -104,8 +104,13 @@ u32 getMinLuminancePreset(void) u32 getMaxLuminancePreset(void) { + // Unlike SetLuminanceLevel, SetLuminance doesn't + // check if preset <= 5, and actually allows the lumiance + // levels provisioned for the "brightness boost mode" (brighter + // when adapter is plugged in), even when the feature is disabled + // (it is disabled for anything but the OG model, iirc) readCalibration(); - return s_blPwmData.luminanceLevels[s_blPwmData.numLevels - 1]; + return s_blPwmData.luminanceLevels[6]; } u32 getCurrentLuminance(bool top) @@ -114,7 +119,8 @@ u32 getCurrentLuminance(bool top) readCalibration(); - const float *coeffs = s_blPwmData.coeffs[top ? (isN3DS ? 2 : 1) : 0]; + bool is3d = (REG32(0x10202000 + 0x000) & 1) != 0; + const float *coeffs = s_blPwmData.coeffs[top ? (is3d ? 2 : 1) : 0]; u32 brightness = REG32(regbase + 0x40); float ratio = getPwmRatio(s_blPwmData.brightnessMax, REG32(regbase + 0x44)); diff --git a/sysmodules/rosalina/source/menus/sysconfig.c b/sysmodules/rosalina/source/menus/sysconfig.c index 7569fc76..6f2dec52 100644 --- a/sysmodules/rosalina/source/menus/sysconfig.c +++ b/sysmodules/rosalina/source/menus/sysconfig.c @@ -560,7 +560,7 @@ void SysConfigMenu_ChangeScreenBrightness(void) posY = Draw_DrawString(10, posY, COLOR_WHITE, "Press A to start, B to exit.\n\n"); posY = Draw_DrawString(10, posY, COLOR_RED, "WARNING: \n"); - posY = Draw_DrawString(10, posY, COLOR_WHITE, " * value will be limited by the presets.\n"); + posY = Draw_DrawString(10, posY, COLOR_WHITE, " * value will be limited by calibration.\n"); posY = Draw_DrawString(10, posY, COLOR_WHITE, " * bottom framebuffer will be restored until\nyou exit."); Draw_FlushFramebuffer(); Draw_Unlock();