Browse Source

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.
peter
Peter Cai 2 months ago
parent
commit
949917e3cd
  1. 8
      wasp/drivers/bma421.py

8
wasp/drivers/bma421.py

@ -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"""

Loading…
Cancel
Save