Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rotation calculation improvements #42

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mjschuetze102
Copy link
Member

Description

Problem

When a rotary encoder is spun, the resulting direction is immediately sent to the host machine. When this happens, the host machine will store a buffer of each spin (as there are typically many sent at the same time). The host machine then calls the volume changer logic on the operating system one instruction at a time. And since each instruction is equivalent to one rotation, multiple instructions need to be sent to the OS in order to perform the volume changes requested. The code to interface with the operating system is rather slow, meaning there can be quite a bit of latency between rotary encoder spins and the volume actually changing

Solution

The rotary encoder spins are now grouped into 200ms intervals. This allows for sending one request that represents multiple spins rather than multiple request with one spin. This reduces the latency seen with the OS operations

Additionally, the bitwise operations for determining direction of rotation were modified slightly. When using boards with different underlying storage space for int, the bitwise logic would not always act the way intended. For example, with the Arduino Uno int represents int16, whereas int on a Teensy 3.2 is actually an int32. This meant the bitwise math of the Teensy did not properly account for the negative rotation direction because the beginning 16 bits remained as all 0s. The datatype used to store was changed to int16 to allow for the math to continue to work regardless of board being used

@mjschuetze102 mjschuetze102 added Enhancement New feature or request Controller Work done on the micro controller labels Oct 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Controller Work done on the micro controller Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant