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

Support for rotary encoder #12

Merged
merged 7 commits into from
Mar 15, 2021
Merged

Conversation

martinfelis
Copy link
Contributor

Adds support for rotary encoders (potential fix for #11). Two pins can be linked by specifying the same id for the rotenc_idoption e.g.:

    [raspberry-gpio]
    enabled = true
    bcm21 = volume_down,active_low,10,rotenc_id=vol,step=1
    bcm20 = volume_up,active_low,10,rotenc_id=vol,step=1

In principle multiple rotary encoders should be supported, simply use different rotenc_ids.

In case you want to use the reverse rotation simply swap the events in the first argument to the bcm specification.

import unittest

from unittest.mock import patch
from mopidy_raspberry_gpio import RotEncoder
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be:

from mopidy_raspberry_gpio.rotencoder import RotEncoder

Tests pass locally for me with this change.

@codecov-io
Copy link

codecov-io commented Mar 15, 2021

Codecov Report

Merging #12 (289edf8) into master (b4f6137) will increase coverage by 3.67%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #12      +/-   ##
==========================================
+ Coverage   91.08%   94.76%   +3.67%     
==========================================
  Files           2        4       +2     
  Lines         101      172      +71     
==========================================
+ Hits           92      163      +71     
  Misses          9        9              
Impacted Files Coverage Δ
mopidy_raspberry_gpio/frontend.py 93.75% <100.00%> (+2.08%) ⬆️
mopidy_raspberry_gpio/rotencoder.py 100.00% <100.00%> (ø)
mopidy_raspberry_gpio/__init__.py 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b4f6137...289edf8. Read the comment docs.

@martinfelis
Copy link
Contributor Author

@Gadgetoid thanks for the hint.

@Gadgetoid Gadgetoid merged commit 726eff3 into pimoroni:master Mar 15, 2021
@Gadgetoid
Copy link
Member

Thanks for the awesome addition to this library!

Now to... uh... figure out how to release this sucker. It's been a while.

@martinfelis
Copy link
Contributor Author

In case it is possible to add this somehow: the contributions of this pull request was joint work with @bombadil.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants