- 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
|
git submodule update --init
|
||||||
cd rpi-rgb-led-matrix/
|
cd rpi-rgb-led-matrix/
|
||||||
make
|
make
|
||||||
|
cp rgbmatrix.so ../
|
||||||
sudo ./minimal-example
|
sudo ./minimal-example
|
||||||
sudo ./led-matrix -D 0
|
sudo ./led-matrix -D 0
|
||||||
sudo python matrixtest.py
|
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 ImageDraw
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from rgbmatrix import Adafruit_RGBmatrix
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
# Rows and chain length are both required parameters:
|
||||||
|
matrix = Adafruit_RGBmatrix(32, 3)
|
||||||
|
|
||||||
r = requests.get('https://spaceapi.syn2cat.lu/status/json')
|
r = requests.get('https://spaceapi.syn2cat.lu/status/json')
|
||||||
|
|
||||||
obj = json.loads(r.text)
|
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"]:
|
if obj["state"]["open"]:
|
||||||
print("And we are open!")
|
print("And we are open!")
|
||||||
print("There are {} Hackers present NOW!".format(presence))
|
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