diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..fab8f691 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +venv +*.pyc \ No newline at end of file diff --git a/Adafruit_LEDBackpack/Adafruit_8x8.py b/Adafruit_LEDBackpack/Adafruit_8x8.py index df966dc9..e4589835 100644 --- a/Adafruit_LEDBackpack/Adafruit_8x8.py +++ b/Adafruit_LEDBackpack/Adafruit_8x8.py @@ -47,6 +47,10 @@ def clear(self): "Clears the entire display" self.disp.clear() + def setBrightness(self, brightness): + "Sets the brightness level from 0..15" + self.disp.setBrightness(brightness) + class ColorEightByEight(EightByEight): def setPixel(self, x, y, color=1): "Sets a single pixel" diff --git a/Adafruit_LEDBackpack/email.py b/Adafruit_LEDBackpack/email.py new file mode 100644 index 00000000..464dca03 --- /dev/null +++ b/Adafruit_LEDBackpack/email.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python +import os + +import feedparser, time + +import datetime +from Adafruit_8x8 import ColorEightByEight + +DEBUG = 1 +os.system("export ENAME") +os.system("export EPASS") +USERNAME = os.environ["ENAME"] # just the part before the @ sign, add yours here +PASSWORD = os.environ["EPASS"] + +NEWMAIL_OFFSET = 0 # my unread messages never goes to zero, yours might +MAIL_CHECK_FREQ = 30 # check mail every 60 seconds + +# GPIO.setmode(GPIO.BCM) +# GREEN_LED = 18 +# RED_LED = 23 +# GPIO.setup(GREEN_LED, GPIO.OUT) +# GPIO.setup(RED_LED, GPIO.OUT) +# =========================================================================== +# 8x8 Pixel Example +# =========================================================================== +grid = ColorEightByEight(address=0x70) + +print "Press CTRL+Z to exit" + +smile_bmp = [0b00011110,0b00100001,0b11010010,0b11000000,0b11010010,0b11001100,0b00100001,0b00011110] +neutral_bmp = [0b00011110,0b00100001,0b11010010,0b11000000,0b11011110,0b11000000,0b00100001,0b00011110] +frown_bmp = [0b00011110,0b00100001,0b11010010,0b11000000,0b11001100,0b11010010,0b00100001,0b00011110] + +grid.setBrightness(15) + +while True: + + newmails = int(feedparser.parse("https://" + USERNAME + ":" + PASSWORD +"@mail.google.com/gmail/feed/atom")["feed"]["fullcount"]) + + if DEBUG: + print "You have", newmails, "new emails!" + + if newmails > NEWMAIL_OFFSET: + # Write a frown face + for i in range(0,8): + grid.writeRowRaw(i, frown_bmp[i]) + time.sleep(1) + else: + # Write a smiley face + for i in range(0,8): + grid.writeRowRaw(i, smile_bmp[i]) + time.sleep(1) + + time.sleep(MAIL_CHECK_FREQ) + + + diff --git a/Adafruit_LEDBackpack/ex_8x8_andy.py b/Adafruit_LEDBackpack/ex_8x8_andy.py new file mode 100644 index 00000000..7bd81ea6 --- /dev/null +++ b/Adafruit_LEDBackpack/ex_8x8_andy.py @@ -0,0 +1,37 @@ +#!/usr/bin/python + +import time +import datetime +from Adafruit_8x8 import ColorEightByEight + +# =========================================================================== +# 8x8 Pixel Example +# =========================================================================== +grid = ColorEightByEight(address=0x70) + +print "Press CTRL+Z to exit" + +smile_bmp = [0b00011110,0b00100001,0b11010010,0b11000000,0b11010010,0b11001100,0b00100001,0b00011110] +neutral_bmp = [0b00011110,0b00100001,0b11010010,0b11000000,0b11011110,0b11000000,0b00100001,0b00011110] +frown_bmp = [0b00011110,0b00100001,0b11010010,0b11000000,0b11001100,0b11010010,0b00100001,0b00011110] + +grid.setBrightness(15) + +for x in range(1, 4): + for y in range(1, 4): + grid.setPixel(x, y) + +# Write a frown face +for i in range(0,8): + grid.writeRowRaw(i, frown_bmp[i]) +time.sleep(1) + +# Write a neutral face +for i in range(0,8): + grid.writeRowRaw(i, neutral_bmp[i]) +time.sleep(1) + +# Write a smiley face +for i in range(0,8): + grid.writeRowRaw(i, smile_bmp[i]) +time.sleep(1) \ No newline at end of file diff --git a/Adafruit_LEDBackpack/test.py b/Adafruit_LEDBackpack/test.py new file mode 100644 index 00000000..0fe8e8eb --- /dev/null +++ b/Adafruit_LEDBackpack/test.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python +import os +os.system("export ENAME") +os.system("export EPASS") +USERNAME = os.environ["ENAME"] # just the part before the @ sign, add yours here +PASSWORD = os.environ["EPASS"] + +print USERNAME +print PASSWORD \ No newline at end of file