Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 40d4aac7ba | |||
| fb86269b21 | |||
| bf01c01ce9 | |||
| ecf8e53d1b |
14
.gitignore
vendored
14
.gitignore
vendored
@ -1,17 +1,5 @@
|
||||
software/.DS_Store
|
||||
.DS_Store
|
||||
Hardware/gtoe/gtoe-backups
|
||||
Hardware/gtoe/fp-info-cache
|
||||
Hardware/gtoe/#auto_saved_files#
|
||||
|
||||
README.MD.backup
|
||||
Hardware/gtoe/_autosave-gtoe.kicad_pcb
|
||||
|
||||
Hardware/gtoe/gtoe.kicad_sch-bak
|
||||
Hardware/gtoe/_autosave-gtoe.kicad_sch
|
||||
Software/Gravity/build/arduino.avr.nano
|
||||
Software/Gravity/build/arduino.avr.nano
|
||||
Hardware/gtoe/midi-backups
|
||||
Hardware/gtoe/midi-panel-backups
|
||||
Hardware/gtoe/MIDI Board REV1.zip
|
||||
Hardware/gtoe/MIDI Panel REV1.zip
|
||||
src/Gravity/build/
|
||||
@ -1,36 +0,0 @@
|
||||
//
|
||||
//Abel: at 120bpm the actual output is 119.3bpm (47.7Hz). Does this depend on each individual power supply? Would it be possible to calibrate 120bpm to 48Hz?
|
||||
//
|
||||
// in theory it should be 600000 / (120 * 24) = 208.333(3). 20.8ms should result in 48.076923076923
|
||||
#include <FixedPoints.h>
|
||||
#include <FixedPointsCommon.h>
|
||||
|
||||
|
||||
//uint16_t pulsePeriod; //useful range of 0 to 65,535 ((2^16) - 1).
|
||||
UFixed<7, 9> bpm = 120; //0-255
|
||||
|
||||
#define PPQN 24
|
||||
#define PULSE_LENGTH 120 //1/10ms resolution. 12ms was failing at 1ms resolution at higher bpm. 60000/200/24 = 12.5 the max pulse length at 1ms resolution for 200bpm is 11ms
|
||||
#define MAXBPM 200 //250 at 24ppqn with 5ms pulse will be 50/50 square wave
|
||||
#define MINBPM 20
|
||||
|
||||
void setup() {
|
||||
Serial.begin(19200);
|
||||
int pulsePeriod = 600000 / (bpm.getInteger() * PPQN);
|
||||
Serial.print("original uint16_t: ");
|
||||
Serial.println(pulsePeriod);
|
||||
float floatperiod = 600000 / ((float)bpm * (float)PPQN);
|
||||
Serial.print("float: ");
|
||||
Serial.println(floatperiod);
|
||||
// fpperiod = 600000 / (bpm * PPQN);
|
||||
//Serial.print("UQ8x8: ");
|
||||
//Serial.println((float)fpperiod);
|
||||
UFixed<7, 9> fpperiodplus = 600000 / (bpm * PPQN);
|
||||
Serial.print("UQ7x9: ");
|
||||
Serial.println((float)fpperiodplus);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
|
||||
}
|
||||
@ -1,164 +0,0 @@
|
||||
#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);
|
||||
}
|
||||
}
|
||||
@ -1,106 +0,0 @@
|
||||
#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);
|
||||
}
|
||||
}
|
||||
674
LICENSE
Normal file
674
LICENSE
Normal file
@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
29
README.MD
29
README.MD
@ -1,25 +1,10 @@
|
||||
6hp multichannel eurorack clock and trigger utility designed to be low cost and DIY friendly.
|
||||
# Sitka Instruments Gravity Firmware
|
||||
Arduino project of [Sitka Instruments Gravity](https://sitkainstruments.com/gravity/) eurorack clock module firmware.
|
||||
|
||||
> It is like a "Pamela's 'very light' Workout" ;)
|
||||
>
|
||||
> —u/BBougre
|
||||
Designed and developed by Oleksiy Hrachov.
|
||||
|
||||
### Features:
|
||||
- 24ppqn internal clock with master BPM
|
||||
- 6 output channels
|
||||
- Separate divider or multiplier per chennel (from /32 to x24)
|
||||
- Per-channel random pulse skip probability setting
|
||||
- Per-channel offset setting
|
||||
- 2 inputs for external modulation (assignable per channel)
|
||||
- All channel settings and bpm are saved on play/pause and recalled on power up
|
||||
- 2 external clock modes (24ppqn and beat)
|
||||
|
||||
### TODO:
|
||||
- swing
|
||||
- settings (pulse length, display timeout)
|
||||
- expanders with midi/tap tempo etc
|
||||
|
||||
### Acknowlidgements
|
||||
Timer library available here
|
||||
https://github.com/PaulStoffregen/FlexiTimer2
|
||||
Licence: GPLv3
|
||||
|
||||
Related repos:
|
||||
- [Gravity Hardware](https://git.sitkainstruments.com/Oleksiy/GravityHW)
|
||||
- [Gravity MIDI Expander Hardware](https://git.sitkainstruments.com/Oleksiy/GravityMIDIExpanderHW)
|
||||
|
||||
@ -1,649 +0,0 @@
|
||||
#include <Wire.h>
|
||||
#include <FlexiTimer2.h>
|
||||
#include <EEPROM.h>
|
||||
#include <U8g2lib.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <NeoHWSerial.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "fonts.h"
|
||||
|
||||
#define VERSION "V:1.2A2"
|
||||
|
||||
uint8_t memCode = '0'; //Change to different letter if you changed the data structure
|
||||
|
||||
uint16_t CV1Calibration = 512;
|
||||
uint16_t CV2Calibration = 512;
|
||||
bool showDone = false;
|
||||
|
||||
const int subDivs[] = { -24, -12, -8, -6, -4, -3, -2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 16, 24, 32, 64, 128 }; //positive - divide, negative - multiply, 0 - off
|
||||
|
||||
uint8_t bpm = 130;
|
||||
uint8_t bpmModulationChannel = 200; //0 - CV1, 1 - CV2, 255 - OFF
|
||||
uint8_t bpmModulationRange = 0;
|
||||
|
||||
enum modes {Clock, Random, Sequencer, Swing, Gate};
|
||||
|
||||
struct channel {
|
||||
enum modes mode : 3; //mv: 7. 0 - CLK, 1 - RND, 2 - SEQ, 3 - SWING, 4 - Gate
|
||||
uint8_t subDiv : 5; //mv: 31
|
||||
uint8_t random : 4; //mv: 15
|
||||
uint8_t seqPattern : 5;
|
||||
uint8_t CV1Target : 3; //0 - Off, 1 - Subdiv, 2 - RND, 3 - SeqPattern
|
||||
uint8_t CV2Target : 3;
|
||||
uint8_t swing : 3;
|
||||
uint8_t offset : 7; //mv: 127
|
||||
uint8_t gate : 7;
|
||||
bool isMute : 1;
|
||||
};
|
||||
|
||||
channel channels[7] = { //array of channel settings
|
||||
{ 0, 7, 0, 0, 0, 0, 0, 0, 1, 0 },
|
||||
{ 0, 7, 0, 0, 0, 0, 0, 0, 1, 0 },
|
||||
{ 0, 7, 0, 0, 0, 0, 0, 0, 1, 0 },
|
||||
{ 0, 7, 0, 0, 0, 0, 0, 0, 1, 0 },
|
||||
{ 0, 7, 0, 0, 0, 0, 0, 0, 1, 0 },
|
||||
{ 0, 7, 0, 0, 0, 0, 0, 0, 1, 0 },
|
||||
{ 0, 7, 0, 0, 0, 0, 0, 0, 1, 0 }
|
||||
};
|
||||
|
||||
struct sequence {
|
||||
uint32_t sequence;
|
||||
uint8_t length : 5 ; //don't forget to add 1 where needed, values 0 - 31
|
||||
};
|
||||
|
||||
sequence sequences[] {
|
||||
{0b000000000000000001001000100010001, 15},
|
||||
{0b000000000000000000000100000010000, 11},
|
||||
{0b000000000000000000001001001001001, 6},
|
||||
{0b000000000000000001100110011001100, 20},
|
||||
{0b000000000000000001110111011101110, 30},
|
||||
{0b000000000000000000101010001010100, 31},
|
||||
{0b000000000000000000111111111011111, 15},
|
||||
{0b000000000000000001101101110110011, 15},
|
||||
{0b000000000000000000000000000000000, 15},
|
||||
{0b000000000000000000000000000000000, 15},
|
||||
{0b000000000000000000000000000000000, 15},
|
||||
{0b000000000000000000000000000000000, 15},
|
||||
{0b000000000000000000000000000000000, 15},
|
||||
{0b000000000000000000000000000000000, 15},
|
||||
{0b000000000000000000000000000000000, 15},
|
||||
{0b000000000000000000000000000000000, 15},
|
||||
{0b000000000000000000000000000000000, 15},
|
||||
{0b000000000000000000000000000000000, 15},
|
||||
{0b000000000000000000000000000000000, 15},
|
||||
{0b000000000000000000000000000000000, 15},
|
||||
{0b000000000000000000000000000000000, 15},
|
||||
{0b000000000000000000000000000000000, 15},
|
||||
{0b000000000000000000000000000000000, 15},
|
||||
{0b000000000000000000000000000000000, 15},
|
||||
{0b000000000000000000000000000000000, 15},
|
||||
{0b000000000000000000000000000000000, 15},
|
||||
{0b000000000000000000000000000000000, 15},
|
||||
{0b000000000000000000000000000000000, 15},
|
||||
{0b000000000000000000000000000000000, 15},
|
||||
{0b000000000000000000000000000000000, 15},
|
||||
{0b000000000000000000000000000000000, 15},
|
||||
{0b000000000000000000000000000000000, 15}
|
||||
};
|
||||
|
||||
uint8_t currentStep[7] = {0};
|
||||
int8_t stepNumSelected = 0;
|
||||
uint8_t patternToEdit;
|
||||
|
||||
unsigned int channelPulseCount[7];
|
||||
unsigned int channelPulsesPerCycle[7];
|
||||
uint8_t sixteenthPulseCount = 0;
|
||||
int playingModes[7]; // should be renamed to currentSubdivs or something. Updated from channels object on beat and with applied CV modulation
|
||||
int playingModesOld[7];
|
||||
|
||||
uint16_t pulsePeriod;
|
||||
bool isPlaying;// = false; // replace with some flags like uint8_t status where 1xxxxxx isPlaying, x1xxxxx isRecording etc
|
||||
bool isRecording = false;
|
||||
bool recordToNextStep = false;
|
||||
bool MIDIClockReceived = false;
|
||||
|
||||
uint16_t tickCount = 0;
|
||||
uint16_t pulseCount = 0;
|
||||
|
||||
uint8_t masterClockMode = 0; // 0 - internal, 1 - external 24ppqn, 2 - MIDI
|
||||
uint8_t extClockPPQN = 0; // 0 - 24, 1 - 4 (1/16)
|
||||
uint8_t extraChannel = 0; // 0 - off, 1 - pulse out = 7th channel
|
||||
uint32_t lastExtPulseTime = 0;
|
||||
uint32_t newExtPulseTime = 0;
|
||||
|
||||
bool needPulseReset[] = { true, true, true, true, true, true, true }; //to optimise, can be switched to uint8_t
|
||||
uint16_t gateLengthTime[] = {0, 0, 0, 0, 0, 0, 0};
|
||||
uint16_t gateCountDown[7];
|
||||
bool stepIsOdd = 1;
|
||||
|
||||
uint8_t displayTab = 0;
|
||||
bool insideTab = false;
|
||||
uint8_t menuItem = 0;
|
||||
bool menuItemSelected = false;
|
||||
uint8_t lastMenuItem = 3;
|
||||
uint8_t displayScreen = 0; //0 - main, 1 - sequencer, 2 - settings
|
||||
|
||||
int16_t CV1Input = 0;
|
||||
int16_t CV2Input = 0;
|
||||
|
||||
bool playBtnPushed = false;
|
||||
bool shiftBtnPushed = false;
|
||||
bool encBtnPushed;
|
||||
|
||||
int encPositionOld = 0;
|
||||
uint8_t encDirectionOld = 0;
|
||||
uint32_t encPressedTime;
|
||||
uint32_t encReleasedTime;
|
||||
uint32_t playPressedTime;
|
||||
uint32_t playReleasedTime;
|
||||
uint32_t shiftPressedTime;
|
||||
uint32_t shiftReleasedTime;
|
||||
|
||||
|
||||
int extResetCountdown;
|
||||
int extTriggerCount;
|
||||
|
||||
//uint32_t lastInteractionTime; // used for display timeout
|
||||
|
||||
U8G2_SSD1306_128X64_NONAME_2_HW_I2C u8g2(U8G2_R2, SCL, SDA, U8X8_PIN_NONE);
|
||||
|
||||
String version;
|
||||
|
||||
void setup() {
|
||||
version = F(VERSION);
|
||||
|
||||
NeoSerial.begin(31250);
|
||||
NeoSerial.attachInterrupt(receiveMIDI);
|
||||
|
||||
pinMode(ENC_BTN_PIN, INPUT_PULLUP);
|
||||
pinMode(START_STOP_BTN_PIN, INPUT_PULLUP);
|
||||
pinMode(SHIFT_BTN_PIN, INPUT_PULLUP);
|
||||
pinMode(EXT_INPUT_PIN, INPUT_PULLUP);
|
||||
attachInterrupt(digitalPinToInterrupt(EXT_INPUT_PIN), externalClock, FALLING);
|
||||
|
||||
for (uint8_t i = 0; i < 6; i++) {
|
||||
pinMode(outsPins[i], OUTPUT);
|
||||
}
|
||||
|
||||
pinMode(clockOutPin, OUTPUT);
|
||||
|
||||
|
||||
pinMode(ENC_D1_PIN, INPUT_PULLUP);
|
||||
pinMode(ENC_D2_PIN, INPUT_PULLUP);
|
||||
|
||||
//Enabling PinChange Interrupts for the encoder
|
||||
//pins 17 (PC3/PCINT11) and 4 (PD4/PCINT20), ports C and D
|
||||
PCICR |= 0b00000110;
|
||||
PCMSK1 |= 0b00001000;
|
||||
PCMSK2 |= 0b00010000;
|
||||
|
||||
loadState();
|
||||
|
||||
u8g2.begin();
|
||||
checkScreenRotation();
|
||||
updateScreen();
|
||||
|
||||
calculateCycles();
|
||||
calculateBPMTiming();
|
||||
checkEncoderStatus();
|
||||
|
||||
resetClocks();
|
||||
|
||||
FlexiTimer2::set(1, 1.0 / 10000, clock); // 1.0/1000 = 1ms period
|
||||
FlexiTimer2::start();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (masterClockMode == 1 && extClockPPQN == 1) {
|
||||
calculateBPMTiming();
|
||||
}
|
||||
checkInputs();
|
||||
}
|
||||
|
||||
//Encoder interrupts
|
||||
ISR (PCINT1_vect) {
|
||||
checkEncoderStatus();
|
||||
}
|
||||
ISR (PCINT2_vect) {
|
||||
checkEncoderStatus();
|
||||
}
|
||||
|
||||
uint8_t encoderStatus;
|
||||
uint32_t encoderCheckTime = 0;
|
||||
uint32_t encoderTimeBetweenPulses = 0;
|
||||
bool encoderDirectionOld; //0 = -, 1 = +, Old because current direction can be determined by encoderChange
|
||||
int8_t encoderChange = 0;
|
||||
uint8_t encoderBurstCount = 0;
|
||||
|
||||
void checkEncoderStatus() {
|
||||
//bool pin1Status = digitalRead(ENC_D1_PIN);
|
||||
//bool pin2Status = digitalRead(ENC_D2_PIN);
|
||||
uint8_t newStatus = (digitalRead(ENC_D1_PIN) << 1) | digitalRead(ENC_D2_PIN);
|
||||
switch(encoderStatus) { // encoderStatus & 0b00000011 - to check only 2 last bits
|
||||
case 0b00:
|
||||
if (newStatus == 0b01) {
|
||||
encoderChange++;
|
||||
} else if (newStatus == 0b10) {
|
||||
encoderChange--;
|
||||
}
|
||||
break;
|
||||
case 0b01:
|
||||
if (newStatus == 0b11) {
|
||||
encoderChange++;
|
||||
} else if (newStatus == 0b00) {
|
||||
encoderChange--;
|
||||
}
|
||||
break;
|
||||
case 0b11:
|
||||
if (newStatus == 0b10) {
|
||||
encoderChange++;
|
||||
} else if (newStatus == 0b01) {
|
||||
encoderChange--;
|
||||
}
|
||||
break;
|
||||
case 0b10:
|
||||
if (newStatus == 0b00) {
|
||||
encoderChange++;
|
||||
} else if (newStatus == 0b11) {
|
||||
encoderChange--;
|
||||
}
|
||||
break;
|
||||
}
|
||||
encoderStatus = newStatus;
|
||||
|
||||
uint32_t currentTime = millis();
|
||||
encoderTimeBetweenPulses = currentTime - encoderCheckTime;
|
||||
encoderCheckTime = currentTime;
|
||||
}
|
||||
|
||||
void sendMIDIClock() {
|
||||
NeoSerial.write(0xF8);
|
||||
}
|
||||
void sendMIDIStart() {
|
||||
NeoSerial.write(0xFA);
|
||||
}
|
||||
void sendMIDIStop() {
|
||||
NeoSerial.write(0xFC);
|
||||
}
|
||||
|
||||
void receiveMIDI( uint8_t msg, uint8_t status ) {
|
||||
if (masterClockMode == 2) {
|
||||
if (msg == 0xF8) { //Clock tick
|
||||
MIDIClockReceived = true;
|
||||
} else if (msg == 0xFC) { //stop
|
||||
isPlaying = false;
|
||||
} else if (msg == 0xFA || msg == 0xFB) { //start and continue
|
||||
isPlaying = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void clock() {
|
||||
if (isPlaying) {
|
||||
|
||||
// Action on each pulse
|
||||
if (tickCount == 0) {
|
||||
sendTriggers();
|
||||
if (!extraChannel) {
|
||||
digitalWrite(clockOutPin, HIGH);
|
||||
}
|
||||
sendMIDIClock();
|
||||
}
|
||||
|
||||
//this part gets the Pulse and Ticks ticking
|
||||
//it's placed after the triggers to avoid problems on the start (when pulseCount==0)
|
||||
tickCount++;
|
||||
if (masterClockMode == 0) {
|
||||
if (tickCount >= pulsePeriod) {
|
||||
tickCount = 0;
|
||||
if (pulseCount < (PPQN - 1)) { //-1 is here to avoid extra IF to reset to 0
|
||||
pulseCount++;
|
||||
} else {
|
||||
pulseCount = 0;
|
||||
}
|
||||
if (bpmModulationRange != 0) {
|
||||
calculateBPMTiming();
|
||||
for (uint8_t i; i < 7; i++) {
|
||||
if (channels[i].mode == Gate) {
|
||||
calculateGate(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (masterClockMode == 1 && extClockPPQN == 1) {
|
||||
if (tickCount >= pulsePeriod && pulseCount < (PPQN - 1)) { // ((6 * (extTriggerCount + 1)) - 1)) { //this formula puts it out of sync, so there's PPQN-1 for now
|
||||
tickCount = 0;
|
||||
pulseCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (masterClockMode == 2 && MIDIClockReceived) {
|
||||
tickCount = 0; //to make things happen in the main clock function
|
||||
if (pulseCount < (PPQN - 1)) {
|
||||
pulseCount++;
|
||||
} else {
|
||||
pulseCount = 0;
|
||||
}
|
||||
MIDIClockReceived = false;
|
||||
}
|
||||
|
||||
// pull low all outputs after set pulse length
|
||||
for (uint8_t i = 0; i < 7; i++) {
|
||||
if (channels[i].mode != Gate && tickCount >= PULSE_LENGTH) { //everything but gate mode
|
||||
digitalWrite(outsPins[i], LOW);
|
||||
} else if (channels[i].mode == Gate && tickCount >= gateCountDown[i]) { //gate mode gateLengthTime[i] < pulsePeriod
|
||||
digitalWrite(outsPins[i], LOW);
|
||||
gateCountDown[i] = gateLengthTime[i];
|
||||
} else if (channels[i].mode == Gate && gateCountDown[i] > pulsePeriod && tickCount == 0) {
|
||||
gateCountDown[i] = gateCountDown[i] - pulsePeriod;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void externalClock() {
|
||||
lastExtPulseTime = newExtPulseTime;
|
||||
newExtPulseTime = millis();
|
||||
|
||||
if (masterClockMode == 1 && extClockPPQN == 0) { // EXT 24ppqn
|
||||
if (!isPlaying) {
|
||||
isPlaying = true;
|
||||
}
|
||||
|
||||
//reset cycles if there were no pulses for a while
|
||||
if ((newExtPulseTime - lastExtPulseTime) > 125) { //125ms is 20bpm
|
||||
resetClocks();
|
||||
}
|
||||
|
||||
tickCount = 0; //to make things happen in the main clock function
|
||||
if (pulseCount < (PPQN - 1)) {
|
||||
pulseCount++;
|
||||
} else {
|
||||
pulseCount = 0;
|
||||
}
|
||||
} else if (masterClockMode == 1 && extClockPPQN == 1) { //EXT 1/16
|
||||
if (!isPlaying) {
|
||||
isPlaying = true;
|
||||
}
|
||||
if ((newExtPulseTime - lastExtPulseTime) > 750) {
|
||||
resetClocks();
|
||||
extResetCountdown = 0;
|
||||
extTriggerCount = 0;
|
||||
}
|
||||
|
||||
if (extTriggerCount == 0) { //happens on beat
|
||||
pulseCount = 0;
|
||||
tickCount = 0;
|
||||
}
|
||||
if (extTriggerCount < 3) {
|
||||
extTriggerCount++;
|
||||
} else {
|
||||
extTriggerCount = 0;
|
||||
}
|
||||
|
||||
if (extResetCountdown < 4) { //reset on the second beat (5th pulse), so that BPM is already calculated correctly
|
||||
extResetCountdown++;
|
||||
} else if (extResetCountdown == 4) {
|
||||
resetClocks();
|
||||
extResetCountdown++; //to get out of the loop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sendTriggers() { //rename to onPulse or something
|
||||
|
||||
for (uint8_t i = 0; i < (extraChannel ? 7 : 6); i++) {
|
||||
if (playingModes[i] != subDivs[channels[i].subDiv] && playingModesOld[i] != playingModes[i]) {
|
||||
needPulseReset[i] = true;
|
||||
playingModesOld[i] = playingModes[i];
|
||||
}
|
||||
}
|
||||
//16th notes for sequencer and swing
|
||||
if (sixteenthPulseCount == 0) {
|
||||
stepIsOdd = !stepIsOdd;
|
||||
for (uint8_t i = 0; i < (extraChannel ? 7 : 6); i++) {
|
||||
|
||||
//pattern modulation
|
||||
int seqMod = 0;
|
||||
uint8_t 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;
|
||||
}
|
||||
|
||||
bool currentStepValue = bitRead(sequences[channels[i].seqPattern].sequence, currentStep[i]);
|
||||
if (channels[i].mode == Sequencer && currentStepValue && !channels[i].isMute) {
|
||||
digitalWrite(outsPins[i], HIGH);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sixteenthPulseCount < (PPQN / 4) - 1) {
|
||||
sixteenthPulseCount++;
|
||||
if (sixteenthPulseCount > 3) { //quantization. might need fine-tuning
|
||||
recordToNextStep = true;
|
||||
}
|
||||
} else {
|
||||
sixteenthPulseCount = 0;
|
||||
for (uint8_t i; i < 7; i++) {
|
||||
if (channels[i].mode == Sequencer && currentStep[i] < sequences[channels[i].seqPattern].length) {
|
||||
currentStep[i] ++;
|
||||
} else {
|
||||
currentStep[i] = 0;
|
||||
}
|
||||
}
|
||||
recordToNextStep = false;
|
||||
}
|
||||
|
||||
//switching modes on the beat and resetting channel clock
|
||||
if (pulseCount == 0) {
|
||||
calculateCycles();
|
||||
for (uint8_t i = 0; i < (extraChannel ? 7 : 6); i++) {
|
||||
if (needPulseReset[i] == true) {
|
||||
channelPulseCount[i] = 0;
|
||||
needPulseReset[i] = false;
|
||||
}
|
||||
if (channels[i].mode == Gate) {
|
||||
calculateGate(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//multiplier
|
||||
for (uint8_t i = 0; i < (extraChannel ? 7 : 6); i++) {
|
||||
|
||||
//RND modulation
|
||||
uint8_t randMod = 0;
|
||||
if (channels[i].CV1Target == 2) {
|
||||
randMod = randMod + CV1Input;
|
||||
}
|
||||
if (channels[i].CV2Target == 2) {
|
||||
randMod = randMod + CV2Input;
|
||||
}
|
||||
if (channels[i].CV1Target == 2 || channels[i].CV2Target == 2) {
|
||||
randMod = map(randMod, 0, 1023, -5, +5);
|
||||
}
|
||||
uint8_t randAmount = channels[i].random + randMod;
|
||||
if (randAmount > 100) {
|
||||
randAmount = 0;
|
||||
} else if (randAmount > 10) {
|
||||
randAmount = 10;
|
||||
}
|
||||
|
||||
if (!channels[i].isMute) {
|
||||
if ((channels[i].mode == Swing && channelPulseCount[i] == 0 && stepIsOdd == 0)
|
||||
|| (channels[i].mode == Swing && channelPulseCount[i] == channels[i].swing && stepIsOdd == 1) //swing
|
||||
) {
|
||||
digitalWrite(outsPins[i], HIGH);
|
||||
}
|
||||
|
||||
if ((channels[i].mode == Clock && channelPulseCount[i] == channels[i].offset) //CLK with offset
|
||||
|| (channels[i].mode == Random && channelPulseCount[i] == 0 && (random(10) + 1) > randAmount) //RND
|
||||
|| (channels[i].mode == Gate && channelPulseCount[i] == 0) //Gate
|
||||
) {
|
||||
digitalWrite(outsPins[i], HIGH);
|
||||
}
|
||||
}
|
||||
if (channelPulseCount[i] < channelPulsesPerCycle[i]) {
|
||||
channelPulseCount[i]++;
|
||||
} else {
|
||||
channelPulseCount[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void calculateCycles() {
|
||||
|
||||
for (uint8_t i = 0; i < (extraChannel ? 7 : 6); i++) {
|
||||
int mod = 0; //subdiv modulation happens here
|
||||
if (channels[i].CV1Target == 1) {
|
||||
mod = map(CV1Input, -1, 1024, -5, 5);
|
||||
} else if (channels[i].CV2Target == 1) {
|
||||
mod = map(CV2Input, -1, 1024, -5, 5);
|
||||
}
|
||||
playingModes[i] = subDivs[channels[i].subDiv - mod]; //subtracting because the innitial array is backwards
|
||||
|
||||
if (channels[i].mode == Sequencer || channels[i].mode == Swing) { //Sequencer and swing plays 1/16th
|
||||
channelPulsesPerCycle[i] = (PPQN / 4) - 1;
|
||||
} else if (playingModes[i] > 0) {
|
||||
channelPulsesPerCycle[i] = (playingModes[i] * PPQN) - 1;
|
||||
} else if (playingModes[i] < 0) {
|
||||
channelPulsesPerCycle[i] = (PPQN / abs(playingModes[i])) - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void calculateGate(uint8_t channel) {
|
||||
//if (subDivs[channels[channel].subDiv] > 0) {
|
||||
gateLengthTime[channel] = ((channelPulsesPerCycle[channel] + 1) * (pulsePeriod + 1) / 100) * channels[channel].gate;
|
||||
gateCountDown[channel] = gateLengthTime[channel];
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
void calculateBPMTiming() {
|
||||
int mod = 0;
|
||||
if (masterClockMode == 0) { //Internal clock
|
||||
if (bpmModulationRange != 0 && bpmModulationChannel == 0) {
|
||||
mod = map(CV1Input, 0, 1023, bpmModulationRange * -10, bpmModulationRange * 10);
|
||||
} else if (bpmModulationRange != 0 && bpmModulationChannel == 1) {
|
||||
mod = map(CV2Input, 0, 1023, bpmModulationRange * -10, bpmModulationRange * 10);
|
||||
}
|
||||
uint8_t calcbpm = bpm + mod;
|
||||
if (calcbpm > MAXBPM) { calcbpm = MAXBPM; };
|
||||
pulsePeriod = 600000 / (calcbpm * PPQN); // 600000.0 / ((float)(calcbpm * PPQN)) - floats eat up ~2% of program memory, but are they more precise? need to measure
|
||||
|
||||
} else if (masterClockMode == 1 && extClockPPQN == 1) { //for ext 1/16 clock
|
||||
pulsePeriod = (newExtPulseTime - lastExtPulseTime) * 10 / 6;
|
||||
}
|
||||
}
|
||||
|
||||
void resetClocks() {
|
||||
for (uint8_t i = 0; i < (extraChannel ? 7 : 6); i++) {
|
||||
channelPulseCount[i] = 0;
|
||||
digitalWrite(outsPins[i], LOW); //to avoid stuck leds
|
||||
}
|
||||
pulseCount = 0;
|
||||
tickCount = 0;
|
||||
sixteenthPulseCount = 0;
|
||||
for (uint8_t i; i < 7; i++) {
|
||||
currentStep[i] = 0;
|
||||
}
|
||||
stepIsOdd = 1;
|
||||
}
|
||||
|
||||
void saveState() {
|
||||
uint16_t addr = 0;
|
||||
EEPROM.put(addr, bpm);
|
||||
addr = addr + sizeof(bpm);
|
||||
EEPROM.put(addr, bpmModulationChannel);
|
||||
addr = addr + sizeof(bpmModulationChannel);
|
||||
EEPROM.put(addr, bpmModulationRange);
|
||||
addr = addr + sizeof(bpmModulationRange);
|
||||
EEPROM.put(addr, masterClockMode);
|
||||
addr = addr + sizeof(masterClockMode);
|
||||
EEPROM.put(addr, channels);
|
||||
addr = addr + sizeof(channels);
|
||||
EEPROM.put(addr, sequences);
|
||||
addr = addr + sizeof(sequences);
|
||||
EEPROM.put(addr, CV1Calibration);
|
||||
addr = addr + sizeof(CV1Calibration);
|
||||
EEPROM.put(addr, CV2Calibration);
|
||||
addr = addr + sizeof(CV2Calibration);
|
||||
EEPROM.put(addr, rotateScreen);
|
||||
addr = addr + sizeof(rotateScreen);
|
||||
EEPROM.put(addr, extClockPPQN);
|
||||
addr = addr + sizeof(extClockPPQN);
|
||||
EEPROM.put(addr, reverseEnc);
|
||||
addr = addr + sizeof(reverseEnc);
|
||||
EEPROM.put(addr, extraChannel);
|
||||
}
|
||||
|
||||
void loadState() { //optimisation: try to make an abstraction that can take an array (of pointers?) of settings to be loaded/saved
|
||||
//check last bit in eeprom to know if the correct settings were stored
|
||||
if (EEPROM.read(1023) == memCode) {
|
||||
uint16_t 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, sequences);
|
||||
addr = addr + sizeof(sequences);
|
||||
EEPROM.get(addr, CV1Calibration);
|
||||
addr = addr + sizeof(CV1Calibration);
|
||||
EEPROM.get(addr, CV2Calibration);
|
||||
addr = addr + sizeof(CV2Calibration);
|
||||
EEPROM.get(addr, rotateScreen);
|
||||
addr = addr + sizeof(rotateScreen);
|
||||
EEPROM.get(addr, extClockPPQN);
|
||||
addr = addr + sizeof(extClockPPQN);
|
||||
EEPROM.get(addr, reverseEnc);
|
||||
addr = addr + sizeof(reverseEnc);
|
||||
EEPROM.get(addr, extraChannel);
|
||||
} else {
|
||||
saveState(); //write default values to EEPROM
|
||||
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);
|
||||
saveState();
|
||||
showDone = true;
|
||||
updateScreen();
|
||||
}
|
||||
|
||||
void checkScreenRotation() {
|
||||
if (rotateScreen) {
|
||||
u8g2.setDisplayRotation(U8G2_R0);
|
||||
} else {
|
||||
u8g2.setDisplayRotation(U8G2_R2);
|
||||
}
|
||||
}
|
||||
@ -1,40 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#define PPQN 24
|
||||
#define PULSE_LENGTH 120 //1/10ms resolution. 12ms was failing at 1ms resolution at higher bpm. 60000/200/24 = 12.5 the max pulse length at 1ms resolution for 200bpm is 11ms
|
||||
#define MAXBPM 200 //250 at 24ppqn with 5ms pulse will be 50/50 square wave
|
||||
#define MINBPM 20
|
||||
|
||||
#define SCREEN_ADDRESS 0x3C
|
||||
|
||||
// Rev 2+ 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 uint8_t clockOutPin = 3;
|
||||
const uint8_t outsPins[] = { 7, 8, 10, 6, 9, 11, clockOutPin };
|
||||
bool rotateScreen = false;
|
||||
bool reverseEnc = false;
|
||||
|
||||
/* 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 SHIFT_BTN_PIN 100
|
||||
|
||||
#define EXT_INPUT_PIN 2 //needs to be an interrupt pin
|
||||
#define ANALOGUE_INPUT_1_PIN A2
|
||||
#define ANALOGUE_INPUT_2_PIN A1
|
||||
|
||||
const byte clockOutPin = 13;
|
||||
const byte outsPins[6] = {6, 11, 7, 10, 8, 9, clockOutPin};
|
||||
bool rotateScreen = true;
|
||||
*/
|
||||
|
||||
#define bitFlip(value, bit) ((value) ^ (1UL << (bit)))
|
||||
@ -1,38 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
const PROGMEM uint8_t stkS[437] U8G2_FONT_SECTION("stk-s") =
|
||||
"\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 PROGMEM uint8_t stkL[592] U8G2_FONT_SECTION("stk-l") =
|
||||
"\26\0\4\4\4\5\2\1\6\17\27\1\0\27\0\0\0\1\77\0\0\2\63%'\17\37\313\330R#&"
|
||||
"\32!F\14\211I\310\24!\65\204(MF\21)Cd\304\10\62b\14\215\60Vb\334\20\0/\14"
|
||||
"\272\336\336d\244\350\263q\343\0\60\37|\377\216!%*\10\35\263\253ChD\30\21bB\14\242S"
|
||||
"\306lv\210\204\22Ef\0\61\24z\337\322\60R\205\314\234\31\61F\310\270\371\177\224\42\3\62\33|"
|
||||
"\377\216)\64*\10\35\63\66r\206\304\314`c\252\34\301\221\263|\360\300\0\63\34|\377\216)\64*"
|
||||
"\10\35\63\66r \71\332YIr\226\306\16\221P\203\312\14\0\64 |\377\226\220AC\306\20\31B"
|
||||
"f\310\240\21\204F\214\32\61j\304(cv\366\200\305\312\371\0\65\32|\377\206\212-F\316\27\204\224"
|
||||
"\254\30\65t\344,\215\35\42\241\6\225\31\0\66\33}\17\317\251\64+\206\235\63:/\314,aA\352"
|
||||
"\234\335\235\42\261&\325\31\0\67\23|\377\302\212\7)\347Crt\70\345\300\221\363\16\0\70 |\377"
|
||||
"\216)\64*\10\35\263\354\20\11\42d\20\235BC\204\4\241cvv\210\204\32Tf\0\71\32|\377"
|
||||
"\216)\64*\10\35\263\263C$\226\250I\71_\14\42\241\6\225\31\0A\26}\17S\271Si(\31"
|
||||
"\65d\324\210q\366\356\301w\366\273\1B$}\17C\42\65KF\221\30\66b\330\210a#\206\215\30"
|
||||
"Eb\311&\243H\14;g\317\36\204`\261\4\0C\27}\17\317\251\64K\10!\63:\377\247\304F"
|
||||
"\20\42\261F\21\22\0D\33}\17C\42\65KF\15\31\66b\330\210q\366\77;\66b\24\211%j"
|
||||
"\22\1E\21|\377\302\7)\347%\42\214F\316/\37<\60I\7so\302\37$M$}\17\203\310"
|
||||
"r\346N\245Q\263\202E\12)L\224\60Q\302\310\20#C\214\14\61\23\306L\30s\366\335\0T\15"
|
||||
"}\17\303\7\251\206\316\377\377\12\0X)~\37\303@\203\307H\14\33B\210\14\21RC\206\241\63h"
|
||||
"\222(I\203\346\220\15\31E\204\14!\42\303F\20;h\341\0x\24\312\336\302 CGH\240\61E"
|
||||
"\312\14\222)\6Y\64\0\0\0\0\4\377\377\0";
|
||||
685
src/Gravity/Gravity.ino
Normal file
685
src/Gravity/Gravity.ino
Normal file
@ -0,0 +1,685 @@
|
||||
#include <Wire.h>
|
||||
#include <RotaryEncoder.h>
|
||||
#include <FlexiTimer2.h>
|
||||
#include <EEPROM.h>
|
||||
#include <U8g2lib.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <NeoHWSerial.h>
|
||||
|
||||
#define VERSION "V:1.1.2"
|
||||
|
||||
byte memCode = 'D'; //Change to different letter if you changed the data structure
|
||||
|
||||
#define PPQN 24
|
||||
#define PULSE_LENGTH 120 //1/10ms resolution. 12ms was failing at 1ms resolution at higher bpm. 60000/200/24 = 12.5 the max pulse length at 1ms resolution for 200bpm is 11ms
|
||||
#define MAXBPM 200 //250 at 24ppqn with 5ms pulse will be 50/50 square wave
|
||||
#define MINBPM 20
|
||||
|
||||
#define SCREEN_ADDRESS 0x3C
|
||||
|
||||
// Rev 2+ 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;
|
||||
bool rotateScreen = false;
|
||||
bool reverseEnc = false;
|
||||
//
|
||||
|
||||
/* 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 SHIFT_BTN_PIN 100
|
||||
|
||||
#define EXT_INPUT_PIN 2 //needs to be an interrupt pin
|
||||
#define ANALOGUE_INPUT_1_PIN A2
|
||||
#define ANALOGUE_INPUT_2_PIN A1
|
||||
|
||||
const byte clockOutPin = 13;
|
||||
const byte outsPins[6] = {6, 11, 7, 10, 8, 9};
|
||||
bool rotateScreen = true;
|
||||
*/
|
||||
|
||||
|
||||
uint16_t CV1Calibration = 512;
|
||||
uint16_t CV2Calibration = 512;
|
||||
bool showDone = false;
|
||||
|
||||
const int subDivs[20] = { -24, -12, -8, -6, -4, -3, -2, 1, 2, 3, 4, 5, 6, 7, 8, 16, 24, 32, 64, 128 }; //positive - divide, negative - multiply, 0 - off
|
||||
|
||||
byte bpm = 130;
|
||||
byte bpmModulationChannel = 200; //0 - CV1, 1 - CV2, 255 - OFF
|
||||
byte bpmModulationRange = 0;
|
||||
|
||||
struct channel {
|
||||
byte mode; //0 - CLK, 1 - RND, 2 - SEQ
|
||||
byte subDiv;
|
||||
byte CV1Target; //0 - Off, 1 - Subdiv, 2 - RND, 3 - SeqPattern
|
||||
byte CV1Range;
|
||||
byte CV2Target;
|
||||
byte CV2Range;
|
||||
uint8_t offset;
|
||||
byte random;
|
||||
byte seqPattern;
|
||||
};
|
||||
|
||||
channel channels[6] = { //array of channel settings
|
||||
{ 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, 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;
|
||||
|
||||
unsigned int channelPulseCount[6];
|
||||
unsigned int channelPulsesPerCycle[6];
|
||||
byte sixteenthPulseCount = 0;
|
||||
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;
|
||||
bool MIDIClockReceived = false;
|
||||
|
||||
unsigned int tickCount = 0;
|
||||
unsigned int pulseCount = 0;
|
||||
|
||||
byte masterClockMode = 0; // 0 - internal, 1 - external 24ppqn, 2 - MIDI
|
||||
byte extClockPPQN = 0; // 0 - 24, 1 - 4 (1/16)
|
||||
unsigned long lastExtPulseTime = 0;
|
||||
unsigned long newExtPulseTime = 0;
|
||||
|
||||
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 CV1Input = 0;
|
||||
int CV2Input = 0;
|
||||
|
||||
int encPositionOld = 0;
|
||||
int encDirectionOld = 0;
|
||||
unsigned long encPressedTime;
|
||||
unsigned long encReleasedTime;
|
||||
unsigned long playPressedTime;
|
||||
unsigned long playReleasedTime;
|
||||
unsigned long shiftPressedTime;
|
||||
unsigned long shiftReleasedTime;
|
||||
bool encBtnPushed;
|
||||
|
||||
int extResetCountdown;
|
||||
int extTriggerCount;
|
||||
|
||||
//unsigned long lastInteractionTime; // used for display timeout
|
||||
|
||||
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);
|
||||
|
||||
//Font
|
||||
const PROGMEM 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 PROGMEM uint8_t stkL[569] U8G2_FONT_SECTION("stk-l") =
|
||||
"\25\0\4\4\4\5\2\1\6\17\27\1\0\27\0\0\0\1\77\0\0\2\34%'\17\37\313\330R#&"
|
||||
"\32!F\14\211I\310\24!\65\204(MF\21)Cd\304\10\62b\14\215\60Vb\334\20\0/\14"
|
||||
"\272\336\336d\244\350\263q\343\0\60\37|\377\12\32\25\17\2\35\263\253ChD\30\21bB\14\242S"
|
||||
"\306lv\350A\10\65H\0\61\24z\337\322\60R\205\314\234\31\61F\310\270\371\177\224\42\3\62\33|"
|
||||
"\377\216\251$*\10\35\63\66r\206\304\314`c\252\34\301\221\263|\360\300\0\63\34|\377\216)\64*"
|
||||
"\10\35\63\66r \71\332YIr\226\306\16\221P\203\312\14\0\64 |\377\226\220AC\306\20\31B"
|
||||
"f\310\240\21\204F\214\32\61j\304(cv\366\200\305\312\371\0\65\32}\17\307\12.\206\316\213Bj"
|
||||
"\226\214\42JtN\315\235\42\261&\325\31\0\66\33}\17\317\251\64+\206\235\63:/\314,aA\352"
|
||||
"\234\335\235\42\261&\325\31\0\67\23|\377\302\212\7)\347Crt\70\345\300\221\363\16\0\70 |\377"
|
||||
"\216)\64*\10\35\263\331!\22D\310\240\62\205\206\10\11B\307lv\210\204\32Tf\0\71\32|\377"
|
||||
"\216)\64*\10\35\263\263C$\226\250I\71_\14\42\241\6\225\31\0A\26}\17S\271Si(\31"
|
||||
"\65d\324\210q\366\356\301w\366\273\1B$}\17\203\232%KF\221\30\66b\330\210a#\206\215\30"
|
||||
"Eb\311&\243H\14;g\317\36\204`\261\4\0D\33}\17C\42\65KF\15\31\66b\330\210q"
|
||||
"\366\77;\66b\24\211%j\22\1E\21|\377\302\7)\347%\42\214F\316/\37<\60I\7so"
|
||||
"\302\37$M$}\17\203\310r\346N\245Q\263\202E\12)L\224\60Q\302\310\20#C\214\14\61\23"
|
||||
"\306L\30s\366\335\0T\15}\17\303\7\251\206\316\377\377\12\0X)~\37\303@\203\307H\14\33B"
|
||||
"\210\14\21RC\206\241\63h\222(I\203\346\220\15\31E\204\14!\42\303F\20;h\341\0x\24\312"
|
||||
"\336\302 CGH\240\61E\312\14\222)\6Y\64\0\0\0\0\4\377\377\0";
|
||||
|
||||
String version;
|
||||
|
||||
void setup() {
|
||||
version = F(VERSION);
|
||||
|
||||
NeoSerial.begin(31250);
|
||||
NeoSerial.attachInterrupt(receiveMIDI);
|
||||
|
||||
pinMode(ENC_BTN_PIN, INPUT_PULLUP);
|
||||
pinMode(START_STOP_BTN_PIN, INPUT_PULLUP);
|
||||
pinMode(SHIFT_BTN_PIN, INPUT_PULLUP);
|
||||
pinMode(EXT_INPUT_PIN, INPUT_PULLUP);
|
||||
attachInterrupt(digitalPinToInterrupt(EXT_INPUT_PIN), externalClock, FALLING);
|
||||
|
||||
for (byte i = 0; i < 6; i++) {
|
||||
pinMode(outsPins[i], OUTPUT);
|
||||
}
|
||||
|
||||
pinMode(clockOutPin, OUTPUT);
|
||||
|
||||
loadState();
|
||||
|
||||
u8g2.begin();
|
||||
checkScreenRotation();
|
||||
updateScreen();
|
||||
|
||||
calculateCycles();
|
||||
calculateBPMTiming();
|
||||
|
||||
resetClocks();
|
||||
|
||||
FlexiTimer2::set(1, 1.0 / 10000, clock); // 1.0/1000 = 1ms period. If other than 1ms calculateBPMTiming() might need tweaking
|
||||
FlexiTimer2::start();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (masterClockMode == 1 && extClockPPQN == 1) {
|
||||
calculateBPMTiming();
|
||||
}
|
||||
checkInputs();
|
||||
}
|
||||
|
||||
void sendMIDIClock() {
|
||||
NeoSerial.write(0xF8);
|
||||
}
|
||||
void sendMIDIStart() {
|
||||
NeoSerial.write(0xFA);
|
||||
}
|
||||
void sendMIDIStop() {
|
||||
NeoSerial.write(0xFC);
|
||||
}
|
||||
|
||||
void receiveMIDI( uint8_t msg, uint8_t status ) {
|
||||
if (masterClockMode == 2) {
|
||||
//int msg = NeoSerial.read();
|
||||
if (msg == 0xF8) { //Clock
|
||||
MIDIClockReceived = true;
|
||||
} else if (msg == 0xFC) { //stop
|
||||
isPlaying = false;
|
||||
resetClocks();
|
||||
sendMIDIStop();
|
||||
} else if (msg == 0xFA || msg == 0xFB) { //start and continue
|
||||
resetClocks();
|
||||
isPlaying = true;
|
||||
sendMIDIStart();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void clock() {
|
||||
if (isPlaying) {
|
||||
|
||||
// Action on each pulse
|
||||
if (tickCount == 0) {
|
||||
sendTriggers();
|
||||
digitalWrite(clockOutPin, HIGH);
|
||||
sendMIDIClock();
|
||||
}
|
||||
|
||||
//this part gets the Pulse and Ticks ticking
|
||||
//it's placed after the triggers to avoid problems on the start (when pulseCount==0)
|
||||
tickCount++;
|
||||
if (masterClockMode == 0) {
|
||||
if (tickCount >= pulsePeriod) {
|
||||
tickCount = 0;
|
||||
if (pulseCount < (PPQN - 1)) { //-1 is here to avoid extra IF to reset to 0
|
||||
pulseCount++;
|
||||
} else {
|
||||
pulseCount = 0;
|
||||
}
|
||||
if (bpmModulationRange != 0) {
|
||||
calculateBPMTiming();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (masterClockMode == 1 && extClockPPQN == 1) {
|
||||
if (tickCount >= pulsePeriod && pulseCount < (PPQN - 1)) { // ((6 * (extTriggerCount + 1)) - 1)) { //this formula puts it out of sync, so there's PPQN-1 for now
|
||||
tickCount = 0;
|
||||
pulseCount++;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
MIDIClockReceived = false;
|
||||
}
|
||||
|
||||
// pull low all outputs after set pulse length
|
||||
if (tickCount >= PULSE_LENGTH) {
|
||||
for (byte i = 0; i < 6; i++) {
|
||||
digitalWrite(outsPins[i], LOW);
|
||||
}
|
||||
digitalWrite(clockOutPin, LOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void externalClock() {
|
||||
lastExtPulseTime = newExtPulseTime;
|
||||
newExtPulseTime = millis();
|
||||
|
||||
if (masterClockMode == 1 && extClockPPQN == 0) { // EXT 24ppqn
|
||||
if (!isPlaying) {
|
||||
isPlaying = true;
|
||||
}
|
||||
|
||||
//reset cycles if there were no pulses for a while
|
||||
if ((newExtPulseTime - lastExtPulseTime) > 125) { //125ms is 20bpm
|
||||
|
||||
resetClocks();
|
||||
}
|
||||
|
||||
tickCount = 0; //to make things happen in the main clock function
|
||||
if (pulseCount < (PPQN - 1)) {
|
||||
pulseCount++;
|
||||
} else {
|
||||
pulseCount = 0;
|
||||
}
|
||||
} else if (masterClockMode == 1 && extClockPPQN == 1) { //EXT 1/16
|
||||
if (!isPlaying) {
|
||||
isPlaying = true;
|
||||
}
|
||||
if ((newExtPulseTime - lastExtPulseTime) > 750) {
|
||||
resetClocks();
|
||||
extResetCountdown = 0;
|
||||
extTriggerCount = 0;
|
||||
}
|
||||
|
||||
if (extTriggerCount == 0) { //happens on beat
|
||||
pulseCount = 0;
|
||||
tickCount = 0;
|
||||
}
|
||||
if (extTriggerCount < 3) {
|
||||
extTriggerCount++;
|
||||
} else {
|
||||
extTriggerCount = 0;
|
||||
}
|
||||
|
||||
if (extResetCountdown < 4) { //reset on the second beat (5th pulse), so that BPM is already calculated correctly
|
||||
extResetCountdown++;
|
||||
} else if (extResetCountdown == 4) {
|
||||
resetClocks();
|
||||
extResetCountdown++; //to get out of the loop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sendTriggers() {
|
||||
|
||||
for (byte i = 0; i < 6; i++) {
|
||||
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 && currentSeq[currentStep]) { // EXT CLOCK SEQUENCER BUG IS SOMEWHERE HERE ???? && channelPulseCount[i] == 0 might be related to channelPulsesPerCycle not calculated in time
|
||||
digitalWrite(outsPins[i], HIGH);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sixteenthPulseCount < (PPQN / 4) - 1) {
|
||||
sixteenthPulseCount++;
|
||||
if (sixteenthPulseCount > 3) { //quantization. might need fine-tuning
|
||||
recordToNextStep = true;
|
||||
}
|
||||
} else {
|
||||
sixteenthPulseCount = 0;
|
||||
if (currentStep < 15) {
|
||||
currentStep ++;
|
||||
} else {
|
||||
currentStep = 0;
|
||||
}
|
||||
recordToNextStep = false;
|
||||
}
|
||||
|
||||
//switching modes on the beat and resetting channel clock
|
||||
if (pulseCount == 0) {
|
||||
calculateCycles();
|
||||
for (byte i = 0; i < 6; i++) {
|
||||
if (needPulseReset[i] == true) {
|
||||
channelPulseCount[i] = 0;
|
||||
needPulseReset[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//multiplier
|
||||
for (byte i = 0; i < 6; i++) {
|
||||
|
||||
//RND modulation
|
||||
byte randMod = 0;
|
||||
if (channels[i].CV1Target == 2) {
|
||||
randMod = randMod + CV1Input;
|
||||
}
|
||||
if (channels[i].CV2Target == 2) {
|
||||
randMod = randMod + CV2Input;
|
||||
}
|
||||
if (channels[i].CV1Target == 2 || channels[i].CV2Target == 2) {
|
||||
randMod = map(randMod, 0, 1023, -5, +5);
|
||||
}
|
||||
byte randAmount = channels[i].random + randMod;
|
||||
if (randAmount > 100) {
|
||||
randAmount = 0;
|
||||
} else if (randAmount > 10) {
|
||||
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
|
||||
) {
|
||||
digitalWrite(outsPins[i], HIGH);
|
||||
}
|
||||
if (channelPulseCount[i] < channelPulsesPerCycle[i]) {
|
||||
channelPulseCount[i]++;
|
||||
} else {
|
||||
channelPulseCount[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void calculateCycles() {
|
||||
|
||||
for (byte i = 0; i < 6; i++) {
|
||||
int mod = 0; //subdiv modulation happens here
|
||||
if (channels[i].CV1Target == 1) {
|
||||
mod = map(CV1Input, -1, 1024, -5, 5);
|
||||
} else if (channels[i].CV2Target == 1) {
|
||||
mod = map(CV2Input, -1, 1024, -5, 5);
|
||||
}
|
||||
playingModes[i] = subDivs[channels[i].subDiv - mod]; //subtracting because the innitial array is backwards
|
||||
|
||||
if (channels[i].mode == 2) { //Sequencer plays 1/16th
|
||||
channelPulsesPerCycle[i] = (PPQN / 4) - 1;
|
||||
} else if (playingModes[i] > 0) {
|
||||
channelPulsesPerCycle[i] = (playingModes[i] * PPQN) - 1;
|
||||
} else if (playingModes[i] < 0) {
|
||||
channelPulsesPerCycle[i] = (PPQN / abs(playingModes[i])) - 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void calculateBPMTiming() {
|
||||
int mod = 0;
|
||||
if (masterClockMode == 0) { //Internal clock
|
||||
if (bpmModulationRange != 0 && bpmModulationChannel == 0) {
|
||||
mod = map(CV1Input, 0, 1023, bpmModulationRange * -10, bpmModulationRange * 10);
|
||||
} else if (bpmModulationRange != 0 && bpmModulationChannel == 1) {
|
||||
mod = map(CV2Input, 0, 1023, bpmModulationRange * -10, bpmModulationRange * 10);
|
||||
}
|
||||
byte calcbpm = bpm + mod;
|
||||
if (calcbpm > MAXBPM) { calcbpm = MAXBPM; };
|
||||
pulsePeriod = 600000 / (calcbpm * PPQN);
|
||||
|
||||
} else if (masterClockMode == 1 && extClockPPQN == 1) { //for ext 1/16 clock (hardcoded)
|
||||
pulsePeriod = ((newExtPulseTime - lastExtPulseTime) * 10) / 6;
|
||||
}
|
||||
}
|
||||
|
||||
void resetClocks() {
|
||||
for (byte i = 0; i < 6; i++) {
|
||||
channelPulseCount[i] = 0;
|
||||
digitalWrite(outsPins[i], LOW); //to avoid stuck leds
|
||||
}
|
||||
pulseCount = 0;
|
||||
tickCount = 0;
|
||||
sixteenthPulseCount = 0;
|
||||
currentStep = 0;
|
||||
}
|
||||
|
||||
void saveState() {
|
||||
int addr = 0;
|
||||
EEPROM.put(addr, bpm);
|
||||
addr = addr + sizeof(bpm);
|
||||
EEPROM.put(addr, bpmModulationChannel);
|
||||
addr = addr + sizeof(bpmModulationChannel);
|
||||
EEPROM.put(addr, bpmModulationRange);
|
||||
addr = addr + sizeof(bpmModulationRange);
|
||||
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);
|
||||
addr = addr + sizeof(rotateScreen);
|
||||
EEPROM.put(addr, extClockPPQN);
|
||||
addr = addr + sizeof(extClockPPQN);
|
||||
EEPROM.put(addr, reverseEnc);
|
||||
}
|
||||
|
||||
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);
|
||||
addr = addr + sizeof(rotateScreen);
|
||||
EEPROM.get(addr, extClockPPQN);
|
||||
addr = addr + sizeof(extClockPPQN);
|
||||
EEPROM.get(addr, reverseEnc);
|
||||
} else {
|
||||
saveState(); //write default values to EEPROM
|
||||
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);
|
||||
saveState();
|
||||
showDone = true;
|
||||
updateScreen();
|
||||
}
|
||||
|
||||
void checkScreenRotation() {
|
||||
if (rotateScreen) {
|
||||
u8g2.setDisplayRotation(U8G2_R0);
|
||||
} else {
|
||||
u8g2.setDisplayRotation(U8G2_R2);
|
||||
}
|
||||
}
|
||||
@ -12,8 +12,40 @@ void checkInputs() {
|
||||
} else if (encReleasedTime - encPressedTime <= 300) { // press shorter than .3s is for entering the submenu
|
||||
if (!insideTab && displayScreen == 0) {
|
||||
insideTab = true;
|
||||
} else if (insideTab && channels[displayTab - 1].mode == Sequencer && menuItem == 2 && displayScreen == 0) { //enter the pattern editor
|
||||
patternToEdit = channels[displayTab - 1].seqPattern;
|
||||
} 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) {
|
||||
@ -35,9 +67,6 @@ void checkInputs() {
|
||||
showDone = true;
|
||||
updateScreen();
|
||||
} else if (displayScreen == 2 && menuItem == 3) {
|
||||
extraChannel = !extraChannel;
|
||||
updateScreen();
|
||||
} else if (displayScreen == 2 && menuItem == 4) {
|
||||
EEPROM.put(1023, memCode - 1);
|
||||
reboot();
|
||||
}
|
||||
@ -45,9 +74,7 @@ void checkInputs() {
|
||||
if (menuItemSelected == 1) {
|
||||
menuItemSelected = 0;
|
||||
} else if (displayScreen != 0) {
|
||||
menuItem = 0;
|
||||
displayScreen = 0;
|
||||
menuItemSelected = 0;
|
||||
} else if (insideTab == 1) {
|
||||
insideTab = 0;
|
||||
menuItem = 0;
|
||||
@ -61,40 +88,37 @@ void checkInputs() {
|
||||
}
|
||||
|
||||
//encoder
|
||||
if (encoderChange != 0) {
|
||||
if (!reverseEnc) {
|
||||
encoderChange = encoderChange * -1;
|
||||
encoder.tick();
|
||||
int encPosition = encoder.getPosition();
|
||||
int encDirection = (int)(encoder.getDirection());
|
||||
if (encPositionOld != encPosition) {
|
||||
int change = encPositionOld - encPosition;
|
||||
if (reverseEnc) {
|
||||
change = change * -1;
|
||||
}
|
||||
|
||||
/*if (((encoderChange > 0) != encoderDirectionOld) && encoderTimeBetweenPulses < 150) { //filter out encoder "jumps". Comented out
|
||||
encoderChange = 0; //because it seems like sometimes it was preventing normal scroll
|
||||
} //if it works ok without it delete encoderDirectionOld var altogether
|
||||
encoderDirectionOld = (encoderChange > 0);*/
|
||||
|
||||
//encoder acceleration
|
||||
if (encoderTimeBetweenPulses < 15) { // <--
|
||||
encoderBurstCount++;
|
||||
} else {
|
||||
encoderBurstCount = 0;
|
||||
unsigned long ms = encoder.getMillisBetweenRotations();
|
||||
/*if (encDirectionOld == encDirection && ms < 20) { //encoder acceleration
|
||||
change = change * 5;
|
||||
} else if (encDirectionOld == encDirection && ms < 80) {
|
||||
change = change * 2;
|
||||
} else */ if (encDirectionOld != encDirection && ms < 200) { //filter out encoder "jumps"
|
||||
change = 0;
|
||||
}
|
||||
if (encoderBurstCount > 3) { // <--
|
||||
encoderChange = encoderChange * 3; // <-- The three params need to be finetuned to feel natural
|
||||
}
|
||||
|
||||
encDirectionOld = encDirection;
|
||||
if (displayScreen == 0) {
|
||||
uint8_t channelCV;
|
||||
byte channelCV;
|
||||
if (!insideTab && !shiftBtnPushed) { //Change tab
|
||||
displayTab = displayTab + encoderChange;
|
||||
displayTab = displayTab + change;
|
||||
if (displayTab > 100) { //to address "negative" numbers
|
||||
displayTab = 0;
|
||||
} else if (displayTab > (extraChannel ? 7 : 6)) {
|
||||
displayTab = (extraChannel ? 7 : 6);
|
||||
} else if (displayTab > 6) {
|
||||
displayTab = 6;
|
||||
}
|
||||
} else if (((!insideTab && shiftBtnPushed)
|
||||
|| (insideTab && menuItem == 0
|
||||
&& (menuItemSelected || shiftBtnPushed)))
|
||||
&& displayTab == 0 && masterClockMode == 0) { //Change BPM
|
||||
bpm = bpm + encoderChange;
|
||||
bpm = bpm + change;
|
||||
if (bpm > MAXBPM) {
|
||||
bpm = MAXBPM;
|
||||
} else if (bpm < MINBPM) {
|
||||
@ -106,13 +130,13 @@ void checkInputs() {
|
||||
|| (insideTab && menuItem == 0
|
||||
&& (menuItemSelected || shiftBtnPushed)))
|
||||
&& displayTab != 0
|
||||
&& channels[displayTab - 1].mode == Clock) {
|
||||
channels[displayTab - 1].subDiv = channels[displayTab - 1].subDiv - encoderChange;
|
||||
&& 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(subDivs[0])) - 1) {
|
||||
channels[displayTab - 1].subDiv = (sizeof(subDivs) / sizeof(subDivs[0])) - 1;
|
||||
} if (channels[displayTab - 1].subDiv > (sizeof(subDivs) / sizeof(int)) - 1) {
|
||||
channels[displayTab - 1].subDiv = (sizeof(subDivs) / sizeof(int)) - 1;
|
||||
}
|
||||
if (!isPlaying) {
|
||||
calculateCycles();
|
||||
@ -131,8 +155,8 @@ void checkInputs() {
|
||||
|| (insideTab && menuItem == 0
|
||||
&& (menuItemSelected || shiftBtnPushed)))
|
||||
&& displayTab != 0
|
||||
&& channels[displayTab - 1].mode == Random) { //Change Random
|
||||
channels[displayTab - 1].random = channels[displayTab - 1].random + encoderChange;
|
||||
&& 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) {
|
||||
@ -143,42 +167,16 @@ void checkInputs() {
|
||||
|| (insideTab && menuItem == 0
|
||||
&& (menuItemSelected || shiftBtnPushed)))
|
||||
&& displayTab != 0
|
||||
&& channels[displayTab - 1].mode == Sequencer) { //Change SEQ pattern
|
||||
if (channels[displayTab - 1].seqPattern == 0 && encoderChange == -1) {
|
||||
&& 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 == 31 && encoderChange == 1) {
|
||||
channels[displayTab - 1].seqPattern = 31;
|
||||
} else {
|
||||
channels[displayTab - 1].seqPattern = channels[displayTab - 1].seqPattern + encoderChange;
|
||||
} else if (channels[displayTab - 1].seqPattern > 15) {
|
||||
channels[displayTab - 1].seqPattern = 15;
|
||||
}
|
||||
saveState();
|
||||
} else if (((!insideTab && shiftBtnPushed)
|
||||
|| (insideTab && menuItem == 0
|
||||
&& (menuItemSelected || shiftBtnPushed)))
|
||||
&& displayTab != 0
|
||||
&& channels[displayTab - 1].mode == Swing) { //Change SWING
|
||||
channels[displayTab - 1].swing = channels[displayTab - 1].swing + encoderChange;
|
||||
if (channels[displayTab - 1].swing > 6) {
|
||||
channels[displayTab - 1].swing = 0;
|
||||
} else if (channels[displayTab - 1].swing > 5) {
|
||||
channels[displayTab - 1].swing = 5;
|
||||
}
|
||||
saveState();
|
||||
} else if (((!insideTab && shiftBtnPushed)
|
||||
|| (insideTab && menuItem == 0
|
||||
&& (menuItemSelected || shiftBtnPushed)))
|
||||
&& displayTab != 0
|
||||
&& channels[displayTab - 1].mode == Gate) { //Change GATE
|
||||
channels[displayTab - 1].gate = channels[displayTab - 1].gate + encoderChange;
|
||||
if (channels[displayTab - 1].gate > 100 || channels[displayTab - 1].gate == 0) {
|
||||
channels[displayTab - 1].gate = 1;
|
||||
} else if (channels[displayTab - 1].gate > 99) {
|
||||
channels[displayTab - 1].gate = 99;
|
||||
}
|
||||
calculateGate(displayTab - 1);
|
||||
saveState();
|
||||
} else if (insideTab && !shiftBtnPushed && !menuItemSelected) {
|
||||
menuItem = menuItem + encoderChange;
|
||||
menuItem = menuItem + change;
|
||||
if (menuItem > 100) { //for "negative" values
|
||||
menuItem = 0;
|
||||
} else if (menuItem > lastMenuItem) {
|
||||
@ -188,14 +186,14 @@ void checkInputs() {
|
||||
&& (shiftBtnPushed || menuItemSelected)
|
||||
&& displayTab == 0
|
||||
&& menuItem == 1) { //Master Clock Mode
|
||||
if (masterClockMode == 1) { // && encoderChange == -1) { //Stop when switching from ext to int or to midi
|
||||
if (masterClockMode == 1) { // && change == -1) { //Stop when switching from ext to int or to midi
|
||||
isPlaying = false;
|
||||
}
|
||||
|
||||
masterClockMode = masterClockMode + encoderChange;
|
||||
masterClockMode = masterClockMode + change;
|
||||
if (masterClockMode > 100) {
|
||||
masterClockMode = 0;
|
||||
} else if (masterClockMode > 2) {
|
||||
} else if (masterClockMode > 2) { //Set to 1 to hide MIDI mode
|
||||
masterClockMode = 2;
|
||||
}
|
||||
saveState();
|
||||
@ -204,7 +202,7 @@ void checkInputs() {
|
||||
&& displayTab == 0
|
||||
&& menuItem == 2
|
||||
&& masterClockMode == 0) { //Modulation channel
|
||||
bpmModulationChannel = bpmModulationChannel + encoderChange;
|
||||
bpmModulationChannel = bpmModulationChannel + change;
|
||||
if (bpmModulationChannel == 0 || bpmModulationChannel == 1) {
|
||||
bpmModulationRange = 1;
|
||||
} else if (bpmModulationChannel > 100) {
|
||||
@ -219,7 +217,7 @@ void checkInputs() {
|
||||
&& displayTab == 0
|
||||
&& menuItem == 2
|
||||
&& masterClockMode == 1) { //PPQN
|
||||
extClockPPQN = extClockPPQN + encoderChange;
|
||||
extClockPPQN = extClockPPQN + change;
|
||||
if (extClockPPQN > 100) {
|
||||
extClockPPQN = 0;
|
||||
} else if (extClockPPQN > 1) {
|
||||
@ -230,7 +228,7 @@ void checkInputs() {
|
||||
&& (menuItemSelected || shiftBtnPushed)
|
||||
&& displayTab == 0
|
||||
&& menuItem == 3) { //Modulation range
|
||||
bpmModulationRange = bpmModulationRange + encoderChange;
|
||||
bpmModulationRange = bpmModulationRange + change;
|
||||
if (bpmModulationRange == 0) {
|
||||
bpmModulationRange = 1;
|
||||
} else if (bpmModulationRange > 100) {
|
||||
@ -243,11 +241,11 @@ void checkInputs() {
|
||||
&& (menuItemSelected || shiftBtnPushed)
|
||||
&& displayTab != 0
|
||||
&& menuItem == 1) { //Channel Mode
|
||||
channels[displayTab - 1].mode = channels[displayTab - 1].mode + encoderChange;
|
||||
if (channels[displayTab - 1].mode == 7) {
|
||||
channels[displayTab - 1].mode = 4; //to make it cycle through all the modes
|
||||
} else if (channels[displayTab - 1].mode > 4) {
|
||||
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;
|
||||
@ -255,8 +253,8 @@ void checkInputs() {
|
||||
} else if (insideTab
|
||||
&& (menuItemSelected || shiftBtnPushed)
|
||||
&& displayTab != 0 && menuItem == 2
|
||||
&& channels[displayTab - 1].mode == Clock) { //Offset
|
||||
channels[displayTab - 1].offset = channels[displayTab - 1].offset + encoderChange;
|
||||
&& channels[displayTab - 1].mode == 0) { //Offset
|
||||
channels[displayTab - 1].offset = channels[displayTab - 1].offset + change;
|
||||
if (channels[displayTab - 1].offset == 255) { // 0 - 1 for uint8 is 255
|
||||
channels[displayTab - 1].offset = 0;
|
||||
} else if (channels[displayTab - 1].offset > channelPulsesPerCycle[displayTab-1]) {
|
||||
@ -267,12 +265,12 @@ void checkInputs() {
|
||||
&& (menuItemSelected || shiftBtnPushed)
|
||||
&& displayTab != 0
|
||||
&& menuItem == 2
|
||||
&& (channels[displayTab - 1].mode == Random || channels[displayTab - 1].mode == Gate)) { //SUBDIV for RANDOM and GATE
|
||||
channels[displayTab - 1].subDiv = channels[displayTab - 1].subDiv - encoderChange;
|
||||
&& 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(subDivs[0])) - 1) {
|
||||
channels[displayTab - 1].subDiv = (sizeof(subDivs) / sizeof(subDivs[0])) - 1;
|
||||
} else if (channels[displayTab - 1].subDiv > (sizeof(subDivs) / sizeof(int)) - 1) {
|
||||
channels[displayTab - 1].subDiv = (sizeof(subDivs) / sizeof(int)) - 1;
|
||||
}
|
||||
if (!isPlaying) {
|
||||
calculateCycles();
|
||||
@ -282,7 +280,7 @@ void checkInputs() {
|
||||
&& (menuItemSelected || shiftBtnPushed)
|
||||
&& displayTab != 0
|
||||
&& menuItem == 3
|
||||
&& channels[displayTab - 1].mode == Clock) { //CV for CLK
|
||||
&& 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) {
|
||||
@ -290,7 +288,7 @@ void checkInputs() {
|
||||
} else {
|
||||
channelCV = 0;
|
||||
}
|
||||
channelCV = channelCV + encoderChange;
|
||||
channelCV = channelCV + change;
|
||||
if (channelCV == 0 || channelCV > 100) {
|
||||
channelCV = 0;
|
||||
channels[displayTab - 1].CV1Target = 0;
|
||||
@ -304,7 +302,7 @@ void checkInputs() {
|
||||
channels[displayTab - 1].CV2Target = 1;
|
||||
}
|
||||
saveState();
|
||||
} else if (insideTab && (menuItemSelected || shiftBtnPushed) && displayTab != 0 && menuItem == 3 && channels[displayTab - 1].mode == Random) { //CV for RND
|
||||
} 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) {
|
||||
@ -312,7 +310,7 @@ void checkInputs() {
|
||||
} else {
|
||||
channelCV = 0;
|
||||
}
|
||||
channelCV = channelCV + encoderChange;
|
||||
channelCV = channelCV + change;
|
||||
if (channelCV == 0 || channelCV > 100) {
|
||||
channelCV = 0;
|
||||
channels[displayTab - 1].CV1Target = 0;
|
||||
@ -326,7 +324,7 @@ void checkInputs() {
|
||||
channels[displayTab - 1].CV2Target = 2;
|
||||
}
|
||||
saveState();
|
||||
} else if (insideTab && (menuItemSelected || shiftBtnPushed) && displayTab != 0 && menuItem == 3 && channels[displayTab - 1].mode == Sequencer) { //CV1 for SEQ
|
||||
} 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) {
|
||||
@ -334,7 +332,7 @@ void checkInputs() {
|
||||
} else {
|
||||
channelCV = 0;
|
||||
}
|
||||
channelCV = channelCV + encoderChange;
|
||||
channelCV = channelCV + change;
|
||||
if (channelCV == 0 || channelCV > 100) {
|
||||
channelCV = 0;
|
||||
channels[displayTab - 1].CV1Target = 0;
|
||||
@ -348,21 +346,16 @@ void checkInputs() {
|
||||
channels[displayTab - 1].CV2Target = 3;
|
||||
}
|
||||
saveState();
|
||||
}
|
||||
} else if (displayScreen == 1 && !isRecording && !shiftBtnPushed) {
|
||||
stepNumSelected = stepNumSelected + encoderChange;
|
||||
if (stepNumSelected < -1 ) {
|
||||
stepNumSelected = -1;
|
||||
} else if (stepNumSelected > sequences[channels[displayTab - 1].seqPattern].length && !shiftBtnPushed) {
|
||||
}
|
||||
} else if (displayScreen == 1 && !isRecording) {
|
||||
stepNumSelected = stepNumSelected + change;
|
||||
if (stepNumSelected > 100) {
|
||||
stepNumSelected = 15;
|
||||
} else if (stepNumSelected > 15) {
|
||||
stepNumSelected = 0;
|
||||
}
|
||||
} else if (displayScreen == 1 && !isRecording && stepNumSelected == -1 && shiftBtnPushed) {
|
||||
if ((sequences[channels[displayTab - 1].seqPattern].length != 31 && encoderChange > 0) ||
|
||||
(sequences[channels[displayTab - 1].seqPattern].length != 0 && encoderChange < 0)) {
|
||||
sequences[channels[displayTab - 1].seqPattern].length += encoderChange;
|
||||
}
|
||||
}
|
||||
} else if (displayScreen == 2 && !shiftBtnPushed) {
|
||||
menuItem = menuItem + encoderChange;
|
||||
menuItem = menuItem + change;
|
||||
if (menuItem > 100) { //for "negative" values
|
||||
menuItem = 0;
|
||||
} else if (menuItem > lastMenuItem) {
|
||||
@ -371,11 +364,11 @@ void checkInputs() {
|
||||
}
|
||||
|
||||
updateScreen();
|
||||
encoderChange = 0;
|
||||
encPositionOld = encPosition;
|
||||
}
|
||||
|
||||
//play button
|
||||
if (!digitalRead(START_STOP_BTN_PIN) && !playBtnPushed && !shiftBtnPushed) {
|
||||
if (!digitalRead(START_STOP_BTN_PIN) && !playBtnPushed) {
|
||||
if (masterClockMode == 0) {
|
||||
calculateBPMTiming();
|
||||
if (!isPlaying) {
|
||||
@ -394,15 +387,6 @@ void checkInputs() {
|
||||
playBtnPushed = false;
|
||||
}
|
||||
|
||||
//shift + play = mute channel
|
||||
if (!digitalRead(START_STOP_BTN_PIN) && !playBtnPushed && shiftBtnPushed) {
|
||||
channels[displayTab - 1].isMute = !channels[displayTab - 1].isMute;
|
||||
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;
|
||||
@ -410,22 +394,24 @@ void checkInputs() {
|
||||
if (isRecording) { //Live triggering
|
||||
digitalWrite(outsPins[displayTab - 1], HIGH);
|
||||
}
|
||||
if (displayScreen == 1 && !isRecording && stepNumSelected <= sequences[patternToEdit].length && stepNumSelected != -1) {
|
||||
sequences[patternToEdit].sequence = bitFlip(sequences[patternToEdit].sequence, stepNumSelected);
|
||||
if (displayScreen == 1 && !isRecording) {
|
||||
patternToEdit[stepNumSelected] = !patternToEdit[stepNumSelected];
|
||||
} else if (displayScreen == 1 && isRecording && !recordToNextStep) { //Recording
|
||||
bitSet(sequences[patternToEdit].sequence, currentStep[displayTab - 1]);
|
||||
patternToEdit[currentStep] = 1;
|
||||
} else if (displayScreen == 1 && isRecording && recordToNextStep && currentStep != 15) {
|
||||
bitSet(sequences[patternToEdit].sequence, currentStep[displayTab - 1] + 1);
|
||||
patternToEdit[currentStep+1] = 1;
|
||||
} else if (displayScreen == 1 && isRecording && recordToNextStep && currentStep == 15) {
|
||||
bitSet(sequences[patternToEdit].sequence, 0);
|
||||
patternToEdit[0] = 1;
|
||||
}
|
||||
saveState();
|
||||
updateScreen();
|
||||
} else if (digitalRead(SHIFT_BTN_PIN) && shiftBtnPushed) {
|
||||
shiftBtnPushed = false;
|
||||
shiftReleasedTime = millis();
|
||||
if (displayScreen == 1 && shiftReleasedTime - shiftPressedTime > 1000 && !encBtnPushed && stepNumSelected != -1) { //&& shiftReleasedTime - shiftPressedTime < 2000 //Clear the sequence
|
||||
sequences[patternToEdit].sequence = 0b000000000000000000000000000000000;
|
||||
if (displayScreen == 1 && shiftReleasedTime - shiftPressedTime > 500 && !encBtnPushed) { //&& shiftReleasedTime - shiftPressedTime < 2000 //Clear the sequence
|
||||
for (byte i = 0; i < 16; i++) {
|
||||
patternToEdit[i] = 0;
|
||||
}
|
||||
} else if (shiftReleasedTime - shiftPressedTime > 2000 && encBtnPushed) {
|
||||
displayScreen = 2;
|
||||
menuItemSelected = 1; //hack to prevent from going back when the encoder is released
|
||||
@ -2,8 +2,8 @@ void updateScreen() {
|
||||
|
||||
u8g2.firstPage();
|
||||
do {
|
||||
uint8_t leftOffset;
|
||||
uint8_t width;
|
||||
byte leftOffset;
|
||||
byte width;
|
||||
String valueStr;
|
||||
u8g2.setDrawColor(1);
|
||||
|
||||
@ -11,7 +11,7 @@ void updateScreen() {
|
||||
//BPM Tab
|
||||
if (displayTab == 0) { //BPM
|
||||
|
||||
u8g2.setFont(stkS);
|
||||
u8g2.setFont(velvetscreen);
|
||||
|
||||
//Menu items
|
||||
lastMenuItem = 4;
|
||||
@ -27,7 +27,7 @@ void updateScreen() {
|
||||
lastMenuItem = 1;
|
||||
}
|
||||
|
||||
for (uint8_t i = 1; i <= lastMenuItem; i++) {
|
||||
for (byte i = 1; i <= lastMenuItem; i++) {
|
||||
if (i == 1) {
|
||||
valueStr = F("MODE:");
|
||||
} else if (i == 2 && masterClockMode == 0) {
|
||||
@ -48,7 +48,7 @@ void updateScreen() {
|
||||
}
|
||||
|
||||
//Values
|
||||
for (uint8_t i = 1; i <= lastMenuItem; i++) {
|
||||
for (byte i = 1; i <= lastMenuItem; i++) {
|
||||
if (i == 1 && masterClockMode == 0) { //Channel mode
|
||||
valueStr = F("INT");
|
||||
} else if (i == 1 && masterClockMode == 1) {
|
||||
@ -91,19 +91,19 @@ void updateScreen() {
|
||||
if ((!insideTab && !shiftBtnPushed) || (insideTab && menuItem != 0)) { //default view, nothing is selected or editable
|
||||
u8g2.setFont(stkL);
|
||||
u8g2.drawButtonUTF8(leftOffset-1, 28, U8G2_BTN_BW0|U8G2_BTN_HCENTER, width, 0, 3, valueStr.c_str() );
|
||||
u8g2.setFont(stkS);
|
||||
u8g2.setFont(velvetscreen);
|
||||
valueStr = F("BPM");
|
||||
u8g2.drawButtonUTF8(leftOffset, 40, U8G2_BTN_BW0|U8G2_BTN_HCENTER, width, 0, 2, valueStr.c_str() );
|
||||
} else if ((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0 && (menuItemSelected || shiftBtnPushed))) { //show value as editable
|
||||
u8g2.setFont(stkL);
|
||||
u8g2.drawButtonUTF8(leftOffset-1, 28, U8G2_BTN_BW1|U8G2_BTN_HCENTER, width, 0, 3, valueStr.c_str() );
|
||||
u8g2.setFont(stkS);
|
||||
u8g2.setFont(velvetscreen);
|
||||
valueStr = F("BPM");
|
||||
u8g2.drawButtonUTF8(leftOffset, 40, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, width, 0, 2, valueStr.c_str() );
|
||||
} else if (insideTab && menuItem == 0 && !menuItemSelected) { //show as selected menu item
|
||||
u8g2.setFont(stkL);
|
||||
u8g2.drawButtonUTF8(leftOffset-1, 28, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, width, 0, 3, valueStr.c_str() );
|
||||
u8g2.setFont(stkS);
|
||||
u8g2.setFont(velvetscreen);
|
||||
valueStr = F("BPM");
|
||||
u8g2.drawButtonUTF8(leftOffset, 40, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, width, 0, 2, valueStr.c_str() );
|
||||
}
|
||||
@ -118,26 +118,18 @@ void updateScreen() {
|
||||
//Channel Tabs
|
||||
else {
|
||||
//Menu items
|
||||
if (channels[displayTab - 1].mode == Swing) {
|
||||
lastMenuItem = 1;
|
||||
} else if (channels[displayTab - 1].mode == Gate) {
|
||||
lastMenuItem = 3;
|
||||
} else {
|
||||
lastMenuItem = 3;
|
||||
}
|
||||
lastMenuItem = 3;
|
||||
width = 32;
|
||||
leftOffset = 62;
|
||||
for (uint8_t i = 1; i <= lastMenuItem; i++) {
|
||||
for (byte i = 1; i <= lastMenuItem; i++) {
|
||||
if (i == 1) {
|
||||
valueStr = F("MODE:");
|
||||
} else if (i == 2 && channels[displayTab - 1].mode == Clock) {
|
||||
} else if (i == 2 && channels[displayTab - 1].mode == 0) {
|
||||
valueStr = F("OFFSET:");
|
||||
} else if (i == 2 && (channels[displayTab - 1].mode == Random || channels[displayTab - 1].mode == Gate)) {
|
||||
} else if (i == 2 && channels[displayTab - 1].mode == 1) {
|
||||
valueStr = F("SUBDIV:");
|
||||
} else if (i == 2 && channels[displayTab - 1].mode == Sequencer) {
|
||||
} else if (i == 2 && channels[displayTab - 1].mode == 2) {
|
||||
valueStr = F("EDIT PATTERN");
|
||||
} else if (i == 3 && channels[displayTab - 1].mode == Gate) {
|
||||
valueStr = (String(pulsePeriod) + " " + String(channelPulsesPerCycle[displayTab - 1]));
|
||||
} else if (i == 3) {
|
||||
valueStr = F("MOD:");
|
||||
}
|
||||
@ -149,18 +141,14 @@ void updateScreen() {
|
||||
}
|
||||
|
||||
//Values
|
||||
for (uint8_t i = 1; i <= lastMenuItem; i++) {
|
||||
if (i == 1 && channels[displayTab - 1].mode == Clock) { //Channel mode
|
||||
for (byte i = 1; i <= lastMenuItem; i++) {
|
||||
if (i == 1 && channels[displayTab - 1].mode == 0) { //Channel mode
|
||||
valueStr = F("CLOCK");
|
||||
} else if (i == 1 && channels[displayTab - 1].mode == Random) {
|
||||
} else if (i == 1 && channels[displayTab - 1].mode == 1) {
|
||||
valueStr = F("RAND");
|
||||
} else if (i == 1 && channels[displayTab - 1].mode == Sequencer) {
|
||||
} else if (i == 1 && channels[displayTab - 1].mode == 2) {
|
||||
valueStr = F("SEQ");
|
||||
} else if (i == 1 && channels[displayTab - 1].mode == Swing) {
|
||||
valueStr = F("SWING");
|
||||
} else if (i == 1 && channels[displayTab - 1].mode == Gate) {
|
||||
valueStr = F("GATE");
|
||||
} else if (i == 2 && channels[displayTab - 1].mode == Clock) { //SubDiv and offset
|
||||
} else if (i == 2 && channels[displayTab - 1].mode == 0) { //SubDiv and offset
|
||||
valueStr = String(channels[displayTab - 1].offset) + F("/");
|
||||
int PulsesPerStep;
|
||||
if (subDivs[channels[displayTab - 1].subDiv] < 0) {
|
||||
@ -169,10 +157,10 @@ void updateScreen() {
|
||||
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 == Random || channels[displayTab - 1].mode == Gate) && subDivs[channels[displayTab - 1].subDiv] > 0) {
|
||||
} else if (i == 2 && channels[displayTab - 1].mode == 1 && subDivs[channels[displayTab - 1].subDiv] > 0) {
|
||||
valueStr = F("/");
|
||||
valueStr = valueStr + String(subDivs[channels[displayTab - 1].subDiv]);
|
||||
} else if (i == 2 && (channels[displayTab - 1].mode == Random || channels[displayTab - 1].mode == Gate) && subDivs[channels[displayTab - 1].subDiv] < 0) {
|
||||
} else if (i == 2 && channels[displayTab - 1].mode == 1 && subDivs[channels[displayTab - 1].subDiv] < 0) {
|
||||
valueStr = F("x");
|
||||
valueStr = valueStr + String(abs(subDivs[channels[displayTab - 1].subDiv]));
|
||||
} else if (i == 3 && channels[displayTab - 1].CV1Target == 0 && channels[displayTab - 1].CV2Target == 0) { //MOD
|
||||
@ -183,7 +171,7 @@ void updateScreen() {
|
||||
valueStr = F("CV2");
|
||||
}
|
||||
|
||||
if (i == 2 && channels[displayTab - 1].mode == Sequencer) { //EDIT PATTERN thing
|
||||
if (i == 2 && channels[displayTab - 1].mode == 2) { //EDIT PATTERN thing
|
||||
if (menuItem == i && insideTab) {
|
||||
u8g2.drawBox(leftOffset + 54, ((i-1) * 11), 11, 11);
|
||||
}
|
||||
@ -201,52 +189,36 @@ void updateScreen() {
|
||||
//Main Param
|
||||
leftOffset = 29;
|
||||
width = 55;
|
||||
if (channels[displayTab - 1].mode == Clock) {
|
||||
if (channels[displayTab - 1].mode == 0) {
|
||||
valueStr = F("SUBDIVISION");
|
||||
} else if (channels[displayTab - 1].mode == Random) {
|
||||
} else if (channels[displayTab - 1].mode == 1) {
|
||||
valueStr = F("SKIP CHANCE");
|
||||
} else if (channels[displayTab - 1].mode == Sequencer) {
|
||||
} else if (channels[displayTab - 1].mode == 2) {
|
||||
valueStr = F("PATTERN");
|
||||
} else if (channels[displayTab - 1].mode == Swing) {
|
||||
valueStr = F("SWING");
|
||||
} else if (channels[displayTab - 1].mode == Gate) {
|
||||
valueStr = gateLengthTime[displayTab - 1];
|
||||
}
|
||||
|
||||
}
|
||||
if ((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0)) {
|
||||
u8g2.drawButtonUTF8(leftOffset, 41, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, width, 0, 3, valueStr.c_str() );
|
||||
} else {
|
||||
u8g2.drawButtonUTF8(leftOffset, 41, U8G2_BTN_BW0|U8G2_BTN_HCENTER, width, 1, 2, valueStr.c_str() );
|
||||
}
|
||||
|
||||
if (channels[displayTab - 1].mode == Clock) {
|
||||
if (channels[displayTab - 1].mode == 0) {
|
||||
if (subDivs[channels[displayTab - 1].subDiv] > 0) {
|
||||
valueStr = F("/");
|
||||
} else {
|
||||
valueStr = F("x");
|
||||
}
|
||||
valueStr = valueStr + String(abs(subDivs[channels[displayTab - 1].subDiv]));
|
||||
} else if (channels[displayTab - 1].mode == Random) {
|
||||
valueStr = String(channels[displayTab - 1].random) + (channels[displayTab - 1].random == 0 ? "%" : "0%");
|
||||
} else if (channels[displayTab - 1].mode == Sequencer) {
|
||||
} 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 = F("A");
|
||||
valueStr = valueStr + String(channels[displayTab - 1].seqPattern + 1);
|
||||
} else if (channels[displayTab - 1].seqPattern >= 8 && channels[displayTab - 1].seqPattern < 16) {
|
||||
} else {
|
||||
valueStr = F("B");
|
||||
valueStr = valueStr + String(channels[displayTab - 1].seqPattern - 7);
|
||||
} else if (channels[displayTab - 1].seqPattern >= 16 && channels[displayTab - 1].seqPattern < 24) {
|
||||
valueStr = F("C");
|
||||
valueStr = valueStr + String(channels[displayTab - 1].seqPattern - 15);
|
||||
} else if (channels[displayTab - 1].seqPattern >= 24 && channels[displayTab - 1].seqPattern < 32) {
|
||||
valueStr = F("D");
|
||||
valueStr = valueStr + String(channels[displayTab - 1].seqPattern - 23);
|
||||
}
|
||||
} else if (channels[displayTab - 1].mode == Swing) {
|
||||
uint8_t swingVals[6] = {50, 58, 66, 75, 83, 92};
|
||||
valueStr = String(swingVals[channels[displayTab - 1].swing]) + "%";
|
||||
} else if (channels[displayTab - 1].mode == Gate) {
|
||||
valueStr = String(channels[displayTab - 1].gate) + "%";
|
||||
}
|
||||
u8g2.setFont(stkL);
|
||||
if ((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0 && (menuItemSelected || shiftBtnPushed))) {
|
||||
@ -260,9 +232,9 @@ void updateScreen() {
|
||||
|
||||
//Tabs
|
||||
u8g2.drawHLine(0, 53, 128);
|
||||
u8g2.setFont(stkS);
|
||||
uint8_t yPos = 61;
|
||||
uint8_t xWidth = 12;
|
||||
u8g2.setFont(velvetscreen);
|
||||
byte yPos = 61;
|
||||
byte xWidth = 12;
|
||||
valueStr = F("w");
|
||||
if (displayTab == 0) {
|
||||
if (insideTab == true || shiftBtnPushed == true) {
|
||||
@ -274,7 +246,7 @@ void updateScreen() {
|
||||
u8g2.drawButtonUTF8(xWidth/2, yPos, U8G2_BTN_BW0|U8G2_BTN_HCENTER, xWidth, 0, 2, valueStr.c_str() );
|
||||
}
|
||||
|
||||
for (uint8_t i = 1; i <= (extraChannel ? 7 : 6); i++) {
|
||||
for (int i = 1; i <= 6; i++) {
|
||||
valueStr = String(i);
|
||||
if (displayTab == i) {
|
||||
if (insideTab == true || shiftBtnPushed == true) {
|
||||
@ -298,8 +270,8 @@ void updateScreen() {
|
||||
|
||||
//Edit Pattern Screen (Sequencer)
|
||||
else if (displayScreen == 1) {
|
||||
u8g2.setFont(stkS);
|
||||
uint8_t pattern = channels[displayTab - 1].seqPattern;
|
||||
u8g2.setFont(velvetscreen);
|
||||
byte pattern = channels[displayTab - 1].seqPattern;
|
||||
if (pattern < 8) {
|
||||
valueStr = F("PATTERN A");
|
||||
valueStr = valueStr + String(pattern + 1);
|
||||
@ -307,31 +279,27 @@ void updateScreen() {
|
||||
valueStr = F("PATTERN B");
|
||||
valueStr = valueStr + String(pattern - 7);
|
||||
}
|
||||
u8g2.drawUTF8(8, 6, valueStr.c_str() );
|
||||
valueStr = F("L: ");
|
||||
//u8g2.drawUTF8(100, 5, valueStr.c_str() );
|
||||
if (!isRecording && stepNumSelected == -1) {
|
||||
u8g2.drawButtonUTF8(97, 6, U8G2_BTN_BW1|U8G2_BTN_INV, 5, 1, 2, valueStr.c_str() );
|
||||
} else {
|
||||
u8g2.drawButtonUTF8(97, 6, U8G2_BTN_BW0, 5, 1, 2, valueStr.c_str() );
|
||||
u8g2.drawButtonUTF8(64, 5, U8G2_BTN_BW1|U8G2_BTN_HCENTER, 128, 0, 2, valueStr.c_str() );
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
valueStr = String(sequences[patternToEdit].length + 1);
|
||||
//u8g2.drawUTF8(110, 5, valueStr.c_str() );
|
||||
if (!isRecording && stepNumSelected == -1 && (menuItemSelected || shiftBtnPushed)) {
|
||||
u8g2.drawButtonUTF8(110, 6, U8G2_BTN_BW1, 8, 1, 2, valueStr.c_str() );
|
||||
} else if (!isRecording && stepNumSelected == -1 && (!menuItemSelected || !shiftBtnPushed)) {
|
||||
u8g2.drawButtonUTF8(110, 6, U8G2_BTN_BW1|U8G2_BTN_INV, 8, 1, 2, valueStr.c_str() );
|
||||
} else {
|
||||
u8g2.drawButtonUTF8(110, 6, U8G2_BTN_BW0, 8, 1, 2, valueStr.c_str() );
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
u8g2.drawHLine(0, 8, 128);
|
||||
for (uint8_t i = 0; i <= sequences[patternToEdit].length; i++) {
|
||||
u8g2.drawUTF8(19 + (i % 8)*12, 33 - ((sequences[patternToEdit].length / 8) * 5) + ((i / 8) * 11), (bitRead(sequences[patternToEdit].sequence, i) ? "q" : "p"));
|
||||
}
|
||||
if (!isRecording && stepNumSelected >= 0) {
|
||||
u8g2.drawFrame(16 + (stepNumSelected % 8)*12, 25 - ((sequences[patternToEdit].length / 8) * 5) + ((stepNumSelected / 8) * 11), 11, 11); //cursor
|
||||
if (!isRecording) {
|
||||
if (stepNumSelected < 8 ) {
|
||||
u8g2.drawFrame(16 + stepNumSelected * 12, 16, 11, 11);
|
||||
} else {
|
||||
u8g2.drawFrame(16 + (stepNumSelected-8) * 12, 32, 11, 11);
|
||||
}
|
||||
}
|
||||
|
||||
if (isRecording) {
|
||||
@ -346,9 +314,9 @@ void updateScreen() {
|
||||
u8g2.drawStr(8, 5, valueStr.c_str() );
|
||||
u8g2.drawStr(122 - (u8g2.getStrWidth(version.c_str())), 5, version.c_str() );
|
||||
u8g2.drawHLine(0, 8, 128);
|
||||
lastMenuItem = 4;
|
||||
uint8_t width = 112;
|
||||
for (uint8_t i = 0; i <= lastMenuItem; i++) {
|
||||
lastMenuItem = 3;
|
||||
byte width = 112;
|
||||
for (byte i = 0; i <= lastMenuItem; i++) {
|
||||
switch(i) {
|
||||
case 0:
|
||||
valueStr = F("CALIBRATE CV INS");
|
||||
@ -360,9 +328,6 @@ void updateScreen() {
|
||||
valueStr = F("REVERSE ENCODER");
|
||||
break;
|
||||
case 3:
|
||||
valueStr = (extraChannel ? F("7TH CHANNEL: ON") : F("7TH CHANNEL: OFF"));
|
||||
break;
|
||||
case 4:
|
||||
valueStr = F("FACTORY RESET");
|
||||
break;
|
||||
};
|
||||
Reference in New Issue
Block a user