File tree Expand file tree Collapse file tree 4 files changed +55
-4
lines changed
adafruit_radial_controller
examples/radial_controller_rotary_trinkey Expand file tree Collapse file tree 4 files changed +55
-4
lines changed Original file line number Diff line number Diff line change 18
18
At the minimum, a radial controller is a rotary encoder plus a switch.
19
19
20
20
Documentation is available from Microsoft:
21
+ https://docs.microsoft.com/en-us/windows-hardware/design/component-guidelines/radial-implementation-guide
21
22
22
23
**Software and Dependencies:**
23
24
@@ -77,8 +78,10 @@ def click(self):
77
78
78
79
def rotate (self , degree_tenths ):
79
80
"""Set relative rotation value, in tenths of a degree.
80
- A value of 1 or 10 can be too small and cause tool selection or scrolling to not work.
81
- 100 is a good value for a single increment in most cases."""
81
+ A value of +/- 1 or 10 can be too small and cause tool selection or scrolling to not work.
82
+ +/- 100 is a good value for a single increment in many cases, though it causes value sliders
83
+ to change by 10 instead of 1.
84
+ """
82
85
83
86
if not - 3600 <= degree_tenths <= 3600 :
84
87
raise ValueError ("rotation must be in range -3600 to 3600" )
Original file line number Diff line number Diff line change @@ -69,8 +69,9 @@ def device(report_id):
69
69
0xc0 , # End Collection
70
70
0xc0 , # End Collection
71
71
72
- # The presence of this (even empty) System Control Collection makes the device
73
- # appears in /dev/input in Linux. Don't know why this works yet.
72
+ # The presence of this (empty) System Control Collection makes the device
73
+ # appear in /dev/input in Linux, which will help if radial controller
74
+ # functionality is added in userspace code.
74
75
0x09 , 0x80 , # Usage (System Control)
75
76
0xa1 , 0x01 , # Collection (Application)
76
77
0xc0 , # End Collection
Original file line number Diff line number Diff line change
1
+ # SPDX-FileCopyrightText: Copyright (c) 2021 Dan Halbert for Adafruit Industries
2
+ #
3
+ # SPDX-License-Identifier: Unlicense
4
+
5
+ import usb_hid
6
+
7
+ import adafruit_radial_controller .device
8
+
9
+ REPORT_ID = 5
10
+
11
+ radial_controller_device = adafruit_radial_controller .device .device (REPORT_ID )
12
+ usb_hid .enable ((radial_controller_device ,))
Original file line number Diff line number Diff line change
1
+ # SPDX-FileCopyrightText: Copyright (c) 2021 Dan Halbert for Adafruit Industries
2
+ #
3
+ # SPDX-License-Identifier: Unlicense
4
+
5
+ import board
6
+ import digitalio
7
+ import rotaryio
8
+ import usb_hid
9
+
10
+ from adafruit_debouncer import Debouncer
11
+ import adafruit_radial_controller
12
+
13
+ switch = digitalio .DigitalInOut (board .SWITCH )
14
+ switch .pull = digitalio .Pull .DOWN
15
+ debounced_switch = Debouncer (switch )
16
+
17
+ encoder = rotaryio .IncrementalEncoder (board .ROTA , board .ROTB )
18
+
19
+ radial_controller = adafruit_radial_controller .RadialController (usb_hid .devices )
20
+
21
+ last_position = 0
22
+ DEGREE_TENTHS_MULTIPLIER = 100
23
+
24
+ while True :
25
+ debounced_switch .update ()
26
+ if debounced_switch .rose :
27
+ radial_controller .press ()
28
+ if debounced_switch .fell :
29
+ radial_controller .release ()
30
+
31
+ position = encoder .position
32
+ delta = position - last_position
33
+ if delta != 0 :
34
+ radial_controller .rotate (delta * DEGREE_TENTHS_MULTIPLIER )
35
+ last_position = position
You can’t perform that action at this time.
0 commit comments