Boot chime through ES8311: audio-out path verified on hardware
Test, Build and Push / test-gateway (push) Successful in 10s
Test, Build and Push / release (push) Skipped
Test, Build and Push / build-gateway (push) Skipped

C5->E5 half-second chime with fade-out at boot, right after the face
renders. Codec opens in slave mode, esp_codec_dev write path works.
Phase 1 bring-up is now complete: display, touch, audio, 200MHz PSRAM.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-14 20:34:59 +02:00
co-authored by Claude Fable 5
parent 450bac1c81
commit 60c73e135c
+40
View File
@@ -10,12 +10,51 @@
* Current stage: bring-up — display + a placeholder face.
*/
#include <math.h>
#include <stdlib.h>
#include "esp_log.h"
#include "bsp/esp-bsp.h"
#include "esp_codec_dev.h"
#include "lvgl.h"
static const char *TAG = "desklock";
#define CHIME_RATE 16000
#define CHIME_SAMPLES (CHIME_RATE / 2) /* 0.5 s */
/* Bring-up proof for the audio path: C5 -> E5 with a fade-out. */
static void play_boot_chime(void)
{
esp_codec_dev_handle_t spk = bsp_audio_codec_speaker_init();
if (spk == NULL) {
ESP_LOGW(TAG, "speaker init failed — no chime");
return;
}
esp_codec_dev_sample_info_t fs = {
.sample_rate = CHIME_RATE,
.channel = 1,
.bits_per_sample = 16,
};
esp_codec_dev_set_out_vol(spk, 70);
esp_codec_dev_open(spk, &fs);
int16_t *buf = malloc(CHIME_SAMPLES * sizeof(int16_t));
if (buf != NULL) {
float phase = 0.0f;
for (int i = 0; i < CHIME_SAMPLES; i++) {
float freq = (i < CHIME_SAMPLES / 2) ? 523.25f : 659.25f;
phase += 2.0f * (float)M_PI * freq / CHIME_RATE;
float envelope = 1.0f - (float)i / CHIME_SAMPLES;
buf[i] = (int16_t)(sinf(phase) * 12000.0f * envelope);
}
esp_codec_dev_write(spk, buf, CHIME_SAMPLES * sizeof(int16_t));
free(buf);
ESP_LOGI(TAG, "boot chime played");
}
esp_codec_dev_close(spk);
}
static void show_placeholder_face(void)
{
bsp_display_lock(0);
@@ -50,6 +89,7 @@ void app_main(void)
bsp_display_start();
bsp_display_backlight_on();
show_placeholder_face();
play_boot_chime();
ESP_LOGI(TAG, "DeskLock up (placeholder face)");