Skip to content

Commit 513e7dc

Browse files
committed
removed clear properties
1 parent 84e23d4 commit 513e7dc

File tree

2 files changed

+5
-25
lines changed

2 files changed

+5
-25
lines changed

examples/example6_difference.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@
4343

4444
print('Type Ctrl-C to exit program.')
4545

46-
# Uncomment line below to *not* clear difference value after reading
47-
# twist.clear_difference_after_read = False
48-
4946
try:
5047
while True:
5148
print('Count: ' + str(twist.count))

sparkfun_qwiictwist.py

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@
5959
QWIIC_TWIST_ADDR = const(0x3F) # default I2C Address
6060
QWIIC_TWIST_ID = const(0x5c) # value returned by id register
6161

62-
63-
6462
# private constants
6563

6664
# bit constants
@@ -108,8 +106,6 @@ def __init__(self, i2c, address=QWIIC_TWIST_ADDR, debug=False):
108106
#save handle to i2c bus in case address is changed
109107
self._i2c = i2c
110108
self._debug = debug
111-
# set up clear property after read defaults
112-
self._clear_difference_after_read = True
113109

114110
# public properites (read-only)
115111

@@ -171,12 +167,14 @@ def clicked(self):
171167

172168
@property
173169
def difference(self):
174-
""""Return the difference in number of clicks since previous check."""
170+
"""
171+
Return the difference in number of clicks since previous check.
172+
The value is cleared after it is read.
173+
"""
175174
value = self._read_register16(_TWIST_DIFFERENCE)
176175
diff = _signed_int16(value)
177176

178-
if self._clear_difference_after_read:
179-
self._write_register16(_TWIST_DIFFERENCE, 0)
177+
self._write_register16(_TWIST_DIFFERENCE, 0)
180178

181179
return diff
182180

@@ -296,21 +294,6 @@ def int_timeout(self, value):
296294
the end of knob turning and interrupt firing."""
297295
self._write_register16(_TWIST_TURN_INT_TIMEOUT, value)
298296

299-
# clear proporties
300-
301-
@property
302-
def clear_difference_after_read(self):
303-
"""Return True if the difference value is cleared after read."""
304-
return self._clear_difference_after_read
305-
306-
@clear_difference_after_read.setter
307-
def clear_difference_after_read(self, value):
308-
""""
309-
If True, clear the diffrence value after it is read.
310-
The defalt value is True.
311-
"""
312-
self._clear_difference_after_read = bool(value)
313-
314297
# public methods
315298

316299
def clear_interrupts(self):

0 commit comments

Comments
 (0)