Beispiel #1
0
 def __new__(cls, number):
     if not cls._PINS:
         GPIO.setmode(GPIO.BCM)
         GPIO.setwarnings(False)
     if cls.PI_INFO is None:
         cls.PI_INFO = pi_info("900092")
         #Fake a Pi Zero 1.2, Closest device as just has GPIO Pins and no camera.
         #cls.PI_INFO = 900092
     try:
         return cls._PINS[number]
     except KeyError:
         self = super(RTkGPIOPin, cls).__new__(cls)
         try:
             cls.PI_INFO.physical_pin('GPIO%d' % number)
         except PinNoPins:
             warnings.warn(
                 PinNonPhysical('no physical pins exist for GPIO%d' %
                                number))
         self._number = number
         self._pull = 'up' if cls.PI_INFO.pulled_up('GPIO%d' %
                                                    number) else 'floating'
         self._pwm = None
         self._frequency = None
         self._duty_cycle = None
         self._bounce = -666
         self._when_changed = None
         self._edges = GPIO.BOTH
         GPIO.setup(self._number, GPIO.IN, self.GPIO_PULL_UPS[self._pull])
         cls._PINS[number] = self
         return self
Beispiel #2
0
 def __new__(cls, number):
     if not cls._PINS:
         GPIO.setmode(GPIO.BCM)
         GPIO.setwarnings(False)
     if cls.PI_INFO is None:
         cls.PI_INFO = pi_info("900092")
         #Fake a Pi Zero 1.2, Closest device as just has GPIO Pins and no camera.
         #cls.PI_INFO = 900092
     try:
         return cls._PINS[number]
     except KeyError:
         self = super(RTkGPIOPin, cls).__new__(cls)
         try:
             cls.PI_INFO.physical_pin('GPIO%d' % number)
         except PinNoPins:
             warnings.warn(
                 PinNonPhysical(
                     'no physical pins exist for GPIO%d' % number))
         self._number = number
         self._pull = 'up' if cls.PI_INFO.pulled_up('GPIO%d' % number) else 'floating'
         self._pwm = None
         self._frequency = None
         self._duty_cycle = None
         self._bounce = -666
         self._when_changed = None
         self._edges = GPIO.BOTH
         GPIO.setup(self._number, GPIO.IN, self.GPIO_PULL_UPS[self._pull])
         cls._PINS[number] = self
         return self
Beispiel #3
0
# Import libraries
import threading
from time import strftime
from bs4 import BeautifulSoup
from RTk import GPIO
import sqlite3
from datetime import datetime, timedelta

# setup GPIO PINS
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setwarnings(False)

# Define variables
pollcount = 0
increment = 1
statusPath = "PATH/nginx/html/status.html"
closed = datetime.now()
writeentry = True

# check if database is built and build SQL connection to sqlite database
con = sqlite3.connect("Database location")
cur = con.cursor()
cur.execute(
    "SELECT count(*) FROM sqlite_master WHERE type='table' and name='" +
    datetime.now().strftime("%m/%d/%Y") + "_time_log';")
if cur.fetchone()[0] == 0:
    cur.execute("CREATE TABLE '" + datetime.now().strftime("%m/%d/%Y") +
                "_time_log' (in_time, out_time);")
con.commit()
con.close()