示例#1
0
def balance():
    client = Client(PUBLIC_API_KEY, PRIVATE_API_KEY)
    bm = BinanceSocketManager(client)
    bal = client.get_asset_balance('BTC')['free']
    LCD1602.write(0, 0, bal)
    time.sleep(3)
    LCD1602.clear()
示例#2
0
文件: Halo.py 项目: haloteam/halo
 def destroy(self):
 	LCD.clear()
     LCD.write(0,0,'')
     LCD.write(0,1,'')
     self.set_eyes(0x00)
 	GPIO.output(self.BUZZ_PIN, GPIO.HIGH)
 	GPIO.cleanup()
示例#3
0
    def init(self):

        LCD1602.init(0x27, 1)  # init(slave address, background light)
        LCD1602.write(0, 0, 'Hello')
        LCD1602.write(1, 1, 'World')
        time.sleep(1)
        LCD1602.clear()
示例#4
0
def setup():
        LCD1602.init(0x27, 1)	# init(slave address, background light)
        LCD1602.clear()
        time.sleep(2)
        LCD1602.write(0, 0, 'Greetings!!')
		LCD1602.write(1, 1, 'from SunFounder')
		time.sleep(2)
示例#5
0
def loop():
    while True:
        dis = distance()
        print(dis, 'cm')
        print('')
        GPIO.output(BUZZER, GPIO.LOW)
        if (dis > 400):
            LCD1602.clear()
            LCD1602.write(0, 0, 'Error')
            LCD1602.write(3, 1, 'Out of range')
            time.sleep(0.5)
        else:
            LCD1602.clear()
            LCD1602.write(0, 0, 'Distance is')
            LCD1602.write(5, 1, str(round(dis, 2)) + ' cm')
            if (dis >= 50):
                time.sleep(0.5)
            elif (dis < 50 and dis > 20):
                for i in range(0, 2, 1):
                    GPIO.output(BUZZER, GPIO.HIGH)
                    time.sleep(0.05)
                    GPIO.output(BUZZER, GPIO.LOW)
                    time.sleep(0.2)
            elif (dis <= 20):
                for i in range(0, 5, 1):
                    GPIO.output(BUZZER, GPIO.HIGH)
                    time.sleep(0.05)
                    GPIO.output(BUZZER, GPIO.LOW)
                    time.sleep(0.05)
示例#6
0
    def init(self):

        LCD1602.init(0x27, 1)   # init(slave address, background light)
        LCD1602.write(0, 0, 'Hello')
        LCD1602.write(1, 1, 'World')
        time.sleep(1)
        LCD1602.clear()
示例#7
0
def destroy():
    GPIO.output(BuzzerPin, GPIO.LOW)  #Turn off buzzer

    for pin in pins:
        GPIO.output(pin, GPIO.LOW)  #Turn off all leds

    GPIO.cleanup()
    LCD1602.clear()
示例#8
0
文件: handler.py 项目: inosur/matrbot
def terminate():
    print("terminating matrbot interface")
    LCD1602.clear()
    GPIO.cleanup()
    p.terminate()
    p.join()
    sched.shutdown()
    print("bye!")
示例#9
0
文件: Halo.py 项目: haloteam/halo
 def display_text(self, text):
     LCD.clear()
     if len(text) <= 16:
         LCD.write(0,0,text)
     else:
         top = text[0:15]
         bot = text[16:]
         LCD.write(0,0,top)
         LCD.write(0,1,bot)
示例#10
0
def loop():
    #space = '                '
    #greetings = 'Thank you for buying SunFounder Sensor Kit for Raspberry! ^_^'
    #greetings = space + greetings
    while True:
        LCD1602.write(0, 0, ADC.read(0))
        tmp = GPIO.input(D0)
        time.sleep(0.8)
        LCD1602.clear()
示例#11
0
def ON_OFF(self):   
    global on_off
    LCD1602.clear()
    if GPIO.input(SWITCH)==0:   #if system is off
        GPIO.output(LEDR, GPIO.LOW)
        GPIO.output(LEDG, GPIO.LOW)
        on_off=False
    else:                       #if system is on
        GPIO.output(LEDG, GPIO.HIGH)
        on_off=True
示例#12
0
def output(line1, line2):
    ''' Format for 1602 display and send to output '''
    try:
        LCD.clear()
        LCD.write(0, 0, line1)
        LCD.write(0, 1, line2)
        return 0
    except IOError:
        print "IOError: most likely cause is loose 3to5v converter."
        return -1
示例#13
0
def init():

    #print ('Setting up, please wait...')

    LCD_Width = 16
    # Configure LCD
    LCD1602.init(0x27, 1)  # init(slave address, background light)
    LCD1602.write(0, 0, 'Greetings!!')
    LCD1602.write(0, 1, 'from GordonNet Temp Monitor')
    time.sleep(5)
    LCD1602.clear()
示例#14
0
def loop():
    space = '                '
    greetings = 'Thank you for buying ZHINENG Sensor Kit for Raspberry! ^_^'
    greetings = space + greetings
    while True:
        tmp = greetings
        for i in range(0, len(greetings)):
            LCD1602.write(0, 0, tmp)
            tmp = tmp[1:]
            time.sleep(0.8)
            LCD1602.clear()
示例#15
0
def setup():
    GPIO.setmode(GPIO.BOARD)  # Numbers GPIOs by physical location
    GPIO.setup(RoAPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)  # input mode
    GPIO.setup(RoBPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    GPIO.setup(BtnPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    LCD1602.init(0x27, 1)  # init(slave address, background light)
    LCD1602.clear()
    LCD1602.write(0, 0, "Temperature is")
    LCD1602.write(0, 1, ' ')
    LCD1602.write(7, 1, 'degrees')
    time.sleep(2)
def loop():
	space = '                '
	greetings = 'Thank you for buying SunFounder Sensor Kit for Raspberry! ^_^'
	greetings = space + greetings
	while True:
		tmp = greetings
		for i in range(0, len(greetings)):
			LCD1602.write(0, 0, tmp)
			tmp = tmp[1:]
			time.sleep(0.8)
			LCD1602.clear()
示例#17
0
def main():
    print "Bienvenido al sistema RaspiAlert\n"
    LCD1602.clear()
    while True:
        result = read_dht11_dat()
        if result:
            humidity, temperature = result
            LCD1602.write(0, 0, ' # RaspiAlert #')
            LCD1602.write(1, 1, 'H= %s%% T= %s C' % (humidity, temperature))
            print "humidity: %s %%, Temperature: %s C`" % (humidity,
                                                           temperature)
            time.sleep(5)
示例#18
0
def exit():
    lcd.clear()
    bye_msg = 'Shutting Down In'
    lcd.write(0, 0, bye_msg)
    lcd.write(1, 7, str(3))
    time.sleep(1)
    lcd.write(1, 7, str(2))
    time.sleep(1)
    lcd.write(1, 7, str(1))
    time.sleep(1)

    lcd.clear()
示例#19
0
文件: run.py 项目: haloteam/halo
def setup():
    ADC.setup(0x48)
    LCD.init(0x27, 1)
    LCD.write(0,0,'System startup...')
    time.sleep(1)
    ALARM = False
    LCD.clear()
    GPIO.setup(THERMISTOR_PIN, GPIO.IN)
    GPIO.setup(GAS_SENSOR_PIN, GPIO.IN)
    GPIO.setup(BUZZ_PIN, GPIO.OUT)
    GPIO.setup(H2O_PIN, GPIO.OUT)
    GPIO.output(BUZZ_PIN, GPIO.HIGH)
def lcd_show_input(result):
    LCD1602.clear()
    if result == 1:
        LCD1602.write(0,1,'You have got it!')
        time.sleep(5)
        init_new_value()
        lcd_show_input(0)
        return
    LCD1602.write(0,0,'Enter number:')
    LCD1602.write(13,0,str(count))
    LCD1602.write(0,1,str(lower))
    LCD1602.write(3,1,' < Point < ')
    LCD1602.write(13,1,str(upper))
示例#21
0
def Print(x):
    if x == 0:
        #if ActivarAlarma == 0:
        print '    ***********************'
        print '    *   Button Pressed!   *'
        print '    ***********************'
        LCD1602.clear()
        LCD1602.write(0, 0, ' # RaspiAlert #')
        LCD1602.write(1, 1, 'Alarma activada')
        time.sleep(3)
        LCD1602.write(1, 1, 'Tiene 30s...   ')
        time.sleep(30)
        LCD1602.clear()
        detect_movement()
示例#22
0
def loop():
    lastState=1
    stage=0
    while True:
        currentState=GPIO.input(Joy_BtnPin)
        if currentState==1 and lastState ==0:
            stage=(stage+1)%2
            time.sleep(0.1)    
            LCD1602.clear()
        lastState=currentState
        if stage == 1:
            upper_tem_setting()
        else:
            monitoring_temp()
def setup():
    global keypad, last_key_pressed,keys
    rowsPins = [18,23,24,25]
    colsPins = [10,22,27,17]
    keys = ["1","2","3","A",
            "4","5","6","B",
            "7","8","9","C",
            "*","0","#","D"]
    keypad = Keypad(rowsPins, colsPins, keys)
    last_key_pressed = []
    LCD1602.init(0x27, 1)    # init(slave address, background light)
    LCD1602.clear()
    LCD1602.write(0, 0, 'Welcome!')
    LCD1602.write(0, 1, 'Press A to Start!')
示例#24
0
def setup():
    global keypad, last_key_pressed
    rowsPins = [18,23,24,25]
    colsPins = [10,22,27,17]
    keys = ["1","2","3","A",
            "4","5","6","B",
            "7","8","9","C",
            "*","0","#","D"]
    keypad = Keypad(rowsPins, colsPins, keys)
    last_key_pressed = []
    LCD1602.init(0x27, 1)    # init(slave address, background light)
    LCD1602.clear()
    LCD1602.write(0, 0, 'WELCOME!')
    LCD1602.write(2, 1, 'Enter password')
    time.sleep(2)
示例#25
0
def main():
	print "Arrancado el modulo meteo\n"
	LCD1602.clear()
	while True:
		result = read_dht11_dat()
		if result:
			humidity, temperature = result
			LCD1602.write(0, 0, ' # RaspiAlert #')
                        LCD1602.write(1, 1, 'H= %s%% T= %s C' % (humidity, temperature))
                        texto = "Humedad: %s %%, Temperatura: %s C" % (humidity, temperature)
			print texto
			lectura = open('temp','w')
			lectura.write(texto)
			lectura.close()
		time.sleep(5)
示例#26
0
def main():
    print "Bienvenido al sistema RaspiAlert\n"
    LCD1602.clear()
    #bot.polling(none_stop=True)
    bot.set_update_listener(listener)

    while True:
        result = read_dht11_dat()
        if result:
            humidity, temperature = result
            LCD1602.write(0, 0, ' # RaspiAlert #')
            LCD1602.write(1, 1, 'H= %s%% T= %s C' % (humidity, temperature))
            print "humidity: %s %%, Temperature: %s C`" % (humidity,
                                                           temperature)
            time.sleep(5)
示例#27
0
文件: Main.py 项目: comdan66/OAPi
def setup():
    global DB
    global DB_Connect
    global Sensor2
    Sensor2 = BMP085.BMP085(2, A77)
    LCD1602.init(A27, 1)
    LCD1602.clear()
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(PERSON_PORT, GPIO.IN)

    try:
        host, user, passwd, db = genDB()
        DB = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db)
        DB_Connect = DB.cursor()
    except Exception as e:
        DB = None
示例#28
0
def loop():
    #	url = 'http://192.168.10.142:8880/GetDisplay'
    url = 'http://localhost:8880/GetDisplay'
    headers = {'Content-type': 'application/json'}
    response = requests.get(url, headers=headers)
    data = response.json()
    print(data)
    print(response.url)
    #	LCD1602.init(0x27, 1)	# init(slave address, background light)
    #	line1 = 'Please keep calm'
    #	line2 = 'Help is coming )'
    line1 = data['display1']
    line2 = data['display2']
    LCD1602.clear()
    LCD1602.write(0, 0, line1)
    LCD1602.write(0, 1, line2)
    time.sleep(3.0)
示例#29
0
文件: run.py 项目: haloteam/halo
def update_LCD(temp, gas, h2o):
    global ALARM_ON
    if not IS_TALKING:
        if gas >= 150:
            if not ALARM_ON == True:
                ALARM_ON = True
            LCD.clear()
            LCD.write(0,0,"ALERT!")
            LCD.write(0,1,"Gas detected!")
            print ''
            print '   ***************'
            print '   * Danger Gas! *'
            print '   ***************'
            print ''

        elif temp <= 45:
            if not ALARM_ON == True:
                ALARM_ON = True
            status = 0
            LCD.clear()
            LCD.write(0,0,"ALERT!")
            LCD.write(0,1,"Low temperature!")
            print ''
            print '   ********************'
            print '   * Danger Low Temp! *'
            print '   ********************'
            print ''

        elif h2o <= 200:
            if not ALARM_ON == True:
                ALARM_ON = True
            LCD.clear()
            LCD.write(0,0,"ALERT!")
            LCD.write(0,1,"Water detected!")
            print ''
            print '   **************************'
            print '   * Danger Water Detected! *'
            print '   **************************'
            print ''

        else:
	    if ALARM_ON:
                ALARM_ON = False
            LCD.clear()
            LCD.write(0,0, "System Normal")
            print ''
            print '   --------------------------'
            print '   *  System Status Normal  *'
            print '   --------------------------'
            print ''
    else:
        pass
示例#30
0
def loop():
    global LightsOff
    global OffTemp
    while True:
        humidity, temperature = Adafruit_DHT.read_retry(11, 4)
        if humidity is not None and temperature is not None:
            if temperature > OffTemp:
                #GPIO.output(RelayPin, GPIO.LOW)
                LightsOff = True
                LCD1602.clear()
                LCD1602.write(0, 0, 'High temp!!!')
                LCD1602.write(0, 1, 'Temp=%.0fC' %temperature)
                time.sleep(3)
            elif temperature < OffTemp:
                LCD1602.clear()
                LCD1602.write(0, 0, 'Temp=%.0fC' %temperature)
                LCD1602.write(0, 1, 'Humidity=%.0f%%' %humidity)
        else:
            LCD1602.write(0, 0, 'Reading Failed')
            LCD1602.write(0, 1, 'Trying again...')
        time.sleep(20)
示例#31
0
def loop():
    global keyIndex
    global LENS
    global keypad, last_key_pressed
    while(True):
        pressed_keys = keypad.read()
        if len(pressed_keys) != 0 and last_key_pressed != pressed_keys:
            LCD1602.clear()
            LCD1602.write(0, 0, "Enter password:"******"WRONG KEY!")
                    LCD1602.write(0, 1, "please try again")
                else:
                    LCD1602.clear()
                    LCD1602.write(4, 0, "CORRECT!")
                    LCD1602.write(2, 1, "welcome back")
            keyIndex=keyIndex%LENS

        last_key_pressed = pressed_keys
        time.sleep(0.1)
示例#32
0
def detect_movement():

    print '    ***********************'
    print '    *   Alarma activada!  *'
    print '    ***********************'
    LCD1602.clear()
    LCD1602.write(0, 0, ' # RaspiAlert #')
    LCD1602.write(1, 1, 'Alarma activada')
    time.sleep(3)
    LCD1602.write(1, 1, 'Tiene 30s...   ')
    time.sleep(30)
    LCD1602.clear()

    while alarma == 1:
        i = GPIO.input(pirInput)
        if i == 0:  #When output from motion sensor is LOW
            print "No intruders", i
            time.sleep(0.1)

        elif i == 1:  #When output from motion sensor is HIGH
            print "Intruder detected", i
            enviar_foto()
            time.sleep(1)
示例#33
0
 def loop(self):
     current_text = ""
     while True:
         "Scroll Text"
         # add whitespace
         if len(self.TEXT) > 16:
             text = self.TEXT
             # fancy scrolling if we have a long string
             for i in range(len(text)):
                 #break if text changes
                 if text != self.TEXT:
                     break
                 LCD1602.write(0, 0, text)
                 text = text[1:]
                 time.sleep(0.5)
                 LCD1602.clear()
         elif current_text != self.TEXT:
             #static change
             LCD1602.clear()
             LCD1602.write(0, 0, self.TEXT)
             current_text = self.TEXT
             time.sleep(1)  # hold for at least 1 second
         else:  # sleep poll
             time.sleep(1)
示例#34
0
 def loop(self):
     current_text = ""
     while True:
         "Scroll Text"
         # add whitespace
         if len(self.TEXT) > 16:
             text = self.TEXT
             # fancy scrolling if we have a long string
             for i in range(len(text)):
                 #break if text changes
                 if text != self.TEXT:
                     break
                 LCD1602.write(0, 0, text)
                 text = text[1:]
                 time.sleep(0.5)
                 LCD1602.clear()
         elif current_text != self.TEXT:
             #static change
             LCD1602.clear()
             LCD1602.write(0, 0, self.TEXT)
             current_text = self.TEXT
             time.sleep(1) # hold for at least 1 second
         else:  # sleep poll
             time.sleep(1)
示例#35
0
def main():
    LCD1602.clear()

    running = threading.Event()
    running.set()

    thread = threading.Thread(target=clock, args=(running, ))
    thread.start()

    try:

        while True:
            now = datetime.datetime.now()
            LCD1602.write(
                0, 0, '{}.{}.{}'.format('{:02d}'.format(now.year),
                                        '{:02d}'.format(now.month),
                                        '{:02d}'.format(now.day)))
            LCD1602.write(
                2, 1, '{} {} {}'.format('{:02d}'.format(now.hour % 12),
                                        '{:02d}'.format(now.minute),
                                        '{:02d}'.format(now.second)))

            LCD1602.write(11, 0, '{0:0.1f}C'.format(t) if t > 0 else '--.-C')
            LCD1602.write(11, 1, '{0:0.1f}%'.format(h) if h > 0 else '--.-%')

            time.sleep(0.5)
            LCD1602.write(4, 1, ':')
            LCD1602.write(7, 1, ':')
            time.sleep(0.5)

    except KeyboardInterrupt:
        running.clear()
        thread.join()

        LCD1602.clear()
        print('exit')
示例#36
0
def door_bell_pressed():
    LCD.clear()  #clear the LCD screen
    distance = measure_distance()
    d = distance()  # distance is measured in cm
    while (d < 100):  # while distance < 100 cm
        LCD.write(0, 0, "Come Closer to Door")
        d = distance()
        time.sleep(0.05)  #50ms interval between each distance measured

    LCD.write(0, 0, "prs 0 for keypad")
    LCD.write(0, 1, "prs 1 for RFID")

    selection = keypad()
    if selection == 0:  # if 0 is pressed
        LCD.clear()  #clear the LCD screen
        if check_password(get_password_keypad()):  # if the password is correct
            take_image()  # take a photo of the person
            open_door(
            )  # open the door for the person-> the person will closee it by themselves

        else:
            take_video()  # take a 5 second video  of the intruder
            ring_buzzer()  # ring the buzzer

    elif selection == 1:
        LCD.clear()  #clear the LCD screen
        LCD.write(0, 0, "Scan RFID")  #print on LCD as required
        data = ser.read(12)
        code = validate_rfid(data)
        if code == "5400653CCF":
            take_image()  # take a photo of the person
            open_door(
            )  # open the door for the person-> the person will closee it by themselves
        else:
            take_video()  # take a 5 second video  of the intruder
            ring_buzzer()  # ring the buzzer
    else:
        LCD.clear()
        LCD.write(0, 0, "Invalid Selection")  #print on LCD as required
    def setup(self, evenementArrive, evenement):
        global code

        #quand le sensor detecte un mouvement et que le système est enclenché
        if evenementArrive == Constante.motion:

            LCD1602.write(0, 0, 'Entrer le code')
            LCD1602.write(0, 1, code)
            time.sleep(1)

        #quand on desactive le systme on clear le LCD et on insère l'évenemnt dans la BD
        elif evenementArrive == Constante.desactivation:

            connexion = BD.connexionBD()
            BD.insertionDonnees(evenement, connexion)
            BD.fermerBD(connexion)
            LCD1602.clear()
            LCD1602.write(0, 0, 'System disabled')

        #quand on desactive le systme on clear le LCD et on insère l'évenemnt dans la BD
        elif evenementArrive == Constante.activation:
            connexion = BD.connexionBD()
            BD.insertionDonnees(evenement, connexion)
            BD.fermerBD(connexion)
            LCD1602.clear()
            LCD1602.write(0, 0, 'System enabled')

        elif evenementArrive == Constante.blocked:
            connexion = BD.connexionBD()
            BD.insertionDonnees(evenement, connexion)
            BD.fermerBD(connexion)
            LCD1602.clear()
            LCD1602.write(0, 0, 'Acces blocked')

        else:
            connexion = BD.connexionBD()
            BD.insertionDonnees(evenement, connexion)
            BD.fermerBD(connexion)
def temp_out_LCD(temp):
    LCD1602.clear()
    LCD1602.write(0, 0, 'current temp:')
    LCD1602.write(1, 1, temp + ' C')
示例#39
0
def setup():
	LCD1602.init(0x27, 1)	# init(slave address, background light)
	LCD1602.write(0, 0, 'Greetings!!')
	LCD1602.write(1, 1, 'from SunFounder')
	time.sleep(2)
	LCD1602.clear()
示例#40
0
文件: Halo.py 项目: haloteam/halo
 def mouth_close(self):
     LCD.clear()
     LCD.write(0,0,'________________')
     LCD.write(0,1,'----------------')
示例#41
0
文件: Halo.py 项目: haloteam/halo
 def alert(self, text):
     LCD.clear()
     LCD.write(0,0,"ALERT!")
     LCD.write(0,1,text)
示例#42
0
文件: run.py 项目: haloteam/halo
def mouth_open():
    LCD.clear()
    LCD.write(0,0,"")
示例#43
0
文件: Halo.py 项目: haloteam/halo
 def mouth_open(self):
     LCD.clear()
     LCD.write(0,0,'|--------------|')
     LCD.write(0,1,'|______________|')
示例#44
0
文件: run.py 项目: haloteam/halo
def destroy():
	LCD.clear()
	GPIO.output(BUZZ_PIN, GPIO.HIGH)
	GPIO.output(H2O_PIN, GPIO.HIGH)
	GPIO.cleanup()
def destroy():
    LCD1602.clear()