main/task_sound.c

branch
novnc
changeset 42
c6a1a6ca5437
parent 38
537ffe280775
child 43
2079940c3989
equal deleted inserted replaced
41:7639cfa6aec0 42:c6a1a6ca5437
41 * @brief Play sounds on the piezo buzzer. 41 * @brief Play sounds on the piezo buzzer.
42 * @param sound The sound array. 42 * @param sound The sound array.
43 */ 43 */
44 void BuzzerPlay(const uint16_t *sound) 44 void BuzzerPlay(const uint16_t *sound)
45 { 45 {
46 char msg[16];
47
46 for (int i = 1; i <= sound[0]; i += 2) { 48 for (int i = 1; i <= sound[0]; i += 2) {
47 gpio_set_level(PIEZO_BUZZER, 1); 49 gpio_set_level(PIEZO_BUZZER, 1);
50 if (sound != _sound_Startup) {
51 snprintf(msg, 15, "{\"beep\":\"1\"}");
52 ws_server_send_text_clients("/ws", msg, strlen(msg));
53 }
48 vTaskDelay(sound[i] / portTICK_PERIOD_MS); 54 vTaskDelay(sound[i] / portTICK_PERIOD_MS);
49 gpio_set_level(PIEZO_BUZZER, 0); 55 gpio_set_level(PIEZO_BUZZER, 0);
56 // if (sound != _sound_Startup) {
57 // snprintf(msg, 15, "{\"beep\":\"0\"}");
58 // ws_server_send_text_clients("/ws", msg, strlen(msg));
59 // }
50 vTaskDelay(sound[i+1] / portTICK_PERIOD_MS); 60 vTaskDelay(sound[i+1] / portTICK_PERIOD_MS);
51 } 61 }
52 62
53 gpio_set_level(PIEZO_BUZZER, 0); // Just make sure the sound is off. 63 gpio_set_level(PIEZO_BUZZER, 0); // Just make sure the sound is off.
64 // snprintf(msg, 15, "{\"beep\":\"0\"}");
65 // ws_server_send_text_clients("/ws", msg, strlen(msg));
54 } 66 }
55 67
56 68
57 69
58 void SoundPlay(int id) 70 void SoundPlay(int id)

mercurial