示例#1
0
#!/user/bin/env python

import smbus
import time
import sys
import LCD1602 as LCD

if __name__ == '__main__':
    LCD.init_lcd()
    LCD.print_lcd(0, 0, 'RaspberryPi IIC')
    LCD.print_lcd(1, 1, 'wait a moment')
    print('wait 3 seconds')
    LCD.turn_light(1)
    time.sleep(3)
    try:
        while True:
            nowtime = time.strftime('%m-%d %H:%M:%S',
                                    time.localtime(time.time()))
            mintime = time.strftime('%M', time.localtime(time.time()))
            print('current time:' + nowtime)
            LCD.print_lcd(1, 1, nowtime)
            if mintime == 59:
                LCD.turn_light(1)
                print('mintime:' + mintime)
            time.sleep(1)
    except KeyboardInterrupt:
        LCD.print_lcd(0, 1, 'Can\'t see anyth')
    print('exit')
示例#2
0
def get_mem_info():
    total = commands.getoutput('free -m|grep Mem:|awk \'{print $2}\'')
    free = commands.getoutput('free -m|grep cache:|awk \'{print $4}\'')
    return 'M:F' + free + '/T' + total + ' MiB'


def run_cmd(cmd):
    p = Popen(cmd, shell=True, stdout=PIPE)
    output = p.communicate()[0]
    return output


if __name__ == '__main__':
    LCD.init_lcd()
    LCD.turn_light(0)


    # LCD.print_lcd(0,0,datetime.now().strftime('%b %d %H:%M:%S\n'))
    # LCD.print_lcd(1,1,'local time')
    # print('wait 5 seconds')
    # time.sleep(5)


    while True:
        # nowtime = datetime.now().strftime('%b %d %H:%M:%S')
        # mintime = time.strftime('%M',time.localtime(time.time()))
        # print('current time:'+nowtime)
        # LCD.print_lcd(0,0,nowtime)
        # if mintime == 59:
        # LCD.turn_light(1)
def LCD_Init():
    LCD.init_lcd()
    LCD.print_lcd(0,0,'RaspberryPi IIC')
    #LCD.print_lcd(1,1,'wait a moment')
    LCD.turn_light(1)
    time.sleep(1.5)