#include "helper.h" void clean_bomb(void) { // clear pending inputs clear_all_pressed_released(); clear_wires_pressed_released_cut(); // clear leds led_strip_clear(leds); led_strip_refresh(leds); // clear module timer stop_module_timer(); set_module_time(0); uint8_t clear[4] = {0}; set_module_sseg_raw(clear); // clear char lcd lcd_clear(&lcd); lcd_no_cursor(&lcd); lcd_set_cursor(&lcd, 0, 0); } void poster_child_task(void* arg) { while (1) { if (get_help_button_pressed()) { play_raw(MOUNT_POINT "/poster.pcm"); } vTaskDelay(pdMS_TO_TICKS(10)); } vTaskDelete(NULL); } static const int STRING_MAX_LEN = 8; void do_star_codes(StarCodeHandler* star_codes, int star_codes_len) { KeypadKey key; int current_idx = 0; char current[STRING_MAX_LEN+1] = {0}; while (1) { while (get_pressed_keypad(&key)) { if (key == KeypadKey::star) { current[0] = '*'; for (int i = 1; i < STRING_MAX_LEN; i++) { current[i] = 0; } current_idx = 1; } else if (key == KeypadKey::pound) { // submit if (current[0] == '\0') { continue; } bool hit = false; for (int i = 0; i < star_codes_len; i++) { StarCodeHandler sch = star_codes[i]; if (strcmp(current, sch.code) == 0) { hit = true; lcd_set_cursor(&lcd, 1, 2); lcd_print(&lcd, sch.display_text); vTaskDelay(pdMS_TO_TICKS(2000)); if (sch.callback != nullptr) { (sch.callback)(); } if (sch.should_exit) { return; } break; } } if (!hit) { lcd_set_cursor(&lcd, 1, 2); lcd_print(&lcd, "Invalid Star Code"); vTaskDelay(pdMS_TO_TICKS(2000)); } // clear for (int i = 0; i < STRING_MAX_LEN; i++) { current[i] = 0; } current_idx = 0; } else { // out of room. skip if (current_idx >= STRING_MAX_LEN) break; // no code started. if (current[0] != '*') continue; char c = char_of_keypad_key(key); current[current_idx++] = c; } // ESP_LOGI(STEP0_TAG, "Pressed: %c", c); lcd_clear(&lcd); lcd_set_cursor(&lcd, 1, 1); lcd_print(&lcd, current); } vTaskDelay(pdMS_TO_TICKS(10)); } }