Skip to content

How to reset different min/max encoder values for button states? #9

Answered by luni64
m-r-m-s asked this question in Q&A
Discussion options

You must be logged in to vote

Your code does not compile since a couple of variable definitions are missing... Anyway, from your description I assume that you want to change the counting range of the encoder when the encoder button is pressed. After such a change the encoder value shall be reset to 0. Here some code (without all the midi stuff) which shows how to achieve this:

#include "Arduino.h"
#include "EncoderTool.h"
using namespace EncoderTool;

PolledEncoder encoder;
int mode = 0;

void onEncoderChanged(int value, int delta)
{
    if (mode == 0)
    {
        // do something with the value....
        Serial.print("Mode 0, value: ");
        Serial.println(value);
    }
    else
    {
        // do something wi…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@m-r-m-s
Comment options

@luni64
Comment options

Answer selected by m-r-m-s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants