-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsnowmessage.py
More file actions
62 lines (55 loc) · 2.25 KB
/
Copy pathsnowmessage.py
File metadata and controls
62 lines (55 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import scrollphathd as sphd
from scrollphathd.fonts import font5x7
import datetime
import time
import signal
import random
str_len = 0
scroll_x = 0
while True:
# Show snow for a period of time
for a in range(0,5,1):
x1 = random.randint(0,16)
z1 = random.randint(-1,2)
x2 = random.randint(0,16)
z2 = random.randint(-1,2)
x3 = random.randint(0,16)
z3 = random.randint(-1,2)
x4 = random.randint(0,16)
z4 = random.randint(-1,2)
sphd.clear()
sphd.show()
sphd.set_brightness(0.5)
for y in range(0,30,1):
for z in range(y,0,-1):
sphd.set_pixel(x1, z+z1, (z/y)/2)
sphd.set_pixel(x2, z+z2, (z/y)/2)
sphd.set_pixel(x3, z+z3, (z/y)/2)
sphd.set_pixel(x4, z+z4, (z/y)/2)
sphd.show()
time.sleep(0.05)
# Show message for a period of time
y = datetime.datetime.now()
xmas = datetime.datetime(y.year, 12, 25) - datetime.datetime.now()
daysleft = xmas.days
hoursleft = xmas.seconds/3600
sphd.set_brightness(0.5)
sphd.clear()
if ((daysleft > 1) or (daysleft == 0)) and ((hoursleft > 1) or (hoursleft == 0)):
str_len = sphd.write_string("Ho ho ho! It's %i days and %i hours until xmas! " %(daysleft, hoursleft), x=0, y=0, font=font5x7)
elif ((daysleft > 1) or (daysleft == 0)) and (hoursleft == 1):
str_len = sphd.write_string("Ho ho ho! It's %i days and %i hour until xmas! " %(daysleft, hoursleft), x=0, y=0, font=font5x7)
elif (daysleft == 1) and ((hoursleft > 1) or (hoursleft == 0)):
str_len = sphd.write_string("Ho ho ho! It's %i day and %i hours until xmas! " %(daysleft, hoursleft), x=0, y=0, font=font5x7)
elif (daysleft == 1) and (hoursleft == 1):
str_len = sphd.write_string("Ho ho ho! It's %i day and %i hour until xmas! " %(daysleft, hoursleft), x=0, y=0, font=font5x7)
else:
str_len = sphd.write_string("Ho ho ho! It's %i days and %i hours until xmas! " %(daysleft, hoursleft), x=0, y=0, font=font5x7)
while True:
sphd.scroll_to(scroll_x, 0)
sphd.show()
time.sleep(0.02)
scroll_x += 1
if scroll_x >= str_len:
scroll_x = 0
break