stripped encoder to barebones, added midi start for external clock (still needs midi stop though)
This commit is contained in:
@ -250,17 +250,15 @@ ISR (PCINT2_vect) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t encoderStatus;
|
uint8_t encoderStatus;
|
||||||
uint32_t encoderCheckTime = 0;
|
//uint32_t encoderCheckTime = 0;
|
||||||
uint32_t encoderTimeBetweenPulses = 0;
|
//uint32_t encoderTimeBetweenPulses = 0;
|
||||||
bool encoderDirectionOld; //0 = -, 1 = +, Old because current direction can be determined by encoderChange
|
//bool encoderDirectionOld; //0 = -, 1 = +, Old because current direction can be determined by encoderChange
|
||||||
int8_t encoderChange = 0;
|
int8_t encoderChange = 0;
|
||||||
uint8_t encoderBurstCount = 0;
|
//uint8_t encoderBurstCount = 0;
|
||||||
|
|
||||||
void checkEncoderStatus() {
|
void checkEncoderStatus() {
|
||||||
bool pin1Status = digitalRead(ENC_D1_PIN);
|
uint8_t newStatus = (digitalRead(ENC_D1_PIN) << 1) | digitalRead(ENC_D2_PIN);
|
||||||
bool pin2Status = digitalRead(ENC_D2_PIN);
|
switch(encoderStatus) {
|
||||||
uint8_t newStatus = (pin1Status << 1) | pin2Status;
|
|
||||||
switch(encoderStatus) { // encoderStatus & 0b00000011 - to check only 2 last bits
|
|
||||||
case 0b00:
|
case 0b00:
|
||||||
if (newStatus == 0b01) {
|
if (newStatus == 0b01) {
|
||||||
encoderChange++;
|
encoderChange++;
|
||||||
@ -290,13 +288,11 @@ void checkEncoderStatus() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//encoderStatus = (encoderStatus << 2); //previous status is now stored in bits 2 and 3
|
encoderStatus = newStatus;
|
||||||
encoderStatus = bitWrite(encoderStatus, 1, pin1Status);
|
|
||||||
encoderStatus = bitWrite(encoderStatus, 0, pin2Status); //This can probably be more optimizied with bit logic
|
|
||||||
|
|
||||||
uint32_t currentTime = millis();
|
//uint32_t currentTime = millis();
|
||||||
encoderTimeBetweenPulses = currentTime - encoderCheckTime;
|
//encoderTimeBetweenPulses = currentTime - encoderCheckTime;
|
||||||
encoderCheckTime = currentTime;
|
//encoderCheckTime = currentTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendMIDIClock() {
|
void sendMIDIClock() {
|
||||||
@ -391,8 +387,8 @@ void externalClock() {
|
|||||||
|
|
||||||
//reset cycles if there were no pulses for a while
|
//reset cycles if there were no pulses for a while
|
||||||
if ((newExtPulseTime - lastExtPulseTime) > 125) { //125ms is 20bpm
|
if ((newExtPulseTime - lastExtPulseTime) > 125) { //125ms is 20bpm
|
||||||
|
|
||||||
resetClocks();
|
resetClocks();
|
||||||
|
sendMIDIStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
tickCount = 0; //to make things happen in the main clock function
|
tickCount = 0; //to make things happen in the main clock function
|
||||||
|
|||||||
@ -99,14 +99,14 @@ void checkInputs() {
|
|||||||
encoderDirectionOld = (encoderChange > 0);*/
|
encoderDirectionOld = (encoderChange > 0);*/
|
||||||
|
|
||||||
//encoder acceleration
|
//encoder acceleration
|
||||||
if (encoderTimeBetweenPulses < 15) { // <--
|
/*if (encoderTimeBetweenPulses < 15) { // <--
|
||||||
encoderBurstCount++;
|
encoderBurstCount++;
|
||||||
} else {
|
} else {
|
||||||
encoderBurstCount = 0;
|
encoderBurstCount = 0;
|
||||||
}
|
}
|
||||||
if (encoderBurstCount > 3) { // <--
|
if (encoderBurstCount > 3) { // <--
|
||||||
encoderChange = encoderChange * 3; // <-- The three params need to be finetuned to feel natural
|
encoderChange = encoderChange * 3; // <-- The three params need to be finetuned to feel natural
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if (displayScreen == 0) {
|
if (displayScreen == 0) {
|
||||||
byte channelCV;
|
byte channelCV;
|
||||||
@ -169,9 +169,7 @@ void checkInputs() {
|
|||||||
} else if (((!insideTab && shiftBtnPushed)
|
} else if (((!insideTab && shiftBtnPushed)
|
||||||
|| (insideTab && menuItem == 0
|
|| (insideTab && menuItem == 0
|
||||||
&& (menuItemSelected || shiftBtnPushed)))
|
&& (menuItemSelected || shiftBtnPushed)))
|
||||||
&& displayTab != 0 // things to try:
|
&& displayTab != 0
|
||||||
// count "burst" changes and apply acceleration (test the period between ticks in a new sketch)
|
|
||||||
|
|
||||||
&& channels[displayTab - 1].mode == 2) { //Change SEQ pattern
|
&& channels[displayTab - 1].mode == 2) { //Change SEQ pattern
|
||||||
channels[displayTab - 1].seqPattern = channels[displayTab - 1].seqPattern + encoderChange;
|
channels[displayTab - 1].seqPattern = channels[displayTab - 1].seqPattern + encoderChange;
|
||||||
if (channels[displayTab - 1].seqPattern > 100) {
|
if (channels[displayTab - 1].seqPattern > 100) {
|
||||||
|
|||||||
Reference in New Issue
Block a user