Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/plugins/wedo_plugin/wedo/tilt.py
diff options
context:
space:
mode:
authorAlan Jhonn Aguiar Schwyn <alanjas@hotmail.com>2013-12-03 17:00:06 (GMT)
committer Walter Bender <walter@sugarlabs.org>2013-12-03 17:00:06 (GMT)
commitc3fe01df954d03839322901fccc43804d31f9f54 (patch)
treea265fe4066fa2e1283ca3ba764843fc037542ff3 /plugins/wedo_plugin/wedo/tilt.py
parentad4497c688d4e15275736e235be8194dd68d81e0 (diff)
new wedo plugin from TurtleBot
Diffstat (limited to 'plugins/wedo_plugin/wedo/tilt.py')
-rw-r--r--plugins/wedo_plugin/wedo/tilt.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/plugins/wedo_plugin/wedo/tilt.py b/plugins/wedo_plugin/wedo/tilt.py
new file mode 100644
index 0000000..4f35340
--- /dev/null
+++ b/plugins/wedo_plugin/wedo/tilt.py
@@ -0,0 +1,14 @@
+FLAT, TILT_FORWARD, TILT_LEFT, TILT_RIGHT, TILT_BACK = range(5)
+
+def process_tilt(raw_tilt_value):
+ """Use a series of elif/value-checks to process the tilt
+ sensor data."""
+ if 10 <= raw_tilt_value <= 40:
+ return TILT_BACK
+ elif 60 <= raw_tilt_value <= 90:
+ return TILT_RIGHT
+ elif 170 <= raw_tilt_value <= 190:
+ return TILT_FORWARD
+ elif 220 <= raw_tilt_value <= 240:
+ return TILT_LEFT
+ return FLAT