Namespace the p001 steps

This commit is contained in:
2026-04-09 13:36:08 -05:00
parent 202b926eb7
commit b2813d62a3
32 changed files with 369 additions and 153 deletions
+12 -6
View File
@@ -1,12 +1,18 @@
set(SOURCES
"setup_wires.cpp"
"step0.cpp"
"step1.cpp"
"step2.cpp"
"step3.cpp"
"step4.cpp"
"step5.cpp"
"step6.cpp"
"p001_step1.cpp"
"p001_step2.cpp"
"p001_step3.cpp"
"p001_step4.cpp"
"p001_step5.cpp"
"p001_step6.cpp"
"p002_step1.cpp"
"p002_step2.cpp"
"p002_step3.cpp"
"p002_step4.cpp"
"p002_step5.cpp"
"p002_step6.cpp"
"wires_puzzle.cpp"
)
@@ -1,4 +1,4 @@
#include "step1.h"
#include "p001_step1.h"
__attribute__((unused))
static const char *TAG = "step1";
@@ -275,7 +275,7 @@ static bool play_part(uint32_t time) {
return true;
}
void step1(void) {
void p001_step1(void) {
while (get_switch_flipped(nullptr));
init_step();
+10
View File
@@ -0,0 +1,10 @@
#ifndef P001_STEP_1_H
#define P001_STEP_1_H
#include <random>
#include "../drivers/all.h"
#include "../helper.h"
void p001_step1(void);
#endif /* P001_STEP_1_H */
@@ -1,4 +1,4 @@
#include "step2.h"
#include "p001_step2.h"
__attribute__((unused))
static const char *TAG = "step2";
@@ -91,7 +91,7 @@ static void new_puzzle(void) {
set_module_sseg_raw(display_map);
}
void step2(void) {
void p001_step2(void) {
KeypadKey key;
int solved_times = 0;
@@ -1,5 +1,5 @@
#ifndef STEP_2_H
#define STEP_2_H
#ifndef P001_STEP_2_H
#define P001_STEP_2_H
#include "../drivers/all.h"
#include "../helper.h"
@@ -7,6 +7,6 @@
#include <random>
#include <map>
void step2(void);
void p001_step2(void);
#endif /* STEP_2_H */
#endif /* P001_STEP_2_H */
@@ -1,4 +1,4 @@
#include "step3.h"
#include "p001_step3.h"
#define ONE_SECOND_TIME 90'000
#define THREE_SECOND_TIME 90'000
@@ -72,7 +72,7 @@ static bool one_second();
static bool three_second();
static bool six_second();
void step3(void) {
void p001_step3(void) {
SemaphoreHandle_t continue_sem = xSemaphoreCreateBinary();
if (continue_sem == nullptr) {
ESP_LOGE(TAG, "could not create semaphore");
+10
View File
@@ -0,0 +1,10 @@
#ifndef P001_STEP_3_H
#define P001_STEP_3_H
#include <random>
#include "../drivers/all.h"
#include "../helper.h"
void p001_step3(void);
#endif /* P001_STEP_3_H */
@@ -1,4 +1,4 @@
#include "step4.h"
#include "p001_step4.h"
__attribute__((unused))
static const char *TAG = "step4";
@@ -379,7 +379,7 @@ static void fail() {
}
}
void step4() {
void p001_step4() {
// TODO: extract to helper function
SemaphoreHandle_t continue_sem = xSemaphoreCreateBinary();
if (continue_sem == nullptr) {
@@ -1,5 +1,5 @@
#ifndef STEP_4_H
#define STEP_4_H
#ifndef P001_STEP_4_H
#define P001_STEP_4_H
#include <random>
#include "../drivers/all.h"
@@ -9,6 +9,6 @@
#define TETRIS_USE_FLASH_IMG
#define TETRIS_USE_FLASH_BG_IMG
void step4(void);
void p001_step4(void);
#endif /* STEP_4_H */
#endif /* P001_STEP_4_H */
@@ -1,4 +1,4 @@
#include "step5.h"
#include "p001_step5.h"
#define TIME_CLEAR 30'000
#define TIME_PLANK 40'000
@@ -178,7 +178,7 @@ bool submit_6(bool* buttons_cycling, bool button_turned_on, int led_off) {
return true;
}
void step5(void) {
void p001_step5(void) {
SemaphoreHandle_t continue_sem = xSemaphoreCreateBinary();
if (continue_sem == nullptr) {
ESP_LOGE(TAG, "could not create semaphore");
@@ -1,5 +1,5 @@
#ifndef STEP_5_H
#define STEP_5_H
#ifndef P001_STEP_5_H
#define P001_STEP_5_H
#include "../drivers/all.h"
#include "../helper.h"
@@ -11,6 +11,6 @@
#include <cmath>
#include <array>
void step5(void);
void p001_step5(void);
#endif /* STEP_5_H */
#endif /* P001_STEP_5_H */
@@ -1,11 +1,11 @@
#include "step6.h"
#include "p001_step6.h"
__attribute__((unused))
static const char *TAG = "step6";
static uint8_t cut_wires = 0;
void step6(void) {
void p001_step6(void) {
get_cut_wires();
clear_all_pressed_released();
+10
View File
@@ -0,0 +1,10 @@
#ifndef P001_STEP_6_H
#define P001_STEP_6_H
#include "wires_puzzle.h"
#include "../drivers/all.h"
#include "../helper.h"
void p001_step6(void);
#endif /* P001_STEP_6_H */
+10
View File
@@ -0,0 +1,10 @@
#include "p002_step1.h"
__attribute__((unused))
static const char *TAG = "step1";
void p002_step1(void) {
// TODO: implement step 1
}
+8
View File
@@ -0,0 +1,8 @@
#ifndef P002_STEP_1_H
#define P002_STEP_1_H
#include "../drivers/all.h"
void p002_step1(void);
#endif /* P002_STEP_1_H */
+8
View File
@@ -0,0 +1,8 @@
#include "p002_step2.h"
__attribute__((unused))
static const char *TAG = "step2";
void p002_step2(void) {
// TODO: implement step 2
}
+8
View File
@@ -0,0 +1,8 @@
#ifndef P002_STEP_2_H
#define P002_STEP_2_H
#include "../drivers/all.h"
void p002_step2(void);
#endif /* P002_STEP_2_H */
+8
View File
@@ -0,0 +1,8 @@
#include "p002_step3.h"
__attribute__((unused))
static const char *TAG = "step3";
void p002_step3(void) {
// TODO: implement step 3
}
+8
View File
@@ -0,0 +1,8 @@
#ifndef P002_STEP_3_H
#define P002_STEP_3_H
#include "../drivers/all.h"
void p002_step3(void);
#endif /* P002_STEP_3_H */
+8
View File
@@ -0,0 +1,8 @@
#include "p002_step4.h"
__attribute__((unused))
static const char *TAG = "step4";
void p002_step4(void) {
// TODO: implement step 4
}
+8
View File
@@ -0,0 +1,8 @@
#ifndef P002_STEP_4_H
#define P002_STEP_4_H
#include "../drivers/all.h"
void p002_step4(void);
#endif /* P002_STEP_4_H */
+8
View File
@@ -0,0 +1,8 @@
#include "p002_step5.h"
__attribute__((unused))
static const char *TAG = "step5";
void p002_step5(void) {
// TODO: implement step 5
}
+8
View File
@@ -0,0 +1,8 @@
#ifndef P002_STEP_5_H
#define P002_STEP_5_H
#include "../drivers/all.h"
void p002_step5(void);
#endif /* P002_STEP_5_H */
+8
View File
@@ -0,0 +1,8 @@
#include "p002_step6.h"
__attribute__((unused))
static const char *TAG = "step6";
void p002_step6(void) {
// TODO: implement step 6
}
+8
View File
@@ -0,0 +1,8 @@
#ifndef P002_STEP_6_H
#define P002_STEP_6_H
#include "../drivers/all.h"
void p002_step6(void);
#endif /* P002_STEP_6_H */
+24 -9
View File
@@ -5,6 +5,7 @@ static const char* TAG = "step0";
extern uint32_t initial_game_time;
extern uint32_t skip_to_step;
extern uint32_t puzzle;
static void set_game_time();
static void skip_to_step1() { skip_to_step = 1; }
@@ -13,12 +14,12 @@ static void skip_to_step3() { skip_to_step = 3; }
static void skip_to_step4() { skip_to_step = 4; }
static void skip_to_step5() { skip_to_step = 5; }
static void skip_to_step6() { skip_to_step = 6; }
static void try_step1() { clean_bomb(); step1(); }
static void try_step2() { clean_bomb(); step2(); }
static void try_step3() { clean_bomb(); step3(); }
static void try_step4() { clean_bomb(); step4(); }
static void try_step5() { clean_bomb(); step5(); }
static void try_step6() { clean_bomb(); step6(); }
static void try_step1() { clean_bomb(); p001_step1(); }
static void try_step2() { clean_bomb(); p001_step2(); }
static void try_step3() { clean_bomb(); p001_step3(); }
static void try_step4() { clean_bomb(); p001_step4(); }
static void try_step5() { clean_bomb(); p001_step5(); }
static void try_step6() { clean_bomb(); p001_step6(); }
static void issue_strike() { strike("Strike Issued"); }
static void flashbang();
static void debug_switches();
@@ -45,6 +46,13 @@ static void replay_last() {
start_playback();
}
static void do_p001() {
puzzle = 1;
}
static void do_p002() {
puzzle = 2;
}
void step0() {
led_set(IndicatorLED::LED_SPEAKER, LEDColor::LED_COLOR_BLUE);
@@ -59,15 +67,22 @@ void step0() {
StarCodeEntry star_codes[] = {
{
.code = "9819",
.display_text = "Diffusal Initiated",
.display_text = "Start P001",
.delay_us = 2'000'000,
.callback = nullptr,
.callback = do_p001,
.triggered_sem = continue_sem,
},
{
.code = "3141",
.display_text = "Start P002",
.delay_us = 2'000'000,
.callback = do_p002,
.triggered_sem = continue_sem,
},
{
.code = "59861",
.display_text = "Setup Wires",
.delay_us = 10'000'000,
.delay_us = 2'000'000,
.callback = setup_wires,
.triggered_sem = nullptr,
},
+6 -6
View File
@@ -4,12 +4,12 @@
#include "../drivers/all.h"
#include "setup_wires.h"
#include "step1.h"
#include "step2.h"
#include "step3.h"
#include "step4.h"
#include "step5.h"
#include "step6.h"
#include "p001_step1.h"
#include "p001_step2.h"
#include "p001_step3.h"
#include "p001_step4.h"
#include "p001_step5.h"
#include "p001_step6.h"
/// Wait for "*9819"
void step0(void);
-10
View File
@@ -1,10 +0,0 @@
#ifndef STEP_1_H
#define STEP_1_H
#include <random>
#include "../drivers/all.h"
#include "../helper.h"
void step1(void);
#endif /* STEP_1_H */
-10
View File
@@ -1,10 +0,0 @@
#ifndef STEP_3_H
#define STEP_3_H
#include <random>
#include "../drivers/all.h"
#include "../helper.h"
void step3(void);
#endif /* STEP_3_H */
-10
View File
@@ -1,10 +0,0 @@
#ifndef STEP_6_H
#define STEP_6_H
#include "wires_puzzle.h"
#include "../drivers/all.h"
#include "../helper.h"
void step6(void);
#endif /* STEP_6_H */