Added ext MIDI start and stop handeling
This commit is contained in:
106
Extra/MIDITest/MIDITest.ino
Normal file
106
Extra/MIDITest/MIDITest.ino
Normal file
@ -0,0 +1,106 @@
|
||||
#include <Wire.h>
|
||||
#include <U8g2lib.h>
|
||||
|
||||
#define SCREEN_ADDRESS 0x3C
|
||||
|
||||
// Rev 2 and 3 Config
|
||||
#define ENC_BTN_PIN 14
|
||||
#define ENC_D1_PIN 17
|
||||
#define ENC_D2_PIN 4
|
||||
#define START_STOP_BTN_PIN 5
|
||||
#define SHIFT_BTN_PIN 12
|
||||
#define EXT_INPUT_PIN 2 //needs to be an interrupt pin
|
||||
#define ANALOGUE_INPUT_1_PIN A7
|
||||
#define ANALOGUE_INPUT_2_PIN A6
|
||||
const byte outsPins[6] = { 7, 8, 10, 6, 9, 11 };
|
||||
const byte clockOutPin = 3;
|
||||
|
||||
int CV1Calibration = 512;
|
||||
int CV2Calibration = 512;
|
||||
bool rotateScreen = false;
|
||||
|
||||
|
||||
int a1Input = 0;
|
||||
int a2Input = 0;
|
||||
|
||||
|
||||
U8G2_SSD1306_128X64_NONAME_2_HW_I2C u8g2(U8G2_R2, SCL, SDA, U8X8_PIN_NONE);
|
||||
|
||||
bool MIDIClockRecived = false;
|
||||
|
||||
//Font
|
||||
const uint8_t velvetscreen[437] U8G2_FONT_SECTION("velvetscreen") =
|
||||
"\64\0\2\2\3\3\2\3\4\5\5\0\0\5\0\5\0\0\221\0\0\1\230 \4\200\134%\11\255tT"
|
||||
"R\271RI(\6\252\334T\31)\7\252\134bJ\12+\7\233\345\322J\0,\5\221T\4-\5\213"
|
||||
"f\6.\5\211T\2/\6\244\354c\33\60\10\254\354T\64\223\2\61\7\353\354\222\254\6\62\11\254l"
|
||||
"\66J*\217\0\63\11\254l\66J\32\215\4\64\10\254l\242\34\272\0\65\11\254l\206\336h$\0\66"
|
||||
"\11\254\354T^\61)\0\67\10\254lF\216u\4\70\11\254\354TL*&\5\71\11\254\354TL;"
|
||||
")\0:\6\231UR\0A\10\254\354T\34S\6B\11\254lV\34)\216\4C\11\254\354T\324\61"
|
||||
")\0D\10\254lV\64G\2E\10\254l\206\36z\4F\10\254l\206^\71\3G\11\254\354TN"
|
||||
"\63)\0H\10\254l\242\34S\6I\6\251T\206\0J\10\254\354k\231\24\0K\11\254l\242J\62"
|
||||
"\225\1L\7\254lr{\4M\11\255t\362ZI\353\0N\11\255t\362TI\356\0O\10\254\354T"
|
||||
"\64\223\2P\11\254lV\34)g\0Q\10\254\354T\264b\12R\10\254lV\34\251\31S\11\254\354"
|
||||
"FF\32\215\4T\7\253dVl\1U\10\254l\242\63)\0V\11\255t\262Ne\312\21W\12\255"
|
||||
"t\262J*\251.\0X\11\254l\242L*\312\0Y\12\255tr\252\63\312(\2Z\7\253df*"
|
||||
"\7p\10\255\364V\266\323\2q\7\255\364\216\257\5r\10\253d\242\32*\2t\6\255t\376#w\11"
|
||||
"\255\364V\245FN\13x\6\233dR\7\0\0\0\4\377\377\0";
|
||||
|
||||
|
||||
void setup() {
|
||||
//Serial.begin(9600);
|
||||
Serial.begin(31250);
|
||||
|
||||
//pinMode(EXT_INPUT_PIN, INPUT_PULLUP);
|
||||
pinMode(SHIFT_BTN_PIN, INPUT_PULLUP);
|
||||
|
||||
u8g2.begin();
|
||||
checkScreenRotation();
|
||||
updateScreen();
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
//receiveMIDI();
|
||||
updateScreen();
|
||||
Serial.println(Serial.read());
|
||||
delay(500);
|
||||
}
|
||||
|
||||
|
||||
void receiveMIDI() {
|
||||
if(Serial.available() > 0) {
|
||||
if (Serial.read() == 0xF8) { //Clock
|
||||
MIDIClockRecived = true;
|
||||
//} else if (Serial.read() == 0xFA || Serial.read() == 0xFB) { //start and continue
|
||||
// isPlaying = true;
|
||||
//} else if (Serial.read() == 0xFC) { //stop
|
||||
// isPlaying = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void updateScreen() {
|
||||
|
||||
u8g2.firstPage();
|
||||
do {
|
||||
u8g2.setFont(velvetscreen);
|
||||
String valueStr = String(analogRead(ANALOGUE_INPUT_1_PIN));
|
||||
char valueChar[16];
|
||||
if (Serial.available() > 0) {
|
||||
u8g2.drawStr(10, 8, Serial.available());
|
||||
} else {
|
||||
u8g2.drawStr(10, 8, "HI");
|
||||
}
|
||||
|
||||
} while ( u8g2.nextPage() );
|
||||
}
|
||||
|
||||
|
||||
void checkScreenRotation() {
|
||||
if (rotateScreen) {
|
||||
u8g2.setDisplayRotation(U8G2_R0);
|
||||
} else {
|
||||
u8g2.setDisplayRotation(U8G2_R2);
|
||||
}
|
||||
}
|
||||
77
Hardware/gtoe/.xdp-gtoe.kicad_prl-MsqCQE
Normal file
77
Hardware/gtoe/.xdp-gtoe.kicad_prl-MsqCQE
Normal file
@ -0,0 +1,77 @@
|
||||
{
|
||||
"board": {
|
||||
"active_layer": 0,
|
||||
"active_layer_preset": "",
|
||||
"auto_track_width": true,
|
||||
"hidden_netclasses": [],
|
||||
"hidden_nets": [],
|
||||
"high_contrast_mode": 0,
|
||||
"net_color_mode": 1,
|
||||
"opacity": {
|
||||
"images": 0.6,
|
||||
"pads": 1.0,
|
||||
"tracks": 1.0,
|
||||
"vias": 1.0,
|
||||
"zones": 0.6
|
||||
},
|
||||
"selection_filter": {
|
||||
"dimensions": true,
|
||||
"footprints": true,
|
||||
"graphics": true,
|
||||
"keepouts": true,
|
||||
"lockedItems": false,
|
||||
"otherItems": true,
|
||||
"pads": true,
|
||||
"text": true,
|
||||
"tracks": true,
|
||||
"vias": true,
|
||||
"zones": true
|
||||
},
|
||||
"visible_items": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13,
|
||||
15,
|
||||
16,
|
||||
17,
|
||||
18,
|
||||
19,
|
||||
20,
|
||||
21,
|
||||
22,
|
||||
23,
|
||||
24,
|
||||
25,
|
||||
26,
|
||||
27,
|
||||
28,
|
||||
29,
|
||||
30,
|
||||
32,
|
||||
33,
|
||||
34,
|
||||
35,
|
||||
36,
|
||||
39,
|
||||
40
|
||||
],
|
||||
"visible_layers": "fffffff_ffffffff",
|
||||
"zone_display_mode": 0
|
||||
},
|
||||
"meta": {
|
||||
"filename": "gtoe.kicad_prl",
|
||||
"version": 3
|
||||
},
|
||||
"project": {
|
||||
"files": []
|
||||
}
|
||||
}
|
||||
@ -3,10 +3,12 @@
|
||||
"active_layer": 0,
|
||||
"active_layer_preset": "Front Layers",
|
||||
"auto_track_width": false,
|
||||
"hidden_netclasses": [],
|
||||
"hidden_nets": [],
|
||||
"high_contrast_mode": 0,
|
||||
"net_color_mode": 1,
|
||||
"opacity": {
|
||||
"images": 0.6,
|
||||
"pads": 1.0,
|
||||
"tracks": 1.0,
|
||||
"vias": 1.0,
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
{
|
||||
"board": {
|
||||
"3dviewports": [],
|
||||
"design_settings": {
|
||||
"defaults": {
|
||||
"board_outline_line_width": 0.09999999999999999,
|
||||
@ -134,7 +135,8 @@
|
||||
"zones_allow_external_fillets": false,
|
||||
"zones_use_no_outline": true
|
||||
},
|
||||
"layer_presets": []
|
||||
"layer_presets": [],
|
||||
"viewports": []
|
||||
},
|
||||
"boards": [],
|
||||
"cvpcb": {
|
||||
@ -356,7 +358,7 @@
|
||||
"net_settings": {
|
||||
"classes": [
|
||||
{
|
||||
"bus_width": 12.0,
|
||||
"bus_width": 12,
|
||||
"clearance": 0.2,
|
||||
"diff_pair_gap": 0.25,
|
||||
"diff_pair_via_gap": 0.25,
|
||||
@ -370,13 +372,15 @@
|
||||
"track_width": 0.25,
|
||||
"via_diameter": 0.8,
|
||||
"via_drill": 0.4,
|
||||
"wire_width": 6.0
|
||||
"wire_width": 6
|
||||
}
|
||||
],
|
||||
"meta": {
|
||||
"version": 2
|
||||
"version": 3
|
||||
},
|
||||
"net_colors": null
|
||||
"net_colors": null,
|
||||
"netclass_assignments": null,
|
||||
"netclass_patterns": []
|
||||
},
|
||||
"pcbnew": {
|
||||
"last_paths": {
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
#include <U8g2lib.h>
|
||||
#include <avr/wdt.h>
|
||||
|
||||
const char version[5] = "v:1.b";
|
||||
const char version[5] = "v:1.1";
|
||||
|
||||
#define SCREEN_ADDRESS 0x3C
|
||||
|
||||
@ -105,10 +105,10 @@ int playingModes[6]; // should be renamed to currentSubdivs or something. Updat
|
||||
int playingModesOld[6];
|
||||
|
||||
unsigned int pulsePeriod;
|
||||
bool isPlaying = false;
|
||||
bool isPlaying;// = false;
|
||||
bool isRecording = false;
|
||||
bool recordToNextStep = false;
|
||||
bool MIDIClockRecived = false;
|
||||
bool MIDIClockReceived = false;
|
||||
|
||||
unsigned int tickCount = 0;
|
||||
unsigned int pulseCount = 0;
|
||||
@ -190,7 +190,6 @@ const uint8_t stkL[569] U8G2_FONT_SECTION("stk-l") =
|
||||
|
||||
|
||||
void setup() {
|
||||
//Serial.begin(9600);
|
||||
Serial.begin(31250);
|
||||
|
||||
pinMode(ENC_BTN_PIN, INPUT_PULLUP);
|
||||
@ -221,12 +220,12 @@ void setup() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
checkInputs();
|
||||
if (masterClockMode == 2) {
|
||||
receiveMIDI();
|
||||
} else if (masterClockMode == 1 && extClockPPQN == 1) {
|
||||
calculateBPMTiming();
|
||||
}
|
||||
checkInputs();
|
||||
}
|
||||
|
||||
void sendMIDIClock() {
|
||||
@ -238,18 +237,21 @@ void sendMIDIStart() {
|
||||
void sendMIDIStop() {
|
||||
Serial.write(0xFC);
|
||||
}
|
||||
|
||||
void receiveMIDI() {
|
||||
if(Serial.available() > 0) {
|
||||
if (Serial.read() == 0xF8) { //Clock
|
||||
MIDIClockRecived = true;
|
||||
//} else if (Serial.read() == 0xFA || Serial.read() == 0xFB) { //start and continue
|
||||
//if(Serial.available() > 0) {
|
||||
int msg = Serial.read();
|
||||
if (msg == 0xF8) { //Clock
|
||||
MIDIClockReceived = true;
|
||||
} else if (msg == 0xFC) { //stop
|
||||
isPlaying = false;
|
||||
} else if (msg == 0xFA || msg == 0xFB) { //start and continue
|
||||
isPlaying = true;
|
||||
//} else if (Serial.read() == 0xFC) { //stop
|
||||
// isPlaying = false;
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
void clock() {
|
||||
if (isPlaying) {
|
||||
|
||||
@ -283,14 +285,14 @@ void clock() {
|
||||
}
|
||||
}
|
||||
|
||||
if (masterClockMode == 2 && MIDIClockRecived) { // MIDI should happen here (needs testing)
|
||||
if (masterClockMode == 2 && MIDIClockReceived) { // MIDI should happen here (needs testing)
|
||||
tickCount = 0; //to make things happen in the main clock function
|
||||
if (pulseCount < (PPQN - 1)) {
|
||||
pulseCount++;
|
||||
} else {
|
||||
pulseCount = 0;
|
||||
}
|
||||
MIDIClockRecived = false;
|
||||
MIDIClockReceived = false;
|
||||
}
|
||||
|
||||
// pull low all outputs after set pulse length
|
||||
|
||||
@ -51,7 +51,7 @@ void checkInputs() {
|
||||
} else if (insideTab && displayScreen == 0) {
|
||||
menuItemSelected = !menuItemSelected;
|
||||
} else if (displayScreen == 1 && !isRecording) {
|
||||
isPlaying = 1;
|
||||
isPlaying = true;
|
||||
isRecording = 1;
|
||||
} else if (displayScreen == 1 && isRecording) {
|
||||
isRecording = 0;
|
||||
|
||||
Reference in New Issue
Block a user