Code: Select all
b=(200) # brightness
def clamp(value, min_value=75, max_value=255):
return min(max_value, max(min_value, value))
def pushed_up(event):
global b
if event.action != ACTION_PRESSED:
b = clamp(b - 5)
def pushed_down(event):
global b
if event.action != ACTION_PRESSED:
b = clamp(b + 5)
def pushed_push(event):
if event.action != ACTION_PRESSED:
os.system("sudo shutdown now -P")
def pushed_right(event):
if event.action != ACTION_PRESSED:
raise SystemExit
sense.stick.direction_up = pushed_up
sense.stick.direction_down = pushed_down
sense.stick.direction_push = pushed_push
sense.stick.direction_right = pushed_right
