python-dream-cheeky/examples/print_on_button_press.py
2015-09-11 02:43:28 -04:00

24 lines
472 B
Python
Executable File

#!/usr/bin/env python
"""Sample script for python-dream-cheeky."""
import os
from dream_cheeky import BigRedButton
def handle_button_press():
"""Handles a button press."""
print("Button pressed!")
def main():
"""Main function for the sync button."""
device_file = os.open("/dev/big_red_button", os.O_RDWR)
button = BigRedButton(device_file)
button.on_button_press(handle_button_press)
button.run()
if __name__ == '__main__':
main()