almost final
This commit is contained in:
parent
a048ddef66
commit
40fad6c142
|
@ -1,172 +0,0 @@
|
|||
:root {
|
||||
/* Set sans-serif & mono fonts */
|
||||
--sans-font: "IBM Plex Sans","Roboto",-apple-system,BlinkMacSystemFont,"Nimbus Sans L",Avenir,"Noto Sans", "Segoe UI",Arial,Helvetica,"Helvetica Neue",sans-serif;
|
||||
--mono-font: "IBM Plex Mono","Roboto Mono","Ubuntu Mono","Fira Code","Overpass Mono", Monaco,"Droid Sans Mono",monospace;
|
||||
/* Body font size. By default, effectively 18.4px, based on 16px as 'root em' */
|
||||
--base-fontsize: 1.2rem;
|
||||
/* Major third scale progression - see https://type-scale.com/ */
|
||||
--header-scale: 1.185;
|
||||
/* Line height is set to the "Golden ratio" for optimal legibility */
|
||||
--line-height: 1.618;
|
||||
/*This is my dark themed color scheme*/
|
||||
--bg: #FFFFFF;
|
||||
--accent-bg: #F2F4F8;
|
||||
--text: #4c566a;
|
||||
--text-light: #4c566a;
|
||||
--border: #3b4252;
|
||||
--accent: #5e81ac;
|
||||
--accent-light: #5e81ac;
|
||||
--code: #2e3440;
|
||||
--code-bg: #e5e9f0;
|
||||
}
|
||||
@media (prefers-color-scheme:dark) {
|
||||
:root {
|
||||
--bg: #242933;
|
||||
--accent-bg: #3b4252;
|
||||
--text: #eceff4;
|
||||
--text-light: #d8dee9;
|
||||
--border: #88c0d0;
|
||||
--accent: #a3be8c;
|
||||
--accent-light: #bf616a;
|
||||
--code: #ebcb8b;
|
||||
--code-bg: #2e3440;
|
||||
}
|
||||
}
|
||||
html{
|
||||
font-family: var(--sans-font);
|
||||
}
|
||||
hr{
|
||||
color: var(--border);
|
||||
}
|
||||
header{
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
margin: 1rem 0;
|
||||
|
||||
}
|
||||
body {
|
||||
padding: 20px;
|
||||
background-color: var(--bg);
|
||||
color: var(--text);
|
||||
font-size: 1.1rem;
|
||||
line-height: var(--line-height);
|
||||
margin: 0 auto;
|
||||
max-width: 50rem;
|
||||
}
|
||||
main img, main video, embed {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
opacity: 0.8;
|
||||
border-radius: 5px;
|
||||
}
|
||||
figure {
|
||||
margin: 0;
|
||||
}
|
||||
figcaption {
|
||||
font-size: .9rem;
|
||||
color: var(--text-light);
|
||||
text-align: center;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
blockquote {
|
||||
color: var(--text-light);
|
||||
font-style: italic;
|
||||
|
||||
}
|
||||
a {
|
||||
color: var(--accent);
|
||||
}
|
||||
a:hover {
|
||||
text-decoration: none
|
||||
}
|
||||
h1 {
|
||||
font-size: 1.3rem;
|
||||
color: var(--border);
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
h2, h3, h4, h5, h6 {
|
||||
font-size: 1.2rem;
|
||||
color: var(--accent-light);
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
p {
|
||||
padding: 0px;
|
||||
}
|
||||
code, pre, pre span, kbd, samp {
|
||||
font-family: var(--mono-font);
|
||||
color: var(--code);
|
||||
background: var(--code-bg);
|
||||
border-radius: 5px;
|
||||
padding: 0.12rem 0.3rem;
|
||||
}
|
||||
kbd {
|
||||
border: 1px solid var(--preformatted);
|
||||
border-bottom: 3px solid var(--preformatted);
|
||||
border-radius: 5px;
|
||||
padding: .1rem;
|
||||
}
|
||||
pre {
|
||||
padding: 1rem 1.4rem;
|
||||
max-width: 100%;
|
||||
overflow: auto;
|
||||
overflow-x: auto;
|
||||
background: var(--code-bg);
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
}
|
||||
pre code {
|
||||
font-family: var(--mono-font);
|
||||
background: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
svg {
|
||||
width: 36px;
|
||||
}
|
||||
/* Format navigation */
|
||||
nav a {
|
||||
background: var(--code-bg);
|
||||
margin: 1rem 0 0 .5rem;
|
||||
color: var(--border) !important;
|
||||
border-radius: 8px;
|
||||
display: inline-block;
|
||||
padding: .1rem .6rem;
|
||||
text-decoration: none;
|
||||
transition: .4s;
|
||||
}
|
||||
nav a.nav-current {
|
||||
background: var(--border);
|
||||
color: var(--bg) !important;
|
||||
font-weight: 700;
|
||||
opacity: 1;
|
||||
}
|
||||
nav a:hover {
|
||||
color: var(--bg) !important;
|
||||
border-color: var(--border);
|
||||
background: var(--border);
|
||||
}
|
||||
header h1{
|
||||
color: var(--accent) !important;
|
||||
display: inline-block;
|
||||
}
|
||||
header nav {
|
||||
display: inline-block;
|
||||
/*position: relative;*/
|
||||
}
|
||||
|
||||
a button,
|
||||
button,
|
||||
input[type="submit"],
|
||||
input[type="reset"],
|
||||
input[type="button"] {
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
background: var(--accent);
|
||||
font-size: 1rem;
|
||||
color: var(--bg);
|
||||
text-decoration: none;
|
||||
padding: .7rem .9rem;
|
||||
margin: .5rem .1rem;
|
||||
transition: .4s;
|
||||
}
|
|
@ -30,9 +30,7 @@ mysqli_close($conn);
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Login attempted</title>
|
||||
<meta name="description" content="Our first page">
|
||||
<meta name="keywords" content="html tutorial template">
|
||||
<title>Inicio de sesión</title>
|
||||
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Acceso VIP estacionamiento</title>
|
||||
<meta name="description" content="Our first page">
|
||||
<meta name="keywords" content="html tutorial template">
|
||||
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
</head>
|
||||
|
@ -17,7 +15,6 @@
|
|||
<input type="password" name="userpassword" required/><br>
|
||||
<button type="submit" name="register" value="registro">Iniciar sesión</button>
|
||||
</form>
|
||||
<p><a href="/web/register/">Registrar usuario frecuente</a></p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
104
parking.py
104
parking.py
|
@ -1,104 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
import RPi.GPIO as GPIO
|
||||
import pymysql
|
||||
import sys
|
||||
import os
|
||||
import time as t
|
||||
from gtts import gTTS as gt
|
||||
from datetime import datetime as dt
|
||||
|
||||
def angle_to_duty(angle):
|
||||
return (angle / 18 + 2)
|
||||
|
||||
def allow_entrance():
|
||||
servo.start(0)
|
||||
for i in range(0,91):
|
||||
servo.ChangeDutyCycle(angle_to_duty(i))
|
||||
t.sleep(0.004)
|
||||
t.sleep(1)
|
||||
for i in range(90,-1, -1):
|
||||
servo.ChangeDutyCycle(angle_to_duty(i))
|
||||
t.sleep(0.006)
|
||||
t.sleep(0.5)
|
||||
|
||||
|
||||
pressed = int(sys.argv[1])
|
||||
|
||||
db = pymysql.connect(host='localhost', user='pi2', passwd='emb20', db='parking_lot')
|
||||
cur = db.cursor()
|
||||
|
||||
servo_pin = 4
|
||||
pwm_freq = 50 # Nos referimos a un rango en Hz
|
||||
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO.setup(servo_pin, GPIO.OUT)
|
||||
servo = GPIO.PWM(servo_pin, pwm_freq)
|
||||
|
||||
if pressed == 1:
|
||||
try:
|
||||
space_num = int(sys.argv[2])
|
||||
pressed = 0
|
||||
query= "select spaceID from spaces where usedID = True"
|
||||
cur.execute(query)
|
||||
db.commit()
|
||||
spaces = cur.fetchall()
|
||||
if (len(spaces)) == 0:
|
||||
output="There are no cars inside"
|
||||
print(output)
|
||||
else:
|
||||
spaceID = space_num
|
||||
query= "select usedID from spaces where spaceID = {0}".format(spaceID)
|
||||
cur.execute(query)
|
||||
db.commit()
|
||||
spaces = cur.fetchall()
|
||||
if spaces[0][0] == True:
|
||||
print("<h2>Have a nice day!</h2>")
|
||||
print("<p>We hope to see you again!</p>")
|
||||
now = dt.now()
|
||||
date = now.date()
|
||||
time = now.time().replace(microsecond=0)
|
||||
query = "update spaces set date = '{0}', endTime = '{1}', usedID = False where spaceID = {2}".format(date, time, spaceID)
|
||||
cur.execute(query)
|
||||
db.commit()
|
||||
allow_entrance()
|
||||
else:
|
||||
print("<h2>This place is already empty!</h2>")
|
||||
output = "<p>Please input a valid number.</p>"
|
||||
print(output)
|
||||
pressed = 1
|
||||
except IndexError:
|
||||
print("<h2>This number is out of bounds!</h2>")
|
||||
output = "Please, input the spot you were assigned when you entered."
|
||||
print("<script>alert('{0}')</script>".format(output))
|
||||
|
||||
print(output)
|
||||
|
||||
pressed = 1
|
||||
|
||||
elif pressed == 2:
|
||||
try:
|
||||
pressed = 0
|
||||
query = "select spaceID from spaces where usedID = False and reserved = False order by spaceID desc"
|
||||
cur.execute(query)
|
||||
db.commit()
|
||||
spaces = cur.fetchall()
|
||||
status= "<p>Estacionese en el lugar <b>{0}</b>.".format(spaces[0][0])
|
||||
print("<h2>Disfrute su visita!</h2>")
|
||||
print(status)
|
||||
print("Bienvenido!</p>")
|
||||
|
||||
now = dt.now()
|
||||
date = now.date()
|
||||
time = now.time().replace(microsecond=0)
|
||||
query = "update spaces set date = '{0}', startTime = '{1}', endTime= NULL, usedID = True where spaceID = {2}".format(date, time, spaces[0][0])
|
||||
cur.execute(query)
|
||||
db.commit()
|
||||
allow_entrance()
|
||||
except IndexError:
|
||||
status ="<script>alert('Lo sentimos, ya no hay espacios disponibles')</script>"
|
||||
print(status)
|
||||
|
||||
servo.stop()
|
||||
GPIO.cleanup()
|
||||
db.close()
|
||||
sys.exit(0)
|
BIN
vip/file.png
BIN
vip/file.png
Binary file not shown.
Before Width: | Height: | Size: 859 B After Width: | Height: | Size: 1023 B |
|
@ -2,8 +2,6 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Usuarios frecuentes</title>
|
||||
<meta name="description" content="Our first page">
|
||||
<meta name="keywords" content="html tutorial template">
|
||||
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<style>
|
||||
|
@ -108,7 +106,5 @@ mysqli_close($conn);
|
|||
<footer>
|
||||
<p>Todos los derechos reservados (©).</p>
|
||||
</footer>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
Log file generated
|
||||
Log file generated
|
||||
09:07:05: car entered to space 15
|
||||
09:07:37: exit from space 09:07:37
|
||||
Log file generated
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/python3
|
||||
import RPi.GPIO as GPIO
|
||||
import pymysql
|
||||
import sys
|
||||
import os
|
||||
import time as t
|
||||
from gtts import gTTS as gt
|
||||
from datetime import datetime as dt
|
||||
|
||||
def angle_to_duty(angle):
|
||||
return (angle / 18 + 2)
|
||||
|
||||
def allow_entrance():
|
||||
servo.start(0)
|
||||
for i in range(0,91):
|
||||
servo.ChangeDutyCycle(angle_to_duty(i))
|
||||
t.sleep(0.004)
|
||||
t.sleep(1)
|
||||
for i in range(90,-1, -1):
|
||||
servo.ChangeDutyCycle(angle_to_duty(i))
|
||||
t.sleep(0.006)
|
||||
t.sleep(0.5)
|
||||
|
||||
|
||||
servo_pin = 4
|
||||
pwm_freq = 50 # Nos referimos a un rango en Hz
|
||||
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO.setup(servo_pin, GPIO.OUT)
|
||||
servo = GPIO.PWM(servo_pin, pwm_freq)
|
||||
|
||||
allow_entrance()
|
||||
servo.stop()
|
||||
GPIO.cleanup()
|
||||
db.close()
|
||||
sys.exit(0)
|
|
@ -0,0 +1,174 @@
|
|||
#!/usr/bin/python3
|
||||
import RPi.GPIO as GPIO
|
||||
import pymysql
|
||||
import sys
|
||||
import os
|
||||
import time as t
|
||||
from gtts import gTTS as gt
|
||||
from datetime import datetime as dt
|
||||
import adafruit_dht
|
||||
import signal
|
||||
|
||||
def signal_handler(sig,frame):
|
||||
print("Closing")
|
||||
servo.stop()
|
||||
GPIO.cleanup()
|
||||
db.close()
|
||||
sys.exit(0)
|
||||
|
||||
def angle_to_duty(angle):
|
||||
return (angle / 18 + 2)
|
||||
|
||||
def allow_entrance():
|
||||
servo.start(0)
|
||||
print("Opening entrance")
|
||||
for i in range(0,91):
|
||||
servo.ChangeDutyCycle(angle_to_duty(i))
|
||||
t.sleep(0.004)
|
||||
t.sleep(1)
|
||||
print("Closing entrance")
|
||||
for i in range(90,-1, -1):
|
||||
servo.ChangeDutyCycle(angle_to_duty(i))
|
||||
t.sleep(0.006)
|
||||
t.sleep(0.5)
|
||||
|
||||
def play_output(sound):
|
||||
print("playing sound")
|
||||
tts = gt(sound, lang = 'es')
|
||||
tts.save('sound.mp3')
|
||||
os.system("mpg123 -q sound.mp3")
|
||||
|
||||
def button_press_callback(channel):
|
||||
os.system("echo 'Log file generated' >> log.txt")
|
||||
print("Generating log file")
|
||||
# os.system("cat log.txt")
|
||||
|
||||
db = pymysql.connect(host='localhost', user='pi2', passwd='emb20', db='parking_lot')
|
||||
cur = db.cursor()
|
||||
|
||||
signal.signal(signal.SIGINT,signal_handler)
|
||||
|
||||
|
||||
BOTON = 14
|
||||
servo_pin = 4
|
||||
pwm_freq = 50 # Nos referimos a un rango en Hz
|
||||
pressed = 0
|
||||
ECHO = 16
|
||||
TRIG = 12
|
||||
|
||||
# Configuración del boton
|
||||
GPIO.setup(BOTON, GPIO.IN, pull_up_down = GPIO.PUD_UP)
|
||||
GPIO.add_event_detect(BOTON, GPIO.RISING, callback = button_press_callback, bouncetime = 500)
|
||||
|
||||
# Configuracion del sensor ultrasonico
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO.setup(TRIG, GPIO.OUT)
|
||||
GPIO.output(TRIG, False)
|
||||
GPIO.setup(ECHO, GPIO.IN)
|
||||
|
||||
# Configuracion del servomotor
|
||||
GPIO.setup(servo_pin, GPIO.OUT)
|
||||
servo = GPIO.PWM(servo_pin, pwm_freq)
|
||||
|
||||
while True:
|
||||
if pressed == 0:
|
||||
t.sleep(2)
|
||||
GPIO.output(TRIG, True)
|
||||
t.sleep(0.00001)
|
||||
GPIO.output(TRIG, False)
|
||||
|
||||
while GPIO.input(ECHO)==0:
|
||||
pulse_start = t.time()
|
||||
|
||||
while GPIO.input(ECHO)==1:
|
||||
pulse_end = t.time()
|
||||
|
||||
pulse_duration = pulse_end-pulse_start
|
||||
distance = pulse_duration*17150
|
||||
distance = round(distance,2)
|
||||
if distance < 5.0:
|
||||
pressed = int(input("Desea entrar[2] o salir?[1]:"))
|
||||
if pressed != 1 and pressed != 2:
|
||||
print("Ingrese un valor valido")
|
||||
pressed = 0;
|
||||
if pressed == 1:
|
||||
try:
|
||||
pressed = 0
|
||||
query= "select spaceID from spaces where usedID = True"
|
||||
cur.execute(query)
|
||||
db.commit()
|
||||
spaces = cur.fetchall()
|
||||
now = dt.now()
|
||||
date = now.date()
|
||||
time = now.time().replace(microsecond=0)
|
||||
if (len(spaces)) == 0:
|
||||
output="No hay carros en el estacionamiento"
|
||||
os.system("echo '{0}: invalid exit, no cars inside' >> log.txt".format(time))
|
||||
print(output)
|
||||
play_output(output)
|
||||
else:
|
||||
order = "Ingresa el numero de tu espacio: "
|
||||
play_output(order)
|
||||
spaceID = input(order)
|
||||
query= "select usedID from spaces where spaceID = {0}".format(spaceID)
|
||||
cur.execute(query)
|
||||
db.commit()
|
||||
spaces = cur.fetchall()
|
||||
if spaces[0][0] == True:
|
||||
recheck = "select reserved from spaces where spaceID = {0}".format(spaceID)
|
||||
cur.execute(recheck)
|
||||
db.commit()
|
||||
reservedspaces=cur.fetchall()
|
||||
query = "update spaces set date = '{0}', endTime = '{1}', usedID = False, reserved = False where spaceID = {2}".format(date, time, spaceID)
|
||||
cur.execute(query)
|
||||
db.commit()
|
||||
if reservedspaces[0][0] == True:
|
||||
response = "Saliendo de espacio reservado, en el futuro esto se verificara"
|
||||
print(response)
|
||||
play_output(response)
|
||||
os.system("echo '{0}: exit from reserved space {0}' >> log.txt".format(time, spaceID))
|
||||
else:
|
||||
order = "Puedes salir!"
|
||||
play_output(order)
|
||||
os.system("echo '{0}: exit from space {0}' >> log.txt".format(time, spaceID))
|
||||
allow_entrance()
|
||||
else:
|
||||
output = "Este espacio no esta ocupado"
|
||||
os.system("echo '{0}: invalid exit, no cars in selected space' >> log.txt".format(time))
|
||||
print(output)
|
||||
play_output(output)
|
||||
pressed = 1
|
||||
except IndexError:
|
||||
now = dt.now()
|
||||
time = now.time().replace(microsecond=0)
|
||||
os.system("echo '{0}: invalid value, outside of bounds' >> log.txt".format(time))
|
||||
output = "Valor inválido"
|
||||
print(output)
|
||||
play_output(output)
|
||||
pressed = 1
|
||||
|
||||
elif pressed == 2:
|
||||
now = dt.now()
|
||||
date = now.date()
|
||||
time = now.time().replace(microsecond=0)
|
||||
try:
|
||||
query = "select spaceID from spaces where usedID = False and reserved = False order by spaceID desc"
|
||||
cur.execute(query)
|
||||
db.commit()
|
||||
spaces = cur.fetchall()
|
||||
status= "Favor de estacionarse en el lugar{0}".format(spaces[0][0])
|
||||
os.system("echo '{0}: car entered to space {1}' >> log.txt".format(time, spaces[0][0]))
|
||||
print(status)
|
||||
play_output(status)
|
||||
query = "update spaces set date = '{0}', startTime = '{1}', endTime= NULL, usedID = True where spaceID = {2}".format(date, time, spaces[0][0])
|
||||
cur.execute(query)
|
||||
db.commit()
|
||||
print("commit query")
|
||||
pressed = 0
|
||||
allow_entrance()
|
||||
except IndexError:
|
||||
status ="Ya no hay espacios disponibles"
|
||||
os.system("echo '{0}: no available spaces' >> log.txt".format(time))
|
||||
print(status)
|
||||
play_output(status)
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/python3
|
||||
import RPi.GPIO as GPIO
|
||||
import pymysql
|
||||
import sys
|
||||
import os
|
||||
import time as t
|
||||
from gtts import gTTS as gt
|
||||
from datetime import datetime as dt
|
||||
|
||||
def angle_to_duty(angle):
|
||||
return (angle / 18 + 2)
|
||||
|
||||
def allow_entrance():
|
||||
servo.start(0)
|
||||
for i in range(0,91):
|
||||
servo.ChangeDutyCycle(angle_to_duty(i))
|
||||
t.sleep(0.004)
|
||||
t.sleep(1)
|
||||
for i in range(90,-1, -1):
|
||||
servo.ChangeDutyCycle(angle_to_duty(i))
|
||||
t.sleep(0.006)
|
||||
t.sleep(0.5)
|
||||
|
||||
now = dt.now()
|
||||
time = now.time().replace(microsecond=0)
|
||||
|
||||
|
||||
servo_pin = 4
|
||||
pwm_freq = 50 # Nos referimos a un rango en Hz
|
||||
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO.setup(servo_pin, GPIO.OUT)
|
||||
servo = GPIO.PWM(servo_pin, pwm_freq)
|
||||
|
||||
os.system('echo "{0}reserved space claimed" >> log.txt'.format(time))
|
||||
|
||||
allow_entrance()
|
||||
servo.stop()
|
||||
GPIO.cleanup()
|
||||
db.close()
|
||||
sys.exit(0)
|
Binary file not shown.
|
@ -23,6 +23,12 @@ else{
|
|||
|
||||
$query = "update spaces set usedID = True where spaceID = (select place from users where id = $iduser and password = '$secret')";
|
||||
$validate = $conn->query($query);
|
||||
$currentDate = new DateTime();
|
||||
$time = $currentDate->format('H:i:s');
|
||||
$var = "$time : reserved space claimed";
|
||||
echo "<var>", $var;
|
||||
exec("sudo ./servo.py ");
|
||||
//exec('sudo qrencode -s 20 -o file.png '. $url);
|
||||
//$query = "update users set place = NULL where id = $iduser";
|
||||
//$validate = $conn->query($query);
|
||||
//sudo
|
||||
|
|
Loading…
Reference in New Issue