Skip to content

Commit 1f210a4

Browse files
committed
2 parents 55a1d4c + a1072c0 commit 1f210a4

File tree

3 files changed

+51
-9
lines changed

3 files changed

+51
-9
lines changed

SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
#include "PokemonSV/Programs/Farming/PokemonSV_TournamentFarmer.h"
121121
#include "NintendoSwitch/Programs/NintendoSwitch_NumberCodeEntry.h"
122122
#include "PokemonSV/Inference/ItemPrinter/PokemonSV_ItemPrinterMenuDetector.h"
123+
#include "PokemonSV/Inference/Picnics/PokemonSV_SandwichHandDetector.h"
123124

124125

125126
#include <QPixmap>
@@ -317,6 +318,7 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
317318
// std::terminate();
318319

319320

321+
#if 0
320322
ImageRGB32 image("20250404-154507236508.png");
321323

322324
ArcPhoneDetector phone(logger, overlay, std::chrono::milliseconds(250), true);
@@ -333,10 +335,23 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
333335
{phone}
334336
);
335337
#endif
338+
#endif
336339

337340
#if 0
338341
// ImageRGB32 image(IMAGE_PATH);
339342
auto image = feed.snapshot();
343+
#if 1
344+
ImageRGB32 image(IMAGE_PATH);
345+
// auto image = feed.snapshot();
346+
347+
SandwichHandLocator hand(SandwichHandType::FREE, {0, 0, 1, 1});
348+
std::pair<double, double> location = hand.locate_sandwich_hand(image, {0,0,1,1});
349+
cout << location.first << ", " << location.second << endl;
350+
#endif
351+
352+
#if 0
353+
ImageRGB32 image(IMAGE_PATH);
354+
// auto image = feed.snapshot();
340355

341356
ItemPrinterMaterialDetector detector(COLOR_RED, Language::English);
342357

@@ -349,6 +364,7 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
349364
}
350365

351366
#endif
367+
#endif
352368

353369
#if 0
354370

SerialPrograms/Source/PokemonSV/Programs/Sandwiches/PokemonSV_SandwichMaker.cpp

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

77
#include "CommonFramework/Notifications/ProgramNotifications.h"
8+
#include "CommonFramework/ProgramStats/StatsTracking.h"
89
#include "CommonTools/StartupChecks/VideoResolutionCheck.h"
910
#include "Pokemon/Pokemon_Strings.h"
1011
#include "PokemonSV/Programs/Sandwiches/PokemonSV_SandwichRoutines.h"
@@ -32,6 +33,22 @@ SandwichMaker_Descriptor::SandwichMaker_Descriptor()
3233
)
3334
{}
3435

36+
struct SandwichMaker_Descriptor::Stats : public StatsTracker{
37+
Stats()
38+
: sandwiches(m_stats["Sandwiches"])
39+
, errors(m_stats["Errors"])
40+
{
41+
m_display_order.emplace_back("Sandwiches");
42+
m_display_order.emplace_back("Errors", HIDDEN_IF_ZERO);
43+
}
44+
std::atomic<uint64_t>& sandwiches;
45+
std::atomic<uint64_t>& errors;
46+
};
47+
48+
std::unique_ptr<StatsTracker> SandwichMaker_Descriptor::make_stats() const{
49+
return std::unique_ptr<StatsTracker>(new Stats());
50+
}
51+
3552
SandwichMaker::SandwichMaker()
3653
: SANDWICH_OPTIONS(
3754
"Sandwich Options",
@@ -40,29 +57,34 @@ SandwichMaker::SandwichMaker()
4057
false,
4158
GroupOption::EnableMode::ALWAYS_ENABLED
4259
)
60+
, NUM_SANDWICHES(
61+
"<b>Number of sandwiches to make:</b><br>Repeatedly make the same sandwich.",
62+
LockMode::UNLOCK_WHILE_RUNNING,
63+
1, 1, 1000
64+
)
4365
, GO_HOME_WHEN_DONE(false)
4466
, NOTIFICATIONS({
4567
&NOTIFICATION_PROGRAM_FINISH,
4668
&NOTIFICATION_ERROR_FATAL,
4769
})
4870
{
4971
PA_ADD_OPTION(SANDWICH_OPTIONS);
72+
PA_ADD_OPTION(NUM_SANDWICHES);
5073
PA_ADD_OPTION(GO_HOME_WHEN_DONE);
5174
PA_ADD_OPTION(NOTIFICATIONS);
5275
}
5376

5477
void SandwichMaker::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
5578
assert_16_9_720p_min(env.logger(), env.console);
79+
SandwichMaker_Descriptor::Stats& stats = env.current_stats<SandwichMaker_Descriptor::Stats>();
5680

57-
#if 0
58-
// make unlimited sandwiches. until it errors out.
59-
while (true){
60-
make_sandwich_option(env, env.console, context, SANDWICH_OPTIONS);
61-
enter_sandwich_recipe_list(env.program_info(), env.console, context);
62-
}
63-
#endif
64-
65-
make_sandwich_option(env, env.console, context, SANDWICH_OPTIONS);
81+
for (int i = 0; i < NUM_SANDWICHES; i++){
82+
env.console.log("Making sandwich number: " + std::to_string(i+1), COLOR_ORANGE);
83+
stats.sandwiches++;
84+
env.update_stats();
85+
make_sandwich_option(env, env.console, context, SANDWICH_OPTIONS);
86+
enter_sandwich_recipe_list(env.program_info(), env.console, context);
87+
}
6688

6789
GO_HOME_WHEN_DONE.run_end_of_program(context);
6890
send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH);

SerialPrograms/Source/PokemonSV/Programs/Sandwiches/PokemonSV_SandwichMaker.h

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

1010
#include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h"
1111
#include "NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.h"
12+
#include "Common/Cpp/Options/SimpleIntegerOption.h"
1213
#include "CommonFramework/Notifications/EventNotificationsTable.h"
1314
#include "PokemonSV/Options/PokemonSV_SandwichMakerOption.h"
1415

@@ -20,6 +21,8 @@ namespace PokemonSV{
2021
class SandwichMaker_Descriptor : public SingleSwitchProgramDescriptor{
2122
public:
2223
SandwichMaker_Descriptor();
24+
struct Stats;
25+
virtual std::unique_ptr<StatsTracker> make_stats() const override;
2326
};
2427

2528
class SandwichMaker : public SingleSwitchProgramInstance{
@@ -30,6 +33,7 @@ class SandwichMaker : public SingleSwitchProgramInstance{
3033

3134
private:
3235
SandwichMakerOption SANDWICH_OPTIONS;
36+
SimpleIntegerOption<uint16_t> NUM_SANDWICHES;
3337
GoHomeWhenDoneOption GO_HOME_WHEN_DONE;
3438
EventNotificationsOption NOTIFICATIONS;
3539
};

0 commit comments

Comments
 (0)