def LcdEnd(line1, line2): I2C.lcd_init() # 초기화 I2C.lcd_string(line1, I2C.LCD_LINE_1) # 윗줄 I2C.lcd_string(line2, I2C.LCD_LINE_2) # 아랫줄 time.sleep(3) I2C.lcd_init() # 초기화 sys.exit(1)
def ScrollLeft(line1, line2): I2C.lcd_init() for i in range(10): I2C.lcd_string("%s%s" % (" " * (9 - i), line1), I2C.LCD_LINE_1) I2C.lcd_string("%s%s" % (" " * (9 - i), line2), I2C.LCD_LINE_2) time.sleep(0.01) time.sleep(1) I2C.lcd_init()
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ] month_num = [ "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" ] try: while True: time_split = time.ctime().split(" ") year = time_split[4] month = time_split[1] day = time_split[2] week = time_split[0] current_time = time_split[3] for i in range(0, 12): if month == month_string[i]: month = month_num[i] break I2C.lcd_string( "{}.{}.{}.{}".format(year, month, day, current_time[0:5]), I2C.LCD_LINE_1) I2C.lcd_string("Distance : {}m".format(Distance.Get()), I2C.LCD_LINE_2) time.sleep(1) except: GPIO.cleanup() I2C.lcd_init()
import smbus import time import i2c_module as I2C I2C.lcd_init() # 초기화 I2C.lcd_string("Hello World", I2C.LCD_LINE_1) # 윗줄 I2C.lcd_string("Connect Complete", I2C.LCD_LINE_2) # 아랫줄 time.sleep(3) I2C.lcd_init() # 초기화 scroll = "Scroll" # 스크롤 할 문자 whitespace = " " # 공백 for i in range(0, 11): I2C.lcd_string("{}{}".format(whitespace * i, scroll), I2C.LCD_LINE_1) I2C.lcd_string("{}{}".format(whitespace * (10 - i), scroll), I2C.LCD_LINE_2) time.sleep(0.01) # 한계속도. 0.01초로 설정했지만 체감은 0.2 ~ 0.3초 time.sleep(1) I2C.lcd_init() # 초기화
pin = 4 # BCM 4, WPi 7, pin7 month_string = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ] month_num = [ "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" ] while True: humidity, temperature = Adafruit_DHT.read_retry(sensor, pin) time_split = time.ctime().split(" ") year = time_split[4] month = time_split[1] day = time_split[2] week = time_split[0] current_time = time_split[3] for i in range(0, 12): if month == month_string[i]: month = month_num[i] break I2C.lcd_string("{}.{}.{}.{}".format(year, month, day, current_time[0:5]), I2C.LCD_LINE_1) I2C.lcd_string("{}`C {}%".format(temperature, humidity), I2C.LCD_LINE_2) time.sleep(1)
def StaticMessage(line1, line2): I2C.lcd_init() # 초기화 I2C.lcd_string(line1, I2C.LCD_LINE_1) # 윗줄 I2C.lcd_string(line2, I2C.LCD_LINE_2) # 아랫줄 time.sleep(3) I2C.lcd_init()
def LcdAbort(): I2C.lcd_init() # 초기화 I2C.lcd_string(" You Press ", I2C.LCD_LINE_1) # 윗줄 I2C.lcd_string(" Ctrl - C ", I2C.LCD_LINE_2) # 아랫줄 time.sleep(3) I2C.lcd_init() # 초기화