Skip to content

Commit 7565d80

Browse files
committed
updated method name and examples
1 parent 58dafe8 commit 7565d80

File tree

5 files changed

+80
-5
lines changed

5 files changed

+80
-5
lines changed

docs/examples.rst

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,66 @@ Ensure your device works with this simple test.
66
.. literalinclude:: ../examples/qwiictwist_simpletest.py
77
:caption: examples/qwiictwist_simpletest.py
88
:linenos:
9+
10+
Examples
11+
---------
12+
13+
1. Basic Readings - Print number of steps knob has been twisted.
14+
15+
.. literalinclude:: ../examples/example1_basic_readings.py
16+
:caption: examples/example1_basic_readings.py
17+
:linenos:
18+
19+
2. Set Color - Set the knob color.
20+
21+
.. literalinclude:: ../examples/example2_set_color.py
22+
:caption: examples/example2_set_color.py
23+
:linenos:
24+
25+
3. Crazy Color - Set the knob to random colors.
26+
27+
.. literalinclude:: ../examples/example3_crazy_color.py
28+
:caption: examples/example3_crazy_color.py
29+
:linenos:
30+
31+
4. Connect Color - Change the knob color as it is twisted.
32+
33+
.. literalinclude:: ../examples/example4_connect_color.py
34+
:caption: examples/example3_connect_color.py
35+
:linenos:
36+
37+
5. Timestamps - Show timestamps for when knob is twisted or pressed.
38+
39+
.. literalinclude:: ../examples/example5_timestamps.py
40+
:caption: examples/example5_timesteamps.py
41+
:linenos:
42+
43+
6. Difference - Show the diffence between encoder counts when knob is twisted.
44+
45+
.. literalinclude:: ../examples/example6_difference.py
46+
:caption: examples/example6_difference.py
47+
:linenos:
48+
49+
7. Set Count - Change the encoder count reported when knob is twisted.
50+
51+
.. literalinclude:: ../examples/example7_set_count.py
52+
:caption: examples/example7_set_count.py
53+
:linenos:
54+
55+
8. Interrupts - Enable button and twist interrupts.
56+
57+
.. literalinclude:: ../examples/example8_interrupts.py
58+
:caption: examples/example8_interruptst.py
59+
:linenos:
60+
61+
9. Change I2C Addres - Change the device I2C address.
62+
63+
.. literalinclude:: ../examples/example9_change_i2c_address.py
64+
:caption: examples/example9_change_i2c_address.py
65+
:linenos:
66+
67+
10. I2C Scanner - Scan the IC2 bus for devices.
68+
69+
.. literalinclude:: ../examples/example10_i2c_scanner.py
70+
:caption: examples/example10_i2c_scanner.py
71+
:linenos:

docs/examples.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
example10_i2c_scanner.py
2+
example1_basic_readings.py
3+
example2_set_color.py
4+
example3_crazy_color.py
5+
example4_connect_colors.py
6+
example5_timestamps.py
7+
example6_difference.py
8+
example7_set_count.py
9+
example8_interrupts.py
10+
example9_change_i2c_address.py
11+
examples.txt
12+
qwiictwist_simpletest.py

examples/example6_difference.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
# Create twist object
3333
twist = sparkfun_qwiictwist.Sparkfun_QwiicTwist(i2c)
3434

35-
print('Qwicc Twist Example 1 Basic Readings')
35+
print('Qwicc Twist Example 6 Difference')
3636

3737
# Check if connected
3838
if twist.connected:
@@ -46,7 +46,7 @@
4646
try:
4747
while True:
4848
print('Count: ' + str(twist.count))
49-
print('Difference: ' + str(twist.difference()))
49+
print('Difference: ' + str(twist.get_difference()))
5050
sleep(0.250)
5151

5252
except KeyboardInterrupt:

examples/example7_set_count.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# Create twist object
3030
twist = sparkfun_qwiictwist.Sparkfun_QwiicTwist(i2c)
3131

32-
print('Qwicc Twist Example 1 Basic Readings')
32+
print('Qwicc Twist Example 7 Set Count')
3333

3434
# Check if connected
3535
if twist.connected:
@@ -46,7 +46,7 @@
4646
try:
4747
while True:
4848
print('Count: ' + str(twist.count))
49-
print('Difference: ' + str(twist.difference()))
49+
print('Difference: ' + str(twist.get_difference()))
5050
sleep(0.250)
5151

5252
except KeyboardInterrupt:

sparkfun_qwiictwist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def int_timeout(self, value):
248248

249249
# public functions
250250

251-
def difference(self, clear=True):
251+
def get_difference(self, clear=True):
252252
""""Return the number of clicks since last check."""
253253
value = self._read_register16(_TWIST_DIFFERENCE)
254254
diff = self._signed_int16(value)

0 commit comments

Comments
 (0)