diff --git a/libctru/include/3ds/services/mcuhwc.h b/libctru/include/3ds/services/mcuhwc.h index 9af78d6d8..027cdc5fb 100644 --- a/libctru/include/3ds/services/mcuhwc.h +++ b/libctru/include/3ds/services/mcuhwc.h @@ -4,15 +4,25 @@ */ #pragma once -typedef enum +typedef enum { + LED_NORMAL = 1, ///< The normal mode of the led + LED_SLEEP_MODE, ///< The led pulses slowly as it does in the sleep mode + LED_OFF, ///< Switch off power led + LED_RED, ///< Red state of the led + LED_BLUE, ///< Blue state of the led + LED_BLINK_RED, ///< Blinking red state of power led and notification led +} powerLedState; + +typedef struct InfoLedPattern { - LED_NORMAL = 1, ///< The normal mode of the led - LED_SLEEP_MODE, ///< The led pulses slowly as it does in the sleep mode - LED_OFF, ///< Switch off power led - LED_RED, ///< Red state of the led - LED_BLUE, ///< Blue state of the led - LED_BLINK_RED, ///< Blinking red state of power led and notification led -}powerLedState; + u8 delay; ///< Delay between pattern values, 1/16th of a second (1 second = 0x10) + u8 smoothing; ///< Smoothing between pattern values (higher = smoother) + u8 loopDelay; ///< Delay between pattern loops, 1/16th of a second (1 second = 0x10, 0xFF = pattern is played only once) + u8 blinkSpeed; ///< Blink speed, when smoothing == 0x00 + u8 redPattern[32]; ///< Pattern for red component + u8 greenPattern[32]; ///< Pattern for green component + u8 bluePattern[32]; ///< Pattern for blue component +} InfoLedPattern; /// Initializes mcuHwc. Result mcuHwcInit(void); @@ -66,6 +76,12 @@ Result MCUHWC_GetSoundSliderLevel(u8 *level); */ Result MCUHWC_SetWifiLedState(bool state); +/** + * @brief Sets the notification LED pattern + * @param pattern Pattern for the notification LED. + */ +Result MCUHWC_SetInfoLedPattern(const InfoLedPattern* pattern); + /** * @brief Sets Power LED state * @param state powerLedState State of power LED. diff --git a/libctru/source/services/mcuhwc.c b/libctru/source/services/mcuhwc.c index 3b0d410bf..99f8e1d3d 100644 --- a/libctru/source/services/mcuhwc.c +++ b/libctru/source/services/mcuhwc.c @@ -1,3 +1,4 @@ +#include #include <3ds/types.h> #include <3ds/svc.h> #include <3ds/synchronization.h> @@ -114,6 +115,22 @@ Result MCUHWC_SetWifiLedState(bool state) return (Result)cmdbuf[1]; } +Result MCUHWC_SetInfoLedPattern(const InfoLedPattern* pattern) +{ + Result ret = 0; + u32 *cmdbuf = getThreadCommandBuffer(); + + cmdbuf[0] = IPC_MakeHeader(0x0A,25,0); // 0xA0640 + cmdbuf[1] = ((u32)pattern->blinkSpeed << 24) | ((u32)pattern->loopDelay << 16) | ((u32)pattern->smoothing << 8) | pattern->delay; + memcpy(&cmdbuf[2], pattern->redPattern, sizeof(pattern->redPattern)); + memcpy(&cmdbuf[10], pattern->greenPattern, sizeof(pattern->greenPattern)); + memcpy(&cmdbuf[18], pattern->bluePattern, sizeof(pattern->bluePattern)); + + if(R_FAILED(ret = svcSendSyncRequest(mcuHwcHandle))) return ret; + + return (Result)cmdbuf[1]; +} + Result MCUHWC_GetSoundSliderLevel(u8 *level) { Result ret = 0;