How to handle encoder data

Okay! I’m finally tackling the encoders. I’m planning on having multiple banks of encoders for different functions within Hachi, but I don’t want to use your system of banks, because of the storage overhead.

I plan on storing the current value of each controller, and then when I get an update from EncoderInputs::SendRotaryMessage() I’ll update the controller that’s currently active.

However, the encoder code is pretty complicated, I think because you’re tracking direction of movement and acceleration etc. I’d like to reuse your code for that stuff but with use it with my own controller tracking.

I’m looking at the code in encoders.ino, starting about line 1079:

// GET NEW ENCODER VALUE based on speed, direction and speed multiplier (14 bits config)

If I just have one bank, will there only be one set of eBankData? It looks like the amount to update the value is determined either by normalDirection or nextJump*speedMultiplier. So if I pull out the value after that block of code, I’ll be reusing your acceleration logic. Is that right?

And if I just want to use one of your banks but have my own values, can I just insert my values into eBankData[eHwData[encNo].thisEncoderBank][encNo].encoderValue when I change my “banks” and let the rest of your logic just update those values?

I think the other option would be for me to just tap in earlier and grab normalDirection and create my own acceleration logic? I’m not sure yet what makes more sense – I just started trying to figure this out. Any suggestions are welcome!

Related question: I’d like to experiment with letting the encoders go faster – can I just increase ENCODER_MAX_SPEED?

Never mind that last question I updated the accel speed values:

uint8_t encoderAccelSpeed[][ENCODER_MAX_SPEED] = {{1, 2, 3, 3, 4, 5},
{1, 2, 3, 4, 6, 7},
{1, 2, 4, 8, 12, 16}};

Increasing the acceleration makes the encoders feel kind of unpredictable. I might go to fixed speed but have fast and slow modes, but where fast is pretty fast, like a jump value of 8-12. Encoder click could switch between modes. The other thing I was thinking was use the encoder click to jump between zero and the current value, for very quick changes.

We’ll see what works! I’m thinking I maybe should have made Hachi with faders instead, but I do love the LED rings.

Hi here as well! haha

Sorry for the late reply and leave your post unattended all this time.

Could you figure this out?

That’s correct, only index 0 will have data.

Correct, after that whole IF on the line you mentioned, the value eBankData[eHwData[encNo].thisEncoderBank][encNo].encoderValue will contain the new value with acceleration or fixed speed amounts applied (where thisEncoderBank will always be 0 if you have one bank) for the normal encoder operation.
Shift encoder bank or double CC values have their respective variables.

For this I’d use the function SetEncoderValue(), though it will limit the values to the integer range between 0 and 127.

You could do this obviously.

Haha who doesn’t

For this you can change two things (in acceleration modes):

  1. Increase the encoderAccelSpeed array you found, changing the value jumps for each speed.
  2. Increase the detentMillisSpeedThresholds with which you tell the controller to be less restrictive regarding timing to reach the higher speeds.

For Fixed speeds I am sorry but there is no other way than making greater jumps.
Fixed 3 speed is really similar to a potentiometer, that is, a 300° turn will make the value increase from 0 to 127.

There is a double click function for the encoder switch that let’s you jump to 0, to center (betwen MIN and MAX) or to 127.
You can modify it so it can jump to the previous value.

Let me know if you could figure things out, and hope this answer helps, even being so late.

Sorry again for that! Keep up the great work!