Skip to content

Commit 790deb2

Browse files
committed
read from eqep position file
1 parent 0b4bf35 commit 790deb2

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Adafruit_BBIO/Encoder.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@ def getPosition(self):
138138
'''
139139
position_file = "%s/position" % self.base_dir
140140
print("getPosition(): position_file: {0}".format(position_file))
141-
print("getPosition(): TODO: read position_file")
141+
position_handle = open(position_file, 'r')
142+
print("getPosition(): position_handle: {0}".format(position_handle))
143+
position = position_handle.read()
144+
print("getPosition(): position: {0}".format(position))
142145
#return sysfs.kernelFileIO(position_file)
143146

144147
def setFrequency(self,freq):

test/test_rotary.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/python
22

33
import Adafruit_BBIO.Encoder as Encoder
4-
5-
qep = Encoder.RotaryEncoder(1)
4+
# A on P8.11 and B on P8.12
5+
qep = Encoder.RotaryEncoder(2)
66
#qep = Encoder.QEP()
77
print qep
88

0 commit comments

Comments
 (0)