KMKfw / kmk_firmware

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

[BUG] kmk AttributeError: 'PeriodicTaskMeta' object has no attribute 'restart' #805

Closed blazingh closed 1 year ago

blazingh commented 1 year ago

Describe the bug i was adding the mouse_keys module to my controller rp2040 and had this issue when calling any of the MS_UP MS_DN adn the others

To Reproduce follow the documentation on the oficcial website to add mouse movement call any of the MS_UP MS_DN and other

Expected behavior the mouse to movew

Debug output kmk AttributeError: 'PeriodicTaskMeta' object has no attribute 'restart'

Additional context

print("Starting")

import board

from kmk.kmk_keyboard import KMKKeyboard
from kmk.keys import KC
from kmk.scanners import DiodeOrientation
from kmk.modules.mouse_keys import MouseKeys

keyboard = KMKKeyboard()

keyboard.col_pins = (board.GP2,board.GP3,board.GP4,board.GP5,)
keyboard.row_pins = (board.GP6,board.GP7,board.GP8)
keyboard.diode_orientation = DiodeOrientation.COL2ROW
keyboard.modules.append(MouseKeys())

keyboard.keymap = [
    [KC.MB_LMB,KC.MS_UP,KC.MB_RMB,KC.D,
     KC.MS_LEFT,KC.MS_DN,KC.MS_RIGHT,KC.H,
     KC.I,KC.J,KC.K,KC.L]
]

if __name__ == '__main__':
    keyboard.go()
blazingh commented 1 year ago

i was able to solve this by adding a restart function the PeriodicTaskMeta class in the scheduler file fixed my isue

    def restart(self) -> None:
        _task_queue.remove(self._task)
        _task_queue.push_sorted(self._task, ticks_add(ticks_ms(), self.period))

requested a pull, but not sure if it will effect other function #804