Use the correct MCU LED period for calculations (#807)

Fixes #772
This commit is contained in:
Wolfvak 2023-04-25 10:13:07 -03:00 committed by GitHub
parent 620e5061c5
commit b5fca3bc7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,6 +22,8 @@
#include <stdatomic.h> #include <stdatomic.h>
#include "common.h"
#include "arm/timer.h" #include "arm/timer.h"
#include "hw/gpio.h" #include "hw/gpio.h"
@ -116,16 +118,13 @@ u32 mcuGetSpecialHID(void)
void mcuSetStatusLED(u32 period_ms, u32 color) void mcuSetStatusLED(u32 period_ms, u32 color)
{ {
u32 r, g, b; u32 r, g, b, delay;
mcuStatusLED ledState; mcuStatusLED ledState;
// handle proper non-zero periods delay = clamp((period_ms * 0x200) / 1000, 1, 0xFF);
// so small the hardware can't handle it
if (period_ms != 0 && period_ms < 63)
period_ms = 63;
ledState.delay = (period_ms * 0x10) / 1000; ledState.delay = delay;
ledState.smoothing = 0x40; ledState.smoothing = delay;
ledState.loop_delay = 0x10; ledState.loop_delay = 0x10;
ledState.unk = 0; ledState.unk = 0;