Skip to content

Commit c7d3c7e

Browse files
committed
more udpates to home_to_date_time
1 parent 17fd9af commit c7d3c7e

File tree

2 files changed

+67
-13
lines changed

2 files changed

+67
-13
lines changed

SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,7 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
317317

318318

319319
#if 1
320-
ImageFloatBox box(0.060, 0.75, 0.02, 0.08);
321-
ImageFloatBox system_settings(0.685, 0.69, 0.05, 0.03);
322-
ImageFloatBox other_setting1(0.615, 0.69, 0.05, 0.03);
323-
ImageFloatBox other_setting2(0.545, 0.69, 0.05, 0.03);
324-
cout << is_setting_selected(console, context, system_settings, other_setting1, other_setting2) << endl;
320+
home_to_date_time(console, context, true, false);
325321
#endif
326322

327323
#if 0

SerialPrograms/Source/NintendoSwitch/Programs/NintendoSwitch_Navigation.cpp

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
#include "Controllers/ControllerTypes.h"
8+
#include "CommonFramework/Exceptions/OperationFailedException.h"
89
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
910
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
1011
#include "CommonFramework/ImageTools/ImageStats.h"
@@ -32,8 +33,8 @@ bool is_setting_selected(VideoStream& stream, ProControllerContext& context, Ima
3233
overlays.add(COLOR_RED, selected_box);
3334
overlays.add(COLOR_BLUE, unselected_box1);
3435
overlays.add(COLOR_BLUE, unselected_box2);
35-
context.wait_for(Milliseconds(100));
3636
context.wait_for_all_requests();
37+
context.wait_for(Milliseconds(250));
3738
VideoSnapshot snapshot = stream.video().snapshot();
3839

3940
ImageStats stats_unselected_box1 = image_stats(extract_box_reference(snapshot, unselected_box1));
@@ -72,7 +73,31 @@ void home_to_date_time(VideoStream& stream, ProControllerContext& context, bool
7273

7374
ssf_issue_scroll(context, SSF_SCROLL_LEFT, 0);
7475

76+
// we expect to be at Settings icon
77+
ImageFloatBox system_settings(0.685, 0.69, 0.05, 0.03);
78+
ImageFloatBox other_setting1(0.615, 0.69, 0.05, 0.03);
79+
ImageFloatBox other_setting2(0.545, 0.69, 0.05, 0.03);
80+
if (!is_setting_selected(stream, context, system_settings, other_setting1, other_setting2)){
81+
// not at Settings Icon
82+
// mash down, mash right. then left one
83+
size_t iterations = Milliseconds(1200) / 24ms + 1;
84+
for (size_t i = 0; i < iterations; i++){
85+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 24ms);
86+
}
7587

88+
for (size_t i = 0; i < iterations; i++){
89+
ssf_issue_scroll(context, SSF_SCROLL_RIGHT, 24ms);
90+
}
91+
ssf_issue_scroll(context, SSF_SCROLL_LEFT, 0);
92+
93+
if (!is_setting_selected(stream, context, system_settings, other_setting1, other_setting2)){
94+
OperationFailedException::fire(
95+
ErrorReport::SEND_ERROR_REPORT,
96+
"home_to_date_time(): Failed to reach settings gear on Home page after 2 attempts.",
97+
stream
98+
);
99+
}
100+
}
76101

77102
// Two A presses in case we drop the 1st one.
78103
ssf_press_button(context, BUTTON_A, 3);
@@ -105,18 +130,51 @@ void home_to_date_time(VideoStream& stream, ProControllerContext& context, bool
105130
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 3);
106131
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 3);
107132

108-
if (!to_date_change){
109-
// Triple up this A press to make sure it gets through.
133+
134+
// double up this A press to make sure it gets through.
135+
ssf_press_button(context, BUTTON_A, 3);
136+
ssf_press_button(context, BUTTON_A, 3);
137+
138+
context.wait_for_all_requests();
139+
// we expect to be within "Date and Time", with "Synchronize Clock via Internet" being highlighted
140+
ImageFloatBox sync_clock(0.168, 0.185, 0.01, 0.1);
141+
ImageFloatBox other_setting3(0.1, 0.185, 0.01, 0.1);
142+
ImageFloatBox other_setting4(0.05, 0.185, 0.01, 0.1);
143+
if (!is_setting_selected(stream, context, sync_clock, other_setting3, other_setting4)){
144+
// press B once, then mash Up. then try again to scroll down to Date and Time
145+
pbf_press_button(context, BUTTON_B, 100ms, 100ms);
146+
pbf_move_left_joystick(context, 128, 0, 3000ms, 100ms);
147+
148+
size_t iterations = Milliseconds(1200) / 24ms + 1;
149+
for (size_t i = 0; i < iterations; i++){
150+
ssf_issue_scroll(context, SSF_SCROLL_UP, 24ms);
151+
}
152+
153+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 3);
154+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 3);
155+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 10);
156+
ssf_press_dpad(context, DPAD_DOWN, 45, 40);
157+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 3);
158+
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 3);
159+
160+
// double up this A press to make sure it gets through.
110161
ssf_press_button(context, BUTTON_A, 3);
111162
ssf_press_button(context, BUTTON_A, 3);
112-
ssf_press_button(context, BUTTON_A, 45);
163+
164+
if (!is_setting_selected(stream, context, sync_clock, other_setting3, other_setting4)){
165+
OperationFailedException::fire(
166+
ErrorReport::SEND_ERROR_REPORT,
167+
"home_to_date_time(): Failed to reach settings gear on Home page after 2 attempts.",
168+
stream
169+
);
170+
}
171+
172+
}
173+
174+
if (!to_date_change){
113175
return;
114176
}
115177

116-
// Triple up this A press to make sure it gets through.
117-
ssf_press_button(context, BUTTON_A, 3);
118-
ssf_press_button(context, BUTTON_A, 3);
119-
ssf_press_button(context, BUTTON_A, 3);
120178
{
121179
auto iterations = Milliseconds(250) / 24ms + 1;
122180
do{

0 commit comments

Comments
 (0)