Compare commits
35 Commits
hardware-r
...
u8g2-test
| Author | SHA1 | Date | |
|---|---|---|---|
| 54c0f0d50a | |||
| 1820e678c9 | |||
| 9d07f35908 | |||
| 0a4fba7870 | |||
| 95d07893bc | |||
| 5aaa6e694d | |||
| 4c9a4e966f | |||
| e51337abf2 | |||
| e93b6b53a9 | |||
| c5d1c1cded | |||
| aa868c0a01 | |||
| 545581ec32 | |||
| 3a21d8616e | |||
| fc381b4829 | |||
| f6ba128ab8 | |||
| adc80bd626 | |||
| 9d4142b46b | |||
| ebd5005942 | |||
| aec68332e4 | |||
| fc622a1663 | |||
| eb32f46ea3 | |||
| cdb4cb58a2 | |||
| c5a252cb34 | |||
| 4c6c68e260 | |||
| d8398eb986 | |||
| ede342fb1f | |||
| 392f536203 | |||
| a40f7ec67d | |||
| c79c8e4ae5 | |||
| 0744c199c7 | |||
| fb1436db18 | |||
| 51d004b4a4 | |||
| fd77b88b6f | |||
| dbf6cfe85a | |||
| 21e67180ec |
164
Extra/CVTest/CVTest.ino
Normal file
164
Extra/CVTest/CVTest.ino
Normal file
@ -0,0 +1,164 @@
|
||||
#include <Wire.h>
|
||||
#include <EEPROM.h>
|
||||
#include <U8g2lib.h>
|
||||
#include <avr/wdt.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);
|
||||
|
||||
//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";
|
||||
|
||||
const uint8_t fabryka[450] U8G2_FONT_SECTION("fabryka") =
|
||||
"\17\0\4\4\4\5\2\1\6\17\30\1\0\30\0\0\0\1K\0\0\1\245%'\17\37\313\330R#&"
|
||||
"\32!F\14\211I\310\24!\65\204(MF\21)Cd\304\10\62b\14\215\60Vb\334\20\0/\15"
|
||||
"\376\36\357\244$\351\77\35;\26\0\60$\216\37\17*\65,\210\35\264\335\61T\42\14\11\61#\306\210"
|
||||
" \23\242\220\235\63h\303c$\330\250B\3\0\61\27\216\37\27\311\202\346\216\221\30Ed\324\230Q\202"
|
||||
"\306\316\377\263\26\35\62\33\216\37\17*\65,\210\35\64\70v\246\344\316h\203\252$\321\261s\373\340\1"
|
||||
"\3\63\35\216\37\17*\65,\210\35\64\70v(IZZKv\266\6\15\36#\301F\25\32\0\64\37"
|
||||
"\216\37\227\240\331\20\32Bj\310\260\21\304F\214\33\61n\304\70\203\366\360\301\203\20m\347\3\65\32\216"
|
||||
"\37\7\213.\306\316'\205\326\60!E\226\354\334\32<F\202\215*\64\0\66\33\216\37\17*\65,\210"
|
||||
"\35\64;/\316\60iA\354\240=<F\202\215*\64\0\67\25\216\37C\213\7m\347S\222\364\351\264"
|
||||
"C\307\16\35;)\0\70 \216\37\17*\65,\210\35\264\341\61\22\204\310\250B\245\206\20\11b\7\355"
|
||||
"\360\30\11\66\252\320\0\71\33\216\37\17*\65,\210\35\264\207\307H\64asb\354|\61\214\4\33U"
|
||||
"h\0A\30\216\37\223\71Tj\10\21\31\66d\330\210\201\366\360\301\7\3\355\17\7B&\216\37\203\242"
|
||||
"\65L\206\221\30\67b\334\210q#\306\215\30\67b\30\11&\234\14#\61\356\240\275{ \242\5\23\0"
|
||||
"x\32\336\36\303\300c$\10\221!B\12\235I\222\346P\21!C\210\4\261\203\3\0\0\0\4\377\377"
|
||||
"\0";
|
||||
|
||||
|
||||
void setup() {
|
||||
//Serial.begin(9600);
|
||||
|
||||
//pinMode(EXT_INPUT_PIN, INPUT_PULLUP);
|
||||
pinMode(SHIFT_BTN_PIN, INPUT_PULLUP);
|
||||
|
||||
u8g2.begin();
|
||||
checkScreenRotation();
|
||||
updateScreen();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
checkInputs();
|
||||
updateScreen();
|
||||
delay(500);
|
||||
}
|
||||
|
||||
|
||||
void checkInputs() {
|
||||
if (analogRead(ANALOGUE_INPUT_1_PIN) > (CV1Calibration)) {
|
||||
a1Input = map(analogRead(ANALOGUE_INPUT_1_PIN), CV1Calibration, 1023, 512, 1023);
|
||||
} else if (analogRead(ANALOGUE_INPUT_1_PIN) < (CV1Calibration)) {
|
||||
a1Input = map(analogRead(ANALOGUE_INPUT_1_PIN), 0, CV1Calibration, 0, 512);
|
||||
} else {
|
||||
a1Input = 512;
|
||||
}
|
||||
|
||||
if (analogRead(ANALOGUE_INPUT_2_PIN) > (CV1Calibration)) {
|
||||
a2Input = map(analogRead(ANALOGUE_INPUT_2_PIN), CV1Calibration, 1023, 512, 1023);
|
||||
} else if (analogRead(ANALOGUE_INPUT_2_PIN) < (CV1Calibration)) {
|
||||
a2Input = map(analogRead(ANALOGUE_INPUT_2_PIN), 0, CV1Calibration, 0, 512);
|
||||
} else {
|
||||
a2Input = 512;
|
||||
}
|
||||
}
|
||||
|
||||
void updateScreen() {
|
||||
|
||||
u8g2.firstPage();
|
||||
do {
|
||||
u8g2.setFont(velvetscreen);
|
||||
String valueStr = String(analogRead(ANALOGUE_INPUT_1_PIN));
|
||||
char valueChar[16];
|
||||
|
||||
u8g2.drawStr(10, 8, "CV1:");
|
||||
valueStr.toCharArray(valueChar, 16);
|
||||
u8g2.drawStr(32, 8, valueChar);
|
||||
|
||||
u8g2.drawStr(64, 8, "CAL:");
|
||||
valueStr = String(a1Input);
|
||||
valueStr.toCharArray(valueChar, 16);
|
||||
u8g2.drawStr(86, 8, valueChar);
|
||||
|
||||
u8g2.drawStr(10, 16, "MAP:");
|
||||
valueStr = String(map(a1Input, 5, 1024, -5, 6));
|
||||
valueStr.toCharArray(valueChar, 16);
|
||||
u8g2.drawStr(32, 16, valueChar);
|
||||
|
||||
|
||||
u8g2.drawStr(10, 40, "CV2:");
|
||||
valueStr = String(analogRead(ANALOGUE_INPUT_2_PIN));
|
||||
valueStr.toCharArray(valueChar, 16);
|
||||
u8g2.drawStr(32, 40, valueChar);
|
||||
|
||||
u8g2.drawStr(64, 40, "CAL:");
|
||||
valueStr = String(a2Input);
|
||||
valueStr.toCharArray(valueChar, 16);
|
||||
u8g2.drawStr(86, 40, valueChar);
|
||||
|
||||
u8g2.drawStr(10, 48, "MAP:");
|
||||
valueStr = String(map(a2Input, 5, 1024, -5, 6));
|
||||
valueStr.toCharArray(valueChar, 16);
|
||||
u8g2.drawStr(32, 48, valueChar);
|
||||
|
||||
|
||||
if (!digitalRead(SHIFT_BTN_PIN)) {
|
||||
calibrateCVs();
|
||||
u8g2.drawStr(40, 64, "CALIBRATING");
|
||||
}
|
||||
|
||||
} while ( u8g2.nextPage() );
|
||||
}
|
||||
|
||||
void calibrateCVs() {
|
||||
CV1Calibration = analogRead(ANALOGUE_INPUT_1_PIN);
|
||||
CV2Calibration = analogRead(ANALOGUE_INPUT_2_PIN);
|
||||
//CV1Calibration = 255 - (analogRead(ANALOGUE_INPUT_1_PIN) / 2);
|
||||
//CV2Calibration = 255 - (analogRead(ANALOGUE_INPUT_2_PIN) / 2);
|
||||
}
|
||||
|
||||
void checkScreenRotation() {
|
||||
if (rotateScreen) {
|
||||
u8g2.setDisplayRotation(U8G2_R0);
|
||||
} else {
|
||||
u8g2.setDisplayRotation(U8G2_R2);
|
||||
}
|
||||
}
|
||||
2220
Extra/Fonts/Velvet Screen Bitmap Font/Velvet Screen.bdf
Normal file
2220
Extra/Fonts/Velvet Screen Bitmap Font/Velvet Screen.bdf
Normal file
File diff suppressed because it is too large
Load Diff
2220
Extra/Fonts/Velvet Screen Bitmap Font/VelvetScreen.bdf
Normal file
2220
Extra/Fonts/Velvet Screen Bitmap Font/VelvetScreen.bdf
Normal file
File diff suppressed because it is too large
Load Diff
BIN
Extra/Fonts/Velvet Screen Bitmap Font/bdfconv
Executable file
BIN
Extra/Fonts/Velvet Screen Bitmap Font/bdfconv
Executable file
Binary file not shown.
BIN
Extra/Fonts/Velvet Screen Bitmap Font/velvet-screen.fon
Normal file
BIN
Extra/Fonts/Velvet Screen Bitmap Font/velvet-screen.fon
Normal file
Binary file not shown.
21
Extra/Fonts/Velvet Screen Bitmap Font/velvetscreen.c
Normal file
21
Extra/Fonts/Velvet Screen Bitmap Font/velvetscreen.c
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
Fontname: Velvet Screen
|
||||
Copyright: Created with Fony 1.4.7
|
||||
Glyphs: 52/256
|
||||
BBX Build Mode: 0
|
||||
*/
|
||||
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";
|
||||
BIN
Extra/Fonts/theory.fon
Normal file
BIN
Extra/Fonts/theory.fon
Normal file
Binary file not shown.
18
Hardware/gtoe/Production files REV3/GRAVITY REV 3 BOM.csv
Normal file
18
Hardware/gtoe/Production files REV3/GRAVITY REV 3 BOM.csv
Normal file
@ -0,0 +1,18 @@
|
||||
"Id";"Designator";"Package";"Quantity";"Designation";"Supplier and ref";
|
||||
1;"J9,J2,J5,J3,J8,J6,J1,J4,J7";"thonkiconn";9;"AudioJack2_SwitchT";;;
|
||||
2;"SW3,SW1";"button";2;"SW_DIP_x01";;;
|
||||
3;"D5,D4,D3,D2,D6,D1";"FlatTopLed";6;"LED";;;
|
||||
4;"Screen";"I2C SSD1306";1;"SSD1306";;;
|
||||
5;"SW2";"SwitchEncoder";1;"RotaryEncoder_Switch";;;
|
||||
6;"D13,D12";"D_SOD-123";2;"1N5819HW";;;
|
||||
7;"R24,R19,R9,R3,R23,R7,R12,R10,R22,R18,R2,R5,R11,R1,R15,R8,R4,R17,R6,R16";"R_0805_2012Metric";20;"1K";;;
|
||||
8;"C1,C2";"CP_Radial_D4.0mm_P2.00mm";2;"10uF";;;
|
||||
9;"D9,D11,D8,D10";"D_SOD-123";4;"BAT43";;;
|
||||
10;"U2,U1";"SO-14_3.9x8.65mm_P1.27mm";2;"TL074";;;
|
||||
11;"A1";"Arduino_Nano (adjusted courtyard)";1;"Arduino_Nano_v2.x";;;
|
||||
12;"R13,R14";"R_0805_2012Metric";2;"10k";;;
|
||||
13;"J11";"PinHeader_1x06_P2.54mm_Vertical";1;"Conn_01x05";;;
|
||||
14;"R20,R21";"R_0805_2012Metric";2;"100K";;;
|
||||
15;"D7";"D_SOD-123";1;"1N4148";;;
|
||||
16;"Q1";"TO-92_Inline";1;"PN2222A";;;
|
||||
17;"J10";"PinHeader_2x05_P2.54mm_Vertical";1;"Power";;;
|
||||
|
Can't render this file because it has a wrong number of fields in line 2.
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"board": {
|
||||
"active_layer": 31,
|
||||
"active_layer_preset": "Back Assembly View",
|
||||
"active_layer_preset": "",
|
||||
"auto_track_width": false,
|
||||
"hidden_nets": [],
|
||||
"high_contrast_mode": 0,
|
||||
@ -62,7 +62,7 @@
|
||||
35,
|
||||
36
|
||||
],
|
||||
"visible_layers": "0015050_00000000",
|
||||
"visible_layers": "0015050_80000001",
|
||||
"zone_display_mode": 0
|
||||
},
|
||||
"meta": {
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
#include <RotaryEncoder.h>
|
||||
#include <FlexiTimer2.h>
|
||||
#include <EEPROM.h>
|
||||
#include <U8g2lib.h>
|
||||
#include <avr/wdt.h>
|
||||
|
||||
#define VERSION "0.9b"
|
||||
const char version[5] = "V:1.0";
|
||||
|
||||
#define SCREEN_ADDRESS 0x3C
|
||||
|
||||
@ -13,18 +13,6 @@
|
||||
#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 MINBPM 20
|
||||
#define SCREEN_TIMEOUT 600000 //Turn display off after 5 min
|
||||
|
||||
/* Rev 1 Config
|
||||
#define ENC_BTN_PIN 14
|
||||
#define ENC_D1_PIN 17
|
||||
#define ENC_D2_PIN 4
|
||||
#define START_STOP_BTN_PIN 5
|
||||
#define EXT_INPUT_PIN 2 //needs to be an interrupt pin
|
||||
#define ANALOGUE_INPUT_1_PIN A2
|
||||
#define ANALOGUE_INPUT_2_PIN A1
|
||||
const int outsPins[6] = {6, 11, 7, 10, 8, 9};
|
||||
*/
|
||||
|
||||
// Rev 2 and 3 Config
|
||||
#define ENC_BTN_PIN 14
|
||||
@ -36,7 +24,12 @@ const int outsPins[6] = {6, 11, 7, 10, 8, 9};
|
||||
#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;
|
||||
bool showDone = false;
|
||||
|
||||
const int subDivs[17] = { -24, -12, -8, -6, -4, -3, -2, 1, 2, 3, 4, 5, 6, 7, 8, 16, 32 }; //positive - divide, negative - multiply, 0 - off
|
||||
|
||||
@ -48,51 +41,55 @@ struct channel {
|
||||
byte mode; //0 - CLK, 1 - RND, 2 - SEQ
|
||||
byte subDiv;
|
||||
byte CV1Target; //0 - Off, 1 - Subdiv, 2 - RND, 3 - SeqPattern
|
||||
byte CV1Value;
|
||||
byte CV1Range;
|
||||
byte CV2Target;
|
||||
byte CV2Value;
|
||||
byte offset;
|
||||
byte CV2Range;
|
||||
unsigned int offset;
|
||||
byte random;
|
||||
byte seqPattern;
|
||||
};
|
||||
|
||||
channel channels[6] = { //array of channel settings
|
||||
{ 0, 7, 0, 3, 0, 3, 0, 0, 0 },
|
||||
{ 0, 7, 0, 3, 0, 3, 0, 0, 0 },
|
||||
{ 0, 7, 0, 3, 0, 3, 0, 0, 0 },
|
||||
{ 0, 7, 0, 3, 0, 3, 0, 0, 0 },
|
||||
{ 0, 7, 0, 3, 0, 3, 0, 0, 0 },
|
||||
{ 0, 7, 0, 3, 0, 3, 0, 0, 0 }
|
||||
{ 0, 7, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{ 0, 7, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{ 0, 7, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{ 0, 7, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{ 0, 7, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{ 0, 7, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
bool seqA1[16] = {1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0};
|
||||
bool seqA2[16] = {0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0};
|
||||
bool seqA3[16] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
bool seqA4[16] = {1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0};
|
||||
bool seqA5[16] = {1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0};
|
||||
bool seqA6[16] = {0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0};
|
||||
bool seqA7[16] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
bool seqA8[16] = {1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0};
|
||||
bool seqB1[16] = {1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0};
|
||||
bool seqB2[16] = {0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0};
|
||||
bool seqB3[16] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
bool seqB4[16] = {1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0};
|
||||
bool seqB5[16] = {1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0};
|
||||
bool seqB6[16] = {0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0};
|
||||
bool seqB7[16] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
bool seqB8[16] = {1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0};
|
||||
bool *currentSeq;
|
||||
bool seqA1[16] = {1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1};
|
||||
bool seqA2[16] = {0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0};
|
||||
bool seqA3[16] = {1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0};
|
||||
bool seqA4[16] = {0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1};
|
||||
bool seqA5[16] = {0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1};
|
||||
bool seqA6[16] = {0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0};
|
||||
bool seqA7[16] = {1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0};
|
||||
bool seqA8[16] = {1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1};
|
||||
bool seqB1[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
bool seqB2[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
bool seqB3[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
bool seqB4[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
bool seqB5[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
bool seqB6[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
bool seqB7[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
bool seqB8[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
byte currentStep = 0;
|
||||
byte stepNumSelected = 0;
|
||||
bool *patternToEdit;
|
||||
|
||||
byte memCode = 'A'; //Change to different letter if you changed the data structure
|
||||
byte memCode = 'B'; //Change to different letter if you changed the data structure
|
||||
|
||||
unsigned int channelPulseCount[6];
|
||||
unsigned int channelPulsesPerCycle[6];
|
||||
byte sixteenthPulseCount = 0;
|
||||
int playingModes[6]; //actual channel modes array updated from channels object on each beat
|
||||
int playingModes[6]; // should be renamed to currentSubdivs or something. Updated from channels object on beat and with applied CV modulation
|
||||
int playingModesOld[6];
|
||||
|
||||
unsigned int pulsePeriod;
|
||||
bool isPlaying = false;
|
||||
bool isRecording = false;
|
||||
bool recordToNextStep = false;
|
||||
|
||||
unsigned int tickCount = 0;
|
||||
unsigned int pulseCount = 0;
|
||||
@ -106,65 +103,67 @@ bool needPulseReset[6] = { true, true, true, true, true, true };
|
||||
byte displayTab = 0;
|
||||
bool insideTab = false;
|
||||
byte menuItem = 0;
|
||||
bool menuItemSelected = false;
|
||||
byte lastMenuItem = 3;
|
||||
byte displayScreen = 0; //0 - main, 1 - sequencer, 2 - settings
|
||||
|
||||
bool playBtnPushed = false;
|
||||
bool shiftBtnPushed = false;
|
||||
|
||||
int a1Input = 0;
|
||||
int a2Input = 0;
|
||||
int CV1Input = 0;
|
||||
int CV2Input = 0;
|
||||
|
||||
int encPositionOld = 0;
|
||||
unsigned long encPressedTime;
|
||||
unsigned long encReleasedTime;
|
||||
bool encPressRegistered;
|
||||
unsigned long playPressedTime;
|
||||
unsigned long playReleasedTime;
|
||||
unsigned long shiftPressedTime;
|
||||
unsigned long shiftReleasedTime;
|
||||
bool encBtnPushed;
|
||||
|
||||
//unsigned long lastInteractionTime; // used for display timeout
|
||||
|
||||
Adafruit_SSD1306 display(128, 64, &Wire, -1);
|
||||
U8G2_SSD1306_128X64_NONAME_2_HW_I2C u8g2(U8G2_R2, SCL, SDA, U8X8_PIN_NONE);
|
||||
RotaryEncoder encoder(ENC_D1_PIN, ENC_D2_PIN, RotaryEncoder::LatchMode::TWO03);
|
||||
|
||||
const unsigned char splash_logo[] PROGMEM = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x07, 0xf8, 0x03, 0xff, 0xc0, 0x03, 0xf8, 0x1f, 0x00, 0x7c, 0x7c, 0x3f, 0xff, 0xc7, 0xc0, 0x3e,
|
||||
0x0f, 0xfe, 0x03, 0xff, 0xe0, 0x07, 0xf8, 0x0f, 0x00, 0x78, 0x7c, 0x3f, 0xff, 0xc3, 0xe0, 0x7c,
|
||||
0x1f, 0xff, 0x03, 0xff, 0xf0, 0x07, 0xf8, 0x0f, 0x80, 0xf8, 0x7c, 0x3f, 0xff, 0xc3, 0xe0, 0x78,
|
||||
0x3f, 0xff, 0x03, 0xff, 0xf8, 0x07, 0xfc, 0x0f, 0x80, 0xf8, 0x7c, 0x3f, 0xff, 0xc1, 0xf0, 0xf8,
|
||||
0x7e, 0x0f, 0x83, 0xe0, 0xf8, 0x0f, 0x3c, 0x07, 0x80, 0xf0, 0x7c, 0x00, 0xf8, 0x00, 0xf8, 0xf0,
|
||||
0x7c, 0x07, 0x83, 0xe0, 0x78, 0x0f, 0x3c, 0x07, 0xc0, 0xf0, 0x7c, 0x00, 0xf0, 0x00, 0xf9, 0xf0,
|
||||
0x7c, 0x00, 0x03, 0xe0, 0xf8, 0x0f, 0x3e, 0x07, 0xc1, 0xf0, 0x7c, 0x00, 0xf0, 0x00, 0x7d, 0xe0,
|
||||
0x78, 0x00, 0x03, 0xe0, 0xf8, 0x1e, 0x1e, 0x03, 0xc1, 0xe0, 0x7c, 0x00, 0xf0, 0x00, 0x7f, 0xc0,
|
||||
0x78, 0x3f, 0xc3, 0xff, 0xf0, 0x1e, 0x1e, 0x03, 0xe1, 0xe0, 0x7c, 0x00, 0xf0, 0x00, 0x3f, 0xc0,
|
||||
0x78, 0x3f, 0xc3, 0xff, 0xe0, 0x1e, 0x1f, 0x01, 0xe3, 0xe0, 0x7c, 0x00, 0xf0, 0x00, 0x1f, 0x80,
|
||||
0x78, 0x3f, 0xc3, 0xff, 0xc0, 0x3e, 0x1f, 0x01, 0xe3, 0xc0, 0x7c, 0x00, 0xf0, 0x00, 0x1f, 0x80,
|
||||
0x7c, 0x3f, 0xc3, 0xe7, 0xc0, 0x3f, 0xff, 0x01, 0xf3, 0xc0, 0x7c, 0x00, 0xf0, 0x00, 0x0f, 0x00,
|
||||
0x7e, 0x07, 0xc3, 0xe3, 0xe0, 0x3f, 0xff, 0x80, 0xf7, 0xc0, 0x7c, 0x00, 0xf0, 0x00, 0x0f, 0x00,
|
||||
0x3f, 0x1f, 0xc3, 0xe1, 0xe0, 0x7f, 0xff, 0x80, 0xff, 0x80, 0x7c, 0x00, 0xf0, 0x00, 0x0f, 0x00,
|
||||
0x1f, 0xff, 0xc3, 0xe1, 0xf0, 0x78, 0x07, 0x80, 0xff, 0x80, 0x7c, 0x00, 0xf0, 0x00, 0x0f, 0x00,
|
||||
0x0f, 0xff, 0xc3, 0xe0, 0xf8, 0xf8, 0x07, 0xc0, 0x7f, 0x00, 0x7c, 0x00, 0xf0, 0x00, 0x0f, 0x00,
|
||||
0x07, 0xf3, 0xc3, 0xe0, 0xf8, 0xf8, 0x07, 0xc0, 0x7f, 0x00, 0x7c, 0x00, 0xf0, 0x00, 0x0f, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
//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";
|
||||
|
||||
const uint8_t fabryka[450] U8G2_FONT_SECTION("fabryka") =
|
||||
"\17\0\4\4\4\5\2\1\6\17\30\1\0\30\0\0\0\1K\0\0\1\245%'\17\37\313\330R#&"
|
||||
"\32!F\14\211I\310\24!\65\204(MF\21)Cd\304\10\62b\14\215\60Vb\334\20\0/\15"
|
||||
"\376\36\357\244$\351\77\35;\26\0\60$\216\37\17*\65,\210\35\264\335\61T\42\14\11\61#\306\210"
|
||||
" \23\242\220\235\63h\303c$\330\250B\3\0\61\27\216\37\27\311\202\346\216\221\30Ed\324\230Q\202"
|
||||
"\306\316\377\263\26\35\62\33\216\37\17*\65,\210\35\64\70v\246\344\316h\203\252$\321\261s\373\340\1"
|
||||
"\3\63\35\216\37\17*\65,\210\35\64\70v(IZZKv\266\6\15\36#\301F\25\32\0\64\37"
|
||||
"\216\37\227\240\331\20\32Bj\310\260\21\304F\214\33\61n\304\70\203\366\360\301\203\20m\347\3\65\32\216"
|
||||
"\37\7\213.\306\316'\205\326\60!E\226\354\334\32<F\202\215*\64\0\66\33\216\37\17*\65,\210"
|
||||
"\35\64;/\316\60iA\354\240=<F\202\215*\64\0\67\25\216\37C\213\7m\347S\222\364\351\264"
|
||||
"C\307\16\35;)\0\70 \216\37\17*\65,\210\35\264\341\61\22\204\310\250B\245\206\20\11b\7\355"
|
||||
"\360\30\11\66\252\320\0\71\33\216\37\17*\65,\210\35\264\207\307H\64asb\354|\61\214\4\33U"
|
||||
"h\0A\30\216\37\223\71Tj\10\21\31\66d\330\210\201\366\360\301\7\3\355\17\7B&\216\37\203\242"
|
||||
"\65L\206\221\30\67b\334\210q#\306\215\30\67b\30\11&\234\14#\61\356\240\275{ \242\5\23\0"
|
||||
"x\32\336\36\303\300c$\10\221!B\12\235I\222\346P\21!C\210\4\261\203\3\0\0\0\4\377\377"
|
||||
"\0";
|
||||
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
//check last bit in eeprom to know if the correct settings were stored
|
||||
if (EEPROM.read(1023) == memCode) {
|
||||
int addr = 0;
|
||||
EEPROM.get(addr, bpm);
|
||||
addr = addr + sizeof(bpm);
|
||||
EEPROM.get(addr, bpmModulationChannel);
|
||||
addr = addr + sizeof(bpmModulationChannel);
|
||||
EEPROM.get(addr, bpmModulationRange);
|
||||
addr = addr + sizeof(bpmModulationRange);
|
||||
EEPROM.get(addr, masterClockMode);
|
||||
addr = addr + sizeof(masterClockMode);
|
||||
EEPROM.get(addr, channels);
|
||||
} else {
|
||||
saveState();
|
||||
EEPROM.write(1023, memCode);
|
||||
}
|
||||
//Serial.begin(9600);
|
||||
|
||||
pinMode(ENC_BTN_PIN, INPUT_PULLUP);
|
||||
pinMode(START_STOP_BTN_PIN, INPUT_PULLUP);
|
||||
@ -176,22 +175,14 @@ void setup() {
|
||||
pinMode(outsPins[i], OUTPUT);
|
||||
}
|
||||
|
||||
display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);
|
||||
display.setRotation(2);
|
||||
display.clearDisplay();
|
||||
pinMode(clockOutPin, OUTPUT);
|
||||
|
||||
//Splash screen
|
||||
display.drawBitmap(0, 16, splash_logo, 128, 19, 1);
|
||||
|
||||
display.setCursor(0, 56);
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
display.print(F("V:"));
|
||||
display.print(F(VERSION));
|
||||
display.display();
|
||||
delay(800);
|
||||
loadState();
|
||||
|
||||
u8g2.begin();
|
||||
checkScreenRotation();
|
||||
updateScreen();
|
||||
|
||||
calculateCycles();
|
||||
calculateBPMTiming();
|
||||
|
||||
@ -201,12 +192,6 @@ void setup() {
|
||||
|
||||
void loop() {
|
||||
checkInputs();
|
||||
/*if ((millis() - lastInteractionTime) > SCREEN_TIMEOUT) {
|
||||
display.clearDisplay();
|
||||
display.display();
|
||||
if (masterClockMode == 2 || masterClockMode == 3) {
|
||||
calculateBPMTiming();
|
||||
}}*/
|
||||
}
|
||||
|
||||
void clock() {
|
||||
@ -215,6 +200,7 @@ void clock() {
|
||||
// Action on each pulse
|
||||
if (tickCount == 0) {
|
||||
sendTriggers();
|
||||
digitalWrite(clockOutPin, HIGH);
|
||||
}
|
||||
|
||||
//this part gets the Pulse and Ticks ticking
|
||||
@ -239,6 +225,7 @@ void clock() {
|
||||
for (byte i = 0; i < 6; i++) {
|
||||
digitalWrite(outsPins[i], LOW);
|
||||
}
|
||||
digitalWrite(clockOutPin, LOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -271,14 +258,71 @@ void externalClock() {
|
||||
void sendTriggers() {
|
||||
|
||||
for (byte i = 0; i < 6; i++) {
|
||||
if (playingModes[i] != subDivs[channels[i].subDiv]) {
|
||||
if (playingModes[i] != subDivs[channels[i].subDiv] && playingModesOld[i] != playingModes[i]) {
|
||||
needPulseReset[i] = true;
|
||||
playingModesOld[i] = playingModes[i];
|
||||
}
|
||||
}
|
||||
|
||||
//16th notes for sequencer
|
||||
if (sixteenthPulseCount == 0) {
|
||||
bool *currentSeq;
|
||||
|
||||
for (byte i = 0; i < 6; i++) {
|
||||
|
||||
//pattern modulation
|
||||
int seqMod = 0;
|
||||
byte seqPattern;
|
||||
if (channels[i].CV2Target == 3) {
|
||||
seqMod = map(CV2Input, -1, 1024, -8, 8); //-1 and 1024 are to try to make the last step not at max value (should make the range from -7 to +7)
|
||||
} else if (channels[i].CV1Target == 3) {
|
||||
seqMod = map(CV1Input, -1, 1024, -8, 8);
|
||||
}
|
||||
if (channels[i].seqPattern < 8 && channels[i].seqPattern + seqMod >= 8) {
|
||||
seqPattern = 7;
|
||||
} else if (channels[i].seqPattern < 8 && channels[i].seqPattern + seqMod < 0) {
|
||||
seqPattern = 0;
|
||||
} else if (channels[i].seqPattern >= 8 && channels[i].seqPattern + seqMod < 8) {
|
||||
seqPattern = 8;
|
||||
} else if (channels[i].seqPattern >= 8 && channels[i].seqPattern + seqMod >= 16) {
|
||||
seqPattern = 15;
|
||||
} else {
|
||||
seqPattern = channels[i].seqPattern + seqMod;
|
||||
}
|
||||
|
||||
if (seqPattern == 0) {
|
||||
currentSeq = seqA1;
|
||||
} else if (seqPattern == 1) {
|
||||
currentSeq = seqA2;
|
||||
} else if (seqPattern == 2) {
|
||||
currentSeq = seqA3;
|
||||
} else if (seqPattern == 3) {
|
||||
currentSeq = seqA4;
|
||||
} else if (seqPattern == 4) {
|
||||
currentSeq = seqA5;
|
||||
} else if (seqPattern == 5) {
|
||||
currentSeq = seqA6;
|
||||
} else if (seqPattern == 6) {
|
||||
currentSeq = seqA7;
|
||||
} else if (seqPattern == 7) {
|
||||
currentSeq = seqA8;
|
||||
} else if (seqPattern == 8) {
|
||||
currentSeq = seqB1;
|
||||
} else if (seqPattern == 9) {
|
||||
currentSeq = seqB2;
|
||||
} else if (seqPattern== 10) {
|
||||
currentSeq = seqB3;
|
||||
} else if (seqPattern == 11) {
|
||||
currentSeq = seqB4;
|
||||
} else if (seqPattern == 12) {
|
||||
currentSeq = seqB5;
|
||||
} else if (seqPattern == 13) {
|
||||
currentSeq = seqB6;
|
||||
} else if (seqPattern == 14) {
|
||||
currentSeq = seqB7;
|
||||
} else if (seqPattern == 15) {
|
||||
currentSeq = seqB8;
|
||||
}
|
||||
if (channels[i].mode == 2 && channelPulseCount[i] == 0 && currentSeq[currentStep]) {
|
||||
digitalWrite(outsPins[i], HIGH);
|
||||
}
|
||||
@ -286,6 +330,9 @@ void sendTriggers() {
|
||||
}
|
||||
if (sixteenthPulseCount < (PPQN / 4) - 1) {
|
||||
sixteenthPulseCount++;
|
||||
if (sixteenthPulseCount > 3) { //quantization. might need fine-tuning
|
||||
recordToNextStep = true;
|
||||
}
|
||||
} else {
|
||||
sixteenthPulseCount = 0;
|
||||
if (currentStep < 15) {
|
||||
@ -293,6 +340,7 @@ void sendTriggers() {
|
||||
} else {
|
||||
currentStep = 0;
|
||||
}
|
||||
recordToNextStep = false;
|
||||
}
|
||||
|
||||
//switching modes on the beat and resetting channel clock
|
||||
@ -312,10 +360,10 @@ void sendTriggers() {
|
||||
//RND modulation
|
||||
byte randMod = 0;
|
||||
if (channels[i].CV1Target == 2) {
|
||||
randMod = randMod + a1Input;
|
||||
randMod = randMod + CV1Input;
|
||||
}
|
||||
if (channels[i].CV2Target == 2) {
|
||||
randMod = randMod + a2Input;
|
||||
randMod = randMod + CV2Input;
|
||||
}
|
||||
if (channels[i].CV1Target == 2 || channels[i].CV2Target == 2) {
|
||||
randMod = map(randMod, 0, 1023, -5, +5);
|
||||
@ -327,10 +375,8 @@ void sendTriggers() {
|
||||
randAmount = 10;
|
||||
}
|
||||
|
||||
|
||||
if ((channels[i].mode == 0 && channelPulseCount[i] == channels[i].offset) //CLK with offset
|
||||
|| (channels[i].mode == 1 && channelPulseCount[i] == 0 && (random(10) + 1) > randAmount) //RND
|
||||
//|| (channels[i].mode == 2 && channelPulseCount[i] == 0 && currentSeq[currentStep])
|
||||
) {
|
||||
digitalWrite(outsPins[i], HIGH);
|
||||
}
|
||||
@ -346,19 +392,13 @@ void sendTriggers() {
|
||||
void calculateCycles() {
|
||||
|
||||
for (byte i = 0; i < 6; i++) {
|
||||
if (channels[i].CV1Target != 1 && channels[i].CV2Target != 1) {
|
||||
playingModes[i] = subDivs[channels[i].subDiv];
|
||||
} else if (channels[i].CV1Target == 1) { //subdiv modulation happens here
|
||||
int mod;
|
||||
mod = a1Input;
|
||||
mod = map(mod, 0, 1023, (channels[i].CV1Value * -1), channels[i].CV1Value);
|
||||
playingModes[i] = subDivs[channels[i].subDiv - mod]; //subtracting because the innitial array is backwards
|
||||
int mod = 0; //subdiv modulation happens here
|
||||
if (channels[i].CV1Target == 1) {
|
||||
mod = map(CV1Input, -1, 1024, -5, 5); //(channels[i].CV1Value * -1), channels[i].CV1Value)
|
||||
} else if (channels[i].CV2Target == 1) {
|
||||
int mod;
|
||||
mod = a2Input;
|
||||
mod = map(mod, 0, 1023, (channels[i].CV2Value * -1), channels[i].CV2Value);
|
||||
playingModes[i] = subDivs[channels[i].subDiv - mod];
|
||||
mod = map(CV2Input, -1, 1024, -5, 5);
|
||||
}
|
||||
playingModes[i] = subDivs[channels[i].subDiv - mod]; //subtracting because the innitial array is backwards
|
||||
|
||||
if (playingModes[i] > 0 && channels[i].mode != 2) {
|
||||
channelPulsesPerCycle[i] = (playingModes[i] * PPQN) - 1;
|
||||
@ -367,9 +407,6 @@ void calculateCycles() {
|
||||
} else if (channels[i].mode == 2) { //Sequencer plays 1/16th
|
||||
channelPulsesPerCycle[i] = (PPQN / 4) - 1;
|
||||
}
|
||||
if (channels[i].offset > channelPulsesPerCycle[i]) {
|
||||
channels[i].offset = channelPulsesPerCycle[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -377,9 +414,9 @@ void calculateBPMTiming() {
|
||||
int mod = 0;
|
||||
if (masterClockMode == 0) { //Internal clock
|
||||
if (bpmModulationRange != 0 && bpmModulationChannel == 0) {
|
||||
mod = map(a1Input, 0, 1023, bpmModulationRange * -10, bpmModulationRange * 10);
|
||||
mod = map(CV1Input, 0, 1023, bpmModulationRange * -10, bpmModulationRange * 10);
|
||||
} else if (bpmModulationRange != 0 && bpmModulationChannel == 1) {
|
||||
mod = map(a2Input, 0, 1023, bpmModulationRange * -10, bpmModulationRange * 10);
|
||||
mod = map(CV2Input, 0, 1023, bpmModulationRange * -10, bpmModulationRange * 10);
|
||||
}
|
||||
pulsePeriod = 60000 / ((bpm + mod) * PPQN);
|
||||
|
||||
@ -398,6 +435,8 @@ void resetClocks() {
|
||||
}
|
||||
pulseCount = 0;
|
||||
tickCount = 0;
|
||||
sixteenthPulseCount = 0;
|
||||
currentStep = 0;
|
||||
}
|
||||
|
||||
void saveState() {
|
||||
@ -411,4 +450,120 @@ void saveState() {
|
||||
EEPROM.put(addr, masterClockMode);
|
||||
addr = addr + sizeof(masterClockMode);
|
||||
EEPROM.put(addr, channels);
|
||||
addr = addr + sizeof(channels);
|
||||
EEPROM.put(addr, seqA1);
|
||||
addr = addr + sizeof(seqA1);
|
||||
EEPROM.put(addr, seqA2);
|
||||
addr = addr + sizeof(seqA2);
|
||||
EEPROM.put(addr, seqA3);
|
||||
addr = addr + sizeof(seqA3);
|
||||
EEPROM.put(addr, seqA4);
|
||||
addr = addr + sizeof(seqA4);
|
||||
EEPROM.put(addr, seqA5);
|
||||
addr = addr + sizeof(seqA5);
|
||||
EEPROM.put(addr, seqA6);
|
||||
addr = addr + sizeof(seqA6);
|
||||
EEPROM.put(addr, seqA7);
|
||||
addr = addr + sizeof(seqA7);
|
||||
EEPROM.put(addr, seqA8);
|
||||
addr = addr + sizeof(seqA8);
|
||||
EEPROM.put(addr, seqB1);
|
||||
addr = addr + sizeof(seqB1);
|
||||
EEPROM.put(addr, seqB2);
|
||||
addr = addr + sizeof(seqB2);
|
||||
EEPROM.put(addr, seqB3);
|
||||
addr = addr + sizeof(seqB3);
|
||||
EEPROM.put(addr, seqB4);
|
||||
addr = addr + sizeof(seqB4);
|
||||
EEPROM.put(addr, seqB5);
|
||||
addr = addr + sizeof(seqB5);
|
||||
EEPROM.put(addr, seqB6);
|
||||
addr = addr + sizeof(seqB6);
|
||||
EEPROM.put(addr, seqB7);
|
||||
addr = addr + sizeof(seqB7);
|
||||
EEPROM.put(addr, seqB8);
|
||||
addr = addr + sizeof(seqB8);
|
||||
EEPROM.put(addr, CV1Calibration);
|
||||
addr = addr + sizeof(CV1Calibration);
|
||||
EEPROM.put(addr, CV2Calibration);
|
||||
addr = addr + sizeof(CV2Calibration);
|
||||
EEPROM.put(addr, rotateScreen);
|
||||
}
|
||||
|
||||
void loadState() {
|
||||
//check last bit in eeprom to know if the correct settings were stored
|
||||
if (EEPROM.read(1023) == memCode) {
|
||||
int addr = 0;
|
||||
EEPROM.get(addr, bpm);
|
||||
addr = addr + sizeof(bpm);
|
||||
EEPROM.get(addr, bpmModulationChannel);
|
||||
addr = addr + sizeof(bpmModulationChannel);
|
||||
EEPROM.get(addr, bpmModulationRange);
|
||||
addr = addr + sizeof(bpmModulationRange);
|
||||
EEPROM.get(addr, masterClockMode);
|
||||
addr = addr + sizeof(masterClockMode);
|
||||
EEPROM.get(addr, channels);
|
||||
addr = addr + sizeof(channels);
|
||||
EEPROM.get(addr, seqA1);
|
||||
addr = addr + sizeof(seqA1);
|
||||
EEPROM.get(addr, seqA2);
|
||||
addr = addr + sizeof(seqA2);
|
||||
EEPROM.get(addr, seqA3);
|
||||
addr = addr + sizeof(seqA3);
|
||||
EEPROM.get(addr, seqA4);
|
||||
addr = addr + sizeof(seqA4);
|
||||
EEPROM.get(addr, seqA5);
|
||||
addr = addr + sizeof(seqA5);
|
||||
EEPROM.get(addr, seqA6);
|
||||
addr = addr + sizeof(seqA6);
|
||||
EEPROM.get(addr, seqA7);
|
||||
addr = addr + sizeof(seqA7);
|
||||
EEPROM.get(addr, seqA8);
|
||||
addr = addr + sizeof(seqA8);
|
||||
EEPROM.get(addr, seqB1);
|
||||
addr = addr + sizeof(seqB1);
|
||||
EEPROM.get(addr, seqB2);
|
||||
addr = addr + sizeof(seqB2);
|
||||
EEPROM.get(addr, seqB3);
|
||||
addr = addr + sizeof(seqB3);
|
||||
EEPROM.get(addr, seqB4);
|
||||
addr = addr + sizeof(seqB4);
|
||||
EEPROM.get(addr, seqB5);
|
||||
addr = addr + sizeof(seqB5);
|
||||
EEPROM.get(addr, seqB6);
|
||||
addr = addr + sizeof(seqB6);
|
||||
EEPROM.get(addr, seqB7);
|
||||
addr = addr + sizeof(seqB7);
|
||||
EEPROM.get(addr, seqB8);
|
||||
addr = addr + sizeof(seqB8);
|
||||
EEPROM.get(addr, CV1Calibration);
|
||||
addr = addr + sizeof(CV1Calibration);
|
||||
EEPROM.get(addr, CV2Calibration);
|
||||
addr = addr + sizeof(CV2Calibration);
|
||||
EEPROM.get(addr, rotateScreen);
|
||||
} else {
|
||||
//calibrateCVs();
|
||||
saveState();
|
||||
EEPROM.write(1023, memCode);
|
||||
}
|
||||
}
|
||||
|
||||
void reboot() {
|
||||
wdt_enable(WDTO_15MS); //reboot after 15ms
|
||||
while(true);
|
||||
}
|
||||
|
||||
void calibrateCVs() {
|
||||
CV1Calibration = analogRead(ANALOGUE_INPUT_1_PIN);
|
||||
CV2Calibration = analogRead(ANALOGUE_INPUT_2_PIN);
|
||||
showDone = true;
|
||||
updateScreen();
|
||||
}
|
||||
|
||||
void checkScreenRotation() {
|
||||
if (rotateScreen) {
|
||||
u8g2.setDisplayRotation(U8G2_R0);
|
||||
} else {
|
||||
u8g2.setDisplayRotation(U8G2_R2);
|
||||
}
|
||||
}
|
||||
@ -1,192 +0,0 @@
|
||||
void checkInputs() {
|
||||
|
||||
//encoder button
|
||||
if (!digitalRead(ENC_BTN_PIN) && !encPressRegistered) {
|
||||
encPressRegistered = true;
|
||||
encPressedTime = millis();
|
||||
} else if (digitalRead(ENC_BTN_PIN) && encPressRegistered) {
|
||||
encPressRegistered = false;
|
||||
encReleasedTime = millis();
|
||||
|
||||
if (encReleasedTime - encPressedTime < 500) { // press shorter than .5s is for entering the submenu
|
||||
if (insideTab == 0) {
|
||||
insideTab = 1;
|
||||
}
|
||||
updateScreen();
|
||||
} else if (encReleasedTime - encPressedTime < 2000) { // longer press (<2s) is for navigating back. longer than 2s presses are ignored
|
||||
if (insideTab == 1) {
|
||||
insideTab = 0;
|
||||
menuItem = 0;
|
||||
}
|
||||
updateScreen();
|
||||
}
|
||||
}
|
||||
|
||||
//encoder
|
||||
encoder.tick();
|
||||
int encPosition = encoder.getPosition();
|
||||
if (encPositionOld != encPosition) {
|
||||
int change = encPositionOld - encPosition;
|
||||
if (!insideTab && !shiftBtnPushed) { //Change tab
|
||||
displayTab = displayTab + change;
|
||||
if (displayTab > 100) { //to address "negative" numbers
|
||||
displayTab = 0;
|
||||
} else if (displayTab > 6) {
|
||||
displayTab = 6;
|
||||
}
|
||||
} else if (!insideTab && shiftBtnPushed && displayTab == 0 && masterClockMode == 0) { //Change BPM
|
||||
bpm = bpm + change;
|
||||
if (bpm > MAXBPM) {
|
||||
bpm = MAXBPM;
|
||||
} else if (bpm < MINBPM) {
|
||||
bpm = MINBPM;
|
||||
}
|
||||
calculateBPMTiming();
|
||||
} else if (!insideTab && shiftBtnPushed && displayTab != 0) { //Change Subdiv
|
||||
channels[displayTab - 1].subDiv = channels[displayTab - 1].subDiv - change;
|
||||
if (channels[displayTab - 1].subDiv > 200) {
|
||||
channels[displayTab - 1].subDiv = 0;
|
||||
} else if (channels[displayTab - 1].subDiv > (sizeof(subDivs) / sizeof(byte)) - 1) {
|
||||
channels[displayTab - 1].subDiv = (sizeof(subDivs) / sizeof(byte)) - 1;
|
||||
}
|
||||
if (!isPlaying) {
|
||||
calculateCycles();
|
||||
}
|
||||
} else if (insideTab && !shiftBtnPushed) {
|
||||
menuItem = menuItem + change;
|
||||
if (menuItem > 100) { //for "negative" values
|
||||
menuItem = 0;
|
||||
} else if (menuItem > lastMenuItem) {
|
||||
menuItem = lastMenuItem;
|
||||
}
|
||||
} else if (insideTab && shiftBtnPushed && displayTab == 0 && menuItem == 0) { //Master Clock Mode
|
||||
masterClockMode = masterClockMode + change;
|
||||
if (masterClockMode > 100) {
|
||||
masterClockMode = 0;
|
||||
} else if (masterClockMode > 1) {
|
||||
masterClockMode = 1;
|
||||
}
|
||||
} else if (insideTab && shiftBtnPushed && displayTab == 0 && menuItem == 1) { //Modulation channel
|
||||
bpmModulationChannel = bpmModulationChannel + change;
|
||||
if (bpmModulationChannel == 0 || bpmModulationChannel == 1) {
|
||||
bpmModulationRange = 1;
|
||||
} else if (bpmModulationChannel > 100) {
|
||||
bpmModulationRange = 0;
|
||||
bpmModulationChannel = 255;
|
||||
} else if (bpmModulationChannel > 1) {
|
||||
bpmModulationChannel = 1;
|
||||
}
|
||||
} else if (insideTab && shiftBtnPushed && displayTab == 0 && menuItem == 2) { //Modulation range
|
||||
bpmModulationRange = bpmModulationRange + change;
|
||||
if (bpmModulationRange == 0) {
|
||||
bpmModulationRange = 1;
|
||||
} else if (bpmModulationRange > 100) {
|
||||
bpmModulationRange = 1;
|
||||
} else if (bpmModulationRange > 5) { //50bpm
|
||||
bpmModulationRange = 5;
|
||||
}
|
||||
} else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 0) { //Channel Mode
|
||||
channels[displayTab - 1].mode = channels[displayTab - 1].mode + change;
|
||||
if (channels[displayTab - 1].mode > 100) {
|
||||
channels[displayTab - 1].mode = 0;
|
||||
} else if (channels[displayTab - 1].mode > 2) {
|
||||
channels[displayTab - 1].mode = 2;
|
||||
}
|
||||
} else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 1 && channels[displayTab - 1].mode == 0) { //Offset
|
||||
channels[displayTab - 1].offset = channels[displayTab - 1].offset + change;
|
||||
if (channels[displayTab - 1].offset > 100) {
|
||||
channels[displayTab - 1].offset = 0;
|
||||
} else if (channels[displayTab - 1].offset > channelPulsesPerCycle[displayTab-1]) {
|
||||
channels[displayTab - 1].offset = channelPulsesPerCycle[displayTab-1];
|
||||
}
|
||||
} else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 1 && channels[displayTab - 1].mode == 1) { //RANDOM
|
||||
channels[displayTab - 1].random = channels[displayTab - 1].random + change;
|
||||
if (channels[displayTab - 1].random > 100) {
|
||||
channels[displayTab - 1].random = 0;
|
||||
} else if (channels[displayTab - 1].random > 9) {
|
||||
channels[displayTab - 1].random = 9;
|
||||
}
|
||||
} else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 1 && channels[displayTab - 1].mode == 2) { //Seq PAttern
|
||||
channels[displayTab - 1].seqPattern = channels[displayTab - 1].seqPattern + change;
|
||||
if (channels[displayTab - 1].seqPattern > 100) {
|
||||
channels[displayTab - 1].seqPattern = 0;
|
||||
} else if (channels[displayTab - 1].seqPattern > 8) {
|
||||
channels[displayTab - 1].seqPattern = 8;
|
||||
}
|
||||
|
||||
if (channels[displayTab - 1].seqPattern == 0) {
|
||||
currentSeq = seqA1;
|
||||
} else if (channels[displayTab - 1].seqPattern == 1) {
|
||||
currentSeq = seqA2;
|
||||
} else if (channels[displayTab - 1].seqPattern == 2) {
|
||||
currentSeq = seqA3;
|
||||
} else if (channels[displayTab - 1].seqPattern == 3) {
|
||||
currentSeq = seqA4;
|
||||
}
|
||||
} else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 2 && channels[displayTab - 1].mode == 0) { //CV1 for CLK
|
||||
channels[displayTab - 1].CV1Target = channels[displayTab - 1].CV1Target + change;
|
||||
if (channels[displayTab - 1].CV1Target > 100) {
|
||||
channels[displayTab - 1].CV1Target = 0;
|
||||
} else if (channels[displayTab - 1].CV1Target > 1) {
|
||||
channels[displayTab - 1].CV1Target = 1;
|
||||
}
|
||||
}
|
||||
else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 3 && channels[displayTab - 1].mode == 0) { //CV2 for CLK
|
||||
channels[displayTab - 1].CV2Target = channels[displayTab - 1].CV2Target + change;
|
||||
if (channels[displayTab - 1].CV2Target > 100) {
|
||||
channels[displayTab - 1].CV2Target = 0;
|
||||
} else if (channels[displayTab - 1].CV2Target > 1) {
|
||||
channels[displayTab - 1].CV2Target = 1;
|
||||
}
|
||||
} else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 2 && channels[displayTab - 1].mode == 1) { //CV1 for RND
|
||||
channels[displayTab - 1].CV1Target = channels[displayTab - 1].CV1Target + change;
|
||||
if (channels[displayTab - 1].CV1Target > 100) {
|
||||
channels[displayTab - 1].CV1Target = 0;
|
||||
} else if (channels[displayTab - 1].CV1Target > 2) {
|
||||
channels[displayTab - 1].CV1Target = 2;
|
||||
}
|
||||
}
|
||||
else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 3 && channels[displayTab - 1].mode == 1) { //CV2 for RND
|
||||
channels[displayTab - 1].CV2Target = channels[displayTab - 1].CV2Target + change;
|
||||
if (channels[displayTab - 1].CV2Target > 100) {
|
||||
channels[displayTab - 1].CV2Target = 0;
|
||||
} else if (channels[displayTab - 1].CV2Target > 2) {
|
||||
channels[displayTab - 1].CV2Target = 2;
|
||||
}
|
||||
}
|
||||
|
||||
updateScreen();
|
||||
encPositionOld = encPosition;
|
||||
}
|
||||
|
||||
//play button
|
||||
if (!digitalRead(START_STOP_BTN_PIN) && !playBtnPushed) {
|
||||
if (masterClockMode == 0) {
|
||||
calculateBPMTiming();
|
||||
resetClocks();
|
||||
isPlaying = !isPlaying;
|
||||
}
|
||||
playBtnPushed = true;
|
||||
saveState();
|
||||
updateScreen(); //to wake up the screen if turned off
|
||||
} else if (digitalRead(START_STOP_BTN_PIN) && playBtnPushed) {
|
||||
playBtnPushed = false;
|
||||
}
|
||||
|
||||
//shift button
|
||||
if (!digitalRead(SHIFT_BTN_PIN) && !shiftBtnPushed) {
|
||||
shiftBtnPushed = true;
|
||||
//display.fillRoundRect(120, 52, 8, 8, 3, SSD1306_WHITE);
|
||||
//display.display();
|
||||
updateScreen();
|
||||
} else if (digitalRead(SHIFT_BTN_PIN) && shiftBtnPushed) {
|
||||
shiftBtnPushed = false;
|
||||
//display.fillRoundRect(120, 52, 8, 8, 3, SSD1306_BLACK);
|
||||
//display.display();
|
||||
updateScreen();
|
||||
}
|
||||
|
||||
//modulations
|
||||
a1Input = analogRead(ANALOGUE_INPUT_1_PIN);
|
||||
a2Input = analogRead(ANALOGUE_INPUT_2_PIN);
|
||||
}
|
||||
377
Software/Gravity/Interactions.ino
Normal file
377
Software/Gravity/Interactions.ino
Normal file
@ -0,0 +1,377 @@
|
||||
void checkInputs() {
|
||||
|
||||
//encoder button
|
||||
if (!digitalRead(ENC_BTN_PIN) && !encBtnPushed) {
|
||||
encBtnPushed = true;
|
||||
encPressedTime = millis();
|
||||
} else if (digitalRead(ENC_BTN_PIN) && encBtnPushed) {
|
||||
encBtnPushed = false;
|
||||
encReleasedTime = millis();
|
||||
if (showDone) {
|
||||
showDone = false;
|
||||
} else if (encReleasedTime - encPressedTime < 500) { // press shorter than .5s is for entering the submenu
|
||||
if (!insideTab && displayScreen == 0) {
|
||||
insideTab = true;
|
||||
} else if (insideTab && channels[displayTab - 1].mode == 2 && menuItem == 2 && displayScreen == 0) { //enter the pattern editor
|
||||
if (channels[displayTab - 1].seqPattern == 0) {
|
||||
patternToEdit = seqA1;
|
||||
} else if (channels[displayTab - 1].seqPattern == 1) {
|
||||
patternToEdit = seqA2;
|
||||
} else if (channels[displayTab - 1].seqPattern == 2) {
|
||||
patternToEdit = seqA3;
|
||||
} else if (channels[displayTab - 1].seqPattern == 3) {
|
||||
patternToEdit = seqA4;
|
||||
} else if (channels[displayTab - 1].seqPattern == 4) {
|
||||
patternToEdit = seqA5;
|
||||
} else if (channels[displayTab - 1].seqPattern == 5) {
|
||||
patternToEdit = seqA6;
|
||||
} else if (channels[displayTab - 1].seqPattern == 6) {
|
||||
patternToEdit = seqA7;
|
||||
} else if (channels[displayTab - 1].seqPattern == 7) {
|
||||
patternToEdit = seqA8;
|
||||
} else if (channels[displayTab - 1].seqPattern == 8) {
|
||||
patternToEdit = seqB1;
|
||||
} else if (channels[displayTab - 1].seqPattern == 9) {
|
||||
patternToEdit = seqB2;
|
||||
} else if (channels[displayTab - 1].seqPattern == 10) {
|
||||
patternToEdit = seqB3;
|
||||
} else if (channels[displayTab - 1].seqPattern == 11) {
|
||||
patternToEdit = seqB4;
|
||||
} else if (channels[displayTab - 1].seqPattern == 12) {
|
||||
patternToEdit = seqB5;
|
||||
} else if (channels[displayTab - 1].seqPattern == 13) {
|
||||
patternToEdit = seqB6;
|
||||
} else if (channels[displayTab - 1].seqPattern == 14) {
|
||||
patternToEdit = seqB7;
|
||||
} else if (channels[displayTab - 1].seqPattern == 15) {
|
||||
patternToEdit = seqB8;
|
||||
}
|
||||
displayScreen = 1;
|
||||
isRecording = 0;
|
||||
} else if (insideTab && displayScreen == 0) {
|
||||
menuItemSelected = !menuItemSelected;
|
||||
} else if (displayScreen == 1 && !isRecording) {
|
||||
isPlaying = 1;
|
||||
isRecording = 1;
|
||||
} else if (displayScreen == 1 && isRecording) {
|
||||
isRecording = 0;
|
||||
} else if (displayScreen == 2 && menuItem == 0) {
|
||||
calibrateCVs();
|
||||
} else if (displayScreen == 2 && menuItem == 1) {
|
||||
rotateScreen = !rotateScreen;
|
||||
saveState();
|
||||
checkScreenRotation();
|
||||
} else if (displayScreen == 2 && menuItem == 2) {
|
||||
EEPROM.put(1023, memCode - 1);
|
||||
reboot();
|
||||
}
|
||||
} else if (encReleasedTime - encPressedTime < 2000) { // longer press (<2s) is for navigating back. longer than 2s presses are ignored
|
||||
if (displayScreen != 0) {
|
||||
displayScreen = 0;
|
||||
} else if (menuItemSelected == 1) {
|
||||
menuItemSelected = 0;
|
||||
} else if (insideTab == 1) {
|
||||
insideTab = 0;
|
||||
menuItem = 0;
|
||||
isRecording = 0;
|
||||
menuItemSelected = 0;
|
||||
}
|
||||
} else if (encReleasedTime - encPressedTime > 2000 && shiftBtnPushed) { //2s+ combo with shift to open the settings
|
||||
displayScreen = 2;
|
||||
}
|
||||
updateScreen();
|
||||
}
|
||||
|
||||
//encoder
|
||||
encoder.tick();
|
||||
int encPosition = encoder.getPosition();
|
||||
if (encPositionOld != encPosition) {
|
||||
int change = encPositionOld - encPosition;
|
||||
if (displayScreen == 0) {
|
||||
byte channelCV;
|
||||
if (!insideTab && !shiftBtnPushed) { //Change tab
|
||||
displayTab = displayTab + change;
|
||||
if (displayTab > 100) { //to address "negative" numbers
|
||||
displayTab = 0;
|
||||
} else if (displayTab > 6) {
|
||||
displayTab = 6;
|
||||
}
|
||||
} else if (((!insideTab && shiftBtnPushed)
|
||||
|| (insideTab && menuItem == 0
|
||||
&& (menuItemSelected || shiftBtnPushed)))
|
||||
&& displayTab == 0 && masterClockMode == 0) { //Change BPM
|
||||
bpm = bpm + change;
|
||||
if (bpm > MAXBPM) {
|
||||
bpm = MAXBPM;
|
||||
} else if (bpm < MINBPM) {
|
||||
bpm = MINBPM;
|
||||
}
|
||||
saveState();
|
||||
calculateBPMTiming();
|
||||
} else if (((!insideTab && shiftBtnPushed) //Change Subdiv and reset offset
|
||||
|| (insideTab && menuItem == 0
|
||||
&& (menuItemSelected || shiftBtnPushed)))
|
||||
&& displayTab != 0
|
||||
&& channels[displayTab - 1].mode == 0) {
|
||||
channels[displayTab - 1].subDiv = channels[displayTab - 1].subDiv - change;
|
||||
//channels[displayTab - 1].offset = 0;
|
||||
if (channels[displayTab - 1].subDiv > 100) {
|
||||
channels[displayTab - 1].subDiv = 0;
|
||||
} if (channels[displayTab - 1].subDiv > (sizeof(subDivs) / sizeof(int)) - 1) {
|
||||
channels[displayTab - 1].subDiv = (sizeof(subDivs) / sizeof(int)) - 1;
|
||||
}
|
||||
if (!isPlaying) {
|
||||
calculateCycles();
|
||||
}
|
||||
int PulsesPerStep; //offset part
|
||||
if (subDivs[channels[displayTab - 1].subDiv] < 0) {
|
||||
PulsesPerStep = PPQN / subDivs[channels[displayTab - 1].subDiv] * -1 ;
|
||||
} else {
|
||||
PulsesPerStep = subDivs[channels[displayTab - 1].subDiv] * PPQN;
|
||||
}
|
||||
if (channels[displayTab - 1].offset >= PulsesPerStep) {
|
||||
channels[displayTab - 1].offset = PulsesPerStep - 1;
|
||||
}
|
||||
saveState();
|
||||
} else if (((!insideTab && shiftBtnPushed)
|
||||
|| (insideTab && menuItem == 0
|
||||
&& (menuItemSelected || shiftBtnPushed)))
|
||||
&& displayTab != 0
|
||||
&& channels[displayTab - 1].mode == 1) { //Change Random
|
||||
channels[displayTab - 1].random = channels[displayTab - 1].random + change;
|
||||
if (channels[displayTab - 1].random > 100) {
|
||||
channels[displayTab - 1].random = 0;
|
||||
} else if (channels[displayTab - 1].random > 9) {
|
||||
channels[displayTab - 1].random = 9;
|
||||
}
|
||||
saveState();
|
||||
} else if (((!insideTab && shiftBtnPushed)
|
||||
|| (insideTab && menuItem == 0
|
||||
&& (menuItemSelected || shiftBtnPushed)))
|
||||
&& displayTab != 0
|
||||
&& channels[displayTab - 1].mode == 2) { //Change SEQ pattern
|
||||
channels[displayTab - 1].seqPattern = channels[displayTab - 1].seqPattern + change;
|
||||
if (channels[displayTab - 1].seqPattern > 100) {
|
||||
channels[displayTab - 1].seqPattern = 0;
|
||||
} else if (channels[displayTab - 1].seqPattern > 15) {
|
||||
channels[displayTab - 1].seqPattern = 15;
|
||||
}
|
||||
saveState();
|
||||
} else if (insideTab && !shiftBtnPushed && !menuItemSelected) {
|
||||
menuItem = menuItem + change;
|
||||
if (menuItem > 100) { //for "negative" values
|
||||
menuItem = 0;
|
||||
} else if (menuItem > lastMenuItem) {
|
||||
menuItem = lastMenuItem;
|
||||
}
|
||||
} else if (insideTab
|
||||
&& (shiftBtnPushed || menuItemSelected)
|
||||
&& displayTab == 0
|
||||
&& menuItem == 1) { //Master Clock Mode
|
||||
masterClockMode = masterClockMode + change;
|
||||
if (masterClockMode > 100) {
|
||||
masterClockMode = 0;
|
||||
} else if (masterClockMode > 1) {
|
||||
masterClockMode = 1;
|
||||
}
|
||||
saveState();
|
||||
} else if (insideTab && (menuItemSelected || shiftBtnPushed) && displayTab == 0 && menuItem == 2) { //Modulation channel
|
||||
bpmModulationChannel = bpmModulationChannel + change;
|
||||
if (bpmModulationChannel == 0 || bpmModulationChannel == 1) {
|
||||
bpmModulationRange = 1;
|
||||
} else if (bpmModulationChannel > 100) {
|
||||
bpmModulationRange = 0;
|
||||
bpmModulationChannel = 255;
|
||||
} else if (bpmModulationChannel > 1) {
|
||||
bpmModulationChannel = 1;
|
||||
}
|
||||
saveState();
|
||||
} else if (insideTab && (menuItemSelected || shiftBtnPushed) && displayTab == 0 && menuItem == 3) { //Modulation range
|
||||
bpmModulationRange = bpmModulationRange + change;
|
||||
if (bpmModulationRange == 0) {
|
||||
bpmModulationRange = 1;
|
||||
} else if (bpmModulationRange > 100) {
|
||||
bpmModulationRange = 1;
|
||||
} else if (bpmModulationRange > 5) { //50bpm
|
||||
bpmModulationRange = 5;
|
||||
}
|
||||
saveState();
|
||||
} else if (insideTab && (menuItemSelected || shiftBtnPushed) && displayTab != 0 && menuItem == 1) { //Channel Mode
|
||||
channels[displayTab - 1].mode = channels[displayTab - 1].mode + change;
|
||||
if (channels[displayTab - 1].mode > 100) {
|
||||
channels[displayTab - 1].mode = 0;
|
||||
} else if (channels[displayTab - 1].mode > 2) {
|
||||
channels[displayTab - 1].mode = 2;
|
||||
}
|
||||
channels[displayTab - 1].CV1Target = 0;
|
||||
channels[displayTab - 1].CV2Target = 0;
|
||||
saveState();
|
||||
} else if (insideTab && (menuItemSelected || shiftBtnPushed) && displayTab != 0 && menuItem == 2 && channels[displayTab - 1].mode == 0) { //Offset
|
||||
channels[displayTab - 1].offset = channels[displayTab - 1].offset + change;
|
||||
if (channels[displayTab - 1].offset > 1000) {
|
||||
channels[displayTab - 1].offset = 0;
|
||||
} else if (channels[displayTab - 1].offset > channelPulsesPerCycle[displayTab-1]) {
|
||||
channels[displayTab - 1].offset = channelPulsesPerCycle[displayTab-1];
|
||||
}
|
||||
saveState();
|
||||
} else if (insideTab && (menuItemSelected || shiftBtnPushed) && displayTab != 0 && menuItem == 2 && channels[displayTab - 1].mode == 1) { //SUBDIV for RANDOM
|
||||
channels[displayTab - 1].subDiv = channels[displayTab - 1].subDiv - change;
|
||||
if (channels[displayTab - 1].subDiv > 200) {
|
||||
channels[displayTab - 1].subDiv = 0;
|
||||
} else if (channels[displayTab - 1].subDiv > (sizeof(subDivs) / sizeof(byte)) - 1) {
|
||||
channels[displayTab - 1].subDiv = (sizeof(subDivs) / sizeof(byte)) - 1;
|
||||
}
|
||||
if (!isPlaying) {
|
||||
calculateCycles();
|
||||
}
|
||||
saveState();
|
||||
} else if (insideTab && (menuItemSelected || shiftBtnPushed) && displayTab != 0 && menuItem == 3 && channels[displayTab - 1].mode == 0) { //CV for CLK
|
||||
if (channels[displayTab - 1].CV1Target == 1 && channels[displayTab - 1].CV2Target == 0) {
|
||||
channelCV = 1;
|
||||
} else if (channels[displayTab - 1].CV1Target == 0 && channels[displayTab - 1].CV2Target == 1) {
|
||||
channelCV = 2;
|
||||
} else {
|
||||
channelCV = 0;
|
||||
}
|
||||
channelCV = channelCV + change;
|
||||
if (channelCV == 0 || channelCV > 100) {
|
||||
channelCV = 0;
|
||||
channels[displayTab - 1].CV1Target = 0;
|
||||
channels[displayTab - 1].CV2Target = 0;
|
||||
} else if (channelCV == 1) {
|
||||
channels[displayTab - 1].CV1Target = 1;
|
||||
channels[displayTab - 1].CV2Target = 0;
|
||||
} else if (channelCV >= 2) {
|
||||
channelCV = 2;
|
||||
channels[displayTab - 1].CV1Target = 0;
|
||||
channels[displayTab - 1].CV2Target = 1;
|
||||
}
|
||||
saveState();
|
||||
} else if (insideTab && (menuItemSelected || shiftBtnPushed) && displayTab != 0 && menuItem == 3 && channels[displayTab - 1].mode == 1) { //CV for RND
|
||||
if (channels[displayTab - 1].CV1Target == 2 && channels[displayTab - 1].CV2Target == 0) {
|
||||
channelCV = 1;
|
||||
} else if (channels[displayTab - 1].CV1Target == 0 && channels[displayTab - 1].CV2Target == 2) {
|
||||
channelCV = 2;
|
||||
} else {
|
||||
channelCV = 0;
|
||||
}
|
||||
channelCV = channelCV + change;
|
||||
if (channelCV == 0 || channelCV > 100) {
|
||||
channelCV = 0;
|
||||
channels[displayTab - 1].CV1Target = 0;
|
||||
channels[displayTab - 1].CV2Target = 0;
|
||||
} else if (channelCV == 1) {
|
||||
channels[displayTab - 1].CV1Target = 2;
|
||||
channels[displayTab - 1].CV2Target = 0;
|
||||
} else if (channelCV >= 2) {
|
||||
channelCV = 2;
|
||||
channels[displayTab - 1].CV1Target = 0;
|
||||
channels[displayTab - 1].CV2Target = 2;
|
||||
}
|
||||
saveState();
|
||||
} else if (insideTab && (menuItemSelected || shiftBtnPushed) && displayTab != 0 && menuItem == 3 && channels[displayTab - 1].mode == 2) { //CV1 for SEQ
|
||||
if (channels[displayTab - 1].CV1Target == 3 && channels[displayTab - 1].CV2Target == 0) {
|
||||
channelCV = 1;
|
||||
} else if (channels[displayTab - 1].CV1Target == 0 && channels[displayTab - 1].CV2Target == 3) {
|
||||
channelCV = 2;
|
||||
} else {
|
||||
channelCV = 0;
|
||||
}
|
||||
channelCV = channelCV + change;
|
||||
if (channelCV == 0 || channelCV > 100) {
|
||||
channelCV = 0;
|
||||
channels[displayTab - 1].CV1Target = 0;
|
||||
channels[displayTab - 1].CV2Target = 0;
|
||||
} else if (channelCV == 1) {
|
||||
channels[displayTab - 1].CV1Target = 3;
|
||||
channels[displayTab - 1].CV2Target = 0;
|
||||
} else if (channelCV >= 2) {
|
||||
channelCV = 2;
|
||||
channels[displayTab - 1].CV1Target = 0;
|
||||
channels[displayTab - 1].CV2Target = 3;
|
||||
}
|
||||
saveState();
|
||||
}
|
||||
} else if (displayScreen == 1 && !isRecording) {
|
||||
stepNumSelected = stepNumSelected + change;
|
||||
if (stepNumSelected > 100) {
|
||||
stepNumSelected = 15;
|
||||
} else if (stepNumSelected > 15) {
|
||||
stepNumSelected = 0;
|
||||
}
|
||||
} else if (displayScreen == 2 && !shiftBtnPushed) {
|
||||
menuItem = menuItem + change;
|
||||
if (menuItem > 100) { //for "negative" values
|
||||
menuItem = 0;
|
||||
} else if (menuItem > lastMenuItem) {
|
||||
menuItem = lastMenuItem;
|
||||
}
|
||||
}
|
||||
|
||||
updateScreen();
|
||||
encPositionOld = encPosition;
|
||||
}
|
||||
|
||||
//play button
|
||||
if (!digitalRead(START_STOP_BTN_PIN) && !playBtnPushed) {
|
||||
if (masterClockMode == 0) {
|
||||
calculateBPMTiming();
|
||||
resetClocks();
|
||||
isPlaying = !isPlaying;
|
||||
}
|
||||
playBtnPushed = true;
|
||||
updateScreen(); //to wake up the screen if turned off
|
||||
} else if (digitalRead(START_STOP_BTN_PIN) && playBtnPushed) {
|
||||
playBtnPushed = false;
|
||||
}
|
||||
|
||||
//shift button
|
||||
if (!digitalRead(SHIFT_BTN_PIN) && !shiftBtnPushed) {
|
||||
shiftBtnPushed = true;
|
||||
shiftPressedTime = millis();
|
||||
if (isRecording) { //Live triggering
|
||||
digitalWrite(outsPins[displayTab - 1], HIGH);
|
||||
}
|
||||
if (displayScreen == 1 && !isRecording) {
|
||||
patternToEdit[stepNumSelected] = !patternToEdit[stepNumSelected];
|
||||
} else if (displayScreen == 1 && isRecording && !recordToNextStep) { //Recording
|
||||
patternToEdit[currentStep] = 1;
|
||||
} else if (displayScreen == 1 && isRecording && recordToNextStep && currentStep != 15) {
|
||||
patternToEdit[currentStep+1] = 1;
|
||||
} else if (displayScreen == 1 && isRecording && recordToNextStep && currentStep == 15) {
|
||||
patternToEdit[0] = 1;
|
||||
}
|
||||
saveState();
|
||||
updateScreen();
|
||||
} else if (digitalRead(SHIFT_BTN_PIN) && shiftBtnPushed) {
|
||||
shiftBtnPushed = false;
|
||||
shiftReleasedTime = millis();
|
||||
if (shiftReleasedTime - shiftPressedTime > 500 && shiftReleasedTime - shiftPressedTime < 2000 && isRecording) {
|
||||
for (byte i = 0; i < 16; i++) {
|
||||
patternToEdit[i] = 0;
|
||||
}
|
||||
} else if (shiftReleasedTime - shiftPressedTime > 2000 && encBtnPushed) {
|
||||
displayScreen = 2;
|
||||
}
|
||||
saveState();
|
||||
updateScreen();
|
||||
}
|
||||
|
||||
if (analogRead(ANALOGUE_INPUT_1_PIN) > (CV1Calibration)) {
|
||||
CV1Input = map(analogRead(ANALOGUE_INPUT_1_PIN), CV1Calibration, 1023, 512, 1023);
|
||||
} else if (analogRead(ANALOGUE_INPUT_1_PIN) < (CV1Calibration-5)) { //-5 is to shift a -1 break point a little lower
|
||||
CV1Input = map(analogRead(ANALOGUE_INPUT_1_PIN), 0, CV1Calibration-5, 0, 512);
|
||||
} else {
|
||||
CV1Input = 512;
|
||||
}
|
||||
|
||||
if (analogRead(ANALOGUE_INPUT_2_PIN) > (CV1Calibration)) {
|
||||
CV2Input = map(analogRead(ANALOGUE_INPUT_2_PIN), CV1Calibration, 1023, 512, 1023);
|
||||
} else if (analogRead(ANALOGUE_INPUT_2_PIN) < (CV1Calibration-5)) {
|
||||
CV2Input = map(analogRead(ANALOGUE_INPUT_2_PIN), 0, CV1Calibration-5, 0, 512);
|
||||
} else {
|
||||
CV2Input = 512;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,272 +1,340 @@
|
||||
void updateScreen() {
|
||||
|
||||
display.clearDisplay();
|
||||
u8g2.firstPage();
|
||||
do {
|
||||
byte leftOffset;
|
||||
byte width;
|
||||
//String textToShow;
|
||||
String valueStr;
|
||||
char valueChar[16];
|
||||
u8g2.setDrawColor(1);
|
||||
|
||||
//lastInteractionTime = millis(); //not sure if it's a right place for this, but should do for now
|
||||
if (displayScreen == 0) {
|
||||
//BPM Tab
|
||||
if (displayTab == 0) { //BPM
|
||||
|
||||
//Tabs
|
||||
display.drawRect(0, 48, 128, 1, SSD1306_WHITE);
|
||||
display.setCursor(4, 52);
|
||||
display.setTextSize(1);
|
||||
u8g2.setFont(velvetscreen);
|
||||
|
||||
if (displayTab == 0) {
|
||||
if (insideTab == true || shiftBtnPushed == true) {
|
||||
display.drawRoundRect(0, 46, 24, 18, 3, SSD1306_WHITE);
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
} else {
|
||||
display.fillRoundRect(0, 46, 24, 18, 3, SSD1306_WHITE);
|
||||
display.setTextColor(SSD1306_BLACK);
|
||||
}
|
||||
display.print(F("BPM"));
|
||||
} else {
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
display.print(F("BPM"));
|
||||
}
|
||||
//Menu items
|
||||
lastMenuItem = 4;
|
||||
width = 32;
|
||||
leftOffset = 62;
|
||||
if (masterClockMode == 0 && bpmModulationRange == 0) {
|
||||
lastMenuItem = 2;
|
||||
} else if (masterClockMode == 0 && bpmModulationRange != 0) {
|
||||
lastMenuItem = 3;
|
||||
} else if (masterClockMode == 1) {
|
||||
lastMenuItem = 1;
|
||||
}
|
||||
|
||||
for (byte i = 1; i <= lastMenuItem; i++) {
|
||||
if (i == 1) {
|
||||
valueStr = "MODE:";
|
||||
} else if (i == 2 && masterClockMode == 0) {
|
||||
valueStr = "MOD:";
|
||||
} else if (i == 3 && masterClockMode == 0) {
|
||||
valueStr = "RANGE:";
|
||||
}
|
||||
valueStr.toCharArray(valueChar, 16);
|
||||
if (menuItem == i && insideTab) {
|
||||
u8g2.drawButtonUTF8(leftOffset, 8 + (i-1) *11, U8G2_BTN_BW1|U8G2_BTN_INV, width, 1, 2, valueChar );
|
||||
} else {
|
||||
u8g2.drawButtonUTF8(leftOffset, 8 + (i-1) *11, U8G2_BTN_BW0, width, 1, 2, valueChar);
|
||||
}
|
||||
}
|
||||
if (masterClockMode != 0 && menuItem == 0) { //to make main param non selectable for external clock
|
||||
menuItem = 1;
|
||||
}
|
||||
|
||||
//Values
|
||||
for (byte i = 1; i <= lastMenuItem; i++) {
|
||||
if (i == 1 && masterClockMode == 0) { //Channel mode
|
||||
valueStr = "INT";
|
||||
} else if (i == 1 && masterClockMode == 1) {
|
||||
valueStr = "EXT";
|
||||
} else if (i == 2 && masterClockMode == 0 && bpmModulationRange != 0 && bpmModulationChannel == 0) {
|
||||
valueStr = "CV1";
|
||||
} else if (i == 2 && masterClockMode == 0 && bpmModulationRange != 0 && bpmModulationChannel == 1) {
|
||||
valueStr = "CV2";
|
||||
} else if (i == 2 && masterClockMode == 0 && bpmModulationRange == 0) {
|
||||
valueStr = "OFF";
|
||||
} else if (i == 3 && bpmModulationRange != 0) {
|
||||
valueStr = String(bpmModulationRange * 10);
|
||||
}
|
||||
|
||||
valueStr.toCharArray(valueChar, 16);
|
||||
|
||||
if (menuItem == i && insideTab && (menuItemSelected || shiftBtnPushed)) {
|
||||
u8g2.drawButtonUTF8(leftOffset + 37, 8 + (i-1) *11, U8G2_BTN_BW1, 26, 2, 2, valueChar );
|
||||
} else if (menuItem == i && insideTab && (!menuItemSelected || !shiftBtnPushed)) {
|
||||
u8g2.drawButtonUTF8(leftOffset + 37, 8 + (i-1) *11, U8G2_BTN_BW1|U8G2_BTN_INV, 26, 2, 2, valueChar );
|
||||
} else {
|
||||
u8g2.drawButtonUTF8(leftOffset + 37, 8 + (i-1) *11, U8G2_BTN_BW0, 26, 2, 2, valueChar );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String bpmStr;
|
||||
if (masterClockMode == 0) {
|
||||
bpmStr = String(bpm);
|
||||
} else if (masterClockMode == 1) {
|
||||
bpmStr = "24";
|
||||
}
|
||||
char bpmChar[5];
|
||||
bpmStr.toCharArray(bpmChar, 5);
|
||||
leftOffset = 29;
|
||||
width = 55;
|
||||
if (masterClockMode == 0) {
|
||||
if ((!insideTab && !shiftBtnPushed) || (insideTab && menuItem != 0)) { //default view, nothing is selected or editable
|
||||
u8g2.setFont(fabryka);
|
||||
u8g2.drawButtonUTF8(leftOffset-1, 28, U8G2_BTN_BW0|U8G2_BTN_HCENTER, width, 0, 3, bpmChar );
|
||||
u8g2.setFont(velvetscreen);
|
||||
u8g2.drawButtonUTF8(leftOffset, 40, U8G2_BTN_BW0|U8G2_BTN_HCENTER, width, 0, 2, "BPM" );
|
||||
} else if ((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0 && (menuItemSelected || shiftBtnPushed))) { //show value as editable
|
||||
u8g2.setFont(fabryka);
|
||||
u8g2.drawButtonUTF8(leftOffset-1, 28, U8G2_BTN_BW1|U8G2_BTN_HCENTER, width, 0, 3, bpmChar );
|
||||
u8g2.setFont(velvetscreen);
|
||||
u8g2.drawButtonUTF8(leftOffset, 40, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, width, 0, 2, "BPM" );
|
||||
} else if (insideTab && menuItem == 0 && !menuItemSelected) { //show as selected menu item
|
||||
u8g2.setFont(fabryka);
|
||||
u8g2.drawButtonUTF8(leftOffset-1, 28, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, width, 0, 3, bpmChar );
|
||||
u8g2.setFont(velvetscreen);
|
||||
u8g2.drawButtonUTF8(leftOffset, 40, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, width, 0, 2, "BPM" );
|
||||
}
|
||||
}
|
||||
|
||||
if (masterClockMode == 1) {
|
||||
u8g2.setFont(fabryka);
|
||||
u8g2.drawButtonUTF8(leftOffset, 28, U8G2_BTN_BW0|U8G2_BTN_HCENTER, width, 0, 0, bpmChar );
|
||||
u8g2.setFont(velvetscreen);
|
||||
u8g2.drawButtonUTF8(leftOffset, 40, U8G2_BTN_BW0|U8G2_BTN_HCENTER, width, 0, 2, "PPQN" );
|
||||
}
|
||||
|
||||
for (byte i = 1; i <= 6; i++) {
|
||||
if (displayTab == i) {
|
||||
if (insideTab == true || shiftBtnPushed == true) {
|
||||
display.drawRoundRect(i*12 + 12, 46, 13, 18, 3, SSD1306_WHITE);
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
} else {
|
||||
display.fillRoundRect(i*12 + 12, 46, 13, 18, 3, SSD1306_WHITE);
|
||||
display.setTextColor(SSD1306_BLACK);
|
||||
}
|
||||
display.print(" ");
|
||||
display.print(i);
|
||||
} else {
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
display.print(" ");
|
||||
display.print(i);
|
||||
//Channel Tabs
|
||||
else {
|
||||
//Menu items
|
||||
lastMenuItem = 3;
|
||||
width = 32;
|
||||
leftOffset = 62;
|
||||
for (byte i = 1; i <= lastMenuItem; i++) {
|
||||
if (i == 1) {
|
||||
valueStr = "MODE:";
|
||||
} else if (i == 2 && channels[displayTab - 1].mode == 0) {
|
||||
valueStr = "OFFSET:";
|
||||
} else if (i == 2 && channels[displayTab - 1].mode == 1) {
|
||||
valueStr = "SUBDIV:";
|
||||
} else if (i == 2 && channels[displayTab - 1].mode == 2) {
|
||||
valueStr = "EDIT PATTERN";
|
||||
} else if (i == 3) {
|
||||
valueStr = "MOD:";
|
||||
}
|
||||
valueStr.toCharArray(valueChar, 16);
|
||||
if (menuItem == i && insideTab) {
|
||||
u8g2.drawButtonUTF8(leftOffset, 8 + (i-1) *11, U8G2_BTN_BW1|U8G2_BTN_INV, width, 1, 2, valueChar );
|
||||
} else {
|
||||
u8g2.drawButtonUTF8(leftOffset, 8 + (i-1) *11, U8G2_BTN_BW0, width, 1, 2, valueChar);
|
||||
}
|
||||
}
|
||||
|
||||
//Values
|
||||
for (byte i = 1; i <= lastMenuItem; i++) {
|
||||
if (i == 1 && channels[displayTab - 1].mode == 0) { //Channel mode
|
||||
valueStr = "CLOCK";
|
||||
} else if (i == 1 && channels[displayTab - 1].mode == 1) {
|
||||
valueStr = "RAND";
|
||||
} else if (i == 1 && channels[displayTab - 1].mode == 2) {
|
||||
valueStr = "SEQ";
|
||||
} else if (i == 2 && channels[displayTab - 1].mode == 0) { //SubDiv and offset
|
||||
valueStr = String(channels[displayTab - 1].offset) + "/";
|
||||
int PulsesPerStep;
|
||||
if (subDivs[channels[displayTab - 1].subDiv] < 0) {
|
||||
PulsesPerStep = PPQN / subDivs[channels[displayTab - 1].subDiv] * -1 ;
|
||||
} else {
|
||||
PulsesPerStep = subDivs[channels[displayTab - 1].subDiv] * PPQN;
|
||||
}
|
||||
valueStr = valueStr + String(PulsesPerStep); //(playingModes[i] * PPQN) - 1 //String(channelPulsesPerCycle[displayTab-1]+1)
|
||||
} else if (i == 2 && channels[displayTab - 1].mode == 1 && subDivs[channels[displayTab - 1].subDiv] > 0) {
|
||||
valueStr = "/" + String(subDivs[channels[displayTab - 1].subDiv]);
|
||||
} else if (i == 2 && channels[displayTab - 1].mode == 1 && subDivs[channels[displayTab - 1].subDiv] < 0) {
|
||||
valueStr = "x" + String(abs(subDivs[channels[displayTab - 1].subDiv]));
|
||||
} else if (i == 3 && channels[displayTab - 1].CV1Target == 0 && channels[displayTab - 1].CV2Target == 0) { //MOD
|
||||
valueStr = "OFF";
|
||||
} else if (i == 3 && channels[displayTab - 1].CV1Target != 0 && channels[displayTab - 1].CV2Target == 0) {
|
||||
valueStr = "CV1";
|
||||
} else if (i == 3 && channels[displayTab - 1].CV1Target == 0 && channels[displayTab - 1].CV2Target != 0) {
|
||||
valueStr = "CV2";
|
||||
}
|
||||
|
||||
valueStr.toCharArray(valueChar, 16);
|
||||
if (i == 2 && channels[displayTab - 1].mode == 2) { //EDIT PATTERN thing
|
||||
if (menuItem == i && insideTab) {
|
||||
u8g2.drawBox(leftOffset + 54, ((i-1) * 11), 11, 11);
|
||||
}
|
||||
} else {
|
||||
if (menuItem == i && insideTab && (menuItemSelected || shiftBtnPushed)) {
|
||||
u8g2.drawButtonUTF8(leftOffset + 37, 8 + (i-1) *11, U8G2_BTN_BW1, 26, 2, 2, valueChar );
|
||||
} else if (menuItem == i && insideTab && (!menuItemSelected || !shiftBtnPushed)) {
|
||||
u8g2.drawButtonUTF8(leftOffset + 37, 8 + (i-1) *11, U8G2_BTN_BW1|U8G2_BTN_INV, 26, 2, 2, valueChar );
|
||||
} else {
|
||||
u8g2.drawButtonUTF8(leftOffset + 37, 8 + (i-1) *11, U8G2_BTN_BW0, 26, 2, 2, valueChar );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Main Param
|
||||
leftOffset = 29;
|
||||
width = 55;
|
||||
if (channels[displayTab - 1].mode == 0) {
|
||||
valueStr = "SUBDIVISION";
|
||||
} else if (channels[displayTab - 1].mode == 1) {
|
||||
valueStr = "SKIP CHANCE";
|
||||
} else if (channels[displayTab - 1].mode == 2) {
|
||||
valueStr = "PATTERN";
|
||||
}
|
||||
valueStr.toCharArray(valueChar, 16);
|
||||
if ((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0)) {
|
||||
u8g2.drawButtonUTF8(leftOffset, 41, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, width, 0, 3, valueChar );
|
||||
} else {
|
||||
u8g2.drawButtonUTF8(leftOffset, 41, U8G2_BTN_BW0|U8G2_BTN_HCENTER, width, 1, 2, valueChar );
|
||||
}
|
||||
|
||||
if (channels[displayTab - 1].mode == 0) {
|
||||
if (subDivs[channels[displayTab - 1].subDiv] > 0) {
|
||||
valueStr = "/" + String(subDivs[channels[displayTab - 1].subDiv]);
|
||||
} else {
|
||||
valueStr = "x" + String(abs(subDivs[channels[displayTab - 1].subDiv]));
|
||||
}
|
||||
} else if (channels[displayTab - 1].mode == 1) {
|
||||
valueStr = String(channels[displayTab - 1].random) + "0%";
|
||||
} else if (channels[displayTab - 1].mode == 2) {
|
||||
if (channels[displayTab - 1].seqPattern < 8) {
|
||||
valueStr = "A" + String(channels[displayTab - 1].seqPattern + 1);
|
||||
} else {
|
||||
valueStr = "B" + String(channels[displayTab - 1].seqPattern - 7);
|
||||
}
|
||||
}
|
||||
valueStr.toCharArray(valueChar, 16);
|
||||
u8g2.setFont(fabryka);
|
||||
if ((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0 && (menuItemSelected || shiftBtnPushed))) {
|
||||
u8g2.drawButtonUTF8(leftOffset, 28, U8G2_BTN_BW1|U8G2_BTN_HCENTER, width, 0, 3, valueChar );
|
||||
} else if (insideTab && menuItem == 0 && !menuItemSelected) {
|
||||
u8g2.drawButtonUTF8(leftOffset, 28, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, width, 0, 3, valueChar );
|
||||
} else {
|
||||
u8g2.drawButtonUTF8(leftOffset, 28, U8G2_BTN_BW0|U8G2_BTN_HCENTER, width, 0, 3, valueChar );
|
||||
}
|
||||
}
|
||||
|
||||
//Tabs
|
||||
u8g2.drawHLine(0, 53, 128);
|
||||
u8g2.setFont(velvetscreen);
|
||||
byte yPos = 61;
|
||||
byte xWidth = 12;
|
||||
if (displayTab == 0) {
|
||||
if (insideTab == true || shiftBtnPushed == true) {
|
||||
u8g2.drawButtonUTF8(xWidth/2, yPos, U8G2_BTN_BW1|U8G2_BTN_HCENTER, xWidth-2, 0, 2, "w" );
|
||||
} else {
|
||||
u8g2.drawButtonUTF8(xWidth/2, yPos, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, xWidth-2, 0, 2, "w" );
|
||||
}
|
||||
} else {
|
||||
u8g2.drawButtonUTF8(xWidth/2, yPos, U8G2_BTN_BW0|U8G2_BTN_HCENTER, xWidth, 0, 2, "w" );
|
||||
}
|
||||
|
||||
for (int i = 1; i <= 6; i++) {
|
||||
String tabNameStr = String(i);
|
||||
char tabNameChar[3];
|
||||
tabNameStr.toCharArray(tabNameChar, 3);
|
||||
if (displayTab == i) {
|
||||
if (insideTab == true || shiftBtnPushed == true) {
|
||||
u8g2.drawButtonUTF8(i*xWidth + xWidth/2, yPos, U8G2_BTN_BW1|U8G2_BTN_HCENTER, xWidth-2, 0, 2, tabNameChar);
|
||||
} else {
|
||||
u8g2.drawButtonUTF8(i*xWidth + xWidth/2, yPos, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, xWidth-2, 0, 2, tabNameChar);
|
||||
}
|
||||
} else {
|
||||
u8g2.drawButtonUTF8(i*xWidth + xWidth/2, yPos, U8G2_BTN_BW0|U8G2_BTN_HCENTER, xWidth, 0, 2, tabNameChar);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isPlaying) {
|
||||
u8g2.drawUTF8(121, yPos, "t");
|
||||
} else {
|
||||
u8g2.drawUTF8(122, yPos, "r");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
display.drawRect(0, 46, 128, 2, SSD1306_BLACK); //to crop off parts of tabs round rect
|
||||
//Edit Pattern Screen
|
||||
else if (displayScreen == 1) {
|
||||
byte pattern = channels[displayTab - 1].seqPattern;
|
||||
String patStr;
|
||||
if (pattern < 8) {
|
||||
patStr = "EDIT PATTERN A" + String(pattern + 1);
|
||||
} else {
|
||||
patStr = "EDIT PATTERN B" + String(pattern - 7);
|
||||
}
|
||||
char patChar[16];
|
||||
patStr.toCharArray(patChar, 16);
|
||||
u8g2.drawButtonUTF8(64, 5, U8G2_BTN_BW1|U8G2_BTN_HCENTER, 128, 0, 2, patChar );
|
||||
for (byte i = 0; i < 8; i++) {
|
||||
if (patternToEdit[i]) {
|
||||
u8g2.drawUTF8(19 + i*12, 24, "q");
|
||||
} else {
|
||||
u8g2.drawUTF8(19 + i*12, 24, "p");
|
||||
}
|
||||
}
|
||||
for (byte i = 8; i < 16; i++) {
|
||||
if (patternToEdit[i]) {
|
||||
u8g2.drawUTF8(19 + (i-8)*12, 40, "q");
|
||||
} else {
|
||||
u8g2.drawUTF8(19 + (i-8)*12, 40, "p");
|
||||
}
|
||||
}
|
||||
if (!isRecording) {
|
||||
if (stepNumSelected < 8 ) {
|
||||
u8g2.drawFrame(16 + stepNumSelected * 12, 16, 11, 11);
|
||||
} else {
|
||||
u8g2.drawFrame(16 + (stepNumSelected-8) * 12, 32, 11, 11);
|
||||
}
|
||||
}
|
||||
|
||||
//Submenu
|
||||
if (insideTab) {
|
||||
display.fillRoundRect(60, menuItem*12, 68, 10, 2, SSD1306_WHITE);
|
||||
}
|
||||
if (displayTab == 0) { //BPM
|
||||
if (masterClockMode == 0 && bpmModulationRange == 0) {
|
||||
lastMenuItem = 1;
|
||||
} else if (masterClockMode == 0 && bpmModulationRange != 0) {
|
||||
if (isRecording) {
|
||||
u8g2.drawButtonUTF8(64, 62, U8G2_BTN_BW1|U8G2_BTN_HCENTER|U8G2_BTN_INV, 50, 0, 2, "RECORDING" );
|
||||
}
|
||||
}
|
||||
|
||||
//Settings Screen
|
||||
else if (displayScreen == 2) {
|
||||
u8g2.drawStr(8, 5,"SETTINGS" );
|
||||
u8g2.drawStr(102, 5, version );
|
||||
u8g2.drawHLine(0, 8, 128);
|
||||
lastMenuItem = 2;
|
||||
} else if (masterClockMode == 1) {
|
||||
lastMenuItem = 0;
|
||||
}
|
||||
if (menuItem == 0 && insideTab) {
|
||||
display.setTextColor(SSD1306_BLACK);
|
||||
} else {
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
}
|
||||
display.setCursor(62, 1);
|
||||
display.println(F("CLK:"));
|
||||
if (masterClockMode == 0) {
|
||||
byte width = 112;
|
||||
if (menuItem == 0) {
|
||||
u8g2.drawButtonUTF8(8, 19, U8G2_BTN_BW0|U8G2_BTN_INV, width, 2, 3, "CALIBRATE CV INS" );
|
||||
} else {
|
||||
u8g2.drawButtonUTF8(8, 19, U8G2_BTN_BW0, width, 2, 3, "CALIBRATE CV INS" );
|
||||
}
|
||||
if (menuItem == 1) {
|
||||
display.setTextColor(SSD1306_BLACK);
|
||||
u8g2.drawButtonUTF8(8, 31, U8G2_BTN_BW0|U8G2_BTN_INV, width, 2, 3, "ROTATE SCREEN" );
|
||||
} else {
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
}
|
||||
display.setCursor(62, 13);
|
||||
display.println(F("MOD:"));
|
||||
if (menuItem == 2) {
|
||||
display.setTextColor(SSD1306_BLACK);
|
||||
} else {
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
}
|
||||
if (bpmModulationRange != 0) {
|
||||
display.setCursor(62, 25);
|
||||
display.println(F("RNG:"));
|
||||
}
|
||||
}
|
||||
|
||||
} else { //CHANNELS
|
||||
lastMenuItem = 3;
|
||||
if (menuItem == 0 && insideTab) {
|
||||
display.setTextColor(SSD1306_BLACK);
|
||||
} else {
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
}
|
||||
display.setCursor(62, 1);
|
||||
display.println(F("MODE:"));
|
||||
if (menuItem == 1) {
|
||||
display.setTextColor(SSD1306_BLACK);
|
||||
} else {
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
}
|
||||
display.setCursor(62, 13);
|
||||
if (channels[displayTab - 1].mode == 0) {
|
||||
display.println(F("OFT:"));
|
||||
} else if (channels[displayTab - 1].mode == 1) {
|
||||
display.println(F("RND:"));
|
||||
} else if (channels[displayTab - 1].mode == 2) {
|
||||
display.println(F("PAT:"));
|
||||
}
|
||||
if (menuItem == 2) {
|
||||
display.setTextColor(SSD1306_BLACK);
|
||||
} else {
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
}
|
||||
display.setCursor(62, 25);
|
||||
display.println(F("CV1:"));
|
||||
if (menuItem == 3) {
|
||||
display.setTextColor(SSD1306_BLACK);
|
||||
} else {
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
}
|
||||
display.setCursor(62, 37);
|
||||
display.println(F("CV2:"));
|
||||
}
|
||||
|
||||
//Submenu Values
|
||||
if (displayTab == 0) { //BPM
|
||||
if (menuItem == 0 && insideTab) {
|
||||
display.setTextColor(SSD1306_BLACK);
|
||||
} else {
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
}
|
||||
display.setCursor(94, 1);
|
||||
if (masterClockMode == 0) {
|
||||
display.println(F("INT"));
|
||||
} else if (masterClockMode == 1) {
|
||||
display.println(F("EXT"));
|
||||
}
|
||||
if (masterClockMode == 0) {
|
||||
if (menuItem == 1) {
|
||||
display.setTextColor(SSD1306_BLACK);
|
||||
} else {
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
}
|
||||
display.setCursor(94, 13);
|
||||
if (bpmModulationRange != 0 && bpmModulationChannel == 0) {
|
||||
display.println(F("CV1"));
|
||||
} else if (bpmModulationRange != 0 && bpmModulationChannel == 1) {
|
||||
display.println(F("CV2"));
|
||||
} else if (bpmModulationRange == 0) {
|
||||
display.println(F("OFF"));
|
||||
u8g2.drawButtonUTF8(8, 31, U8G2_BTN_BW0, width, 2, 3, "ROTATE SCREEN" );
|
||||
}
|
||||
if (menuItem == 2) {
|
||||
display.setTextColor(SSD1306_BLACK);
|
||||
u8g2.drawButtonUTF8(8, 43, U8G2_BTN_BW0|U8G2_BTN_INV, width, 2, 3, "FACTORY RESET" );
|
||||
} else {
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
}
|
||||
display.setCursor(94, 25);
|
||||
if (bpmModulationRange != 0) {
|
||||
display.println(bpmModulationRange * 10);
|
||||
u8g2.drawButtonUTF8(8, 43, U8G2_BTN_BW0, width, 2, 3, "FACTORY RESET" );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else { //CHANNELS
|
||||
if (menuItem == 0 && insideTab) {
|
||||
display.setTextColor(SSD1306_BLACK);
|
||||
} else {
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
if (showDone) {
|
||||
//u8g2.clear();
|
||||
u8g2.setDrawColor(0);
|
||||
u8g2.setFontMode(0);
|
||||
u8g2.drawBox(18,13,93,32);
|
||||
u8g2.drawBox(18,16,96,30);
|
||||
u8g2.setDrawColor(1);
|
||||
u8g2.drawButtonUTF8(64, 32, U8G2_BTN_BW1|U8G2_BTN_HCENTER|U8G2_BTN_SHADOW2|U8G2_BTN_INV, 64, 12, 12, "DONE" );
|
||||
}
|
||||
display.setCursor(94, 1);
|
||||
if (channels[displayTab - 1].mode == 0) {
|
||||
display.print(F("CLK"));
|
||||
} else if (channels[displayTab - 1].mode == 1) {
|
||||
display.print(F("RND"));
|
||||
} else if (channels[displayTab - 1].mode == 2) {
|
||||
display.print(F("SEQ"));
|
||||
}
|
||||
if (menuItem == 1) {
|
||||
display.setTextColor(SSD1306_BLACK);
|
||||
} else {
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
}
|
||||
display.setCursor(94, 13);
|
||||
if (channels[displayTab - 1].mode == 0) { //OFFSET
|
||||
display.print(channels[displayTab - 1].offset);
|
||||
display.print(F("/"));
|
||||
display.print(channelPulsesPerCycle[displayTab-1]+1);
|
||||
display.print(F(" "));
|
||||
} else if (channels[displayTab - 1].mode == 1) { //RANDOM
|
||||
display.print(channels[displayTab - 1].random);
|
||||
display.print(F("0% "));
|
||||
} else if (channels[displayTab - 1].mode == 2) { //SEQ
|
||||
display.print(channels[displayTab - 1].seqPattern + 1);
|
||||
}
|
||||
if (menuItem == 2) {
|
||||
display.setTextColor(SSD1306_BLACK);
|
||||
} else {
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
}
|
||||
display.setCursor(94, 25);
|
||||
if (channels[displayTab - 1].CV1Target == 1) {
|
||||
display.print(F("DIV"));
|
||||
//display.print(channels[displayTab - 1].CV1Value);
|
||||
} else if (channels[displayTab - 1].CV1Target == 2) {
|
||||
display.print(F("RND"));
|
||||
//display.print(channels[displayTab - 1].CV1Value);
|
||||
} else if (channels[displayTab - 1].CV1Target == 3) {
|
||||
display.print(F("PAT"));
|
||||
//display.print(channels[displayTab - 1].CV1Value);
|
||||
} else {
|
||||
display.print(F("OFF "));
|
||||
}
|
||||
if (menuItem == 3) {
|
||||
display.setTextColor(SSD1306_BLACK);
|
||||
} else {
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
}
|
||||
display.setCursor(94, 37);
|
||||
if (channels[displayTab - 1].CV2Target == 1) {
|
||||
display.print(F("DIV"));
|
||||
//display.print(channels[displayTab - 1].CV2Value);
|
||||
} else if (channels[displayTab - 1].CV2Target == 2) {
|
||||
display.print(F("RND"));
|
||||
//display.print(channels[displayTab - 1].CV2Value);
|
||||
} else if (channels[displayTab - 1].CV2Target == 3) {
|
||||
display.print(F("PAT"));
|
||||
//display.print(channels[displayTab - 1].CV2Value);
|
||||
} else {
|
||||
display.print(F("OFF "));
|
||||
}
|
||||
}
|
||||
|
||||
//Content
|
||||
display.setCursor(2, 2);
|
||||
display.setTextSize(3);
|
||||
if (!insideTab && shiftBtnPushed){
|
||||
display.fillRoundRect(0, 0, 58, 42, 5, SSD1306_WHITE);
|
||||
display.setTextColor(SSD1306_BLACK);
|
||||
} else {
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
}
|
||||
if (displayTab == 0 && masterClockMode == 0) {
|
||||
if (bpm < 100) {
|
||||
display.print(" ");
|
||||
}
|
||||
display.println(bpm);
|
||||
display.setCursor(19, 26);
|
||||
display.setTextSize(2);
|
||||
display.println(F("BPM"));
|
||||
} else if (displayTab == 0 && masterClockMode == 1) {
|
||||
display.println(F(" 24"));
|
||||
display.setCursor(8, 26);
|
||||
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 (subDivs[channels[displayTab - 1].subDiv] == 0) {
|
||||
display.print(F("OFF"));
|
||||
} else if (subDivs[channels[displayTab - 1].subDiv] > 0) {
|
||||
display.print(F("/"));
|
||||
display.print(abs(subDivs[channels[displayTab - 1].subDiv]));
|
||||
} else {
|
||||
display.print(F("x"));
|
||||
display.print(abs(subDivs[channels[displayTab - 1].subDiv]));
|
||||
}
|
||||
}
|
||||
|
||||
display.display();
|
||||
} while ( u8g2.nextPage() );
|
||||
}
|
||||
Reference in New Issue
Block a user