Skip to content

Commit

Permalink
fix audio player bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
pebri86 committed Dec 3, 2019
1 parent 680863f commit f2d9125
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
6 changes: 3 additions & 3 deletions esplay-launcher/main/audio_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down
14 changes: 12 additions & 2 deletions esplay-launcher/main/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
#include <string.h>

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);
Expand All @@ -27,6 +28,9 @@ static void keypad_task(void *arg)
}
prevKey = key;
}

vTaskDelete(NULL);
vQueueDelete(event_queue);
}

void event_init(void)
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions esplay-launcher/main/include/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
7 changes: 2 additions & 5 deletions esplay-launcher/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,6 @@ void app_main(void)
audio_amp_disable();

gamepad_init();
event_init();

// Display
display_prepare();
Expand Down Expand Up @@ -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
Expand Down
11 changes: 2 additions & 9 deletions esplay-sdk/esplay-components/esplay-hal/src/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,27 +147,20 @@ 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)
{
fixFull = 1;
}

if (fixFull)
{
system_led_set(0);
}
else
{
system_led_set(1);
}

if (chrg == NO_CHRG)
{
system_led_set(0);
Expand Down

0 comments on commit f2d9125

Please sign in to comment.