def load(self): if self.is_load == False: self.is_load = True self.agent = agent() self.agent.event(500, sample_page.next) else: sample_page.next()
class app: ctrl = agent() @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(): ui.display() def run(): #app.ctrl.event(100, lambda *args: time.sleep(1)) app.ctrl.event(5, app.draw) while True: #import time #last = time.ticks_ms() while True: try: #print((int)(1000 / (time.ticks_ms() - last)), 'fps') #last = time.ticks_ms() app.ctrl.cycle() protect.keep() #time.sleep(0.1) except KeyboardInterrupt: protect.stop() raise KeyboardInterrupt() except Exception as e: # gc.collect() print(e)
def load(self): if self.is_load == False: #print(case.load) self.is_load = True sample_page.btn.enable = False self.btn = sipeed_button() self.agent = agent() self.agent.event(150, self.key_event)
def load(): self = __class__ self.h, self.w = 0, 0 self.ctrl = agent() self.ctrl.event(5, self.draw) def into_launcher(self): container.reload(launcher) self.remove(into_launcher) self.ctrl.event(2000, into_launcher)
def load(self): if self.is_load == False: self.is_load = True self.result = os.getcwd( ) == '/sd' # and len(os.listdir('/sd')) > 0 self.agent = agent() self.agent.event(500, sample_page.next) else: sample_page.next()
def __init__(self): self.is_load = False self.i2c = I2C(I2C.I2C1, freq=100 * 1000, sda=31, scl=30) #fm.register(30, fm.fpioa.I2C1_SCLK, force=True) #fm.register(31, fm.fpioa.I2C1_SDA, force=True) self.isconnected = False self.agent = agent() self.agent.event(500, self.check) self.tapped = False self.acceleration = (0, 0, 0)
def load(self): if self.is_load == False: self.is_load = True sample_page.btn.enable = False self.btn = sipeed_button() # self.btn.config(23, 20, 31) self.agent = agent() self.agent.event(150, self.key_event) #self.agent.event(500, sample_page.next) elif Report.RearSensor_Test: sample_page.next()
def load(): self = __class__ self.h, self.w = 0, 0 self.value = 0 self.ctrl = agent() self.ctrl.event(10, self.draw) def test_once(self): container.latest() self.remove(test_once) self.ctrl.event(5000, test_once) button_io.config(10, 11, 16)
def load(self): if Report.Spmod_Test: sample_page.next() if self.is_load == False: # i2c init() sample_page.btn.enable = False self.isError = None self.work_info = [] self.work_data = None self.agent = agent() self.agent.event(250, self.check) self.agent.event(1500, self.test_event) self.is_load = True
def load(self): if Report.Msa301_Test: sample_page.next() if self.is_load == False: # i2c init() sample_page.btn.enable = False self.isconnected = False self.isError = None self.tapped = False self.acceleration = (0, 0, 0) self.agent = agent() self.agent.event(500, self.check) self.agent.event(1500, self.test_event) self.is_load = True
def load(self): if Report.Power_Test: sample_page.next() if self.is_load == False: # i2c init() sample_page.btn.enable = False self.isconnected = False self.isError = None self.vbat_voltage = 0 self.work_info = [] self.agent = agent() self.agent.event(500, self.check) self.agent.event(1500, self.test_event) self.is_load = True
def load(self): if Report.RearSensor_Test: sample_page.next() if self.is_load == False: sipeed_led.init(13, 12, 14, 32) sipeed_led.w.value(1) sample_page.btn.enable = False self.btn = sipeed_button() # self.btn.config(23, 20, 31) self.get_image = None self.isError = None self.agent = agent() self.agent.event(150, self.check) self.agent.event(8000, self.test_event) self.is_load = True
def load(self): if self.is_load == False: self.is_load = True sample_page.btn.enable = False self.btn = sipeed_button() # self.btn.config(23, 20, 31) self.agent = agent() self.agent.event(150, self.key_event) #self.agent.event(500, sample_page.next) elif Report.Audio_Test: sample_page.next() Report.Audio_Test = False if AudioTest.PlayTest and AudioTest.RecordTest: Report.Audio_Test = True
def load(self): if Report.Key_Test: sample_page.next() if self.is_load == False: #print(case.load) self.is_load = True sample_page.btn.enable = False sipeed_led.init(13, 12, 14, 32) self.btn = sipeed_button() # self.btn.config(23, 20, 31) self.agent = agent() self.agent.event(150, self.key_event) self.agent.event(16000, lambda: sample_page.next()) KeyTest.home_click = 0 KeyTest.back_click = 0 KeyTest.next_click = 0
def load(self): if Report.Audio_Test: sample_page.next() if self.is_load == False: # i2c init() sample_page.btn.enable = False self.isconnected = False self.isError = None self.is_play = False self.is_record = False self.state = 0 self.fft_amp = None self.btn = sipeed_button() # self.btn.config(23, 20, 31) self.count += 1 self.agent = agent() self.agent.event(150, self.key_event) self.agent.event(500, self.check) self.agent.event(16000, self.test_event) self.is_load = True
def load(): __class__.state = 0 __class__.limit = 100 __class__.count = 0 __class__.ctrl = agent() __class__.ctrl.event(20, __class__.draw) def test_once(self): self.remove(test_once) if __class__.state == 0: __class__.state = 1 __class__.ctrl.event(1000, test_once) def test_task(self): if __class__.state == 0: __class__.state = 1 if __class__.state == 2: __class__.state = 3 __class__.ctrl.event(3000, test_task)
class launcher: alpha = 0 app_select = 0 app_sets = [ icon(40, 50, os.getcwd() + "/res/icons/app_camera.bmp"), icon(140, 50, os.getcwd() + "/res/icons/app_settings.bmp"), icon(40, 150, os.getcwd() + "/res/icons/app_explorer.bmp"), icon(140, 150, os.getcwd() + "/res/icons/app_system_info.bmp") ] btn = sipeed_button() agent = agent() def init(): launcher.agent.event(150, launcher.key_event) def key_event(): launcher.btn.event() if launcher.btn.back() == 1: launcher.app_select -= 1 elif launcher.btn.next() == 1: launcher.app_select += 1 elif launcher.btn.home() == 1: print('start', launcher.app_select) # ui.canvas.draw_string(15, 120, '(%s)' % launcher.app_sets[launcher.app_select]) launcher.app_select = launcher.app_select % 4 # lock pos def draw(): launcher.agent.parallel_cycle() value = math.cos(math.pi * launcher.alpha / 12) * 50 + 200 launcher.alpha = (launcher.alpha + 1) % 24 for pos in range(0, 4): checked = (pos == launcher.app_select) launcher.app_sets[pos].draw(checked, value if checked else 255)
def load(): __class__.state = 0 __class__.lists = ['', '456789', '789abc', 'abcefg', ''] __class__.selected = 0 __class__.limit = 90 __class__.count = 0 __class__.ctrl = agent() __class__.ctrl.event(20, __class__.draw) #def test_once(self): #self.remove(test_once) #if __class__.state == 0: #__class__.state = 1 #__class__.ctrl.event(1000, test_once) def test_task(self): __class__.count = 0 if time.ticks_ms() % 2: __class__.state = 1 else: __class__.state = 3 __class__.ctrl.event(1000, test_task)
@ui.warp_template(ui.bg_in_draw) #@ui.warp_template(ui.anime_in_draw) #@ui.warp_template(taskbar.time_draw) #@ui.warp_template(taskbar.mem_draw) #@catch # need sipeed_button def draw(): ui.display() def event(): self = __class__ self.ctrl.parallel_cycle() if __name__ == "__main__": system = agent() container.reload(shift_view) while True: while True: last = time.ticks_ms() - 1 while True: print(1000 // (time.ticks_ms() - last), 'fps') last = time.ticks_ms() try: gc.collect() container.forever() system.parallel_cycle() protect.keep() #gc.collect() #print_mem_free()
def __init__(self): self.is_load = False self.i2c = I2C(I2C.I2C0, freq=100 * 1000) self.isconnected = False self.agent = agent() self.agent.event(1000, self.check)
class launcher: effect = [] alpha = 0 app_select = 0 app_run = False app_sets = [ Camera(60, 200), System(160, 200), Demo(260, 200), Photo(360, 200), ] toth = Touch(480, 320, 50) btn = sipeed_button() agent = agent() def init(): launcher.agent.event(150, launcher.key_event) launcher.agent.event(50, launcher.touch_event) def touch_event(): launcher.toth.event() #print(launcher.toth.state, launcher.toth.points) if launcher.toth.state == 1: old = launcher.toth.points[0] sel = launcher.toth.points[1] #if len(launcher.effect) > 8: #launcher.effect.pop(0) #launcher.effect.append((old[0], old[1])) if 250 < sel[2] - old[2] and sel[2] - old[2] < 500: launcher.toth.state = 2 if launcher.toth.state == 2: #print(launcher.toth.state, launcher.toth.points) #launcher.effect = [] old = launcher.toth.points[0] sel = launcher.toth.points[1] #print(sel, old, sel[2] - old[2]) if sel[2] - old[2] < 1000: # start #if 136 < sel[1] and sel[1] < 200: for i in range(len(launcher.app_sets)): p = launcher.app_sets[i] x, y = p.x, 320 - p.y # print(x, p.w, y, p.h) if x < sel[0] and sel[1] < y and sel[ 0] < x + p.w and y - p.h < sel[1]: launcher.app_select = i if sel[2] - old[2] < 250: print('launcher.app_select', launcher.app_select) launcher.app_run = True def key_event(): launcher.btn.event() if launcher.btn.back() == 1: launcher.app_select -= 1 elif launcher.btn.next() == 1: launcher.app_select += 1 elif launcher.btn.home() == 1: print('start', launcher.app_select) # launcher.app_run = True # ui.canvas.draw_string(15, 120, '(%s)' % launcher.app_sets[launcher.app_select]) launcher.app_select = launcher.app_select % len( launcher.app_sets) # lock pos a = b'\x00\x00\x03\x03\x07\x07\x0E\x0E\x1C\x1F\x38\x38\x70\xF0\x00\x00\x00\x00\xC0\xC0\xE0\xE0\x70\x70\x38\xF8\x1C\x1C\x0E\x0F\x00\x00' m = b'\x00\x00\x00\x00\x00\x67\x7F\x61\x61\x61\x61\x61\x61\x61\x00\x00\x00\x00\x00\x00\x00\x1C\xFE\x86\x86\x86\x86\x86\x86\x86\x00\x00' i = b'\x00\x00\x01\x00\x00\x01\x01\x01\x01\x01\x01\x01\x01\x01\x00\x00\x00\x00\x80\x00\x00\x80\x80\x80\x80\x80\x80\x80\x80\x80\x00\x00' g = b'\x00\x00\x00\x00\x00\x07\x1C\x18\x38\x1C\x1F\x30\x1F\x30\x70\x1F\x00\x00\x00\x00\x00\xCE\x72\x30\x38\x70\xC0\x00\xF8\x0C\x0E\xF8' o = b'\x00\x00\x00\x00\x00\x03\x1E\x38\x70\x70\x70\x38\x1C\x03\x00\x00\x00\x00\x00\x00\x00\xC0\x78\x1C\x0C\x0E\x0E\x1C\x38\xC0\x00\x00' def draw(): launcher.agent.parallel_cycle() #ui.canvas.draw_rectangle((0, 0, ui.height, ui.weight), #fill = True, color = (0, 0, 0)) #ui.canvas.draw_rectangle((0, 0, ui.height, ui.weight), fill = True, color = (0x70, 0x80, 0x90)) ui.canvas.draw_rectangle((0, 0, ui.height, ui.weight), fill=True, color=(215, 228, 181)) #ui.canvas.draw_rectangle((0, 0, ui.height, ui.weight), #fill = True, color = (37, 40, 55)) #ui.canvas.draw_string(203, 73, "Amigo", #color=(64, 64, 64), scale=8, mono_space=0) ui.canvas.draw_font(182, 82, 16, 16, launcher.a, scale=5, color=(37, 40, 55)) ui.canvas.draw_font(180, 80, 16, 16, launcher.a, scale=5, color=(0x2d, 0x85, 0xf0)) ui.canvas.draw_font(252, 82, 16, 16, launcher.m, scale=4, color=(37, 40, 55)) ui.canvas.draw_font(250, 80, 16, 16, launcher.m, scale=4, color=(0xf4, 0x43, 0x3c)) ui.canvas.draw_font(292, 82, 16, 16, launcher.i, scale=4, color=(37, 40, 55)) ui.canvas.draw_font(290, 80, 16, 16, launcher.i, scale=4, color=(0xff, 0xbc, 0x32)) ui.canvas.draw_font(332, 77, 16, 16, launcher.g, scale=4, color=(37, 40, 55)) ui.canvas.draw_font(330, 75, 16, 16, launcher.g, scale=4, color=(0x0a, 0xa8, 0x58)) ui.canvas.draw_font(392, 82, 16, 16, launcher.o, scale=4, color=(37, 40, 55)) ui.canvas.draw_font(390, 80, 16, 16, launcher.o, scale=4, color=(0xf4, 0x43, 0x3c)) #ui.canvas.draw_string(200, 70, "A", #color=(0x2d, 0x85, 0xf0), scale=8, mono_space=0) #ui.canvas.draw_string(200, 70, " m", #color=(0xf4, 0x43, 0x3c), scale=8, mono_space=0) #ui.canvas.draw_string(200, 70, " i", #color=(0xff, 0xbc, 0x32), scale=8, mono_space=0) #ui.canvas.draw_string(200, 70, " g", #color=(0x0a, 0xa8, 0x58), scale=8, mono_space=0) #ui.canvas.draw_string(200, 70, " o", #color=(0xf4, 0x43, 0x3c), scale=8, mono_space=0) value = math.cos(math.pi * launcher.alpha / 12) * 50 + 200 launcher.alpha = (launcher.alpha + 1) % 24 for pos in range(0, len(launcher.app_sets)): checked = (pos == launcher.app_select) launcher.app_sets[pos].draw(checked, value if checked else 255) #for pos in range(len(launcher.effect)): #tmp = launcher.effect[pos] #cor = (pos + 1) * 32 #ui.canvas.draw_circle(tmp[0], 320 - tmp[1], (pos + 1) * 3, thickness=1, fill=False, color=(cor, cor, cor)) launcher.agent.parallel_cycle()