basic rework of UI for rev 2
This commit is contained in:
@ -10,12 +10,12 @@
|
|||||||
#define SCREEN_ADDRESS 0x3C
|
#define SCREEN_ADDRESS 0x3C
|
||||||
|
|
||||||
#define PPQN 24
|
#define PPQN 24
|
||||||
#define PULSE_LENGTH 12 //ms (with 12 ms you can't get higher than 208bpm)
|
#define PULSE_LENGTH 12 //ms (with 12 ms you can't get higher than 208bpm)
|
||||||
#define MAXBPM 200 //250 at 24ppqn with 5ms pulse will be 50/50 square wave
|
#define MAXBPM 200 //250 at 24ppqn with 5ms pulse will be 50/50 square wave
|
||||||
#define MINBPM 20
|
#define MINBPM 20
|
||||||
#define SCREEN_TIMEOUT 300000 //Turn display off after 5 min
|
#define SCREEN_TIMEOUT 600000 //Turn display off after 5 min
|
||||||
|
|
||||||
///* Rev 1 Config
|
/* Rev 1 Config
|
||||||
#define ENC_BTN_PIN 14
|
#define ENC_BTN_PIN 14
|
||||||
#define ENC_D1_PIN 17
|
#define ENC_D1_PIN 17
|
||||||
#define ENC_D2_PIN 4
|
#define ENC_D2_PIN 4
|
||||||
@ -26,35 +26,35 @@
|
|||||||
#define ANALOGUE_INPUT_2_PIN A1
|
#define ANALOGUE_INPUT_2_PIN A1
|
||||||
|
|
||||||
const int outsPins[6] = {6, 11, 7, 10, 8, 9};
|
const int outsPins[6] = {6, 11, 7, 10, 8, 9};
|
||||||
//*/
|
*/
|
||||||
|
|
||||||
/* Rev 2 Config
|
///* Rev 2 Config
|
||||||
#define ENC_BTN_PIN 14
|
#define ENC_BTN_PIN 14
|
||||||
#define ENC_D1_PIN 17
|
#define ENC_D1_PIN 17
|
||||||
#define ENC_D2_PIN 4
|
#define ENC_D2_PIN 4
|
||||||
#define START_STOP_BTN_PIN 5
|
#define START_STOP_BTN_PIN 5
|
||||||
#define SHIFT_BTN_PIN 12
|
#define SHIFT_BTN_PIN 12
|
||||||
|
|
||||||
#define EXT_INPUT_PIN 2 //needs to be an interrupt pin
|
#define EXT_INPUT_PIN 2 //needs to be an interrupt pin
|
||||||
#define ANALOGUE_INPUT_1_PIN A7
|
#define ANALOGUE_INPUT_1_PIN A7
|
||||||
#define ANALOGUE_INPUT_2_PIN A6
|
#define ANALOGUE_INPUT_2_PIN A6
|
||||||
|
|
||||||
const int outsPins[6] = {7, 8, 10, 6, 9, 11};
|
const int outsPins[6] = { 7, 8, 10, 6, 9, 11 };
|
||||||
*/
|
//*/
|
||||||
|
|
||||||
|
|
||||||
const int clockModes[17] = {-24, -12, -8, -6, -4, -3, -2, 1, 2, 3, 4, 5, 6, 7, 8, 16, 32}; //positive - divide, negative - multiply, 0 - off
|
const int clockModes[17] = { -24, -12, -8, -6, -4, -3, -2, 1, 2, 3, 4, 5, 6, 7, 8, 16, 32 }; //positive - divide, negative - multiply, 0 - off
|
||||||
|
|
||||||
unsigned int bpm = 130;
|
unsigned int bpm = 130;
|
||||||
bool bpmModulationChannel; //0 - CV1, 1 - CV2
|
bool bpmModulationChannel; //0 - CV1, 1 - CV2
|
||||||
byte bpmModulationRange = 0;
|
byte bpmModulationRange = 0;
|
||||||
|
|
||||||
struct channel {
|
struct channel {
|
||||||
unsigned int mode;
|
unsigned int mode;
|
||||||
unsigned int random;
|
unsigned int random;
|
||||||
bool modulationChannel; //0 - CV1, 1 - CV2
|
bool modulationChannel; //0 - CV1, 1 - CV2
|
||||||
int modulationRange;
|
int modulationRange;
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
channel channels[6] = { //array of channel settings
|
channel channels[6] = { //array of channel settings
|
||||||
@ -68,7 +68,7 @@ channel channels[6] = { //array of channel settings
|
|||||||
|
|
||||||
int channelPulseCount[6];
|
int channelPulseCount[6];
|
||||||
int channelPulsesPerCycle[6];
|
int channelPulsesPerCycle[6];
|
||||||
int playingModes[6]; //actual channel modes array updated from channels object on each beat
|
int playingModes[6]; //actual channel modes array updated from channels object on each beat
|
||||||
|
|
||||||
unsigned int pulsePeriod;
|
unsigned int pulsePeriod;
|
||||||
bool isPlaying = false;
|
bool isPlaying = false;
|
||||||
@ -78,11 +78,11 @@ unsigned int pulseCount = 0;
|
|||||||
unsigned int extTriggerCount = 0;
|
unsigned int extTriggerCount = 0;
|
||||||
byte extResetCountdown = 0;
|
byte extResetCountdown = 0;
|
||||||
|
|
||||||
byte masterClockMode = 0; // 0 - internal, 1 - external 24ppqn, 2 - external beat
|
byte masterClockMode = 0; // 0 - internal, 1 - external 24ppqn, 2 - external beat
|
||||||
unsigned long lastExtPulseTime;
|
unsigned long lastExtPulseTime;
|
||||||
unsigned long newExtPulseTime;
|
unsigned long newExtPulseTime;
|
||||||
|
|
||||||
bool needPulseReset[6] = {true, true, true, true, true, true};
|
bool needPulseReset[6] = { true, true, true, true, true, true };
|
||||||
|
|
||||||
unsigned int displayTab = 0;
|
unsigned int displayTab = 0;
|
||||||
unsigned int displayTabOld;
|
unsigned int displayTabOld;
|
||||||
@ -97,31 +97,32 @@ unsigned long encPressedTime;
|
|||||||
unsigned long encReleasedTime;
|
unsigned long encReleasedTime;
|
||||||
bool encPressRegistered;
|
bool encPressRegistered;
|
||||||
|
|
||||||
unsigned long lastInteractionTime; // used for display timeout
|
unsigned long lastInteractionTime; // used for display timeout
|
||||||
|
|
||||||
Adafruit_SSD1306 display(128, 64, &Wire, -1);
|
Adafruit_SSD1306 display(128, 64, &Wire, -1);
|
||||||
RotaryEncoder encoder(ENC_D1_PIN, ENC_D2_PIN, RotaryEncoder::LatchMode::TWO03);
|
RotaryEncoder encoder(ENC_D1_PIN, ENC_D2_PIN, RotaryEncoder::LatchMode::TWO03);
|
||||||
|
|
||||||
const unsigned char splash_logo [] PROGMEM = {
|
const unsigned char splash_logo[] PROGMEM = {
|
||||||
0x00, 0x1f, 0xfc, 0x00, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x01, 0xff, 0xff, 0xc0, 0x00, 0x03,
|
0x00, 0x1f, 0xfc, 0x00, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x01, 0xff, 0xff, 0xc0, 0x00, 0x03,
|
||||||
0xfc, 0x1f, 0xe0, 0x00, 0x07, 0xe0, 0x03, 0xf0, 0x00, 0x0f, 0x80, 0x00, 0xf8, 0x00, 0x1f, 0x00,
|
0xfc, 0x1f, 0xe0, 0x00, 0x07, 0xe0, 0x03, 0xf0, 0x00, 0x0f, 0x80, 0x00, 0xf8, 0x00, 0x1f, 0x00,
|
||||||
0x00, 0x7c, 0x00, 0x1e, 0x00, 0x00, 0x3c, 0x00, 0x3c, 0x00, 0x00, 0x1e, 0x00, 0x3c, 0x00, 0x00,
|
0x00, 0x7c, 0x00, 0x1e, 0x00, 0x00, 0x3c, 0x00, 0x3c, 0x00, 0x00, 0x1e, 0x00, 0x3c, 0x00, 0x00,
|
||||||
0x1e, 0x00, 0x78, 0x0c, 0x18, 0x0f, 0x00, 0x78, 0x1e, 0x3c, 0x0f, 0x00, 0x70, 0x1e, 0x3c, 0x07,
|
0x1e, 0x00, 0x78, 0x0c, 0x18, 0x0f, 0x00, 0x78, 0x1e, 0x3c, 0x0f, 0x00, 0x70, 0x1e, 0x3c, 0x07,
|
||||||
0x00, 0xf0, 0x1e, 0x3c, 0x07, 0x80, 0xf0, 0x1e, 0x3c, 0x07, 0x80, 0xf0, 0x1e, 0x3c, 0x07, 0x80,
|
0x00, 0xf0, 0x1e, 0x3c, 0x07, 0x80, 0xf0, 0x1e, 0x3c, 0x07, 0x80, 0xf0, 0x1e, 0x3c, 0x07, 0x80,
|
||||||
0xf0, 0x1e, 0x3c, 0x07, 0x80, 0xf0, 0x0c, 0x18, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0xf0, 0x1e, 0x3c, 0x07, 0x80, 0xf0, 0x0c, 0x18, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x04, 0x0c, 0x18, 0x10, 0x00, 0x0f, 0x1e, 0x3c, 0x78, 0x00, 0x0f, 0x1e,
|
0x00, 0x00, 0x00, 0x00, 0x04, 0x0c, 0x18, 0x10, 0x00, 0x0f, 0x1e, 0x3c, 0x78, 0x00, 0x0f, 0x1e,
|
||||||
0x3c, 0x78, 0x00, 0x1e, 0x0c, 0x18, 0x3c, 0x00, 0x1e, 0x00, 0x00, 0x3c, 0x00, 0x3c, 0x00, 0x00,
|
0x3c, 0x78, 0x00, 0x1e, 0x0c, 0x18, 0x3c, 0x00, 0x1e, 0x00, 0x00, 0x3c, 0x00, 0x3c, 0x00, 0x00,
|
||||||
0x1e, 0x00, 0x3c, 0x00, 0x00, 0x1e, 0x00, 0x78, 0x00, 0x00, 0x0f, 0x00, 0x78, 0x00, 0x00, 0x0f,
|
0x1e, 0x00, 0x3c, 0x00, 0x00, 0x1e, 0x00, 0x78, 0x00, 0x00, 0x0f, 0x00, 0x78, 0x00, 0x00, 0x0f,
|
||||||
0x00, 0xf0, 0x00, 0x00, 0x07, 0x80, 0xf0, 0x00, 0x00, 0x07, 0x80, 0xf0, 0x00, 0x00, 0x07, 0x80,
|
0x00, 0xf0, 0x00, 0x00, 0x07, 0x80, 0xf0, 0x00, 0x00, 0x07, 0x80, 0xf0, 0x00, 0x00, 0x07, 0x80,
|
||||||
0x78, 0x00, 0x00, 0x0f, 0x00, 0x7c, 0x00, 0x00, 0x1f, 0x00, 0x3e, 0x00, 0x00, 0x3e, 0x00, 0x3f,
|
0x78, 0x00, 0x00, 0x0f, 0x00, 0x7c, 0x00, 0x00, 0x1f, 0x00, 0x3e, 0x00, 0x00, 0x3e, 0x00, 0x3f,
|
||||||
0xff, 0xff, 0xfe, 0x00, 0x1f, 0xff, 0xff, 0xfc, 0x00, 0x07, 0xff, 0xff, 0xf0, 0x00, 0x01, 0xff,
|
0xff, 0xff, 0xfe, 0x00, 0x1f, 0xff, 0xff, 0xfc, 0x00, 0x07, 0xff, 0xff, 0xf0, 0x00, 0x01, 0xff,
|
||||||
0xff, 0xc0, 0x00
|
0xff, 0xc0, 0x00
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
//Serial.begin(9600);
|
//Serial.begin(9600);
|
||||||
|
|
||||||
//check last bit in eeprom to know if the correct settings were stored
|
//check last bit in eeprom to know if the correct settings were stored
|
||||||
if (EEPROM.read(1023) == 'S') {
|
if (EEPROM.read(1023) == 'S') {
|
||||||
int addr = 0;
|
int addr = 0;
|
||||||
EEPROM.get(addr, bpm);
|
EEPROM.get(addr, bpm);
|
||||||
@ -144,17 +145,19 @@ void setup() {
|
|||||||
pinMode(EXT_INPUT_PIN, INPUT_PULLUP);
|
pinMode(EXT_INPUT_PIN, INPUT_PULLUP);
|
||||||
attachInterrupt(digitalPinToInterrupt(EXT_INPUT_PIN), externalClock, FALLING);
|
attachInterrupt(digitalPinToInterrupt(EXT_INPUT_PIN), externalClock, FALLING);
|
||||||
|
|
||||||
for (int i=0; i<6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
pinMode(outsPins[i], OUTPUT);
|
pinMode(outsPins[i], OUTPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);
|
display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);
|
||||||
|
display.setRotation(2);
|
||||||
|
display.clearDisplay();
|
||||||
|
|
||||||
//Splash screen
|
//Splash screen
|
||||||
display.clearDisplay();
|
//displayLogo();
|
||||||
//display.setRotation(2); //rotate display for rev 2
|
display.drawBitmap(48, 0, splash_logo, 33, 39, 1);
|
||||||
display.drawBitmap(48, 18, splash_logo, 33, 39, 1);
|
|
||||||
display.setCursor(90,1);
|
display.setCursor(0, 56);
|
||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
display.setTextColor(SSD1306_WHITE);
|
display.setTextColor(SSD1306_WHITE);
|
||||||
display.print(F("V:"));
|
display.print(F("V:"));
|
||||||
@ -166,16 +169,16 @@ void setup() {
|
|||||||
calculateCycles();
|
calculateCycles();
|
||||||
calculateBPMTiming();
|
calculateBPMTiming();
|
||||||
|
|
||||||
FlexiTimer2::set(1, 1.0/1000, clock); // 1.0/1000 = 1ms period. If other than 1ms calculateBPMTiming() might need tweaking
|
FlexiTimer2::set(1, 1.0 / 1000, clock); // 1.0/1000 = 1ms period. If other than 1ms calculateBPMTiming() might need tweaking
|
||||||
FlexiTimer2::start();
|
FlexiTimer2::start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
checkInputs();
|
checkInputs();
|
||||||
if ((millis() - lastInteractionTime) > SCREEN_TIMEOUT) {
|
/*if ((millis() - lastInteractionTime) > SCREEN_TIMEOUT) {
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
display.display();
|
display.display();
|
||||||
}
|
}*/
|
||||||
if (masterClockMode == 2 || masterClockMode == 3) {
|
if (masterClockMode == 2 || masterClockMode == 3) {
|
||||||
calculateBPMTiming();
|
calculateBPMTiming();
|
||||||
}
|
}
|
||||||
@ -195,7 +198,7 @@ void clock() {
|
|||||||
if (masterClockMode == 0) {
|
if (masterClockMode == 0) {
|
||||||
if (tickCount >= pulsePeriod) {
|
if (tickCount >= pulsePeriod) {
|
||||||
tickCount = 0;
|
tickCount = 0;
|
||||||
if (pulseCount < (PPQN-1)) { //-1 is here to avoid extra IF to reset to 0
|
if (pulseCount < (PPQN - 1)) { //-1 is here to avoid extra IF to reset to 0
|
||||||
pulseCount++;
|
pulseCount++;
|
||||||
} else {
|
} else {
|
||||||
pulseCount = 0;
|
pulseCount = 0;
|
||||||
@ -208,7 +211,7 @@ void clock() {
|
|||||||
|
|
||||||
//EXT-B
|
//EXT-B
|
||||||
if (masterClockMode == 2) {
|
if (masterClockMode == 2) {
|
||||||
if (tickCount >= pulsePeriod && pulseCount < (PPQN-1)) {
|
if (tickCount >= pulsePeriod && pulseCount < (PPQN - 1)) {
|
||||||
tickCount = 0;
|
tickCount = 0;
|
||||||
pulseCount++;
|
pulseCount++;
|
||||||
}
|
}
|
||||||
@ -216,7 +219,7 @@ void clock() {
|
|||||||
|
|
||||||
//EXT-16
|
//EXT-16
|
||||||
if (masterClockMode == 3) {
|
if (masterClockMode == 3) {
|
||||||
if (tickCount >= pulsePeriod && pulseCount < (PPQN-1)) { // ((6 * (extTriggerCount + 1)) - 1)) { //this formula puts it out of sync, so there's PPQN-1 for now
|
if (tickCount >= pulsePeriod && pulseCount < (PPQN - 1)) { // ((6 * (extTriggerCount + 1)) - 1)) { //this formula puts it out of sync, so there's PPQN-1 for now
|
||||||
tickCount = 0;
|
tickCount = 0;
|
||||||
pulseCount++;
|
pulseCount++;
|
||||||
}
|
}
|
||||||
@ -225,11 +228,10 @@ void clock() {
|
|||||||
|
|
||||||
// pull low all outputs after set pulse length
|
// pull low all outputs after set pulse length
|
||||||
if (tickCount >= PULSE_LENGTH) {
|
if (tickCount >= PULSE_LENGTH) {
|
||||||
for (int i = 0; i<6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
digitalWrite(outsPins[i], LOW);
|
digitalWrite(outsPins[i], LOW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,17 +241,17 @@ void externalClock() {
|
|||||||
|
|
||||||
if (masterClockMode == 1) { // EXT-24
|
if (masterClockMode == 1) { // EXT-24
|
||||||
//reset cycles if there was no pulses for a while
|
//reset cycles if there was no pulses for a while
|
||||||
if ((newExtPulseTime - lastExtPulseTime) > 125) { //125ms is 20bpm
|
if ((newExtPulseTime - lastExtPulseTime) > 125) { //125ms is 20bpm
|
||||||
for (int i = 0; i<6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
channelPulseCount[i] = 0;
|
channelPulseCount[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isPlaying) {
|
if (!isPlaying) {
|
||||||
isPlaying = true;
|
isPlaying = true;
|
||||||
}
|
}
|
||||||
tickCount = 0; //to make things happen in the main clock function
|
tickCount = 0; //to make things happen in the main clock function
|
||||||
if (pulseCount < (PPQN-1)) {
|
if (pulseCount < (PPQN - 1)) {
|
||||||
pulseCount++;
|
pulseCount++;
|
||||||
} else {
|
} else {
|
||||||
pulseCount = 0;
|
pulseCount = 0;
|
||||||
@ -259,17 +261,17 @@ void externalClock() {
|
|||||||
if (!isPlaying) {
|
if (!isPlaying) {
|
||||||
isPlaying = true;
|
isPlaying = true;
|
||||||
}
|
}
|
||||||
if ((newExtPulseTime - lastExtPulseTime) > 3000) { //3000ms is 1/4 at 20bpm
|
if ((newExtPulseTime - lastExtPulseTime) > 3000) { //3000ms is 1/4 at 20bpm
|
||||||
resetClocks();
|
resetClocks();
|
||||||
extResetCountdown = 0;
|
extResetCountdown = 0;
|
||||||
}
|
}
|
||||||
tickCount = 0;
|
tickCount = 0;
|
||||||
pulseCount = 0;
|
pulseCount = 0;
|
||||||
if (extResetCountdown < 1) { //reset on the second pulse, so that BPM is already calculated correctly
|
if (extResetCountdown < 1) { //reset on the second pulse, so that BPM is already calculated correctly
|
||||||
extResetCountdown++;
|
extResetCountdown++;
|
||||||
} else if (extResetCountdown == 1) {
|
} else if (extResetCountdown == 1) {
|
||||||
resetClocks();
|
resetClocks();
|
||||||
extResetCountdown++; //to get out of the loop
|
extResetCountdown++; //to get out of the loop
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (masterClockMode == 3) { // EXT-16
|
} else if (masterClockMode == 3) { // EXT-16
|
||||||
@ -281,8 +283,8 @@ void externalClock() {
|
|||||||
extResetCountdown = 0;
|
extResetCountdown = 0;
|
||||||
extTriggerCount = 0;
|
extTriggerCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extTriggerCount == 0) { //happens on beat
|
if (extTriggerCount == 0) { //happens on beat
|
||||||
pulseCount = 0;
|
pulseCount = 0;
|
||||||
tickCount = 0;
|
tickCount = 0;
|
||||||
}
|
}
|
||||||
@ -292,20 +294,18 @@ void externalClock() {
|
|||||||
extTriggerCount = 0;
|
extTriggerCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extResetCountdown < 4) { //reset on the second beat (5th pulse), so that BPM is already calculated correctly
|
if (extResetCountdown < 4) { //reset on the second beat (5th pulse), so that BPM is already calculated correctly
|
||||||
extResetCountdown++;
|
extResetCountdown++;
|
||||||
} else if (extResetCountdown == 4) {
|
} else if (extResetCountdown == 4) {
|
||||||
resetClocks();
|
resetClocks();
|
||||||
extResetCountdown++; //to get out of the loop
|
extResetCountdown++; //to get out of the loop
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendTriggers() {
|
void sendTriggers() {
|
||||||
|
|
||||||
for (int i = 0; i<6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
if (playingModes[i] != clockModes[channels[i].mode]) {
|
if (playingModes[i] != clockModes[channels[i].mode]) {
|
||||||
needPulseReset[i] = true;
|
needPulseReset[i] = true;
|
||||||
}
|
}
|
||||||
@ -314,7 +314,7 @@ void sendTriggers() {
|
|||||||
//switching modes on the beat and resetting channel clock
|
//switching modes on the beat and resetting channel clock
|
||||||
if (pulseCount == 0) {
|
if (pulseCount == 0) {
|
||||||
calculateCycles();
|
calculateCycles();
|
||||||
for (int i = 0; i<6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
if (needPulseReset[i] == true) {
|
if (needPulseReset[i] == true) {
|
||||||
channelPulseCount[i] = 0;
|
channelPulseCount[i] = 0;
|
||||||
needPulseReset[i] = false;
|
needPulseReset[i] = false;
|
||||||
@ -323,23 +323,23 @@ void sendTriggers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//multiplier
|
//multiplier
|
||||||
for (int i = 0; i<6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
if (channelPulseCount[i] == channels[i].offset) { //Pulse on 0
|
if (channelPulseCount[i] == channels[i].offset) { //Pulse on 0
|
||||||
if (channels[i].random == 0 || random(10) > channels[i].random) { //random
|
if (channels[i].random == 0 || random(10) > channels[i].random) { //random
|
||||||
digitalWrite(outsPins[i], HIGH);
|
digitalWrite(outsPins[i], HIGH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (channelPulseCount[i] < channelPulsesPerCycle[i]) {
|
if (channelPulseCount[i] < channelPulsesPerCycle[i]) {
|
||||||
channelPulseCount[i]++;
|
channelPulseCount[i]++;
|
||||||
} else {
|
} else {
|
||||||
channelPulseCount[i] = 0;
|
channelPulseCount[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void calculateCycles() {
|
void calculateCycles() {
|
||||||
|
|
||||||
for (int i = 0; i<6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
if (channels[i].modulationRange == 0) {
|
if (channels[i].modulationRange == 0) {
|
||||||
playingModes[i] = clockModes[channels[i].mode];
|
playingModes[i] = clockModes[channels[i].mode];
|
||||||
} else { //modulation happens here
|
} else { //modulation happens here
|
||||||
@ -349,8 +349,8 @@ void calculateCycles() {
|
|||||||
} else {
|
} else {
|
||||||
mod = a2Input;
|
mod = a2Input;
|
||||||
}
|
}
|
||||||
mod = map (mod, 0, 1023, 0, channels[i].modulationRange);
|
mod = map(mod, 0, 1023, 0, channels[i].modulationRange);
|
||||||
playingModes[i] = clockModes[channels[i].mode - mod]; //subtracting because the innitiall array is backwards
|
playingModes[i] = clockModes[channels[i].mode - mod]; //subtracting because the innitiall array is backwards
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playingModes[i] > 0) {
|
if (playingModes[i] > 0) {
|
||||||
@ -358,32 +358,31 @@ void calculateCycles() {
|
|||||||
} else {
|
} else {
|
||||||
channelPulsesPerCycle[i] = (PPQN / abs(playingModes[i])) - 1;
|
channelPulsesPerCycle[i] = (PPQN / abs(playingModes[i])) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void calculateBPMTiming() {
|
void calculateBPMTiming() {
|
||||||
int mod = 0;
|
int mod = 0;
|
||||||
if (masterClockMode == 0) { //Internal clock
|
if (masterClockMode == 0) { //Internal clock
|
||||||
if (bpmModulationRange != 0 && !bpmModulationChannel) {
|
if (bpmModulationRange != 0 && !bpmModulationChannel) {
|
||||||
mod = map (a1Input, 0, 1023, 0, bpmModulationRange*10);
|
mod = map(a1Input, 0, 1023, 0, bpmModulationRange * 10);
|
||||||
} else if (bpmModulationRange != 0 && bpmModulationChannel) {
|
} else if (bpmModulationRange != 0 && bpmModulationChannel) {
|
||||||
mod = map (a2Input, 0, 1023, 0, bpmModulationRange*10);
|
mod = map(a2Input, 0, 1023, 0, bpmModulationRange * 10);
|
||||||
}
|
}
|
||||||
pulsePeriod = 60000 / ((bpm + mod) * PPQN);
|
pulsePeriod = 60000 / ((bpm + mod) * PPQN);
|
||||||
|
|
||||||
} else if (masterClockMode == 2) { //for external beat clock
|
} else if (masterClockMode == 2) { //for external beat clock
|
||||||
pulsePeriod = (newExtPulseTime - lastExtPulseTime) / PPQN;
|
pulsePeriod = (newExtPulseTime - lastExtPulseTime) / PPQN;
|
||||||
|
|
||||||
} else if (masterClockMode == 3) { //for ext 1/16 clock (hardcoded)
|
} else if (masterClockMode == 3) { //for ext 1/16 clock (hardcoded)
|
||||||
pulsePeriod = (newExtPulseTime - lastExtPulseTime) / 6;
|
pulsePeriod = (newExtPulseTime - lastExtPulseTime) / 6;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetClocks() {
|
void resetClocks() {
|
||||||
for (int i = 0; i<6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
channelPulseCount[i] = 0;
|
channelPulseCount[i] = 0;
|
||||||
digitalWrite(outsPins[i], LOW); //to avoid stuck leds
|
digitalWrite(outsPins[i], LOW); //to avoid stuck leds
|
||||||
}
|
}
|
||||||
pulseCount = 0;
|
pulseCount = 0;
|
||||||
tickCount = 0;
|
tickCount = 0;
|
||||||
@ -412,22 +411,22 @@ void checkInputs() {
|
|||||||
encPressRegistered = false;
|
encPressRegistered = false;
|
||||||
encReleasedTime = millis();
|
encReleasedTime = millis();
|
||||||
|
|
||||||
if (encReleasedTime - encPressedTime < 500) { // press shorter than .5s switches tabs
|
if (encReleasedTime - encPressedTime < 500) { // press shorter than .5s switches tabs
|
||||||
if (insideTab == 0) {
|
if (insideTab == 0) {
|
||||||
displayTabOld = displayTab;
|
displayTabOld = displayTab;
|
||||||
displayTab++;
|
displayTab++;
|
||||||
if (displayTab>6) {
|
if (displayTab > 6) {
|
||||||
displayTab = 0;
|
displayTab = 0;
|
||||||
}
|
}
|
||||||
} else if (insideTab < 3 && displayTab != 0) {
|
} else if (insideTab < 3 && displayTab != 0) {
|
||||||
insideTab ++;
|
insideTab++;
|
||||||
} else if (insideTab < 2 && displayTab == 0) {
|
} else if (insideTab < 2 && displayTab == 0) {
|
||||||
insideTab ++;
|
insideTab++;
|
||||||
} else {
|
} else {
|
||||||
insideTab = 1;
|
insideTab = 1;
|
||||||
}
|
}
|
||||||
updateScreen();
|
updateScreen();
|
||||||
} else if (encReleasedTime - encPressedTime < 2000) { // longer press (<2s) and switches random mode, longer than 2s presses are ignored
|
} else if (encReleasedTime - encPressedTime < 2000) { // longer press (<2s) and switches random mode, longer than 2s presses are ignored
|
||||||
if (insideTab == 0) {
|
if (insideTab == 0) {
|
||||||
insideTab = 1;
|
insideTab = 1;
|
||||||
} else {
|
} else {
|
||||||
@ -451,7 +450,7 @@ void checkInputs() {
|
|||||||
}
|
}
|
||||||
calculateBPMTiming();
|
calculateBPMTiming();
|
||||||
|
|
||||||
} else if (displayTab == 0 && insideTab == 1) { //Clock mode
|
} else if (displayTab == 0 && insideTab == 1) { //Clock mode
|
||||||
masterClockMode = masterClockMode + change;
|
masterClockMode = masterClockMode + change;
|
||||||
if (masterClockMode > 250) {
|
if (masterClockMode > 250) {
|
||||||
masterClockMode = 0;
|
masterClockMode = 0;
|
||||||
@ -471,49 +470,49 @@ void checkInputs() {
|
|||||||
bpmModulationChannel = 1;
|
bpmModulationChannel = 1;
|
||||||
} else if (bpmModulationRange > 9 && bpmModulationChannel == 1) {
|
} else if (bpmModulationRange > 9 && bpmModulationChannel == 1) {
|
||||||
bpmModulationRange = 9;
|
bpmModulationRange = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (displayTab != 0 && insideTab == 0) { //subdivision
|
} else if (displayTab != 0 && insideTab == 0) { //subdivision
|
||||||
channels[displayTab-1].mode = channels[displayTab-1].mode - change;
|
channels[displayTab - 1].mode = channels[displayTab - 1].mode - change;
|
||||||
if (channels[displayTab-1].mode == 65535) { //65535 is 0-1 for unsigned vars
|
if (channels[displayTab - 1].mode == 65535) { //65535 is 0-1 for unsigned vars
|
||||||
channels[displayTab-1].mode = 0;
|
channels[displayTab - 1].mode = 0;
|
||||||
} else if (channels[displayTab-1].mode > (sizeof(clockModes)/sizeof(int)) - 1) {
|
} else if (channels[displayTab - 1].mode > (sizeof(clockModes) / sizeof(int)) - 1) {
|
||||||
channels[displayTab-1].mode = (sizeof(clockModes)/sizeof(int)) - 1;
|
channels[displayTab - 1].mode = (sizeof(clockModes) / sizeof(int)) - 1;
|
||||||
}
|
}
|
||||||
if (!isPlaying) {
|
if (!isPlaying) {
|
||||||
calculateCycles();
|
calculateCycles();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (displayTab != 0 && insideTab == 1) { //random
|
} else if (displayTab != 0 && insideTab == 1) { //random
|
||||||
channels[displayTab-1].random = channels[displayTab-1].random + change;
|
channels[displayTab - 1].random = channels[displayTab - 1].random + change;
|
||||||
if (channels[displayTab-1].random == 65535) {
|
if (channels[displayTab - 1].random == 65535) {
|
||||||
channels[displayTab-1].random = 0;
|
channels[displayTab - 1].random = 0;
|
||||||
} else if (channels[displayTab-1].random > 9) {
|
} else if (channels[displayTab - 1].random > 9) {
|
||||||
channels[displayTab-1].random = 9;
|
channels[displayTab - 1].random = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (displayTab != 0 && insideTab == 2) { //modulation
|
} else if (displayTab != 0 && insideTab == 2) { //modulation
|
||||||
channels[displayTab-1].modulationRange = channels[displayTab-1].modulationRange + change;
|
channels[displayTab - 1].modulationRange = channels[displayTab - 1].modulationRange + change;
|
||||||
if (channels[displayTab-1].modulationRange < 0 && channels[displayTab-1].modulationChannel == 0) {
|
if (channels[displayTab - 1].modulationRange < 0 && channels[displayTab - 1].modulationChannel == 0) {
|
||||||
channels[displayTab-1].modulationRange = 0;
|
channels[displayTab - 1].modulationRange = 0;
|
||||||
} else if (channels[displayTab-1].modulationRange > 6 && channels[displayTab-1].modulationChannel == 0) {
|
} else if (channels[displayTab - 1].modulationRange > 6 && channels[displayTab - 1].modulationChannel == 0) {
|
||||||
channels[displayTab-1].modulationChannel = 1;
|
channels[displayTab - 1].modulationChannel = 1;
|
||||||
channels[displayTab-1].modulationRange = 0;
|
channels[displayTab - 1].modulationRange = 0;
|
||||||
} else if (channels[displayTab-1].modulationRange < 0 && channels[displayTab-1].modulationChannel == 1) {
|
} else if (channels[displayTab - 1].modulationRange < 0 && channels[displayTab - 1].modulationChannel == 1) {
|
||||||
channels[displayTab-1].modulationChannel = 0;
|
channels[displayTab - 1].modulationChannel = 0;
|
||||||
channels[displayTab-1].modulationRange = 6;
|
channels[displayTab - 1].modulationRange = 6;
|
||||||
} else if (channels[displayTab-1].modulationRange > 6 && channels[displayTab-1].modulationChannel == 1) {
|
} else if (channels[displayTab - 1].modulationRange > 6 && channels[displayTab - 1].modulationChannel == 1) {
|
||||||
channels[displayTab-1].modulationRange = 6;
|
channels[displayTab - 1].modulationRange = 6;
|
||||||
}
|
|
||||||
|
|
||||||
} else if (displayTab != 0 && insideTab == 3) { //offset
|
|
||||||
channels[displayTab-1].offset = channels[displayTab-1].offset + change;
|
|
||||||
if (channels[displayTab-1].offset == 65535) {
|
|
||||||
channels[displayTab-1].offset = 0;
|
|
||||||
} else if (channels[displayTab-1].offset >= channelPulsesPerCycle[displayTab-1]) {
|
|
||||||
channels[displayTab-1].offset = channelPulsesPerCycle[displayTab-1];
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
} else if (displayTab != 0 && insideTab == 3) { //offset
|
||||||
|
channels[displayTab - 1].offset = channels[displayTab - 1].offset + change;
|
||||||
|
if (channels[displayTab - 1].offset == 65535) {
|
||||||
|
channels[displayTab - 1].offset = 0;
|
||||||
|
} else if (channels[displayTab - 1].offset >= channelPulsesPerCycle[displayTab - 1]) {
|
||||||
|
channels[displayTab - 1].offset = channelPulsesPerCycle[displayTab - 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
updateScreen();
|
updateScreen();
|
||||||
encPositionOld = encPosition;
|
encPositionOld = encPosition;
|
||||||
}
|
}
|
||||||
@ -527,7 +526,7 @@ void checkInputs() {
|
|||||||
}
|
}
|
||||||
playBtnPushed = true;
|
playBtnPushed = true;
|
||||||
saveState();
|
saveState();
|
||||||
updateScreen(); //to wake up the screen if turned off
|
updateScreen(); //to wake up the screen if turned off
|
||||||
} else if (digitalRead(START_STOP_BTN_PIN) && playBtnPushed) {
|
} else if (digitalRead(START_STOP_BTN_PIN) && playBtnPushed) {
|
||||||
playBtnPushed = false;
|
playBtnPushed = false;
|
||||||
}
|
}
|
||||||
@ -537,168 +536,3 @@ void checkInputs() {
|
|||||||
a2Input = analogRead(ANALOGUE_INPUT_2_PIN);
|
a2Input = analogRead(ANALOGUE_INPUT_2_PIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateScreen() {
|
|
||||||
display.clearDisplay();
|
|
||||||
|
|
||||||
lastInteractionTime = millis(); //not sure if it's a right place for this, but should do for now
|
|
||||||
|
|
||||||
//Tabs
|
|
||||||
display.drawRect(0, 0, 128, 2, SSD1306_WHITE);
|
|
||||||
display.setCursor(0,2);
|
|
||||||
display.setTextSize(1);
|
|
||||||
if (displayTab == 0) {
|
|
||||||
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
|
|
||||||
display.print(F(" "));
|
|
||||||
display.setTextColor(SSD1306_WHITE);
|
|
||||||
display.print(F(" bpm "));
|
|
||||||
} else {
|
|
||||||
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
|
|
||||||
display.print(F(" bpm"));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 1; i <= 6; i++) {
|
|
||||||
if (displayTab == i) {
|
|
||||||
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
|
|
||||||
display.print(" ");
|
|
||||||
display.setTextColor(SSD1306_WHITE);
|
|
||||||
display.print(" ");
|
|
||||||
display.print(i);
|
|
||||||
display.print(" ");
|
|
||||||
} else {
|
|
||||||
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
|
|
||||||
display.print(" ");
|
|
||||||
display.print(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
|
|
||||||
display.fillRect(108, 2, 20, 8, SSD1306_WHITE);
|
|
||||||
display.println();
|
|
||||||
display.println();
|
|
||||||
display.fillRect(0, 10, 128, 2, SSD1306_WHITE);
|
|
||||||
|
|
||||||
//Content
|
|
||||||
display.setCursor(4,16);
|
|
||||||
display.setTextSize(3);
|
|
||||||
display.setTextColor(SSD1306_WHITE);
|
|
||||||
if (displayTab == 0 && masterClockMode == 0) {
|
|
||||||
if (bpm<100) {
|
|
||||||
display.print(" ");
|
|
||||||
}
|
|
||||||
display.println(bpm);
|
|
||||||
display.setCursor(21,40);
|
|
||||||
display.setTextSize(2);
|
|
||||||
display.println(F("bpm"));
|
|
||||||
} else if (displayTab == 0 && masterClockMode == 1) {
|
|
||||||
display.println(F(" 24"));
|
|
||||||
display.setCursor(8,40);
|
|
||||||
display.setTextSize(2);
|
|
||||||
display.println(F("PPQN"));
|
|
||||||
} else if (displayTab == 0 && masterClockMode == 2) {
|
|
||||||
display.setCursor(8,16);
|
|
||||||
display.setTextSize(2);
|
|
||||||
display.println(F("BEAT"));
|
|
||||||
} else if (displayTab == 0 && masterClockMode == 3) {
|
|
||||||
display.setCursor(8,16);
|
|
||||||
display.setTextSize(2);
|
|
||||||
display.println(F("1/16"));
|
|
||||||
} else {
|
|
||||||
if (clockModes[channels[displayTab-1].mode] == 0) {
|
|
||||||
display.print(F("OFF"));
|
|
||||||
} else if (clockModes[channels[displayTab-1].mode]>0) {
|
|
||||||
display.print(F("/"));
|
|
||||||
display.print(abs(clockModes[channels[displayTab-1].mode]));
|
|
||||||
} else {
|
|
||||||
display.print(F("x"));
|
|
||||||
display.print(abs(clockModes[channels[displayTab-1].mode]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
display.println();
|
|
||||||
display.setTextSize(1);
|
|
||||||
display.println();
|
|
||||||
|
|
||||||
//Extra params
|
|
||||||
display.setCursor(58,16);
|
|
||||||
display.setTextSize(1);
|
|
||||||
if (displayTab == 0) {
|
|
||||||
if (insideTab == 1) {
|
|
||||||
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
|
|
||||||
} else {
|
|
||||||
display.setTextColor(SSD1306_WHITE);
|
|
||||||
}
|
|
||||||
display.print(F(" CLK:"));
|
|
||||||
if (masterClockMode == 1) {
|
|
||||||
display.println(F("EXT24 "));
|
|
||||||
} else if (masterClockMode == 2) {
|
|
||||||
display.println(F("EXT-B "));
|
|
||||||
} else if (masterClockMode == 3) {
|
|
||||||
display.println(F("EXT16 "));
|
|
||||||
} else {
|
|
||||||
display.println(F("INT "));
|
|
||||||
}
|
|
||||||
if (insideTab == 2) {
|
|
||||||
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
|
|
||||||
} else {
|
|
||||||
display.setTextColor(SSD1306_WHITE);
|
|
||||||
}
|
|
||||||
display.setCursor(58,30);
|
|
||||||
display.print(F(" MOD:"));
|
|
||||||
if (bpmModulationRange != 0 && masterClockMode == 0) {
|
|
||||||
display.print(F("CV"));
|
|
||||||
display.print(bpmModulationChannel+1);
|
|
||||||
display.print("+");
|
|
||||||
display.print(bpmModulationRange * 10);
|
|
||||||
} else {
|
|
||||||
display.print(F("Off "));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (insideTab == 1) {
|
|
||||||
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
|
|
||||||
} else {
|
|
||||||
display.setTextColor(SSD1306_WHITE);
|
|
||||||
}
|
|
||||||
display.print(F(" RND:"));
|
|
||||||
if (channels[displayTab-1].random > 0) {
|
|
||||||
display.print(channels[displayTab-1].random);
|
|
||||||
display.print(F("0% "));
|
|
||||||
} else {
|
|
||||||
display.print(F("Off "));
|
|
||||||
}
|
|
||||||
if (insideTab == 2) {
|
|
||||||
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
|
|
||||||
} else {
|
|
||||||
display.setTextColor(SSD1306_WHITE);
|
|
||||||
}
|
|
||||||
display.setCursor(58,30);
|
|
||||||
display.print(F(" MOD:"));
|
|
||||||
if (channels[displayTab-1].modulationChannel && channels[displayTab-1].modulationRange != 0) {
|
|
||||||
display.print(F("CV2"));
|
|
||||||
if (channels[displayTab-1].modulationRange > 0) {
|
|
||||||
display.print(F("+"));
|
|
||||||
}
|
|
||||||
display.print(channels[displayTab-1].modulationRange);
|
|
||||||
display.print(F(" "));
|
|
||||||
} else if (!channels[displayTab-1].modulationChannel && channels[displayTab-1].modulationRange != 0) {
|
|
||||||
display.print(F("CV1"));
|
|
||||||
if (channels[displayTab-1].modulationRange > 0) {
|
|
||||||
display.print(F("+"));
|
|
||||||
}
|
|
||||||
display.print(channels[displayTab-1].modulationRange);
|
|
||||||
display.print(F(" "));
|
|
||||||
} else {
|
|
||||||
display.print(F("Off "));
|
|
||||||
}
|
|
||||||
if (insideTab == 3) {
|
|
||||||
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
|
|
||||||
} else {
|
|
||||||
display.setTextColor(SSD1306_WHITE);
|
|
||||||
}
|
|
||||||
display.setCursor(58,44);
|
|
||||||
display.print(F(" OFT:"));
|
|
||||||
display.print(channels[displayTab-1].offset);
|
|
||||||
display.print(F("/"));
|
|
||||||
display.print(channelPulsesPerCycle[displayTab-1]+1);
|
|
||||||
display.print(F(" "));
|
|
||||||
}
|
|
||||||
|
|
||||||
display.display();
|
|
||||||
}
|
|
||||||
162
software/GToE/UI.ino
Normal file
162
software/GToE/UI.ino
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
void updateScreen() {
|
||||||
|
display.clearDisplay();
|
||||||
|
|
||||||
|
lastInteractionTime = millis(); //not sure if it's a right place for this, but should do for now
|
||||||
|
|
||||||
|
//Tabs
|
||||||
|
display.drawRect(0, 48, 128, 1, SSD1306_WHITE);
|
||||||
|
display.setCursor(0, 50);
|
||||||
|
display.setTextSize(1);
|
||||||
|
if (displayTab == 0) {
|
||||||
|
//display.setTextColor(SSD1306_WHITE, SSD1306_BLACK);
|
||||||
|
//display.print(F(" "));
|
||||||
|
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
|
||||||
|
display.print(F(" bpm "));
|
||||||
|
} else {
|
||||||
|
display.setTextColor(SSD1306_WHITE, SSD1306_BLACK);
|
||||||
|
display.print(F(" bpm"));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 1; i <= 6; i++) {
|
||||||
|
if (displayTab == i) {
|
||||||
|
display.setTextColor(SSD1306_WHITE, SSD1306_BLACK);
|
||||||
|
display.print(" ");
|
||||||
|
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
|
||||||
|
display.print(" ");
|
||||||
|
display.print(i);
|
||||||
|
display.print(" ");
|
||||||
|
} else {
|
||||||
|
display.setTextColor(SSD1306_WHITE, SSD1306_BLACK);
|
||||||
|
display.print(" ");
|
||||||
|
display.print(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
|
||||||
|
//display.fillRect(108, 60, 20, 8, SSD1306_WHITE);
|
||||||
|
//display.println();
|
||||||
|
//display.println();
|
||||||
|
//display.fillRect(0, 10, 128, 2, SSD1306_WHITE);
|
||||||
|
|
||||||
|
//Content
|
||||||
|
display.setCursor(4, 0);
|
||||||
|
display.setTextSize(3);
|
||||||
|
display.setTextColor(SSD1306_WHITE);
|
||||||
|
if (displayTab == 0 && masterClockMode == 0) {
|
||||||
|
if (bpm < 100) {
|
||||||
|
display.print(" ");
|
||||||
|
}
|
||||||
|
display.println(bpm);
|
||||||
|
display.setCursor(21, 24);
|
||||||
|
display.setTextSize(2);
|
||||||
|
display.println(F("bpm"));
|
||||||
|
} else if (displayTab == 0 && masterClockMode == 1) {
|
||||||
|
display.println(F(" 24"));
|
||||||
|
display.setCursor(8, 24);
|
||||||
|
display.setTextSize(2);
|
||||||
|
display.println(F("PPQN"));
|
||||||
|
} else if (displayTab == 0 && masterClockMode == 2) {
|
||||||
|
display.setCursor(8, 8);
|
||||||
|
display.setTextSize(2);
|
||||||
|
display.println(F("BEAT"));
|
||||||
|
} else if (displayTab == 0 && masterClockMode == 3) {
|
||||||
|
display.setCursor(8, 8);
|
||||||
|
display.setTextSize(2);
|
||||||
|
display.println(F("1/16"));
|
||||||
|
} else {
|
||||||
|
if (clockModes[channels[displayTab - 1].mode] == 0) {
|
||||||
|
display.print(F("OFF"));
|
||||||
|
} else if (clockModes[channels[displayTab - 1].mode] > 0) {
|
||||||
|
display.print(F("/"));
|
||||||
|
display.print(abs(clockModes[channels[displayTab - 1].mode]));
|
||||||
|
} else {
|
||||||
|
display.print(F("x"));
|
||||||
|
display.print(abs(clockModes[channels[displayTab - 1].mode]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Extra params
|
||||||
|
display.setCursor(58, 0);
|
||||||
|
display.setTextSize(1);
|
||||||
|
if (displayTab == 0) {
|
||||||
|
if (insideTab == 1) {
|
||||||
|
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
|
||||||
|
} else {
|
||||||
|
display.setTextColor(SSD1306_WHITE);
|
||||||
|
}
|
||||||
|
display.print(F(" CLK:"));
|
||||||
|
if (masterClockMode == 1) {
|
||||||
|
display.println(F("EXT24 "));
|
||||||
|
} else if (masterClockMode == 2) {
|
||||||
|
display.println(F("EXT-B "));
|
||||||
|
} else if (masterClockMode == 3) {
|
||||||
|
display.println(F("EXT16 "));
|
||||||
|
} else {
|
||||||
|
display.println(F("INT "));
|
||||||
|
}
|
||||||
|
if (insideTab == 2) {
|
||||||
|
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
|
||||||
|
} else {
|
||||||
|
display.setTextColor(SSD1306_WHITE);
|
||||||
|
}
|
||||||
|
display.setCursor(58, 16);
|
||||||
|
display.print(F(" MOD:"));
|
||||||
|
if (bpmModulationRange != 0 && masterClockMode == 0) {
|
||||||
|
display.print(F("CV"));
|
||||||
|
display.print(bpmModulationChannel + 1);
|
||||||
|
display.print("+");
|
||||||
|
display.print(bpmModulationRange * 10);
|
||||||
|
} else {
|
||||||
|
display.print(F("Off "));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (insideTab == 1) {
|
||||||
|
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
|
||||||
|
} else {
|
||||||
|
display.setTextColor(SSD1306_WHITE);
|
||||||
|
}
|
||||||
|
display.print(F(" RND:"));
|
||||||
|
if (channels[displayTab - 1].random > 0) {
|
||||||
|
display.print(channels[displayTab - 1].random);
|
||||||
|
display.print(F("0% "));
|
||||||
|
} else {
|
||||||
|
display.print(F("Off "));
|
||||||
|
}
|
||||||
|
if (insideTab == 2) {
|
||||||
|
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
|
||||||
|
} else {
|
||||||
|
display.setTextColor(SSD1306_WHITE);
|
||||||
|
}
|
||||||
|
display.setCursor(58, 16);
|
||||||
|
display.print(F(" MOD:"));
|
||||||
|
if (channels[displayTab - 1].modulationChannel && channels[displayTab - 1].modulationRange != 0) {
|
||||||
|
display.print(F("CV2"));
|
||||||
|
if (channels[displayTab - 1].modulationRange > 0) {
|
||||||
|
display.print(F("+"));
|
||||||
|
}
|
||||||
|
display.print(channels[displayTab - 1].modulationRange);
|
||||||
|
display.print(F(" "));
|
||||||
|
} else if (!channels[displayTab - 1].modulationChannel && channels[displayTab - 1].modulationRange != 0) {
|
||||||
|
display.print(F("CV1"));
|
||||||
|
if (channels[displayTab - 1].modulationRange > 0) {
|
||||||
|
display.print(F("+"));
|
||||||
|
}
|
||||||
|
display.print(channels[displayTab - 1].modulationRange);
|
||||||
|
display.print(F(" "));
|
||||||
|
} else {
|
||||||
|
display.print(F("Off "));
|
||||||
|
}
|
||||||
|
if (insideTab == 3) {
|
||||||
|
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
|
||||||
|
} else {
|
||||||
|
display.setTextColor(SSD1306_WHITE);
|
||||||
|
}
|
||||||
|
display.setCursor(58, 32);
|
||||||
|
display.print(F(" OFT:"));
|
||||||
|
display.print(channels[displayTab - 1].offset);
|
||||||
|
display.print(F("/"));
|
||||||
|
display.print(channelPulsesPerCycle[displayTab - 1] + 1);
|
||||||
|
display.print(F(" "));
|
||||||
|
}
|
||||||
|
|
||||||
|
display.display();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user