Skip to content

Commit

Permalink
Lyrat Mini example
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Nov 1, 2024
1 parent 00accd5 commit 9213f4c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
36 changes: 36 additions & 0 deletions examples/examples-custom-boards/lyrat-mini/output/outout.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Demo to output audio on a lyrat-mini board: with headphone detection active
// to switch the power amplifier on and off

#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"

AudioInfo info(44100, 2, 16);
SineWaveGenerator<int16_t> sineWave(32000); // subclass of SoundGenerator with max amplitude of 32000
GeneratedSoundStream<int16_t> sound(sineWave); // Stream generated from sine wave
AudioBoardStream out(LyratMini);
StreamCopy copier(out, sound); // copies sound into i2s

// Arduino Setup
void setup(void) {
// Open Serial
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);

// start I2S
Serial.println("starting I2S...");
auto config = out.defaultConfig(TX_MODE);
config.copyFrom(info);

// additinal settings
out.setVolume(0.5);
out.addHeadphoneDetectionAction();

// start sine wave
sineWave.begin(info, N_B4);
Serial.println("started...");
}

void loop() {
copier.copy();
out.processActions();
}
4 changes: 2 additions & 2 deletions src/AudioTools/AudioLibs/AudioBoardStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ class AudioBoardStream : public I2SCodecStream {
}

/// Adds headphone determination
void addHeadphonDetectionAction() {
void addHeadphoneDetectionAction() {
// pin conflicts with AIThinker A101: key6 and headphone detection
int head_phone = pinHeadphoneDetect();
if (head_phone != -1 && (getPinID(PinFunction::KEY, 6) != head_phone)) {
Expand All @@ -323,7 +323,7 @@ class AudioBoardStream : public I2SCodecStream {
*/
void addDefaultActions() {
TRACEI();
addHeadphonDetectionAction();
addHeadphoneDetectionAction();
addStartStopAction();
addVolumeActions();
}
Expand Down

0 comments on commit 9213f4c

Please sign in to comment.