Start writing setup mode

This commit is contained in:
Neale Pickett 2020-11-23 18:11:19 -07:00
parent 28bcf63417
commit b65001ba84
1 changed files with 54 additions and 36 deletions

View File

@ -5,6 +5,7 @@
#include <SparkFun_Qwiic_Button.h> #include <SparkFun_Qwiic_Button.h>
#include <Adafruit_MPR121.h> #include <Adafruit_MPR121.h>
#include <paj7620.h> #include <paj7620.h>
#include <Fonts/FreeSans9pt7b.h>
#include "synth.h" #include "synth.h"
#include "patches.h" #include "patches.h"
#include "notes.h" #include "notes.h"
@ -218,10 +219,6 @@ void updateTunables(uint8_t buttons, int note) {
void loop() { void loop() {
static uint8_t last_note = 0;
bool updateDisplay = false;
bool setupMode = false;
pipe.Update(); pipe.Update();
#if defined(ADAFRUIT_TRELLIS_M4_EXPRESS) #if defined(ADAFRUIT_TRELLIS_M4_EXPRESS)
@ -231,31 +228,52 @@ void loop() {
trellis.setPixelColor(0, trellis.ColorHSV(64*pipe.kneeClosedness, 255, 120)); trellis.setPixelColor(0, trellis.ColorHSV(64*pipe.kneeClosedness, 255, 120));
#endif #endif
if (false) { // If we're infinitely (for the sensor) off the knee,
static uint16_t loopno = 0; // go into setup mode!
if (pipe.kneeClosedness == 0) {
doSetup();
} else {
doPlay();
}
}
display.clearDisplay(); /** doSetup performs "setup mode" behavior for the pipe.
display.setTextSize(1); *
display.setCursor(0, 0); * Setup mode sets the following new meanings to the buttons:
// display.print("mem: "); *
// display.print(AudioMemoryUsageMax()); * key: function [alternate]
// display.print(" prx: "); * C: Alt
// display.print(pipe.kneeClosedness); * B: Chanter
// display.setCursor(0, 24); * A: Regulators
// display.print("Note: "); * G: Drones
// display.print(pipe.note); * F: Up [+ coarse]
// display.print(" n: "); * E: Down [- coarse]
display.print(loopno++); * E: + [+ fine]
display.display(); * D: - [- fine]
*
*/
void doSetup() {
display.clearDisplay();
bool alt = bitRead(pipe.keys, 7);
display.fillRect(0, 0, 40, 32, SSD1306_WHITE);
display.setFont(&FreeSans9pt7b);
display.setCursor(1, 13);
display.setTextColor(SSD1306_BLACK);
if (alt) {
display.print("pipe");
} else {
display.print("alt");
} }
// If we're infinitely (for the sensor) off the knee, display.display();
// go into setup mode!
if (pipe.kneeClosedness == 0) {
setupMode = true;
updateDisplay = true;
} }
void doPlay() {
static uint8_t last_note = 0;
bool updateDisplay = false;
if (pipe.silent) { if (pipe.silent) {
Chanter.NoteOff(); Chanter.NoteOff();
} else { } else {
@ -284,7 +302,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 = "--";
@ -297,18 +315,18 @@ if (pipe.kneeClosedness == 0) {
if (updateDisplay) { if (updateDisplay) {
display.clearDisplay(); display.clearDisplay();
display.setCursor(0, 16);
display.setTextSize(2); display.setTextSize(2);
display.setCursor(0, 0);
display.print(Chanter.patch->name); display.print(Chanter.patch->name);
if (setupMode) { display.setCursor(0, 0);
// THE SETUP DONUT display.setTextSize(2);
display.fillCircle(128-8, 16+8, 4, SSD1306_WHITE); display.print(note_name);
display.fillCircle(128-8, 16+8, 2, SSD1306_BLACK);
} else { display.setCursor(40, 0);
display.setCursor(0, 8); display.setTextSize(1);
display.print(note_name); display.print(pipe.kneeClosedness);
}
display.display(); display.display();
last_note = pipe.note; last_note = pipe.note;