Beispiel #1
0
class Microprocessor(Receiver):
    in_0 = KeyboardPanel()
    out_0 = LCD()
    out_1 = Bell()
    out_2 = Lock()

    def __init__(self):
        self.olh = OpenLockHandler(self)
        self.clh = ClosedLockHandler(self)

        self.pkh = PassKeyHandler(self)
        self.ckh = CtrlKeyHandler(self)

        self.pkch = PassKeyChangeHandler(self)

        self.cbh = CallButtonHandler(self)
        self.pkah = PassKeyAcceptHandler(self.pkh, self)
        self.ckah = PassKeyAcceptHandler(self.ckh, self)

        self.cbh.set_next(self.clh).set_next(self.pkh).set_next(
            self.olh).set_next(self.ckh).set_next(self.ckh).set_next(self.pkch)

    def receive_signal(self, signal):
        signal = self.in_0.invoke()
        self.cbh.handle(signal)
        self.out_0.receive_signal(signal)

    def procedure(self):
        self.out_2.receive_signal(None)
        print(f"Lock: {self.out_2.state.info}")
Beispiel #2
0
 def show_on_lcd(self):
     lcd = LCD()
     lcd.stuur_instructie(0x0C | 0b10000000)
     lcd.stuur_tekst(str(round(self.speed, 2)))
     lcd.stuur_instructie(0x4C | 0b10000000)
     lcd.stuur_tekst(str(round(self.distance, 2)))
     lcd.stuur_instructie(12)
Beispiel #3
0
def sessie(hall=AH3661(26)):
    GPIO.setup(18, GPIO.OUT)
    while True:
        global stop
        stop = False

        uid, found = serialReadBadgeID()  # get BadgeID
        correctuid = datatodb.correct_badgeID(uid)  #  Check badgeID

        if found is True and correctuid is True:
            init_speed_distance()  # Standard values on LCD
            buzzer(True)  # when badged, buzz

            datatodb.create_session(uid,
                                    datetime.datetime.now())  # Create session

            hall.create_event()  # create event

            uid2, stop = serialReadBadgeID()  # get badgeID
            correctuid2 = datatodb.correct_badgeID(uid2)  # Check badgeID
            if found is stop and correctuid2 is True:
                buzzer(True)  # when badged, buzz

                eind = datetime.datetime.now()
                print("sessie is gedaan")
                datatodb.save_session(eind, round(hall.distance, 2))
                hall.remove_event()  # delete session
                lcd = LCD()
                lcd.stuur_instructie(1)
                break
        else:
            buzzer(False)  # when badged, buzz
            pass
Beispiel #4
0
    def __init__(self):
        ''' Initialization code '''
        self.busy = False
        self.masterMode = False

        #Initialize system components
        self.rfidReader = RFIDReader()
        self.keypad = Keypad()
        self.lcd = LCD()
        self.doorLatch = DoorLatch()
        self.database = Database()

        self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.server_address = ('192.168.43.206', 8888)
        self.socket.bind(self.server_address)

        self.correct_pin = self.database.getCorrectPin()
        self.entered_pin = ""
Beispiel #5
0
    def __init__(self, test=False):
        logging.getLogger().setLevel(logging.INFO)
        logging.info("Starting")

        if not test:
            from LCD import LCD
            from Reader import Reader
            from Keypad import Keypad

            self.lcd = LCD()
            self.reader = Reader()
            self.keypad = Keypad()
        else:
            from testLCD import TestLCD
            from testReader import TestReader
            from testKeypad import TestKeypad

            self.lcd = TestLCD()
            self.reader = TestReader()
            self.keypad = TestKeypad()
Beispiel #6
0
def toon_start_info(lcd=LCD()):
    initLCD()
    lcd.stuur_tekst("Programma wordt gestart")
    time.sleep(2)

    lcd.stuur_instructie(1)
    lcd.stuur_tekst("IP adres wordt getoond in 3")
    time.sleep(1)

    lcd.stuur_instructie(0x4B | 0b10000000)
    lcd.stuur_tekst("2")
    time.sleep(1)

    lcd.stuur_instructie(0x4B | 0b10000000)
    lcd.stuur_tekst("1")
    time.sleep(1)

    lcd.stuur_instructie(1)
    lcd.stuur_tekst(str(get_ip_address()))  # Toon ip address op scherm
    time.sleep(5)

    lcd.stuur_instructie(1)
Beispiel #7
0
 def __init__(self, btnID):
     threading.Thread.__init__(self)
     self.lcd = LCD()
     self.dName = 'Button-Press'
     self.btnID = btnID
     GPIO.setup(self.btnID, GPIO.IN, pull_up_down=GPIO.PUD_UP)
Beispiel #8
0
#!/usr/bin/python

# https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code/tree/master/Adafruit_CharLCD

from LCD import LCD
from subprocess import *
from time import sleep, strftime
from datetime import datetime

lcd = LCD()

cmd = "ip addr show wlan0 | grep inet | awk '{print $2}' | cut -d/ -f1"

lcd.begin(16, 1)


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


while 1:
    lcd.clear()
    ipaddr = run_cmd(cmd)
    lcd.message(datetime.now().strftime('%b %d  %H:%M:%S\n'))
    lcd.message('IP %s' % (ipaddr))
    sleep(1)
Beispiel #9
0
 def display2(self, str1, str2):
     lcd = LCD()
     lcd.printB(str1, str2)
     del lcd
Beispiel #10
0
 def display1(self, str):
     lcd = LCD()
     lcd.print(str)
     del lcd
Beispiel #11
0
import Adafruit_DHT
import sys, time
import MySQLdb
from blink import LED
from LCD import LCD
import warnings

warnings.filterwarnings("ignore")
db = MySQLdb.connect("localhost", "mine", "secret", "finalproject")
cur = db.cursor()
sensor = Adafruit_DHT.DHT11
pin = 4
id = 1
mid = 'r1'

while True:
    humid, temp = Adafruit_DHT.read_retry(sensor, pin)
    if humid is not None and temp is not None:
        print('Temp={0:0.1f}*C Humidity={1:0.1f}%'.format(temp, humid))
        LED(humid)
        time.sleep(5)
        now = time.strftime('%Y-%m-%d %H:%M:%S')
        cur.execute('insert into datain values(%s, %s, %s, %s, %s)',
                    (mid, temp, humid, now, id))
        db.commit()
        LCD(db)

    else:
        print('Failed to get reading. Try again!')
Beispiel #12
0
def initLCD(lcd=LCD()):
    lcd.stuur_instructie(56)  # 8-bit, 2 lines, character font 5x10
    lcd.stuur_instructie(12)  # display aan, cursor uit, cursor blink uit
    lcd.stuur_instructie(1)  # clear display en cursor home
Beispiel #13
0
def init_speed_distance(lcd=LCD()):
    lcd.stuur_tekst("Snelheid:")
    lcd.stuur_instructie(0x40 | 0b10000000)
    lcd.stuur_tekst("Afstand:")
    lcd.stuur_instructie(12)
Beispiel #14
0
from LCD import LCD
from mpd import MPDClient
import time
import random

DISP_LEN = 20
lcd = LCD()  # params available for rPi revision, I2C Address, and backlight on/off
# lcd = LCD(2, 0x3F, True)

client = MPDClient()
client.connect("localhost", 6600)


def display_long_text(from_ch, txt):
    return txt[from_ch:]


def display_text(txt, prev_pos=0):
    if len(txt) > DISP_LEN:
        if prev_pos == 0:
            return display_long_text(prev_pos, txt), prev_pos+1
        elif DISP_LEN-1 == (len(txt)-prev_pos):
            return display_long_text(prev_pos, txt), 0
        else:
            return display_long_text(prev_pos, txt), prev_pos+1
    else:
        return txt, 0


def parse_audio(audio):
    d = audio.split(":")
Beispiel #15
0
import time
import requests
from LCD import LCD

URL = 'http://localhost:8000'
LCD_ADDRESS = 0x27
lcd = LCD(2, LCD_ADDRESS, True)
lcd.clear()
counter = 0

while True:
    try:
        data = requests.get(URL).json()
        temp_text = '{:.1f}C'.format(data['temperature'])
        hum_text = '{:.1f}%'.format(data['humidity'])
        counter = (counter + 1) % 11
        temp_c = 0
        while temp_c < counter:
            temp_text = ' '+temp_text
            hum_text = ' '+hum_text
            temp_c += 1
        lcd.clear()
        lcd.message(temp_text, 1)
        lcd.message(hum_text, 2)
    except:
        lcd.clear()
        lcd.message("Service", 1)
        lcd.message("Unavailable", 2)
    time.sleep(3)
Beispiel #16
0
  display.write(get_date())
  now = datetime.datetime.now()
  sec = int(now.strftime("%S"))
  time.sleep(60-sec)
  display.clear_display()
  display.write(get_time())
  display.new_line()
  display.write(get_date())

def update():
  display.clear_display()
  display.write(get_time())
  display.new_line()
  display.write(get_date())
  
display = LCD(12, 16, 18, 22, 24, 26, 32, 36, 10, 8)

display.function_set()
display.init_cursor()
display.clear_display()

#start()

#while True:
  #time.sleep(60)
  #date = get_date()
  #time1 = get_time()
  #display.clear_display()
  #display.write(time1)
  #display.new_line()
  #display.write(date)