Example #1
0
    def run():
        # debug into app_select
        # launcher.app_select = 2
        # app.layer = 1

        ui.height, ui.weight = 480, 320
        # button_io.config(23, 20, 31) # amigo tft
        button_io.config(16, 23, 20)  # amigo ips
        sipeed_led.init(14, 15, 17, 32)

        app.i2c3 = I2C(I2C.I2C3, freq=100 * 1000, scl=24, sda=27)
        app.i2c4 = I2C(I2C.I2C4, freq=100 * 1000, scl=9, sda=7)

        TouchLow.config(i2c3=app.i2c3)  # amigo

        #if AXP173_ADDR in i2c.scan():
        axp173 = AXP173(i2c_dev=app.i2c3)
        axp173.enable_adc(True)
        # 默认充电限制在 4.2V, 190mA 档位
        axp173.setEnterChargingControl(True)
        axp173.exten_output_enable()
        # amigo sensor config.
        axp173.writeREG(0x27, 0x20)
        axp173.writeREG(0x28, 0x0C)
        taskbar.init(axp173)

        CubeAudio.init(app.i2c3)
        if CubeAudio.check():
            CubeAudio.ready()
            fm.register(13, fm.fpioa.I2S0_MCLK, force=True)
            fm.register(21, fm.fpioa.I2S0_SCLK, force=True)
            fm.register(18, fm.fpioa.I2S0_WS, force=True)
            fm.register(35, fm.fpioa.I2S0_IN_D0, force=True)
            fm.register(34, fm.fpioa.I2S0_OUT_D2, force=True)

        #app.ctrl.event(100, lambda *args: time.sleep(1))
        #app.ctrl.event(10, app.on_event)
        app.ctrl.event(5, app.draw)
        #ui.enable = False
        while True:
            last = 0
            while True:
                try:
                    # print((int)(1000 / (time.ticks_ms() - last)), 'fps')
                    # last = time.ticks_ms()
                    # print_mem_free()
                    gc.collect()
                    app.ctrl.cycle()
                    protect.keep()
                    #time.sleep(0.1)
                except KeyboardInterrupt:
                    protect.stop()
                    raise KeyboardInterrupt()
                except Exception as e:
                    # gc.collect()
                    print(e)
Example #2
0
 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)
Example #3
0
    def run():
        # debug into app_select
        #launcher.app_select = 0
        #app.layer = 2

        button_io.config()
        sipeed_led.init(13, 12, 14, 32)
        sample_page.key_init()

        fm.register(30, fm.fpioa.I2C1_SCLK, force=True)
        fm.register(31, fm.fpioa.I2C1_SDA, force=True)

        axp173 = AXP173()
        axp173.enable_adc(True)
        # 默认充电限制在 4.2V, 190mA 档位
        axp173.setEnterChargingControl(True)
        axp173.exten_output_enable()
        taskbar.init(axp173)

        if CubeAudio.check():
            CubeAudio.ready()
            fm.register(19, fm.fpioa.I2S0_MCLK, force=True)
            fm.register(35, fm.fpioa.I2S0_SCLK, force=True)
            fm.register(33, fm.fpioa.I2S0_WS, force=True)
            fm.register(34, fm.fpioa.I2S0_IN_D0, force=True)
            fm.register(18, fm.fpioa.I2S0_OUT_D2, force=True)

        #app.ctrl.event(100, lambda *args: time.sleep(1))
        #app.ctrl.event(10, app.btn.event)
        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()
                    #print_mem_free()
                    gc.collect()
                    app.ctrl.cycle()
                    protect.keep()
                    #time.sleep(0.1)
                except KeyboardInterrupt:
                    protect.stop()
                    raise KeyboardInterrupt()
                except Exception as e:
                    # gc.collect()
                    print(e)
Example #4
0
            ai_camera.reload()
            ai_camera.replace = False

        tmp = camera.obj.get_image()
        if ai_camera.model and ai_camera.model.is_load:
            ai_camera.model.work(tmp)

        ui.canvas.draw_image(tmp, 0, 0)


ai_camera.reload()

if __name__ == "__main__":

    ui.height, ui.weight = 480, 320
    button_io.config(23, 31, 20)  # amigo

    def test_ai_camera():
        @ui.warp_template(ui.blank_draw)
        @ui.warp_template(ai_camera.ai_draw)
        def app_main():
            ui.display()

        import time
        last = time.ticks_ms()
        while True:
            kpu.memtest()
            try:
                print(time.ticks_ms() - last)
                last = time.ticks_ms()
                app_main()
Example #5
0
    ui.canvas.draw_string(10, 225, str(CubeListBox.info), scale=1)

    CubeListBox.process = CubeListBox.process + 1 % 24
    tmp = 5 * math.cos(CubeListBox.process * (math.pi / 12))

    view_len = len(CubeListBox.files)
    if view_len > CubeListBox.limit:
        view_len = CubeListBox.limit

    for i in range(view_len):
        pos = draw_dialog_alpha(ui.canvas, 20, int(tmp) + 40 + i * 50, 200, 20, 10, color=(0,255,0) if CubeListBox.selected == i else (255, 0, 0), alpha=255 - i * 30)
        ui.canvas.draw_string(pos[0] + 10, pos[1] + 10, CubeListBox.files[i], scale=2, color=(0,0,0))

if __name__ == "__main__":
    button_io.config(10, 11, 16) # cube
    CubeListBox.btn.Limit = 250
    @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(CubeListBox.on_draw)
    def unit_test():
      ui.display()

    import time
    last = time.ticks_ms()
    while True:
        print(time.ticks_ms() - last)
        last = time.ticks_ms()
        # gc.collect()
Example #6
0
    def run():
        # debug into app_select
        #launcher.app_select = 0
        #app.layer = 2

        ui.height, ui.weight = 480, 320
        button_io.config(23, 31, 20) # amigo
        cube_led.init(14, 15, 17, 32)


        app.i2c0 = I2C(I2C.I2C0, freq=100*1000)
        app.i2c1 = I2C(I2C.I2C1, freq=100*1000)
        fm.register(24,fm.fpioa.I2C1_SCLK, force=True)
        fm.register(27,fm.fpioa.I2C1_SDA, force=True)

        print('monkey patch & config for i2c')
        TouchLow.config(i2c1=app.i2c1) # amigo

        for i in range(100):
            try:
                tmp = fm.fpioa.get_Pin_num(fm.fpioa.I2C1_SDA)
                fm.register(tmp, fm.fpioa.GPIOHS15)
                sda = GPIO(GPIO.GPIOHS15, GPIO.OUT)
                sda.value(1)
                fm.register(tmp, fm.fpioa.I2C1_SDA, force=True)

                #if AXP173_ADDR in i2c.scan():
                axp173 = AXP173(i2c_dev=app.i2c1)
                axp173.enable_adc(True)
                # 默认充电限制在 4.2V, 190mA 档位
                axp173.setEnterChargingControl(True)
                axp173.exten_output_enable()
                # amigo sensor config.
                axp173.writeREG(0x27, 0x20)
                axp173.writeREG(0x28, 0x0C)
                taskbar.init(axp173)

                break
            except Exception as e:
                # gc.collect()
                pass

                #if i == 99:
                    #raise(e)

        if CubeAudio.check():
            CubeAudio.ready()
            fm.register(13,fm.fpioa.I2S0_MCLK, force=True)
            fm.register(21,fm.fpioa.I2S0_SCLK, force=True)
            fm.register(18,fm.fpioa.I2S0_WS, force=True)
            fm.register(35,fm.fpioa.I2S0_IN_D0, force=True)
            fm.register(34,fm.fpioa.I2S0_OUT_D2, force=True)

        #app.ctrl.event(100, lambda *args: time.sleep(1))
        #app.ctrl.event(10, app.on_event)
        app.ctrl.event(5, app.draw)
        #ui.enable = False
        while True:
            last = 0
            while True:
                try:
                    # gc.collect()
                    print((int)(1000 / (time.ticks_ms() - last)), 'fps')
                    last = time.ticks_ms()
                    #print_mem_free()
                    app.ctrl.cycle()
                    protect.keep()
                    #time.sleep(0.1)
                except KeyboardInterrupt:
                    protect.stop()
                    raise KeyboardInterrupt()
                except Exception as e:
                    # gc.collect()
                    print(e)
Example #7
0
                FaceReco.is_load = False
                gc.collect()
        except Exception as e:
            print(e)  # see py_kpu_deinit error will mp_raise_TypeError


if __name__ == "__main__":
    try:
        from ui_canvas import ui
    except ImportError:
        from ui.ui_canvas import ui

    ui.height, ui.weight = 480, 320
    # button_io.config(10, 11, 16) # cube
    button_io.config(23, 31, 20)  # amigo 3.8M 750*1024

    @ui.warp_template(ui.blank_draw)  # first draw
    def app_main():
        # second draw
        tmp = camera.obj.get_image()
        FaceReco.work(tmp)
        ui.canvas.draw_image(tmp, 0, 0)
        ui.display()  # third display

    def unit_test():
        gc.collect()
        kpu.memtest()
        FaceReco.load()
        kpu.memtest()
        import time
Example #8
0
    except Exception as e:
        with open('/flash/config.json', "w") as f:
            f.write(cfg)
        import machine
        machine.reset()

    protect.keep()

    import time, gc
    # gc.collect()
    # gc.collect()
    if len(sample_page.samples) > 0:
        sample_page.samples = []
        # gc.collect()

    button_io.config(10, 11, 16)
    sample_page.key_init()

    sample_page.add_sample(Report())  # keep

    sample_page.add_sample(AudioReport())
    sample_page.add_sample(AudioTest())

    sample_page.add_sample(RearSensorReport())
    sample_page.add_sample(RearSensorTest())

    sample_page.add_sample(KeyReport())
    sample_page.add_sample(KeyTest())

    sample_page.add_sample(WaitTestStart())