1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-23 14:58:09 +00:00

ui.swipe: make constants private

Private const() can be inlined properly.
This commit is contained in:
Jan Pochyla 2016-10-20 15:08:28 +02:00
parent 4e290cc6df
commit 74b2170e3f

View File

@ -4,9 +4,9 @@ from trezor import loop
from . import in_area, rotate_coords from . import in_area, rotate_coords
SWIPE_DISTANCE_THRESHOLD = const(20) # Min pixels in the primary direction _SWIPE_DISTANCE_THRESHOLD = const(20) # Min pixels in the primary direction
SWIPE_VELOCITY_THRESHOLD = const(200) # Min pixels/second _SWIPE_VELOCITY_THRESHOLD = const(200) # Min pixels per second
SWIPE_RATIO_THRESHOLD = const(30) # Max ratio or directions in % _SWIPE_RATIO_THRESHOLD = const(30) # Max ratio or directions in %
SWIPE_UP = const(180) SWIPE_UP = const(180)
SWIPE_DOWN = const(0) SWIPE_DOWN = const(0)
@ -46,17 +46,17 @@ class Swipe():
# Horizontal direction # Horizontal direction
velxa = abs(pdx / td) velxa = abs(pdx / td)
ratio = int(pdya / pdxa * 100) if pdxa > 0 else 100 ratio = int(pdya / pdxa * 100) if pdxa > 0 else 100
if (velxa >= SWIPE_VELOCITY_THRESHOLD if (velxa >= _SWIPE_VELOCITY_THRESHOLD
and pdxa >= SWIPE_DISTANCE_THRESHOLD and pdxa >= _SWIPE_DISTANCE_THRESHOLD
and ratio <= SWIPE_RATIO_THRESHOLD): and ratio <= _SWIPE_RATIO_THRESHOLD):
return SWIPE_RIGHT if pdx > 0 else SWIPE_LEFT return SWIPE_RIGHT if pdx > 0 else SWIPE_LEFT
else: else:
# Vertical direction # Vertical direction
velya = abs(pdy / td) velya = abs(pdy / td)
ratio = int(pdxa / pdya * 100) if pdya > 0 else 100 ratio = int(pdxa / pdya * 100) if pdya > 0 else 100
if (velya >= SWIPE_VELOCITY_THRESHOLD if (velya >= _SWIPE_VELOCITY_THRESHOLD
and pdya >= SWIPE_DISTANCE_THRESHOLD and pdya >= _SWIPE_DISTANCE_THRESHOLD
and ratio <= SWIPE_RATIO_THRESHOLD): and ratio <= _SWIPE_RATIO_THRESHOLD):
return SWIPE_DOWN if pdy > 0 else SWIPE_UP return SWIPE_DOWN if pdy > 0 else SWIPE_UP
# No swipe, reset the state # No swipe, reset the state
self.start_pos = None self.start_pos = None