Page 1 of 1

Use Rotary Encoder no counter just up or down

Posted: 01 Feb 2021, 11:26
by Stephan123
For one of my amps U build an IR transmitter so I can use it form a distance (it's on a cabinet out of reach) with my Logitech remote.
No I like to add a volume control button to my remote so I am able to control it also without remote.

For that I want to use a Rotary Encoder. I have the encoder working, but now I want to be able to know when I turn it clockwise (+1) or counter clockwise (-1) and I do not need the counter for more.
So i like to set it after every turn click to 0 and use a rule to figure out which side is was turned and use that as a command to fire the IR signal.

Is this possible with the standard stack?

Re: Use Rotary Encoder no counter just up or down

Posted: 01 Feb 2021, 12:04
by Ath
Have you tried the 'Switch - Rotary encoder' plugin?

I'd expect the counter to go down when turned in the 'opposite' direction, (though I've never used this plugin).
You can detect and handle that in rules.

Re: Use Rotary Encoder no counter just up or down

Posted: 01 Feb 2021, 21:22
by Stephan123
I indeed use the rotary encoder plugin it counts down or up. But how do I use that in a rule?
And when I come back later and do the same action it still nows that it goes down or up?

In short, I am only interested in the direction of turning, the counting is not needed for this project :)

Re: Use Rotary Encoder no counter just up or down

Posted: 01 Feb 2021, 22:37
by Ath
You can add a Dummy Device to your Devices list, give it a useful name, say Variables and enable it.
Then add this to your rules:

Code: Select all

on System#Boot do
  TaskValueSet,12,1,[Rotary#Count] // Assume the Dummy device is on task 12
endon

on Rotary#Count do
  if %eventvalue% > [Variables#Dummy]
    // transmit IR volume up command
  endif
  if %eventvalue% < [Variables#Dummy]
    // transmit IR volume down command
  endif
  TaskValueSet,12,1,%eventvalue% // Store current value
endon
Edit: Changed to not turn down the volume when nothing changes but a periodic event is fired (and the Count value doesn't change).

Re: Use Rotary Encoder no counter just up or down

Posted: 26 Jul 2022, 02:24
by Trelsonowsky
Hi, this is a long shot as this post was last active in 2021 but..
The code you've posted isn't working for me.
Whenever I turn the encoder I only get this and no IR commands are sent.

Code: Select all

250812 : Info   : QEI  : 31
250816 : Info   : EVENT: VOL#Counter=31
251612 : Info   : QEI  : 30
251616 : Info   : EVENT: VOL#Counter=30
251912 : Info   : QEI  : 29
251915 : Info   : EVENT: VOL#Counter=29
my rules are:

Code: Select all

on System#Boot do
  TaskValueSet,12,1,[VOL#Count] // Assume the Dummy device is on task 12
endon

on Rotary#Count do
  if %eventvalue% > [Variables#Dummy]
    IRSEND,NEC,0x616E2AD5,32
  endif
  if %eventvalue% < [Variables#Dummy]
    IRSEND,NEC,0x616ECA35,32
  endif
  TaskValueSet,12,1,%eventvalue% // Store current value
endon

on Switch#State do
 if [Switch#State]=1
  IRSEND,NEC,0x616E02FD,32
 else
 IRSEND,NEC,0x616E827D,32
 endif
endon

Re: Use Rotary Encoder no counter just up or down

Posted: 26 Jul 2022, 10:06
by TD-er
Just to be sure, what build are you using?
Also do you have a task configured with the IR-TX plugin?

Re: Use Rotary Encoder no counter just up or down

Posted: 26 Jul 2022, 10:47
by chromo23
Trelsonowsky wrote: 26 Jul 2022, 02:24 my rules are:
CODE: SELECT ALL

on System#Boot do
TaskValueSet,12,1,[VOL#Count] // Assume the Dummy device is on task 12
endon

on Rotary#Count do
if %eventvalue% > [Variables#Dummy]
IRSEND,NEC,0x616E2AD5,32
endif
if %eventvalue% < [Variables#Dummy]
IRSEND,NEC,0x616ECA35,32
endif
TaskValueSet,12,1,%eventvalue% // Store current value
endon

on Switch#State do
Look at your code... it seem that your rotary encoder task is called VOL and the taskvalue is called Count ([VOL#Count])
So this line:

Code: Select all

on Rotary#Count do
you should change into:

Code: Select all

On VOL#Count Do