@@ -25,14 +25,6 @@ int main(int argc, char* argv[])
25
25
u64 UniquePadIds [2 ];
26
26
HidsysNotificationLedPattern pattern ;
27
27
28
- memset (& pattern , 0 , sizeof (pattern ));
29
-
30
- // Setup the pattern data.
31
- pattern .globalMiniCycleDuration = 0xf ;
32
- pattern .totalMiniCycles = 0xf ;
33
- pattern .totalFullCycles = 0xf ;
34
- pattern .startIntensity = 0xf ;
35
-
36
28
printf ("notification-led example\n" );
37
29
38
30
rc = hidsysInitialize ();
@@ -42,8 +34,9 @@ int main(int argc, char* argv[])
42
34
}
43
35
else {
44
36
initflag = 1 ;
45
- printf ("Press A to set the notification-LED pattern.\n" );
46
- printf ("Press + to exit.\n" );
37
+ printf ("Press A to set a Breathing effect notification-LED pattern.\n" );
38
+ printf ("Press B to set a Heartbeat effect notification-LED pattern.\n" );
39
+ printf ("Press + to disable notification-LED and exit.\n" );
47
40
}
48
41
49
42
// Main loop
@@ -56,10 +49,60 @@ int main(int argc, char* argv[])
56
49
// just pressed in this frame compared to the previous one
57
50
u64 kDown = hidKeysDown (CONTROLLER_P1_AUTO );
58
51
59
- if (kDown & KEY_PLUS )
60
- break ; // break in order to return to hbmenu
52
+ if (kDown & KEY_PLUS ) {
53
+ // Disable notification led.
54
+ memset (& pattern , 0 , sizeof (pattern ));
55
+ }
56
+ else if (kDown & KEY_A ) {
57
+ memset (& pattern , 0 , sizeof (pattern ));
58
+
59
+ // Setup Breathing effect pattern data.
60
+ pattern .baseMiniCycleDuration = 0x8 ; // 100ms.
61
+ pattern .totalMiniCycles = 0x2 ; // 3 mini cycles. Last one 12.5ms.
62
+ pattern .totalFullCycles = 0x0 ; // Repeat forever.
63
+ pattern .startIntensity = 0x2 ; // 13%.
64
+
65
+ pattern .miniCycles [0 ].ledIntensity = 0xF ; // 100%.
66
+ pattern .miniCycles [0 ].transitionSteps = 0xF ; // 15 steps. Transition time 1.5s.
67
+ pattern .miniCycles [0 ].finalStepDuration = 0x0 ; // Forced 12.5ms.
68
+ pattern .miniCycles [1 ].ledIntensity = 0x2 ; // 13%.
69
+ pattern .miniCycles [1 ].transitionSteps = 0xF ; // 15 steps. Transition time 1.5s.
70
+ pattern .miniCycles [1 ].finalStepDuration = 0x0 ; // Forced 12.5ms.
71
+ }
72
+ else if (kDown & KEY_B ) {
73
+ memset (& pattern , 0 , sizeof (pattern ));
74
+
75
+ // Setup Heartbeat effect pattern data.
76
+ pattern .baseMiniCycleDuration = 0x1 ; // 12.5ms.
77
+ pattern .totalMiniCycles = 0xF ; // 16 mini cycles.
78
+ pattern .totalFullCycles = 0x0 ; // Repeat forever.
79
+ pattern .startIntensity = 0x0 ; // 0%.
80
+
81
+ // First beat.
82
+ pattern .miniCycles [0 ].ledIntensity = 0xF ; // 100%.
83
+ pattern .miniCycles [0 ].transitionSteps = 0xF ; // 15 steps. Total 187.5ms.
84
+ pattern .miniCycles [0 ].finalStepDuration = 0x0 ; // Forced 12.5ms.
85
+ pattern .miniCycles [1 ].ledIntensity = 0x0 ; // 0%.
86
+ pattern .miniCycles [1 ].transitionSteps = 0xF ; // 15 steps. Total 187.5ms.
87
+ pattern .miniCycles [1 ].finalStepDuration = 0x0 ; // Forced 12.5ms.
88
+
89
+ // Second beat.
90
+ pattern .miniCycles [2 ].ledIntensity = 0xF ;
91
+ pattern .miniCycles [2 ].transitionSteps = 0xF ;
92
+ pattern .miniCycles [2 ].finalStepDuration = 0x0 ;
93
+ pattern .miniCycles [3 ].ledIntensity = 0x0 ;
94
+ pattern .miniCycles [3 ].transitionSteps = 0xF ;
95
+ pattern .miniCycles [3 ].finalStepDuration = 0x0 ;
96
+
97
+ // Led off wait time.
98
+ for (i = 2 ; i < 15 ; i ++ ) {
99
+ pattern .miniCycles [i ].ledIntensity = 0x0 ; // 0%.
100
+ pattern .miniCycles [i ].transitionSteps = 0xF ; // 15 steps. Total 187.5ms.
101
+ pattern .miniCycles [i ].finalStepDuration = 0xF ; // 187.5ms.
102
+ }
103
+ }
61
104
62
- if (kDown & KEY_A ) {
105
+ if (kDown & ( KEY_A | KEY_B | KEY_PLUS ) ) {
63
106
total_entries = 0 ;
64
107
memset (UniquePadIds , 0 , sizeof (UniquePadIds ));
65
108
@@ -81,6 +124,9 @@ int main(int argc, char* argv[])
81
124
82
125
// Update the console, sending a new frame to the display
83
126
consoleUpdate (NULL );
127
+
128
+ if (kDown & KEY_PLUS )
129
+ break ; // break in order to return to hbmenu
84
130
}
85
131
86
132
if (initflag ) hidsysExit ();
0 commit comments