|
|
|
@ -23,12 +23,12 @@ def apply_hysteresis(val: float, val_steady: float, hyst_gap: float) -> float: |
|
|
|
|
|
|
|
|
|
def create_button_events(cur_button: int, prev_button: int, buttons_dict: Dict[int, capnp.lib.capnp._EnumModule], |
|
|
|
|
unpressed: int = 0, init: Optional[int] = None) -> List[capnp.lib.capnp._DynamicStructBuilder]: |
|
|
|
|
events = [] |
|
|
|
|
# initializing, don't add any events |
|
|
|
|
# TODO: if it's possible to go from init to NOT unpressed, we want to check that as well |
|
|
|
|
if (init is not None and prev_button == init) or cur_button == prev_button: |
|
|
|
|
events = [] |
|
|
|
|
if init is not None and prev_button == init and cur_button == unpressed: |
|
|
|
|
return events |
|
|
|
|
|
|
|
|
|
# Handle transitions between buttons without going to the unpressed value |
|
|
|
|
if cur_button != prev_button: |
|
|
|
|
for pressed, btn in ((False, prev_button), (True, cur_button)): |
|
|
|
|
if btn == unpressed: |
|
|
|
|