-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathPlaySounds.cpp
More file actions
executable file
·30 lines (26 loc) · 833 Bytes
/
PlaySounds.cpp
File metadata and controls
executable file
·30 lines (26 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <esp_log.h>
#include <driver/uart.h>
#include "DYPlayerESP32.h"
#define TAG "dyplayer"
// Initialise the player on uart2, pins TX: 18, RX: 19.
DY::Player player(UART_NUM_2, 18, 19);
extern "C" void app_main(void)
{
vTaskDelay(1000 / portTICK_PERIOD_MS);
player.setVolume(15); // 50% Volume
ESP_LOGI(TAG, "Sound count: %u", (uint8_t)player.getSoundCount());
while (true)
{
// Change to next sound after 5 seconds (non-blocking call so will cut off
// currently playing sound if any).
for (uint8_t i = 1; i < player.getSoundCount(); i++)
{
player.playSpecified(i);
ESP_LOGI(TAG, "Playing song %d", player.getPlayingSound());
vTaskDelay(5000 / portTICK_PERIOD_MS);
}
vTaskDelay(10000 / portTICK_PERIOD_MS);
}
}