-
Notifications
You must be signed in to change notification settings - Fork 18
/
app_main.py
80 lines (70 loc) · 2.09 KB
/
app_main.py
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# This file is part of MaixUI
# Copyright (c) sipeed.com
#
# Licensed under the MIT license:
# http://www.opensource.org/licenses/mit-license.php
#
import time, gc, math, sys
try:
from core import agent, system
from dialog import draw_dialog_alpha
from ui_canvas import ui, print_mem_free
from ui_container import container
from wdt import protect
from creater import get_time_curve
except ImportError as e:
sys.print_exception(e)
from lib.core import agent, system
from lib.dialog import draw_dialog_alpha
from ui.ui_canvas import ui, print_mem_free
from ui.ui_container import container
from driver.wdt import protect
from lib.creater import get_time_curve
class launcher:
def load():
__class__.ctrl = agent()
__class__.ctrl.event(20, __class__.draw)
def free():
__class__.ctrl = None
@ui.warp_template(ui.blank_draw)
@ui.warp_template(ui.grey_draw)
@ui.warp_template(ui.bg_in_draw)
@ui.warp_template(ui.anime_in_draw)
@ui.warp_template(ui.help_in_draw)
#@ui.warp_template(taskbar.time_draw)
#@ui.warp_template(taskbar.mem_draw)
#@catch # need sipeed_button
def draw():
height = 100 + int(get_time_curve(3, 250) * 60)
pos = draw_dialog_alpha(ui.canvas, 20, height, 200, 20, 10, color=(255, 0, 0), alpha=200)
ui.canvas.draw_string(pos[0] + 10, pos[1] + 10, "Welcome to MaixUI", scale=2, color=(0,0,0))
ui.display()
def event():
__class__.ctrl.cycle()
if __name__ == "__main__":
container.reload(launcher)
while True:
while True:
last = time.ticks_ms() - 1
while True:
try:
#time.sleep(0.1)
print(1000 // (time.ticks_ms() - last), 'fps')
last = time.ticks_ms()
gc.collect()
container.forever()
system.parallel_cycle()
protect.keep()
#gc.collect()
#print_mem_free()
except KeyboardInterrupt:
protect.stop()
raise KeyboardInterrupt
#except Exception as e:
#gc.collect()
#print(e)
finally:
try:
ui.display()
except:
pass