update star code references

This commit is contained in:
2025-07-12 18:16:15 -05:00
parent 1267d1356d
commit e27fb6f015
19 changed files with 299 additions and 356 deletions
+155 -134
View File
@@ -6,15 +6,13 @@ static const char* TAG = "step0";
extern uint32_t initial_game_time;
extern uint32_t skip_to_step;
static SemaphoreHandle_t continue_sem;
static void set_game_time();
static void skip_to_step1() { skip_to_step = 1; xSemaphoreGive(continue_sem, portMAX_DELAY); }
static void skip_to_step2() { skip_to_step = 2; xSemaphoreGive(continue_sem, portMAX_DELAY); }
static void skip_to_step3() { skip_to_step = 3; xSemaphoreGive(continue_sem, portMAX_DELAY); }
static void skip_to_step4() { skip_to_step = 4; xSemaphoreGive(continue_sem, portMAX_DELAY); }
static void skip_to_step5() { skip_to_step = 5; xSemaphoreGive(continue_sem, portMAX_DELAY); }
static void skip_to_step6() { skip_to_step = 6; xSemaphoreGive(continue_sem, portMAX_DELAY); }
static void skip_to_step1() { skip_to_step = 1; }
static void skip_to_step2() { skip_to_step = 2; }
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(); }
@@ -47,135 +45,157 @@ static void replay_last() {
start_playback();
}
static const StarCodeEntry star_codes[] = {
{
.code = "9819",
.display_text = "Defusal Initiated",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = nullptr,
},
{
.code = "59862",
.display_text = "Set Up Wires",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = setup_wires,
},
{
.code = "59862",
.display_text = "Set Game Time",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = set_game_time,
},
{
.code = "59863",
.display_text = "Debug Switches",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = debug_switches,
},
{
.code = "59864",
.display_text = "Battery Stats",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = battery_stats,
},
{
.code = "59871",
.display_text = "Try Step 1",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = try_step1,
},
{
.code = "59872",
.display_text = "Try Step 2",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = try_step2,
},
{
.code = "59873",
.display_text = "Try Step 3",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = try_step3,
},
{
.code = "59874",
.display_text = "Try Step 4",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = try_step4,
},
{
.code = "59875",
.display_text = "Try Step 5",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = try_step5,
},
{
.code = "59876",
.display_text = "Try Step 6",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = try_step6,
},
{
.code = "59881",
.display_text = "Skip To Step 1",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = skip_to_step1,
},
{
.code = "59882",
.display_text = "Skip To Step 2",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = skip_to_step2,
},
{
.code = "59883",
.display_text = "Skip To Step 3",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = skip_to_step3,
},
{
.code = "59884",
.display_text = "Skip To Step 4",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = skip_to_step4,
},
{
.code = "59885",
.display_text = "Skip To Step 5",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = skip_to_step5,
},
{
.code = "59886",
.display_text = "Skip To Step 6",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = skip_to_step6,
},
{
.code = "1111",
.display_text = "Issue Strike",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = issue_strike,
},
{
.code = "1112",
.display_text = "????",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = flashbang,
},
{
.code = "1113",
.display_text = "replay_last",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = replay_last,
},
};
const static size_t len = sizeof(star_codes)/sizeof(star_codes[0]);
void step0() {
uint8_t _byte;
continue_sem = xSemaphoreCreateBinary();
StarCodeEntry star_codes[] = {
{
.code = "9819",
.display_text = "Defusal Initiated",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = nullptr,
.triggered_sem = nullptr,
},
{
.code = "59862",
.display_text = "Set Up Wires",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = setup_wires,
.triggered_sem = nullptr,
},
{
.code = "59862",
.display_text = "Set Game Time",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = set_game_time,
.triggered_sem = nullptr,
},
{
.code = "59863",
.display_text = "Debug Switches",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = debug_switches,
.triggered_sem = nullptr,
},
{
.code = "59864",
.display_text = "Battery Stats",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = battery_stats,
.triggered_sem = nullptr,
},
{
.code = "59871",
.display_text = "Try Step 1",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = try_step1,
.triggered_sem = nullptr,
},
{
.code = "59872",
.display_text = "Try Step 2",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = try_step2,
.triggered_sem = nullptr,
},
{
.code = "59873",
.display_text = "Try Step 3",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = try_step3,
.triggered_sem = nullptr,
},
{
.code = "59874",
.display_text = "Try Step 4",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = try_step4,
.triggered_sem = nullptr,
},
{
.code = "59875",
.display_text = "Try Step 5",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = try_step5,
.triggered_sem = nullptr,
},
{
.code = "59876",
.display_text = "Try Step 6",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = try_step6,
.triggered_sem = nullptr,
},
{
.code = "59881",
.display_text = "Skip To Step 1",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = skip_to_step1,
.triggered_sem = nullptr,
},
{
.code = "59882",
.display_text = "Skip To Step 2",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = skip_to_step2,
.triggered_sem = nullptr,
},
{
.code = "59883",
.display_text = "Skip To Step 3",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = skip_to_step3,
.triggered_sem = nullptr,
},
{
.code = "59884",
.display_text = "Skip To Step 4",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = skip_to_step4,
.triggered_sem = nullptr,
},
{
.code = "59885",
.display_text = "Skip To Step 5",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = skip_to_step5,
.triggered_sem = nullptr,
},
{
.code = "59886",
.display_text = "Skip To Step 6",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = skip_to_step6,
.triggered_sem = nullptr,
},
{
.code = "1111",
.display_text = "Issue Strike",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = issue_strike,
.triggered_sem = nullptr,
},
{
.code = "1112",
.display_text = "????",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = flashbang,
.triggered_sem = nullptr,
},
{
.code = "1113",
.display_text = "replay_last",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = replay_last,
.triggered_sem = nullptr,
},
};
size_t len = sizeof(star_codes)/sizeof(star_codes[0]);
SemaphoreHandle_t continue_sem = xSemaphoreCreateBinary();
if (continue_sem == nullptr) {
ESP_FAIL("could not create semaphore");
ESP_LOGE(TAG, "could not create semaphore");
return;
}
led_set(IndicatorLED::LED_SPEAKER, LEDColor::LED_COLOR_BLUE);
@@ -184,6 +204,7 @@ void step0() {
add_star_codes(star_codes, len);
xSemaphoreTake(continue_sem, portMAX_DELAY);
rm_star_codes(star_codes, len);
vSemaphoreDelete(continue_sem);
}
static const int CURSOR_POS_MAP[5] = {1, 3, 4, 6, 7};
+1
View File
@@ -3,6 +3,7 @@
#include "../drivers/all.h"
#include "setup_wires.h"
#include "step1.h"
#include "step2.h"
#include "step3.h"
+3 -4
View File
@@ -206,18 +206,17 @@ static bool play_part(uint32_t time) {
set_module_time(time);
lcd_clear();
lcd_set_cursor_pos(1, 1);
switch (part) {
case 0:
lcd_print("COLOR");
lcd_print(1, 1, "COLOR");
led_set(IndicatorLED::LED_LCD, LEDColor::LED_COLOR_PINK);
break;
case 1:
lcd_print("NUMBER");
lcd_print(1, 1, "NUMBER");
led_set(IndicatorLED::LED_LCD, LEDColor::LED_COLOR_BLUE);
break;
case 2:
lcd_print("SWITCH");
lcd_print(1, 1, "SWITCH");
led_set(IndicatorLED::LED_LCD, LEDColor::LED_COLOR_YELLOW);
break;
}
+17 -9
View File
@@ -73,16 +73,24 @@ static bool three_second();
static bool six_second();
void step3(void) {
StarCodeHandler star_codes[] = {
{
.code = "*1642",
.display_text = "Starting...",
.should_exit = true,
.callback = nullptr,
},
SemaphoreHandle_t continue_sem = xSemaphoreCreateBinary();
if (continue_sem == nullptr) {
ESP_LOGE(TAG, "could not create semaphore");
return;
}
StarCodeEntry start_code = {
.code = "1642",
.display_text = "Starting...",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = nullptr,
.triggered_sem = continue_sem,
};
int len = sizeof(star_codes)/sizeof(StarCodeHandler);
do_star_codes(star_codes, len);
add_star_code(start_code);
xSemaphoreTake(continue_sem, portMAX_DELAY);
rm_star_code(start_code.code);
vSemaphoreDelete(continue_sem);
while (times < TIMES_TO_COMPLETE) {
tone = tone_dist(gen);
+17 -4
View File
@@ -380,16 +380,29 @@ static void fail() {
}
void step4() {
StarCodeHandler star_code = {
.code = "*3850",
// TODO: extract to helper function
SemaphoreHandle_t continue_sem = xSemaphoreCreateBinary();
if (continue_sem == nullptr) {
ESP_LOGE(TAG, "could not create semaphore");
}
StarCodeEntry start_code = {
.code = "3850",
.display_text = "Starting...",
.should_exit = true,
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = nullptr,
.triggered_sem = continue_sem,
};
do_star_codes(&star_code, 1);
add_star_code(start_code);
xSemaphoreTake(continue_sem, portMAX_DELAY);
rm_star_code(start_code.code);
vSemaphoreDelete(continue_sem);
init_screen();
while (!play_game(4*60*1000, 2)) fail();
// TODO: create constants for common assets, and put them in a folder.
play_clip_wav(MOUNT_POINT "/partdone.wav", true, false, 0, 0);
complete();
while (!play_game(4*60*1000, 4)) fail();
+1
View File
@@ -4,6 +4,7 @@
#include <random>
#include "../drivers/all.h"
#include "../helper.h"
#include "esp_log.h"
#define TETRIS_USE_FLASH_IMG
#define TETRIS_USE_FLASH_BG_IMG
+22 -13
View File
@@ -179,13 +179,23 @@ bool submit_6(bool* buttons_cycling, bool button_turned_on, int led_off) {
}
void step5(void) {
StarCodeEntry star_code = {
.code = "*2648",
SemaphoreHandle_t continue_sem = xSemaphoreCreateBinary();
if (continue_sem == nullptr) {
ESP_LOGE(TAG, "could not create semaphore");
}
StarCodeEntry start_code = {
.code = "2648",
.display_text = "Starting...",
.delay_ticks = pdMS_TO_TICKS(2000),
.callback = nullptr, // TODO
.callback = nullptr,
.triggered_sem = continue_sem,
};
add_star_code(star_code);
add_star_code(start_code);
xSemaphoreTake(continue_sem, portMAX_DELAY);
rm_star_code(start_code.code);
vSemaphoreDelete(continue_sem);
std::vector<int> all_leds;
@@ -219,14 +229,13 @@ void step5(void) {
clean_bomb();
int solved_puzzles = 0;
while (solved_puzzles < TIMES_TO_SOLVE) {
lcd_set_cursor_pos(1, 1);
bool solved_correctly = false;
int puzzle = puzzle_dist(gen);
switch (puzzle) {
case 0: {
lcd_print("Clear");
lcd_print(1, 1, "Clear");
set_module_time(TIME_CLEAR);
start_module_timer();
@@ -261,7 +270,7 @@ void step5(void) {
break;
}
case 1: {
lcd_print("Blank");
lcd_print(1, 1, "Blank");
set_module_time(TIME_BLANK);
start_module_timer();
@@ -375,7 +384,7 @@ void step5(void) {
break;
}
case 3: {
lcd_print("Nothing");
lcd_print(1, 1, "Nothing");
set_module_time(TIME_NOTHING);
start_module_timer();
@@ -434,7 +443,7 @@ void step5(void) {
break;
}
case 4: {
lcd_print("Blink");
lcd_print(1, 1, "Blink");
set_module_time(TIME_BLINK);
start_module_timer();
@@ -498,7 +507,7 @@ void step5(void) {
break;
}
case 5: {
lcd_print("Ummm");
lcd_print(1, 1, "Ummm");
set_module_time(TIME_UMMM);
start_module_timer();
@@ -554,7 +563,7 @@ void step5(void) {
break;
}
case 6: {
lcd_print("Plank");
lcd_print(1, 1, "Plank");
set_module_time(TIME_PLANK);
start_module_timer();
@@ -647,7 +656,7 @@ void step5(void) {
break;
}
case 7: {
lcd_print("What");
lcd_print(1, 1, "What");
set_module_time(TIME_WHAT);
start_module_timer();
@@ -795,7 +804,7 @@ void step5(void) {
break;
}
case 8: {
lcd_print("Plink");
lcd_print(1, 1, "Plink");
set_module_time(TIME_PLINK);
start_module_timer();