Get it working with SGTL5000
This commit is contained in:
parent
a12e5f6276
commit
28bcf63417
62
pipe.h
62
pipe.h
|
@ -6,46 +6,46 @@
|
||||||
#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;
|
||||||
|
|
||||||
// keys are which keys are being pressed.
|
// keys are which keys are being pressed.
|
||||||
uint8_t keys;
|
uint8_t keys;
|
||||||
|
|
||||||
// note holds the note being played, according to the fingering chart.
|
// note holds the note being played, according to the fingering chart.
|
||||||
uint8_t note;
|
uint8_t note;
|
||||||
|
|
||||||
// silent is true if all keys and the knee are closed.
|
// silent is true if all keys and the knee are closed.
|
||||||
bool silent;
|
bool silent;
|
||||||
|
|
||||||
// bag is true if the bag is being squished.
|
// bag is true if the bag is being squished.
|
||||||
bool bag;
|
bool bag;
|
||||||
|
|
||||||
// altFingering is true if the "alternate fingering" is being played.
|
// altFingering is true if the "alternate fingering" is being played.
|
||||||
// This should sound different than the standard fingering.
|
// This should sound different than the standard fingering.
|
||||||
bool altFingering;
|
bool altFingering;
|
||||||
|
|
||||||
// glissandoNote is the note that would be played if partially open keys were fully open.
|
// glissandoNote is the note that would be played if partially open keys were fully open.
|
||||||
uint8_t glissandoNote;
|
uint8_t glissandoNote;
|
||||||
|
|
||||||
// glissandoOpenness is how "open" the holes are in the direction of the glissandoNote.
|
// glissandoOpenness is how "open" the holes are in the direction of the glissandoNote.
|
||||||
float glissandoOpenness;
|
float glissandoOpenness;
|
||||||
|
|
||||||
Pipe();
|
Pipe();
|
||||||
|
|
||||||
// Init initializes everything.
|
// Init initializes everything.
|
||||||
//
|
//
|
||||||
// Returns true if it all worked. You can run it again if it didn't.
|
// Returns true if it all worked. You can run it again if it didn't.
|
||||||
bool Init();
|
bool Init();
|
||||||
|
|
||||||
// Update reads sensors and updates pipe state.
|
// Update reads sensors and updates pipe state.
|
||||||
//
|
//
|
||||||
// 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;
|
||||||
};
|
};
|
||||||
|
|
36
uilleann.ino
36
uilleann.ino
|
@ -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,11 +306,11 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
display.display();
|
display.display();
|
||||||
last_note = pipe.note;
|
last_note = pipe.note;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue