python-dream-cheeky/examples/print_on_button_press.py
Ian Adam Naval 65faeba785 Fix driver
I finally got the button in the mail today and I've finally done it.
2015-09-15 23:06:16 -04:00

24 lines
479 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/hidraw0", os.O_RDWR|os.O_NONBLOCK)
button = BigRedButton(device_file)
button.on_button_press(handle_button_press)
button.run()
if __name__ == '__main__':
main()