44 *
55 */
66
7+ #include " Common/Cpp/RecursiveThrottler.h"
78#include " CommonFramework/Exceptions/OperationFailedException.h"
89#include " CommonFramework/ImageTools/ImageBoxes.h"
910// #include "CommonFramework/VideoPipeline/VideoFeed.h"
@@ -23,7 +24,10 @@ namespace NintendoSwitch{
2324void home_to_date_time_Switch1_wired_blind (
2425 Logger& logger, ProControllerContext& context, bool to_date_change
2526){
26- logger.log (" home_to_date_time_Switch1_wired_blind()" );
27+ ThrottleScope scope (context->logging_throttler ());
28+ if (scope){
29+ context->logger ().log (" NintendoSwitch::home_to_date_time_Switch1_wired_blind()" );
30+ }
2731
2832 ssf_issue_scroll (context, SSF_SCROLL_RIGHT, 32ms);
2933 ssf_issue_scroll (context, SSF_SCROLL_RIGHT, 32ms);
@@ -93,7 +97,10 @@ void home_to_date_time_Switch1_wired_blind(
9397void home_to_date_time_Switch1_wireless_esp32_blind (
9498 Logger& logger, ProControllerContext& context, bool to_date_change
9599){
96- logger.log (" home_to_date_time_Switch1_wireless_esp32_blind()" );
100+ ThrottleScope scope (context->logging_throttler ());
101+ if (scope){
102+ context->logger ().log (" NintendoSwitch::home_to_date_time_Switch1_wireless_esp32_blind()" );
103+ }
97104
98105 Milliseconds tv = context->timing_variation ();
99106 Milliseconds unit = 24ms + tv;
@@ -167,7 +174,10 @@ void home_to_date_time_Switch1_wireless_esp32_blind(
167174void home_to_date_time_Switch1_sbb_blind (
168175 Logger& logger, ProControllerContext& context, bool to_date_change
169176){
170- logger.log (" home_to_date_time_Switch1_sbb_blind()" );
177+ ThrottleScope scope (context->logging_throttler ());
178+ if (scope){
179+ context->logger ().log (" NintendoSwitch::home_to_date_time_Switch1_sbb_blind()" );
180+ }
171181
172182 Milliseconds tv = context->timing_variation ();
173183// ssf_do_nothing(context, 1500ms);
@@ -213,34 +223,41 @@ void home_to_date_time_Switch1_wired_feedback(
213223
214224 size_t max_attempts = 5 ;
215225 for (size_t i = 0 ; i < max_attempts; i++){
216- ssf_issue_scroll (context, SSF_SCROLL_RIGHT, 32ms);
217- ssf_issue_scroll (context, SSF_SCROLL_RIGHT, 32ms);
218- ssf_issue_scroll (context, SSF_SCROLL_RIGHT, 32ms);
226+ {
227+ ThrottleScope scope (context->logging_throttler ());
228+ if (scope){
229+ context->logger ().log (" NintendoSwitch::home_to_date_time_Switch1_wired_feedback() - Part 1/3" );
230+ }
219231
220- // Down twice in case we drop one.
221- ssf_issue_scroll (context, SSF_SCROLL_DOWN, 24ms );
222- ssf_issue_scroll (context, SSF_SCROLL_DOWN , 32ms);
232+ ssf_issue_scroll (context, SSF_SCROLL_RIGHT, 32ms);
233+ ssf_issue_scroll (context, SSF_SCROLL_RIGHT, 32ms );
234+ ssf_issue_scroll (context, SSF_SCROLL_RIGHT , 32ms);
223235
224- // if (i > 0){ // intentionally create a failure, for testing
225- ssf_issue_scroll (context, SSF_SCROLL_LEFT, 0ms, 40ms , 24ms);
226- // }
236+ // Down twice in case we drop one.
237+ ssf_issue_scroll (context, SSF_SCROLL_DOWN , 24ms);
238+ ssf_issue_scroll (context, SSF_SCROLL_DOWN, 32ms);
227239
240+ // if (i > 0){ // intentionally create a failure, for testing
241+ ssf_issue_scroll (context, SSF_SCROLL_LEFT, 0ms, 40ms, 24ms);
242+ // }
228243
229- // ImageFloatBox system_icon(0.685, 0.69, 0.05, 0.03);
230- // ImageFloatBox other_setting1(0.615, 0.69, 0.05, 0.03);
231- // ImageFloatBox other_setting2(0.545, 0.69, 0.05, 0.03);
232244
233- // Two A presses in case we drop the 1st one.
234- // the program can self recover even if the second button press is registered.
235- ssf_press_button (context, BUTTON_A, 24ms, 40ms, 24ms);
236- ssf_press_button (context, BUTTON_A, 24ms, 48ms, 24ms);
245+ // ImageFloatBox system_icon(0.685, 0.69, 0.05, 0.03);
246+ // ImageFloatBox other_setting1(0.615, 0.69, 0.05, 0.03);
247+ // ImageFloatBox other_setting2(0.545, 0.69, 0.05, 0.03);
237248
238- // Just button mash it. lol
239- {
240- auto iterations = Milliseconds (1200 ) / 24ms + 1 ;
241- do {
242- ssf_issue_scroll (context, SSF_SCROLL_DOWN, 24ms);
243- }while (--iterations);
249+ // Two A presses in case we drop the 1st one.
250+ // the program can self recover even if the second button press is registered.
251+ ssf_press_button (context, BUTTON_A, 24ms, 40ms, 24ms);
252+ ssf_press_button (context, BUTTON_A, 24ms, 48ms, 24ms);
253+
254+ // Just button mash it. lol
255+ {
256+ auto iterations = Milliseconds (1200 ) / 24ms + 1 ;
257+ do {
258+ ssf_issue_scroll (context, SSF_SCROLL_DOWN, 24ms);
259+ }while (--iterations);
260+ }
244261 }
245262
246263 context.wait_for_all_requests ();
@@ -263,26 +280,33 @@ void home_to_date_time_Switch1_wired_feedback(
263280 continue ;
264281 }
265282
266-
267283 {
268- auto iterations = Milliseconds (312 ) / 24ms + 1 ;
269- do {
270- ssf_issue_scroll (context, SSF_SCROLL_RIGHT, 24ms);
271- }while (--iterations);
284+ ThrottleScope scope (context->logging_throttler ());
285+ if (scope){
286+ context->logger ().log (" NintendoSwitch::home_to_date_time_Switch1_wired_feedback() - Part 2/3" );
287+ }
288+
289+ {
290+ auto iterations = Milliseconds (312 ) / 24ms + 1 ;
291+ do {
292+ ssf_issue_scroll (context, SSF_SCROLL_RIGHT, 24ms);
293+ }while (--iterations);
294+ }
295+
296+ ssf_issue_scroll (context, SSF_SCROLL_DOWN, 24ms);
297+ ssf_issue_scroll (context, SSF_SCROLL_DOWN, 24ms);
298+ ssf_issue_scroll (context, SSF_SCROLL_DOWN, 80ms, 40ms, 24ms);
299+ ssf_press_dpad (context, DPAD_DOWN, 360ms, 320ms);
300+ ssf_issue_scroll (context, SSF_SCROLL_DOWN, 24ms);
301+ // if (i > 1){ // intentionally create a failure, for testing
302+ ssf_issue_scroll (context, SSF_SCROLL_DOWN, 24ms);
303+ // }
304+
305+ // only one ButtonA press since the program can self-recover if the button is dropped.
306+ // furthermore, the program can't self-recover if a second button press is registered.
307+ ssf_press_button (context, BUTTON_A, 24ms, 48ms, 24ms);
272308 }
273309
274- ssf_issue_scroll (context, SSF_SCROLL_DOWN, 24ms);
275- ssf_issue_scroll (context, SSF_SCROLL_DOWN, 24ms);
276- ssf_issue_scroll (context, SSF_SCROLL_DOWN, 80ms, 40ms, 24ms);
277- ssf_press_dpad (context, DPAD_DOWN, 360ms, 320ms);
278- ssf_issue_scroll (context, SSF_SCROLL_DOWN, 24ms);
279- // if (i > 1){ // intentionally create a failure, for testing
280- ssf_issue_scroll (context, SSF_SCROLL_DOWN, 24ms);
281- // }
282-
283- // only one ButtonA press since the program can self-recover if the button is dropped.
284- // furthermore, the program can't self-recover if a second button press is registered.
285- ssf_press_button (context, BUTTON_A, 24ms, 48ms, 24ms);
286310
287311 context.wait_for_all_requests ();
288312 context.wait_for (Milliseconds (300 ));
@@ -306,6 +330,12 @@ void home_to_date_time_Switch1_wired_feedback(
306330 return ;
307331 }
308332
333+ ThrottleScope scope (context->logging_throttler ());
334+ if (scope){
335+ context->logger ().log (" NintendoSwitch::home_to_date_time_Switch1_wired_feedback() - Part 3/3" );
336+ }
337+
338+
309339 {
310340 auto iterations = Milliseconds (250 ) / 24ms + 1 ;
311341 do {
@@ -334,6 +364,11 @@ void home_to_date_time_Switch1_wired_feedback(
334364
335365
336366void home_to_date_time_Switch1_joycon_blind (JoyconContext& context, bool to_date_change){
367+ ThrottleScope scope (context->logging_throttler ());
368+ if (scope){
369+ context->logger ().log (" NintendoSwitch::home_to_date_time_Switch1_joycon_blind()" );
370+ }
371+
337372 Milliseconds tv = context->timing_variation ();
338373 Milliseconds unit = 100ms + tv;
339374
0 commit comments