Last active
December 29, 2015 13:48
-
-
Save pdp7/7679350 to your computer and use it in GitHub Desktop.
title: beaglebone black with adafruit 8x8 LED matrix facebook notification display
author: drew fustini (http://element14.com/fustini)
blog: http://www.element14.com/community/community/knode/single-board_computers/next-gen_beaglebone/blog/
This file contains 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
#!/usr/bin/python | |
import time | |
import datetime | |
import facebook | |
import sys | |
from Adafruit_8x8 import EightByEight | |
# =========================================================================== | |
# title: beaglebone black with adafruit 8x8 LED matrix facebook notification display | |
# author: drew fustini (http://element14.com/fustini) | |
# blog: http://www.element14.com/community/community/knode/single-board_computers/next-gen_beaglebone/blog/ | |
# | |
# method 1: get short term (2 hour) access_token from: | |
# https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Fnotifications | |
# method 2: get extended (60 days) access_token via instructions at: | |
# http://fearofcoding.blogspot.com/2012/10/python-script-to-fetch-messages-from.html | |
# note: install the needed python module with "pip install facepy" | |
# =========================================================================== | |
access_token = "PASTE_YOUR_EXTENDED_ACCESS_TOKEN_HERE" | |
grid = EightByEight(address=0x70) | |
print "Press CTRL+C to exit" | |
# Continually update the current unseen notification count on an Adafruit 8x8 LED matrix display | |
while(True): | |
graph = facebook.GraphAPI(access_token) | |
notifications = graph.get_object("me/notifications") | |
print "notifications" | |
print notifications | |
summary = notifications['summary'] | |
grid.clear() | |
if summary: | |
num = summary['unseen_count'] | |
print num | |
min=0 | |
max=8 | |
fullRows=0 | |
for n in range(0, 8): | |
if num > min and num <= max: | |
for y in range(0, 8): | |
for x in range(0, fullRows): | |
grid.setPixel(x, y) | |
for y in range(0, num-min): | |
grid.setPixel(fullRows, y) | |
min+=8 | |
max+=8 | |
fullRows+=1 | |
time.sleep(60) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment