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

View File

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