示例#1
0
def CheckTemp(): 
    global temp
    global temp_set
    global heating
    global mode
    global current_hour
    global wait_action
    global RELAY_WAIT
    global ivac
    global fvac
    global tvac
    if (current_hour!=time.localtime().tm_hour): # Change of the hour
        current_hour=time.localtime().tm_hour
        if (mode==SEMI): # If the thermostat was in semi automatic mode, it reverts to full automatic
            mode=AUTO
    if (mode==AUTO): # If mode is automatic, gets target temp from the hourly list
        temp_set=temp_list[current_hour]
    d=datetime.date.fromtimestamp(time.time())
    if (d>=ivac) and (d<=ivac): # If inside holidays range, use related temperature and reverts to automatic
        temp=tvac
        mode=AUTO
    if (temp<temp_set)and(wait_action==0): # Turn on the heating system if possible
        heating=True
        GPIO.output(RELAY,0)
        wait_action=RELAY_WAIT
    if (temp>temp_set)and(wait_action==0): # Turn off the heating system if possible
        heating=False
        GPIO.output(RELAY,1)
        wait_action=RELAY_WAIT
示例#2
0
 def on(self):
     GPIO.output(self.BACK_LIGHT,0)
示例#3
0
 def off(self):
     GPIO.output(self.BACK_LIGHT,1)
示例#4
0
def closeDoor():
    print "Clossing..."
    GPIO.output(17,False)
    GPIO.output(18,True)
    isopen = False
    opencnt = 0
示例#5
0
def openDoor ():
    print "Opening..."
    GPIO.output(18,False)
    GPIO.output(17,True)
    isopen = True
    opencnt = 40
示例#6
0
import ST7735 as TFT
import Adafruit_GPIO as GPIO
import Adafruit_GPIO.SPI as SPI
import qrcode
from nomorepass.core import NoMorePass
from uuid import getnode as get_mac
import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)

GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(17, GPIO.OUT)
GPIO.setup(18, GPIO.OUT)
GPIO.output(17,True)

isopen = False
opencnt = 0

mac = get_mac()
macaddr = ':'.join(("%012X" % mac)[i:i+2] for i in range(0, 12, 2))

WIDTH = 128
HEIGHT = 160
SPEED_HZ = 4000000


# Raspberry Pi configuration.
DC = 24
RST = 25
示例#7
0
def LCD_Light(val): 
    global backlight
    if (val==1):
        GPIO.output(backlight, GPIO.HIGH)
    else:
        GPIO.output(backlight, GPIO.LOW)
示例#8
0
RST = 23       # TFT parameter
SPI_PORT = 0   # TFT parameter
SPI_DEVICE = 0 # TFT parameter
backlight = 18 # LCD backlight
GPIO.setup(backlight, GPIO.OUT)
B1 = 17 # Button 1 ******Verificare
GPIO.setup(B1, GPIO.IN, pull_up_down=GPIO.PUD_UP)
B2 = 22 # Button 2 ******Verificare
GPIO.setup(B2, GPIO.IN, pull_up_down=GPIO.PUD_UP)
B3 = 23 # Button 3 ******Verificare
GPIO.setup(B3, GPIO.IN, pull_up_down=GPIO.PUD_UP)
B4 = 27 # Button 4 ******Verificare
GPIO.setup(B4, GPIO.IN, pull_up_down=GPIO.PUD_UP)
RELAY = 24 # Relay control
GPIO.setup(RELAY, GPIO.OUT)
GPIO.output(RELAY,1) # initial status = heating off (relay not active)
tlist=[] # Array for temp mean
max_t_num = 10 # Numbero of readings for mean calculation

# Creates screen image and TFT instance
screen = Image.new("RGB", (320, 240), "white")
disp = TFT.ILI9341(DC, rst=RST, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=64000000))
disp.begin()

# **********************************************************
# Thermostat functions
# **********************************************************

#** Returns if the Raspberry is connected to the LAN
def Connected():
    ipaddress=socket.gethostbyname(socket.gethostname())
示例#9
0
        dist_sens = False
        time.sleep(0.2)
    else:
        dist_sens = True
    #--------------------DISTANCE SENSOR DATA SCREEN--------------------
    if (dist_sens == False):
        sens_accX, sens_accY, sens_accZ = motion.accelerometer()

        draw.rectangle((217, 310, 23, 260), outline=(255, 255, 255), fill=(0, 120, 255))

        draw.rectangle((217, 250, 23, 200), outline=(255, 255, 255), fill=(0, 120, 255))
        i = sens_accY * 57.295779513
        w, h = draw.textsize(str(round(int(i))))
        draw_rotated_text(disp.buffer, str(round(i)), (120 - w, 220), text_rotation, font,fill=(255, 255, 255))

        GPIO.output(TRIG, False)
        time.sleep(0.1)
        GPIO.output(TRIG, True)
        time.sleep(0.00001)
        GPIO.output(TRIG, False)
        while GPIO.input(ECHO) == 0:
            pulse_start = time.time()
        while GPIO.input(ECHO) == 1:
            pulse_end = time.time()
        pulse_duration = (pulse_end - pulse_start)
        distance = pulse_duration * 17150
        distance = round(distance, 2)
        if distance > 2 and distance < 400:  # Check whether the distance is within range
            w, h = draw.textsize(str(distance)+"cm")
            draw_rotated_text(disp.buffer,str(distance - 0.5) + "cm", (120-w, 280), text_rotation, font, fill=(255, 255, 255))
        else: