clean bomb and step 1
This commit is contained in:
parent
ee178f3340
commit
ed9554171b
@ -1,4 +1,4 @@
|
|||||||
idf_component_register(SRCS "main.cpp"
|
idf_component_register(SRCS "helper.cpp" "main.cpp"
|
||||||
INCLUDE_DIRS ".")
|
INCLUDE_DIRS ".")
|
||||||
|
|
||||||
add_subdirectory(drivers)
|
add_subdirectory(drivers)
|
||||||
|
|||||||
@ -161,6 +161,9 @@ bool get_touch_released(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void poll_bottom_task(void *arg);
|
static void poll_bottom_task(void *arg);
|
||||||
|
static void receive_keypad(void);
|
||||||
|
static void receive_button(void);
|
||||||
|
static void receive_touch(void);
|
||||||
|
|
||||||
// static void IRAM_ATTR gpio_isr_handler(void* arg)
|
// static void IRAM_ATTR gpio_isr_handler(void* arg)
|
||||||
// {
|
// {
|
||||||
@ -196,6 +199,10 @@ void init_bottom_half() {
|
|||||||
//hook isr handler for specific gpio pin
|
//hook isr handler for specific gpio pin
|
||||||
// gpio_isr_handler_add(BOTTOM_INTERUPT_PIN, gpio_isr_handler, NULL);
|
// gpio_isr_handler_add(BOTTOM_INTERUPT_PIN, gpio_isr_handler, NULL);
|
||||||
|
|
||||||
|
receive_keypad();
|
||||||
|
receive_button();
|
||||||
|
receive_touch();
|
||||||
|
|
||||||
xTaskCreate(poll_bottom_task, "poll_bottom", 4096, NULL, 10, NULL);
|
xTaskCreate(poll_bottom_task, "poll_bottom", 4096, NULL, 10, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -45,6 +45,7 @@ esp_err_t play_raw(const char *fp) {
|
|||||||
i2s_channel_disable(tx_chan);
|
i2s_channel_disable(tx_chan);
|
||||||
free(read_buf);
|
free(read_buf);
|
||||||
free(write_buf);
|
free(write_buf);
|
||||||
|
fclose(fh);
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,8 +36,9 @@
|
|||||||
|
|
||||||
static const char *TFT_TAG = "tft_driver";
|
static const char *TFT_TAG = "tft_driver";
|
||||||
|
|
||||||
#define DISPLAY_HORIZONTAL_PIXELS 320
|
// rotation swaps the horizontal and vertical pixel counts
|
||||||
#define DISPLAY_VERTICAL_PIXELS 480
|
#define DISPLAY_HORIZONTAL_PIXELS 480
|
||||||
|
#define DISPLAY_VERTICAL_PIXELS 320
|
||||||
#define DISPLAY_COMMAND_BITS 8
|
#define DISPLAY_COMMAND_BITS 8
|
||||||
#define DISPLAY_PARAMETER_BITS 8
|
#define DISPLAY_PARAMETER_BITS 8
|
||||||
#define DISPLAY_REFRESH_HZ 40000000
|
#define DISPLAY_REFRESH_HZ 40000000
|
||||||
@ -169,9 +170,9 @@ void initialize_display() {
|
|||||||
|
|
||||||
ESP_ERROR_CHECK(esp_lcd_panel_reset(lcd_handle));
|
ESP_ERROR_CHECK(esp_lcd_panel_reset(lcd_handle));
|
||||||
ESP_ERROR_CHECK(esp_lcd_panel_init(lcd_handle));
|
ESP_ERROR_CHECK(esp_lcd_panel_init(lcd_handle));
|
||||||
ESP_ERROR_CHECK(esp_lcd_panel_invert_color(lcd_handle, false));
|
ESP_ERROR_CHECK(esp_lcd_panel_invert_color(lcd_handle, true));
|
||||||
ESP_ERROR_CHECK(esp_lcd_panel_swap_xy(lcd_handle, false));
|
ESP_ERROR_CHECK(esp_lcd_panel_swap_xy(lcd_handle, true));
|
||||||
ESP_ERROR_CHECK(esp_lcd_panel_mirror(lcd_handle, true, false));
|
ESP_ERROR_CHECK(esp_lcd_panel_mirror(lcd_handle, false, true));
|
||||||
ESP_ERROR_CHECK(esp_lcd_panel_set_gap(lcd_handle, 0, 0));
|
ESP_ERROR_CHECK(esp_lcd_panel_set_gap(lcd_handle, 0, 0));
|
||||||
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
|
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
|
||||||
ESP_ERROR_CHECK(esp_lcd_panel_disp_off(lcd_handle, false));
|
ESP_ERROR_CHECK(esp_lcd_panel_disp_off(lcd_handle, false));
|
||||||
@ -199,6 +200,7 @@ void initialize_lvgl() {
|
|||||||
lv_disp_drv.flush_cb = lvgl_flush_cb;
|
lv_disp_drv.flush_cb = lvgl_flush_cb;
|
||||||
lv_disp_drv.draw_buf = &lv_disp_buf;
|
lv_disp_drv.draw_buf = &lv_disp_buf;
|
||||||
lv_disp_drv.user_data = lcd_handle;
|
lv_disp_drv.user_data = lcd_handle;
|
||||||
|
// lv_disp_drv.rotated = LV_DISP_ROT_90;
|
||||||
lv_display = lv_disp_drv_register(&lv_disp_drv);
|
lv_display = lv_disp_drv_register(&lv_disp_drv);
|
||||||
|
|
||||||
ESP_LOGI(TFT_TAG, "Creating LVGL tick timer");
|
ESP_LOGI(TFT_TAG, "Creating LVGL tick timer");
|
||||||
@ -271,11 +273,21 @@ void create_demo_ui() {
|
|||||||
lv_anim_start(&a);
|
lv_anim_start(&a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tick_timer_task(void* arg) {
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
lv_timer_handler();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void init_tft() {
|
void init_tft() {
|
||||||
initialize_spi();
|
initialize_spi();
|
||||||
initialize_display();
|
initialize_display();
|
||||||
initialize_lvgl();
|
initialize_lvgl();
|
||||||
|
|
||||||
|
xTaskCreate(tick_timer_task, "tick_lvgl", 4096, NULL, 5, NULL);
|
||||||
|
|
||||||
ESP_LOGI(TFT_TAG, "TFT initialization Successful");
|
ESP_LOGI(TFT_TAG, "TFT initialization Successful");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -55,20 +55,26 @@ uint8_t get_cut_wires(void) {
|
|||||||
return return_;
|
return return_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get_button(void) {
|
bool get_help_button(void) {
|
||||||
return button_state;
|
return button_state;
|
||||||
}
|
}
|
||||||
bool get_button_pressed(void) {
|
bool get_help_button_pressed(void) {
|
||||||
bool return_ = button_pressed;
|
bool return_ = button_pressed;
|
||||||
button_pressed = false;
|
button_pressed = false;
|
||||||
return return_;
|
return return_;
|
||||||
}
|
}
|
||||||
bool get_button_released(void) {
|
bool get_help_button_released(void) {
|
||||||
bool return_ = button_released;
|
bool return_ = button_released;
|
||||||
button_released = false;
|
button_released = false;
|
||||||
return return_;
|
return return_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clear_wires_pressed_released_cut(void) {
|
||||||
|
wires_cut = 0;
|
||||||
|
button_pressed = false;
|
||||||
|
button_released = false;
|
||||||
|
}
|
||||||
|
|
||||||
void strike(char* reason) {
|
void strike(char* reason) {
|
||||||
ESP_LOGW("strike!", "%s", reason);
|
ESP_LOGW("strike!", "%s", reason);
|
||||||
uint8_t reg = 6;
|
uint8_t reg = 6;
|
||||||
|
|||||||
@ -17,9 +17,11 @@ void init_wires(void);
|
|||||||
uint8_t get_wires(void);
|
uint8_t get_wires(void);
|
||||||
uint8_t get_cut_wires(void);
|
uint8_t get_cut_wires(void);
|
||||||
|
|
||||||
bool get_button(void);
|
bool get_help_button(void);
|
||||||
bool get_button_pressed(void);
|
bool get_help_button_pressed(void);
|
||||||
bool get_button_released(void);
|
bool get_help_button_released(void);
|
||||||
|
|
||||||
|
void clear_wires_pressed_released_cut(void);
|
||||||
|
|
||||||
void set_leds(uint8_t led_states);
|
void set_leds(uint8_t led_states);
|
||||||
|
|
||||||
|
|||||||
22
main/helper.cpp
Normal file
22
main/helper.cpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#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[] = {0};
|
||||||
|
set_module_sseg_raw(clear);
|
||||||
|
|
||||||
|
// clear char lcd
|
||||||
|
lcd_clear(&lcd);
|
||||||
|
lcd_no_cursor(&lcd);
|
||||||
|
lcd_set_cursor(&lcd, 0, 0);
|
||||||
|
}
|
||||||
14
main/helper.h
Normal file
14
main/helper.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#ifndef HELPER_H
|
||||||
|
#define HELPER_H
|
||||||
|
|
||||||
|
#include "drivers/game_timer.h"
|
||||||
|
#include "drivers/sseg.h"
|
||||||
|
#include "drivers/bottom_half.h"
|
||||||
|
#include "drivers/wires.h"
|
||||||
|
#include "drivers/char_lcd.h"
|
||||||
|
#include "drivers/leds.h"
|
||||||
|
|
||||||
|
/// Clears most persistant bomb state
|
||||||
|
void clean_bomb(void);
|
||||||
|
|
||||||
|
#endif /* HELPER_H */
|
||||||
@ -14,6 +14,8 @@
|
|||||||
#include "esp_rom_gpio.h"
|
#include "esp_rom_gpio.h"
|
||||||
#include "drivers/leds.h"
|
#include "drivers/leds.h"
|
||||||
|
|
||||||
|
#include "helper.h"
|
||||||
|
|
||||||
#include "steps/step0.hpp"
|
#include "steps/step0.hpp"
|
||||||
#include "steps/step1.hpp"
|
#include "steps/step1.hpp"
|
||||||
#include "steps/step2.hpp"
|
#include "steps/step2.hpp"
|
||||||
@ -38,21 +40,31 @@ extern "C" void app_main(void) {
|
|||||||
init_bottom_half();
|
init_bottom_half();
|
||||||
init_char_lcd();
|
init_char_lcd();
|
||||||
|
|
||||||
|
// create_demo_ui();
|
||||||
|
clean_bomb();
|
||||||
|
|
||||||
step0();
|
step0();
|
||||||
set_game_time(30000);
|
set_game_time(30000);
|
||||||
start_game_timer();
|
start_game_timer();
|
||||||
|
clean_bomb();
|
||||||
step1();
|
step1();
|
||||||
|
clean_bomb();
|
||||||
step2();
|
step2();
|
||||||
|
clean_bomb();
|
||||||
step3();
|
step3();
|
||||||
|
clean_bomb();
|
||||||
step4();
|
step4();
|
||||||
|
clean_bomb();
|
||||||
step5();
|
step5();
|
||||||
|
clean_bomb();
|
||||||
step6();
|
step6();
|
||||||
|
clean_bomb();
|
||||||
|
|
||||||
stop_game_timer();
|
stop_game_timer();
|
||||||
ESP_LOGI(TAG, "Bomb has been diffused. Counter-Terrorists win.");
|
ESP_LOGI(TAG, "Bomb has been diffused. Counter-Terrorists win.");
|
||||||
ESP_ERROR_CHECK_WITHOUT_ABORT(play_raw("/sdcard/diffused.pcm"));
|
ESP_ERROR_CHECK_WITHOUT_ABORT(play_raw("/sdcard/diffused.pcm"));
|
||||||
|
|
||||||
// create_demo_ui();
|
|
||||||
|
|
||||||
// play_example();
|
// play_example();
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,310 @@
|
|||||||
#ifndef STEP_1_HPP
|
#ifndef STEP_1_HPP
|
||||||
#define STEP_1_HPP
|
#define STEP_1_HPP
|
||||||
|
|
||||||
|
#include <random>
|
||||||
|
|
||||||
static const char *STEP1_TAG = "step1";
|
static const char *STEP1_TAG = "step1";
|
||||||
|
|
||||||
void step1(void) {
|
static char* COLOR_NAMES[] = {
|
||||||
|
"green",
|
||||||
|
"red",
|
||||||
|
"yellow",
|
||||||
|
"purple"
|
||||||
|
};
|
||||||
|
|
||||||
|
static char* NUM_NAMES[] = {
|
||||||
|
"one",
|
||||||
|
"two",
|
||||||
|
"three",
|
||||||
|
"four"
|
||||||
|
};
|
||||||
|
|
||||||
|
static uint8_t NEOPIXEL_COLORS[4][3] = {
|
||||||
|
{0, 20, 0},
|
||||||
|
{20, 0, 0},
|
||||||
|
{20, 20, 0},
|
||||||
|
{15, 0, 20},
|
||||||
|
};
|
||||||
|
|
||||||
|
std::random_device my_rd;
|
||||||
|
std::mt19937 my_gen(my_rd());
|
||||||
|
std::uniform_int_distribution<> zero_to_one(0, 1);
|
||||||
|
std::uniform_int_distribution<> zero_to_two(0, 2);
|
||||||
|
std::uniform_int_distribution<> zero_to_three(0, 3);
|
||||||
|
|
||||||
|
static lv_obj_t *scr;
|
||||||
|
static lv_obj_t *text = NULL;
|
||||||
|
|
||||||
|
static lv_style_t green_text;
|
||||||
|
static lv_style_t red_text;
|
||||||
|
static lv_style_t yellow_text;
|
||||||
|
static lv_style_t purple_text;
|
||||||
|
|
||||||
|
static int switch_leds[] = {0, 0, 0, 0};
|
||||||
|
|
||||||
|
static lv_style_t* color_styles[] = {
|
||||||
|
&green_text,
|
||||||
|
&red_text,
|
||||||
|
&yellow_text,
|
||||||
|
&purple_text
|
||||||
|
};
|
||||||
|
|
||||||
|
void init_step(void) {
|
||||||
|
scr = lv_disp_get_scr_act(NULL);
|
||||||
|
|
||||||
|
// Set the background color of the display to black.
|
||||||
|
lv_style_init(&style_screen);
|
||||||
|
lv_style_set_bg_color(&style_screen, lv_color_black());
|
||||||
|
lv_style_set_text_font(&style_screen, &lv_font_montserrat_32);
|
||||||
|
lv_obj_add_style(lv_scr_act(), &style_screen, LV_STATE_DEFAULT);
|
||||||
|
|
||||||
|
// rgb565
|
||||||
|
lv_color_t green;
|
||||||
|
green.full = 0x27e0;
|
||||||
|
lv_color_t red;
|
||||||
|
red.full = 0xf800;
|
||||||
|
lv_color_t yellow;
|
||||||
|
yellow.full = 0xffa9;
|
||||||
|
lv_color_t purple;
|
||||||
|
purple.full = 0x881f;
|
||||||
|
|
||||||
|
lv_style_init(&green_text);
|
||||||
|
lv_style_set_text_color(&green_text, green);
|
||||||
|
|
||||||
|
lv_style_init(&red_text);
|
||||||
|
lv_style_set_text_color(&red_text, red);
|
||||||
|
|
||||||
|
lv_style_init(&yellow_text);
|
||||||
|
lv_style_set_text_color(&yellow_text, yellow);
|
||||||
|
|
||||||
|
lv_style_init(&purple_text);
|
||||||
|
lv_style_set_text_color(&purple_text, purple);
|
||||||
|
|
||||||
|
text = lv_label_create(scr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clean_up_step(void) {
|
||||||
|
lv_obj_clean(text);
|
||||||
|
lv_obj_clean(scr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void generate_switch_leds(void) {
|
||||||
|
int colors[4] = {0, 1, 2, 3};
|
||||||
|
|
||||||
|
int idx = zero_to_three(my_gen);
|
||||||
|
switch_leds[0] = colors[idx];
|
||||||
|
colors[idx] = colors[3];
|
||||||
|
|
||||||
|
idx = zero_to_two(my_gen);
|
||||||
|
switch_leds[1] = colors[idx];
|
||||||
|
colors[idx] = colors[2];
|
||||||
|
|
||||||
|
idx = zero_to_one(my_gen);
|
||||||
|
switch_leds[2] = colors[idx];
|
||||||
|
colors[idx] = colors[1];
|
||||||
|
|
||||||
|
switch_leds[3] = colors[0];
|
||||||
|
|
||||||
|
ESP_LOGI(STEP1_TAG, "%d, %d, %d, %d", switch_leds[0], switch_leds[1], switch_leds[2], switch_leds[3]);
|
||||||
|
|
||||||
|
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_strip_refresh(leds);
|
||||||
|
}
|
||||||
|
|
||||||
|
int generate_part_a(void) {
|
||||||
|
int text_color = zero_to_three(my_gen);
|
||||||
|
int text_idx = zero_to_three(my_gen);
|
||||||
|
|
||||||
|
char* text_string = COLOR_NAMES[text_idx];
|
||||||
|
|
||||||
|
lv_label_set_text(text, text_string);
|
||||||
|
lv_obj_center(text);
|
||||||
|
lv_obj_add_style(text, color_styles[text_color], LV_STATE_DEFAULT);
|
||||||
|
|
||||||
|
generate_switch_leds();
|
||||||
|
|
||||||
|
// the correct answer is the text color
|
||||||
|
return text_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
int generate_part_b(void) {
|
||||||
|
int is_color = zero_to_one(my_gen) == 0;
|
||||||
|
if (is_color) {
|
||||||
|
return generate_part_a();
|
||||||
|
}
|
||||||
|
|
||||||
|
int text_color = zero_to_three(my_gen);
|
||||||
|
int text_number = zero_to_three(my_gen);
|
||||||
|
|
||||||
|
char* text_string = NUM_NAMES[text_number];
|
||||||
|
|
||||||
|
lv_label_set_text(text, text_string);
|
||||||
|
lv_obj_center(text);
|
||||||
|
lv_obj_add_style(text, color_styles[text_color], LV_STATE_DEFAULT);
|
||||||
|
|
||||||
|
generate_switch_leds();
|
||||||
|
|
||||||
|
// the correct answer is the number
|
||||||
|
return text_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
int generate_part_c(void) {
|
||||||
|
int type = zero_to_two(my_gen);
|
||||||
|
if (type != 0) {
|
||||||
|
return generate_part_b();
|
||||||
|
}
|
||||||
|
|
||||||
|
int text_color = zero_to_three(my_gen);
|
||||||
|
char* text_string = "switch";
|
||||||
|
|
||||||
|
lv_label_set_text(text, text_string);
|
||||||
|
lv_obj_center(text);
|
||||||
|
lv_obj_add_style(text, color_styles[text_color], LV_STATE_DEFAULT);
|
||||||
|
|
||||||
|
generate_switch_leds();
|
||||||
|
|
||||||
|
// the correct answer is the switch
|
||||||
|
return text_color + 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
void part_a(void) {
|
||||||
|
stop_module_timer();
|
||||||
|
set_module_time(30);
|
||||||
|
|
||||||
|
lcd_clear(&lcd);
|
||||||
|
lcd_set_cursor(&lcd, 1, 1);
|
||||||
|
lcd_print(&lcd, "COLOR");
|
||||||
|
ESP_ERROR_CHECK(led_strip_set_pixel(leds, Led::char_lcd, 20, 0, 20));
|
||||||
|
ESP_ERROR_CHECK(led_strip_refresh(leds));
|
||||||
|
|
||||||
|
int times = 0;
|
||||||
|
int correct = generate_part_a();
|
||||||
|
|
||||||
|
ButtonKey button;
|
||||||
|
SwitchKey switch_;
|
||||||
|
|
||||||
|
while (times < 15) {
|
||||||
|
while (get_pressed_button(&button)) {
|
||||||
|
start_module_timer();
|
||||||
|
if ((int)(button) == correct) {
|
||||||
|
times++;
|
||||||
|
if (times >= 15) break;
|
||||||
|
correct = generate_part_a();
|
||||||
|
} else {
|
||||||
|
strike("Incorrect color action");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (get_flipped_switch(&switch_)) {
|
||||||
|
strike("Incorrect color action");
|
||||||
|
}
|
||||||
|
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
}
|
||||||
|
|
||||||
|
lv_label_set_text(text, "");
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(80));
|
||||||
|
play_raw(MOUNT_POINT "/correct.pcm");
|
||||||
|
}
|
||||||
|
|
||||||
|
void part_b(void) {
|
||||||
|
stop_module_timer();
|
||||||
|
set_module_time(25);
|
||||||
|
|
||||||
|
lcd_clear(&lcd);
|
||||||
|
lcd_set_cursor(&lcd, 1, 1);
|
||||||
|
lcd_print(&lcd, "NUMBER");
|
||||||
|
ESP_ERROR_CHECK(led_strip_set_pixel(leds, Led::char_lcd, 0, 0, 30));
|
||||||
|
ESP_ERROR_CHECK(led_strip_refresh(leds));
|
||||||
|
|
||||||
|
int times = 0;
|
||||||
|
int correct = generate_part_b();
|
||||||
|
|
||||||
|
ButtonKey button;
|
||||||
|
SwitchKey switch_;
|
||||||
|
|
||||||
|
while (times < 15) {
|
||||||
|
while (get_pressed_button(&button)) {
|
||||||
|
start_module_timer();
|
||||||
|
if ((int)(button) == correct) {
|
||||||
|
times++;
|
||||||
|
if (times >= 15) break;
|
||||||
|
correct = generate_part_b();
|
||||||
|
} else {
|
||||||
|
strike("Incorrect color action");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (get_flipped_switch(&switch_)) {
|
||||||
|
strike("Incorrect color action");
|
||||||
|
}
|
||||||
|
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
}
|
||||||
|
|
||||||
|
lv_label_set_text(text, "");
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(80));
|
||||||
|
play_raw(MOUNT_POINT "/correct.pcm");
|
||||||
|
}
|
||||||
|
|
||||||
|
void part_c(void) {
|
||||||
|
stop_module_timer();
|
||||||
|
set_module_time(20);
|
||||||
|
|
||||||
|
lcd_clear(&lcd);
|
||||||
|
lcd_set_cursor(&lcd, 1, 1);
|
||||||
|
lcd_print(&lcd, "SWITCH");
|
||||||
|
ESP_ERROR_CHECK(led_strip_set_pixel(leds, Led::char_lcd, 20, 20, 0));
|
||||||
|
ESP_ERROR_CHECK(led_strip_refresh(leds));
|
||||||
|
|
||||||
|
int times = 0;
|
||||||
|
int correct = generate_part_c();
|
||||||
|
|
||||||
|
ButtonKey button;
|
||||||
|
SwitchKey switch_;
|
||||||
|
|
||||||
|
while (times < 15) {
|
||||||
|
while (get_pressed_button(&button)) {
|
||||||
|
start_module_timer();
|
||||||
|
if ((int)(button) == correct) {
|
||||||
|
times++;
|
||||||
|
if (times >= 15) break;
|
||||||
|
correct = generate_part_c();
|
||||||
|
} else {
|
||||||
|
strike("Incorrect color action");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (get_flipped_switch(&switch_)) {
|
||||||
|
start_module_timer();
|
||||||
|
if (switch_leds[(int)(switch_)] + 4 == correct) {
|
||||||
|
times++;
|
||||||
|
if (times >= 10) break;
|
||||||
|
correct = generate_part_c();
|
||||||
|
} else {
|
||||||
|
strike("Incorrect color action");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
}
|
||||||
|
|
||||||
|
lv_label_set_text(text, "");
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(80));
|
||||||
|
play_raw(MOUNT_POINT "/correct.pcm");
|
||||||
|
}
|
||||||
|
|
||||||
|
void step1(void) {
|
||||||
|
SwitchKey switch_;
|
||||||
|
while (get_flipped_switch(&switch_));
|
||||||
|
|
||||||
|
init_step();
|
||||||
|
part_a();
|
||||||
|
part_b();
|
||||||
|
part_c();
|
||||||
|
clean_up_step();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* STEP_1_HPP */
|
#endif /* STEP_1_HPP */
|
||||||
@ -9,7 +9,6 @@ static const char *STEP6_TAG = "step6";
|
|||||||
|
|
||||||
static uint8_t cut_wires = 0;
|
static uint8_t cut_wires = 0;
|
||||||
|
|
||||||
static void correct_wire_task(void *arg);
|
|
||||||
|
|
||||||
void step6(void) {
|
void step6(void) {
|
||||||
get_cut_wires();
|
get_cut_wires();
|
||||||
@ -28,10 +27,8 @@ void step6(void) {
|
|||||||
|
|
||||||
for (int i = 0; i < NUM_WIRES; i++) {
|
for (int i = 0; i < NUM_WIRES; i++) {
|
||||||
if (just_cut_wires & (1<<i)) {
|
if (just_cut_wires & (1<<i)) {
|
||||||
// ESP_LOGI(STEP6_TAG, "Wire %d cut", i);
|
|
||||||
if (solution[i]) {
|
if (solution[i]) {
|
||||||
xTaskCreate(correct_wire_task, "correct_wire", 4096, NULL, 5, NULL);
|
play_raw(MOUNT_POINT "/correct.pcm");
|
||||||
// ESP_LOGI(STEP6_TAG, "correct wire");
|
|
||||||
} else {
|
} else {
|
||||||
strike("Cut wrong wire");
|
strike("Cut wrong wire");
|
||||||
}
|
}
|
||||||
@ -57,10 +54,4 @@ void step6(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void correct_wire_task(void *arg) {
|
|
||||||
ESP_LOGI(STEP6_TAG, "Correct!");
|
|
||||||
|
|
||||||
vTaskDelete(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* STEP_6_HPP */
|
#endif /* STEP_6_HPP */
|
||||||
20
sdkconfig
20
sdkconfig
@ -1,6 +1,6 @@
|
|||||||
#
|
#
|
||||||
# Automatically generated file. DO NOT EDIT.
|
# Automatically generated file. DO NOT EDIT.
|
||||||
# Espressif IoT Development Framework (ESP-IDF) 5.2.2 Project Configuration
|
# Espressif IoT Development Framework (ESP-IDF) 5.2.1 Project Configuration
|
||||||
#
|
#
|
||||||
CONFIG_SOC_MPU_MIN_REGION_SIZE=0x20000000
|
CONFIG_SOC_MPU_MIN_REGION_SIZE=0x20000000
|
||||||
CONFIG_SOC_MPU_REGIONS_MAX_NUM=8
|
CONFIG_SOC_MPU_REGIONS_MAX_NUM=8
|
||||||
@ -331,7 +331,6 @@ CONFIG_SOC_WIFI_WAPI_SUPPORT=y
|
|||||||
CONFIG_SOC_WIFI_CSI_SUPPORT=y
|
CONFIG_SOC_WIFI_CSI_SUPPORT=y
|
||||||
CONFIG_SOC_WIFI_MESH_SUPPORT=y
|
CONFIG_SOC_WIFI_MESH_SUPPORT=y
|
||||||
CONFIG_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW=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_SUPPORTED=y
|
||||||
CONFIG_SOC_BLE_MESH_SUPPORTED=y
|
CONFIG_SOC_BLE_MESH_SUPPORTED=y
|
||||||
CONFIG_SOC_BLE_50_SUPPORTED=y
|
CONFIG_SOC_BLE_50_SUPPORTED=y
|
||||||
@ -436,7 +435,6 @@ CONFIG_ESP_ROM_HAS_RETARGETABLE_LOCKING=y
|
|||||||
CONFIG_ESP_ROM_USB_OTG_NUM=3
|
CONFIG_ESP_ROM_USB_OTG_NUM=3
|
||||||
CONFIG_ESP_ROM_USB_SERIAL_DEVICE_NUM=4
|
CONFIG_ESP_ROM_USB_SERIAL_DEVICE_NUM=4
|
||||||
CONFIG_ESP_ROM_HAS_ERASE_0_REGION_BUG=y
|
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_GET_CLK_FREQ=y
|
||||||
CONFIG_ESP_ROM_HAS_HAL_WDT=y
|
CONFIG_ESP_ROM_HAS_HAL_WDT=y
|
||||||
CONFIG_ESP_ROM_NEEDS_SWSETUP_WORKAROUND=y
|
CONFIG_ESP_ROM_NEEDS_SWSETUP_WORKAROUND=y
|
||||||
@ -559,7 +557,6 @@ CONFIG_APPTRACE_LOCK_ENABLE=y
|
|||||||
# Bluetooth
|
# Bluetooth
|
||||||
#
|
#
|
||||||
# CONFIG_BT_ENABLED is not set
|
# CONFIG_BT_ENABLED is not set
|
||||||
CONFIG_BT_ALARM_MAX_NUM=50
|
|
||||||
# end of Bluetooth
|
# end of Bluetooth
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -747,10 +744,7 @@ CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=y
|
|||||||
#
|
#
|
||||||
# GDB Stub
|
# GDB Stub
|
||||||
#
|
#
|
||||||
CONFIG_ESP_GDBSTUB_ENABLED=y
|
|
||||||
# CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set
|
# CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set
|
||||||
CONFIG_ESP_GDBSTUB_SUPPORT_TASKS=y
|
|
||||||
CONFIG_ESP_GDBSTUB_MAX_TASKS=32
|
|
||||||
# end of GDB Stub
|
# end of GDB Stub
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -915,7 +909,6 @@ CONFIG_ESP_PHY_RF_CAL_PARTIAL=y
|
|||||||
# CONFIG_ESP_PHY_RF_CAL_NONE is not set
|
# CONFIG_ESP_PHY_RF_CAL_NONE is not set
|
||||||
# CONFIG_ESP_PHY_RF_CAL_FULL is not set
|
# CONFIG_ESP_PHY_RF_CAL_FULL is not set
|
||||||
CONFIG_ESP_PHY_CALIBRATION_MODE=0
|
CONFIG_ESP_PHY_CALIBRATION_MODE=0
|
||||||
# CONFIG_ESP_PHY_PLL_TRACK_DEBUG is not set
|
|
||||||
# end of PHY
|
# end of PHY
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -1213,7 +1206,6 @@ CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0
|
|||||||
CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES=1
|
CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES=1
|
||||||
# CONFIG_FREERTOS_USE_TRACE_FACILITY is not set
|
# CONFIG_FREERTOS_USE_TRACE_FACILITY is not set
|
||||||
# CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS is not set
|
# CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS is not set
|
||||||
# CONFIG_FREERTOS_USE_APPLICATION_TASK_TAG is not set
|
|
||||||
# end of Kernel
|
# end of Kernel
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -1501,9 +1493,7 @@ CONFIG_MBEDTLS_CMAC_C=y
|
|||||||
CONFIG_MBEDTLS_HARDWARE_AES=y
|
CONFIG_MBEDTLS_HARDWARE_AES=y
|
||||||
CONFIG_MBEDTLS_AES_USE_INTERRUPT=y
|
CONFIG_MBEDTLS_AES_USE_INTERRUPT=y
|
||||||
CONFIG_MBEDTLS_AES_INTERRUPT_LEVEL=0
|
CONFIG_MBEDTLS_AES_INTERRUPT_LEVEL=0
|
||||||
# CONFIG_MBEDTLS_GCM_SUPPORT_NON_AES_CIPHER is not set
|
|
||||||
CONFIG_MBEDTLS_HARDWARE_MPI=y
|
CONFIG_MBEDTLS_HARDWARE_MPI=y
|
||||||
# CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI is not set
|
|
||||||
CONFIG_MBEDTLS_MPI_USE_INTERRUPT=y
|
CONFIG_MBEDTLS_MPI_USE_INTERRUPT=y
|
||||||
CONFIG_MBEDTLS_MPI_INTERRUPT_LEVEL=0
|
CONFIG_MBEDTLS_MPI_INTERRUPT_LEVEL=0
|
||||||
CONFIG_MBEDTLS_HARDWARE_SHA=y
|
CONFIG_MBEDTLS_HARDWARE_SHA=y
|
||||||
@ -1590,7 +1580,7 @@ CONFIG_MBEDTLS_ECP_FIXED_POINT_OPTIM=y
|
|||||||
# CONFIG_MBEDTLS_CHACHA20_C is not set
|
# CONFIG_MBEDTLS_CHACHA20_C is not set
|
||||||
# CONFIG_MBEDTLS_HKDF_C is not set
|
# CONFIG_MBEDTLS_HKDF_C is not set
|
||||||
# CONFIG_MBEDTLS_THREADING_C is not set
|
# CONFIG_MBEDTLS_THREADING_C is not set
|
||||||
CONFIG_MBEDTLS_ERROR_STRINGS=y
|
# CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI is not set
|
||||||
# end of mbedTLS
|
# end of mbedTLS
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -2006,11 +1996,11 @@ CONFIG_LV_FONT_MONTSERRAT_14=y
|
|||||||
# CONFIG_LV_FONT_MONTSERRAT_18 is not set
|
# CONFIG_LV_FONT_MONTSERRAT_18 is not set
|
||||||
# CONFIG_LV_FONT_MONTSERRAT_20 is not set
|
# CONFIG_LV_FONT_MONTSERRAT_20 is not set
|
||||||
# CONFIG_LV_FONT_MONTSERRAT_22 is not set
|
# CONFIG_LV_FONT_MONTSERRAT_22 is not set
|
||||||
# CONFIG_LV_FONT_MONTSERRAT_24 is not set
|
CONFIG_LV_FONT_MONTSERRAT_24=y
|
||||||
# CONFIG_LV_FONT_MONTSERRAT_26 is not set
|
# CONFIG_LV_FONT_MONTSERRAT_26 is not set
|
||||||
# CONFIG_LV_FONT_MONTSERRAT_28 is not set
|
# CONFIG_LV_FONT_MONTSERRAT_28 is not set
|
||||||
# CONFIG_LV_FONT_MONTSERRAT_30 is not set
|
# CONFIG_LV_FONT_MONTSERRAT_30 is not set
|
||||||
# CONFIG_LV_FONT_MONTSERRAT_32 is not set
|
CONFIG_LV_FONT_MONTSERRAT_32=y
|
||||||
# CONFIG_LV_FONT_MONTSERRAT_34 is not set
|
# CONFIG_LV_FONT_MONTSERRAT_34 is not set
|
||||||
# CONFIG_LV_FONT_MONTSERRAT_36 is not set
|
# CONFIG_LV_FONT_MONTSERRAT_36 is not set
|
||||||
# CONFIG_LV_FONT_MONTSERRAT_38 is not set
|
# CONFIG_LV_FONT_MONTSERRAT_38 is not set
|
||||||
@ -2232,8 +2222,6 @@ CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y
|
|||||||
# CONFIG_EVENT_LOOP_PROFILING is not set
|
# CONFIG_EVENT_LOOP_PROFILING is not set
|
||||||
CONFIG_POST_EVENTS_FROM_ISR=y
|
CONFIG_POST_EVENTS_FROM_ISR=y
|
||||||
CONFIG_POST_EVENTS_FROM_IRAM_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_OTA_ALLOW_HTTP is not set
|
||||||
# CONFIG_ESP_SYSTEM_PD_FLASH is not set
|
# CONFIG_ESP_SYSTEM_PD_FLASH is not set
|
||||||
CONFIG_ESP32S3_DEEP_SLEEP_WAKEUP_DELAY=2000
|
CONFIG_ESP32S3_DEEP_SLEEP_WAKEUP_DELAY=2000
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user