ui: code style, make header icon optional

pull/25/head
Jan Pochyla 8 years ago
parent b60206d588
commit ad2955aaab

@ -72,23 +72,23 @@ def blend(ca: int, cb: int, t: float) -> int:
async def alert(count=3):
current = display.backlight()
for i in range(count*2):
for i in range(count * 2):
if i % 2 == 0:
display.backlight(BACKLIGHT_MAX)
yield loop.Sleep(20000)
else:
display.backlight(BACKLIGHT_NORMAL)
yield loop.Sleep(80000)
display.backlight(current)
async def backlight_slide(val, speed=20000):
current = display.backlight()
for i in range(current, val, -1 if current > val else 1):
display.backlight(i)
await loop.Sleep(speed)
def animate_pulse(func, ca, cb, speed=200000, delay=30000):
while True:
# normalize sin from interval -1:1 to 0:1
@ -97,12 +97,15 @@ def animate_pulse(func, ca, cb, speed=200000, delay=30000):
func(c)
yield loop.Sleep(delay)
def header(title, icon=ICON_RESET, fg=BLACK, bg=PM_DARK_BLUE):
display.bar(0, 0, 240, 32, bg)
image = res.load(icon)
display.icon(8, 4, image, fg, bg)
if icon is not None:
image = res.load(icon)
display.icon(8, 4, image, fg, bg)
display.text(8 + 24 + 8, 23, title, BOLD, fg, bg)
def rotate_coords(pos: tuple) -> tuple:
r = display.orientation()
if r == 0:

Loading…
Cancel
Save