File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/python
2+
3+ # ===========================================================================
4+ # Adafruit_BBIO.Encoder.QEP Class
5+ # ===========================================================================
6+
7+ class QEP :
8+
9+ def __init__ (self , channel = 1 , debug = False ):
10+ self .channel = channel
11+ self .debug = debug
12+
13+ def errMsg (self ):
14+ print ("Error accessing 0x%02X: Check your QEP channel" % self .address )
15+ return - 1
16+
17+ # example method from Adafruit_I2C
18+ # TODO: delete this
19+ def write8 (self , reg , value ):
20+ "Writes an 8-bit value to the specified register/address"
21+ try :
22+ self .bus .write_byte_data (self .address , reg , value )
23+ if self .debug :
24+ print ("Rotary: Wrote 0x%02X to register 0x%02X" % (value , reg ))
25+ except IOError as err :
26+ return self .errMsg ()
27+
28+
29+ if __name__ == '__main__' :
30+ try :
31+ qep = Adafruit_BBIO .Encoder .QEP ()
32+ print ("Default QEP channel is accessible" )
33+ except :
34+ print ("Error accessing default Rotary bus" )
You can’t perform that action at this time.
0 commit comments