KMKfw / kmk_firmware

Clackety Keyboards Powered by Python
https://kmkfw.zulipchat.com
Other
1.32k stars 458 forks source link

[BUG] KC.MO on RP2040-Plus either crashes or doesn't work #906

Closed nealie closed 6 months ago

nealie commented 8 months ago

Calling KC.MO(1) on an RP2040-Plus (Waveshare Pi Pico clone) crashes if the documented example is used.

When placed before keyboard.modules.append(Layers()) the code does not crash, but also does not perform the layer shift. When placed afterwards, circuitpython enters safe mode.

My code is as follows:

import board
from kmk.kmk_keyboard import KMKKeyboard
from kmk.keys import KC
from kmk.scanners import DiodeOrientation
from kmk.modules.layers import Layers

keyboard = KMKKeyboard()

keyboard.col_pins = (
    board.GP0,  board.GP1,  board.GP2,  board.GP3,  board.GP4,  board.GP5,
    board.GP22, board.GP21, board.GP20, board.GP19, board.GP18, board.GP17
)
keyboard.row_pins = (board.GP6, board.GP7, board.GP8, board.GP9, board.GP10)
keyboard.diode_orientation = DiodeOrientation.COL2ROW

SYMBOL = KC.MO(1)   # <--- Does not crash here, but also doesn't do anything.

keyboard.modules.append(Layers())

#SYMBOL = KC.MO(1)  # <--- Crashes here and enters safe mode.

keyboard.keymap = [
    [ # Layer 0
        KC.ESCAPE, KC.N1,   KC.N2,   KC.N3,   KC.N4,   KC.N5,    KC.N6,    KC.N7,    KC.N8,     KC.N9,   KC.N0,     KC.BSPACE,
        KC.TAB,    KC.Q,    KC.W,    KC.E,    KC.R,    KC.T,     KC.Y,     KC.U,     KC.I,      KC.O,    KC.P,      KC.DELETE,
        KC.LSHIFT, KC.A,    KC.S,    KC.D,    KC.F,    KC.G,     KC.H,     KC.J,     KC.K,      KC.L,    KC.SCOLON, KC.QUOTE,
        SYMBOL,    KC.Z,    KC.X,    KC.C,    KC.V,    KC.B,     KC.N,     KC.M,     KC.COMMA,  KC.DOT,  KC.UP,     KC.ENTER,
        KC.LCTRL,  KC.LGUI, KC.LALT, KC.NO,   KC.NO,   KC.SPACE, KC.SPACE, KC.SLASH, KC.BSLASH, KC.LEFT, KC.DOWN,   KC.RIGHT
    ],
    [ # Layer 1
        KC.TRNS,   KC.EXLM, KC.AT,   KC.HASH, KC.DLR,  KC.PERC,  KC.CIRC,  KC.AMPR,  KC.ASTR,   KC.LPRN, KC.RPRN,   KC.TRNS,
        KC.TRNS,   KC.GRV,  KC.TILD, KC.MINS, KC.UNDS, KC.EQUAL, KC.PLUS,  KC.LCBR,  KC.RCBR,   KC.LBRC, KC.RBRC,   KC.INSERT,
        KC.NO,     KC.F1,   KC.F2,   KC.F3,   KC.F4,   KC.F5,    KC.F6,    KC.NO,    KC.NO,     KC.NO,   KC.COLON,  KC.DQUO,
        KC.NO,     KC.F7,   KC.F8,   KC.F9,   KC.F10,  KC.F11,   KC.F12,   KC.NO,    KC.LABK,   KC.RABK, KC.PGUP,   KC.TRNS,
        KC.RCTRL,  KC.RGUI, KC.RALT, KC.NO,   KC.NO,   KC.TRNS,  KC.TRNS,  KC.QUES,  KC.PIPE,   KC.HOME, KC.PGDOWN, KC.END
    ]
]

if __name__ == '__main__':
    keyboard.go()

This issue seems to be the same as this issue on the zulipchat forum: Crash of rp2040 when I add "FN = KC.MO(1)" line to code.py

xs5871 commented 8 months ago

That is most likely a bug in the Circuitpython build you're using. Certainly not KMK.

claycooper commented 6 months ago

Per update in Zulip: Unable to reproduce.

EduardoOliveira commented 3 months ago

I'm having the same behavior... @nealie did you manage to solve this?

EduardoOliveira commented 3 months ago

Just to have it documented somewhere, flashing CircuitPython 8.2.0 solves the issue.