Пример #1
0
def Main():
    
    try:
	#Création d'une instance pour gérer la lecture du fichier d'accès
    	fichier = access_file.AccessFile()
	
	#Initialisation des entrées/sorties du raspberry
	InitGpio()

	#Initialisation de l'afficheur
	afficheur = lcd_display.lcd()

	#Obtention de l'adresse IP
	time.sleep(2)
	addip = fichier.GetIpAddress('eth0')
	print "Adresse IP (eth0) : %s" % addip
        Debug("GetIpAddresse : %s" % addip)

	#On récupère l'adresse ip du fichier de config
	ip_borne = ReadConfigFile()
        print "Adresse IP (ini) : %s" % ip_borne
	Debug("ReadConfigFile : %s" % ip_borne)

	#Affichage de l'ip
	if str(addip) == ip_borne:
	    GPIO.PWM(LED_BLUE, 10)
	    GPIO.output(LED_BLUE, True)
	    	
	#Boucle de lecture
	while True:

    	    cardId = ReadNFC()
	    Debug("ReadNFC : lecture carte, uid (" + cardId + ")") 
            
	    test = fichier.SearchCardId(cardId)
            if test == True:
	        print "Accès Autorisé"
		Debug("Borne : carte autorisée, uid (" + cardId + ")")
		LedBlink('green')
		afficheur.lcd_string("PASS : AUTORISE", 2)
    	    else:
        	print "Non autorisé"
		Debug("Borne : carte non autorisée/inconnue, uid (" + cardId + ")")
		LedBlink('red')
		afficheur.lcd_string("PASS : INTERDIT", 2)
	    time.sleep(1)
	    afficheur.lcd_clear()

    except KeyboardInterrupt:
        Debug("KeyboardInterrupt : arrêt ctrl+c")
	#GPIO.cleanup()
        pass
    GPIO.cleanup()
    Debug("GPIO.cleanup : réinitialisation du GPIO") 
Пример #2
0
from lcd_display import lcd
import RPi.GPIO as GPIO
import time
import dht11
import os

file = open("id.txt", "r")
id = file.read()
id = id[:-1]

GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.cleanup()

cidlo = dht11.DHT11(pin = 11)
displej = lcd()

displej.display_string("Nacitam data", 1)

while (1):
        data = cidlo.read()
	if data.is_valid():
		teplota = data.temperature
		vlhkost = data.humidity

		adresa = "https://ioe.zcu.cz/th.php?id=" + str(id) + "&temperature=" + str(teplota) + "&humidity=" + str(vlhkost)
				
		os.system('curl "' + adresa + '"') 

                displej.display_string("Teplota je: %d C " % teplota, 1)
                displej.display_string("Vlhkost je: %d %%" % vlhkost, 2)
Пример #3
0
#!/usr/bin/python
###
# Kerkradio versie 2.0
# Kees Nobel
# Twitter: @keesnobel

import time
import RPi.GPIO as GPIO
import os
import threading
from time import sleep
import lcd_display

lcd = lcd_display.lcd()
from urllib2 import urlopen
import commands
from datetime import datetime
import pyspeedtest
import psutil
from subprocess import check_output
import logging

#Button config
POWER = 24
LINKS = 18
RECHTS = 17
NEER = 4
OP = 10
LED = 27
RELAIS = 23
Пример #4
0
import sys
import time
import signal
import lcd_display as ld
from datetime import datetime


def signal_handler(signum, frame):
    print('Turning display off...')
    mylcd.lcd_clear()
    mylcd.backlight(0)
    sys.exit(0)


signal.signal(signal.SIGINT, signal_handler)

mylcd = ld.lcd()
mylcd.lcd_clear()
mylcd.lcd_display_string('Hello, World!', 1)
mylcd.lcd_display_string('Parth\'s Raspberry Pi', 4)

while True:
    mylcd.lcd_display_string(datetime.now().strftime('%I:%M %p'), 2)
    time.sleep(0.001)
Пример #5
0
#!/usr/bin/python

import bluetooth
import time
from lcd_display import lcd

d = lcd()
d.clear()
d.display_string("Who's Home?", 1)

sleep_time = 600

while True:
    string = ''

    result = bluetooth.lookup_name('1C:66:AA:CF:DD:35', timeout=5)
    if (result != None):
        string = string + ' Dad'
    d.display_string(string, 2)

    result = bluetooth.lookup_name('94:3A:F0:63:2D:99', timeout=5)
    if (result != None):
        string = string + ' Mum'
    d.display_string(string, 2)

    result = bluetooth.lookup_name('34:BB:1F:39:DE:12', timeout=5)
    if (result != None):
        string = string + ' Sophie'
    d.display_string(string, 2)

    f = open('whoshome.log', 'a')
Пример #6
0
from lcd_display import lcd
from time import sleep

a = lcd()

a.clear()

while 1:
    a.display_string("     ------      ***", 1)
    a.display_string("      ----        **", 2)
    a.display_string("  @                 ", 3)
    a.display_string("--------------------", 4)

    a.display_string("  @                +", 3)
    a.display_string("  @               + ", 3)
    a.display_string("  @              +  ", 3)
    a.display_string("  @             +   ", 3)
    a.display_string("  @            +    ", 3)
    a.display_string("  @           +     ", 3)
    a.display_string("  @          +      ", 3)
    a.display_string("  @         +       ", 3)
    a.display_string("  @        +        ", 3)
    a.display_string("  @       +         ", 3)
    a.display_string("  @      +          ", 3)
    a.display_string("  @     +           ", 3)
    a.display_string("  @    +            ", 3)
    a.display_string("  @   +             ", 3)
    a.display_string("  @  +              ", 3)
    a.display_string("  @   ----        **", 2)
    a.display_string("    +               ", 3)
    a.display_string("   +                ", 3)
Пример #7
0
    time.sleep(d)
    GPIO.output(11, True)
    time.sleep(d)


# use Pi board pin numbers with GPIO.BOARD
GPIO.cleanup()
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.OUT)
GPIO.setup(7, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# see http://elinux.org/Rpi_Low-level_peripherals
# see http://pypi.python.org/pypi/RPi.GPIO

# initialise the lcd display
lcd1 = lcd()
lcd1.clear()
lcd1.display_string("Picture Taker", 1)

flash(0.2)
flash(0.2)

while True:

    # Check camera is present
    while not os.path.exists('/dev/video0'):
        lcd1.display_string("No Camera", 2)
        time.sleep(1.0)

    lcd1.display_string("ready", 2)
Пример #8
0
""" 
This is the script that will be run on the Pi to fetch the message being displayed.
"""
import requests
import time
from lcd_display import lcd

my_lcd = lcd()
my_lcd.backlight(0)


def update_lcd():
    """
    Updates lcd screen to show most recently submitted message from web app.
        * Remember to change the URL after web app goes live. *
    """
    while True:
        message = requests.get('http://127.0.0.1:5000/message').text
        my_lcd.lcd_display_string(message, 2)
        time.sleep(3)


if __name__ == '__main__':
    update_lcd()
Пример #9
0
teplota = " "
vlhkost = " "
temp_c = " "
currentMode = "inTemp"

#Nacteni teplomeru z 1Wire
os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')

base_dir = '/sys/bus/w1/devices/'
device_folder = glob.glob(base_dir + '28*')[0]
device_file = device_folder + '/w1_slave'

#Nacteni DHT11 a displeje
cidlo = dht11.DHT11(pin=11)
displej = lcd()

displej.display_string("Nacitam data", 1)


#Cteni teploty z DHT11 a odeslani na soutezni server
def read_inside():
    data = cidlo.read()
    if data.is_valid():
        global teplota
        global vlhkost
        teplota = data.temperature
        vlhkost = data.humidity

        adresa = "https://ioe.zcu.cz/th.php?id=" + str(
            id) + "&temperature=" + str(teplota) + "&humidity=" + str(vlhkost)
Пример #10
0
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.OUT)
GPIO.setup(7, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# see http://elinux.org/Rpi_Low-level_peripherals
# see http://pypi.python.org/pypi/RPi.GPIO


def flash(d):
    GPIO.output(11, False)
    sleep(d)
    GPIO.output(11, True)
    sleep(d)


disp = lcd()
disp.display_string("Raspi Dice      ", 1)
disp.display_string("                ", 2)

flash(0.2)
flash(0.2)

while True:

    go = not (GPIO.input(7))
    stop = not (GPIO.input(12))

    if go:

        # wait for button release
        while go:
Пример #11
0
# use Pi board pin numbers with GPIO.BOARD
GPIO.cleanup()
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.OUT)
GPIO.setup(7, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# see http://elinux.org/Rpi_Low-level_peripherals
# see http://pypi.python.org/pypi/RPi.GPIO

def flash(d):
      GPIO.output(11, False)
      sleep(d)
      GPIO.output(11, True)
      sleep(d)

disp = lcd()
disp.display_string("Raspi Dice 4      ", 1)
disp.display_string("                ", 2)

flash(0.2)
flash(0.2)

n = 0

while True:

  go = not(GPIO.input(7))
  stop = not(GPIO.input(12))

  if go:
Пример #12
0
    AnzSender = subprocess.check_output(
        [AnzSenderBASH], shell=True)  # Anzahl Sender ermitteln mit AWK Befehl
    AnzSender = AnzSender.strip("\n")  # Umbruch raus
    AnzSender = int(AnzSender)  # Umwandeln in int


####################
# Beim Systemstart #
####################
a = 0  # Einmalige Initialisierung für Zeile C Startindex der Ausgabe
z = 20  # Einmalige Initialisierung für Zeile C Endindex der Ausgabe
fav1 = 1  # Vorbelegung Favoritsender1 beim Boot
fav2 = 2  # Vorbelegung Favoritsender2 beim Boot
AnzSender = 0  # Senderanzahl als GLOBAL Variable da Interrupt-Aufrufe keine Rückgabe liefern, 0 als Vorbelegung
sender = 1  # Aktuelle Sendernummer als GLOBAL Variable da Interrupt-Aufrufe keine Rückgabe liefern, 1 als erster Sender nach Start
my_lcd = lcd()  # LCD initialisieren
wlan_konf()  # ggf. W-LAN konfigurieren
if modus == 90:
    RUMode()  # RunUp sobald
    ZeilenABCD_RUMode(version)  # RunUp Anzeige mit Übergabe der Versionsnummer
    RAMode()  # Radio nach RunUp ohne Interrupt starten

######################################
# TastenInerrupts mit Multithreading #
######################################
# Taste A Event Senderwechsel hoch
GPIO.add_event_detect(TasteHoch, GPIO.FALLING, callback=SWH, bouncetime=200)
# Taste B Event Senderwechsel runter
GPIO.add_event_detect(TasteRunter, GPIO.FALLING, callback=SWR, bouncetime=200)
# Taste C Event Eigene Musik Zufallswiedergabe
GPIO.add_event_detect(TasteModus,
Пример #13
0
class test():
    #lcd顯示
    my_lcd = lcd()
    #照相機
    pir = 22
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(pir, GPIO.IN)
    vs = VideoStream(usePiCamera=True).start()
    time.sleep(1)
    print("Start camera")
    child = Popen(
        "./darknet detector test obj.data cfg/yolov4-Icantest-tiny.cfg yolov4-Icantrain-tiny_best.weights -dont_show -save_labels -thresh 0.5 ",
        stdin=PIPE,
        stdout=PIPE,
        bufsize=1,
        universal_newlines=True,
        shell=True)
    while True:
        input_state = GPIO.input(pir)
        frame = vs.read()
        if input_state == 0:
            img = frame
            print("get")
            time.sleep(1)
            print("take a picture")
            cv2.imwrite("test.jpg", img)
            print("test.jpg", file=child.stdin)
            time.sleep(8)
            f = open("test.txt", "r")
            word = f.read(1)
            if word == 0 or word == '':
                my_lcd.display_string("This is", 1)
                my_lcd.display_string("Trash", 2)
                print(word + ' :Trash')
            else:
                my_lcd.display_string("This is", 1)
                my_lcd.display_string("Recyclable", 2)
                print(word + ' :Recyclable')
            if word == "1":
                type1 = "recycle"
                type2 = "bottle"
            elif word == "2":
                type1 = "recycle"
                type2 = "can"
            elif word == "3":
                type1 = "recycle"
                type2 = "battery"
            elif word == "4":
                type1 = "recycle"
                type2 = "paper"
            elif word == "0":
                type1 = "normal"
                type2 = "trash"
            else:
                type1 = "normal"
                type2 = "trash"
            #mongodb= id time type classes
            dt = time.strftime("%Y-%m-%d_%H:%M:%S", time.localtime())
            dicts = {"time": dt, "type": type1, "class": type2}
            print(dicts)
            conn = MongoClient("mongodb://192.168.137.1/27017")  #pi 連結成功
            db = conn["ican"]
            coll = db["trash"]
            coll.insert_one(dicts)
            print("Connect success!")
Пример #14
0
    rom = sys.argv[3].split('/')[-1].replace('.rom', '').replace('.zip', '')

    lcd.display_string(title, 1)
    lcd.display_string(rom, 2)
    lcd.display_string(system, 3)
    lcd.display_string(emulator, 4)


def screen_home():
    lcd.clear

    i = 0
    bar = ''
    for i in range(0, 20):
        bar = bar + unichr(255)
        lcd.display_string(bar, 1)
        i += 1

    lcd.display_string(title, 1)
    lcd.display_string("", 2)
    lcd.display_string("CHOOSE A GAME", 3)
    lcd.display_string("", 4)


lcd = lcd()

if (len(sys.argv) > 1):
    screen_game()
else:
    screen_home()
Пример #15
0
from lcd_display import lcd
import sys

line1=(sys.argv[1])
line2=(sys.argv[2])

my_lcd = lcd()
my_lcd.display_string(line1, 1)
my_lcd.display_string(line2, 2)
Пример #16
0
# Libraries
import gi
from lcd_display import lcd

gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk

# Variables
screen = lcd()

# Code
class MyWindow(Gtk.Window):
    def __init__(self):
        Gtk.Window.__init__(self, title="Puzzle 2")
        self.set_border_width(8)
        self.set_default_size(200, 50)
        # CSS
        css = b'* {background-color: #000000; color: #ffff00} button {color: #ffffff; }'
        css_provider = Gtk.CssProvider()
        css_provider.load_from_data(css)
        context = Gtk.StyleContext()
        screen = Gdk.Screen.get_default()
        context.add_provider_for_screen(screen, css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
        # Widgets
        self.grid = Gtk.Box(orientation="vertical", spacing=4)
        self.add(self.grid)
        self.textView = Gtk.TextView()
        self.button = Gtk.Button(label="Display Text")
        self.button.connect("clicked", self.button_clicked)
        # Grid pack
        self.grid.pack_start(self.textView, True, True, 0)
Пример #17
0
#!/usr/bin/env python

#from lcd_display import lcd
import lcd_display
import RPi.GPIO as GPIO
from subprocess import *
from time import sleep, strftime
from datetime import datetime

#pin number for switch
SW1=11

mode=1

myLCD = lcd_display.lcd()

def setup():
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(SW1, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    GPIO.add_event_detect(SW1, GPIO.RISING, callback=changeMode, bouncetime=300)

def run_cmd(cmd):
    p = Popen(cmd, shell=True, stdout=PIPE)
    output = p.communicate()[0]
    return output

IPCMD = "ip addr show wlan0 | grep 'inet ' | awk '{print $2}' | cut -d/ -f1"
ipaddr = run_cmd(IPCMD).rstrip('\n')

WEATHCMD="wget -qO- http://wxdata.weather.com/wxdata/weather/local/CAXX0255?cc=*\&unit=m | grep tmp | sed 's/[^-0-9]*//g'"
temper = run_cmd(WEATHCMD).rstrip('\n')
Пример #18
0
    def __init__(self, master):
        #firebase_init
        #firebase
        global register
        cred = credentials.Certificate(
            '../raspberryfirebase-firebase-adminsdk-q4ht6-296b3b1772.json')
        firebase_admin.initialize_app(
            cred, {'databaseURL': 'https://raspberryfirebase.firebaseio.com/'})
        self.lcdRef = db.reference('raspberrypi/LCD')
        self.firestoreClient = firestore.client()

        #buzzer init
        #self.bz = Buzzer(16)
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(36, GPIO.OUT)
        GPIO.setwarnings(False)

        self.p = GPIO.PWM(36, 50)

        #Tkinter
        #for buzzer
        buzzerFrame = Frame(master)
        Button(buzzerFrame,
               text="Buzzer Control",
               command=self.userClickBuzzer,
               padx=10,
               pady=10).pack(padx=30, pady=10, expand=YES, fill=BOTH)
        buzzerFrame.pack(expand=YES, fill=BOTH)

        #for lcd
        lcdFrame = Frame(master)
        self.entryString1 = StringVar()
        self.entryString2 = StringVar()
        entry1Frame = Frame(lcdFrame)
        Label(entry1Frame, text="name").pack(side=LEFT)
        Entry(entry1Frame, textvariable=self.entryString1,
              width=50).pack(side=LEFT, padx=10)
        self.entryString1.set("tfirst line")
        entry1Frame.pack(expand=YES, fill=BOTH, padx=10, pady=10)

        entry2Frame = Frame(lcdFrame)
        Label(entry2Frame, text="pwd").pack(side=LEFT)
        Entry(entry2Frame, textvariable=self.entryString2,
              width=50).pack(side=LEFT, expand=YES, fill=BOTH, padx=10)
        self.entryString2.set("second line")
        entry2Frame.pack(expand=YES, fill=BOTH, padx=10, pady=10)

        Button(lcdFrame,
               text="Entry Send",
               command=self.userClickSend,
               padx=10,
               pady=10).pack(padx=30, pady=10, expand=YES, fill=BOTH)
        lcdFrame.pack()
        #lcd
        self.my_lcd = lcd()

        #firebase register
        try:
            register = self.lcdRef.listen(self.lcdCallBack)
        except ApiCallError as error:
            print("apiCallError")

        #checked uid
        self.uid = []
        self.preUid0 = 0
        self.preUid1 = 0
        self.preUid2 = 0
        self.preUid3 = 0
        self.MIFAREReader = MFRC522.MFRC522()
        self.rfidHandler()
Пример #19
0
      GPIO.output(11, False)
      time.sleep(d)
      GPIO.output(11, True)
      time.sleep(d)

# use Pi board pin numbers with GPIO.BOARD
GPIO.cleanup()
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.OUT)
GPIO.setup(7, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# see http://elinux.org/Rpi_Low-level_peripherals
# see http://pypi.python.org/pypi/RPi.GPIO

# initialise the lcd display
lcd1 = lcd()
lcd1.clear()
lcd1.display_string("Picture Taker", 1)

flash(0.2)
flash(0.2)

while True:

  # Check camera is present
  while not os.path.exists('/dev/video0'):
    lcd1.display_string("No Camera", 2)
    time.sleep(1.0)

  lcd1.display_string("ready", 2)