2021-01-25 11:07:05 +01:00
|
|
|
/*
|
2021-02-04 23:40:22 +01:00
|
|
|
Example sketch for the MiniDSP 2x4HD library - developed by Dennis Frett
|
2021-01-25 11:07:05 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <MiniDSP.h>
|
|
|
|
|
|
|
|
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
|
|
|
#ifdef dobogusinclude
|
|
|
|
#include <spi4teensy3.h>
|
|
|
|
#endif
|
|
|
|
#include <SPI.h>
|
|
|
|
|
|
|
|
USB Usb;
|
|
|
|
MiniDSP MiniDSP(&Usb);
|
|
|
|
|
2021-02-04 23:40:22 +01:00
|
|
|
void OnMiniDSPConnected() {
|
2021-02-05 11:49:23 +01:00
|
|
|
Serial.println("MiniDSP connected");
|
2021-02-04 23:40:22 +01:00
|
|
|
}
|
2021-01-25 11:07:05 +01:00
|
|
|
|
|
|
|
void OnVolumeChange(uint8_t volume) {
|
2021-02-05 11:49:23 +01:00
|
|
|
Serial.println("Volume is: " + String(volume));
|
2021-01-25 11:07:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void OnMutedChange(bool isMuted) {
|
2021-02-05 11:49:23 +01:00
|
|
|
Serial.println("Muted status: " + String(isMuted ? "muted" : "unmuted"));
|
2021-01-25 11:07:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void setup() {
|
2021-02-05 11:49:23 +01:00
|
|
|
Serial.begin(115200);
|
2021-01-25 11:07:05 +01:00
|
|
|
#if !defined(__MIPSEL__)
|
2021-02-05 11:49:23 +01:00
|
|
|
while(!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
|
2021-01-25 11:07:05 +01:00
|
|
|
#endif
|
2021-02-05 11:49:23 +01:00
|
|
|
if(Usb.Init() == -1) {
|
|
|
|
Serial.print(F("\r\nOSC did not start"));
|
|
|
|
while(1); // Halt
|
|
|
|
}
|
|
|
|
Serial.println(F("\r\nMiniDSP 2x4HD Library Started"));
|
|
|
|
|
|
|
|
// Register callbacks.
|
|
|
|
MiniDSP.attachOnInit(&OnMiniDSPConnected);
|
|
|
|
MiniDSP.attachOnVolumeChange(&OnVolumeChange);
|
|
|
|
MiniDSP.attachOnMutedChange(&OnMutedChange);
|
2021-01-25 11:07:05 +01:00
|
|
|
}
|
|
|
|
|
2021-02-04 23:40:22 +01:00
|
|
|
void loop() {
|
2021-02-05 11:49:23 +01:00
|
|
|
Usb.Task();
|
2021-02-04 23:40:22 +01:00
|
|
|
}
|