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
input: gpio_qdec: add optical encoder support #66121
input: gpio_qdec: add optical encoder support #66121
Conversation
00d161c
to
4c22e4c
Compare
4c22e4c
to
109999a
Compare
05f44ee
to
7c5df92
Compare
Rename gpio to ab_gpio, this is in preparation for adding another gpio pointer. Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
7c5df92
to
8c087aa
Compare
Merge conflict, rebased. |
Change the gpio_qdec driver to support optical encoders. Add a property to use for defining an arbitrary number of GPIOs for the sensing devices (typically infrared LEDs, but could also be the biasing for the phototransistor), and one for adding a delay between turning those on and reading the pin status. The infrared LEDs typically consume a non negligible amount of power, so there's also a new idle-poll-time-us property that enables two possible modes of operation: - if idle-poll-time-us is zero (default) the LEDs are enabled all the time and the driver enters polling mode using the GPIO interrupt as with mechanical encoders. This is usable for mains powered devices and has the lowest overhead on the CPU. - if idle-poll-time-us is non zero, then the driver polls the encoder all the time, turning on the LEDs just before reading the state and shutting them off immediately after, but when the encoder is idle it switches the polling rate to idle-poll-time-us to save power, and only polls at sample-time-us when some movement is detected. Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
8c087aa
to
ae4ee35
Compare
@kartben ping |
@fabiobaltieri Just tested this on an ESP32 today and it crashes unless INPUT_STACK_SIZE is 1024. Would it make sense to change the default stack size of the input thread to a more conservative value? I am guessing 768 would be an option too :P |
Yeah not a bad idea, found myself changing it for some applications as well, 512 may have been optimistic. Can you send a PR? If you set it to 1024 (which sounds good to me) you can drop the override from |
Sounds good. Will probably have to wait after 3.6 -- still wrapping up all the demos I want to videotape, which this driver will apparently be a part of :) |
Yeah no sense pushing it for 3.6, I'll just file it myself then not a problem. |
Change the gpio_qdec driver to support optical encoders.
Add a property to use for defining an arbitrary number of GPIOs for the sensing devices (typically infrared LEDs, but could also be the biasing for the phototransistor), and one for adding a delay between turning those on and reading the pin status.
The infrared LEDs typically consume a non negligible amount of power, so there's also a new idle-poll-time-us property that enables two possible modes of operation:
if idle-poll-time-us is zero (default) the LEDs are enabled all the time and the driver enters polling mode using the GPIO interrupt as with mechanical encoders. This is usable for mains powered devices and has the lowest overhead on the CPU.
if idle-poll-time-us is non zero, then the driver polls the encoder all the time, turning on the LEDs just before reading the state and shutting them off immediately after, but when the encoder is idle it switches the polling rate to idle-poll-time-us to save power, and only polls at sample-time-us when some movement is detected.