예제 #1
0
def lcd_display():
    global flate
    if flate:
        lcd = CharLCD('PCF8574',
                      address=ADDRESS,
                      port=1,
                      backlight_enabled=True)
        lcd.clear()
        lcd.cursor_pos = (0, 5)
        lcd.write_string("Welcome!")
        lcd.cursor_pos = (1, 5)
        global txt
        lcd.write_string(txt)
        flate = False
        os.system("cat /dev/null > plate.txt")
    else:
        lcd = CharLCD('PCF8574',
                      address=ADDRESS,
                      port=1,
                      backlight_enabled=False)
        os.system("cat /dev/null > plate.txt")
예제 #2
0
def lcd_print_main():
    sys.modules['smbus'] = smbus2

    from RPLCD.i2c import CharLCD

    lcd = CharLCD('PCF8574', address=0x27, port=1, backlight_enabled=True)

    try:
        print('lcd printing')
        lcd.clear()
        while 1:
            lcd.cursor_pos = (0, 0)
            lcd.write_string("Whiskey")
            lcd.cursor_pos = (1, 0)
            lcd.write_string("is coming......")
            time.sleep(5)
            break
            # main()
        # lcd.clear()
    except KeyboardInterrupt:
        print('closing')
    finally:
        lcd.clear()
예제 #3
0
def get_lcd(backlight_on, clear_screen=True):
    GPIO.setmode(GPIO.BCM)
    GPIO.setwarnings(False)
    GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP)

    lcd = CharLCD(i2c_expander='PCF8574', address=0x27, port=1,
              cols=20, rows=4, dotsize=8,
              charmap='A00',
              auto_linebreaks=True,
              #backlight_enabled=backlight_on)
              backlight_enabled=True)
    if clear_screen:
        lcd.clear()
    lcd.write_string("********************")
    lcd.cursor_pos = (1, 0)
    lcd.cursor_pos = (3, 0)
    lcd.write_string("********************")
    return lcd
예제 #4
0
from RPLCD.i2c import CharLCD
import time
import datetime  # python date module
lcd = CharLCD('PCF8574', 0x27)
try:
    while True:
        now = datetime.datetime.now()  # current time
        nowDate = now.strftime('%Y-%m-%d')  # today's date parsing
        nowTime = now.strftime('%H-%M:%S')  # today's time parsing
        print(now, nowDate, nowTime)
        time.sleep(1)
        lcd.clear()
        lcd.cursor_pos = (0, 3)  # Position to mark letters
        lcd.write_string(nowDate)
        lcd.crlf()
        lcd.cursor_pos = (1, 4)
        lcd.write_string(nowTime)

except KeyboardInterrupt:
    lcd.clear()  # LCD clean
예제 #5
0
from gpiozero import MCP3008
from time import sleep
from RPLCD.i2c import CharLCD

lm35 = MCP3008(channel=1)
lcd = CharLCD('PCF8574', address=0x3f, port=1, backlight_enabled=True)
lcd.clear()


def convert_temp(gen):
    for value in gen:
        print('value=', value)
        yield value * 3.3 * 100


for temp in convert_temp(lm35.values):
    print('The temp is ', temp, ' C')
    lcd.cursor_pos = (0, 0)
    lcd.write_string('Temp %.2f C' % temp)
    sleep(1)
예제 #6
0
## Pinout
# GND - Pin 6
# VCC - Pin 4
# SDA - Pin 3
# SCL - Pin 5

lcd = CharLCD(i2c_expander='PCF8574',
              address=0x27,
              port=1,
              cols=16,
              rows=2,
              dotsize=8,
              charmap='A02',
              auto_linebreaks=False,
              backlight_enabled=True)

lines = [
    "abcdefghijklmnop123", "It works! but you can't see the rest of the text"
]

for i, line in enumerate(lines):
    char_count = len(line)
    #print(char_count)
    if char_count > 16:
        print(f"The message on LINE {i} is too long to display!")
        print(f"Only displaying:\t\'{line[0:16]}\'")
        print(f"Should see:\t\t\'{line}\'")
    lcd.cursor_pos = (i, 0)
    lcd.write_string(line)
예제 #7
0
if artist == 'false': artist = idots
lines = rows == 2 and title or artist + rn + title + rn + album
# remove accents
lines = ''.join(c for c in unicodedata.normalize('NFD', lines)
                if unicodedata.category(c) != 'Mn')

lcd.write_string(lines + rn + progress[:cols])
lcd.close()

if state == 'stop' or state == 'pause': quit()

# play
import subprocess
import time

prog = subprocess.getoutput("mpc | awk '/^.playing/ {print $3}' | cut -d/ -f1")
elapsed = 0
for each in prog.split(':'):
    elapsed = elapsed * 60 + int(each)
row = rows - 1
starttime = time.time()

while True:
    sl = 1 - ((time.time() - starttime) % 1)
    time.sleep(sl)
    progress = iplay + second2hhmmss(elapsed) + totalhhmmss
    if len(progress) > (cols - 3): progress += '  '
    lcd.cursor_pos = (row, 0)
    lcd.write_string(progress[:cols])
    elapsed += 1
예제 #8
0
from RPLCD.i2c import CharLCD
from time import sleep

lcd = CharLCD("PCF8574", 0x27)
lcd.write_string('Raspberry Pi HD44780')
lcd.cursor_pos = (2, 0)
lcd.write_string('https://github.com/\n\rdbrgn/RPLCD')

예제 #9
0
relais8 = LED(9, active_high=False)
relais9 = LED(11, active_high=False)

lcd = CharLCD(i2c_expander='PCF8574',
              address=0x20,
              port=1,
              cols=20,
              rows=4,
              dotsize=8,
              charmap='A02',
              auto_linebreaks=True,
              backlight_enabled=True)

# Display löschen und Starttext ausgeben
lcd.clear()
lcd.cursor_pos = (1, 1)
lcd.write_string("Initialisierung ...")

#Relais auf 0 schalten
relais1.off()
relais2.off()
relais3.off()
relais4.off()
relais5.off()
relais6.off()
relais7.off()
relais8.off()
relais9.off()

# Pygame starten für USB-KeyPad
pygame.init()
예제 #10
0
# see note in test_16x2.py about configuring your backlight, if you have one

input('Display should be blank. ')

lcd.cursor_mode = CursorMode.blink
input('The cursor should now blink. ')

lcd.cursor_mode = CursorMode.line
input('The cursor should now be a line. ')

lcd.write_string('Hello world!')
input('"Hello world!" should be on the LCD. ')

assert lcd.cursor_pos == (0, 12), 'cursor_pos should now be (0, 12)'

lcd.cursor_pos = (1, 0)
lcd.write_string('2')
lcd.cursor_pos = (2, 0)
lcd.write_string('3')
lcd.cursor_pos = (3, 0)
lcd.write_string('4')
assert lcd.cursor_pos == (3, 1), 'cursor_pos should now be (3, 1)'
input('Lines 2, 3 and 4 should now be labelled with the right numbers. ')

lcd.clear()
input('Display should now be clear, cursor should be at initial position. ')

lcd.cursor_pos = (0, 5)
lcd.write_string('12345')
input('The string should have a left offset of 5 characters. ')
예제 #11
0
def main():

    try:
        
        thread_one_wire = One_Wire()
        thread_one_wire.start()

        thread_stop_watch = Stop_Watch()
        thread_stop_watch.start()
        
        lcd = CharLCD('PCF8574', 0x27)
        degree = (0b00010, 0b00101, 0b00101, 0b00010, 0b00000, 0b00000, 0b00000, 0b00000)
        lcd.create_char(0, degree)
        
        sandclock = (0b00000, 0b11111, 0b01010, 0b00100, 0b00100, 0b01010, 0b11111, 0b00000)
        lcd.create_char(1, sandclock)
        
        lcd.cursor_pos = (0, 0)
        lcd.write_string('Temp 1: 00.0\x00C')
        lcd.cursor_pos = (1, 0)
        lcd.write_string('Temp 2: 00.0\x00C')
        lcd.cursor_pos = (2, 0)
        lcd.write_string('Temp 3: 00.0\x00C')
        lcd.cursor_pos = (3, 0)
        lcd.write_string('Timer : 00:00:00')

        Display_ref = ['0','02','03']

        print("End program with CRLT+C !!")

        while(True):
            for i in range(3):
                lcd.cursor_pos = (i, 8)
                lcd.write_string(thread_one_wire.Device_Temp[i])

          
            if Display_ref[0] != thread_stop_watch.Display_value[0]:
                lcd.cursor_pos = (3, 9)
                Display_ref[0] = thread_stop_watch.Display_value[0]
                lcd.write_string(thread_stop_watch.Display_value[0])
                #print("treffer hour")
            
            
            if Display_ref[1] != thread_stop_watch.Display_value[1]:
                lcd.cursor_pos = (3, 11)
                Display_ref[1] = thread_stop_watch.Display_value[1]
                #print("treffer min")
                if len(thread_stop_watch.Display_value[1]) > 1:
                    lcd.write_string(thread_stop_watch.Display_value[1])
                else:
                    lcd.write_string("0" + thread_stop_watch.Display_value[1])
            
            if Display_ref[2] != thread_stop_watch.Display_value[2]:
                lcd.cursor_pos = (3, 14)
                Display_ref[2] = thread_stop_watch.Display_value[2]
                #print("treffer sec")
                if len(thread_stop_watch.Display_value[2]) > 1:
                    lcd.write_string(thread_stop_watch.Display_value[2])
                else:
                    lcd.write_string("0" + thread_stop_watch.Display_value[2])
            
            if thread_stop_watch.Timer_running == True: 
                lcd.cursor_pos = (3, 18)
                lcd.write_string('\x01')
            else:
                lcd.cursor_pos = (3, 18)
                lcd.write_string(' ')

            time.sleep(.5)

    except Exception as err:
        print(err)
예제 #12
0
import sys

import smbus2
from RPLCD.i2c import CharLCD
sys.modules['smbus'] = smbus2

import time

if __name__ == "__main__":

    lcd = CharLCD('PCF8574', address=0x27, port=1, backlight_enabled=True)
    lcd.clear()
    
    while(True):
        today = time.localtime(time.time())
        line1 = time.strftime("%Y/%m/%d %a", today)
        taipei_time = time.strftime("%H:%M:%S", today)
        today = time.localtime(time.time()+3600)
        tokyo_time = time.strftime("%H:%M:%S", today)
        today = time.gmtime(time.time())
        london_time = time.strftime("%I:%M:%S %p", today)

        lcd.cursor_pos = (0, 3)
        #lcd.write_string("{:^20s}".format(line1))
        lcd.write_string(line1)
        lcd.cursor_pos = (1, 0)
        lcd.write_string("{:>6s}: {}".format("Taipei", taipei_time))
        lcd.cursor_pos = (2, 0)
        lcd.write_string("{:>6s}: {}".format("Tokyo", tokyo_time))
        lcd.cursor_pos = (3, 0)
        lcd.write_string("{:>6s}: {}".format("London", london_time))
예제 #13
0
파일: lcd.py 프로젝트: grutig/moode-lcd
                          stdin=subprocess.PIPE)
    out, err = bt.communicate("exit")
    # strip escape sequences
    out = out.replace("\x1b[", "")
    # extract connected device
    cn = out[out.find("[") + 1:out.find("]")]
    if cn == 'bluetooth':
        return ''
    return "BT:" + cn[0:13]


# ini LCD
lcd = CharLCD('PCF8574', 0x27)
lcd.compat_mode = True
# show splash
lcd.cursor_pos = (0, 0)
lcd.write_string('   Moodeaudio   ')
lcd.cursor_pos = (1, 0)
lcd.write_string('    by I8ZSE    ')
sleep(5)
# get main ip address and show it on LCD
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
lanip = s.getsockname()[0]
# show IP address of device
lcd.clear()
lcd.cursor_pos = (1, int((LCD_W - len(lanip)) / 2))
lcd.write_string(lanip)
sleep(3)
# clear LCD
lcd.cursor_pos = (1, 0)
예제 #14
0
파일: script.py 프로젝트: seregega/orangepi
from RPLCD.i2c import CharLCD
import datetime
import psutil
import time

lcd1 = CharLCD(i2c_expander='PCF8574',
               address=0x22,
               port=0,
               cols=20,
               rows=4,
               dotsize=8,
               charmap='A02',
               auto_linebreaks=True,
               backlight_enabled=True)
lcd1.clear()
lcd1.cursor_pos = (0, 0)
lcd1.write_string("Current Temperature ")
lcd1.cursor_pos = (2, 0)
lcd1.write_string("Current  Datetime   ")

lcd2 = CharLCD(i2c_expander='PCF8574',
               address=0x20,
               port=0,
               cols=20,
               rows=4,
               dotsize=8,
               charmap='A02',
               auto_linebreaks=True,
               backlight_enabled=True)
lcd2.clear()
lcd2.cursor_pos = (0, 0)
예제 #15
0
import sys

import smbus2
from RPLCD.i2c import CharLCD
sys.modules['smbus'] = smbus2

import time

if __name__ == "__main__":

    lcd = CharLCD('PCF8574', address=0x27, port=1, backlight_enabled=True)
    lcd.clear()

    text = "Raspberry"

    while (True):
        for i in range(80):
            lcd.clear()
            lcd.cursor_pos = (int(i / 20), i % 20)
            lcd.write_string(text)
            time.sleep(0.4)
예제 #16
0
파일: main.py 프로젝트: jason50123/python
    print ("Motion detected")

    for i in range(10):
        GPIO.output(16, 1)
        time.sleep(0.2)
        GPIO.output(16, 0)
        time.sleep(0.2)
#閃完紅燈後開啟攝像頭,如果可以為登陸成員則螢幕顯示
    if takepicture.main() == True :
        print("Welecome Home")    
#偵測到有人觸摸後執行
try:
    print('loading')
    lcd.clear()
    while True:
        if GPIO.input(11):
            GPIO.output(13,1)
            GPIO.output(15,0)
#在LCD螢幕顯示,並觸發紅外線感測器執行
            lcd.cursor_pos = (0, 0)
            lcd.write_string("Please standing ")
            lcd.cursor_pos = (1, 0)
            lcd.write_string("   on LINE  ")
            GPIO.add_event_detect(12, GPIO.RISING, callback=action, bouncetime=200)
        time.sleep(1)
        

except KeyboardInterrupt:
    print('close')
finally:
    lcd.clear()
tn.write('your callsign' + "\n") #please enter your callsign
time.sleep(5)

# Main body of code
try:
    while True:
        line = tn.read_until("\n")  # Read one line
        l1 = line.split()
        add = [" "," "," "," "," "," "," "," "," "," "]
        l1.extend(add)

        print(l1)[0],(l1)[1],(l1)[2],(l1)[3],(l1)[4],(l1)[5],(l1)[6],(l1)[7],(l1)[8]
        lcd.write_string((l1)[0])
        lcd.write_string(" "+(l1)[1])
        lcd.write_string(" "+(l1)[2])
        lcd.cursor_pos = (1, 0)
        lcd.write_string((l1)[3])
        lcd.write_string(" "+(l1)[4])
        lcd.cursor_pos = (2, 0)
        lcd.write_string((l1)[5])
        lcd.write_string(" "+(l1)[6])
        time.sleep(10)  #i add time between spot. If you want different seconds, change 10
        lcd.close(clear=True)

        if b'abcd' in line:  # last line, no more read
            break
except KeyboardInterrupt: # If there is a KeyboardInterrupt (when you press ctrl+c), exit the pr$
    print("Cleaning up!")
    lcd.close(clear=True)

예제 #18
0
#!/bin/python3
# -*- coding: utf-8 -*-

import sys

from RPLCD.i2c import CharLCD

lcd = CharLCD(i2c_expander='PCF8574',
              address=0x3f,
              port=1,
              cols=16,
              rows=2,
              dotsize=8,
              charmap='A02',
              auto_linebreaks=True,
              backlight_enabled=True)

lcd.write_string(sys.argv[1])
lcd.cursor_pos = (1, 0)
lcd.write_string(sys.argv[2] + "m" + sys.argv[3] + "s left")

exit()
예제 #19
0
from time import sleep
from threading import Thread

lcd = CharLCD(i2c_expander='PCF8574',
              address=0x3f,
              port=1,
              cols=20,
              rows=4,
              dotsize=8,
              charmap='A02',
              auto_linebreaks=True,
              backlight_enabled=False)

lcd.cursor_mode = "hide"
lcd.write_string('PiNet -> Nexus')
lcd.cursor_pos = (2, 0)
lcd.write_string('BORG Assimilated')
lcd.cursor_pos = (3, 0)
lcd.write_string("{:^20}".format("PolyHub Listening..."))


def turnOnForSeconds(seconds=5):
    backlightThread = Thread(target=timedBacklight, args=(seconds, ))
    backlightThread.start()


def timedBacklight(seconds):
    lcd.backlight_enabled = True
    sleep(seconds)
    lcd.backlight_enabled = False