diff --git a/esplay-launcher/main/audio_player.c b/esplay-launcher/main/audio_player.c index 55bfaf3..f35f81a 100644 --- a/esplay-launcher/main/audio_player.c +++ b/esplay-launcher/main/audio_player.c @@ -219,6 +219,7 @@ static PlayerResult handle_cmd(PlayerState *const state, const AudioInfo info, c break; case PlayerCmdToggleLoopMode: state->playing_mode = (state->playing_mode + 1) % PlayingModeMax; + settings_save(SettingPlayingMode, (int32_t)state->playing_mode); push_audio_event(AudioPlayerEventStateChanged); break; case PlayerCmdTerminate: @@ -477,10 +478,7 @@ static void handle_keypress(event_keypad_t keys, bool *quit) if (!keys.last_state.values[GAMEPAD_INPUT_LEFT] && keys.state.values[GAMEPAD_INPUT_LEFT]) player_send_cmd(PlayerCmdPrev); if (!keys.last_state.values[GAMEPAD_INPUT_START] && keys.state.values[GAMEPAD_INPUT_START]) - { player_send_cmd(PlayerCmdToggleLoopMode); - settings_save(SettingPlayingMode, (int32_t)player_state.playing_mode); - } if (!keys.last_state.values[GAMEPAD_INPUT_SELECT] && keys.state.values[GAMEPAD_INPUT_SELECT]) { set_display_brightness(backlight_on ? 0 : 50); @@ -585,6 +583,7 @@ static void load_settings(PlayerState *state) int audio_player(AudioPlayerParam params) { + event_init(); memset(&player_state, 0, sizeof(PlayerState)); load_settings(&player_state); @@ -638,6 +637,7 @@ int audio_player(AudioPlayerParam params) player_terminate(); free_playlist(&player_state); keys_locked = false; + event_deinit(); set_display_brightness(50); return 0; diff --git a/esplay-launcher/main/event.c b/esplay-launcher/main/event.c index cf82098..ecfe6dc 100644 --- a/esplay-launcher/main/event.c +++ b/esplay-launcher/main/event.c @@ -7,14 +7,15 @@ #include static QueueHandle_t event_queue; +static bool event_running = false; static void keypad_task(void *arg) { + event_running = true; event_t event; - input_gamepad_state prevKey; gamepad_read(&prevKey); - while (true) { + while (event_running) { input_gamepad_state key; gamepad_read(&key); vTaskDelay(10 / portTICK_PERIOD_MS); @@ -27,6 +28,9 @@ static void keypad_task(void *arg) } prevKey = key; } + + vTaskDelete(NULL); + vQueueDelete(event_queue); } void event_init(void) @@ -35,6 +39,12 @@ void event_init(void) xTaskCreate(keypad_task, "keypad", 4096, NULL, 5, NULL); } +void event_deinit(void) +{ + event_running = false; + printf("Shutdown event..\n"); +} + int wait_event(event_t *event) { int got_event = xQueueReceive(event_queue, event, portMAX_DELAY); diff --git a/esplay-launcher/main/include/event.h b/esplay-launcher/main/include/event.h index fc20767..8bb6d8b 100644 --- a/esplay-launcher/main/include/event.h +++ b/esplay-launcher/main/include/event.h @@ -42,5 +42,6 @@ typedef union { } event_t; void event_init(void); +void event_deinit(void); int wait_event(event_t *event); int push_event(event_t *event); diff --git a/esplay-launcher/main/main.c b/esplay-launcher/main/main.c index 97fa60f..3a4bcd5 100755 --- a/esplay-launcher/main/main.c +++ b/esplay-launcher/main/main.c @@ -398,7 +398,6 @@ void app_main(void) audio_amp_disable(); gamepad_init(); - event_init(); // Display display_prepare(); @@ -589,13 +588,11 @@ void app_main(void) audio_player((AudioPlayerParam){new_entries, n_entries, 0, AUDIO_FILE_PATH, true}); fops_free_entries(&new_entries, n_entries); - // TODO : For some reason after audio_player close it won't play anymore so just restart for now - esp_restart(); - /* + + UG_FontSelect(&FONT_8X12); drawHomeScreen(); lastUpdate = 0; doRefresh = 1; - */ } // B Pressed instead of A diff --git a/esplay-sdk/esplay-components/esplay-hal/src/power.c b/esplay-sdk/esplay-components/esplay-hal/src/power.c index 44716ad..61dade9 100644 --- a/esplay-sdk/esplay-components/esplay-hal/src/power.c +++ b/esplay-sdk/esplay-components/esplay-hal/src/power.c @@ -147,11 +147,13 @@ static void battery_monitor_task() if (chrg == FULL_CHARGED || fixFull) { fullCtr++; + system_led_set(0); } if (chrg == CHARGING) { fullCtr = 0; + system_led_set(1); } if (fullCtr == 32) @@ -159,15 +161,6 @@ static void battery_monitor_task() fixFull = 1; } - if (fixFull) - { - system_led_set(0); - } - else - { - system_led_set(1); - } - if (chrg == NO_CHRG) { system_led_set(0);