Commit cd4d03d 1 parent 4859b75 commit cd4d03d Copy full SHA for cd4d03d
File tree 3 files changed +22
-1
lines changed
3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ AE = AnalogEvent(
92
92
A "convenience" implementation of ` AnalogEvent ` that emits ` Key ` objects.
93
93
94
94
``` python
95
- from analogio import AnalogKey
95
+ from kmk.modules.analogin.keys import AnalogKey
96
96
97
97
AK = AnalogKey(
98
98
key: Key,
@@ -108,6 +108,7 @@ AK = AnalogKey(
108
108
import board
109
109
from analogio import AnalogIn
110
110
from kmk.modules.analogin import AnalogInput, AnalogInputs
111
+ from kmk.modules.analogin.keys import AnalogKey
111
112
112
113
analog = AnalogInputs(
113
114
[
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ from . import AnalogEvent
2
+
3
+
4
+ class AnalogKey (AnalogEvent ):
5
+ def __init__ (self , key , threshold = 127 ):
6
+ self .key = key
7
+ self .threshold = threshold
8
+ self .pressed = False
9
+
10
+ def on_change (self , event , keyboard ):
11
+ if event .value >= self .threshold and not self .pressed :
12
+ self .pressed = True
13
+ keyboard .pre_process_key (self .key , True )
14
+
15
+ elif event .value < self .threshold and self .pressed :
16
+ self .pressed = False
17
+ keyboard .pre_process_key (self .key , False )
18
+
19
+ def on_stop (self , event , keyboard ):
20
+ pass
You can’t perform that action at this time.
0 commit comments