Skip to content

Commit

Permalink
Add MCUHWC_SetInfoLEDPattern
Browse files Browse the repository at this point in the history
  • Loading branch information
kynex7510 committed Aug 7, 2024
1 parent faf5162 commit a0eb3ac
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
16 changes: 16 additions & 0 deletions libctru/include/3ds/services/mcuhwc.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ typedef enum
LED_BLINK_RED, ///< Blinking red state of power led and notification led
}powerLedState;

typedef struct {
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);

Expand Down Expand Up @@ -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.
Expand Down
17 changes: 17 additions & 0 deletions libctru/source/services/mcuhwc.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <string.h>
#include <3ds/types.h>
#include <3ds/svc.h>
#include <3ds/synchronization.h>
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit a0eb3ac

Please sign in to comment.