step 3 fixes

This commit is contained in:
Drake Marino 2024-08-11 20:57:50 -05:00
parent 7e036417ae
commit ec75439cc4

View File

@ -8,10 +8,6 @@ static std::uniform_int_distribution<> puzzle_dist(0, 7);
static std::uniform_int_distribution<> led_picker_dist(0, 20);
static std::uniform_int_distribution<> led_color_dist(0, 5);
static const int INDICATOR_RED[6] = {20, 0, 0, 10, 10, 5};
static const int INDICATOR_GREEN[6] = {0, 0, 10, 5, 0, 5};
static const int INDICATOR_BLUE[6] = {0, 10, 0, 0, 5, 5};
void set_unique_leds(std::vector<int>& input_options, const int num, const int r, const int g, const int b) {
for (int i = 0; i < num; i++) {
std::uniform_int_distribution<> led_option_dist(0, input_options.size() - 1);
@ -45,19 +41,43 @@ std::vector<int> unique_values(std::vector<int>& input_options, int num) {
}
void step3(void) {
set_module_time(20000);
start_module_timer();
// wait
while (get_module_time() > 0) {
vTaskDelay(10);
}
std::vector<int> all_leds;
for (int i = 0; i < 21; i++) {
all_leds.push_back(i);
}
const int INDICATOR_RED[6] = {20, 0, 0, 10, 10, 5};
const int INDICATOR_GREEN[6] = {0, 0, 10, 5, 0, 5};
const int INDICATOR_BLUE[6] = {0, 10, 0, 0, 5, 5};
static std::uniform_int_distribution<> led_number_dist(0, 21);
int last_cycle_tick = xTaskGetTickCount();
int scrambled_times = 0;
std::vector<int> led_options = all_leds;
while (scrambled_times < 5) {
if (xTaskGetTickCount() - last_cycle_tick > 50) {
set_unique_leds_random_color(led_options, led_number_dist(gen), INDICATOR_RED, INDICATOR_GREEN, INDICATOR_BLUE);
led_strip_refresh(leds);
last_cycle_tick = xTaskGetTickCount();
}
}
clean_bomb();
int solved_puzzles = 0;
while (solved_puzzles < 3) {
lcd_set_cursor(&lcd, 1, 1);
// int puzzle = puzzle_dist(gen);
int puzzle = 6;
int puzzle = puzzle_dist(gen);
// int puzzle = 6;
bool solved_correctly = false;
switch (puzzle) {
@ -379,20 +399,10 @@ void step3(void) {
int switch_colors[4] = {switch_color_dist(gen), switch_color_dist(gen), switch_color_dist(gen), switch_color_dist(gen)};
// int s1_color = switch_color_dist(gen);
// int s2_color = switch_color_dist(gen);
// int s3_color = switch_color_dist(gen);
// int s4_color = switch_color_dist(gen);
for (int i = 0; i < 4; i++) {
ESP_ERROR_CHECK(led_strip_set_pixel(leds, (16 - i), SWITCH_COLOR_RED[switch_colors[i]], SWITCH_COLOR_GREEN[switch_colors[i]], 0));
}
// ESP_ERROR_CHECK(led_strip_set_pixel(leds, 16, SWITCH_COLOR_RED[s1_color], SWITCH_COLOR_GREEN[s1_color], 0));
// ESP_ERROR_CHECK(led_strip_set_pixel(leds, 15, SWITCH_COLOR_RED[s2_color], SWITCH_COLOR_GREEN[s2_color], 0));
// ESP_ERROR_CHECK(led_strip_set_pixel(leds, 14, SWITCH_COLOR_RED[s3_color], SWITCH_COLOR_GREEN[s3_color], 0));
// ESP_ERROR_CHECK(led_strip_set_pixel(leds, 13, SWITCH_COLOR_RED[s4_color], SWITCH_COLOR_GREEN[s4_color], 0));
ESP_ERROR_CHECK(led_strip_refresh(leds));
ButtonKey button;