Convert to supervisor ticks
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import digitalio
|
||||
from supervisor import ticks_ms
|
||||
|
||||
from kmk.kmktime import ticks_ms
|
||||
from kmk.modules import Module
|
||||
|
||||
|
||||
|
@@ -1,9 +1,10 @@
|
||||
'''One layer isn't enough. Adds keys to get to more of them'''
|
||||
from micropython import const
|
||||
from supervisor import ticks_ms
|
||||
|
||||
from kmk.key_validators import layer_key_validator
|
||||
from kmk.keys import make_argumented_key
|
||||
from kmk.kmktime import accurate_ticks, accurate_ticks_diff
|
||||
from kmk.kmktime import check_deadline
|
||||
from kmk.modules import Module
|
||||
|
||||
|
||||
@@ -131,15 +132,13 @@ class Layers(Module):
|
||||
|
||||
def _lt_pressed(self, key, keyboard, *args, **kwargs):
|
||||
# Sets the timer start and acts like MO otherwise
|
||||
self.start_time[LayerType.LT] = accurate_ticks()
|
||||
self.start_time[LayerType.LT] = ticks_ms()
|
||||
self._mo_pressed(key, keyboard, *args, **kwargs)
|
||||
|
||||
def _lt_released(self, key, keyboard, *args, **kwargs):
|
||||
# On keyup, check timer, and press key if needed.
|
||||
if self.start_time[LayerType.LT] and (
|
||||
accurate_ticks_diff(
|
||||
accurate_ticks(), self.start_time[LayerType.LT], keyboard.tap_time
|
||||
)
|
||||
check_deadline(ticks_ms(), self.start_time[LayerType.LT], keyboard.tap_time)
|
||||
):
|
||||
keyboard.hid_pending = True
|
||||
keyboard.tap_key(key.meta.kc)
|
||||
@@ -171,10 +170,10 @@ class Layers(Module):
|
||||
'''
|
||||
if self.start_time[LayerType.TT] is None:
|
||||
# Sets the timer start and acts like MO otherwise
|
||||
self.start_time[LayerType.TT] = accurate_ticks()
|
||||
self.start_time[LayerType.TT] = ticks_ms()
|
||||
self._mo_pressed(key, keyboard, *args, **kwargs)
|
||||
elif accurate_ticks_diff(
|
||||
accurate_ticks(), self.start_time[LayerType.TT], keyboard.tap_time
|
||||
elif check_deadline(
|
||||
ticks_ms(), self.start_time[LayerType.TT], keyboard.tap_time
|
||||
):
|
||||
self.start_time[LayerType.TT] = None
|
||||
self._tg_pressed(key, keyboard, *args, **kwargs)
|
||||
@@ -182,8 +181,8 @@ class Layers(Module):
|
||||
return
|
||||
|
||||
def _tt_released(self, key, keyboard, *args, **kwargs):
|
||||
if self.start_time[LayerType.TT] is None or not accurate_ticks_diff(
|
||||
accurate_ticks(), self.start_time[LayerType.TT], keyboard.tap_time
|
||||
if self.start_time[LayerType.TT] is None or not check_deadline(
|
||||
ticks_ms(), self.start_time[LayerType.TT], keyboard.tap_time
|
||||
):
|
||||
# On first press, works like MO. On second press, does nothing unless let up within
|
||||
# time window, then acts like TG.
|
||||
|
@@ -1,6 +1,8 @@
|
||||
from supervisor import ticks_ms
|
||||
|
||||
from kmk.key_validators import mod_tap_validator
|
||||
from kmk.keys import make_argumented_key
|
||||
from kmk.kmktime import accurate_ticks, accurate_ticks_diff
|
||||
from kmk.kmktime import check_deadline
|
||||
from kmk.modules import Module
|
||||
|
||||
|
||||
@@ -39,16 +41,14 @@ class ModTap(Module):
|
||||
'''Sets the timer start and acts like a modifier otherwise'''
|
||||
keyboard.keys_pressed.add(key.meta.mods)
|
||||
|
||||
self._mod_tap_timer = accurate_ticks()
|
||||
self._mod_tap_timer = ticks_ms()
|
||||
return keyboard
|
||||
|
||||
def mt_released(self, key, keyboard, *args, **kwargs):
|
||||
'''On keyup, check timer, and press key if needed.'''
|
||||
keyboard.keys_pressed.discard(key.meta.mods)
|
||||
if self._mod_tap_timer and (
|
||||
accurate_ticks_diff(
|
||||
accurate_ticks(), self._mod_tap_timer, keyboard.tap_time
|
||||
)
|
||||
check_deadline(ticks_ms(), self._mod_tap_timer, keyboard.tap_time)
|
||||
):
|
||||
keyboard.hid_pending = True
|
||||
keyboard.tap_key(key.meta.kc)
|
||||
|
@@ -1,9 +1,12 @@
|
||||
import board
|
||||
import digitalio
|
||||
from supervisor import ticks_ms
|
||||
|
||||
from time import sleep
|
||||
|
||||
from kmk.handlers.stock import passthrough as handler_passthrough
|
||||
from kmk.keys import make_key
|
||||
from kmk.kmktime import sleep_ms, ticks_diff, ticks_ms
|
||||
from kmk.kmktime import check_deadline
|
||||
from kmk.modules import Module
|
||||
|
||||
|
||||
@@ -100,10 +103,10 @@ class Power(Module):
|
||||
'''
|
||||
Sleeps longer and longer to save power the more time in between updates.
|
||||
'''
|
||||
if ticks_diff(ticks_ms(), self._powersave_start) <= 60000:
|
||||
sleep_ms(8)
|
||||
elif ticks_diff(ticks_ms(), self._powersave_start) >= 240000:
|
||||
sleep_ms(180)
|
||||
if check_deadline(ticks_ms(), self._powersave_start) <= 60000:
|
||||
sleep(8 / 1000)
|
||||
elif check_deadline(ticks_ms(), self._powersave_start) >= 240000:
|
||||
sleep(180 / 1000)
|
||||
return
|
||||
|
||||
def psave_time_reset(self):
|
||||
@@ -120,7 +123,7 @@ class Power(Module):
|
||||
return
|
||||
|
||||
def usb_rescan_timer(self):
|
||||
return bool(ticks_diff(ticks_ms(), self._usb_last_scan) > 5000)
|
||||
return bool(check_deadline(ticks_ms(), self._usb_last_scan) > 5000)
|
||||
|
||||
def usb_time_reset(self):
|
||||
self._usb_last_scan = ticks_ms()
|
||||
|
@@ -1,10 +1,11 @@
|
||||
'''Enables splitting keyboards wirelessly or wired'''
|
||||
import busio
|
||||
from micropython import const
|
||||
from supervisor import ticks_ms
|
||||
|
||||
from storage import getmount
|
||||
|
||||
from kmk.kmktime import ticks_diff, ticks_ms
|
||||
from kmk.kmktime import check_deadline
|
||||
from kmk.matrix import intify_coordinate
|
||||
from kmk.modules import Module
|
||||
|
||||
@@ -241,7 +242,7 @@ class Split(Module):
|
||||
|
||||
def ble_rescan_timer(self):
|
||||
'''If true, the rescan timer is up'''
|
||||
return bool(ticks_diff(ticks_ms(), self._ble_last_scan) > 5000)
|
||||
return bool(check_deadline(ticks_ms(), self._ble_last_scan) > 5000)
|
||||
|
||||
def ble_time_reset(self):
|
||||
'''Resets the rescan timer'''
|
||||
|
Reference in New Issue
Block a user