main/task_sound.c

branch
novnc
changeset 43
2079940c3989
parent 42
c6a1a6ca5437
child 54
7b134c27fadb
equal deleted inserted replaced
42:c6a1a6ca5437 43:2079940c3989
44 void BuzzerPlay(const uint16_t *sound) 44 void BuzzerPlay(const uint16_t *sound)
45 { 45 {
46 char msg[16]; 46 char msg[16];
47 47
48 for (int i = 1; i <= sound[0]; i += 2) { 48 for (int i = 1; i <= sound[0]; i += 2) {
49 gpio_set_level(PIEZO_BUZZER, 1);
50 if (sound != _sound_Startup) { 49 if (sound != _sound_Startup) {
51 snprintf(msg, 15, "{\"beep\":\"1\"}"); 50 snprintf(msg, 15, "{\"beep\":\"1\"}");
52 ws_server_send_text_clients("/ws", msg, strlen(msg)); 51 ws_server_send_text_clients("/ws", msg, strlen(msg));
53 } 52 }
53 gpio_set_level(PIEZO_BUZZER, 1);
54 vTaskDelay(sound[i] / portTICK_PERIOD_MS); 54 vTaskDelay(sound[i] / portTICK_PERIOD_MS);
55 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 // }
60 vTaskDelay(sound[i+1] / portTICK_PERIOD_MS); 56 vTaskDelay(sound[i+1] / portTICK_PERIOD_MS);
61 } 57 }
62 58
63 gpio_set_level(PIEZO_BUZZER, 0); // Just make sure the sound is off. 59 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));
66 } 60 }
67 61
68 62
69 63
70 void SoundPlay(int id) 64 void SoundPlay(int id)

mercurial