Created
May 31, 2014 15:29
-
-
Save choffee/7fc91c4f0a87b761c6c6 to your computer and use it in GitHub Desktop.
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/env python | |
import time | |
from time import sleep | |
import Adafruit_Nokia_LCD as LCD | |
import Adafruit_GPIO.SPI as SPI | |
import Adafruit_BBIO.GPIO as GPIO | |
import Image | |
import ImageDraw | |
import ImageFont | |
# | |
DC = 'P9_15' | |
RST = 'P9_12' | |
SPI_PORT = 1 | |
SPI_DEVICE = 0 | |
CE0="P8_12" | |
CE1="P8_9" | |
CE2="P8_10" | |
CES=[CE0, CE1, CE2] | |
print LCD.LCDWIDTH, LCD.LCDHEIGHT | |
for CE in CES: | |
GPIO.setup(CE, GPIO.OUT) | |
GPIO.output(CE, GPIO.HIGH) | |
disp = LCD.PCD8544(DC, RST, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=4000000)) | |
disp.reset() | |
# Setup all the displays | |
for CE in CES: | |
GPIO.output(CE, GPIO.LOW) | |
disp.begin(contrast=40) | |
disp.clear() | |
disp.display() | |
GPIO.output(CE, GPIO.HIGH) | |
image = Image.new('1', (LCD.LCDWIDTH, LCD.LCDHEIGHT)) | |
draw = ImageDraw.Draw(image) | |
# empty box | |
def empty(): | |
draw.rectangle((0,0,LCD.LCDWIDTH,LCD.LCDHEIGHT), outline=255, fill = 255) | |
font = ImageFont.load_default() | |
def box(x,y,text): | |
draw.rectangle((0+x,0+y,32+x,22+y), outline=0, fill=255) | |
draw.text((2+x, 2+y), text, font=font) | |
#draw.ellipse((2,2,22,22), outline=0, fill=255) | |
#draw.rectangle((24,2,44,22), outline=0, fill=255) | |
def write_image(display): | |
GPIO.output(display, GPIO.LOW) | |
disp.image(image) | |
disp.display() | |
GPIO.output(display, GPIO.HIGH) | |
xoffset = 0 | |
dir = 1 | |
while True: | |
for CE in CES: | |
empty() | |
box(xoffset,2,CE) | |
write_image(CE) | |
xoffset += dir | |
if xoffset > 48 or xoffset < 0: | |
dir = -dir | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment