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:
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