EMF_Camp_Badge/nyan/main.py

39 lines
1015 B
Python
Raw Permalink Normal View History

2018-09-02 17:01:52 -04:00
"""Nyan Cat Animation! Rotate the screen with 'A'."""
2018-09-02 15:20:03 -04:00
2018-09-02 15:44:32 -04:00
___name___ = "nyan"
2018-09-02 15:20:03 -04:00
___license___ = "MIT"
___dependencies___ = ["sleep", "app", "ugfx_helper",
"shared/nyan/0.png",
"shared/nyan/1.png",
"shared/nyan/2.png",
"shared/nyan/3.png",
"shared/nyan/4.png",
"shared/nyan/5.png"]
2018-09-02 15:20:03 -04:00
2018-09-02 17:23:26 -04:00
___categories___ = ["Homescreens", "Other"]
2018-09-02 15:20:03 -04:00
import ugfx_helper, os, wifi, ugfx, http, time, sleep, app
from tilda import Buttons
# initialize screen
ugfx_helper.init()
ugfx.clear(ugfx.BLACK)
ugfx.backlight(100)
n = 0
2018-09-02 21:48:27 -04:00
r = 270
2018-09-02 15:20:03 -04:00
while True:
ugfx.display_image( 0, 90, "shared/nyan/{}.png".format(n) )
n = (n+1) % 6
2018-09-02 15:20:03 -04:00
sleep.sleep_ms(10)
if Buttons.is_pressed(Buttons.BTN_B):
break
2018-09-02 17:01:52 -04:00
elif Buttons.is_pressed(Buttons.BTN_A):
r = (r + 180) % 360
ugfx.clear(ugfx.BLACK)
ugfx.orientation(r)
2018-09-02 15:20:03 -04:00
ugfx.clear()
app.restart_to_default()