Ejemplo n.º 1
0
Archivo: ttp223.py Proyecto: oronum/upm
def main():
    # Create the TTP223 touch sensor object using GPIO pin 0
    touch = ttp223.TTP223(0)

    # Check whether or not a finger is near the touch sensor and
    # print accordingly, waiting one second between readings
    while 1:
        if touch.isPressed():
            print touch.name(), 'is pressed'
        else:
            print touch.name(), 'is not pressed'
        time.sleep(1)

    # Delete the touch sensor object
    del touch
        myLcd.setColor(255, 0, 0)
    elif (percentage <= 0.50):
        myLcd.setColor(255, 165, 0)
    elif (percentage <= 0.75):
        myLcd.setColor(255, 255, 0)
    elif (percentage <= 1):
        myLcd.setColor(0, 255, 0)
    myLcd.setCursor(1, 0)
    if (value < 10):
        myLcd.write("Available: " + "0" + str(currentCapacity))
    else:
        myLcd.write("Available: " + str(currentCapacity))


# Create the touch object using GPIO pin 4
touch1 = ttp223.TTP223(4)
# Create the button object using GPIO pin 8
button = grove.GroveButton(8)
#Create the lcd object
myLcd = lcd.Jhd1313m1(4, 0x3E, 0x62)
#Values from the db
currentCapacity = checkCapacity("Z2", urlzone)
capacity = checkMax("Z2", urlzone)

#LCD first display
myLcd.setCursor(0, 0)
myLcd.write("zone: " + str(checkZone("Z2", urlzone)))
changeLCD(currentCapacity, capacity)


def exit(touch, tId, url):
Ejemplo n.º 3
0
import pyupm_ttp223 as t
from time import sleep

touch = t.TTP223(4)

while True:
    if touch.isPressed():
        print 'Sensor is pressed'
    else:
        print 'Sensor is not pressed'
    sleep(1.0)
import time
#Import button and touch sensor
import pyupm_ttp223 as ttp223 #Touch Sensor
import pyupm_grove as grove # Grove button
import requests
import json

#
url = "http://requestb.in/1mj62581?inspect"
#Format for the request
headers = {'content-type': 'application/json'}

#Create a touch sensor object using GPIO pin 4
touch = ttp223.TTP223(4)
#Create a button object using GPIO pin 8
button = grove.GroveButton(8)


#Function to read the input from the touch sensor on the entrance and send the data
def sendInfo(touch, tId, aID):
    if touch.isPressed():
    	print "Send Info"
            data = {"Id": aID, "Espacio": tId, "Disponible": False}
            data = json.dumps(data)
            requests.post(url, params=data, headers=headers)
    return Pressed

#Function to read the input from the button in the exit and send the data
def enter(button, tID, aID):
	if(button.value()!= 0):
		data = {"Id": "AI", "Espacio": tId, "Disponible": True}
import time
import pyupm_ttp223 as ttp223
import requests
import json

url = "http://requestb.in/1mj62581?inspect"
headers = {'content-type': 'application/json'}

touch1 = ttp223.TTP223(4)
touch1Pressed = False
touch2 = ttp223.TTP223(8)
touch2Pressed = False


def sendInfo(touch, tId, Pressed):
    if touch.isPressed():
        if not Pressed:
            print "Send Info"
            Pressed = True
            data = {"Id": "AI", "Espacio": tId, "Disponible": False}
            data = json.dumps(data)
            requests.post(url, params=data, headers=headers)
    else:
        if Pressed:
            print "Send Info"
            Pressed = False
            data = {"Id": "AI", "Espacio": tId, "Disponible": True}
            data = json.dumps(data)
            requests.post(url, params=data, headers=headers)
    return Pressed
while True:
Ejemplo n.º 6
0
# Pins used in Grove kit.
EMERGENCY_BUTTON = 3
ALERT_LED = 4

# Alarm status.
ON = True
OFF = False
alarm_status_list = {ON: "on", OFF: "off"}

# Succes code for Bluetooth commands.
SUCCESS_CODE = "OK"

# Initialize your devices.
alarm_led = grove.GroveLed(ALERT_LED)
emergency_button = ttp.TTP223(EMERGENCY_BUTTON)

# Initialize flags.
initialized = False
emergency_button_released = True
alarm_status = OFF


def toggleAlarm(alarmed):
    global alarm_status

    if alarmed:
        alarm_led.on()
        alarm_status = ON
    else:
        alarm_led.off()
Ejemplo n.º 7
0
import requests
import time
import pyupm_grove as grove
import pyupm_i2clcd as lcd
import pyupm_ttp223 as ttp223

touchSensor = ttp223.TTP223(2)

button = grove.GroveButton(3)

lcdDisplay = lcd.Jhd1313m1(0, 0x3E, 0x62)
lcdDisplay.setCursor(0, 0)

touchCounter = 0
buttonCounter = 0

dispPlaces = 20


def updateInfo(info):
    global dispPlaces
    s = requests.post('http://45.40.137.37:88/sensor', {
        "zone": 1,
        "parkID": 1,
        "status": info
    })
    print(s.text)
    print dispPlaces


def parkInfo():