From 363b54d4f19b6ec2e6faf2f4a2829991bc20bf20 Mon Sep 17 00:00:00 2001 From: Liam Howell Date: Thu, 4 Aug 2022 18:25:09 +1000 Subject: [PATCH] Update PiicoDev_LIS3DH.py Added tapped_axis function --- PiicoDev_LIS3DH.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/PiicoDev_LIS3DH.py b/PiicoDev_LIS3DH.py index 14f4b9b..02bd2b5 100644 --- a/PiicoDev_LIS3DH.py +++ b/PiicoDev_LIS3DH.py @@ -199,6 +199,22 @@ def tapped(self): self._read(_INT1_SRC,1) # clear interrupt pin return True return False + + @property + def tapped_axis(self): + raw = self._read(_CLICKSRC,1) + axis_tapped =[False,False,False] + if raw & 0x40: + print(raw-64) + if raw & 0x04: # If respective bit is filled, flag the axes that was activated + axis_tapped[2] = True + if raw & 0x02: + axis_tapped[1] = True + if raw & 0x01: + axis_tapped[0] = True + self._read(_INT1_SRC,1) + return axis_tapped + def shake(self, threshold=15, avg_count=40, total_delay=100): """Detect when the accelerometer is shaken. Optional parameters: