Skip to content

Commit 669e4d3

Browse files
committed
Migrate more SwSh programs to TimeDurationOption.
1 parent 5636633 commit 669e4d3

File tree

46 files changed

+272
-316
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+272
-316
lines changed

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase_Handle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "Common/Microcontroller/DeviceRoutines.h"
1616
#include "Common/NintendoSwitch/NintendoSwitch_ControllerDefs.h"
1717
#include "ClientSource/Libraries/MessageConverter.h"
18-
#include "ClientSource/Connection/SerialConnection.h"
18+
//#include "ClientSource/Connection/SerialConnection.h"
1919
//#include "ClientSource/Connection/BotBase.h"
2020
#include "ClientSource/Connection/PABotBase.h"
2121
#include "CommonFramework/Globals.h"

SerialPrograms/Source/PokemonSwSh/Commands/PokemonSwSh_Commands_EggRoutines.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ void eggfetcher_loop(SwitchControllerContext& context){
2525
ssf_press_left_joystick(context, 192, STICK_MIN, 120, 120);
2626
ssf_press_left_joystick(context, STICK_MAX, STICK_MIN, 120, 120);
2727
}
28-
void move_while_mashing_B(SwitchControllerContext& context, uint16_t duration){
28+
void move_while_mashing_B(SwitchControllerContext& context, Milliseconds duration){
2929
// Hold the joystick to the right for the entire duration.
30-
ssf_press_left_joystick(context, STICK_MAX, STICK_CENTER, 0, duration);
30+
ssf_press_left_joystick(context, STICK_MAX, STICK_CENTER, 0ms, duration);
3131

3232
// While the above is running, spam B.
3333
ssf_mash1_button(context, BUTTON_B, duration);
3434
}
35-
void spin_and_mash_A(SwitchControllerContext& context, uint16_t duration){
36-
for (uint16_t c = 0; c < duration; c += 128){
35+
void spin_and_mash_A(SwitchControllerContext& context, Milliseconds duration){
36+
for (Milliseconds c = 0ms; c < duration; c += 1024ms){
3737
ssf_press_left_joystick(context, STICK_CENTER, STICK_MAX, 0, 32);
3838
ssf_press_button(context, BUTTON_A, 16);
3939
ssf_press_button(context, BUTTON_A, 16);

SerialPrograms/Source/PokemonSwSh/Commands/PokemonSwSh_Commands_EggRoutines.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ namespace NintendoSwitch{
1616

1717

1818
void eggfetcher_loop (SwitchControllerContext& context);
19-
void move_while_mashing_B (SwitchControllerContext& context, uint16_t duration);
20-
void spin_and_mash_A (SwitchControllerContext& context, uint16_t duration);
19+
void move_while_mashing_B (SwitchControllerContext& context, Milliseconds duration);
20+
void spin_and_mash_A (SwitchControllerContext& context, Milliseconds duration);
2121
void travel_to_spin_location(SwitchControllerContext& context);
2222
void travel_back_to_lady (SwitchControllerContext& context);
2323

SerialPrograms/Source/PokemonSwSh/Inference/Dens/PokemonSwSh_BeamSetter.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ BeamSetter::BeamSetter(ProgramEnvironment& /*env*/, VideoStream& stream, SwitchC
4646

4747
BeamSetter::Detection BeamSetter::run(
4848
bool save_screenshot,
49-
uint16_t timeout_ticks,
49+
Milliseconds timeout,
5050
double min_brightness,
5151
double min_euclidean,
5252
double min_delta_ratio,
@@ -77,10 +77,7 @@ BeamSetter::Detection BeamSetter::run(
7777
trackers.emplace_back(std::chrono::milliseconds(1000));
7878
}
7979

80-
InferenceThrottler throttler(
81-
std::chrono::milliseconds((uint64_t)timeout_ticks * 1000 / TICKS_PER_SECOND),
82-
std::chrono::milliseconds(50)
83-
);
80+
InferenceThrottler throttler(timeout, std::chrono::milliseconds(50));
8481

8582
VideoSnapshot last_screenshot = baseline_image;
8683
do{

SerialPrograms/Source/PokemonSwSh/Inference/Dens/PokemonSwSh_BeamSetter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class BeamSetter{
3838

3939
Detection run(
4040
bool save_screenshot,
41-
uint16_t timeout_ticks,
41+
Milliseconds timeout,
4242
double min_brightness,
4343
double min_euclidean,
4444
double min_delta_ratio,

SerialPrograms/Source/PokemonSwSh/Programs/DateSpamFarmers/PokemonSwSh_DateSpam-LotoFarmer.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,18 @@ LotoFarmer::LotoFarmer()
3939
LockMode::LOCK_WHILE_RUNNING,
4040
100000
4141
)
42-
, MASH_B_DURATION(
42+
, MASH_B_DURATION0(
4343
"<b>Mash B for this long to exit the dialog:</b><br>(Some languages like German need to increase this.)",
4444
LockMode::LOCK_WHILE_RUNNING,
45-
TICKS_PER_SECOND,
46-
"9 * TICKS_PER_SECOND"
45+
"9000 ms"
4746
)
4847
, NOTIFICATIONS({
4948
&NOTIFICATION_PROGRAM_FINISH,
5049
})
5150
{
5251
PA_ADD_OPTION(START_LOCATION);
5352
PA_ADD_OPTION(SKIPS);
54-
PA_ADD_OPTION(MASH_B_DURATION);
53+
PA_ADD_OPTION(MASH_B_DURATION0);
5554
PA_ADD_OPTION(NOTIFICATIONS);
5655
}
5756

@@ -73,7 +72,7 @@ void LotoFarmer::program(SingleSwitchProgramEnvironment& env, SwitchControllerCo
7372
pbf_press_button(context, BUTTON_B, 10, 70);
7473
pbf_press_dpad(context, DPAD_DOWN, 10, 5);
7574
pbf_mash_button(context, BUTTON_ZL, 490);
76-
pbf_mash_button(context, BUTTON_B, MASH_B_DURATION);
75+
pbf_mash_button(context, BUTTON_B, MASH_B_DURATION0);
7776

7877
// Tap HOME and quickly spam B. The B spamming ensures that we don't
7978
// accidentally update the system if the system update window pops up.

SerialPrograms/Source/PokemonSwSh/Programs/DateSpamFarmers/PokemonSwSh_DateSpam-LotoFarmer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define PokemonAutomation_PokemonSwSh_LotoFarmer_H
99

1010
#include "Common/Cpp/Options/SimpleIntegerOption.h"
11-
#include "Common/Cpp/Options/TimeExpressionOption.h"
11+
#include "Common/Cpp/Options/TimeDurationOption.h"
1212
#include "CommonFramework/Notifications/EventNotificationsTable.h"
1313
#include "NintendoSwitch/Options/NintendoSwitch_StartInGripMenuOption.h"
1414
#include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h"
@@ -35,7 +35,7 @@ class LotoFarmer : public SingleSwitchProgramInstance{
3535
StartInGripOrGameOption START_LOCATION;
3636

3737
SimpleIntegerOption<uint32_t> SKIPS;
38-
TimeExpressionOption<uint16_t> MASH_B_DURATION;
38+
MillisecondsOption MASH_B_DURATION0;
3939

4040
EventNotificationsOption NOTIFICATIONS;
4141
};

SerialPrograms/Source/PokemonSwSh/Programs/DateSpamFarmers/PokemonSwSh_DateSpam-PokeJobsFarmer.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,10 @@ PokeJobsFarmer::PokeJobsFarmer()
5050
, m_advanced_options(
5151
"<font size=4><b>Advanced Options:</b> You should not need to touch anything below here.</font>"
5252
)
53-
, MASH_B_DURATION(
53+
, MASH_B_DURATION0(
5454
"<b>Mash B for this long upon completion of " + STRING_POKEJOB + ":</b>",
5555
LockMode::LOCK_WHILE_RUNNING,
56-
TICKS_PER_SECOND,
57-
"8 * TICKS_PER_SECOND"
56+
"8000 ms"
5857
)
5958
, NOTIFICATIONS({
6059
&NOTIFICATION_PROGRAM_FINISH,
@@ -64,7 +63,7 @@ PokeJobsFarmer::PokeJobsFarmer()
6463
PA_ADD_OPTION(CONCURRENCY);
6564
PA_ADD_OPTION(MENU_INDEX);
6665
PA_ADD_STATIC(m_advanced_options);
67-
PA_ADD_OPTION(MASH_B_DURATION);
66+
PA_ADD_OPTION(MASH_B_DURATION0);
6867
PA_ADD_OPTION(NOTIFICATIONS);
6968
}
7069

@@ -84,7 +83,7 @@ void PokeJobsFarmer::program(SingleSwitchProgramEnvironment& env, SwitchControll
8483
uint8_t year = MAX_YEAR;
8584

8685
// Play it safe in case some menu is open
87-
pbf_mash_button(context, BUTTON_B, MASH_B_DURATION);
86+
pbf_mash_button(context, BUTTON_B, MASH_B_DURATION0);
8887

8988
for (uint32_t c = 0; c < SKIPS; c++)
9089
{
@@ -95,7 +94,7 @@ void PokeJobsFarmer::program(SingleSwitchProgramEnvironment& env, SwitchControll
9594
pbf_press_button(context, BUTTON_B, 5, 5);
9695
pbf_press_button(context, BUTTON_HOME, 80ms, GameSettings::instance().GAME_TO_HOME_DELAY_FAST0);
9796
home_roll_date_enter_game_autorollback(env.console, context, year);
98-
pbf_mash_button(context, BUTTON_B, MASH_B_DURATION);
97+
pbf_mash_button(context, BUTTON_B, MASH_B_DURATION0);
9998

10099
// Get rid of new jobs notification by entering Poke Jobs and leaving immediately
101100
enter_jobs(context, MENU_INDEX);
@@ -161,7 +160,7 @@ void PokeJobsFarmer::program(SingleSwitchProgramEnvironment& env, SwitchControll
161160

162161
// Skip through wall of text and exit
163162
env.log("#### Exit " + STRING_POKEJOB + "s");
164-
pbf_mash_button(context, BUTTON_B, MASH_B_DURATION);
163+
pbf_mash_button(context, BUTTON_B, MASH_B_DURATION0);
165164
}
166165
}
167166

SerialPrograms/Source/PokemonSwSh/Programs/DateSpamFarmers/PokemonSwSh_DateSpam-PokeJobsFarmer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include "Common/Cpp/Options/StaticTextOption.h"
1111
#include "Common/Cpp/Options/SimpleIntegerOption.h"
12-
#include "Common/Cpp/Options/TimeExpressionOption.h"
12+
#include "Common/Cpp/Options/TimeDurationOption.h"
1313
#include "CommonFramework/Notifications/EventNotificationsTable.h"
1414
#include "NintendoSwitch/Options/NintendoSwitch_StartInGripMenuOption.h"
1515
#include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h"
@@ -39,7 +39,7 @@ class PokeJobsFarmer : public SingleSwitchProgramInstance{
3939

4040
SectionDividerOption m_advanced_options;
4141

42-
TimeExpressionOption<uint16_t> MASH_B_DURATION;
42+
MillisecondsOption MASH_B_DURATION0;
4343

4444
EventNotificationsOption NOTIFICATIONS;
4545
};

SerialPrograms/Source/PokemonSwSh/Programs/DateSpamFarmers/PokemonSwSh_DateSpam-WattFarmer.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,11 @@ WattFarmer_Descriptor::WattFarmer_Descriptor()
3333

3434

3535
WattFarmer::WattFarmer()
36-
: GRIP_MENU_WAIT(
36+
: GRIP_MENU_WAIT0(
3737
"<b>Exit Grip Menu Delay:</b> "
3838
"Wait this long after leaving the grip menu to allow for the Switch to reestablish local connection.",
3939
LockMode::LOCK_WHILE_RUNNING,
40-
TICKS_PER_SECOND,
41-
"5 * TICKS_PER_SECOND"
40+
"5000 ms"
4241
)
4342
, EXIT_DEN_WAIT(
4443
"<b>Exit Den Wait Time:</b> "
@@ -70,7 +69,7 @@ WattFarmer::WattFarmer()
7069
void WattFarmer::program(SingleSwitchProgramEnvironment& env, SwitchControllerContext& context){
7170
if (START_LOCATION.start_in_grip_menu()){
7271
grip_menu_connect_go_home(context);
73-
pbf_wait(context, GRIP_MENU_WAIT);
72+
pbf_wait(context, GRIP_MENU_WAIT0);
7473
}else{
7574
pbf_press_button(context, BUTTON_B, 5, 5);
7675
pbf_press_button(context, BUTTON_HOME, 80ms, GameSettings::instance().GAME_TO_HOME_DELAY_FAST0);

0 commit comments

Comments
 (0)