Get it working with SGTL5000

This commit is contained in:
Neale Pickett 2020-11-22 17:21:47 -07:00
parent a12e5f6276
commit 28bcf63417
2 changed files with 53 additions and 45 deletions

4
pipe.h
View File

@ -6,7 +6,7 @@
#include <paj7620.h>
class Pipe {
public:
public:
// kneeClosedness indicates how "closed" the knee sensor is. 0 = wide open.
uint8_t kneeClosedness;
@ -44,7 +44,7 @@ class Pipe {
// It should be run once per loop.
void Update();
private:
private:
Adafruit_MPR121 capSensor;
QwiicButton bagSensor;
bool bag_enabled;

View File

@ -12,7 +12,7 @@
#if defined(ADAFRUIT_TRELLIS_M4_EXPRESS)
#include <Adafruit_NeoTrellisM4.h>
Adafruit_NeoTrellisM4 trellis = Adafruit_NeoTrellisM4();
Adafruit_NeoTrellisM4 trellis;// = Adafruit_NeoTrellisM4();
#endif
#define DRONES
@ -39,6 +39,8 @@ AudioOutputAnalogStereo out1;
AudioOutputI2S out1;
#endif
AudioControlSGTL5000 sgtl5000;
AudioConnection FMVoicePatchCords[] = {
//{0, 0, 0, 0}, // For some reason, the first one is ignored
@ -119,6 +121,10 @@ void setup() {
// Set aside some memory for the audio library
AudioMemory(20);
// Set up the SGTL5000 using I2C
sgtl5000.enable();
sgtl5000.volume(0.3);
// initialize tunables
updateTunables(3, 0);
@ -221,22 +227,24 @@ void loop() {
#if defined(ADAFRUIT_TRELLIS_M4_EXPRESS)
trellis.tick();
trellis.setPixelColor(0, trellis.ColorHSV(120*pipe.kneeClosedness));
trellis.setPixelColor(1, trellis.ColorHSV(millis(), 255, 120));
trellis.setPixelColor(0, trellis.ColorHSV(64*pipe.kneeClosedness, 255, 120));
#endif
static uint16_t loopno = 0;
if (false) {
static uint16_t loopno = 0;
display.clearDisplay();
display.setTextSize(1);
display.setCursor(0, 0);
display.print("mem: ");
display.print(AudioMemoryUsageMax());
display.print(" prx: ");
display.print(pipe.kneeClosedness);
display.setCursor(0, 24);
display.print("Note: ");
display.print(pipe.note);
display.print(" n: ");
// display.print("mem: ");
// display.print(AudioMemoryUsageMax());
// display.print(" prx: ");
// display.print(pipe.kneeClosedness);
// display.setCursor(0, 24);
// display.print("Note: ");
// display.print(pipe.note);
// display.print(" n: ");
display.print(loopno++);
display.display();
}
@ -276,7 +284,7 @@ if (pipe.kneeClosedness == 0) {
}
}
// Look up the note name
// // Look up the note name
const char *note_name = NoteNames[pipe.note % 12];
if (pipe.silent) {
note_name = "--";
@ -298,7 +306,7 @@ if (pipe.kneeClosedness == 0) {
display.fillCircle(128-8, 16+8, 4, SSD1306_WHITE);
display.fillCircle(128-8, 16+8, 2, SSD1306_BLACK);
} else {
display.setCursor(0, 16);
display.setCursor(0, 8);
display.print(note_name);
}