├── README.md ├── danger.gif ├── filming.gif ├── iltms_piSign.py ├── onair.gif └── piSignIcons.svg /README.md: -------------------------------------------------------------------------------- 1 | # PiSign 2 | This is the Python code to run the project described at http://www.iliketomakestuff.com/make-raspberry-pi-display-sign/ 3 | 4 | It's a Raspberry Pi 3 based RGB LED matrix sign. Arcade buttons display images on the screen, then clear image if re-pressed. 5 | -------------------------------------------------------------------------------- /danger.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iliketomakestuff/PiSign/3d5857789bc43fcb54963b31fbd5a76e7f5e545e/danger.gif -------------------------------------------------------------------------------- /filming.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iliketomakestuff/PiSign/3d5857789bc43fcb54963b31fbd5a76e7f5e545e/filming.gif -------------------------------------------------------------------------------- /iltms_piSign.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # This is assuming you've followed the instructions at 4 | # https://learn.adafruit.com/adafruit-rgb-matrix-plus-real-time-clock-hat-for-raspberry-pi/driving-matrices 5 | 6 | # A more complex RGBMatrix example works with the Python Imaging Library, 7 | # demonstrating a few graphics primitives and image loading. 8 | # Note that PIL graphics do not have an immediate effect on the display -- 9 | # image is drawn into a separate buffer, which is then copied to the matrix 10 | # using the SetImage() function (see examples below). 11 | # Requires rgbmatrix.so present in the same directory. 12 | 13 | # PIL Image module (create or load images) is explained here: 14 | # http://effbot.org/imagingbook/image.htm 15 | # PIL ImageDraw module (draw shapes to images) explained here: 16 | # http://effbot.org/imagingbook/imagedraw.htm 17 | 18 | # This project was created by Bob Clagett of I Like To Make Stuff 19 | # More details and build video available at http://www.iliketomakestuff.com/ 20 | 21 | import Image 22 | import ImageDraw 23 | import time 24 | import os 25 | from rgbmatrix import Adafruit_RGBmatrix 26 | 27 | import RPi.GPIO as GPIO 28 | 29 | imagePath = '/home/pi/rpi-rgb-led-matrix-master/' 30 | pressed = 0 31 | GPIO.setwarnings(False) 32 | GPIO.setmode(GPIO.BCM) 33 | 34 | # on/off button 35 | GPIO.setup(3, GPIO.IN, pull_up_down=GPIO.PUD_UP) 36 | 37 | leds = { 38 | 18: 14, 39 | 24: 15, 40 | 8: 25, 41 | 7: 19 42 | } 43 | 44 | for button, led in leds.items(): 45 | GPIO.setup(led, GPIO.OUT) # led 46 | GPIO.setup(button, GPIO.IN, pull_up_down=GPIO.PUD_UP) # button 47 | 48 | # Rows and chain length are both required parameters: 49 | matrix = Adafruit_RGBmatrix(32, 1) 50 | matrix.SetWriteCycles(4) 51 | # Bitmap example w/graphics prims 52 | image = Image.new("1", (32, 32)) # Can be larger than matrix if wanted!! 53 | 54 | 55 | def showReady(): 56 | lp = 0 57 | # runs a simple animation with the buttons LEDS so you know it's ready. 58 | while lp < 5: 59 | for led in leds.values(): 60 | GPIO.output(led, True) 61 | time.sleep(.15) 62 | GPIO.output(led, False) 63 | lp += 1 64 | image = Image.open(imagePath + "logo.jpg") 65 | image.load() 66 | matrix.SetImage(image.im.id, 0, 1) 67 | time.sleep(2) 68 | matrix.Clear() 69 | 70 | 71 | def clearlights(): 72 | for led in leds.values(): 73 | GPIO.output(led, False) 74 | 75 | 76 | def lookForButtons(buttonNum): 77 | global pressed 78 | input_state = GPIO.input(buttonNum) 79 | if not input_state: 80 | clearlights() 81 | # print('press '+str(buttonNum)) 82 | if buttonNum != pressed: 83 | # new button was pressed 84 | GPIO.output(leds.get(buttonNum, ''), True) 85 | pictures = { 86 | 18: 'danger.gif', 87 | 8: 'onair.gif', 88 | 24: 'filming.gif', 89 | 7: 'logo2.jpg' 90 | } 91 | time.sleep(0.2) 92 | image = Image.open(imagePath + pictures.get(buttonNum, '')) 93 | image.load() 94 | matrix.SetImage(image.im.id, 0, 1) 95 | pressed = buttonNum 96 | 97 | else: 98 | # active button was re-pressed, turn it off and clear screen 99 | matrix.Clear() 100 | matrix.Fill(0x000000) 101 | 102 | pressed = 0 103 | 104 | time.sleep(.6) 105 | 106 | 107 | def lookForShutDown(): 108 | shutDownButton = GPIO.input(3) 109 | if not shutDownButton: 110 | showReady() 111 | GPIO.cleanup() 112 | os.system('shutdown now -h') 113 | 114 | 115 | # setup complete, start running stuff 116 | matrix.Clear() 117 | print('PiSign loaded..... rock on \m/') 118 | showReady() 119 | 120 | while True: 121 | for key in leds: 122 | lookForButtons(key) 123 | lookForShutDown() 124 | time.sleep(.05) # don't lock the cpu 125 | -------------------------------------------------------------------------------- /onair.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iliketomakestuff/PiSign/3d5857789bc43fcb54963b31fbd5a76e7f5e545e/onair.gif -------------------------------------------------------------------------------- /piSignIcons.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 17 | 18 | 19 | 20 | 21 | 22 | --------------------------------------------------------------------------------