Skip to content

Commit e9d9a1e

Browse files
committed
define register numbers in spinner examples so we don't have to unprotect them in the library
1 parent de6f3ab commit e9d9a1e

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

examples/spinner.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,11 @@ def get_position(self, delta):
7070
# call internal methods that change a few register values. This must be done
7171
# AFTER calling set_tap above because the set_tap function also changes
7272
# REG_CTRL5.
73+
# Define register numbers, which are not exported from the library.
74+
_REG_CTRL5 = const(0x24)
75+
_REG_CLICKSRC = const(0x39)
7376
# pylint: disable=protected-access
74-
lis3dh._write_register_byte(adafruit_lis3dh.REG_CTRL5, 0b01001000)
77+
lis3dh._write_register_byte(_REG_CTRL5, 0b01001000)
7578
lis3dh._write_register_byte(0x2E, 0b10000000) # Set FIFO_CTRL to Stream mode.
7679
# pylint: disable=protected-access
7780

@@ -85,7 +88,7 @@ def get_position(self, delta):
8588
while True:
8689
# Read the raw click detection register value and check if there was
8790
# a click detected.
88-
clicksrc = lis3dh._read_register_byte(adafruit_lis3dh.REG_CLICKSRC) # pylint: disable=protected-access
91+
clicksrc = lis3dh._read_register_byte(_REG_CLICKSRC) # pylint: disable=protected-access
8992
if clicksrc & 0b01000000 > 0:
9093
# Click was detected! Quickly read 32 values from the accelerometer
9194
# FIFO and look for the maximum magnitude values.

examples/spinner_advanced.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,11 @@ def update(self, position, primary, secondary):
191191
# readings in a FIFO buffer so they can be read later to see a history of
192192
# recent acceleration. This is handy to look for the maximum/minimum impulse
193193
# after a click is detected.
194+
# Define register numbers, which are not exported from the library.
195+
_REG_CTRL5 = const(0x24)
196+
_REG_CLICKSRC = const(0x39)
194197
# pylint: disable=protected-access
195-
lis3dh._write_register_byte(adafruit_lis3dh.REG_CTRL5, 0b01001000)
198+
lis3dh._write_register_byte(_REG_CTRL5, 0b01001000)
196199
lis3dh._write_register_byte(0x2E, 0b10000000) # Set FIFO_CTRL to Stream mode.
197200
# pylint: disable=protected-access
198201

@@ -219,7 +222,7 @@ def update(self, position, primary, secondary):
219222
# Read the raw click detection register value and check if there was
220223
# a click detected. Remember only the X axis causes clicks because of
221224
# the register configuration set previously.
222-
clicksrc = lis3dh._read_register_byte(adafruit_lis3dh.REG_CLICKSRC) # pylint: disable=protected-access
225+
clicksrc = lis3dh._read_register_byte(_REG_CLICKSRC) # pylint: disable=protected-access
223226
if clicksrc & 0b01000000 > 0:
224227
# Click was detected! Quickly read 32 values from the accelerometer
225228
# and look for the maximum magnitude values. Because the

0 commit comments

Comments
 (0)