Ejemplo n.º 1
0
def updateSelect():
    global g_clock
    global g_cButton
    global g_cWab
    global g_cFiler

    g_clock.tick()

    g_cButton.update()
    #print(g_clock.fps())

    if (fileTestUpdate()):
        tmpInfoList = g_cFiler.getInfoList()
        info = tmpInfoList[g_selCnt]
        classStr = ''
        classList = info.classList
        for cl in classList:
            classStr += cl + ','
        lcd.draw_string(0, 0, classStr, lcd.WHITE, lcd.BLACK)
        fullPath = 'models/' + info.dirName + '/' + info.wavName
        spcStr = '                          '
        sttCnt = min(max(0, len(tmpInfoList) - SEL_DISP_NUM), g_selCnt)
        for i in range(min(SEL_DISP_NUM, len(tmpInfoList))):
            selCol = lcd.RED if (sttCnt + i) == g_selCnt else lcd.BLUE
            dispStr = str(sttCnt + 1 +
                          i) + ':' + tmpInfoList[sttCnt + i].dirName + spcStr
            lcd.draw_string(0, 20 + i * 16, dispStr, lcd.WHITE, selCol)
        if (info.dirName == SETTINGS_DIR_NAME):
            fullPath = 'snd/sys_voicesettings'
        g_cWav.stop()
        g_cWav.play('/sd/' + fullPath + '.wav')
        #g_cWav.wait()
    g_cWav.update()
    return True
Ejemplo n.º 2
0
def boot_menu(cnt):
    global but_a, but_b
    res = 0
    print("#->Waiting for user input!"
          )  # Note: MaixPy's Cam runs about half as fast when connected
    print("#: BtnA big btn for VGA Program, Btn B for QVGA program")
    lcd.draw_string(10, 100, "Waiting for user Btns, A or B?", lcd.ORANGE,
                    lcd.WHITE)
    while (cnt):
        try:
            if but_a.value() == 0:
                print("Btn A pressed!")
                res = 1
                break
            if but_b.value() == 0:
                res = 2
                print("Btn B pressed!")
                break
            cnt = cnt - 1
            time.sleep(0.01)
        except:
            pass

    lcd.draw_string(10, 120, "Btn valid: " + str(res), lcd.BLACK, lcd.WHITE)
    time.sleep(0.5)
    return res
Ejemplo n.º 3
0
 def on_draw(self):
     self.is_dirty = False
     if not self.__initialized:
         self.__lazy_init()
     x_offset = 4
     y_offset = 6
     lcd.clear()
     for i in range(self.current_offset, len(self.current_dir_files)):
         # gc.collect()
         file_name = self.current_dir_files[i]
         print(file_name)
         try:
             f_stat = os.stat('/sd/' + file_name)
             if S_ISDIR(f_stat[0]):
                 file_name = file_name + '/'
             # gc.collect()
             file_readable_size = sizeof_fmt(f_stat[6])
             lcd.draw_string(lcd.width() - 50, y_offset, file_readable_size,
                             lcd.WHITE, lcd.BLUE)
         except Exception as e:
             print("-------------------->", e)
         is_current = self.current_selected_index == i
         line = "%s %d %s" % ("->" if is_current else "  ", i, file_name)
         lcd.draw_string(x_offset, y_offset, line, lcd.WHITE, lcd.RED)
         # gc.collect()
         y_offset += 18
         if y_offset > lcd.height():
             print(y_offset, lcd.height(), "y_offset > height(), break")
             break
Ejemplo n.º 4
0
 def run(self):
     try:
         self.run_inner()
     except Exception as e:
         import uio
         string_io = uio.StringIO()
         sys.print_exception(e, string_io)
         s = string_io.getvalue()
         print("showing blue screen:", s)
         lcd.clear(lcd.BLUE)
         msg = "** " + str(e)
         chunks, chunk_size = len(msg), 29
         msg_lines = [
             msg[i:i + chunk_size] for i in range(0, chunks, chunk_size)
         ]
         # "A problem has been detected and windows has been shut down to prevent damange to your m5stickv :)"
         lcd.draw_string(1, 1, "A problem has been detected and windows",
                         lcd.WHITE, lcd.BLUE)
         lcd.draw_string(1, 1 + 5 + 16, "Technical information:", lcd.WHITE,
                         lcd.BLUE)
         current_y = 1 + 5 + 16 * 2
         for line in msg_lines:
             lcd.draw_string(1, current_y, line, lcd.WHITE, lcd.BLUE)
             current_y += 16
             if current_y >= lcd.height():
                 break
         lcd.draw_string(1, current_y, s, lcd.WHITE, lcd.BLUE)
         lcd.draw_string(1,
                         lcd.height() - 17,
                         "Will reboot after 10 seconds..", lcd.WHITE,
                         lcd.BLUE)
         time.sleep(10)
         machine.reset()
Ejemplo n.º 5
0
def resetKpu():
    global g_selCnt
    global g_cFiler
    global g_task
    global g_powArr

    info = g_cFiler.getInfoList()[g_selCnt]
    fullPath = info.dirName + '/' + info.modelName
    lcd.draw_string(0, 20, fullPath, lcd.GREEN, lcd.BLACK)
    fullPath = '/sd/models/' + fullPath + '.kmodel'
    g_powArr = []
    for ii in range(len(info.classList)):
        g_powArr.append(0.0)

    if (g_task == None):
        g_task = _resetTask()

    sensor.reset()
    sensor.set_pixformat(sensor.RGB565)
    sensor.set_framesize(sensor.QVGA)
    print(info.modelType)
    if (info.modelType == 'vtraining'):
        sensor.set_windowing((224, 224))
    #sensor.skip_frames(time = 20000)
    sensor.run(1)
Ejemplo n.º 6
0
 def on_draw(self):
     if not self.__initialized:
         self.__lazy_init()
     x_offset = 4
     y_offset = 6
     lcd.clear()
     print("progress 0")
     for i in range(self.current_offset,
                    len(self.current_dir_file_info_list)):
         # gc.collect()
         print("progress 1")
         file_info = self.current_dir_file_info_list[i]
         file_name = file_info["file_name"]
         f_stat = file_info["stat"]
         if f_stat != None:
             if S_ISDIR(f_stat[0]):
                 file_name = file_name + '/'
             file_readable_size = sizeof_fmt(f_stat[6])
             lcd.draw_string(lcd.width() - 50, y_offset, file_readable_size,
                             lcd.WHITE, lcd.BLUE)
         is_current = self.current_selected_index == i
         line = "%s %d %s" % ("->" if is_current else "  ", i, file_name)
         lcd.draw_string(x_offset, y_offset, line, lcd.WHITE, lcd.RED)
         # gc.collect()
         print("progress 2")
         y_offset += 18
         if y_offset > lcd.height():
             print("y_offset > height(), break")
             break
         print("progress 3")
Ejemplo n.º 7
0
def initialize_camera():
    err_counter = 0
    while 1:
        try:
            sensor.reset()  #Reset sensor may failed, let's try some times
            break
        except:
            err_counter = err_counter + 1
            if err_counter == 20:
                lcd.draw_string(lcd.width() // 2 - 100,
                                lcd.height() // 2 - 4,
                                "Error: Sensor Init Failed", lcd.WHITE,
                                lcd.RED)
            time.sleep(0.1)
            continue

    sensor.set_pixformat(sensor.RGB565)
    # The memory can't analyze models with resolution higher than QVGA
    # So better we train the model with QVGA too
    sensor.set_framesize(sensor.QVGA)  #QVGA=320x240
    #sensor.set_framesize(sensor.VGA) #VGA=640x480
    # Optimze this settings to get best picture quality
    sensor.set_auto_exposure(False, exposure_us=500)
    sensor.set_auto_gain(
        False
    )  #, gain_db=100)  # must turn this off to prevent image washout...
    sensor.set_auto_whitebal(True)  # turn this off for color tracking

    sensor.run(1)
Ejemplo n.º 8
0
    def __lazy_init(self):
        err_counter = 0

        while 1:
            try:
                sensor.reset()  # Reset sensor may failed, let's try sometimes
                break
            except Exception:
                err_counter = err_counter + 1
                if err_counter == 20:
                    lcd.draw_string(lcd.width() // 2 - 100,
                                    lcd.height() // 2 - 4,
                                    "Error: Sensor Init Failed", lcd.WHITE,
                                    lcd.RED)
                time.sleep(0.1)
                continue
        print("progress 1 OK!")
        sensor.set_pixformat(sensor.RGB565)
        sensor.set_framesize(sensor.QVGA)  # QVGA=320x240
        sensor.run(1)

        print("progress 2 OK!")
        self.task = kpu.load(0x300000)  # Load Model File from Flash
        anchor = (1.889, 2.5245, 2.9465, 3.94056, 3.99987, 5.3658, 5.155437,
                  6.92275, 6.718375, 9.01025)
        # Anchor data is for bbox, extracted from the training sets.
        print("progress 3 OK!")
        kpu.init_yolo2(self.task, 0.5, 0.3, 5, anchor)

        self.but_stu = 1

        self.__initialized = True
Ejemplo n.º 9
0
def show_logo():
    try:
        img = image.Image("/sd/picture3.jpg")
        lcd.display(img)
        time.sleep(0.5)
        play_sound("/sd/logo.wav")

    except:
        lcd.draw_string(lcd.width()//2-100,lcd.height()//2-4, "Error: Cannot find logo.jpg", lcd.WHITE, lcd.RED)
Ejemplo n.º 10
0
def updateKpu():
    global g_cFiler
    global g_selCnt
    global g_cWav
    global g_task
    global g_powArr

    info = g_cFiler.getInfoList()[g_selCnt]

    if (g_task == None):
        g_task = _resetTask()
    if (g_task == None):
        g_cWav.play('/sd/snd/sys_ng.wav')
        g_cWav.wait()

    img = sensor.snapshot()

    if (info.modelType == 'yolo2'):
        plist = []
        for id in range(0, len(info.classList)):
            plist.append(0.0)

        code_obj = kpu.run_yolo2(g_task, img)
        if code_obj:  # object detected
            for i in code_obj:
                rect_size = i.w() * i.h()
                if rect_size > 10:
                    print(len(plist))
                    print(i.classid())
                    plist[i.classid()] = 0.95

    else:
        fmap = kpu.forward(g_task, img, False)
        plist = fmap[:]

    colArr = [(255, 0, 0), (0, 255, 0), (0, 0, 255), (5, 5, 5), (0, 255, 255),
              (255, 255, 0), (128, 128, 128), (50, 200, 50)]
    for id in range(0, len(plist)):
        if (plist[id] > 0.9):
            g_powArr[id] = min((g_powArr[id] + plist[id] - 0.9) * 5.0, 100.0)
        else:
            g_powArr[id] -= 10.0
            g_powArr[id] = max(g_powArr[id], 0.0)
        img.draw_rectangle((10, 50 + 10 * id, int(g_powArr[id] * 1), 8),
                           colArr[id & 7], 10, True)

        if (g_powArr[id] >= 100.0):
            g_powArr[id] = 0.0
            info = g_cFiler.getInfoList()[g_selCnt]
            labels = info.classList
            wavPath = info.dirName + '/' + labels[id] + '.wav'
            lcd.draw_string(0, 20, wavPath)
            g_cWav.play('/sd/models/' + wavPath)
            g_cWav.wait()
    a = lcd.display(img)
    g_cButton.update()
Ejemplo n.º 11
0
def showInfo(string, ret):
    global x, y
    if ret:
        lcd.draw_string(x, y, string, lcd.GREEN, lcd.BLACK)
    else:
        lcd.draw_string(x, y, string, lcd.RED, lcd.BLACK)
    y = y + 16
    if y > 240:
        y = 0
        lcd.clear(lcd.BLACK)
Ejemplo n.º 12
0
def sys_info_display():
    show_akku_status()
    print("#->Image FPS: " + str(clock.fps())
          )  # Note: MaixPy's Cam runs about half as fast when connected
    print("GC free mem: " + str(gc.mem_free() / 1000) + "KB")
    gc.collect()
    print("------------- ")
    lcd.draw_string(10, 20, "Image FPS: " + str(clock.fps()), lcd.BLACK,
                    lcd.WHITE)
    #time.sleep(0.5)
    return
Ejemplo n.º 13
0
def show_logo():
    try:
        img = image.Image("/sd/irasutoya/wall.jpeg")
        set_backlight(0)
        lcd.display(img)
        for i in range(9):
            set_backlight(i)
            time.sleep(0.1)

    except:
        lcd.draw_string(lcd.width()//2-100,lcd.height()//2-4, "Error: Cannot find logo.jpg", lcd.WHITE, lcd.RED)
Ejemplo n.º 14
0
 def loop(self):
     sec = time.ticks_ms() // 1000
     if sec != self.last_sec:
         self.last_sec = sec
         if sec % 5 == 0:
             self.update()
     if self.button_a.value() == 0:
         lcd.clear(lcd.WHITE)
         lcd.draw_string(30, 30, "Sleep...", lcd.RED, lcd.WHITE)
         time.sleep_ms(3000)
         self._axp192.setEnterSleepMode()
     time.sleep_ms(1)
Ejemplo n.º 15
0
    def on_draw(self):
        print("LauncherApp.on_draw()")
        icon_width = 64
        icon_height = 60
        icon_padding = 6
        icon_margin_top = 0
        screen_canvas = image.Image()
        vbat = self.get_system().pmu.getVbatVoltage() / 1000.0
        usb_plugged = self.get_system().pmu.is_usb_plugged_in()
        battery_level = self.calculate_battery_level(vbat)
        vbat_str = str(vbat) + "V"
        print("vbat", vbat_str)
        # screen_canvas.draw_string(180, 10, vbat_str, lcd.GREEN, scale=1)

        icons_count = screen_canvas.width() // (icon_width + icon_padding)
        if icons_count % 2 == 0:
            icons_count += 1
        else:
            icons_count += 2
        # icons_count must be an odd integer
        icons_half_count = icons_count // 2
        animation_offset = 0
        # handle animation
        if len(self.pending_animation_values) > 0:
            anim_index = self.pending_animation_values.pop()
            animation_offset = int(
                (icon_width + icon_padding * 2) * anim_index / self.animation_count)
            # invalidate when need animation
            self.invalidate_drawing()
        for i in range(-icons_half_count, icons_half_count + 1):
            icon_center_x = screen_canvas.width() // 2 + i * (icon_width + icon_padding)
            icon_center_y = screen_canvas.height() // 2 + icon_margin_top
            icon_center_x += animation_offset
            index = (self.cursor_index + i) % self.app_count
            self.draw_icon(screen_canvas, self.app_list[index]["icon"],
                           icon_center_x, icon_center_y, "center", "center")
        # draw center small arrow icon below
        self.draw_icon(screen_canvas, self.arrow_icon_path, screen_canvas.width() // 2,
                       screen_canvas.height() // 2 + icon_height // 2 + icon_padding + icon_margin_top, "center", "top")
        print("draw arrow ok")
        battery_percent = battery_level * 100.0
        battery_icon = self.find_battery_icon(battery_percent, usb_plugged)
        print("before draw battery")
        battery_icon_padding = 3
        self.draw_icon(screen_canvas, battery_icon,
                       screen_canvas.width() - battery_icon_padding, battery_icon_padding, "right", "top")
        print("after draw battery")
        lcd.display(screen_canvas)
        del screen_canvas
        lcd.draw_string(3, 3, "Battery: %.3fV %.1f%%" %
                        (vbat, battery_percent), lcd.GREEN)
        print("launcher on_draw end")
Ejemplo n.º 16
0
def show_logo(vol):
    try:
        img = image.Image("/sd/logo.jpg")
        set_backlight(0)
        lcd.display(img)
        for i in range(9):
            set_backlight(i)
            time.sleep(0.1)
        play_sound("/sd/logo.wav", vol)

    except:
        lcd.draw_string(lcd.width() // 2 - 100,
                        lcd.height() // 2 - 4, "Error: Cannot find logo.jpg",
                        lcd.WHITE, lcd.RED)
Ejemplo n.º 17
0
def show_akku_status():
    #lcd.draw_string(0, 0, "Battery Info Develop", lcd.WHITE, lcd.BLACK)
    #lcd.draw_string(230, 0, "*", lcd.BLUE, lcd.BLACK)
    val = axp.getVbatVoltage()
    #lcd.draw_string(0, 75, "Battery Voltage:" + str(val) + filler, lcd.RED, lcd.BLACK)
    lcd.draw_string(0, 75, "Battery Voltage:" + str(val / 1000) + "v",
                    lcd.WHITE)
    print("Battery Voltage:" + str(val / 1000) + "v")

    val = axp.getBatteryDischargeCurrent()
    print("Battery DischargeCurrent:" + str(val) + "mA")
    lcd.draw_string(0, 90, "DischargeCurrent:" + str(val) + "mA", lcd.GREEN,
                    lcd.BLACK)
    val = axp.getUSBInputCurrent()
    lcd.draw_string(0, 105, "USB InputCurrent:" + str(val) + "mA", lcd.ORANGE,
                    lcd.BLACK)
    val = axp.getTemperature()
    lcd.draw_string(0, 119, "Temperature:" + str(val) + "C", lcd.YELLOW,
                    lcd.BLACK)
    print("PMU Temperature:" + str(val) + "C")

    val = axp.getUSBVoltage()
    #lcd.draw_string(0, 30, "USB Voltage:" + str(val) + filler, lcd.WHITE, lcd.BLACK)
    print("USB Voltage:" + str(val / 1000) + "v")
    val = axp.getUSBInputCurrent()
    print("USB InputCurrent:" + str(val) + "mA")
    #lcd.draw_string(0, 45, "USB InputCurrent:" + str(val) + filler, lcd.RED, lcd.BLACK)
    return
Ejemplo n.º 18
0
def boot_lcd():
    lcd.init()
    lcd.rotation(2)  #Rotate the lcd 180deg

    try:
        img = image.Image("/sd/startup.jpg")
        lcd.display(img)

        test = "test"
        lcd.draw_string(lcd.width() // 50,
                        lcd.height() // 2, test, lcd.WHITE, lcd.RED)

    except:
        lcd.draw_string(lcd.width() // 50,
                        lcd.height() // 2, "Error: Cannot find start.jpg",
                        lcd.WHITE, lcd.RED)
Ejemplo n.º 19
0
def play_sound(filename):
    try:
        player = audio.Audio(path = filename)
        player.volume(50)
        wav_info = player.play_process(wav_dev)
        wav_dev.channel_config(wav_dev.CHANNEL_1, I2S.TRANSMITTER, resolution = I2S.RESOLUTION_16_BIT, align_mode = I2S.STANDARD_MODE)
        wav_dev.set_sample_rate(wav_info[1])
        while True:
            ret = player.play()
            if ret == None:
                break
            elif ret == 0:
                break
        player.finish()
    except:
        lcd.draw_string(10, 10, "ERROR", lcd.RED, lcd.BLACK)
def show_logo(image_filename, sound_filename):
    try:
        # 画像を読み込み
        img = image.Image(image_filename)
        # バックライトの輝度を設定
        set_backlight(0)
        # 画像をLCDに描画
        lcd.display(img)
        # バックライトの輝度を徐々に変更
        for i in range(9):
            set_backlight(i)
            time.sleep(0.1)
        # 音声ファイルを再生
        play_sound(sound_filename)
    except:
        lcd.draw_string(lcd.width() // 2 - 100, lcd.height() // 2 - 4, "Error: Cannot find %s" % image_filename, lcd.WHITE, lcd.RED)
Ejemplo n.º 21
0
def initialize_camera():
    err_counter = 0
    while 1:
        try:
            sensor.reset() #Reset sensor may failed, let's try some times
            break
        except:
            err_counter = err_counter + 1
            if err_counter == 20:
                lcd.draw_string(lcd.width()//2-100,lcd.height()//2-4, "Error: Sensor Init Failed", lcd.WHITE, lcd.RED)
            time.sleep(0.1)
            continue

    sensor.set_pixformat(sensor.RGB565)
    sensor.set_framesize(sensor.QVGA) #QVGA=320x240
    sensor.run(1)
Ejemplo n.º 22
0
def inference(model_file):
    task = kpu.load(model_file)
    kpu.set_outputs(task, 0, 1, 1, 2)
    clock = time.clock()
    while (True):
        img = sensor.snapshot()
        clock.tick()
        fmap = kpu.forward(task, img)
        fps = clock.fps()
        plist = fmap[:]
        pmax = max(plist)
        max_index = plist.index(pmax)
        a = lcd.display(img, oft=(0, 0))
        lcd.draw_string(
            0, 128, "%.2f:%s                            " %
            (pmax, labels[max_index].strip()))
    _ = kpu.deinit(task)
Ejemplo n.º 23
0
def set_IP_PORT(num=None):
    global _IPADDR, _MAX
    if num == '.' or num == ':' or num < 10:
        _IPADDR += '{}'.format(num)
        print('num {}'.format(num))
        if len(_IPADDR) > _MAX:
            _MAX = len(_IPADDR)
    elif num == 10:
        if len(_IPADDR) > 0:
            _IPADDR = _IPADDR[0:-2]
    if len(_IPADDR) < _MAX:
        lcd.draw_string(30, 50,
                        'http://' + _IPADDR + ' ' * (_MAX - len(_IPADDR)),
                        lcd.BLACK, lcd.WHITE)
    else:
        lcd.draw_string(30, 50, 'http://' + _IPADDR, lcd.BLACK, lcd.WHITE)
    print(_IPADDR)
Ejemplo n.º 24
0
def next_method(tp):
    global cursor
    if cursor <= 12:
        lcd.draw_string(40, 40 + cursor * 20, ">", lcd.BLACK, lcd.BLACK)
        cursor += 1
        lcd.draw_string(40, 40 + cursor * 20, ">", lcd.BLUE, lcd.BLACK)
        lcd.draw_string(240, 35, '                                ', lcd.BLUE,
                        lcd.BLACK)
        lcd.draw_string(240, 35, flist[cursor], lcd.BLUE, lcd.BLACK)
    utime.sleep_ms(300)
Ejemplo n.º 25
0
def dir_open(way):
    path = way_get(way)
    lcd.clear()
    global flist
    flist = uos.listdir(path)
    img = image.Image()
    global cursor
    start_cur = 0
    cursor = 0
    for c in range(len(flist)):
        img.draw_string(0, 0 + c * 20, flist[c], scale=1)
    lcd.display(img)
    draw_volt()
    lcd.draw_string(40, 40 + cursor * 20, ">", lcd.BLUE, lcd.BLACK)
    key1.disirq()
    key2.disirq()
    key3.disirq()
    key1.irq(enter_method, GPIO.IRQ_RISING, GPIO.WAKEUP_NOT_SUPPORT, 7)
    key2.irq(next_method, GPIO.IRQ_RISING, GPIO.WAKEUP_NOT_SUPPORT, 7)
    key3.irq(back_method, GPIO.IRQ_RISING, GPIO.WAKEUP_NOT_SUPPORT, 7)
Ejemplo n.º 26
0
 def show_provision(self):
     img = image.Image(resource.provision_image_path)
     lcd.display(img)
     del img
     lcd.draw_string(54, 6, "NEXT", lcd.RED, lcd.BLACK)
     lcd.draw_string(168, 6, "ENTER", lcd.RED, lcd.BLACK)
     lcd.draw_string(152,
                     lcd.height() - 18, "BACK/POWER", lcd.RED, lcd.BLACK)
     lcd.draw_string(21,
                     lcd.height() - 18, "StickV Computer", lcd.WHITE,
                     lcd.BLACK)
     self.check_restore_brightness()
     self.wait_event()
Ejemplo n.º 27
0
def _resetTask():
    global g_selCnt
    global g_cFiler
    global g_task

    info = g_cFiler.getInfoList()[g_selCnt]
    fullPath = info.dirName + '/' + info.modelName
    fullPath = '/sd/models/' + fullPath + '.kmodel'
    try:
        g_task = kpu.load(fullPath)
        if (info.modelType == 'yolo2'):
            anchor = (1.889, 2.5245, 2.9465, 3.94056, 3.99987, 5.3658,
                      5.155437, 6.92275, 6.718375, 9.01025)
            # Anchor data is for bbox, extracted from the training sets.
            kpu.init_yolo2(g_task, 0.5, 0.3, 5, anchor)
    except:
        lcd.draw_string(0, 20, "Err:" + info.modelName + " not find.",
                        lcd.WHITE, lcd.RED)
        g_task = None

    return g_task
Ejemplo n.º 28
0
 def on_draw(self):
     if not self.__initialized:
         self.__lazy_init()
     lcd.clear()
     y = 3
     lcd.draw_string(3, 3, self.system_uname.machine, lcd.WHITE, lcd.BLUE)
     y += 16
     lcd.draw_string(3, y, self.system_uname.version,
                     lcd.WHITE, lcd.BLUE)
     y += 16
     lcd.draw_string(3, y, self.device_id, lcd.WHITE, lcd.BLUE)
     for info in self.fs_info_list:
         y += 16
         lcd.draw_string(3, y, info, lcd.WHITE, lcd.BLUE)
Ejemplo n.º 29
0
def GNSS_update(timer):
    GNSS.GNSS_Read()
    GNSS.GNSS_Parese()
    #lcd.clear(lcd.WHITE)
    #lcd.draw_string(10,40,"Date: "+GNSS.date,lcd.BLACK,lcd.WHITE)
    lcd.draw_string(0, 0, "UTC Time: " + GNSS.UTC_Time, lcd.BLACK, lcd.WHITE)
    lcd.draw_string(0, 20, "latitude:  " + GNSS.latitude + GNSS.N_S, lcd.BLACK,
                    lcd.WHITE)
    lcd.draw_string(0, 40, "longitude: " + GNSS.longitude + GNSS.E_W,
                    lcd.BLACK, lcd.WHITE)
    lcd.draw_string(0, 60, "Speed: " + str(GNSS.speed_to_groud_kh) + "km/h",
                    lcd.BLACK, lcd.WHITE)
    #lcd.draw_string(10,140,"Course_over_ground: "+str(GNSS.course_over_ground),lcd.BLACK,lcd.WHITE)
    GNSS.print_GNSS_info()
Ejemplo n.º 30
0
def bit_sensor():  #摄像头
    print("开始测试摄像头...")
    try:
        lcd.draw_string(30, 50, 'Start test Camera (End by touch) ', lcd.RED,
                        lcd.BLACK)
        sensor.reset()
        sensor.set_pixformat(sensor.RGB565)
        sensor.set_framesize(sensor.QVGA)
        sensor.run(1)
        sensor.skip_frames()
    except:
        #break
        lcd.draw_string(90, 120, 'Camera test failed! ', lcd.GREEN, lcd.BLACK)
        print("摄像头初始化失败!")

    i = 0
    fm.register(9, fm.fpioa.GPIO1)
    key_4 = GPIO(GPIO.GPIO1, GPIO.IN, GPIO.PULL_UP)
    while (key_4.value() == 1):
        lcd.display(sensor.snapshot())
        i = i + 1
        if i > 150:
            break
    lcd.draw_string(90, 90, 'End Camera test ', lcd.RED, lcd.BLACK)
    time.sleep(1)
    lcd.clear()
    print("摄像头实时显示测试完成")