Skip to content

Commit 0b4bf35

Browse files
committed
add test for rotary encoder
1 parent cc5edb2 commit 0b4bf35

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

Adafruit_BBIO/Encoder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def __init__(self, eqep_num):
6868
print("RotaryEncoder(): self._eqep_dirs[0]: {0}".format(self._eqep_dirs[0]))
6969
print("RotaryEncoder(): self._eqep_dirs[1]: {0}".format(self._eqep_dirs[1]))
7070
print("RotaryEncoder(): self._eqep_dirs[2]: {0}".format(self._eqep_dirs[2]))
71-
print("RotaryEncoder(): self._eqep_dirs[eqep_num]: {0}".format(self._eqep_dirs[eqep_num]))
71+
print("RotaryEncoder(): self._eqep_dirs[eqep_num: {0}]: {1}".format(eqep_num, self._eqep_dirs[eqep_num]))
7272
assert 0 <= eqep_num <= 3 , "eqep_num must be between 0 and 3"
7373
self.base_dir = self._eqep_dirs[eqep_num]
7474
print("RotaryEncoder(): self.base_dir: {0}".format(self.base_dir))

test/test_rotary.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/python
2+
3+
import Adafruit_BBIO.Encoder as Encoder
4+
5+
qep = Encoder.RotaryEncoder(1)
6+
#qep = Encoder.QEP()
7+
print qep
8+
9+
print("qep.enable(): {0}".format(qep.enable()))
10+
#qep.getMode()
11+
#qep.setAbsolute()
12+
#qep.setRelative()
13+
#qep.setFrequency(5000)
14+
print("qep.getPosition(): {0}".format(qep.getPosition()))
15+
#qep.setPosition(100)
16+
#qep.disable()

0 commit comments

Comments
 (0)