Permalink
Browse files

updated rotary encoder tests.

  • Loading branch information...
guyc committed Jan 15, 2013
1 parent 248b1da commit e939a4fbc0964b3e338baf78dd383a5fbbbb3dc8
Showing with 27 additions and 1 deletion.
  1. +1 −1 samples/rotary_test.py
  2. +26 −0 samples/rotary_worker_test.py
View
@@ -13,7 +13,7 @@
switch = gaugette.switch.Switch(SW_PIN)
last_state = None
-while 1:
+while True:
delta = encoder.get_delta()
if delta!=0:
print "rotate %d" % delta
@@ -0,0 +1,26 @@
+# Sample code for both the RotaryEncoder class and the Switch class.
+# The common pin for the encoder should be wired to ground.
+# The sw_pin should be shorted to ground by the switch.
+
+import gaugette.rotary_encoder
+import gaugette.switch
+
+A_PIN = 7
+B_PIN = 9
+SW_PIN = 8
+
+encoder = gaugette.rotary_encoder.RotaryEncoder.Worker(A_PIN, B_PIN)
+encoder.start()
+switch = gaugette.switch.Switch(SW_PIN)
+last_state = None
+
+while True:
+ delta = encoder.get_delta()
+ if delta!=0:
+ print "rotate %d" % delta
+
+ sw_state = switch.get_state()
+ if sw_state != last_state:
+ print "switch %d" % sw_state
+ last_state = sw_state
+

0 comments on commit e939a4f

Please sign in to comment.