Last active
August 29, 2015 14:03
-
-
Save pingswept/aee9c49d417a8e06fced to your computer and use it in GitHub Desktop.
Code for monitoring the 3D printers at Happy Workhorse Farms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Add in cat /etc/supervisor/conf.d/smack-blog.conf | |
| # | |
| # [program:smack-blog] | |
| # command=/root/smack-blog.py | |
| #!/usr/bin/python | |
| import Adafruit_BBIO.UART as UART | |
| import os, pytumblr, serial, time | |
| def logMessage(ser, msg): | |
| print(msg) | |
| ser.write(chr(0xFE) + chr(0x01)) | |
| ser.write(msg) | |
| client = pytumblr.TumblrRestClient( | |
| # Get keys from Tumblr API: https://api.tumblr.com/console/calls/user/info | |
| # Put keys here. Should be 4 lines | |
| ) | |
| UART.setup("UART4") | |
| ser = serial.Serial(port = "/dev/ttyO4", baudrate=9600) | |
| ser.close() # Flush any old messages | |
| ser.open() | |
| while(1): | |
| logMessage(ser, "Waiting...") | |
| time.sleep(900) | |
| logMessage(ser, "Button smacked!") | |
| os.system('fswebcam -r 1920x1080 --jpeg 85 --font sans:20 -D 1 /var/www/public/static/images/shot.jpg') | |
| logMessage(ser, "Tried to take a picture") | |
| client.create_photo(u'rascalmicro.tumblr.com', state="published", data="/var/www/public/static/images/shot.jpg") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment