Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/plugins/wedo_plugin/wedo/tilt.py
blob: 4f3534037d7aceb246f9b6ea8ecb6df9511d742e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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