main/task_sound.c

changeset 1
ad2c8b13eb88
parent 0
b74b0e4902c3
child 4
6d1f512cd074
equal deleted inserted replaced
0:b74b0e4902c3 1:ad2c8b13eb88
5 */ 5 */
6 6
7 #include "config.h" 7 #include "config.h"
8 8
9 9
10 #define PIEZO_BUZZER CONFIG_BUZZER_GPIO 10 #define PIEZO_BUZZER CONFIG_BUZZER_GPIO ///< GPIO pin with the piezo buzzer.
11 11
12 EventGroupHandle_t xEventGroupSound; 12 EventGroupHandle_t xEventGroupSound; ///< Event handle.
13 13
14 14
15 static const char *TAG = "task_sound"; 15 static const char *TAG = "task_sound";
16 16
17 const int SOUND_STARTUP = BIT0; ///< When set, play startup sound. 17 const int SOUND_STARTUP = BIT0; ///< When set, play startup sound.
21 const int SOUND_ADDHOP = BIT4; ///< When set, play add hop sound. 21 const int SOUND_ADDHOP = BIT4; ///< When set, play add hop sound.
22 const int SOUND_END = BIT5; ///< When set, play finished sound. 22 const int SOUND_END = BIT5; ///< When set, play finished sound.
23 const int SOUND_WARN = BIT6; ///< When set, play warning sound. 23 const int SOUND_WARN = BIT6; ///< When set, play warning sound.
24 24
25 25
26 const uint16_t _sound_Startup[] = { 50, 10, 10, 10, 10, 10, 10, 10, 10, 10, 200, 26 /* Sound arrays. The first value is the length, followed by the on and off times. */
27 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 27 static const uint16_t _sound_Startup[] = { 50, 10, 10, 10, 10, 10, 10, 10, 10, 10, 200,
28 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 28 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
29 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 29 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
30 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 }; 30 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
31 const uint16_t _sound_Prompt[] = { 2, 50, 125 }; 31 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 };
32 const uint16_t _sound_TempReached[] = { 6, 250, 75, 250, 75, 250, 75}; 32 static const uint16_t _sound_Prompt[] = { 2, 50, 125 };
33 const uint16_t _sound_TimeOut[] = {10, 25, 975, 25, 975, 25, 975, 25, 975, 500, 500 }; // 5 seconds 33 static const uint16_t _sound_TempReached[] = { 6, 250, 75, 250, 75, 250, 75};
34 const uint16_t _sound_AddHop[] = {18, 50, 50, 50, 50, 50, 225, 150, 50, 150, 50, 150, 225, 50, 50, 50 , 50 , 50, 50 }; 34 static const uint16_t _sound_TimeOut[] = { 10, 25, 975, 25, 975, 25, 975, 25, 975, 500, 500 }; // 5 seconds
35 const uint16_t _sound_End[] = { 2, 1000, 75 }; 35 static const uint16_t _sound_AddHop[] = { 18, 50, 50, 50, 50, 50, 225, 150, 50, 150, 50, 150, 225, 50, 50, 50 , 50 , 50, 50 };
36 const uint16_t _sound_Warn[] = { 6, 100, 75, 100, 75, 100, 50 }; 36 static const uint16_t _sound_End[] = { 2, 1000, 75 };
37 static const uint16_t _sound_Warn[] = { 6, 100, 75, 100, 75, 100, 50 };
37 38
38 39
39 40
41 /**
42 * @brief Play sounds on the piezo buzzer.
43 * @param sound The sound array.
44 */
40 void BuzzerPlay(const uint16_t *sound) 45 void BuzzerPlay(const uint16_t *sound)
41 { 46 {
42 for (int i = 1; i <= sound[0]; i += 2) { 47 for (int i = 1; i <= sound[0]; i += 2) {
43 gpio_set_level(PIEZO_BUZZER, 1); 48 gpio_set_level(PIEZO_BUZZER, 1);
44 vTaskDelay(sound[i] / portTICK_PERIOD_MS); 49 vTaskDelay(sound[i] / portTICK_PERIOD_MS);

mercurial