Exemplo n.º 1
0
 def test_minist():
     tmp = camera.obj.get_image()
     Minist.work(tmp)
     ui.canvas.draw_image(tmp, 0, 0)
     ui.canvas.draw_string(5, ui.weight - 20, 'minist result > %d : %.2f' %
                           (Minist.result, Minist.score), scale=2, color=(255, 255, 255))
     ui.display()
Exemplo n.º 2
0
    def test_ai_camera():
        @ui.warp_template(ui.blank_draw)
        def test_minist():
            tmp = camera.obj.get_image()
            Minist.work(tmp)
            ui.canvas.draw_image(tmp, 0, 0)
            ui.canvas.draw_string(5,
                                  ui.weight - 20,
                                  'minist result > %d : %.2f' %
                                  (Minist.result, Minist.score),
                                  scale=2,
                                  color=(255, 255, 255))
            ui.display()

        import time
        last = time.ticks_ms()
        Minist.load()
        while True:
            try:
                print(time.ticks_ms() - last)
                last = time.ticks_ms()
                test_minist()
            except KeyboardInterrupt as e:
                Minist.free()
                ui.display()
                break
Exemplo n.º 3
0
    def draw_photos():
        if photos.photos_len() > 0:

            if app.photos_title != photos.image_path():
                app.photos_title = photos.image_path()
                if app.photos_temp != None:
                    tmp = app.photos_temp
                    del tmp
                    app.photos_temp = None
            if app.photos_temp:
                ui.canvas.draw_image(app.photos_temp, 0, 0)
            else:
                app.photos_temp = image.Image(app.photos_title)

            # [mem < 800*1024]
            #t, ui.canvas = ui.canvas, None
            #del t
            #ui.canvas = image.Image(photos.image_path())

            ui.canvas.draw_string(2,
                                  2,
                                  app.photos_title,
                                  color=(255, 255, 255),
                                  scale=1,
                                  mono_space=0)
        else:
            ui.canvas.draw_string(40,
                                  120,
                                  "Please put pictures\n in '/sd/imgs' folder",
                                  color=(255, 255, 255),
                                  scale=3,
                                  mono_space=0)
        app.touch_draw()
        ui.display()
Exemplo n.º 4
0
 def draw_camera():
     try:
         ai_camera.ai_draw()
         ui.display()
     except Exception as e:
         app.layer = 1
         raise e
Exemplo n.º 5
0
    def draw_camera():
        try:
            ai_camera.ai_draw()
            for model in ai_camera.models:
                #print(model.__qualname__, ai_camera.model.__qualname__)
                if 'ai_sample' == ai_camera.model.__qualname__:
                    ui.canvas.draw_string(60, 170, "AI Demo", scale=3)
                    ui.canvas.draw_string(10,
                                          210,
                                          "Press (<) or (>) to View",
                                          scale=2)
                    pass

                elif 'FaceReco' == ai_camera.model.__qualname__:

                    if ai_camera.model.bbox != None:
                        bbox = ai_camera.model.bbox
                        ui.canvas.draw_string(10,
                                              210,
                                              "Find Face %d" % len(bbox),
                                              scale=2)
                    else:
                        ui.canvas.draw_string(10,
                                              210,
                                              "Find Face Reco",
                                              scale=2)

                elif 'find_color' == ai_camera.model.__qualname__:

                    ui.canvas.draw_string(10,
                                          210,
                                          "Find Color For Red", (255, 0, 0),
                                          scale=2)

                elif 'HowMany' == ai_camera.model.__qualname__:

                    if ai_camera.model.things != None:
                        ui.canvas.draw_string(10,
                                              210,
                                              "How many %d" %
                                              len(ai_camera.model.things),
                                              scale=2)

                    ui.canvas.draw_string(10, 210, "How many?", scale=2)

                elif 'MaybeIs' == ai_camera.model.__qualname__:

                    ui.canvas.draw_string(10,
                                          210,
                                          "Maybe Is %s" %
                                          str(ai_camera.model.result),
                                          scale=2)

            ui.display()
        except Exception as e:
            app.layer = 1
            gc.collect()
            raise e
Exemplo n.º 6
0
    def draw():
        l, r, w, h = 60, 60, 120, 120
        if __class__.state == 0:
            __class__.count += 1
            value = abs(int(get_count_curve(__class__.count, 3, 50) * 10))
            #print(value)

            pos = draw_dialog_alpha(ui.canvas,
                                    l - value // 2,
                                    r - value // 2,
                                    w + value,
                                    h + value,
                                    10,
                                    color=(255, 0, 0),
                                    alpha=230)
            if value >= 9:
                __class__.state = 1

        if __class__.state == 1:

            pos = draw_dialog_alpha(ui.canvas,
                                    l,
                                    r,
                                    w,
                                    h,
                                    10,
                                    color=(255, 0, 0),
                                    alpha=230)
            text = "It will show Message , return last pages after 3s"

            chunks, chunk_size = len(text), w // 12
            msg_lines = [
                text[i:i + chunk_size] for i in range(0, chunks, chunk_size)
            ]
            for i in range(len(msg_lines)):
                ui.canvas.draw_string(pos[0] + 16,
                                      pos[1] + 8 + 26 * i,
                                      msg_lines[i],
                                      scale=2,
                                      color=(0, 0, 0))

        if __class__.state == 2:
            __class__.count += 1
            value = abs(int(get_count_curve(__class__.count, 3, 50) * 10))

            pos = draw_dialog_alpha(ui.canvas,
                                    l - value // 2,
                                    r - value // 2,
                                    w + value,
                                    h + value,
                                    10,
                                    color=(255, 0, 0),
                                    alpha=230)
            if value == 0:
                container.latest()

        ui.display()
Exemplo n.º 7
0
    def test_pmu_axp173_draw():
        global axp173
        tmp = []

        work_mode = axp173.getPowerWorkMode()
        tmp.append("WorkMode:" + hex(work_mode))

        # 检测 电池电压
        vbat_voltage = axp173.getVbatVoltage()
        tmp.append("vbat_voltage: {0} V".format(vbat_voltage))

        # 检测 电池充电电流
        BatteryChargeCurrent = axp173.getBatteryChargeCurrent()
        tmp.append(
            "BatChargeCurrent: {0:>4.1f}mA".format(BatteryChargeCurrent))

        # 检测 USB-ACIN 电压
        usb_voltage = axp173.getUSBVoltage()
        tmp.append("usb_voltage: {0:>4}mV".format(usb_voltage))

        # 检测 USB-ACIN 电流
        USBInputCurrent = axp173.getUSBInputCurrent()
        tmp.append("USBInputCurrent: {0:>4.1f}mA".format(USBInputCurrent))

        ### 检测 VBUS 电压
        #usb_voltage = axp173.getConnextVoltage()
        #print("6 VUBS_voltage: " + str(usb_voltage))

        ### 检测 VBUS 电流
        #USBInputCurrent = axp173.getConnextInputCurrent()
        #print("7 VUBSInputCurrent: " + str(USBInputCurrent) + "mA")

        getChargingControl = axp173.getChargingControl()
        tmp.append("ChargingControl: {}".format(hex(getChargingControl)))

        # 检测 是否正在充电
        if axp173.is_charging() == True:
            tmp.append("Charging....")
        else:
            tmp.append("Not Charging")
        tmp.append(axp173.is_charging())

        # 检测 USB 是否连接
        if axp173.is_usb_plugged_in() == 1:
            tmp.append("USB plugged ....")

        else:
            tmp.append("USB is not plugged in")

        for i in range(len(tmp)):
            print(tmp[i])
            ui.canvas.draw_string(20,
                                  20 + 20 * i,
                                  "{0}".format(str(tmp[i])),
                                  mono_space=1)

        ui.display()
Exemplo n.º 8
0
 def draw_explorer():
     # if explorer.info != "":
     #     protect.stop()
     #     print(explorer.get_path(explorer.paths) + '/' + explorer.info)
     #     # with open(explorer.get_path(explorer.paths) + '/' + tmp, 'rb') as target:
     #     #     # exec(target.read(), locals())
     #     #     exec(target.read())
     #     execfile(explorer.get_path(explorer.paths) + '/' + explorer.info)
     #     protect.start()
     ui.display()
Exemplo n.º 9
0
 def moblienet():
     tmp = camera.obj.get_image()
     MoblieNet.work(tmp)
     ui.canvas.draw_image(tmp, 0, 0)
     ui.canvas.draw_string(0,
                           ui.weight - 25,
                           '%.2f:%s' %
                           (MoblieNet.score, MoblieNet.result.strip()),
                           scale=2,
                           color=(0, 255, 0))
     ui.display()
Exemplo n.º 10
0
    def draw_camera():
        try:
            ai_camera.ai_draw()
            for model in ai_camera.models:
              #print(model.__qualname__, ai_camera.model.__qualname__)
              if 'ai_sample' == ai_camera.model.__qualname__:
                  ui.canvas.draw_string(340, 80, "  AI\nDemo", scale=5)
                  ui.canvas.draw_string(50, 260, "Press Left (<) or Right (>) to View", scale=2)
                  pass

              elif 'FaceReco' == ai_camera.model.__qualname__:

                    if ai_camera.model.bbox != None:
                        bbox = ai_camera.model.bbox
                        ui.canvas.draw_string(50, 260, "Find Face %d" % len(bbox), scale=5)
                        for pos in range(len(bbox)):
                            i = bbox[pos]
                            # print(i.x(), i.y(), i.w(), i.h())
                            face_cut = ui.canvas.cut(i.x(), i.y(), i.w(), i.h())
                            face_cut_128 = face_cut.resize(80, 80)
                            ui.canvas.draw_image(face_cut_128, 320 + int((pos % 2)*80), int((pos // 2)*80))
                    else:
                        ui.canvas.draw_string(50, 260, "Find Face Reco", scale=5)

              elif 'find_color' == ai_camera.model.__qualname__:

                    ui.canvas.draw_string(50, 260, "Find Color For Red (53, 31, 44, 82, 18, 78)", scale=2)
                    ui.canvas.draw_string(50, 260, "                         Red", color=(255,0,0), scale=2)

                    ui.canvas.draw_string(340, 30, "Red\nSum\n  %d" % len(ai_camera.model.blobs), scale=5)

              elif 'HowMany' == ai_camera.model.__qualname__:

                    if ai_camera.model.things != None:
                        ui.canvas.draw_string(340, 30, "How\nMany\n  %d" % len(ai_camera.model.things), scale=5)

                    ui.canvas.draw_string(50, 260, "How many things are there?", scale=2)

              elif 'MaybeIs' == ai_camera.model.__qualname__:

                    ui.canvas.draw_string(340, 50, "Maybe\n   Is\n", scale=3)
                    ui.canvas.draw_string(340, 150, "%s" % str(ai_camera.model.result), scale=2)
                    ui.canvas.draw_string(50, 260, "What is likely to be?", scale=2)

            app.touch_draw()
            ui.display()
        except Exception as e:
            # ai_camera.next()
            # protect.restart() # temp patch
            app.layer -= 1
            raise Exception("This is a Easter egg(Known Bug) This error requires a  restart. It will soon be resolved. :)")
Exemplo n.º 11
0
 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()
Exemplo n.º 12
0
    def draw_pages():
        if app.current != None:
            app.current.draw()

        app.loop = (app.loop + 1) % 200

        value = math.cos(math.pi * app.loop / 12) * 2 + 20
        for i in range(100):
            try:
                #ui.canvas.draw_rectangle((240, 0, 240, 320), fill=False, thickness=3, color=(175, 175, 175))
                if app.msa301 != None:
                    accel = app.msa301.acceleration
                    x, y = 240, 160  # center
                    #print(accel)
                    ui.canvas.draw_circle(
                        x + int(accel[0] * 15),
                        y + int(accel[1] * 20),
                        int(value),
                        fill=True,
                        color=(150 + int(accel[0] * 20),
                               150 + int(accel[1] * 20),
                               100 + int(accel[2] * 20)))  # 10ms
                    ui.canvas.draw_circle(x + int(accel[0] * 15),
                                          y + int(accel[1] * 20),
                                          int(value) + 1,
                                          thickness=3,
                                          fill=False,
                                          color=(0, 0, 0))  # 10ms
                else:

                    app.msa301 = MSA301(app.i2c3)
                break
            except Exception as e:
                pass
                # gc.collect()
        #ui.canvas.draw_string(240 + 10, 140, "x", (255, 0, 0), scale=2)
        #ui.canvas.draw_string(240 + 10, 140, "x", (255, 0, 0), scale=2)
        #ui.canvas.draw_line(240 + 120, 150, 120 + int(accel[0] * 8), 150, color=(41, 131, 255))
        #ui.canvas.draw_string(240 + 10, 160, "y", (0, 255, 0), scale=2)
        #ui.canvas.draw_line(240 + 120, 170, 120 + int(accel[1] * 8), 170, color=(141, 31, 255))
        #ui.canvas.draw_string(240 + 10, 180, "z", (0, 0, 255), scale=2)
        #ui.canvas.draw_line(240 + 120, 190, 120 + int(accel[2] * 8), 190, color=(241, 131, 55))

        ui.display()
Exemplo n.º 13
0
    def draw():
        x, y, w, h = -80, 210, 400, 40

        v = 0

        if __class__.state == 1:
            __class__.count += 1
            v = (int(
                get_count_curve(__class__.count, 2, 120) * __class__.limit))
            if v > __class__.limit // 2:
                __class__.state = 2

        if __class__.state == 3:
            __class__.count -= 1
            v = -(int(
                get_count_curve(__class__.count, 2, 120) * __class__.limit))
            if v < -__class__.limit // 2:
                __class__.state = 4

        tmp = image.Image(size=(w, h))
        tmp.draw_rectangle((0, 0, w, h), fill=True, color=(120, 120, 120))
        for i in range(0, w, 80):
            c = (200, 200, 200)
            if i == 160:
                c = (255, 255, 255)
            tmp.draw_string(i + 5,
                            5,
                            __class__.lists[i // 80],
                            scale=2,
                            color=c)
        ui.canvas.draw_image(tmp, x - v, y, alpha=255)
        del tmp

        if __class__.state == 2:
            if __class__.lists[-2] != '':
                __class__.lists.append(__class__.lists.pop(0))
            __class__.state = 0

        if __class__.state == 4:
            if __class__.lists[1] != '':
                __class__.lists.insert(0, __class__.lists.pop(-1))
            __class__.state = 0

        ui.display()
Exemplo n.º 14
0
 def draw_pages():
     if app.current != None:
         app.current.draw()
     ui.display()
Exemplo n.º 15
0
 def draw_launcher():
     ui.display()
Exemplo n.º 16
0
    def draw_load():

        app.loop = (app.loop + 1) % 200

        value = math.cos(math.pi * app.loop / 8) * 6

        #print(value)
        if app.loading or app.loop > 20:

            ui.canvas.draw_string(200 - int(value) * 2,
                                  68 + (int(value) % 8) * 2,
                                  "A",
                                  color=(64, 64, 64),
                                  scale=8,
                                  mono_space=0)
            ui.canvas.draw_string(200 - int(value),
                                  72 + (int(value) % 8),
                                  "A",
                                  color=(0x2d, 0x85, 0xf0),
                                  scale=8,
                                  mono_space=0)
        else:
            ui.canvas.draw_string(203,
                                  73,
                                  "A",
                                  color=(64, 64, 64),
                                  scale=8,
                                  mono_space=0)

        if app.loading or app.loop > 40:

            ui.canvas.draw_string(203,
                                  72 - int(value) * 5 - 9,
                                  "  m",
                                  color=(64, 64, 64),
                                  scale=8,
                                  mono_space=0)
            ui.canvas.draw_string(200,
                                  70 - int(value) * 4 - 8,
                                  "  m",
                                  color=(0xf4, 0x43, 0x3c),
                                  scale=8,
                                  mono_space=0)
        else:
            ui.canvas.draw_string(203,
                                  72,
                                  "  m",
                                  color=(64, 64, 64),
                                  scale=8,
                                  mono_space=0)

        if app.loading or app.loop > 40:

            ui.canvas.draw_string(203,
                                  72,
                                  "    i",
                                  color=(64, 64, 64),
                                  scale=8,
                                  mono_space=0)
            ui.canvas.draw_string(200,
                                  70,
                                  "    i",
                                  color=(0xff, 0xbc, 0x32),
                                  scale=8,
                                  mono_space=0)

            ui.canvas.draw_rectangle((304, 77, 12, 12),
                                     color=(0x70, 0x70, 0x70),
                                     fill=True)

            ui.canvas.draw_string(259,
                                  44 + int(value),
                                  "    .    ",
                                  color=(64, 64, 64),
                                  scale=4,
                                  mono_space=0)
            ui.canvas.draw_string(256,
                                  42 + int(value),
                                  "    .    ",
                                  color=(0xff, 0xbc, 0x32),
                                  scale=4,
                                  mono_space=0)
        else:
            ui.canvas.draw_string(203,
                                  72,
                                  "    i",
                                  color=(64, 64, 64),
                                  scale=8,
                                  mono_space=0)
            ui.canvas.draw_rectangle((304, 77, 12, 12),
                                     color=(0x70, 0x70, 0x70),
                                     fill=True)
            ui.canvas.draw_string(259,
                                  44,
                                  "    .    ",
                                  color=(64, 64, 64),
                                  scale=4,
                                  mono_space=0)

        if app.loading or app.loop > 60:

            ui.canvas.draw_string(203 + int(value) * 2 + 10,
                                  72,
                                  "     g",
                                  color=(64, 64, 64),
                                  scale=8,
                                  mono_space=0)
            ui.canvas.draw_string(200 + int(value) * 2 + 10,
                                  70,
                                  "     g",
                                  color=(0x0a + int(value) * 50, 0xa8,
                                         0x58 + int(value) * 50),
                                  scale=8,
                                  mono_space=0)
        else:
            ui.canvas.draw_string(203,
                                  72,
                                  "     g",
                                  color=(64, 64, 64),
                                  scale=8,
                                  mono_space=0)

        if app.loading or app.loop > 60:

            ui.canvas.draw_string(203 - int(value) * 2 + 20,
                                  72,
                                  "       o",
                                  color=(64, 64, 64),
                                  scale=8,
                                  mono_space=0)
            ui.canvas.draw_string(200 - int(value) * 2 + 20,
                                  70,
                                  "       o",
                                  color=(0xf4, 0x43 + int(value) * 50, 0x3c),
                                  scale=8,
                                  mono_space=0)
        else:
            ui.canvas.draw_string(203,
                                  72,
                                  "       o",
                                  color=(64, 64, 64),
                                  scale=8,
                                  mono_space=0)

        if app.loading == False and app.loop < 20:

            ui.canvas.draw_string(203,
                                  73,
                                  "Amigo",
                                  color=(64 + int(value) * 2,
                                         64 + int(value) * 2,
                                         64 + int(value) * 2),
                                  scale=8,
                                  mono_space=0)

        if app.loop > 70:
            app.loading = True
            ui.canvas.draw_string(320,
                                  280,
                                  "Now Loading...",
                                  color=(164 + int(value) * 8,
                                         164 + int(value) * 8,
                                         164 + int(value) * 8),
                                  scale=2,
                                  mono_space=0)

        if app.loop == 100:
            app.layer += 1

        ui.display()
Exemplo n.º 17
0
 def app_main():
     # second draw
     tmp = camera.obj.get_image()
     FaceReco.work(tmp)
     ui.canvas.draw_image(tmp, 0, 0)
     ui.display()  # third display
Exemplo n.º 18
0
 def draw():
     ui.display()
Exemplo n.º 19
0
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
Exemplo n.º 20
0
    def test_ai_camera():

        @ui.warp_template(ui.blank_draw)
        def howmany():
            tmp = camera.obj.get_image()
            HowMany.work(tmp)
            ui.canvas.draw_image(tmp, 0, 0)
            ui.display()

        @ui.warp_template(ui.blank_draw)
        def maybe():
            tmp = camera.obj.get_image()
            MaybeIs.work(tmp)
            ui.canvas.draw_image(tmp, 0, 0)
            ui.display()

        @ui.warp_template(ui.blank_draw)
        def moblienet():
            tmp = camera.obj.get_image()
            MoblieNet.work(tmp)
            ui.canvas.draw_image(tmp, 0, 0)
            ui.canvas.draw_string(0, ui.weight - 25, '%.2f:%s' % (MoblieNet.score, MoblieNet.result.strip()), scale=2, color=(0, 255, 0))
            ui.display()

        import time
        last = time.ticks_ms()
        while True:
            #try:
                #HowMany.load()
                #while True:
                    #try:
                        #print(time.ticks_ms() - last)
                        #last = time.ticks_ms()
                        #howmany()
                    #except Exception as e:
                        ## gc.collect()
                        #print(e)
            #except KeyboardInterrupt as e:
                #HowMany.free()
                ##break
            #try:
                #MaybeIs.load()
                #while True:
                    #try:
                        #print(time.ticks_ms() - last)
                        #last = time.ticks_ms()
                        #maybe()
                    #except Exception as e:
                        ## gc.collect()
                        #print(e)
            #except KeyboardInterrupt as e:
                #MaybeIs.free()
                ##break
            MoblieNet.load()
            while True:
                try:
                    print(time.ticks_ms() - last)
                    last = time.ticks_ms()
                    moblienet()
                except KeyboardInterrupt as e:
                    MoblieNet.free()
                    ui.display()
                    break
Exemplo n.º 21
0
 def app_main():
     ui.display()
Exemplo n.º 22
0
 def app_main():
     tmp = camera.obj.get_image()
     find_color.work(tmp)
     ui.canvas.draw_image(tmp, 0, 0)
     ui.display()
Exemplo n.º 23
0
 def draw_load():
     ui.display()
Exemplo n.º 24
0
 def unit_test():
     print('1 display : ' + str(gc.mem_free() / 1024) + ' kb')
     ui.display()
     print('2 display : ' + str(gc.mem_free() / 1024) + ' kb')
Exemplo n.º 25
0
 def maybe():
     tmp = camera.obj.get_image()
     MaybeIs.work(tmp)
     ui.canvas.draw_image(tmp, 0, 0)
     ui.display()
Exemplo n.º 26
0
 def howmany():
     tmp = camera.obj.get_image()
     HowMany.work(tmp)
     ui.canvas.draw_image(tmp, 0, 0)
     ui.display()
Exemplo n.º 27
0
    def draw_demo():
        app.loop = (app.loop + 1) % 200
        value = math.cos(math.pi * app.loop / 16) * 10

        ui.canvas.draw_string(10,
                              5,
                              "Seeed Grove",
                              color=(40 + int(value) * 2, 240 + int(value) * 2,
                                     40 + int(value) * 2),
                              scale=3,
                              mono_space=0)

        try:
            CubeAudio.event()
            if app.isconnected == False:
                CubeAudio.event()

                if app.loop % 5 == 1:
                    result = app.i2c4.scan()
                    ui.canvas.draw_string(290,
                                          80,
                                          "Scan Dev: " + str(result),
                                          color=(140 + int(value) * 5,
                                                 240 + int(value) * 5,
                                                 140 + int(value) * 5),
                                          scale=2,
                                          mono_space=0)

                    if SHT3x_ADDR in result:
                        app.sht3x = SHT3x(app.i2c4, SHT3x_ADDR)
                        app.isconnected = True
                    CubeAudio.event()
                    if SHT31_ADDR in result:
                        app.sht3x = SHT3x(app.i2c4, SHT31_ADDR)
                        app.isconnected = True
                    CubeAudio.event()

                ui.canvas.draw_string(
                    280,
                    25,
                    "Wait Grove Sensor \n sht31/35 <<<  <<  <-",
                    color=(140 + int(value) * 5, 240 + int(value) * 5,
                           140 + int(value) * 5),
                    scale=2,
                    mono_space=0)

                if CubeAudio.event() == False:

                    value = math.cos(math.pi * app.loop / 100) * 50

                    tmp = int(value)
                    #print(value)

                    ui.canvas.draw_circle(0,
                                          0,
                                          100 + tmp,
                                          fill=False,
                                          color=(0, (150 + tmp) + 10, 0))
                    ui.canvas.draw_circle(0,
                                          0,
                                          100 + tmp * 2,
                                          fill=False,
                                          color=(0, (150 + tmp) + 20, 0))
                    ui.canvas.draw_circle(0,
                                          0,
                                          100 + tmp * 3,
                                          fill=False,
                                          color=(0, (150 + tmp) + 30, 0))
                    ui.canvas.draw_circle(0,
                                          0,
                                          100 + tmp * 4,
                                          fill=False,
                                          color=(0, (150 + tmp) + 40, 0))

            else:
                data = app.sht3x.read_temp_humd()
                # print(data)
                if app.sidu == None:
                    app.sidu = image.Image(os.getcwd() +
                                           "/res/images/sidu.jpg")

                ui.canvas.draw_circle(350,
                                      160,
                                      100,
                                      fill=True,
                                      color=(255, 255, 255))
                ui.canvas.draw_image(app.sidu,
                                     270,
                                     60,
                                     alpha=235 + int(value) * 2)
                ui.canvas.draw_string(330,
                                      190,
                                      "%.2d" % data[1],
                                      scale=4,
                                      color=(80, 80, 80))

                ui.canvas.draw_rectangle(60,
                                         60,
                                         180,
                                         200,
                                         thickness=4,
                                         color=(155, 155, 155))
                if len(app.points) > 18:
                    app.points.pop(0)
                elif data[0] > 1 and app.temp != int(data[0] * 10):
                    app.temp = int(data[0] * 10)
                    app.points.append(app.temp)
                for p in range(len(app.points)):
                    #print(app.points)
                    if p < 1:
                        b = (60 + int(10 * (p))), 450 - app.points[p]
                        ui.canvas.draw_circle(b[0],
                                              b[1],
                                              3,
                                              fill=True,
                                              color=(255, 155, 150))
                    else:
                        a, b = ((60 + int(10 * (p - 1))), 450 -
                                app.points[p - 1]), ((60 + int(10 * (p))),
                                                     450 - app.points[p])
                        ui.canvas.draw_circle(b[0],
                                              b[1],
                                              3,
                                              fill=False,
                                              color=(155, 155, 155))
                        ui.canvas.draw_line(a[0],
                                            a[1],
                                            b[0],
                                            b[1],
                                            thickness=4,
                                            color=(255, 255, 255))

                ui.canvas.draw_string(
                    60,
                    280,
                    "Average temperature: %s" %
                    str(sum(app.points) / len(app.points) / 10.0),
                    color=(240 + int(value) * 5, 240 + int(value) * 5,
                           240 + int(value) * 5),
                    scale=2,
                    mono_space=0)

            CubeAudio.event()
            ui.display()
        except Exception as e:
            app.layer = 1
            app.isconnected = False
            app.points = []
            raise e
Exemplo n.º 28
0
 def draw_samples():
     ui.display()
Exemplo n.º 29
0
 def unit_test():
     ui.display()
Exemplo n.º 30
0
    def draw():
        __class__.show_slide()

        ui.display()