コード例 #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
ファイル: app_cube_old.py プロジェクト: vamoosebbf/MaixUI
    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)
コード例 #3
0
 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)
コード例 #4
0
    def run():
        CubeAudio.ready()
        # CubeAudio.load("/flash/1k.wav", 100)
        #app.ctrl.event(100, lambda *args: time.sleep(1))
        app.ctrl.event(10, app.draw)

        while True:
            import time
            last = time.ticks_ms()
            while True:
                try:
                    #print((int)(1000 / (time.ticks_ms() - last)), 'fps')
                    print((int)((time.ticks_ms() - last)))
                    last = time.ticks_ms()
                    app.ctrl.parallel_cycle()
                    protect.keep()
                    #time.sleep(0.1)
                except KeyboardInterrupt:
                    protect.stop()
                    raise KeyboardInterrupt()
                except Exception as e:
                    # gc.collect()
                    print(e)
コード例 #5
0
ファイル: app_main.py プロジェクト: denise-amiga/MaixUI
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
コード例 #6
0
ファイル: app_amigo.py プロジェクト: junhuanchen/MaixUI
    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)