root42 / pi-xmas-tree

Web control for the PiHut 3D Xmas Tree
3 stars 0 forks source link

Merry christmas! #1

Open vloup opened 6 years ago

vloup commented 6 years ago

This is a nice tree you made that I have been spamming for about the last two days. I hope you had as much fun as I did to pull this off.

Merry christmas, and here is my script:

#!/usr/bin/env python3

import datetime
import json
import requests
import time

baseURL = "http://root42.de/led/"
leds = [19, 2, 20, 1, 10, 11, 0, 18, 9, 3, 12, 17, 4, 25, 23, 16, 8, 14, 13, 5, 7, 21, 15, 6, 24, 22]
session = requests.Session()

def sendValue(i, status):
    answer = session.put(baseURL + str(i), data=json.dumps({"value": status}), headers={'user-agent': 'santa-claus/1.0'})
    print(datetime.datetime.now().strftime("%d-%m-%y %H:%M:%S") + ":", answer.status_code)

def off(i):
    sendValue(i, 0.0)

def on(i):
    sendValue(i, 1.0)

for i in leds:
    off(i)

while True:
    for i in range(0, 26):
        off(leds[(i - 1) % 26])
        on(leds[i])
        #time.sleep(1)
root42 commented 5 years ago

Oh dear, I did not even see this issue until this year. The tree will go up again very soon. I will also post a video on my channel.

Happy holidays!

vloup commented 5 years ago

Hehe, I had hopes you did not take that spammy little idea of mine too badly, and that silence of yours was unclear to me. Glad to hear that you just missed it.

Turns out you only need to change the port number to make it work for this year :-)

Merry Christmas!

root42 commented 5 years ago

Yeah, I changed ports this year, since there was still the other frontend, not under my control. :)

Merry christmas!

PS: would be nice if you could cronjob your script, so that like half the day people can simply play with the tree. Ok?

Am 25.12.2018 um 13:07 schrieb vloup notifications@github.com:

Hehe, I had hopes you did not take that spammy little idea of mine too badly, and that silence of yours was unclear to me. Glad to hear that you just missed it.

Turns out you only need to change the port number to make it work for this year :-)

Merry Christmas!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

vloup commented 5 years ago

Sure enough, I stopped it and will not run it again until maybe next year. I was not planning to run it for long for that reason.

root42 commented 5 years ago

Idea: I can add a bool to the JSON 'cycle-leds', which you can query. Whenever a user sets it to on, your script runs its animation. When a user turns it off, it will stop. Does that sound neat? Makes this whole thing brilliantly more complicated. :)