boards/anavi/knobs3: Simplify the source code
Optimize and simplify the source code by using the full potential of class EncoderHandler. Signed-off-by: Leon Anavi <leon.anavi@konsulko.com>
This commit is contained in:
parent
ce0e29b02f
commit
b676afe075
@ -1,25 +0,0 @@
|
||||
'''
|
||||
KMK keyboard for ANAVI Knobs 3
|
||||
'''
|
||||
|
||||
import board
|
||||
|
||||
from kmk.kmk_keyboard import KMKKeyboard
|
||||
from kmk.scanners.keypad import KeysScanner
|
||||
|
||||
# fmt: off
|
||||
_KEY_CFG = [
|
||||
board.D0,
|
||||
board.D3,
|
||||
board.D6
|
||||
]
|
||||
# fmt: on
|
||||
|
||||
|
||||
class AnaviKnob(KMKKeyboard):
|
||||
'''
|
||||
Default keyboard config for the Keybow2040.
|
||||
'''
|
||||
|
||||
def __init__(self):
|
||||
self.matrix = KeysScanner(_KEY_CFG)
|
@ -1,24 +1,32 @@
|
||||
import board
|
||||
|
||||
from anaviknob import AnaviKnob
|
||||
|
||||
from kmk.extensions.media_keys import MediaKeys
|
||||
from kmk.extensions.RGB import RGB, AnimationModes
|
||||
from kmk.keys import KC
|
||||
from kmk.kmk_keyboard import KMKKeyboard
|
||||
from kmk.modules.encoder import EncoderHandler
|
||||
from kmk.scanners.keypad import KeysScanner
|
||||
|
||||
knob = KMKKeyboard()
|
||||
knob.matrix = KeysScanner([])
|
||||
|
||||
media_keys = MediaKeys()
|
||||
knob.extensions.append(media_keys)
|
||||
|
||||
# Rotary encoders that also acts as keys
|
||||
encoder_handler = EncoderHandler()
|
||||
encoder_handler.pins = (
|
||||
(board.D1, board.D2, None, False),
|
||||
(board.D9, board.D10, None, False),
|
||||
(board.D7, board.D8, None, False),
|
||||
(board.D1, board.D2, board.D0),
|
||||
(board.D9, board.D10, board.D3),
|
||||
(board.D7, board.D8, board.D6),
|
||||
)
|
||||
encoder_handler.map = (
|
||||
((KC.VOLD, KC.VOLU), (KC.UP, KC.DOWN), (KC.RIGHT, KC.LEFT)), # base layer
|
||||
((KC.VOLD, KC.VOLU, KC.MUTE), (KC.UP, KC.DOWN, KC.A), (KC.RIGHT, KC.LEFT, KC.B)),
|
||||
)
|
||||
|
||||
knob = AnaviKnob()
|
||||
knob.modules.append(encoder_handler)
|
||||
|
||||
print('ANAVI Knobs 3')
|
||||
|
||||
rgb_ext = RGB(
|
||||
pixel_pin=board.NEOPIXEL,
|
||||
num_pixels=1,
|
||||
@ -28,7 +36,7 @@ rgb_ext = RGB(
|
||||
)
|
||||
knob.extensions.append(rgb_ext)
|
||||
|
||||
knob.keymap = [[KC.MUTE, KC.A, KC.B]]
|
||||
knob.keymap = [[KC.MUTE]]
|
||||
|
||||
if __name__ == '__main__':
|
||||
knob.go()
|
||||
|
Loading…
Reference in New Issue
Block a user