Esempio n. 1
0
 def __init__(self, threadID, name):
   threading.Thread.__init__(self)
   self.threadID = threadID
   self.name = name  
   self.lcd = liquidcrystal_i2c.LiquidCrystal_I2C(DISPLAY_I2C_ADDRESS, DISPLAY_I2C_PORT, numlines=DISPLAY_ROWS)
   self.buffer = ["" for row in range(0, DISPLAY_ROWS)]
   self.changed = False
Esempio n. 2
0
 def __init__(self, _log, *args, **kwargs):
     self._log = _log
     self.lcd = liquidcrystal_i2c.LiquidCrystal_I2C(0x27, 1, numlines=4)
     self.lcd.printline(0, "Droneponics")
     if (kwargs.get('product', None) is not None):
         self.lcd.printline(1, kwargs.get('product'))
     if (kwargs.get('productTagLine', None) is not None):
         self.lcd.printline(2, kwargs.get('productTagLine'))
     if (kwargs.get('ip', None) is not None):
         self.lcd.printline(3, kwargs.get('ip'))
Esempio n. 3
0
 def __init__(self):
     self.bus = smbus2.SMBus(1)
     self.address = 0x08
     self.dataToSend = 1
     self.responsePayloadSize = 11
     self.rows = 4
     self.cols = 20
     self.lcd = liquidcrystal_i2c.LiquidCrystal_I2C(0x27,
                                                    1,
                                                    numlines=self.rows)
     self.positions = {}
     self.previousPositions = {}
Esempio n. 4
0
 def __init__(self):
     import subprocess
     import re
     p = subprocess.Popen(
         ['i2cdetect', '-y', '1'],
         stdout=subprocess.PIPE,
     )
     for i in range(0, 9):
         line = str(p.stdout.readline())
         for match in re.finditer("[0-9][0-9]:.*[a-zA-Z0-9][a-zA-Z0-9]",
                                  line):
             address = match.group()
     if (len(address) > 0):
         addresses = address.split('-- ')
         i2cAddress = addresses[len(addresses) - 1]
         self.lcd = LCD.LiquidCrystal_I2C(int(i2cAddress, 16),
                                          1,
                                          numlines=self.lcd_rows)
Esempio n. 5
0
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import urllib2
import ssl
import json
from gpiozero import MotionSensor
import time
import liquidcrystal_i2c

# instance pir module and lcd module.
pir = MotionSensor(4)
lcd = liquidcrystal_i2c.LiquidCrystal_I2C(0x27, 1, numlines=4)


def get_weather():
    """ access gaode API get weather"""
    report = []
    context = ssl._create_unverified_context()
    api = 'https://restapi.amap.com/v3/weather/weatherInfo?key=857e115ce98e9a5c5b93b0289715fe80&city=310000&extensions=base&output=JSON'
    response = urllib2.urlopen(api, context=context)
    string = response.read()
    dc = json.loads(string)
    data = dc['lives'][0]
    #print(data)
    t = 'Temp: ' + data['temperature'] + 'C'
    h = 'Humidity: ' + data['humidity'] + '%'
    report = data['reporttime']
    lcd.printline(0, report)
    lcd.printline(1, t)
    lcd.printline(2, h)
						help="Enables test mode, Forcing it to use stdout rather than actual hardware.")
	args.add_argument("-d", "--data", type=str, required=True,
						help="The file path of the data to use.")
	args.add_argument("-w", "--wait", type=int, default=5,
						help="The time to wait between each 'page' of text.")
	args.add_argument("-l", "--loop", type=bool, default=False,
						help="Enables looping, re-opening the file and displaying updated results.")

	args = args.parse_args()

	if args.test:
		DEBUG = True
		
	if not DEBUG:
		# TODO: What is 0x27?
		disp = i2c.LiquidCrystal_I2C(0x27, 1, numlines=4)
	else:
		disp = None
	
	# Python doesn't have Do ... While, so this is a kind-of hack to get the same outcome.
	while True: # DO
		
		json_file = open(args.data, 'r')
		data = json.load(json_file)
		json_file.close()

		display(data, disp, args.wait)

		if not args.loop: # WHILE
			break
Esempio n. 7
0
parser = argparse.ArgumentParser(description='Package monitoring')
requiredNamed = parser.add_argument_group('required named arguments')
requiredNamed.add_argument('-s',
                           '--size',
                           help='Display size, e.g. 20x4',
                           required=True)
args = parser.parse_args()

width = int(args.size.split('x')[0])
height = int(args.size.split('x')[1])

# default values
interface = 'eth0'

# Initialize display
lcd = liquidcrystal_i2c.LiquidCrystal_I2C(0x27, 1, clear=False)
# create block characters for charting
for c in range(0, 8):
    rows = []
    for r in range(0, 8):
        if r <= c:
            rows.append(0x1f)
        else:
            rows.append(0x00)
    lcd.createChar(c, rows[::-1])
# create block char array
chars = [' ']
for c in range(0, 8):
    chars.append(chr(c))

# initial values
Esempio n. 8
0
import sys
import os
sys.path.append('/home/pi/droneponics')
import drone
import liquidcrystal_i2c

cols = 20
rows = 4
try:
    lcd = liquidcrystal_i2c.LiquidCrystal_I2C(0x27, 1, numlines=rows)
    lcd.printline(0, 'LCM2004 IIC V2'.center(cols))
    lcd.printline(1, 'host-' + drone.gethostname())
    lcd.printline(2, 'ip-' + drone.get_ip())
    lcd.printline(3, 'liquidcrystal_i2c 1')    
    print("Device found at address 27 on bus 1")
except:
    print("no lcd on bus 1")
    
try:
    lcd = liquidcrystal_i2c.LiquidCrystal_I2C(0x27, 0, numlines=rows)
    lcd.printline(0, 'LCM2004 IIC V2'.center(cols))
    lcd.printline(1, 'host-' + drone.gethostname())
    lcd.printline(2, 'ip-' + drone.get_ip())
    lcd.printline(3, 'liquidcrystal_i2c 0')
    print("Device found at address 27 on bus 0")
except:
    print("no lcd on bus 0")
Esempio n. 9
0
class attendanceLCDPrint:

    # Define LCD column and row size for 20x4 LCD.
    lcd_columns = 20
    lcd_rows = 4
    lcd = LCD.LiquidCrystal_I2C(0x27, 1, numlines=lcd_rows)

    def printIfNoMatchFound(self):
        self.printClearScreen()
        self.lcd.printline(0, "   ATTENDANCE MODE  ")
        self.lcd.printline(2, "    ACCESS DENIED   ")
        t.sleep(2)

    def printDeviceMaintanace(self):
        self.printClearScreen()
        self.lcd.printline(0, "    DEVICE UNDER    ")
        self.lcd.printline(1, "    MAINTAINANCE    ")
        self.lcd.printline(3, "  PLEASE TRY LATER  ")
        t.sleep(2)

    def printClearScreen(self):
        self.lcd.printline(0, "                    ")
        self.lcd.printline(1, "                    ")
        self.lcd.printline(2, "                    ")
        self.lcd.printline(3, "                    ")

    def printAfterSuccessfullEventLogg(self, currentTime, employeeDetails):
        self.printClearScreen()
        self.lcd.printline(0, "ATTENDANCE DONE!!!! ")
        ##        msg = ""
        ##        if str(employeeDetails[4]) == '2':
        ##            if str(employeeDetails[3]) == "":
        ##                msg = "Ms. "+str(employeeDetails[2])
        ##            else:
        ##                msg = "Ms. "+str(employeeDetails[3])
        ##
        ##        else:
        ##            if str(employeeDetails[3]) == "":
        ##                msg = "Mr. "+str(employeeDetails[2])
        ##            else:
        ##                msg = "Mr. "+str(employeeDetails[3])

        message = (str(employeeDetails[2])).upper()
        self.lcd.printline(1, message)
        message = "ID: " + str(employeeDetails[0])
        self.lcd.printline(2, message)
        message = "TIME: " + str(currentTime)
        self.lcd.printline(3, message)
        t.sleep(2)

    def printAfterSuccessfullEventLoggButNoEmployeeID(self):
        self.printClearScreen()
        self.lcd.printline(0, "   ATTENDANCE MODE  ")
        self.lcd.printline(2, "NO EMPLOYEE ID FOUND")
        t.sleep(2)

    def printSyncMessage(self):
        self.printClearScreen()
        self.lcd.printline(0, "PLEASE WAIT........ ")
        self.lcd.printline(1, "                    ")
        self.lcd.printline(2, "  SYNCHRONIZATION   ")
        self.lcd.printline(3, "    IN PROGRESS     ")
        #t.sleep(1)

    def printInitialMessage(self):
        #self.lcd.blink(False)
        self.printClearScreen()
        self.lcd.printline(0, "  ADD COMPANY NAME  ")
        self.lcd.printline(1, "SCAN FOR ATTENDANCE ")
        self.lcd.printline(2, "        OR          ")
        self.lcd.printline(3, "PRESS '#' TO ENROLL ")
        #t.sleep(1)

    def printPleaseWait(self):
        self.printClearScreen()
        self.lcd.printline(0, " PLEASE WAIT...")
        t.sleep(.5)

    def enrollmentMode(self):
        self.printClearScreen()
        self.lcd.printline(0, "  ENROLLMENT MODE  ")

    def printEnrollemntGivePassword(self):
        self.enrollmentMode()
        self.lcd.printline(1, "ENTER PIN=")
        self.lcd.printline(2, "A=ENTER C=CANCEL")
        self.lcd.printline(3, "B=BACKSPACE")
        self.lcd.setCursor(10, 1)

    def printEnrollemntGiveEmployeeId(self):
        self.enrollmentMode()
        self.lcd.printline(1, "EMPLOYEE ID=")
        self.lcd.printline(2, "A=ENTER C=CANCEL")
        self.lcd.printline(3, "B=BACKSPACE")
        self.lcd.setCursor(12, 1)

    def printCompanyNames(self, companyList, printedCompany):
        self.printClearScreen()
        #self.enrollmentMode()
        self.lcd.printline(0, "SELECT YOUR COMPANY ")
        line2 = 0
        line3 = 0
        messageLine2 = ""
        messageLine3 = ""
        companyNo = 1
        for company in companyList:
            if (20 - line2) >= (len(company) + 3):
                messageLine2 = messageLine2 + str(
                    companyNo) + "." + company + " "
                line2 = line2 + (len(company) + 3)
                companyNo = companyNo + 1
                printedCompany = printedCompany + 1
            elif (20 - line3) >= (len(company) + 2):
                messageLine3 = messageLine3 + str(
                    companyNo) + "." + company + " "
                line3 = line3 + (len(company) + 2)
                companyNo = companyNo + 1
                printedCompany = printedCompany + 1
            else:
                break
        self.lcd.printline(1, messageLine2)
        self.lcd.printline(2, messageLine3)
        self.lcd.printline(3, "<<<'*' PRESS 'D'>>>")
        return printedCompany

    def printEmployeeId(self, idNumber):
        self.lcd.printstr(str(idNumber))

    def printPassword(self, pin):
        self.lcd.printstr(str(pin))

    def setLCDCursorForBackSpace(self, x, y):
        self.lcd.setCursor(x, y)
        self.lcd.printstr(" ")
        self.lcd.setCursor(x, y)

    def printValidEmployeeNotSuccess(self, flag, employeeId, x):
        self.enrollmentMode()
        if flag == "Invalid":
            msg = "  ID " + str(employeeId) + " NOT VALID"
            self.lcd.printline(2, msg)
        elif flag == "Registered":
            msg = "  ID " + str(employeeId) + " REGISTERED"
            self.lcd.printline(2, msg)
        elif flag == "Server Down":
            self.lcd.printline(1, "  LOST CONNECTION  ")
            self.lcd.printline(2, "    WITH SERVER    ")
            self.lcd.printline(3, "  TRY AGAIN LATER  ")
        elif x == '1':
            self.lcd.printline(2, " REQUEST TIMED OUT ")
        t.sleep(2)

    def printPasswordResponse(self, flag, x):
        self.enrollmentMode()
        if flag == "Not Matched":
            msg = "    ACCESS DENIED   "
            self.lcd.printline(2, msg)
        elif flag == "Server Down":
            self.lcd.printline(1, "  LOST CONNECTION  ")
            self.lcd.printline(2, "    WITH SERVER    ")
            self.lcd.printline(3, "  TRY AGAIN LATER  ")
        elif x == '1':
            self.lcd.printline(2, " REQUEST TIMED OUT ")
        t.sleep(2)

    def printPutAnyFinger(self):
        self.enrollmentMode()
        self.lcd.printline(2, "  PUT ANY FINGER  ")
        self.lcd.printline(3, " WITHIN 2 MINUTES ")
        t.sleep(1)

    def printFingerAlreadyExists(self):
        self.enrollmentMode()
        self.lcd.printline(2, "   FINGER ALREADY   ")
        self.lcd.printline(3, "       EXISTS       ")
        t.sleep(2)

    def printRemoveAndPutSameFinger(self):
        self.enrollmentMode()
        self.lcd.printline(2, "   REMOVE FINGER  ")
        t.sleep(2)
        self.enrollmentMode()
        self.lcd.printline(2, "  PUT SAME FINGER ")
        self.lcd.printline(3, " WITHIN 2 MINUTES ")
        t.sleep(1)

    def printWaitAfterGivingBothFingers(self):
        self.enrollmentMode()
        self.lcd.printline(2, "  PLEASE WAIT...  ")
        t.sleep(1)

    def printTwoFingersDidNotMatched(self):
        self.enrollmentMode()
        self.lcd.printline(2, " FINGER NOT MATCHED")
        self.lcd.printline(3, "   PROCESS FAILED")
        t.sleep(2)

    def printSuccessEnrollmentMessage(self):
        self.enrollmentMode()
        self.lcd.printline(2, "  FINGER ENROLLED  ")
        self.lcd.printline(3, "   SUCCESSFULLY    ")
        t.sleep(2)

    def printUnsuccessEnrollmentMessage(self, receivedData):
        self.enrollmentMode()
        if receivedData == "Server Error":
            self.lcd.printline(1, "  LOST CONNECTION  ")
            self.lcd.printline(2, "    WITH SERVER    ")
            self.lcd.printline(3, "  TRY AGAIN LATER  ")
        else:
            self.lcd.printline(2, " ERROR HAS OCCURED ")
            self.lcd.printline(3, "    TRY AGAIN      ")
        t.sleep(2)

    def timeOutMessage(self):
        self.enrollmentMode()
        self.lcd.printline(2, " REQUEST TIMED OUT ")
        t.sleep(2)

    def printCompanyNotSelected(self, ch, x):
        self.enrollmentMode()
        if ch == 'C':
            self.lcd.printline(2, "ENROLLMENT CANCELED")
        elif x == '1':
            self.lcd.printline(2, " REQUEST TIMED OUT ")
        t.sleep(2)

    def printIDNotGivenOrTimeOutOrCanceled(self, ch, employeeId, x):
        self.enrollmentMode()
        if ch == 'C':
            self.lcd.printline(2, "ENROLLMENT CANCELED")
        elif x == '1':
            self.lcd.printline(2, " REQUEST TIMED OUT ")
        elif employeeId == "":
            self.lcd.printline(2, "   ID NOT GIVEN    ")
        t.sleep(2)

    def printPasswordNotGivenOrTimeOutOrCanceled(self, ch, employeeId, x):
        self.enrollmentMode()
        if ch == 'C':
            self.lcd.printline(2, "ENROLLMENT CANCELED")
        elif x == '1':
            self.lcd.printline(2, " REQUEST TIMED OUT ")
        elif employeeId == "":
            self.lcd.printline(2, "PASSWORD NOT GIVEN ")
        t.sleep(2)

    def printExceptionMessage(self, message):
        self.printClearScreen()
        self.lcd.printline(1, message.upper())
        t.sleep(1)