From 6487fcf4e657afcc6a5122a11c1a0c85fa93f40a Mon Sep 17 00:00:00 2001 From: pelgraine <140762863+pelgraine@users.noreply.github.com> Date: Wed, 3 Jun 2026 18:40:49 +1000 Subject: [PATCH] same fix --- examples/companion_radio/ui-new/Alarmscreen.h | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/examples/companion_radio/ui-new/Alarmscreen.h b/examples/companion_radio/ui-new/Alarmscreen.h index 68cc6998..0cb7b57b 100644 --- a/examples/companion_radio/ui-new/Alarmscreen.h +++ b/examples/companion_radio/ui-new/Alarmscreen.h @@ -38,6 +38,13 @@ // Forward declarations class UITask; +#ifdef HAS_ES8311_AUDIO +// Defined in target.cpp (where the board object + ES8311 driver are visible). +// Forward-declared here so this UI header doesn't need the heavy target.h. +void meck_audio_route_amp(); +void meck_audio_codec_init(); +#endif + // ============================================================================ // Configuration // ============================================================================ @@ -322,16 +329,31 @@ private: delay(100); // Cold-start needs longer than 50ms // Configure I2S pins (must be done after any stopSong that resets I2S) +#ifdef HAS_ES8311_AUDIO + // MAX: route to the ES8311 + enable the speaker amp, then configure I2S + // WITH MCLK (the ES8311 is clock slave and needs MCLK on BOARD_I2S_MCLK). + // The codec registers are initialised after connecttoFS starts the clocks. + meck_audio_route_amp(); + bool ok = _audio->setPinout(BOARD_I2S_BCLK, BOARD_I2S_LRC, BOARD_I2S_DOUT, + I2S_PIN_NO_CHANGE, BOARD_I2S_MCLK); +#else bool ok = _audio->setPinout(BOARD_I2S_BCLK, BOARD_I2S_LRC, BOARD_I2S_DOUT, 0); if (!ok) { ok = _audio->setPinout(BOARD_I2S_BCLK, BOARD_I2S_LRC, BOARD_I2S_DOUT); } +#endif if (!ok) { Serial.println("ALARM: setPinout FAILED"); } // Connect to file FIRST, then set volume (matches audiobook working pattern) _audio->connecttoFS(SD, soundFile.c_str()); +#ifdef HAS_ES8311_AUDIO + // MAX: I2S clocks are now running, so initialise the ES8311 codec (once; + // idempotent). Without this, alarm audio is silent until a notification + // tone happens to bring the codec up. + meck_audio_codec_init(); +#endif _audio->setVolume(slot.volume); _alarmAudioActive = true; _resolvedSoundPath = soundFile; // Store for restart loop