step 5 fixes
This commit is contained in:
parent
7b8e38844a
commit
23b7ffa7f7
@ -42,6 +42,126 @@ std::vector<int> unique_values(std::vector<int>& input_options, int num) {
|
||||
return output_vec;
|
||||
}
|
||||
|
||||
bool submit_0(int green_indicators) {
|
||||
uint8_t state = get_switch_state();
|
||||
uint8_t flipped_state = 0;
|
||||
flipped_state |= (state & 0b1) << 3;
|
||||
flipped_state |= (state & 0b10) << 1;
|
||||
flipped_state |= (state & 0b100) >> 1;
|
||||
flipped_state |= (state & 0b1000) >> 3;
|
||||
|
||||
if (flipped_state == green_indicators) {
|
||||
return true;
|
||||
} else {
|
||||
strike("Incorrect Switches");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool submit_1(int num_indicators, std::string pressed_keys, uint8_t starting_switch_state) {
|
||||
if (num_indicators < 18) {
|
||||
if (get_switch_state() == 0b1111) {
|
||||
if (pressed_keys == "") {
|
||||
return true;
|
||||
} else {
|
||||
strike("Incorrect keypad!");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
strike("Incorrect switches!");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (starting_switch_state == get_switch_state()) {
|
||||
if (pressed_keys == "ADCB") {
|
||||
return true;
|
||||
} else {
|
||||
strike("Incorrect keypad!");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
strike("Switches changed!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool submit_2(bool* lit_leds, int green_pressed, int blue_pressed, int fingerprint_pressed, std::string keypad_string) {
|
||||
uint8_t switch_state = get_switch_state() & 0b11;
|
||||
|
||||
bool rfid_correct = (lit_leds[0] && (green_pressed == 1)) || (!lit_leds[0] && (green_pressed == 0));
|
||||
bool lcd_correct = (lit_leds[1] && (blue_pressed == 1)) || (!lit_leds[1] && (blue_pressed == 0));
|
||||
bool speaker_correct = (lit_leds[2] && (fingerprint_pressed == 2)) || (!lit_leds[2] && (fingerprint_pressed == 0));
|
||||
bool keypad_correct = (lit_leds[3] && (keypad_string == "12")) || (!lit_leds[3] && (keypad_string == ""));
|
||||
bool tft_correct = (lit_leds[4] && (switch_state == 0b11)) || !lit_leds[4];
|
||||
|
||||
if (rfid_correct && lcd_correct && speaker_correct && keypad_correct && tft_correct) {
|
||||
return true;
|
||||
} else {
|
||||
strike("Incorrect state!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool submit_4(int* button_colors, int* switch_colors, uint8_t initial_switch_state) {
|
||||
if (button_colors[0] == 0 && button_colors[1] == 1 && button_colors[2] == 2 && button_colors[3] == 3) {
|
||||
uint8_t switch_state = get_switch_state();
|
||||
bool correct = true;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (switch_colors[i] == 2) {
|
||||
if ((((switch_state ^ initial_switch_state) >> i) & 0b1) != 1) {
|
||||
correct = false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (((switch_state >> i) & 0b1) != (switch_colors[i] & 0b1)) {
|
||||
correct = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (correct) {
|
||||
return true;
|
||||
}
|
||||
strike("Incorrect switches!");
|
||||
return false;
|
||||
} else {
|
||||
strike("Incorrect buttons!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool submit_5(std::array<int, 4> indicator_numbers, std::array<int, 4> buttons_pressed) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (buttons_pressed == indicator_numbers) {
|
||||
strike("Wrong button state!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t switch_state = get_switch_state();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (((switch_state >> i) & 0b1) == (indicator_numbers[i] & 0b1)) {
|
||||
strike("Wrong switch state!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool submit_6(bool* buttons_cycling, bool button_turned_on, int led_off) {
|
||||
for (int i = 0; i < sizeof(buttons_cycling); i++) {
|
||||
if ((buttons_cycling[i] == true) || (button_turned_on == false && led_off != -1)) {
|
||||
strike("Incorrect!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void step5(void) {
|
||||
StarCodeHandler star_codes[] = {
|
||||
{
|
||||
@ -82,11 +202,11 @@ void step5(void) {
|
||||
int solved_puzzles = 0;
|
||||
while (solved_puzzles < TIMES_TO_SOLVE) {
|
||||
lcd_set_cursor(&lcd, 1, 1);
|
||||
bool solved_correctly = false;
|
||||
|
||||
int puzzle = puzzle_dist(gen);
|
||||
// int puzzle = 6;
|
||||
|
||||
bool solved_correctly = false;
|
||||
switch (puzzle) {
|
||||
case 0: {
|
||||
lcd_print(&lcd, "Clear");
|
||||
@ -110,20 +230,16 @@ void step5(void) {
|
||||
ESP_ERROR_CHECK(led_strip_refresh(leds));
|
||||
|
||||
// wait for time
|
||||
KeypadKey key;
|
||||
while (1) {
|
||||
if (get_module_time() <= 0) {
|
||||
uint8_t state = get_switch_state();
|
||||
uint8_t flipped_state = 0;
|
||||
flipped_state |= (state & 0x01) << 3;
|
||||
flipped_state |= (state & 0x02) << 1;
|
||||
flipped_state |= (state & 0x04) >> 1;
|
||||
flipped_state |= (state & 0x08) >> 3;
|
||||
|
||||
if (flipped_state == green_indicators) {
|
||||
solved_puzzles++;
|
||||
} else {
|
||||
strike("Incorrect Switches");
|
||||
if (get_pressed_keypad(&key)) {
|
||||
if (char_of_keypad_key(key) == '#') {
|
||||
solved_correctly = submit_0(green_indicators);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (get_module_time() <= 0) {
|
||||
solved_correctly = submit_0(green_indicators);
|
||||
break;
|
||||
}
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
@ -145,111 +261,78 @@ void step5(void) {
|
||||
const int INDICATOR_BLUE[6] = {0, 10, 0, 0, 5, 5};
|
||||
|
||||
set_unique_leds_random_color(indicator_options, indicators_num, INDICATOR_RED, INDICATOR_BLUE, INDICATOR_GREEN);
|
||||
|
||||
ESP_ERROR_CHECK(led_strip_refresh(leds));
|
||||
// ESP_LOGI(TAG, "puzzle 1 LEDs set (%i leds)", indicators_num);
|
||||
|
||||
if (indicators_num < 18) {
|
||||
while (1) {
|
||||
if (get_module_time() <= 0) {
|
||||
if (get_switch_state() == 0b1111) {
|
||||
solved_puzzles++;
|
||||
// ESP_LOGI(TAG, "puzzle 1 solved (switches)!");
|
||||
} else {
|
||||
strike("Switch State Changed");
|
||||
}
|
||||
uint8_t starting_switch_state = get_switch_state();
|
||||
std::string pressed_keys;
|
||||
|
||||
KeypadKey key;
|
||||
while (1) {
|
||||
if (get_pressed_keypad(&key)) {
|
||||
char keypad_char = char_of_keypad_key(key);
|
||||
if (keypad_char == '#') {
|
||||
solved_correctly = submit_1(indicators_num, pressed_keys, starting_switch_state);
|
||||
break;
|
||||
}
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
}
|
||||
} else {
|
||||
uint8_t starting_switch_state = get_switch_state();
|
||||
KeypadKey key;
|
||||
std::string pressed_keys;
|
||||
while (1) {
|
||||
if (get_pressed_keypad(&key)) {
|
||||
} else {
|
||||
pressed_keys += char_of_keypad_key(key);
|
||||
// ESP_LOGI(TAG, "key %c pressed", char_of_keypad_key(key));
|
||||
}
|
||||
if (get_module_time() <= 0) {
|
||||
if (starting_switch_state == get_switch_state()) {
|
||||
if (pressed_keys == "ADCB") {
|
||||
solved_puzzles++;
|
||||
solved_correctly = true;
|
||||
// ESP_LOGI(TAG, "puzzle 1 solved (keypad)!");
|
||||
}
|
||||
} else {
|
||||
strike("Switches Changed!");
|
||||
}
|
||||
break;
|
||||
}
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
}
|
||||
if (get_module_time() <= 0) {
|
||||
solved_correctly = submit_1(indicators_num, pressed_keys, starting_switch_state);
|
||||
break;
|
||||
}
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
}
|
||||
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
set_module_time(25000);
|
||||
start_module_timer();
|
||||
|
||||
std::uniform_int_distribution<> lit_led_dist(0, 1);
|
||||
bool rfid_lit = lit_led_dist(gen);
|
||||
bool lcd_lit = lit_led_dist(gen);
|
||||
bool speaker_lit = lit_led_dist(gen);
|
||||
bool keypad_lit = lit_led_dist(gen);
|
||||
bool tft_lit = lit_led_dist(gen);
|
||||
std::map<int, int> idx_to_led_map = {
|
||||
{0, 10},
|
||||
{1, 12},
|
||||
{2, 9},
|
||||
{3, 11},
|
||||
{4, 6},
|
||||
};
|
||||
|
||||
if (rfid_lit) {
|
||||
int color = led_color_dist(gen);
|
||||
ESP_ERROR_CHECK(led_strip_set_pixel(leds, 10, INDICATOR_RED[color], INDICATOR_GREEN[color], INDICATOR_BLUE[color]));
|
||||
}
|
||||
if (lcd_lit) {
|
||||
int color = led_color_dist(gen);
|
||||
ESP_ERROR_CHECK(led_strip_set_pixel(leds, 12, INDICATOR_RED[color], INDICATOR_GREEN[color], INDICATOR_BLUE[color]));
|
||||
}
|
||||
if (speaker_lit) {
|
||||
int color = led_color_dist(gen);
|
||||
ESP_ERROR_CHECK(led_strip_set_pixel(leds, 9, INDICATOR_RED[color], INDICATOR_GREEN[color], INDICATOR_BLUE[color]));
|
||||
}
|
||||
if (keypad_lit) {
|
||||
int color = led_color_dist(gen);
|
||||
ESP_ERROR_CHECK(led_strip_set_pixel(leds, 11, INDICATOR_RED[color], INDICATOR_GREEN[color], INDICATOR_BLUE[color]));
|
||||
}
|
||||
if (tft_lit) {
|
||||
int color = led_color_dist(gen);
|
||||
ESP_ERROR_CHECK(led_strip_set_pixel(leds, 6, INDICATOR_RED[color], INDICATOR_GREEN[color], INDICATOR_BLUE[color]));
|
||||
std::uniform_int_distribution<> lit_led_dist(0, 1);
|
||||
|
||||
// rfid, lcd, speaker, keypad, tft
|
||||
bool lit_leds[5] = {static_cast<bool>(lit_led_dist(gen)), static_cast<bool>(lit_led_dist(gen)), static_cast<bool>(lit_led_dist(gen)), static_cast<bool>(lit_led_dist(gen)), static_cast<bool>(lit_led_dist(gen))};
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (lit_leds[i]) {
|
||||
int color = led_color_dist(gen);
|
||||
ESP_ERROR_CHECK(led_strip_set_pixel(leds, idx_to_led_map[i], INDICATOR_RED[color], INDICATOR_GREEN[color], INDICATOR_BLUE[color]));
|
||||
}
|
||||
}
|
||||
ESP_ERROR_CHECK(led_strip_refresh(leds));
|
||||
|
||||
int green_button_pressed = 0;
|
||||
// ESP_LOGI(TAG, "green pressed: %i", green_button_pressed);
|
||||
int blue_button_pressed = 0;
|
||||
int fingerprint_sensor_pressed = 0;
|
||||
std::string keypad_string;
|
||||
|
||||
ButtonKey button;
|
||||
KeypadKey key;
|
||||
SwitchKey switch1 = s1;
|
||||
SwitchKey switch2 = s2;
|
||||
ButtonKey button;
|
||||
|
||||
while (1) {
|
||||
// add if strike when wrong instead of at the end
|
||||
if (get_pressed_button(&button)) {
|
||||
uint8_t button_state = get_button_state();
|
||||
// ESP_LOGI(TAG, "Button pressed! (%i)", button_state());
|
||||
|
||||
if ((button_state & 0b1) == 0b1) {
|
||||
green_button_pressed++;
|
||||
if ((green_button_pressed > 1) || !rfid_lit) {
|
||||
if ((green_button_pressed > 1) || !lit_leds[0]) {
|
||||
strike("Too many times!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((button_state & 0b1000) == 0b1000) {
|
||||
blue_button_pressed++;
|
||||
if ((blue_button_pressed > 1) || !lcd_lit) {
|
||||
if ((blue_button_pressed > 1) || !lit_leds[1]) {
|
||||
strike("Too many times!");
|
||||
break;
|
||||
}
|
||||
@ -257,58 +340,22 @@ void step5(void) {
|
||||
}
|
||||
if (get_touch_pressed()) {
|
||||
fingerprint_sensor_pressed++;
|
||||
if ((fingerprint_sensor_pressed > 2) || !speaker_lit) {
|
||||
if ((fingerprint_sensor_pressed > 2) || !lit_leds[2]) {
|
||||
strike("Too many times!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (get_pressed_keypad(&key)) {
|
||||
bool wrong = false;
|
||||
keypad_string += char_of_keypad_key(key);
|
||||
switch (keypad_string.length()) {
|
||||
case 1: {
|
||||
if (keypad_string != "1") {
|
||||
strike("Incorrect Keypad!");
|
||||
wrong = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
if (keypad_string != "12") {
|
||||
strike("Incorrect Keypad!");
|
||||
wrong = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
strike("Incorrect Keypad!");
|
||||
wrong = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (wrong) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (get_flipped_up_switch(&switch1) || get_flipped_up_switch(&switch2)) {
|
||||
if (!tft_lit) {
|
||||
strike("Incorrect Switches");
|
||||
char keypad_char = char_of_keypad_key(key);
|
||||
if (keypad_char == '#') {
|
||||
solved_correctly = submit_2(lit_leds, green_button_pressed, blue_button_pressed, fingerprint_sensor_pressed, keypad_string);
|
||||
break;
|
||||
} else {
|
||||
keypad_string += char_of_keypad_key(key);
|
||||
}
|
||||
}
|
||||
if (get_module_time() <= 0) {
|
||||
bool rfid_correct = !(rfid_lit && (green_button_pressed != 1));
|
||||
bool lcd_correct = !(lcd_lit && (blue_button_pressed != 1));
|
||||
bool speaker_correct = !(speaker_lit && (fingerprint_sensor_pressed != 2));
|
||||
bool keypad_correct = !(keypad_lit && (keypad_string != "12"));
|
||||
bool tft_correct = !(tft_lit && ((get_switch_state() & 0b11) != 0b11));
|
||||
|
||||
if (rfid_correct && lcd_correct && speaker_correct && keypad_correct && tft_correct) {
|
||||
solved_puzzles++;
|
||||
solved_correctly = true;
|
||||
} else {
|
||||
strike("Incorrect state!");
|
||||
}
|
||||
solved_correctly = submit_2(lit_leds, green_button_pressed, blue_button_pressed, fingerprint_sensor_pressed, keypad_string);
|
||||
break;
|
||||
}
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
@ -334,7 +381,6 @@ void step5(void) {
|
||||
ESP_ERROR_CHECK(led_strip_set_pixel(leds, 6, COLOR_RED[tft_color], COLOR_GREEN[tft_color], COLOR_BLUE[tft_color]));
|
||||
ESP_ERROR_CHECK(led_strip_set_pixel(leds, 9, COLOR_RED[speaker_color], COLOR_GREEN[speaker_color], COLOR_BLUE[speaker_color]));
|
||||
ESP_ERROR_CHECK(led_strip_set_pixel(leds, 14, COLOR_RED[s3_color], COLOR_GREEN[s3_color], COLOR_BLUE[s3_color]));
|
||||
|
||||
ESP_ERROR_CHECK(led_strip_refresh(leds));
|
||||
|
||||
int buttons_pressed = 0;
|
||||
@ -360,7 +406,6 @@ void step5(void) {
|
||||
if ((button_state >> s3_color) != 0b1) {
|
||||
strike("Wrong button!");
|
||||
} else {
|
||||
solved_puzzles++;
|
||||
solved_correctly = true;
|
||||
}
|
||||
break;
|
||||
@ -373,9 +418,6 @@ void step5(void) {
|
||||
}
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
}
|
||||
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
@ -410,7 +452,7 @@ void step5(void) {
|
||||
ESP_ERROR_CHECK(led_strip_refresh(leds));
|
||||
|
||||
ButtonKey button;
|
||||
SwitchKey switch_key;
|
||||
KeypadKey key;
|
||||
uint8_t starting_switch_state = get_switch_state();
|
||||
|
||||
while (1) {
|
||||
@ -428,101 +470,14 @@ void step5(void) {
|
||||
|
||||
}
|
||||
ESP_ERROR_CHECK(led_strip_refresh(leds));
|
||||
|
||||
if (button_colors[0] == 0 && button_colors[1] == 1 && button_colors[2] == 2 && button_colors[3] == 3) {
|
||||
// check switch state
|
||||
uint8_t switch_state = get_switch_state();
|
||||
bool correct = true;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (switch_colors[i] == 2) {
|
||||
if ((((switch_state ^ starting_switch_state) >> i) & 0b1) != 1) {
|
||||
correct = false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (((switch_state >> i) & 0b1) != (switch_colors[i] & 0b1)) {
|
||||
correct = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (correct) {
|
||||
solved_puzzles++;
|
||||
solved_correctly = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (get_flipped_switch(&switch_key)) {
|
||||
if (button_colors[0] == 0 && button_colors[1] == 1 && button_colors[2] == 2 && button_colors[3] == 3) {
|
||||
// check switch state
|
||||
uint8_t switch_state = get_switch_state();
|
||||
bool correct = true;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (switch_colors[i] == 2) {
|
||||
if ((((switch_state ^ starting_switch_state) >> i) & 0b1) != 1) {
|
||||
correct = false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (((switch_state >> i) & 0b1) != (switch_colors[i] & 0b1)) {
|
||||
correct = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (correct) {
|
||||
solved_puzzles++;
|
||||
solved_correctly = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (get_module_time() <= 0) {
|
||||
// check button state
|
||||
if (button_colors[0] == 0 && button_colors[1] == 1 && button_colors[2] == 2 && button_colors[3] == 3) {
|
||||
// check switch state
|
||||
uint8_t switch_state = get_switch_state();
|
||||
bool correct = true;
|
||||
// ESP_LOGI(TAG, "starting switch state: %i, current switch state: %i", starting_switch_state, switch_state);
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (switch_colors[i] == 2) {
|
||||
// ESP_LOGI(TAG, "color yellow triggered: %i", (((switch_state ^ starting_switch_state) >> i) & 0b1));
|
||||
if ((((switch_state ^ starting_switch_state) >> i) & 0b1) != 1) {
|
||||
correct = false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// ESP_LOGI(TAG, "color green or red triggered: %i != %i", ((switch_state >> i) & 0b1), (switch_colors[i] & 0b1));
|
||||
if (((switch_state >> i) & 0b1) != (switch_colors[i] & 0b1)) {
|
||||
correct = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (correct) {
|
||||
solved_puzzles++;
|
||||
solved_correctly = true;
|
||||
} else {
|
||||
strike("Wrong switch state!");
|
||||
}
|
||||
} else {
|
||||
strike("Wrong button state!");
|
||||
}
|
||||
get_pressed_keypad(&key);
|
||||
if (get_module_time() <= 0 || char_of_keypad_key(key) == '#') {
|
||||
solved_correctly = submit_4(button_colors, switch_colors, starting_switch_state);
|
||||
break;
|
||||
}
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
@ -543,12 +498,11 @@ void step5(void) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
set_unique_leds(indicator_options, indicator_numbers[i], INDICATOR_RED[i], INDICATOR_GREEN[i], INDICATOR_BLUE[i]);
|
||||
}
|
||||
|
||||
ESP_ERROR_CHECK(led_strip_refresh(leds));
|
||||
|
||||
std::array<int, 4> buttons_pressed = {0, 0, 0, 0};
|
||||
|
||||
ButtonKey button;
|
||||
KeypadKey key;
|
||||
|
||||
while (1) {
|
||||
if (get_pressed_button(&button)) {
|
||||
@ -564,27 +518,9 @@ void step5(void) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (get_module_time() <= 0) {
|
||||
// check for correct button presses
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (buttons_pressed == indicator_numbers) {
|
||||
strike("Wrong button state!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t switch_state = get_switch_state();
|
||||
|
||||
// check for correct switch states
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (((switch_state >> i) & 0b1) == (indicator_numbers[i] & 0b1)) {
|
||||
strike("Wrong switch state!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
solved_puzzles++;
|
||||
solved_correctly = true;
|
||||
get_pressed_keypad(&key);
|
||||
if (get_module_time() <= 0 || char_of_keypad_key(key) == '#') {
|
||||
solved_correctly = submit_5(indicator_numbers, buttons_pressed);
|
||||
break;
|
||||
}
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
@ -628,6 +564,7 @@ void step5(void) {
|
||||
bool button_turned_on = false;
|
||||
|
||||
ButtonKey button;
|
||||
KeypadKey key;
|
||||
|
||||
std::uniform_int_distribution<> led_turn_on_dist(0, 3);
|
||||
while (1) {
|
||||
@ -637,7 +574,10 @@ void step5(void) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (((button_state >> i) & 0b1) == 0b1) {
|
||||
if (button_colors[i] == -1) {
|
||||
if (led_turn_on_dist(gen) == 0) {
|
||||
if (button_turned_on) {
|
||||
strike("Pressed after on!");
|
||||
break;
|
||||
} else if (led_turn_on_dist(gen) == 0) {
|
||||
button_turned_on = true;
|
||||
led_strip_set_pixel(leds, (20 - i), COLORS_RED[CORRECT_COLORS[i]], COLORS_GREEN[CORRECT_COLORS[i]], COLORS_BLUE[CORRECT_COLORS[i]]);
|
||||
led_strip_refresh(leds);
|
||||
@ -650,22 +590,8 @@ void step5(void) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool success = true;
|
||||
for (int i = 0; i < sizeof(buttons_cycling); i++) {
|
||||
if ((buttons_cycling[i] == true) || (button_turned_on == false && led_off != -1)) {
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (success) {
|
||||
solved_puzzles++;
|
||||
solved_correctly = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((xTaskGetTickCount() - lastCycleTime) >= pdMS_TO_TICKS(500)) {
|
||||
ESP_LOGI(TAG, "Cycling LEDs");
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (buttons_cycling[i]) {
|
||||
button_colors[i]++;
|
||||
@ -679,19 +605,9 @@ void step5(void) {
|
||||
|
||||
lastCycleTime = xTaskGetTickCount();
|
||||
}
|
||||
if (get_module_time() <= 0) {
|
||||
bool success = true;
|
||||
for (int i = 0; i < sizeof(buttons_cycling); i++) {
|
||||
if ((buttons_cycling[i] == true) || (button_turned_on == false && led_off != -1)) {
|
||||
strike("Ran out of time!");
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (success) {
|
||||
solved_puzzles++;
|
||||
solved_correctly = true;
|
||||
}
|
||||
get_pressed_keypad(&key);
|
||||
if (get_module_time() <= 0 || char_of_keypad_key(key) == '#') {
|
||||
solved_correctly = submit_6(buttons_cycling, button_turned_on, led_off);
|
||||
break;
|
||||
}
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
@ -775,9 +691,6 @@ void step5(void) {
|
||||
lcd_set_cursor(&lcd, 1, 2);
|
||||
lcd_print(&lcd, display_expression.c_str());
|
||||
|
||||
// ESP_LOGI(TAG, "Display expression: %s", display_expression.c_str());
|
||||
// ESP_LOGI(TAG, "Solved expression answer: %i", static_cast<int>(expression_answer));
|
||||
|
||||
// set LEDs
|
||||
|
||||
// blue, red, green, yellow
|
||||
@ -941,7 +854,6 @@ void step5(void) {
|
||||
|
||||
}
|
||||
if (!failed) {
|
||||
solved_puzzles++;
|
||||
solved_correctly = true;
|
||||
}
|
||||
}
|
||||
@ -950,6 +862,7 @@ void step5(void) {
|
||||
}
|
||||
stop_module_timer();
|
||||
if (solved_correctly) {
|
||||
solved_puzzles++;
|
||||
play_raw(MOUNT_POINT "/correct.pcm");
|
||||
vTaskDelay(pdMS_TO_TICKS(500));
|
||||
solved_correctly = false;
|
||||
|
||||
16
sdkconfig
16
sdkconfig
@ -1,6 +1,6 @@
|
||||
#
|
||||
# Automatically generated file. DO NOT EDIT.
|
||||
# Espressif IoT Development Framework (ESP-IDF) 5.2.1 Project Configuration
|
||||
# Espressif IoT Development Framework (ESP-IDF) 5.2.2 Project Configuration
|
||||
#
|
||||
CONFIG_SOC_MPU_MIN_REGION_SIZE=0x20000000
|
||||
CONFIG_SOC_MPU_REGIONS_MAX_NUM=8
|
||||
@ -331,6 +331,7 @@ CONFIG_SOC_WIFI_WAPI_SUPPORT=y
|
||||
CONFIG_SOC_WIFI_CSI_SUPPORT=y
|
||||
CONFIG_SOC_WIFI_MESH_SUPPORT=y
|
||||
CONFIG_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW=y
|
||||
CONFIG_SOC_WIFI_PHY_NEEDS_USB_WORKAROUND=y
|
||||
CONFIG_SOC_BLE_SUPPORTED=y
|
||||
CONFIG_SOC_BLE_MESH_SUPPORTED=y
|
||||
CONFIG_SOC_BLE_50_SUPPORTED=y
|
||||
@ -435,6 +436,7 @@ CONFIG_ESP_ROM_HAS_RETARGETABLE_LOCKING=y
|
||||
CONFIG_ESP_ROM_USB_OTG_NUM=3
|
||||
CONFIG_ESP_ROM_USB_SERIAL_DEVICE_NUM=4
|
||||
CONFIG_ESP_ROM_HAS_ERASE_0_REGION_BUG=y
|
||||
CONFIG_ESP_ROM_HAS_ENCRYPTED_WRITES_USING_LEGACY_DRV=y
|
||||
CONFIG_ESP_ROM_GET_CLK_FREQ=y
|
||||
CONFIG_ESP_ROM_HAS_HAL_WDT=y
|
||||
CONFIG_ESP_ROM_NEEDS_SWSETUP_WORKAROUND=y
|
||||
@ -557,6 +559,7 @@ CONFIG_APPTRACE_LOCK_ENABLE=y
|
||||
# Bluetooth
|
||||
#
|
||||
# CONFIG_BT_ENABLED is not set
|
||||
CONFIG_BT_ALARM_MAX_NUM=50
|
||||
# end of Bluetooth
|
||||
|
||||
#
|
||||
@ -744,7 +747,10 @@ CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=y
|
||||
#
|
||||
# GDB Stub
|
||||
#
|
||||
CONFIG_ESP_GDBSTUB_ENABLED=y
|
||||
# CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set
|
||||
CONFIG_ESP_GDBSTUB_SUPPORT_TASKS=y
|
||||
CONFIG_ESP_GDBSTUB_MAX_TASKS=32
|
||||
# end of GDB Stub
|
||||
|
||||
#
|
||||
@ -909,6 +915,7 @@ CONFIG_ESP_PHY_RF_CAL_PARTIAL=y
|
||||
# CONFIG_ESP_PHY_RF_CAL_NONE is not set
|
||||
# CONFIG_ESP_PHY_RF_CAL_FULL is not set
|
||||
CONFIG_ESP_PHY_CALIBRATION_MODE=0
|
||||
# CONFIG_ESP_PHY_PLL_TRACK_DEBUG is not set
|
||||
# end of PHY
|
||||
|
||||
#
|
||||
@ -1206,6 +1213,7 @@ CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0
|
||||
CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES=1
|
||||
# CONFIG_FREERTOS_USE_TRACE_FACILITY is not set
|
||||
# CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS is not set
|
||||
# CONFIG_FREERTOS_USE_APPLICATION_TASK_TAG is not set
|
||||
# end of Kernel
|
||||
|
||||
#
|
||||
@ -1493,7 +1501,9 @@ CONFIG_MBEDTLS_CMAC_C=y
|
||||
CONFIG_MBEDTLS_HARDWARE_AES=y
|
||||
CONFIG_MBEDTLS_AES_USE_INTERRUPT=y
|
||||
CONFIG_MBEDTLS_AES_INTERRUPT_LEVEL=0
|
||||
# CONFIG_MBEDTLS_GCM_SUPPORT_NON_AES_CIPHER is not set
|
||||
CONFIG_MBEDTLS_HARDWARE_MPI=y
|
||||
# CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI is not set
|
||||
CONFIG_MBEDTLS_MPI_USE_INTERRUPT=y
|
||||
CONFIG_MBEDTLS_MPI_INTERRUPT_LEVEL=0
|
||||
CONFIG_MBEDTLS_HARDWARE_SHA=y
|
||||
@ -1580,7 +1590,7 @@ CONFIG_MBEDTLS_ECP_FIXED_POINT_OPTIM=y
|
||||
# CONFIG_MBEDTLS_CHACHA20_C is not set
|
||||
# CONFIG_MBEDTLS_HKDF_C is not set
|
||||
# CONFIG_MBEDTLS_THREADING_C is not set
|
||||
# CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI is not set
|
||||
CONFIG_MBEDTLS_ERROR_STRINGS=y
|
||||
# end of mbedTLS
|
||||
|
||||
#
|
||||
@ -2225,6 +2235,8 @@ CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y
|
||||
# CONFIG_EVENT_LOOP_PROFILING is not set
|
||||
CONFIG_POST_EVENTS_FROM_ISR=y
|
||||
CONFIG_POST_EVENTS_FROM_IRAM_ISR=y
|
||||
CONFIG_GDBSTUB_SUPPORT_TASKS=y
|
||||
CONFIG_GDBSTUB_MAX_TASKS=32
|
||||
# CONFIG_OTA_ALLOW_HTTP is not set
|
||||
# CONFIG_ESP_SYSTEM_PD_FLASH is not set
|
||||
CONFIG_ESP32S3_DEEP_SLEEP_WAKEUP_DELAY=2000
|
||||
|
||||
Loading…
Reference in New Issue
Block a user