Esempio n. 1
0
USB = os.popen('lsusb')
A = USB.read()
if (A.find("lcd2usb") == -1):
    print('NO device!')
    exit()
else:
    lcd = LCD()
    #lcd_echo(lcd)

################---变量区---##############
briLD = 90  #亮度
conDBD = 164  #对比度
##########################################

########设置###########
lcd.set_brightness(briLD)
lcd.set_contrast(conDBD)
#######################
#lcd.clear()
exit_flag = 0


def Loading():
    lcd.home()
    lcd.clear()
    lcd.goto(1, 0)
    lcd.write('LCD status display')
    sleep(0.5)
    lcd.goto(3, 1)
    lcd.write('raspberry pi')
    sleep(0.5)
Esempio n. 2
0
def main():
    global lcd
    global layout
    global exit_flag
    global errors
    thread.start_new_thread(Key_Daemon, ())
    RE_welcome = 0
    errors = 0
    lcd = LCD()

    while (True):
        try:
            if errors == 0:
                lcd = LCD()
                #lcd_echo(lcd)

                if (RE_welcome != 0):  #re welcome
                    if (RE_welcome < 6):
                        RE_welcome = 0
                    if (RE_welcome > 5):
                        Loading()
                        RE_welcome = 0

                if layout == 1:
                    main_layout()  #主程序界面
                    sleep(0.3)
                    lcd.goto(19, 2)
                    lcd.write(' ')

                elif layout == 2:
                    Network_layout()
                    sleep(0.9)

                elif layout == 0:
                    reload_layout()
                    sleep(0.9)

        except KeyboardInterrupt:
            exit_flag = 1
            sleep(1)
            lcd.clear()
            lcd.goto(0, 1)
            lcd.write("Program End =w=")
            lcd.goto(0, 2)
            lcd.write(datetime.now().strftime('%m/%d %w %p %l:%M:%S'))
            lcd.set_brightness(10)
            lcd.close()
            print('\nProgram End =w=')
            break
        except:
            errors = 1
            sleep(5)
            while errors != 0:
                USB = os.popen('lsusb')
                A = USB.read()
                #print A
                if (A.find("lcd2usb") == -1):
                    print('NO device!')
                    errors = 1
                else:
                    print('ok')
                    errors = 0
Esempio n. 3
0
            lx = 0
        else:
            lx = lx + 20  #否则 加20亮度 避免太暗

        if lx >= 256:  #亮度最高255 避免错误数值
            lx = 255

        if lx != lx_old:  #减少调用次数
            lcd.set_brightness(lx)
        lx_old = lx


if briLD == -1:  #判断是否自动
    thread.start_new_thread(auto_brightness, ())  #启动自动线程
else:
    lcd.set_brightness(briLD)  #手动
lcd.set_contrast(conDBD)


def Loading():
    lcd.home()
    lcd.clear()
    lcd.goto(1, 0)
    lcd.write('LCD status display')
    sleep(0.5)
    lcd.goto(3, 1)
    lcd.write('raspberry pi')
    sleep(0.5)
    lcd.goto(4, 2)
    lcd.write('=Moeyuuko=')
    sleep(0.5)