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

62
pipe.h
View File

@ -6,46 +6,46 @@
#include <paj7620.h>
class Pipe {
public:
// kneeClosedness indicates how "closed" the knee sensor is. 0 = wide open.
uint8_t kneeClosedness;
public:
// kneeClosedness indicates how "closed" the knee sensor is. 0 = wide open.
uint8_t kneeClosedness;
// keys are which keys are being pressed.
uint8_t keys;
// keys are which keys are being pressed.
uint8_t keys;
// note holds the note being played, according to the fingering chart.
uint8_t note;
// note holds the note being played, according to the fingering chart.
uint8_t note;
// silent is true if all keys and the knee are closed.
bool silent;
// silent is true if all keys and the knee are closed.
bool silent;
// bag is true if the bag is being squished.
bool bag;
// bag is true if the bag is being squished.
bool bag;
// altFingering is true if the "alternate fingering" is being played.
// This should sound different than the standard fingering.
bool altFingering;
// altFingering is true if the "alternate fingering" is being played.
// This should sound different than the standard fingering.
bool altFingering;
// glissandoNote is the note that would be played if partially open keys were fully open.
uint8_t glissandoNote;
// glissandoNote is the note that would be played if partially open keys were fully open.
uint8_t glissandoNote;
// glissandoOpenness is how "open" the holes are in the direction of the glissandoNote.
float glissandoOpenness;
// glissandoOpenness is how "open" the holes are in the direction of the glissandoNote.
float glissandoOpenness;
Pipe();
Pipe();
// Init initializes everything.
//
// Returns true if it all worked. You can run it again if it didn't.
bool Init();
// Init initializes everything.
//
// Returns true if it all worked. You can run it again if it didn't.
bool Init();
// Update reads sensors and updates pipe state.
//
// It should be run once per loop.
void Update();
// Update reads sensors and updates pipe state.
//
// It should be run once per loop.
void Update();
private:
Adafruit_MPR121 capSensor;
QwiicButton bagSensor;
bool bag_enabled;
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,11 +306,11 @@ 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);
}
display.display();
last_note = pipe.note;
last_note = pipe.note;
}
}