Skip to content

Commit

Permalink
fixed PER_DETENT (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshnishikawa committed Feb 11, 2022
1 parent 7f3a362 commit 02b1748
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# MIDIcontroller 2.4.2
# MIDIcontroller 2.4.3
### A library for creating Teensy MIDI controllers.
###### by Josh Nishikawa <github.com/joshnishikawa/MIDIcontroller>

Expand All @@ -16,6 +16,9 @@ ___
___

### VERSION LOG:
2.4.3
- Fixed it again (hopefully without breaking anything else this time).

2.4.2
- Fixed a bug preventing PER_DETENT from working on encoders.

Expand Down
2 changes: 1 addition & 1 deletion examples/MIDIenc/MIDIenc.ino
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const int ledPin = 13; // Set an LED to show the state of the switch.
// You can also add min AND max output
// and/or PER_DETENT as a final argument.
// PER_DETENT increases or decreases the CC value once per detent. (on detented quadratic encoders)
MIDIenc myEnc(encPinA, encPinB, 24);
MIDIenc myEnc(encPinA, encPinB, 24, PER_DETENT);

MIDIbutton myButton(buttonPin, 25, LATCH); // CC #25 in latch mode

Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=MIDIcontroller
version=2.4.2
version=2.4.3
author=Josh Nishikawa <joshnishikawa@gmail.com>
maintainer=Josh Nishikawa <joshnishikawa@gmail.com>
sentence=A library for creating Teensy MIDI controllers.
Expand Down
18 changes: 13 additions & 5 deletions src/MIDIenc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,23 @@ MIDIenc::~MIDIenc(){
int MIDIenc::read(){
int newValue = -1;
int incdec = myKnob->read();
if(incdec >= detentOrValue && value < outHi){
newValue = value + 1;

if (incdec >= detentOrValue){
if (value < outHi){
newValue = value + 1;
}
myKnob->write(0);
}
else if (incdec <= -detentOrValue && value > outLo){
newValue = value - 1;
else if (incdec <= -detentOrValue){
if (value > outLo){
newValue = value - 1;
}
myKnob->write(0);
}
else{newValue = -1;}
else{
newValue = -1;
}

return newValue;
};

Expand Down

0 comments on commit 02b1748

Please sign in to comment.