diff --git a/main/drivers/all.h b/main/drivers/all.h index 1ad20bf..863a28e 100644 --- a/main/drivers/all.h +++ b/main/drivers/all.h @@ -1,21 +1,14 @@ #ifndef ALL_H #define ALL_H -// #include "driver/uart.h" -// #include "driver/i2c.h" -// #include "drivers/tft.h" -// #include "drivers/wires.h" -// #include "drivers/sd.h" -// #include "drivers/char_lcd.h" -// #include "drivers/leds.h" -// #include "drivers/power.h" - - #include "char_lcd.h" #include "bottom_half.h" #include "sd.h" #include "speaker.h" #include "game_timer.h" +#include "drivers/tft.h" +#include "drivers/leds.h" +#include "drivers/power.h" void init_drivers(); diff --git a/main/drivers/leds.cpp b/main/drivers/leds.cpp index 9be368e..a345196 100644 --- a/main/drivers/leds.cpp +++ b/main/drivers/leds.cpp @@ -1,4 +1,6 @@ #include "leds.h" +#include "led_strip.h" +#include static const char* TAG = "leds"; @@ -25,8 +27,12 @@ void init_leds() { ESP_LOGI(TAG, "LEDs initialized!"); } -void leds_set(IndicatorLED led, uint8_t r, uint8_t g, uint8_t b) { - led_strip_set_pixel(leds, i, i, LED_COUNT-i, 0) +void led_set(uint32_t led, uint8_t r, uint8_t g, uint8_t b) { + led_strip_set_pixel(leds, led, r, g, b); +} + +void led_set(uint32_t led, uint32_t color) { + led_set(led, (color >> 16) & 0xFF, (color >> 8) & 0xFF, color & 0xFF); } void leds_flush() { diff --git a/main/drivers/leds.h b/main/drivers/leds.h index 09f9ea3..b0c6868 100644 --- a/main/drivers/leds.h +++ b/main/drivers/leds.h @@ -1,36 +1,55 @@ #ifndef LEDS_H #define LEDS_H -#include "led_strip.h" +#include #define LED_COUNT 21 #define NEOPIXEL_PIN GPIO_NUM_7 // 10MHz resolution, 1 tick = 0.1us (led strip needs a high resolution) #define LED_STRIP_RMT_RES_HZ (10 * 1000 * 1000) -typedef enum { - led_shape1 = 0, - led_shape2 = 1, - led_shape3 = 2, - led_shape4 = 3, - led_module_sseg = 4, - led_game_sseg = 5, - led_tft = 6, - led_mic = 7, - led_ir_led = 8, - led_speaker = 9, - led_rfid = 10, - led_keypad = 11, - led_char_lcd = 12, - led_switch4 = 13, - led_switch3 = 14, - led_switch2 = 15, - led_switch1 = 16, - led_button4 = 17, - led_button3 = 18, - led_button2 = 19, - led_button1 = 20, -} IndicatorLED; +enum LEDColor: uint32_t { + LED_COLOR_OFF = 0x00'00'00, + LED_COLOR_RED = 0x17'00'00, + LED_COLOR_RED_STRONG = 0xFF'00'00, + LED_COLOR_ORANGE = 0x17'02'00, + LED_COLOR_ORANGE_STRONG = 0xFF'20'00, + LED_COLOR_YELLOW = 0x07'07'00, + LED_COLOR_YELLOW_STRONG = 0xFF'FF'00, + LED_COLOR_GREEN = 0x00'07'00, + LED_COLOR_GREEN_STRONG = 0x00'FF'00, + LED_COLOR_BLUE = 0x00'00'17, + LED_COLOR_BLUE_STRONG = 0x00'00'FF, + LED_COLOR_PINK = 0x10'00'04, + LED_COLOR_PINK_STRONG = 0xFF'00'80, + LED_COLOR_WHITE = 0x04'04'04, + LED_COLOR_WHITE_STRONG = 0xFF'FF'FF, +}; + +enum IndicatorLED { + LED_SHAPE1 = 0u, + LED_SHAPE2 = 1u, + LED_SHAPE3 = 2u, + LED_SHAPE4 = 3u, + LED_MODULE_SSEG = 4u, + LED_GAME_SSEG = 5u, + LED_TFT = 6u, + LED_MIC = 7u, + LED_IR_LED = 8u, + LED_SPEAKER = 9u, + LED_RFID = 10u, + LED_KEYPAD = 11u, + LED_LCD = 12u, + LED_S4 = 13u, + LED_S3 = 14u, + LED_S2 = 15u, + LED_S1 = 16u, + LED_B4 = 17u, + LED_B3 = 18u, + LED_B2 = 19u, + LED_B1 = 20u, + LED_MAX = 20u, +}; /// @brief Initializes the indicator LEDs void init_leds(); @@ -38,7 +57,12 @@ void init_leds(); /// Sets the color of an LED. /// /// Call `flush_leds()` to send the data to the LEDs. -void leds_set(IndicatorLED led, uint8_t r, uint8_t g, uint8_t b); +void led_set(uint32_t led, uint32_t color); + +/// Sets the color of an LED with rgb. +/// +/// Call `flush_leds()` to send the data to the LEDs. +void led_set(uint32_t led, uint8_t r, uint8_t g, uint8_t b); /// Outputs the data to the leds. void leds_flush(); diff --git a/main/drivers/power.cpp b/main/drivers/power.cpp index 41f401e..09574dd 100644 --- a/main/drivers/power.cpp +++ b/main/drivers/power.cpp @@ -37,7 +37,7 @@ void bat_monitor_task(void* arg) { } void init_power_board() { - ESP_LOGI(TAG, "Initializing power board...") + ESP_LOGI(TAG, "Initializing power board..."); if (!lipo.begin()) { ESP_LOGE(TAG, "Failed to init communication with the battery gas guage"); diff --git a/main/helper.cpp b/main/helper.cpp index fc9f22b..318c0d5 100644 --- a/main/helper.cpp +++ b/main/helper.cpp @@ -7,8 +7,8 @@ void clean_bomb(void) { clear_wires_pressed_released_cut(); // clear leds - led_strip_clear(leds); - led_strip_refresh(leds); + leds_clear(); + leds_flush(); // clear module timer stop_module_timer(); diff --git a/main/steps/step0.cpp b/main/steps/step0.cpp index 48b8abd..ed8e259 100644 --- a/main/steps/step0.cpp +++ b/main/steps/step0.cpp @@ -5,22 +5,23 @@ static const char* TAG = "step0"; extern uint32_t initial_game_time; extern uint32_t skip_to_step; -static void set_game_time(void); -static void skip_to_step1(void) { skip_to_step = 1; } -static void skip_to_step2(void) { skip_to_step = 2; } -static void skip_to_step3(void) { skip_to_step = 3; } -static void skip_to_step4(void) { skip_to_step = 4; } -static void skip_to_step5(void) { skip_to_step = 5; } -static void skip_to_step6(void) { skip_to_step = 6; } -static void try_step1(void) { clean_bomb(); step1(); } -static void try_step2(void) { clean_bomb(); step2(); } -static void try_step3(void) { clean_bomb(); step3(); } -static void try_step4(void) { clean_bomb(); step4(); } -static void try_step5(void) { clean_bomb(); step5(); } -static void try_step6(void) { clean_bomb(); step6(); } -static void issue_strike(void) { strike("Strike Issued"); } -static void debug_switches(void); -static void battery_stats(void) { +static void set_game_time(); +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(); } +static void try_step4() { clean_bomb(); step4(); } +static void try_step5() { clean_bomb(); step5(); } +static void try_step6() { clean_bomb(); step6(); } +static void issue_strike() { strike("Strike Issued"); } +static void flashbang(); +static void debug_switches(); +static void battery_stats() { BaseType_t xReturned; TaskHandle_t xHandle = NULL; xReturned = xTaskCreate(bat_monitor_task, "bat_monitor", 4096, NULL, 5, &xHandle); @@ -34,9 +35,10 @@ static void battery_stats(void) { } /// Wait for "*9819" -void step0(void) { - led_strip_set_pixel(leds, Led::speaker, 0, 0, 20); - led_strip_refresh(leds); +void step0() { + led_set(IndicatorLED::LED_SPEAKER, LED_COLOR_BLUE); + leds_flush(); + StarCodeHandler star_codes[] = { { .code = "*9819", @@ -146,6 +148,12 @@ void step0(void) { .should_exit = false, .callback = issue_strike, }, + { + .code = "*1112", + .display_text = "????", + .should_exit = false, + .callback = flashbang, + }, }; int len = sizeof(star_codes)/sizeof(StarCodeHandler); do_star_codes(star_codes, len); @@ -163,7 +171,7 @@ static void _update_display(uint8_t* digits, uint8_t cursor_pos) { lcd_set_cursor_pos(mapped_cursor_pos, 1); } -static void set_game_time(void) { +static void set_game_time() { uint8_t hours = (initial_game_time / (1000*60*60)) % 10; uint8_t minutes = (initial_game_time / (1000*60)) % 60; uint8_t seconds = (initial_game_time / (1000)) % 60; @@ -195,8 +203,8 @@ static void set_game_time(void) { } clean_bomb(); - led_strip_set_pixel(leds, Led::speaker, 0, 0, 20); - led_strip_refresh(leds); + led_set(IndicatorLED::LED_SPEAKER, 0, 0, 20); + leds_flush(); return; } else { int just_pressed = -1; @@ -266,7 +274,7 @@ static void print_4bin_rev(char* out_str, uint8_t n) { out_str[4] = '\0'; } -static void debug_switches(void) { +static void debug_switches() { clean_bomb(); uint8_t switch_state = 0xFF; uint8_t switch_touch_state = 0xFF; @@ -346,3 +354,18 @@ static void debug_switches(void) { } } +static void flashbang() { + play_clip_wav(MOUNT_POINT "/flash.wav", true, false, 1, 0); + vTaskDelay(pdMS_TO_TICKS(4000)); + + for (int bright = 255; bright >= 0; bright -= 2) { + for (int led_idx = 0; led_idx < IndicatorLED::LED_MAX; led_idx++) { + led_set(led_idx, bright, bright, bright); + } + leds_flush(); + vTaskDelay(pdMS_TO_TICKS(10)); + } + leds_clear(); + leds_flush(); +} + diff --git a/main/steps/step1.cpp b/main/steps/step1.cpp index 87b1097..e7421d6 100644 --- a/main/steps/step1.cpp +++ b/main/steps/step1.cpp @@ -115,9 +115,9 @@ static void generate_switch_leds(void) { for (int i = 0; i < 4; i++) { uint8_t* rgb = NEOPIXEL_COLORS[switch_leds[i]]; - led_strip_set_pixel(leds, Led::switch1 - i, rgb[0], rgb[1], rgb[2]); + led_set(IndicatorLED::LED_S1 - i, rgb[0], rgb[1], rgb[2]); } - led_strip_refresh(leds); + leds_flush(); } static void set_text_and_color(const char* text_str, int color) { @@ -208,18 +208,18 @@ static bool play_part(uint32_t time) { switch (part) { case 0: lcd_print("COLOR"); - led_strip_set_pixel(leds, Led::char_lcd, 20, 0, 20); + led_set(IndicatorLED::LED_LCD, 20, 0, 20); break; case 1: lcd_print("NUMBER"); - led_strip_set_pixel(leds, Led::char_lcd, 0, 0, 30); + led_set(IndicatorLED::LED_LCD, 0, 0, 30); break; case 2: lcd_print("SWITCH"); - led_strip_set_pixel(leds, Led::char_lcd, 20, 20, 0); + led_set(IndicatorLED::LED_LCD, 20, 20, 0); break; } - led_strip_refresh(leds); + leds_flush(); int times = 0; int correct = generate_part(); diff --git a/main/steps/step2.cpp b/main/steps/step2.cpp index 1dbde16..5dc1eac 100644 --- a/main/steps/step2.cpp +++ b/main/steps/step2.cpp @@ -48,8 +48,8 @@ std::map number_map = { static void new_puzzle(void) { // scramble lights for (int i = 0; i < 5; i++) { - led_strip_set_pixel(leds, 9, INDICATOR_RED[map_dist(gen)], INDICATOR_GREEN[map_dist(gen)], INDICATOR_BLUE[map_dist(gen)]); - led_strip_refresh(leds); + led_set(IndicatorLED::LED_SPEAKER, INDICATOR_RED[map_dist(gen)], INDICATOR_GREEN[map_dist(gen)], INDICATOR_BLUE[map_dist(gen)]); + leds_flush(); uint8_t random_segments[4] = {0, 0, 0, 0}; for (int i = 0; i < 4; i++) { @@ -72,8 +72,8 @@ static void new_puzzle(void) { } // ESP_LOGI(TAG, "Chosen Map: %i", chosen_map); - ESP_ERROR_CHECK(led_strip_set_pixel(leds, 9, INDICATOR_RED[chosen_map], INDICATOR_GREEN[chosen_map], INDICATOR_BLUE[chosen_map])); - ESP_ERROR_CHECK(led_strip_refresh(leds)); + led_set(IndicatorLED::LED_SPEAKER, INDICATOR_RED[chosen_map], INDICATOR_GREEN[chosen_map], INDICATOR_BLUE[chosen_map]); + leds_flush(); for (int i = 0; i < 8; i++) { bool bit = (answer_sseg >> i) & 1; diff --git a/main/steps/step3.cpp b/main/steps/step3.cpp index f128d46..876c027 100644 --- a/main/steps/step3.cpp +++ b/main/steps/step3.cpp @@ -140,9 +140,9 @@ static void write_leds() { // update all the leds for (int i = 0; i < LED_COUNT; i++) { auto colors = NEOPIXEL_COLORS[indicator_led_idxs[i]]; - led_strip_set_pixel(leds, i, colors[0], colors[1], colors[2]); + led_set(i, colors[0], colors[1], colors[2]); } - led_strip_refresh(leds); + leds_flush(); } static uint8_t four_bit_flag(bool b0, bool b1, bool b2, bool b3) { @@ -212,7 +212,7 @@ static bool one_second() { start_module_timer(); rng_leds(); - int speaker_color = indicator_led_idxs[Led::speaker]; + int speaker_color = indicator_led_idxs[IndicatorLED::LED_SPEAKER]; int lcd_string_idx = lcd_string_dist(gen); bool was_high = (tone / 3) == 1; write_leds(); @@ -238,10 +238,10 @@ static bool one_second() { uint8_t correct_button_mask = 0b1011; uint8_t correct_buttons = four_bit_flag( - indicator_led_idxs[Led::char_lcd] != 6, // green + indicator_led_idxs[IndicatorLED::LED_LCD] != 6, // green red_led_count > blue_led_count, // red 0, // yellow UNCHECKED - indicator_led_idxs[Led::rfid] == 4 || indicator_led_idxs[Led::rfid] == 6 // blue + indicator_led_idxs[IndicatorLED::LED_RFID] == 4 || indicator_led_idxs[IndicatorLED::LED_RFID] == 6 // blue ); debug_correct_values(correct_buttons, correct_button_mask, correct_switches); @@ -346,7 +346,7 @@ static bool six_second() { bool was_high = (tone / 3) == 1; - bool second_switch_correct_state = (indicator_led_idxs[Led::switch2] == 0) || (indicator_led_idxs[Led::switch2] == 6); + bool second_switch_correct_state = (indicator_led_idxs[IndicatorLED::LED_S2] == 0) || (indicator_led_idxs[IndicatorLED::LED_S2] == 6); second_switch_correct_state = second_switch_correct_state || was_high; rng_leds(); @@ -363,7 +363,7 @@ static bool six_second() { } int purple_led_on_bottom_count = 0; - for (int i = Led::rfid; i < LED_COUNT; i++) { + for (int i = IndicatorLED::LED_RFID; i < LED_COUNT; i++) { if (indicator_led_idxs[i] == 5) { purple_led_on_bottom_count++; } @@ -378,7 +378,7 @@ static bool six_second() { uint8_t correct_button_mask = 0b1101; uint8_t correct_buttons = four_bit_flag( - (!was_high) || (green_led_count >= 2) || indicator_led_idxs[Led::keypad] == 4, // green + (!was_high) || (green_led_count >= 2) || indicator_led_idxs[IndicatorLED::LED_KEYPAD] == 4, // green 0, // red UNCHECKED blue_led_count >= 3, // yellow contains_coconut // blue diff --git a/main/steps/step5.cpp b/main/steps/step5.cpp index 165d46e..36d0cdc 100644 --- a/main/steps/step5.cpp +++ b/main/steps/step5.cpp @@ -25,7 +25,7 @@ void set_unique_leds(std::vector& input_options, const int num, const int r for (int i = 0; i < num; i++) { std::uniform_int_distribution<> led_option_dist(0, input_options.size() - 1); int led = led_option_dist(gen); - ESP_ERROR_CHECK(led_strip_set_pixel(leds, input_options[led], r, g, b)); + led_set(input_options[led], r, g, b); input_options.erase(input_options.begin() + led); } } @@ -37,7 +37,7 @@ void set_unique_leds_random_color(std::vector& input_options, const int num std::uniform_int_distribution<> led_color_dist(0, sizeof(r) - 1); int color = led_color_dist(gen); - ESP_ERROR_CHECK(led_strip_set_pixel(leds, input_options[led], r[color], g[color], b[color])); + led_set(input_options[led], r[color], g[color], b[color]); input_options.erase(input_options.begin() + led); } } @@ -208,7 +208,7 @@ void step5(void) { clean_bomb(); std::vector led_options = all_leds; set_unique_leds_random_color(led_options, led_number_dist(gen), INDICATOR_RED, INDICATOR_GREEN, INDICATOR_BLUE); - ESP_ERROR_CHECK(led_strip_refresh(leds)); + leds_flush(); last_cycle_tick = xTaskGetTickCount(); scrambled_times++; } @@ -243,7 +243,7 @@ void step5(void) { std::uniform_int_distribution<> non_green_indicators_dist(0, (20 - green_indicators)); set_unique_leds_random_color(indicator_options, non_green_indicators_dist(gen), NON_GREEN_INDICATOR_RED, NON_GREEN_INDICATOR_GREEN, NON_GREEN_INDICATOR_BLUE); - ESP_ERROR_CHECK(led_strip_refresh(leds)); + leds_flush(); // wait for submit KeypadKey key; @@ -271,7 +271,7 @@ 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)); + leds_flush(); uint8_t starting_switch_state = get_switch_state(); std::string pressed_keys; @@ -315,10 +315,10 @@ void step5(void) { 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])); + led_set(idx_to_led_map[i], INDICATOR_RED[color], INDICATOR_GREEN[color], INDICATOR_BLUE[color]); } } - ESP_ERROR_CHECK(led_strip_refresh(leds)); + leds_flush(); int green_button_pressed = 0; int blue_button_pressed = 0; @@ -389,10 +389,10 @@ void step5(void) { int speaker_color = color_dist(gen); int s3_color = color_dist(gen); - 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)); + led_set(6, COLOR_RED[tft_color], COLOR_GREEN[tft_color], COLOR_BLUE[tft_color]); + led_set(9, COLOR_RED[speaker_color], COLOR_GREEN[speaker_color], COLOR_BLUE[speaker_color]); + led_set(14, COLOR_RED[s3_color], COLOR_GREEN[s3_color], COLOR_BLUE[s3_color]); + leds_flush(); int buttons_pressed = 0; @@ -444,7 +444,7 @@ void step5(void) { int button_colors[4] = {button_color_dist(gen), button_color_dist(gen), button_color_dist(gen), button_color_dist(gen)}; for (int i = 0; i < 4; i++) { - ESP_ERROR_CHECK(led_strip_set_pixel(leds, (20 - i), BUTTON_COLOR_RED[button_colors[i]], BUTTON_COLOR_GREEN[button_colors[i]], BUTTON_COLOR_BLUE[button_colors[i]])); + led_set(IndicatorLED::LED_B1 - i, BUTTON_COLOR_RED[button_colors[i]], BUTTON_COLOR_GREEN[button_colors[i]], BUTTON_COLOR_BLUE[button_colors[i]]); } // switches @@ -456,10 +456,10 @@ void step5(void) { int switch_colors[4] = {switch_color_dist(gen), switch_color_dist(gen), switch_color_dist(gen), 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)); + led_set(IndicatorLED::LED_S1 - i, SWITCH_COLOR_RED[switch_colors[i]], SWITCH_COLOR_GREEN[switch_colors[i]], 0); } - ESP_ERROR_CHECK(led_strip_refresh(leds)); + leds_flush(); ButtonKey button; KeypadKey key; @@ -475,11 +475,11 @@ void step5(void) { if (button_colors[i] > 3) { button_colors[i] = 0; } - ESP_ERROR_CHECK(led_strip_set_pixel(leds, (20 - i), BUTTON_COLOR_RED[button_colors[i]], BUTTON_COLOR_GREEN[button_colors[i]], BUTTON_COLOR_BLUE[button_colors[i]])); + led_set(IndicatorLED::LED_B1 - i, BUTTON_COLOR_RED[button_colors[i]], BUTTON_COLOR_GREEN[button_colors[i]], BUTTON_COLOR_BLUE[button_colors[i]]); } } - ESP_ERROR_CHECK(led_strip_refresh(leds)); + leds_flush(); } if (get_module_time() <= 0 || (get_keypad_pressed(&key) && (char_of_keypad_key(key) == '#'))) { solved_correctly = submit_4(button_colors, switch_colors, starting_switch_state); @@ -507,7 +507,7 @@ 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)); + leds_flush(); std::array buttons_pressed = {0, 0, 0, 0}; ButtonKey button; @@ -562,14 +562,14 @@ void step5(void) { for (int i = 0; i < 4; i++) { if (led_off != i) { button_colors[i] = led_color_dist(gen); - ESP_ERROR_CHECK(led_strip_set_pixel(leds, (20 - i), COLORS_RED[button_colors[i]], COLORS_GREEN[button_colors[i]], COLORS_BLUE[button_colors[i]])); + led_set(IndicatorLED::LED_B1 - i, COLORS_RED[button_colors[i]], COLORS_GREEN[button_colors[i]], COLORS_BLUE[button_colors[i]]); buttons_cycling[i] = true; } else { button_colors[i] = -1; buttons_cycling[i] = false; } } - ESP_ERROR_CHECK(led_strip_refresh(leds)); + leds_flush(); const uint8_t CORRECT_COLORS[4] = {4, 0, 5, 2}; TickType_t lastCycleTime = xTaskGetTickCount(); @@ -593,8 +593,8 @@ void step5(void) { 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); + led_set(IndicatorLED::LED_B1 - i, COLORS_RED[CORRECT_COLORS[i]], COLORS_GREEN[CORRECT_COLORS[i]], COLORS_BLUE[CORRECT_COLORS[i]]); + leds_flush(); } } else if (button_colors[i] != CORRECT_COLORS[i]) { strike("Wrong time!"); @@ -610,16 +610,16 @@ void step5(void) { } } if ((xTaskGetTickCount() - lastCycleTime) >= pdMS_TO_TICKS(500)) { - for (int i = 0; i < 4; i++) { + for (uint32_t i = 0; i < 4; i++) { if (buttons_cycling[i]) { button_colors[i]++; if (button_colors[i] > 5) { button_colors[i] = 0; } - ESP_ERROR_CHECK(led_strip_set_pixel(leds, (20 - i), COLORS_RED[button_colors[i]], COLORS_GREEN[button_colors[i]], COLORS_BLUE[button_colors[i]])); + led_set(IndicatorLED::LED_B1 - i, COLORS_RED[button_colors[i]], COLORS_GREEN[button_colors[i]], COLORS_BLUE[button_colors[i]]); } } - ESP_ERROR_CHECK(led_strip_refresh(leds)); + leds_flush(); lastCycleTime = xTaskGetTickCount(); } @@ -737,7 +737,7 @@ void step5(void) { set_unique_leds(led_options, modifier_indicators[i], INDICATOR_RED[i], INDICATOR_GREEN[i], INDICATOR_BLUE[i]); } - ESP_ERROR_CHECK(led_strip_refresh(leds)); + leds_flush(); std::string answer_string = std::to_string(expression_answer); std::string entered_string = ""; @@ -803,7 +803,7 @@ void step5(void) { } - ESP_ERROR_CHECK(led_strip_refresh(leds)); + leds_flush(); std::uniform_int_distribution<> answer_color_dist(0, 4); diff --git a/resources/flash.wav b/resources/flash.wav new file mode 100644 index 0000000..95f0f75 Binary files /dev/null and b/resources/flash.wav differ