Use Rotary Encoder no counter just up or down

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Stephan123
New user
Posts: 5
Joined: 03 Jan 2021, 23:45

Use Rotary Encoder no counter just up or down

#1 Post by Stephan123 » 01 Feb 2021, 11:26

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?

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Use Rotary Encoder no counter just up or down

#2 Post by Ath » 01 Feb 2021, 12:04

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.
/Ton (PayPal.me)

Stephan123
New user
Posts: 5
Joined: 03 Jan 2021, 23:45

Re: Use Rotary Encoder no counter just up or down

#3 Post by Stephan123 » 01 Feb 2021, 21:22

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 :)

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Use Rotary Encoder no counter just up or down

#4 Post by Ath » 01 Feb 2021, 22:37

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).
/Ton (PayPal.me)

Trelsonowsky
Normal user
Posts: 10
Joined: 25 Jul 2022, 18:21

Re: Use Rotary Encoder no counter just up or down

#5 Post by Trelsonowsky » 26 Jul 2022, 02:24

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

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Use Rotary Encoder no counter just up or down

#6 Post by TD-er » 26 Jul 2022, 10:06

Just to be sure, what build are you using?
Also do you have a task configured with the IR-TX plugin?

User avatar
chromo23
Normal user
Posts: 821
Joined: 10 Sep 2020, 16:02
Location: germany

Re: Use Rotary Encoder no counter just up or down

#7 Post by chromo23 » 26 Jul 2022, 10:47

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

Post Reply

Who is online

Users browsing this forum: No registered users and 21 guests