snapshot
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
The LyraT Mini is a bit tricky to use because it has a ES8311 which is handling the output and a
|
||||
ES7243 which is handling the microphone input: both need to be on separate I2S ports.
|
||||
|
||||
You should be able to use the examples that can be found in the [audiokit directory](https://github.com/pschatzmann/arduino-audio-tools/tree/main/examples/examples-audiokit): just replace the
|
||||
driver with LyratMini!
|
||||
|
||||
For the examples install:
|
||||
|
||||
- [Arduino AudioTools](https://github.com/pschatzmann/arduino-audio-tools)
|
||||
- [Arduino Audio Driver](https://github.com/pschatzmann/arduino-audio-driver)
|
||||
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @file buttons.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief Demo how to use the buttons.
|
||||
* @version 0.1
|
||||
* @date 2024-11-03
|
||||
*
|
||||
* The button values are determined with an analogRead(39) via the driver library.
|
||||
* This demo shows how to use the integrated AudioActions class via the AudioBoardStream
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*/
|
||||
|
||||
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
|
||||
AudioBoardStream lyrat(LyratMini);
|
||||
|
||||
void rec(bool, int, void*) {
|
||||
Serial.println("rec");
|
||||
}
|
||||
|
||||
void mode(bool, int, void*) {
|
||||
Serial.println("mode");
|
||||
}
|
||||
|
||||
void play(bool, int, void*) {
|
||||
Serial.println("play");
|
||||
}
|
||||
|
||||
void set(bool, int, void*) {
|
||||
Serial.println("set");
|
||||
}
|
||||
|
||||
void volUp(bool, int, void*) {
|
||||
Serial.println("vol+");
|
||||
}
|
||||
|
||||
void volDown(bool, int, void*) {
|
||||
Serial.println("vol-");
|
||||
}
|
||||
|
||||
|
||||
// Arduino Setup
|
||||
void setup(void) {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// start board
|
||||
lyrat.begin(lyrat.defaultConfig(TX_MODE));
|
||||
|
||||
lyrat.addAction(KEY_REC, rec);
|
||||
lyrat.addAction(KEY_MODE, mode);
|
||||
lyrat.addAction(KEY_PLAY, play);
|
||||
lyrat.addAction(KEY_SET, set);
|
||||
lyrat.addAction(KEY_VOLUME_UP, volUp);
|
||||
lyrat.addAction(KEY_VOLUME_DOWN, volDown);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
lyrat.processActions();
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
|
||||
/**
|
||||
* @file output.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief Demo how to use the microphone.
|
||||
* @version 0.1
|
||||
* @date 2024-11-03
|
||||
*
|
||||
* The microphone seems to be attached to 2 different i2s ports. In addition to the
|
||||
* ES8311, the ES7243 is also started.
|
||||
* The I2S pins can be selected via cfg.i2s_function: CODEC uses the ES8311 I2S pins
|
||||
* and CODEC_ADC uses the ES7243 I2S pins; By default the CODEC value is used.
|
||||
*
|
||||
* Only CODEC_ADC will give a proper microphone input!
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*/
|
||||
|
||||
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
|
||||
AudioInfo info(44100, 2, 16);
|
||||
AudioBoardStream i2s(LyratMini); // Access I2S as stream
|
||||
CsvOutput<int16_t> csvOutput(Serial);
|
||||
StreamCopy copier(csvOutput, i2s); // copy i2s to csvOutput
|
||||
|
||||
// Arduino Setup
|
||||
void setup(void) {
|
||||
Serial.begin(115200);
|
||||
// Display details what is going on
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
AudioDriverLogger.begin(Serial, AudioDriverLogLevel::Info);
|
||||
|
||||
auto cfg = i2s.defaultConfig(RX_MODE);
|
||||
cfg.copyFrom(info);
|
||||
// cfg.i2s_function = PinFunction::CODEC_ADC; // determined automatically
|
||||
// cfg.i2s_port_no = 0; // or 1 if 0 is already in use
|
||||
i2s.begin(cfg);
|
||||
|
||||
// make sure that we have the correct number of channels set up
|
||||
csvOutput.begin(info);
|
||||
|
||||
}
|
||||
|
||||
// Arduino loop - copy data
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* @file output.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief Demo to output audio on a lyrat-mini board: with headphone detection
|
||||
* active to switch the power amplifier on and off.
|
||||
* I2S is used and the ES8311 is initialized via the driver library.
|
||||
* @version 0.1
|
||||
* @date 2024-11-03
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*/
|
||||
|
||||
#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);
|
||||
// cfg.i2s_function = PinFunction::CODEC; // determined automatically
|
||||
// cfg.i2s_port_no = 0; // or 1 if 0 is already in use
|
||||
out.begin(config);
|
||||
|
||||
// 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();
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
|
||||
/**
|
||||
* @file sd.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief Test/Demo that SD is not working!
|
||||
* @version 0.1
|
||||
* @date 2024-11-03
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*/
|
||||
|
||||
#include <SPI.h>
|
||||
#include <SD.h>
|
||||
|
||||
// These pins are defined in the HAL
|
||||
#define PIN_SD_CARD_CS 13
|
||||
#define PIN_SD_CARD_MISO 2
|
||||
#define PIN_SD_CARD_MOSI 15
|
||||
#define PIN_SD_CARD_CLK 14
|
||||
#define PIN_SD_CARD_DET 34
|
||||
|
||||
|
||||
// Arduino Setup
|
||||
void setup(void) {
|
||||
Serial.begin(115200);
|
||||
|
||||
// setup SPI
|
||||
SPI.begin(PIN_SD_CARD_CLK, PIN_SD_CARD_MISO, PIN_SD_CARD_MOSI, PIN_SD_CARD_CS);
|
||||
|
||||
// Optionally determine if there is an SD card
|
||||
pinMode(PIN_SD_CARD_DET, INPUT);
|
||||
if (digitalRead(PIN_SD_CARD_DET)!=0){
|
||||
Serial.println("No SD Card detected");
|
||||
}
|
||||
|
||||
// Open SD library
|
||||
if (!SD.begin(PIN_SD_CARD_CS)){
|
||||
Serial.println("SD.begin failed");
|
||||
while(true);
|
||||
}
|
||||
|
||||
// Open an existing file
|
||||
auto file = SD.open("/audio8000.raw", FILE_READ);
|
||||
if (!file){
|
||||
Serial.println("file open failed");
|
||||
while(true);
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
||||
Serial.println("Success");
|
||||
}
|
||||
|
||||
// Arduino loop - repeated processing
|
||||
void loop() {}
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @file sdmmc.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief Test/Demo how to use the SD_MMC API in Arduino with the LyraT Mini
|
||||
* @version 0.1
|
||||
* @date 2024-11-03
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*/
|
||||
|
||||
#include "FS.h"
|
||||
#include "SD_MMC.h"
|
||||
|
||||
// These pins are defined in the HAL
|
||||
const int PIN_SD_CARD_POWER = 13;
|
||||
const int PIN_SD_CARD_DET = 34;
|
||||
|
||||
|
||||
// Arduino Setup
|
||||
void setup(void) {
|
||||
Serial.begin(115200);
|
||||
|
||||
// Mandatory: set power pin to low
|
||||
pinMode(PIN_SD_CARD_POWER, OUTPUT);
|
||||
digitalWrite(PIN_SD_CARD_POWER, LOW);
|
||||
|
||||
// Optionally: Determine if there is an SD card
|
||||
pinMode(PIN_SD_CARD_DET, INPUT);
|
||||
if (digitalRead(PIN_SD_CARD_DET)!=0){
|
||||
Serial.println("No SD Card detected");
|
||||
}
|
||||
|
||||
// open SDMMC in 1 bit mode
|
||||
if (!SD_MMC.begin("/sdcard", true)) {
|
||||
Serial.println("Card Mount Failed");
|
||||
while(true);
|
||||
}
|
||||
|
||||
// open an existing file
|
||||
auto file = SD_MMC.open("/test.mp3", FILE_READ);
|
||||
if (!file){
|
||||
Serial.println("file open failed");
|
||||
while(true);
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
||||
Serial.println("Success");
|
||||
}
|
||||
|
||||
// Arduino loop - repeated processing
|
||||
void loop() {}
|
||||
Reference in New Issue
Block a user