bma421: Use the INT_STATUS register to distinguish between gestures

Currently we have only one type of hardware-based gesture implemented,
but in the future there could be more.
This commit is contained in:
Peter Cai 2022-06-19 14:16:05 -04:00
parent 9848f0afd7
commit 949917e3cd

View file

@ -25,6 +25,9 @@ _DEFAULT_ORIENTATION = const(0b010010000)
# Y sign ────────────────────┘│
# Z sign ─────────────────────┘
# Ref: BMA425 data sheet (register INT_STATUS_0)
_STATUS_MASK_WRIST_TILT = const(0b1000)
class BMA421:
"""BMA421 driver
@ -82,8 +85,9 @@ class BMA421:
def handle_interrupt(self, pin_obj):
"""Interrupt handler for gesture events originating from the sensor"""
self._dev.read_int_status() # TODO: Actually read status from the register
self._gesture_event = motion.AccelGestureEvent.WRIST_TILT
status = self._dev.read_int_status()
if status & _STATUS_MASK_WRIST_TILT:
self._gesture_event = motion.AccelGestureEvent.WRIST_TILT
def get_gesture_event(self):
"""Receive the latest gesture event if any"""