Added basic acceleration and filtering for the encoder, but it still needs finetuning
This commit is contained in:
@ -134,6 +134,7 @@ int CV1Input = 0;
|
|||||||
int CV2Input = 0;
|
int CV2Input = 0;
|
||||||
|
|
||||||
int encPositionOld = 0;
|
int encPositionOld = 0;
|
||||||
|
int encDirectionOld = 0;
|
||||||
unsigned long encPressedTime;
|
unsigned long encPressedTime;
|
||||||
unsigned long encReleasedTime;
|
unsigned long encReleasedTime;
|
||||||
unsigned long playPressedTime;
|
unsigned long playPressedTime;
|
||||||
|
|||||||
@ -85,8 +85,16 @@ void checkInputs() {
|
|||||||
//encoder
|
//encoder
|
||||||
encoder.tick();
|
encoder.tick();
|
||||||
int encPosition = encoder.getPosition();
|
int encPosition = encoder.getPosition();
|
||||||
|
int encDirection = (int)(encoder.getDirection());
|
||||||
if (encPositionOld != encPosition) {
|
if (encPositionOld != encPosition) {
|
||||||
int change = encPositionOld - encPosition;
|
int change = encPositionOld - encPosition;
|
||||||
|
unsigned long ms = encoder.getMillisBetweenRotations();
|
||||||
|
if (encDirectionOld == encDirection && ms < 50) { //encoder acceleration
|
||||||
|
change = change * 5;
|
||||||
|
} else if (encDirectionOld != encDirection && ms < 150) { //filter out encoder "jumps"
|
||||||
|
change = 0;
|
||||||
|
}
|
||||||
|
encDirectionOld = encDirection;
|
||||||
if (displayScreen == 0) {
|
if (displayScreen == 0) {
|
||||||
byte channelCV;
|
byte channelCV;
|
||||||
if (!insideTab && !shiftBtnPushed) { //Change tab
|
if (!insideTab && !shiftBtnPushed) { //Change tab
|
||||||
|
|||||||
Reference in New Issue
Block a user