Skip to content

Commit e7814d7

Browse files
authored
Merge pull request #87 from SHA2017-badge/about
About
2 parents 92d9ba3 + 599d7d1 commit e7814d7

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

esp32/modules/magic.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import ugfx, appglue, hashlib, ubinascii, time, uos
2+
3+
names = ["Kartoffel", "Sebastius", "tsd", "Sprite_TM", "Underhand", "MaruksBek", "Roosted", "the_JinX", "realitygaps", "raboof", "Alexandre Dulaunoy", " Eric Poulsen", "Damien P. George", "Renze Nicolai"]
4+
5+
def action_exit(pushed):
6+
if (pushed):
7+
appglue.home()
8+
9+
def fill_screen_with_crap(c):
10+
print("Filling screen...")
11+
for i in range(0,3):
12+
nr = int.from_bytes(uos.urandom(1), 1)
13+
sha = hashlib.sha1(str(nr))
14+
s = ubinascii.hexlify(sha.digest())
15+
for j in range(0,8):
16+
x = int.from_bytes(uos.urandom(1), 1)
17+
y = int.from_bytes(uos.urandom(1), 1)
18+
if (x<ugfx.width()) and (y<ugfx.height()):
19+
ugfx.string(x, y, s, "Roboto_Regular12", c)
20+
ugfx.flush()
21+
print("done.")
22+
23+
def draw_name(x,y,name):
24+
print("Drawing name "+name)
25+
for i in range(1,5):
26+
ugfx.string(x-i, y-i, name, "PermanentMarker22", ugfx.WHITE)
27+
ugfx.string(x+i, y+i, name, "PermanentMarker22", ugfx.WHITE)
28+
ugfx.string(x-i, y+i, name, "PermanentMarker22", ugfx.WHITE)
29+
ugfx.string(x+i, y-i, name, "PermanentMarker22", ugfx.WHITE)
30+
ugfx.string(x-i, y, name, "PermanentMarker22", ugfx.WHITE)
31+
ugfx.string(x+i, y, name, "PermanentMarker22", ugfx.WHITE)
32+
ugfx.string(x, y-i, name, "PermanentMarker22", ugfx.WHITE)
33+
ugfx.string(x, y+i, name, "PermanentMarker22", ugfx.WHITE)
34+
ugfx.string(x, y, name, "PermanentMarker22", ugfx.BLACK)
35+
print("done.")
36+
ugfx.flush()
37+
38+
def show_names():
39+
global names
40+
c = False
41+
for n in range(0, len(names)):
42+
color = ugfx.BLACK
43+
#if (c):
44+
# c = False
45+
#else:
46+
# c = True
47+
# color = ugfx.WHITE
48+
fill_screen_with_crap(color)
49+
x = int.from_bytes(uos.urandom(1), 1)
50+
y = round(int.from_bytes(uos.urandom(1), 1)/2)
51+
w = ugfx.get_string_width(names[n],"PermanentMarker22")
52+
if (x+w > ugfx.width()):
53+
x = x+w
54+
if (y > ugfx.height()-22):
55+
y = ugfx.height()-22
56+
if (x==0):
57+
x=1
58+
if (y==0):
59+
y=1
60+
print("NAME AT "+str(x)+", "+str(y))
61+
draw_name(x,y,names[n])
62+
time.sleep(1)
63+
64+
def main():
65+
#ugfx.init()
66+
ugfx.input_init()
67+
ugfx.input_attach(ugfx.BTN_B, action_exit)
68+
ugfx.input_attach(ugfx.BTN_START, action_exit)
69+
fill_screen_with_crap(ugfx.BLACK)
70+
show_names()
71+
72+
while (True):
73+
main()

esp32/modules/splash.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,22 @@ def start_ota(pushed):
277277
if(pushed):
278278
print("[SPLASH] Starting OTA...")
279279
appglue.start_ota()
280+
281+
# MAGIC
282+
def actually_start_magic():
283+
print("[SPLASH] Starting magic...")
284+
esp.rtcmem_write_string("magic")
285+
deepsleep.reboot()
286+
287+
magic = 0
288+
def start_magic(pushed):
289+
global magic
290+
if(pushed):
291+
magic = magic + 1
292+
if (magic>10):
293+
actually_start_magic()
294+
else:
295+
print("[SPLASH] Magic in "+str(10-magic)+"...")
280296

281297
# SLEEP
282298
def badge_sleep():
@@ -477,6 +493,7 @@ def splash_main():
477493
ugfx.input_init()
478494
welcome()
479495
ugfx.input_attach(ugfx.BTN_START, start_launcher)
496+
ugfx.input_attach(ugfx.BTN_A, start_magic)
480497
global splashTimer
481498
setup_services()
482499
start_sleep_counter()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy