Rotary Trinkey

Adafruit's tiny microcontroller platform. Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Fishe
 
Posts: 40
Joined: Mon Apr 25, 2016 8:50 pm

Rotary Trinkey

Post by Fishe »

I purchased 5 Rotary Trinkeys in the hope of ganging them up to control volume by Windows application. I do not know if this is possible and my coding skills are minimal. I there a way to modify the Arduino code for the volume control to control by application instead of windows wide control?

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Rotary Trinkey

Post by mikeysklar »

@Fishe,

You could use in-app volume control keycodes, but you will be to be selected on the app.

We do have a CircuitPython example of controlling YouTube position, but you have to be selected on youtube and the rotary encoder will send ',' or '.' to scroll through the video.

Code: Select all

"""Rotary Trinkey YouTube Frame-by-Frame Example"""
import time
import rotaryio
import board
import digitalio
import usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS

print("Rotary Trinkey YouTube Frame-by-Frame example")

encoder = rotaryio.IncrementalEncoder(board.ROTA, board.ROTB)
switch = digitalio.DigitalInOut(board.SWITCH)
switch.switch_to_input(pull=digitalio.Pull.DOWN)

time.sleep(1)  # Sleep for a bit to avoid a race condition on some systems
keyboard = Keyboard(usb_hid.devices)
keyboard_layout = KeyboardLayoutUS(keyboard)  # We're in the US :)

switch_state = None
last_position = encoder.position

while True:
    current_position = encoder.position
    position_change = current_position - last_position
    if position_change > 0:
        for _ in range(position_change):
            keyboard_layout.write('.')
        print(current_position)
    elif position_change < 0:
        for _ in range(-position_change):
            keyboard_layout.write(',')
        print(current_position)
    last_position = current_position
    if not switch.value and switch_state is None:
        switch_state = "pressed"
    if switch.value and switch_state == "pressed":
        print("switch pressed.")
        keyboard_layout.write(' ')
        switch_state = None

User avatar
Fishe
 
Posts: 40
Joined: Mon Apr 25, 2016 8:50 pm

Re: Rotary Trinkey

Post by Fishe »

Let me clarify, I am looking to control volume in app individually, like chrome, discord, iRacing and Master while in a game. There is this https://github.com/omriharel/deej which I am trying

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Rotary Trinkey

Post by mikeysklar »

The deej repo you found look exactly like the individual app control you desire. Were you able to install it and get it running with the rotary trinkey?

User avatar
Fishe
 
Posts: 40
Joined: Mon Apr 25, 2016 8:50 pm

Re: Rotary Trinkey

Post by Fishe »

I am not that smart, was hoping rather was a variation of the three command “Media_volume” whereas you could call the application. I am going to build the Deej first then move over to the trinkey

User avatar
Christopher37
 
Posts: 4
Joined: Sat Dec 02, 2017 11:13 pm

Re: Rotary Trinkey

Post by Christopher37 »

Since the Deej program that runs on your computer seems to just be looking for a string of "|" pipe separated values, anything that can create a serial connection and send a string of values should be able to the control the Deej program.

You could use the rotary encoder to move a number between 0 and 1023 for sending to the Deej program; but it looks like with the Rotary Trinkey you would need to have 5 USB ports to plug them into and an even bigger problem is it looks like the Deej program expects a single string of values from only a single COM port.

You would be better served with something like an Adafruit QT Py board ( https://www.adafruit.com/product/4600 ) and 5 STEMMA QT Adafruit I2C QT Rotary Encoders ( https://www.adafruit.com/product/4991 ). You would then still need to write the code to use the rotary encoders to modify values and send the string over the serial port.

User avatar
Fishe
 
Posts: 40
Joined: Mon Apr 25, 2016 8:50 pm

Re: Rotary Trinkey

Post by Fishe »

Thank you, I didn’t see this till just now. That is pretty much what I have found and like the Stemma route the best

User avatar
Fishe
 
Posts: 40
Joined: Mon Apr 25, 2016 8:50 pm

Re: Rotary Trinkey

Post by Fishe »

Can I store the Deej Client on a board and have it install to a computer

User avatar
Fishe
 
Posts: 40
Joined: Mon Apr 25, 2016 8:50 pm

Re: Rotary Trinkey

Post by Fishe »

I went with the QT PY and 5 breakout boards for the rotary encoder. I am seeing a problem noted in the forum regarding the turning of the know decreases the value instead of increasing. Also, it posts that the button was pressed.

At this point I am using the base arduino example.

User avatar
Fishe
 
Posts: 40
Joined: Mon Apr 25, 2016 8:50 pm

Re: Rotary Trinkey

Post by Fishe »

Fixed the negative

Serial.println(-new_position); // display new position (-)

Locked
Please be positive and constructive with your questions and comments.

Return to “Trinket ATTiny, Trinket M0”