Пример #1
0
 def handle_connect(self):
   self.keepalive()
   keypad.keypad(keypad.init_input(self.wsid), self)
   self.machine('')
   #--------------
   self.pbmpkt_hdr = ''
   self.pbmpkt_buf = ''
   self.pbmpkt_len = 0
Пример #2
0
 def keycontrol(self):
     mapping = {
         # KEY BINDINGS: key to function (with default value)
         # ROVER KEYS
         'w': 'fw', 's': 'rw', 'a': 'left', 'd': 'right',
         ' ': 'stop', 'r': 'init_log', 't': 'save_log',
         # JIB KEYS
         'i': 'jib.moveup', 'j': 'jib.moveleft',
         'k': 'jib.movedw', 'l': 'jib.moveright',
         # MEASURE DISTANCE
         'm': 'print_distance'
     }
     print "ROVER KEYPAD: initialized"
     keypad.keypad(self, mapping)
     print "ROVER KEYPAD: terminated"
Пример #3
0
def main():

    ### KEYPAD INITIALIZATION ###
    kp = keypad(columnCount=4)
    digit = None

    #global target
    global target
    target = ""
    print("Enter your zip code or press '#' for Irvine: ")
    for i in range(5):
        digit = None
        while digit == None:
            digit = kp.getKey()
        if (digit == "#"):
            break
        print(digit)
        target = target + str(digit)
        time.sleep(0.4)

    ### END KEYPAD ###

    relay_motion.setup()
    current_hr = datetime.datetime.now().time().hour
    print(current_hr)
    mylcd = I2C_LCD_driver.lcd()
    #current_hr = 18
    rpi_data.read_sensors(current_hr, mylcd)
Пример #4
0
 def keycontrol(self):
     mapping = {
         # KEY BINDINGS: key to function (with default value)
         # ROVER KEYS
         'w': 'fw',
         's': 'rw',
         'a': 'left',
         'd': 'right',
         ' ': 'stop',
         'r': 'init_log',
         't': 'save_log',
         # JIB KEYS
         'i': 'jib.moveup',
         'j': 'jib.moveleft',
         'k': 'jib.movedw',
         'l': 'jib.moveright',
         # MEASURE DISTANCE
         'm': 'print_distance'
     }
     print "ROVER KEYPAD: initialized"
     keypad.keypad(self, mapping)
     print "ROVER KEYPAD: terminated"
Пример #5
0
 def keycontrol(self):
     mapping = {
         # KEY BINDINGS: key to function (with default value)
         # ROVER KEYS
         "w": "fw",
         "s": "rw",
         "a": "left",
         "d": "right",
         " ": "stop",
         "r": "init_log",
         "t": "save_log",
         # JIB KEYS
         "i": "jib.moveup",
         "j": "jib.moveleft",
         "k": "jib.movedw",
         "l": "jib.moveright",
         # MEASURE DISTANCE
         "m": "print_distance",
     }
     print "ROVER KEYPAD: initialized"
     keypad.keypad(self, mapping)
     print "ROVER KEYPAD: terminated"
Пример #6
0
def handler():

    mqttfunc(txt, 'open', 0, 0)
    kp = keypad(columnCount=3)
    print("Enter the amount of items inserted")

    digit1 = None
    while digit1 == None:
        digit1 = kp.getKey()
        time.sleep(0.2)
    digit2 = None
    while digit2 == None:
        digit2 = kp.getKey()
        time.sleep(0.2)
    digit3 = None
    while digit3 == None:
        digit3 = kp.getKey()
        time.sleep(0.2)

    try:
        conn = sqlite3.connect("mydb.db")
        print("Connected to database")
        cur = conn.cursor()
        cur.execute("SELECT * FROM counttable")
        res = cur.fetchall()

        for i in res:
            print(i)
        print("values of counttable")
        v1 = int(res[0][1])
        v2 = int(res[0][2])
        v3 = int(res[0][3])

        cur.execute(
            "UPDATE counttable SET count1 = ?, count2 = ?, count3 = ? WHERE pkey=1;",
            (digit1, digit2, digit3))
        conn.commit()

        cur.execute("Select * from counttable")
        result = cur.fetchall()
        for i in result:
            print(i)
        mqttfunc(txt, 'close', 0, 0)

    except:
        print("Error in Setting Data")


#end of handler function
Пример #7
0
def getKeyPress(maxwait):
	#Set timeout for how long we wait for button press
	if maxwait == 0:
		timeout = 10000000  #about 110 days
	else:
		timeout = maxwait
		
	kp = keypad(columnCount = 4)
	digit = None
	starttime = time.perf_counter()

	while digit == None and time.perf_counter() - starttime <= timeout:
		digit = kp.getKey()
		time.sleep(0.02)

	if time.perf_counter() - starttime > timeout:
		#we timed out
		return -1
	digit = '0123456789X#*ABCD'.find(str(digit))

	playTouchTone(digit)
	return digit
Пример #8
0
import keypad
import time
import takePhoto
import deal
import threading
import time
import requests
import stepMotor
import postUnLock
import postConfidence

kp = keypad.keypad()

global flag
flag = False  #flag some open method in proccess

mutex = threading.Lock()

global t
t = False


def faceOrKeyOpen():
    global flag, mutex
    #time.sleep(1)
    while True:
        digit = None
        while digit == None:
            digit = kp.getKey()
        #print digit
        #face
Пример #9
0
#!/usr/bin/python3

import keypad
import time

keypad = keypad.keypad()

while (True):
    time.sleep(1)
    print(keypad.getKey())
Пример #10
0
import I2C_LCD_driver
import keypad
import time
import ServoLock as Lock
import LockToggle_pushButton as LockToggle
import LockIndicator_RGB as  LockIndicator

mylcd = I2C_LCD_driver.lcd()
kp = keypad.keypad()
fo = open("foo.txt", "r")
RightPass = fo.read(4)

def getPassword():
    password = ''
    char = ''
    while len(password) < 4 or (char != '#'):
        char = getChar()
        if char == '*':
            password = password[:-1]
        elif char == '#' or len(password) >= 4:
            pass
        else:
            password += str(char)
        mylcd.lcd_display_string((password + '    '), 2, 0)
        print(password)
    return password

def getChar():
    digit = None
    while digit == None:
        digit = kp.getKey()
Пример #11
0
    update = json.loads(incoming)
    password_list.append((update['pwd'], update['min'], update['max']))


def valid_pwd(input):
    now = time.time()
    for entry in password_list:
        if (input == entry[0] and
            (now > entry[1] and now < entry[2] or entry[1] == entry[2] == 0)):
            return True
    return False


broker_address = "broker.mqttdashboard.com"
mqtt_pwd_update_t = "ECE/lockbox/updates/asd"
foo = keypad()
password_list = [([4, 5, 6, 7], 0, 0), ([7, 7, 7, 7], 0, 0)]
client = mqtt.Client()
client.on_message = on_message
client.connect(broker_address)
client.loop_start()
client.subscribe(mqtt_pwd_update_t)


def email_owner(body_text):
    send_email(sender="Tran <*****@*****.**>",
               recipients=['*****@*****.**'],
               subject="Lockbox notice!",
               body_text=body_text)

Пример #12
0
logging.basicConfig(filename=UID + '_dispenser_log_' +
                    time.strftime("%Y%m%d") + '.csv',
                    filemode='a',
                    format='%(asctime)s %(message)s',
                    datefmt="%Y-%m-%d; \t %H:%M:%S;",
                    level=logging.INFO)

logfile = open(UID + "_dispenser_log_" + time.strftime("%Y%m%d") + ".csv", "a")
logfile.write(
    "Date; \tTime; \tMessage; \tQuantity; \tUnit; \tUID; \tStore; \tLocation; \tProduct; \tTransaction;\n"
)
logfile.close()

GPIO.setwarnings(False)

kp = keypad(columnCount=3)


def solenoidon():
    GPIO.output(solenoid, GPIO.HIGH)


def solenoidoff():
    GPIO.output(solenoid, GPIO.LOW)


def beepbeep():
    noiseon()
    time.sleep(0.1)
    noiseoff()
    time.sleep(0.1)
Пример #13
0
#!/usr/bin/python

import keypad as GPIO_Keypad

import time

try:
    keypad = GPIO_Keypad.keypad(columnCount=7)
    arrows = GPIO_Keypad.keypad(columnCount=2)
    # Loop while waiting for a keypress
    var = 1
    while var == 1:
        digit = keypad.getKey()
        #arrows = keypad.getKey()
        if digit != None:
            print digit
        #if arrows != None:
        #print arrows

        if digit != None:
            time.sleep(1)

except KeyboardInterrupt:
    # here you put any code you want to run before the program
    # exits when you press CTRL+C
    print "\n", counter  # print value of counter
    GPIO_Keypad.cleanup()

except:
    # this catches ALL other exceptions including errors.
    # You won't get any error messages for debugging
Пример #14
0
        # if less than 4 enough numbers entered
        if pressed_key != passcode[len(current_code)]:
            # if passcode until now doesn't match
            passcode_is_incorrect()
        else:
            # if it does match, add to list
            current_code.append(pressed_key)
    elif pressed_key == "#" and "".join(current_code) == passcode:
        # if "#" is pressed and current passcode match our passcode
        passcode_is_correct()
    else:
        passcode_is_incorrect()


# keypad
keypad(handler=get_key)  # perform get_key() function on keypress.

try:
    # turn  OFF, turns off fan
    GPIO.output(ledRed, GPIO.LOW)
    GPIO.output(ledBlu, GPIO.LOW)
    GPIO.output(ledGrn, GPIO.LOW)
    GPIO.output(fan, GPIO.LOW)

    # By default the address of LM75A is set to 0x48
    # aka A0, A1, and A2 are set to GND (0v).
    address = 0x48

    # Check if another address has been specified
    if 1 < len(sys.argv):
        address = int(sys.argv[1], 16)
Пример #15
0
from time import sleep
from random import randint
from keypad import keypad
from datetime import datetime
import threading

import RPi.GPIO as GPIO
app = Flask(__name__)
CORS(app)

GPIO.setmode(GPIO.BCM)

lcd = lcd_driver.lcd()
reader = SimpleMFRC522()
conn = Database(app, 'mct', 'mct', 'project', '192.168.0.10')
kp = keypad()


# reads rfid card to unlock door
def scan_unlock():
    while True:
        print('READY FOR SCAN')
        try:
            # clear screen and display welcome message
            lcd.lcd_clear()
            lcd.lcd_display_string('SCAN 2 UNLOCK', 1, 1)

            # call reader to read id from rfid card
            card_id, text = reader.read()
            print('ID: ')
            print(card_id)