aboutsummaryrefslogtreecommitdiff
path: root/AT91SAM7S256/armdebug/nxt-python-fantom/examples/latency.py
diff options
context:
space:
mode:
Diffstat (limited to 'AT91SAM7S256/armdebug/nxt-python-fantom/examples/latency.py')
-rw-r--r--AT91SAM7S256/armdebug/nxt-python-fantom/examples/latency.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/AT91SAM7S256/armdebug/nxt-python-fantom/examples/latency.py b/AT91SAM7S256/armdebug/nxt-python-fantom/examples/latency.py
new file mode 100644
index 0000000..b4b1f26
--- /dev/null
+++ b/AT91SAM7S256/armdebug/nxt-python-fantom/examples/latency.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+
+import time
+import nxt.locator
+from nxt.sensor import *
+
+b = nxt.locator.find_one_brick()
+
+#Touch sensor latency test
+touch = Touch(b, PORT_1)
+start = time.time()
+for i in range(100):
+ touch.get_sample()
+stop = time.time()
+print 'touch latency: %s ms' % (1000 * (stop - start) / 100.0)
+
+#Ultrasonic sensor latency test
+ultrasonic = Ultrasonic(b, PORT_4)
+start = time.time()
+for i in range(100):
+ ultrasonic.get_sample()
+stop = time.time()
+print 'ultrasonic latency: %s ms' % (1000 * (stop - start) / 100.0)