Skip to content

Commit 2622838

Browse files
authored
make multiple sandwiches with SandwichMaker (#565)
1 parent 24a2a8b commit 2622838

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,31 @@ SandwichMaker::SandwichMaker()
4040
false,
4141
GroupOption::EnableMode::ALWAYS_ENABLED
4242
)
43+
, NUM_SANDWICHES(
44+
"<b>Number of sandwiches to make:</b><br>Repeatedly make the same sandwich.",
45+
LockMode::UNLOCK_WHILE_RUNNING,
46+
1, 1, 1000
47+
)
4348
, GO_HOME_WHEN_DONE(false)
4449
, NOTIFICATIONS({
4550
&NOTIFICATION_PROGRAM_FINISH,
4651
&NOTIFICATION_ERROR_FATAL,
4752
})
4853
{
4954
PA_ADD_OPTION(SANDWICH_OPTIONS);
55+
PA_ADD_OPTION(NUM_SANDWICHES);
5056
PA_ADD_OPTION(GO_HOME_WHEN_DONE);
5157
PA_ADD_OPTION(NOTIFICATIONS);
5258
}
5359

5460
void SandwichMaker::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
5561
assert_16_9_720p_min(env.logger(), env.console);
5662

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);
63+
for (int i = 0; i < NUM_SANDWICHES; i++){
64+
env.console.log("Making sandwich number: " + std::to_string(i+1), COLOR_ORANGE);
65+
make_sandwich_option(env, env.console, context, SANDWICH_OPTIONS);
66+
enter_sandwich_recipe_list(env.program_info(), env.console, context);
67+
}
6668

6769
GO_HOME_WHEN_DONE.run_end_of_program(context);
6870
send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH);

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

Lines changed: 2 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

@@ -30,6 +31,7 @@ class SandwichMaker : public SingleSwitchProgramInstance{
3031

3132
private:
3233
SandwichMakerOption SANDWICH_OPTIONS;
34+
SimpleIntegerOption<uint16_t> NUM_SANDWICHES;
3335
GoHomeWhenDoneOption GO_HOME_WHEN_DONE;
3436
EventNotificationsOption NOTIFICATIONS;
3537
};

0 commit comments

Comments
 (0)