Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwittig committed May 31, 2020
1 parent baaefd7 commit 1f218fa
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ git submodule update --init --recursive

## TODO

- [ ] Store volume and read value on start
- [ ] Store last play position and play from last position
- [ ] Store volume and read value on start
- [ ] write empty file with TAG no if file is not found
- [ ] fast forward / rewind
- [ ] can we us the internal event system to connect I2C/RFID?
35 changes: 32 additions & 3 deletions main/toniebox.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <string.h>

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
Expand Down Expand Up @@ -138,7 +139,7 @@ static void sound_task(void *arg) {
ESP_LOGI(TAG, "Event received [source_type: %d, cmd: %d]", msg.source_type, msg.cmd);

// volume down
if ((int)msg.data == get_input_rec_id() && msg.cmd == PERIPH_BUTTON_PRESSED) {
if ((int)msg.data == get_input_rec_id() && msg.cmd == PERIPH_BUTTON_RELEASE) {
int player_volume;
audio_hal_get_volume(board_handle->audio_hal, &player_volume);
player_volume -= 3;
Expand All @@ -150,8 +151,22 @@ static void sound_task(void *arg) {
continue;
}

// start: rewind
if ((int)msg.data == get_input_rec_id() && msg.cmd == PERIPH_BUTTON_LONG_PRESSED) {

ESP_LOGI(TAG, "rewind start");
continue;
}

// stop: rewind
if ((int)msg.data == get_input_rec_id() && msg.cmd == PERIPH_BUTTON_LONG_RELEASE) {

ESP_LOGI(TAG, "rewind stop");
continue;
}

// volume up
if ((int)msg.data == get_input_mode_id() && msg.cmd == PERIPH_BUTTON_PRESSED) {
if ((int)msg.data == get_input_mode_id() && msg.cmd == PERIPH_BUTTON_RELEASE) {
int player_volume;
audio_hal_get_volume(board_handle->audio_hal, &player_volume);
player_volume += 3;
Expand All @@ -163,14 +178,28 @@ static void sound_task(void *arg) {
continue;
}

// start: fast-forward
if ((int)msg.data == get_input_mode_id() && msg.cmd == PERIPH_BUTTON_LONG_PRESSED) {

ESP_LOGI(TAG, "fast-forward start");
continue;
}

// stop: fast-forward
if ((int)msg.data == get_input_mode_id() && msg.cmd == PERIPH_BUTTON_LONG_RELEASE) {

ESP_LOGI(TAG, "fast-forward stop");
continue;
}

// start file
if (msg.source_type == AUDIO_ELEMENT_TYPE_ELEMENT && msg.source == (void *) mp3_decoder
&& msg.cmd == AEL_MSG_CMD_REPORT_MUSIC_INFO) {
audio_element_info_t music_info = {0};
audio_element_getinfo(mp3_decoder, &music_info);

ESP_LOGI(TAG, "Receive music info from mp3 decoder, sample_rates=%d, bits=%d, ch=%d",
music_info.sample_rates, music_info.bits, music_info.channels);
music_info.sample_rates, music_info.bits, music_info.channels);

audio_element_setinfo(i2s_stream_writer, &music_info);
i2s_stream_set_clk(i2s_stream_writer, music_info.sample_rates, music_info.bits, music_info.channels);
Expand Down

0 comments on commit 1f218fa

Please sign in to comment.