From b5fca3bc7e35220cbb6aa0c349e5f5e7c6c992cb Mon Sep 17 00:00:00 2001 From: Wolfvak Date: Tue, 25 Apr 2023 10:13:07 -0300 Subject: [PATCH] Use the correct MCU LED period for calculations (#807) Fixes #772 --- arm11/source/hw/mcu.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/arm11/source/hw/mcu.c b/arm11/source/hw/mcu.c index 33d1446..69ab777 100755 --- a/arm11/source/hw/mcu.c +++ b/arm11/source/hw/mcu.c @@ -22,6 +22,8 @@ #include +#include "common.h" + #include "arm/timer.h" #include "hw/gpio.h" @@ -116,16 +118,13 @@ u32 mcuGetSpecialHID(void) void mcuSetStatusLED(u32 period_ms, u32 color) { - u32 r, g, b; + u32 r, g, b, delay; mcuStatusLED ledState; - // handle proper non-zero periods - // so small the hardware can't handle it - if (period_ms != 0 && period_ms < 63) - period_ms = 63; + delay = clamp((period_ms * 0x200) / 1000, 1, 0xFF); - ledState.delay = (period_ms * 0x10) / 1000; - ledState.smoothing = 0x40; + ledState.delay = delay; + ledState.smoothing = delay; ledState.loop_delay = 0x10; ledState.unk = 0;