- moved pix to correct fn; added rudimentary open/close code
parent
b67f016314
commit
55801937af
|
@ -15,7 +15,9 @@ sudo apt-get install python-imaging
|
|||
git submodule update --init
|
||||
cd rpi-rgb-led-matrix/
|
||||
make
|
||||
cp rgbmatrix.so ../
|
||||
sudo ./minimal-example
|
||||
sudo ./led-matrix -D 0
|
||||
sudo python matrixtest.py
|
||||
```
|
||||
```
|
||||
|
||||
|
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
41
main.py
41
main.py
|
@ -4,16 +4,49 @@ import Image
|
|||
import ImageDraw
|
||||
import time
|
||||
|
||||
from rgbmatrix import Adafruit_RGBmatrix
|
||||
|
||||
import requests
|
||||
import json
|
||||
|
||||
# Rows and chain length are both required parameters:
|
||||
matrix = Adafruit_RGBmatrix(32, 3)
|
||||
|
||||
r = requests.get('https://spaceapi.syn2cat.lu/status/json')
|
||||
|
||||
obj = json.loads(r.text)
|
||||
|
||||
presence = obj["sensors"]["people_now_present"][0]["value"]
|
||||
def main():
|
||||
|
||||
presence = obj["sensors"]["people_now_present"][0]["value"]
|
||||
|
||||
|
||||
if obj["state"]["open"]:
|
||||
print("And we are open!")
|
||||
print("There are {} Hackers present NOW!".format(presence))
|
||||
if obj["state"]["open"]:
|
||||
print("And we are open!")
|
||||
print("There are {} Hackers present NOW!".format(presence))
|
||||
openSpace()
|
||||
|
||||
if obj["state"]["closed"]:
|
||||
print("And we are closed!")
|
||||
print("There were {} Hackers present! Good night, good fight!".format(presence))
|
||||
closedSpace()
|
||||
|
||||
|
||||
def openSpace():
|
||||
matrix.Clear()
|
||||
image = Image.open("images/32px-LightOn.svg.png")
|
||||
image.load()
|
||||
for n in range(32, -image.size[0], -1):
|
||||
matrix.SetImage(image.im.id, n, 1)
|
||||
time.sleep(0.025)
|
||||
|
||||
def closedSpace():
|
||||
matrix.Clear()
|
||||
image = Image.open("images/32px-LightOf.svg.png")
|
||||
image.load()
|
||||
for n in range(32, -image.size[0], -1):
|
||||
matrix.SetImage(image.im.id, n, 1)
|
||||
time.sleep(0.025)
|
||||
|
||||
|
||||
if __name__ == “__main__”: main()
|
||||
|
|
Loading…
Reference in New Issue