device_envoy_esp/audio_player/
audio_player_generated.rs1#[cfg(all(not(doc), not(feature = "host"), target_os = "none"))]
8use crate::audio_player;
9
10#[cfg(all(not(doc), not(feature = "host"), target_os = "none"))]
11audio_player! {
12 pub AudioPlayerGenerated {
13 data_pin: GPIO21,
14 bit_clock_pin: GPIO12,
15 word_select_pin: GPIO13,
16 sample_rate_hz: crate::audio_player::VOICE_22050_HZ,
17 }
18}
19
20#[cfg(doc)]
21pub struct AudioPlayerGenerated;
34
35#[cfg(doc)]
36pub type AudioPlayerGeneratedPlayable = dyn Playable<VOICE_22050_HZ>;
41
42#[cfg(doc)]
43use crate::audio_player::{AtEnd, AudioPlayer, Playable, Volume, VOICE_22050_HZ};
44#[cfg(doc)]
45use crate::Result;
46
47#[cfg(doc)]
48impl AudioPlayerGenerated {
49 pub const SAMPLE_RATE_HZ: u32 = VOICE_22050_HZ;
53 pub const MAX_CLIPS: usize = 16;
55 pub const INITIAL_VOLUME: Volume = Volume::MAX;
57 pub const MAX_VOLUME: Volume = Volume::MAX;
59
60 pub fn new(
64 data_pin: impl Sized,
65 bit_clock_pin: impl Sized,
66 word_select_pin: impl Sized,
67 i2s: impl Sized,
68 dma: impl Sized,
69 spawner: embassy_executor::Spawner,
70 ) -> Result<&'static Self> {
71 static INSTANCE: AudioPlayerGenerated = AudioPlayerGenerated;
72 let _ = (data_pin, bit_clock_pin, word_select_pin, i2s, dma, spawner);
73 Ok(&INSTANCE)
74 }
75}
76
77#[cfg(doc)]
78impl AudioPlayer<VOICE_22050_HZ> for AudioPlayerGenerated {
79 const SAMPLE_RATE_HZ: u32 = VOICE_22050_HZ;
80 const MAX_CLIPS: usize = 16;
81 const INITIAL_VOLUME: Volume = Volume::MAX;
82 const MAX_VOLUME: Volume = Volume::MAX;
83
84 fn play<I>(&self, audio_clips: I, at_end: AtEnd)
85 where
86 I: IntoIterator<Item = &'static dyn Playable<VOICE_22050_HZ>>,
87 {
88 let _ = (audio_clips, at_end);
89 }
90
91 fn stop(&self) {}
92
93 async fn wait_until_stopped(&self) {}
94
95 fn set_volume(&self, volume: Volume) {
96 let _ = volume;
97 }
98
99 fn volume(&self) -> Volume {
100 Volume::MAX
101 }
102}