boards/anavi/knob1: 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
6d132ba4b4
commit
a6825b6a3c
@ -1,23 +0,0 @@
|
||||
'''
|
||||
KMK keyboard for ANAVI Knob 1
|
||||
'''
|
||||
|
||||
import board
|
||||
|
||||
from kmk.kmk_keyboard import KMKKeyboard
|
||||
from kmk.scanners.keypad import KeysScanner
|
||||
|
||||
# fmt: off
|
||||
_KEY_CFG = [
|
||||
board.D0
|
||||
]
|
||||
# fmt: on
|
||||
|
||||
|
||||
class AnaviKnob(KMKKeyboard):
|
||||
'''
|
||||
Default keyboard config for the ANAVI Knob 1
|
||||
'''
|
||||
|
||||
def __init__(self):
|
||||
self.matrix = KeysScanner(_KEY_CFG)
|
@ -1,18 +1,26 @@
|
||||
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 encoder that also acts as a key
|
||||
encoder_handler = EncoderHandler()
|
||||
encoder_handler.pins = ((board.D1, board.D2, None, False),)
|
||||
encoder_handler.map = (((KC.VOLD, KC.VOLU),),) # base layer
|
||||
|
||||
knob = AnaviKnob()
|
||||
encoder_handler.pins = ((board.D1, board.D2, board.D0),)
|
||||
encoder_handler.map = (((KC.VOLD, KC.VOLU, KC.MUTE),),)
|
||||
knob.modules.append(encoder_handler)
|
||||
|
||||
print('ANAVI Knob 1')
|
||||
|
||||
rgb_ext = RGB(
|
||||
pixel_pin=board.NEOPIXEL,
|
||||
num_pixels=1,
|
||||
|
Loading…
Reference in New Issue
Block a user