speaker updates and tweaks

This commit is contained in:
2024-08-14 18:29:51 -05:00
parent 0cbae7b15a
commit 7b8e38844a
9 changed files with 146 additions and 12 deletions
+20 -4
View File
@@ -24,6 +24,9 @@ static const void* BACKGROUND_SRC = (void*)"A:/sdcard/bg.bin";
// LV_IMG_DECLARE(background);
// static const void* BACKGROUND_SRC = (void*)&background;
static QueueHandle_t stop_music;
static bool playing_music = true;
static const char* PIECE_IMG_SRC[] = {
NULL,
"A:/sdcard/lb.bin",
@@ -127,9 +130,17 @@ static int bdca(int i) { // [0,1,2,3] -> [ 0,+2,+1,-1]
}
static void music_task(void* arg) {
while (1) {
play_raw(MOUNT_POINT "/tetris.pcm");
stop_music = xQueueCreate(2, sizeof (uint8_t));
if (stop_music == 0) {
ESP_LOGW(TAG, "Could not create stop_music queue!");
vTaskDelete(NULL);
}
while (playing_music) {
play_raw_stop_queue(MOUNT_POINT "/tetris.pcm", stop_music);
}
vTaskDelete(NULL);
}
static void init_screen(void) {
@@ -170,7 +181,7 @@ static void init_screen(void) {
xSemaphoreGive(xGuiSemaphore);
xTaskCreate(music_task, "music", 4096, NULL, 5, &music_handle);
xTaskCreate(music_task, "music", 4096, NULL, 5, NULL);
}
static void deinit_screen(void) {
@@ -179,7 +190,11 @@ static void deinit_screen(void) {
lv_obj_clean(lv_scr_act());
xSemaphoreGive(xGuiSemaphore);
vTaskDelete(music_handle);
playing_music = false;
uint8_t value = 0;
if (!xQueueSend(stop_music, &value, pdMS_TO_TICKS(1000))) {
ESP_LOGE(TAG, "Faild to send stop queue");
}
}
bool play_game(int time, int required_score) {
@@ -330,6 +345,7 @@ void step4(void) {
complete();
while (!play_game(6*60*1000, 8)) fail();
complete();
// vTaskDelay(pdMS_TO_TICKS(3000));
deinit_screen();
}
+1 -1
View File
@@ -80,7 +80,7 @@ void step5(void) {
clean_bomb();
int solved_puzzles = 0;
while (solved_puzzles < ) {
while (solved_puzzles < TIMES_TO_SOLVE) {
lcd_set_cursor(&lcd, 1, 1);
int puzzle = puzzle_dist(gen);