示例#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)
示例#2
0
def read_cb(drv, ptr):
    # print(ptr, b)
    data = lv.indev_data_t.cast(ptr)
    TOUCH.event()
    if DEBUG:
        print(TOUCH.state, TOUCH.points)
    data.point = lv.point_t({'x': TOUCH.points[1][0], 'y': TOUCH.points[1][1]})
    data.state = lv.INDEV_STATE.PR if TOUCH.state == 1 else lv.INDEV_STATE.REL
    return False

if config_touchscreen_support:
    i2c = I2C(I2C.I2C0, freq=1000*1000, scl=24, sda=27)  # 24 27)
    devices = i2c.scan()
    print("devs", devices)  # devs 0 [16, 38, 52, 56]
    TouchLow.config(i2c)
    TOUCH = Touch(480, 320, 200)

lv.init()

disp_buf1 = lv.disp_buf_t()
buf1_1 = bytearray(320*10)
lv.disp_buf_init(disp_buf1,buf1_1, None, len(buf1_1)//4)
disp_drv = lv.disp_drv_t()
lv.disp_drv_init(disp_drv)
disp_drv.buffer = disp_buf1

disp_drv.flush_cb = lv_h.flush
if board_m1n:
    disp_drv.hor_res = 240
    disp_drv.ver_res = 240
示例#3
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)
示例#4
0
        #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()


launcher.init()

if __name__ == "__main__":
    from ui_canvas import ui
    ui.height, ui.weight = 480, 320
    button_io.config(23, 31, 20)  # amigo
    TouchLow.config(I2C(I2C.I2C3, freq=1000 * 1000, scl=24, sda=27))  # amigo

    @ui.warp_template(ui.blank_draw)
    @ui.warp_template(launcher.draw)
    @ui.warp_template(ui.bg_in_draw)
    def unit_test():
        ui.display()

    import time
    last = time.ticks_ms()
    while True:
        #print(time.ticks_ms() - last)
        last = time.ticks_ms()
        unit_test()
        #time.sleep(0.5)