linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] rotary-encoder: Add new interruption handler
@ 2013-10-04 12:53 Ezequiel Garcia
  2013-10-04 12:53 ` [PATCH v2 1/2] Input: rotary-encoder: Add 'stepped' irq handler Ezequiel Garcia
       [not found] ` <1380891203-17617-1-git-send-email-ezequiel-30ULvvUtt6G51wMPkGsGjgyUoB5FGQPZ@public.gmane.org>
  0 siblings, 2 replies; 8+ messages in thread
From: Ezequiel Garcia @ 2013-10-04 12:53 UTC (permalink / raw)
  To: linux-kernel, linux-input; +Cc: Ezequiel Garcia, Daniel Mack, Dmitry Torokhov

Some rotary-encoder devices (such as those with detents) are capable
of producing a stable event on each step. This simple patch adds support
for this case, by implementing a new interruption handler.

The handler needs only detect the direction of the turn and generate
an event according to this detection.

We encode the previous and the current state, and then use the sum of them
to decide on the direction of the turn, according to the following simple
table:

Previous state + currrent state	| Movement
==========================================
	0b1101			| clockwise
	0b0100			|   ..
	0b0010			|   ..
	0b1011			|   ..
==========================================
	0b1110			| counter-clockwise
	0b0111			|   ..
	0b0001			|   ..
	0b1000			|   ..

(The other sumed values are considered illegal)

This calculation is based on some previous work found at this blog:

  http://bildr.org/2012/08/rotary-encoder-arduino/

The result is a seemingly very robust behavior, with a truly simple
implementation, that produces an event on each turn of the device.

Thanks!

Ezequiel Garcia (2):
  Input: rotary-encoder: Add 'stepped' irq handler
  input: rotary-encoder: Add 'on-each-step' to binding documentation

 .../devicetree/bindings/input/rotary-encoder.txt   |  1 +
 drivers/input/misc/rotary_encoder.c                | 41 ++++++++++++++++++++++
 include/linux/rotary_encoder.h                     |  1 +
 3 files changed, 43 insertions(+)

-- 
1.8.1.5

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-10-12 16:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-04 12:53 [PATCH v2 0/2] rotary-encoder: Add new interruption handler Ezequiel Garcia
2013-10-04 12:53 ` [PATCH v2 1/2] Input: rotary-encoder: Add 'stepped' irq handler Ezequiel Garcia
2013-10-04 13:18   ` Daniel Mack
2013-10-12 16:58     ` Ezequiel García
     [not found] ` <1380891203-17617-1-git-send-email-ezequiel-30ULvvUtt6G51wMPkGsGjgyUoB5FGQPZ@public.gmane.org>
2013-10-04 12:53   ` [PATCH v2 2/2] input: rotary-encoder: Add 'on-each-step' to binding documentation Ezequiel Garcia
2013-10-04 13:19     ` Mark Rutland
2013-10-04 14:09       ` Ezequiel Garcia
2013-10-10 13:55         ` Ezequiel García

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).