Esempio n. 1
0
def ResetTempRange():
    webiopi.debug("Reset All Temp Range Macro...")
    global tShopHigh
    global tShopLo
    global tGpuHigh
    global tGpuLow
    global tCpuHigh
    global tCpuLow
    fahrenheit = t.getFahrenheit()
    GPUfahrenheit = float(get_gpu_temp())
    CPUfahrenheit = float(get_cpu_temp())
    tShopHigh = fahrenheit
    tShopLow = fahrenheit
    tGpuHigh = GPUfahrenheit
    tGpuLow = GPUfahrenheit
    tCpuHigh = CPUfahrenheit
    tCpuLow = CPUfahrenheit
    # LCD Background Cyan
    GPIO.pwmWrite(RED, 1.0)
    GPIO.pwmWrite(GREEN, 0.0)
    GPIO.pwmWrite(BLUE, 0.0)
    # Display current temperature on LCD display
    lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
    lcd.lcd_string("Temp Ranges Reset")
    lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
    lcd.lcd_string("( HTTP Request )")
Esempio n. 2
0
    def __init__(self):

        GPIO.setwarnings(False)
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(GPIO_LED_1, GPIO.OUT)
        GPIO.setup(GPIO_LED_2, GPIO.OUT)
        GPIO.setup(GPIO_MISTING_PUMP, GPIO.OUT)
        GPIO.setup(GPIO_TRANSFER_PUMP, GPIO.OUT)
        GPIO.setup(GPIO_BUTTON, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
        GPIO.setup(GPIO_SMALL_TANK_FLOAT, GPIO.IN, pull_up_down=GPIO.PUD_UP)
        GPIO.setup(GPIO_LARGE_TANK_TOP_FLOAT,
                   GPIO.IN,
                   pull_up_down=GPIO.PUD_UP)
        GPIO.setup(GPIO_LARGE_TANK_BOTTOM_FLOAT,
                   GPIO.IN,
                   pull_up_down=GPIO.PUD_UP)

        self.event_queue = Queue()
        self.button_presses = [
            None
        ] * 100  # big enough that a user can't click the button this many times within the long press timeout
        self.button_press_counter = 0

        try:
            with open(MODE_FILE, 'r') as mode_file:
                self.mode = int(mode_file.readline())
                if self.mode != MODE_ALWAYS_OFF and self.mode != MODE_VENTING and self.mode != MODE_ALWAYS_ON:
                    raise ValueError
        except:
            self.mode = MODE_VENTING

        self.thermostat_temp = 0
        self.small_tank_float = False
        self.large_tank_bottom_float = False
        self.large_tank_top_float = False
        self.transfer_pump = False
        self.misting_pump = False
        self.want_to_mist = False
        self.venting = False
        self.show_text = None
        self.showing_line = 0
        self.flash_led_on = True
        self.current_text = ''
        self.button_pressed = False
        self.cooling_count = 0

        GPIO.add_event_detect(GPIO_BUTTON,
                              GPIO.BOTH,
                              callback=self.button_changed,
                              bouncetime=100)

        lcd_byte(0x40, LCD_CMD)
        for byte in CHAR_DATA:
            lcd_byte(byte, LCD_CHR)

        self.express_state()
        self.post_event(EVENT_DISPLAY_LINE)
        self.post_event(EVENT_FLASH_LED)
        self.post_event(EVENT_RESET_DISPLAY)
Esempio n. 3
0
def displayOnLcd(line1, line2):
    clearLcd()
    # Send some centred test
    lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
    lcd.lcd_string(str("".join(line1)),2)
    lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
    lcd.lcd_string(str("".join(line2)),2)
    GPIO.output(lcd.LED_ON, False)
    return
Esempio n. 4
0
def mov_print(str):
    counter = 0
    str_len = len(str)
    while stopper == 1:
        lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
        lcd.lcd_string(str[counter:str_len] + str[0:counter], 2)
        counter += 1
        if counter == str_len:
            counter = 0
        time.sleep(0.2)
Esempio n. 5
0
def GetSensorTemp():
    webiopi.debug("GetSensorTemp Macro...")
    # Get current temperature
    fahrenheit = t.getFahrenheit()
    setColor(Colors['Purple'])
    # Display current temperature on LCD display
    lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
    lcd.lcd_string("Current: %0.1f" % (fahrenheit)  + chr(223) + "F")
    lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
    lcd.lcd_string("( HTTP Request )")
    return "Current:  %0.1f°F\r\nLow:      %0.1f°F\r\nHigh:     %0.1f°F" % (fahrenheit, tLow, tHigh)
Esempio n. 6
0
def timer(seconds) :
	try :
		while seconds > 0 :
			lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
			lcd.message(str(seconds) + " seconds", style=2)
			seconds -= 1
			time.sleep(1)
			
		return 0
	
	except KeyboardInterrupt :
		leave()
Esempio n. 7
0
	def status(self) :      
		log('Taking picture')
		out = os.system("fswebcam -r " + config.resolution +
					'--log syslog -q --jpeg -1' +
					" -d " + config.camera + 					
					" " + config.tempDirectory + "/" + 					
					config.pictureName)
		log("Camera app returned " + str(out))
		
		lcd.clear()        
		lcd.message("Status request:") 
		lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
		lcd.message("Pin is " + str(state))
Esempio n. 8
0
def ResetTempRange():
    webiopi.debug("Reset Temp Range Macro...")
    global tHigh
    global tLow
    fahrenheit = t.getFahrenheit()
    tHigh = fahrenheit
    tLow = fahrenheit
    setColor(Colors['Cyan'])
    # Display current temperature on LCD display
    lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
    lcd.lcd_string("Temp Range Reset")
    lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
    lcd.lcd_string("( HTTP Request )")
Esempio n. 9
0
	def ip(self) :
		lcd.home()
		lcd.message("IP Request")
		p = os.popen("ip addr show wlan0 | grep inet").readline().split()[1]
		ip = p.split('/')[0]
		#ip = self._getIP()
		#print ip
		log('IP Request from ' + sender)
		log('Local IP: ' + ip)
		lcd.message('IP_ Request', style=2)
		lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
		lcd.message(ip, style=2)     
		mailmanager.sendEmail(sender, 'Local IP', ip)
		time.sleep(config.displayTime)
Esempio n. 10
0
def on_message(client, userdata, msg):
    if msg.payload.decode() == "Hello world!":
        print("H W")
    else:
        #print("Yes!")
        a = msg.payload.decode()
        print(a)
        lcd.lcd_init()
        lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
        lcd.lcd_string("SMART AGRICULTURE", 2)
        lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
        lcd.lcd_string(a, 2)
        if (a == "END"):
            client.disconnect()
Esempio n. 11
0
def waitUntil(seconds, state=False) :
	try :
		while seconds > 0 :
			lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
			lcd.message(str(seconds) + " seconds", style=2)
			seconds -= 1
			time.sleep(1)
			pinstate = commands.readInput()            
			if pinstate == state :                
				break             
		return 0
	
	except KeyboardInterrupt :
		leave()
Esempio n. 12
0
def yaz(satır1, satır2, a=2):
    lcd.lcd_init()
    lcd.GPIO.output(lcd.LED_ON, True)
    time.sleep(1)
    lcd.GPIO.output(lcd.LED_ON, False)
    time.sleep(1)
    lcd.GPIO.output(lcd.LED_ON, True)
    time.sleep(1)
    # set cursor to line 1
    lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
    # display text centered on line 1
    lcd.lcd_string(satır1, a)
    # set cursor to line 2
    lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
    # display additional text on line 2
    lcd.lcd_string(satır2, a)
Esempio n. 13
0
def main():
    while (1):
        k = mode_select()  #selecting mode for :1)new user 2)payment
        if (k == '1'):  #for enrollment of new user finger print
            scan_finger()  #function used to store the finger print of the user
        if (k == '2'):  #mode selection for payment
            y = verify()  #store the id of the user in the variable
        if (k == '#'):
            '''
            send req. to server to update the database
            press #
            '''
            Lprint.lcd_byte(0x01, LCD_CMD)
            Lprint.lcd_string("database updated..",
                              LCD_LINE_1)  #syntax for printing on lcd screen
            time.sleep(2)
Esempio n. 14
0
def GetSensorTemp():
    webiopi.debug("GetSensorTemp Macro...")
    # Get current temperature
    fahrenheit = t.getFahrenheit()
    GPUfahrenheit = round(get_gpu_temp())
    CPUfahrenheit = round(get_cpu_temp())
    # LCD Background Purple
    GPIO.pwmWrite(RED, 0.0)
    GPIO.pwmWrite(GREEN, 1.0)
    GPIO.pwmWrite(BLUE, 0.0)
    
    # Display current temperature on LCD display
    lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
    lcd.lcd_string("W: %0.1f" % (fahrenheit)  + chr(223) + "F" + "G: %0.1f" % (GPUfahrenheit)  + chr(223) + "F" + "W: %0.1f" % (CPUfahrenheit)  + chr(223) + "F")
    lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
    lcd.lcd_string("( HTTP Request )")
    return "Shop:  %0.1f°F\r\nLow:      %0.1f°F\r\nHigh:     %0.1f°F\r\n'     ***************     '\r\nGraphics Processor:  %0.1f°F\r\nLow:      %0.1f°F\r\nHigh:     %0.1f°F\r\n'     ***************     '\r\nCentral Processor:  %0.1f°F\r\nLow:      %0.1f°F\r\nHigh:     %0.1f°F" % (fahrenheit, tShopLow, tShopHigh, GPUfahrenheit, tGpuLow, tGpuHigh, CPUfahrenheit, tCpuLow, tCpuHigh)
def mensajes_lcd(mensaje1, mensaje2, mensaje3, mensaje4):
    lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
    lcd.lcd_string(mensaje1, 2)
    lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
    lcd.lcd_string(mensaje2, 2)

    time.sleep(10)

    lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
    lcd.lcd_string(mensaje3, 2)
    lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
    lcd.lcd_string(mensaje4, 2)
Esempio n. 16
0
def main():
    global stopper

    lcd.lcd_init()
    kb.keyboard_init()
    try:
        while True:

            num = ''
            lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
            lcd.lcd_string('Enter Stock Num:', 2)
            while True:
                print("get:")
                key = kb.get_key()
                time.sleep(0.3)
                if key == 'A':
                    print('A')
                elif key == 'B':
                    num = num[:len(num) - 1]
                    print('Back, Cur num : ' + num)
                    lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
                    lcd.lcd_string(num, 2)
                elif key == 'C':
                    num = ''
                    print('Clear, Cur num : ' + num)
                    lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
                    lcd.lcd_string(num, 2)
                elif key == 'D':
                    print('D')
                elif key == 'E' or key == 'F':
                    print('Searching : ' + num)
                    lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
                    lcd.lcd_string(num, 2)
                    lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
                    lcd.lcd_string('Searching...', 2)
                    break
                else:
                    num += key
                    print('Cur num : ' + num)
                    lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
                    lcd.lcd_string(num, 2)

            stock = twstock.realtime.get(num)

            if not stock['success']:
                lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
                lcd.lcd_string('Stock Not Found', 2)
                continue

            stock_his = twstock.Stock(num)
            print(stock)
            yes = stock_his.price[-2:][0]

            op = stock['realtime']['open']
            now = stock['realtime']["latest_trade_price"]
            high = stock['realtime']['high']
            low = stock['realtime']['low']

            a_s = float(now) - float(yes)

            output = now + '  '
            if a_s > 0:
                output += '+'

            output += "%.2f" % a_s

            lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
            lcd.lcd_string(num, 2)
            lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
            lcd.lcd_string(output, 2)

            while True:
                print("get:")
                key = kb.get_key()
                time.sleep(0.3)
                if key == 'E' or key == 'F':
                    stopper = 0
                    lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
                    lcd.lcd_string('', 2)
                    break
                elif key == 'A':
                    stopper = 0
                    lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
                    lcd.lcd_string(output, 2)
                elif key == 'B':
                    if stopper == 1:
                        stopper = 0
                        t.join()
                    stopper = 1
                    s = ' open: ' + op + ' high: ' + high + ' low: ' + low
                    t = threading.Thread(target=mov_print, args=[s])
                    t.start()
                elif key == 'C':
                    if stopper == 1:
                        stopper = 0
                        t.join()
                    stopper = 1
                    s = ' '.join(str(x)
                                 for x in stock_his.price[-5:]) + '     '
                    t = threading.Thread(target=mov_print, args=[s])
                    t.start()

    except KeyboardInterrupt:
        GPIO.cleanup()
Esempio n. 17
0
#543728 kotl


def weather(city_id):
    api_key = "81a77fe25629fa0937e8ebaf87df7bba"
    base_url = "http://api.openweathermap.org/data/2.5/weather?"
    complete_url = base_url + "appid=" + api_key + "&id=" + city_id + "&units=metric"
    try:
        response = requests.get(complete_url)
        data = response.json()
        temp = data['main']['temp']
        cond = data['weather'][0]['main']
        return str(temp) + 'C'

    except Exception as e:
        print("Exception (weather):", e)
        pass


LCD_LINE_1 = 0x80
LCD_LINE_2 = 0xC0
LCD_CHR = True
LCD_CMD = False
lcd.lcd_init()
time.sleep(1)
lcd.lcd_byte(LCD_LINE_1, LCD_CMD)
lcd.lcd_string("Volgograd", 2)
text = weather("472757")
print(text)
lcd.lcd_byte(LCD_LINE_2, LCD_CMD)
lcd.lcd_string(text, 2)
Esempio n. 18
0
def scan_finger():
    f.start()  #function to start the sensor
    f.start_led()  #function to start the led

    current_id = int(f.current_count(), 16)

    f.start_enroll(f.current_count(
    ))  #function for starting enrollment for storing the finger-print of user
    Lprint.lcd_byte(0x01, LCD_CMD)  #clear lcd
    Lprint.lcd_string("put your finger",
                      LCD_LINE_1)  #syntax for printing on lcd screen
    print 'press finger 1'
    while (f.ispressfinger() == 2):  #check if finger is pressed or not
        time.sleep(0.1)
    if (f.capture_image() == 1):  #capture image
        if (f.enroll1() == 1
            ):  #check if successfull enrollment of user has done or not
            print 'remove finger 1'
            Lprint.lcd_string("remove your finger",
                              LCD_LINE_1)  #syntax for printing on lcd screen
            while (f.ispressfinger() == 1):  #check if finger is pressed or not
                time.sleep(0.1)
            print 'press finger 2'
            Lprint.lcd_string("put your finger again",
                              LCD_LINE_1)  #syntax for printing on lcd screen
            while (f.ispressfinger() == 2):  #check if finger is pressed or not
                time.sleep(0.1)
            if (f.capture_image() == 1):  #capture image
                if (
                        f.enroll2() == 1
                ):  #check if successfull enrollment of user has done or not
                    print 'remove finger 2'
                    Lprint.lcd_string(
                        "remove your finger",
                        LCD_LINE_1)  #syntax for printing on lcd screen
                    while (f.ispressfinger() == 1
                           ):  #check if finger is pressed or not
                        time.sleep(0.1)
                    print 'press finger 3'
                    Lprint.lcd_string(
                        "put your finger again",
                        LCD_LINE_1)  #syntax for printing on lcd screen
                    while (f.ispressfinger() == 2
                           ):  #check if finger is pressed or not
                        time.sleep(0.1)
                    if (f.capture_image() == 1):  #capture image
                        if (
                                f.enroll3() == 1
                        ):  #check if successfull enrollment of user has done or not
                            print 'remove finger 3'
                            Lprint.lcd_string(
                                "successfull scanned:)",
                                LCD_LINE_1)  #syntax for printing on lcd screen
                            time.sleep(1)
                            Lprint.lcd_string(
                                "enter your mobile no",
                                LCD_LINE_1)  #syntax for printing on lcd screen

                            val1 = ''
                            val = ''
                            number = 0

                            while (val != 'D'):
                                Lprint.lcd_string(
                                    "then Press D ", LCD_LINE_2
                                )  #syntax for printing on lcd screen
                                val = keyboard.keyboard_value(
                                )  #calling the function to read the key pressed by the user on keypad
                                time.sleep(0.05)
                                val1 = val1 + val
                                if (val == 'C'):  #cancel command
                                    val1 = ''
                                    val = ''
                                    number = 0
                                    Lprint.lcd_string(
                                        "enter again", LCD_LINE_1
                                    )  #syntax for printing on lcd screen
                                    time.sleep(1.5)
                                elif (val != 'D'):  #varify end of mobile numer
                                    temp = int(val)
                                    number = number * 10 + temp  #store the number in variable
                                    Lprint.lcd_string(val1, LCD_LINE_1)

                            Lprint.lcd_byte(0x01, LCD_CMD)
                            Lprint.lcd_string(
                                "thank you..",
                                LCD_LINE_1)  #syntax for printing on lcd screen
                            time.sleep(1)
                            Lprint.lcd_byte(0x01, LCD_CMD)
                            Lprint.lcd_string(
                                "check sms in",
                                LCD_LINE_1)  #syntax for printing on lcd screen
                            Lprint.lcd_string(
                                "your mobile",
                                LCD_LINE_2)  #syntax for printing on lcd screen
                            time.sleep(2)
                            '''
                                send req. to server....
                                send Current_id and number
                            '''

                            url = "http://malgadi.co.in/touch-n-pay/register_new_user.php?fid=" + str(
                                current_id) + "&mobileno=" + str(number)
                            content = urllib2.urlopen(
                                url).read()  #syntax to update the web server
                            if (content == '1'):
                                Lprint.lcd_string(
                                    "registered successfully", LCD_LINE_1
                                )  #syntax for printing on lcd screen
                                time.sleep(2)
                                '''if internet is not working then delete id if not upload on portal'''

                            while (f.ispressfinger() == 1
                                   ):  #syntax if finger id pressed or not
                                time.sleep(0.1)

                            for i in range(
                                    0, 10):  # to store 10 digit mobile number
                                val = keyboard.keyboard_value()

                            val1 = ''
                            for i in range(0, 10):
                                val = keyboard.keyboard_value()
                                val1 = val1 + val  #to store number in string
                                Lprint.lcd_string(val1, LCD_LINE_2)

                                num.insert(i, val)
                                print num[i]
                            Lprint.lcd_string(
                                "check message in",
                                LCD_LINE_1)  #syntax for printing on lcd screen
                            Lprint.lcd_string(
                                "your phone",
                                LCD_LINE_2)  #syntax for printing on lcd screen
                            time.sleep(2)
                            userid = f.current_count(
                            )  # userid is in 'hex' format, covert it in decimal and minus 1

                            print 'user id is:'
                            print userid
                            '''
                                send req. to server....
                                send userid and num array
                            '''
                            while (f.ispressfinger() == 1):
                                time.sleep(0.1)

                        else:
                            Lprint.lcd_string(
                                "enroll 3 fail", LCD_LINE_1
                            )  #syntax for printing error message on lcd screen
                            Lprint.lcd_string(
                                "please try again",
                                LCD_LINE_2)  #syntax for printing on lcd screen
                            time.sleep(2)
                    else:
                        Lprint.lcd_string(
                            "3rd capture fail", LCD_LINE_1
                        )  #syntax for printing error message on lcd screen
                        Lprint.lcd_string(
                            "please try again",
                            LCD_LINE_2)  #syntax for printing on lcd screen
                        time.sleep(2)
                else:
                    Lprint.lcd_string(
                        "enroll 2 fail", LCD_LINE_1
                    )  #syntax for printing error message on lcd screen
                    Lprint.lcd_string(
                        "please try again",
                        LCD_LINE_2)  #syntax for printing on lcd screen
                    time.sleep(2)
            else:
                Lprint.lcd_string(
                    "2nd capture fail", LCD_LINE_1
                )  #syntax for printing error message on lcd screen
                Lprint.lcd_string(
                    "please try again", LCD_LINE_2
                )  #syntax for printing error message on lcd screen
                time.sleep(2)
        else:
            Lprint.lcd_string(
                "enroll 1 fail",
                LCD_LINE_1)  #syntax for printing error message on lcd screen
            Lprint.lcd_string(
                "please try again",
                LCD_LINE_2)  #syntax for printing error message on lcd screen
            time.sleep(2)
    else:
        Lprint.lcd_string(
            "1st capture fail",
            LCD_LINE_1)  #syntax for printing error message on lcd screen
        Lprint.lcd_string(
            "please try again",
            LCD_LINE_2)  #syntax for printing error message on lcd screen
        time.sleep(2)

    f.stop_led()
Esempio n. 19
0
def verify():
    f.start_led()  #call the function to start the led of finger-print sensor
    print 'press finger'
    Lprint.lcd_byte(0x01, LCD_CMD)
    Lprint.lcd_string("press finger..",
                      LCD_LINE_1)  #syntax for printing on lcd screen
    while (f.ispressfinger() == 2):  #varify if finger is pressed or not
        time.sleep(0.1)
    if (f.capture_image() == 1):  #varify if image is captured successfully

        detected_id = f.identify()  #to store the id of the user

        if (detected_id != 785):  #syntax if proper id is obtained
            detected_id = int(detected_id, 16)
            print 'remove finger'
            Lprint.lcd_byte(0x01, LCD_CMD)
            Lprint.lcd_string("enter ammount ",
                              LCD_LINE_1)  #syntax for printing on lcd screen
            val = ''
            val1 = 'ammount'
            ammount = 0
            while (val != 'D'):
                val = keyboard.keyboard_value(
                )  #function for reading the switch press by the user in keypad
                time.sleep(0.05)
                val1 = val1 + val  #storing the amount in string
                Lprint.lcd_string(
                    "Press D ", LCD_LINE_2)  #syntax for printing on lcd screen
                if (val == 'c'):  #varify cancel command
                    val = ''
                    val1 = 'ammount'
                    ammount = 0
                    Lprint.lcd_string(
                        "enter again",
                        LCD_LINE_1)  #syntax for printing on lcd screen
                    time.sleep(1.5)

                elif (val != 'D'):  #press d for exiting
                    temp = int(val)
                    ammount = ammount * 10 + temp  #store the amount entered by the user in string
                    Lprint.lcd_string(val1, LCD_LINE_1)

        detectedid = f.identify(
        )  #store the id of detected user finger print in the variable
        if (detectedid != 785):
            print 'remove finger'
            Lprint.lcd_byte(0x01, LCD_CMD)
            Lprint.lcd_string("enter ammount ",
                              LCD_LINE_1)  #syntax for printing on lcd screen

            val = keyboard.keyboard_value()
            i = 0
            while (val != 'D'):
                ammount.insert(i, val)
                i = i + 1
                Lprint.lcd_byte(0x01, LCD_CMD)
                Lprint.lcd_string(
                    "press D ", LCD_LINE_2)  #syntax for printing on lcd screen
                val = keyboard.keyboard_value()

            val = ''
            i = 0
            val_string = 'ammount:'
            Lprint.lcd_string(" then press D ",
                              LCD_LINE_2)  #syntax for printing on lcd screen
            while (val != 'D'):
                ammount.insert(i, val)
                i = i + 1
                val = keyboard.keyboard_value()
                val_string = val_string + val
                Lprint.lcd_string(val_string,
                                  LCD_LINE_1)  #print the string on lcd

            Lprint.lcd_byte(0x01, LCD_CMD)
            Lprint.lcd_string("sending data... ",
                              LCD_LINE_1)  #syntax for printing on lcd screen
            '''
                detected id and ammount send to server
                1) success remaining balance display and message
                2) insufficinet balance and message
            
             '''
            url = "http://malgadi.co.in/touch-n-pay/do_payment.php?fid=" + str(
                detected_id) + "&cost=" + str(ammount)
            print 'response from website'

            content = urllib2.urlopen(url).read()
            print content
            Lprint.lcd_byte(0x01, LCD_CMD)
            Lprint.lcd_string("enter ammount ",
                              LCD_LINE_1)  #syntax for printing on lcd screen

            if content == '1':
                Lprint.lcd_string(
                    "payment successfull",
                    LCD_LINE_1)  #syntax for printing on lcd screen
                time.sleep(1.5)
            if content == '2':
                Lprint.lcd_string(
                    "insufficent",
                    LCD_LINE_1)  #syntax for printing on lcd screen
                Lprint.lcd_string(
                    "balance", LCD_LINE_2)  #syntax for printing on lcd screen
                time.sleep(1.5)

        else:
            Lprint.lcd_byte(0x01, LCD_CMD)
            Lprint.lcd_string("user not found",
                              LCD_LINE_1)  #syntax for printing on lcd screen
            time.sleep(2)

    else:
        Lprint.lcd_byte(0x01, LCD_CMD)
        Lprint.lcd_string("sorry....",
                          LCD_LINE_1)  #syntax for printing on lcd screen
        Lprint.lcd_string("try again",
                          LCD_LINE_2)  #syntax for printing on lcd screen
        time.sleep(2)

    f.stop_led()
Esempio n. 20
0
import sys
sys.path.append('`/.python/lcd')
import lcd
lcd.lcd_init()
lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
lcd.lcd_string("Raspberry Pi", 2)
lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
lcd.lcd_string("Model B+", 2)
lcd.GPIO.cleanup()
Esempio n. 21
0
    elif 'home' in msg.topic:
        if 'off' in msg.payload:
            lcd.lcd_string("Everyone is AWAY", lcd.LCD_LINE_4)
        elif 'on' in msg.payload:
            lcd.lcd_string("Someone is HOME", lcd.LCD_LINE_4)


def subscribe_topic():
    # Initialise display
    lcd.lcd_init()
    lcd.lcd_string("IP " + IPAddr, lcd.LCD_LINE_1)
    lcd.lcd_string("Alarm UNKNOWN", lcd.LCD_LINE_2)
    lcd.lcd_string("Garage Door UNKNOWN", lcd.LCD_LINE_3)
    lcd.lcd_string("Unsure where you are", lcd.LCD_LINE_4)
    client = mqtt.Client()
    client.on_connect = on_connect
    client.on_message = on_message
    client.username_pw_set(username=priv.username, password=priv.password)
    client.connect(priv.MQTT_HOST, 1883)
    client.loop_forever()


try:
    subscribe_topic()
except KeyboardInterrupt:
    log.info("Stopping...")
finally:
    print "*** GPIO Cleanup ***"
    GPIO.cleanup()
    lcd.lcd_byte(0x01, lcd.LCD_CMD)
import sys
sys.path.append('/home/pi/fire')
import lcd
lcd.lcd_init()
lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
lcd.lcd_string("Raspberry Pi", 2)
lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
lcd.lcd_string("Model B+", 2)
lcd.GPIO.cleanup()
Esempio n. 23
0
def loop():
    # Run every 5 seconds
    try:
        # Get current temperature
        fahrenheit = t.getFahrenheit()
        webiopi.debug("Current: %0.1f°F" % fahrenheit)

        # Set high & low
        global tHigh
        global tLow
        if fahrenheit > tHigh:
            tHigh = fahrenheit
        if fahrenheit < tLow:
            tLow = fahrenheit
        webiopi.debug("Low:     %0.1f°F" % tLow)
        webiopi.debug("High:    %0.1f°F" % tHigh)

        # Temperature thresholds
        webiopi.debug("Cold Threshold:    %0.1f°F" % COLD)
        webiopi.debug("Hot Threshold:     %0.1f°F" % HOT)
      
        # Toggle State (Current or Range)
        global displayCurrent
        displayCurrent = not displayCurrent

 
        # Check for reset switch press
        if GPIO.digitalRead(SWITCH) == GPIO.LOW:
            tHigh = fahrenheit
            tLow = fahrenheit
            setColor(Colors['White'])
            lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
            lcd.lcd_string("Current: %0.1f" % (fahrenheit)  + chr(223) + "F")
            lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
            lcd.lcd_string("Temp Range Reset")
        elif displayCurrent:
            # Current temp state (text color based on thresholds)
            if fahrenheit >= HOT:
                setColor(Colors['Red'])
            elif fahrenheit <= COLD:
                setColor(Colors['Blue'])
            else:
                setColor(Colors['Green'])
            # Display current temp
            lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
            lcd.lcd_string("Current: %0.1f" % (fahrenheit)  + chr(223) + "F")
            lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
            lcd.lcd_string(" ")
        else:
            # Temp range state (text color based on thresholds)
            if fahrenheit >= HOT:
                setColor(Colors['Orange'])
            elif fahrenheit <= COLD:
                setColor(Colors['Violet'])
            else:
                setColor(Colors['Aquamarine'])
            # Display temp range
            lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
            lcd.lcd_string("Low:  %0.1f" % (tLow)  + chr(223) + "F")
            lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
            lcd.lcd_string("High: %0.1f" % (tHigh)  + chr(223) + "F")
    except:
        webiopi.debug("error: " + str(sys.exc_info()[0]))
    finally:
        webiopi.sleep(5)  
Esempio n. 24
0
    time.sleep(1)
    logger.info('naptime over')

    chip_id, chip_version = readBME280ID()
    logger.info('chip_id=%s', chip_id)
    logger.info('chip_version=%s', chip_version)

    try:
        while True:
            t, p, h = readBME280All()
            logger.info('temperature=%s F | pressure=%s inHg | humidity=%s %%',
                        t, p, h)

            lcd_string('Temperature:', LCD_LINE_1)
            lcd_string(f'  {t} F', LCD_LINE_2)
            time.sleep(2)

            lcd_string('Pressure:', LCD_LINE_1)
            lcd_string(f'  {p} inHg', LCD_LINE_2)
            time.sleep(2)

            lcd_string('Humidity:', LCD_LINE_1)
            lcd_string(f'  {h} %', LCD_LINE_2)
            time.sleep(2)
    except KeyboardInterrupt:
        print()
        logger.info('Ctrl-C mashed')
    finally:
        lcd_byte(0x01, LCD_CMD)
        GPIO.cleanup()
Esempio n. 25
0
def loop():

    print ("GPIO 21 = ", GPIO.digitalRead(26) )
    print ("GPIO 24 = ", GPIO.digitalRead(19) )
    print ("GPIO 21 = ", GPIO.digitalRead(13) )
    print ("GPIO 24 = ", GPIO.digitalRead(6) )

    # Run every 3 seconds
    try:
        global tShopHigh
        global tShopLow
        global tGpuHigh
        global tGpuLow
        global tCpuHigh
        global tCpuLow

        # Get current Shop temperature
        fahrenheit = t.getFahrenheit()
        webiopi.debug("Shop: %0.1f°F" % fahrenheit)
        
    # Get GPU temperature
        GPUfahrenheit = float(get_gpu_temp())
        webiopi.debug("GPU Temp: %0.1f°F" % GPUfahrenheit)
        
        # Get CPU temperature
        CPUfahrenheit = float(get_cpu_temp())
        webiopi.debug("CPU Temp: %0.1f°F" % CPUfahrenheit)
        
        # Set high & low for GPU
        if GPUfahrenheit > tGpuHigh:
            tGpuHigh = GPUfahrenheit
        elif GPUfahrenheit < tGpuLow:
            tGpuLow = GPUfahrenheit
    
        if CPUfahrenheit > tCpuHigh:
            tCpuHigh = CPUfahrenheit
        elif CPUfahrenheit < tCpuLow:
            tCpuLow = CPUfahrenheit
        
        if fahrenheit > tShopHigh:
            tShopHigh = fahrenheit
        elif fahrenheit < tShopLow:
            tShopLow = fahrenheit
        webiopi.debug("GPU Low:     %0.1f°F" % tGpuLow)
        webiopi.debug("GPU High:    %0.1f°F" % tGpuHigh)
        webiopi.debug("CPU Low:     %0.1f°F" % tCpuLow)
        webiopi.debug("CPU High:    %0.1f°F" % tCpuHigh)
        webiopi.debug("Shop Low:     %0.1f°F" % tShopLow)
        webiopi.debug("Shop High:    %0.1f°F" % tShopHigh)

        # Temperature thresholds
        webiopi.debug("Shop Cold Threshold:    %0.1f°F" % COLD_shop)
        webiopi.debug("Shop Hot Threshold:     %0.1f°F" % HOT_shop)
        webiopi.debug("GPU Cold Threshold:    %0.1f°F" % COLD_gpu)
        webiopi.debug("GPU Hot Threshold:     %0.1f°F" % HOT_gpu)
        webiopi.debug("CPU Cold Threshold:    %0.1f°F" % COLD_cpu)
        webiopi.debug("CPU Hot Threshold:     %0.1f°F" % HOT_cpu)

        readouts = ['shopTemp', 'shopRange', 'GPUtemp', 'GPUrange', 'CPUtemp', 'CPUrange']
        for output in readouts:       
            if GPIO.digitalRead(SWITCH) == GPIO.LOW:
                # Reset switch pressed
                tShopHigh = fahrenheit
                tShopLow = fahrenheit
                tGpuHigh = GPUfahrenheit
                tGpuLow = GPUfahrenheit
                tCpuHigh = CPUfahrenheit
                tCpuLow = CPUfahrenheit
                # LCD background white
                GPIO.pwmWrite(RED, 0.0)
                GPIO.pwmWrite(GREEN, 0.6)
                GPIO.pwmWrite(BLUE, 0.8)
                lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
                lcd.lcd_string("")
                lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
                lcd.lcd_string("Temp Ranges Reset")

            elif output == 'shopTemp':
                # LCD background for Shop state
                if fahrenheit >= HOT_shop:
                    red()
                elif fahrenheit <= COLD_shop:
                    blue()
                else:
                    green()
                # Display Shop temp
                lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
                lcd.lcd_string("Shop Temperature")
                lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
                lcd.lcd_string("     %0.1f" % (fahrenheit)  + chr(223) + "F")

            elif output == 'shopRange':
                # LCD background for Shop range state
                if fahrenheit >= HOT_shop:
                    red()
                elif fahrenheit <= COLD_shop:
                    blue()
                else:
                    white()
                # Display Shop range
                lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
                lcd.lcd_string("Shop Low: %0.1f" % (tShopLow)  + chr(223) + "F")
                lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
                lcd.lcd_string("    High: %0.1f" % (tShopHigh)  + chr(223) + "F")

            elif output == 'GPUtemp':
                # LCD background for GPU state
                if GPUfahrenheit >= HOT_gpu:
                    red()
                elif GPUfahrenheit <= COLD_gpu:
                    blue()
                else:
                    green()
                # Display GPU temp
                lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
                lcd.lcd_string("GPU Temperature")
                lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
                lcd.lcd_string("    %0.1f" % (GPUfahrenheit)  + chr(223) + "F")

            elif output == 'GPUrange':
                # LCD background for Shop range state
                if GPUfahrenheit >= HOT_gpu:
                    red()
                elif GPUfahrenheit <= COLD_gpu:
                    blue()
                else:
                    white()
                # Display Shop range
                lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
                lcd.lcd_string("GPU Low: %0.1f" % (tGpuLow)  + chr(223) + "F")
                lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
                lcd.lcd_string("   High: %0.1f" % (tGpuHigh)  + chr(223) + "F")

            elif output == 'CPUtemp':
                # LCD background for Shop state
                if CPUfahrenheit >= HOT_cpu:
                    red()
                elif CPUfahrenheit <= COLD_cpu:
                    blue()
                else:
                    green()
                # Display CPU temp
                lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
                lcd.lcd_string("CPU Temperature")
                lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
                lcd.lcd_string("    %0.1f" % (CPUfahrenheit)  + chr(223) + "F")

            else:
                if output == 'CPUrange':
                # LCD background for CPU range state
                    if CPUfahrenheit >= HOT_cpu:
                        red()
                    elif CPUfahrenheit <= COLD_cpu:
                        blue()
                    else:
                        white()
                    # Display CPU range
                    lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
                    lcd.lcd_string("CPU Low: %0.1f" % (tCpuLow)  + chr(223) + "F")
                    lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
                    lcd.lcd_string("   High: %0.1f" % (tCpuHigh)  + chr(223) + "F")

            webiopi.sleep(1)

    except:     
        webiopi.debug("error: " + str(sys.exc_info()[0]))
Esempio n. 26
0
def loop():
    try:
        #LCD background white
        GPIO.pwmWrite(RED, 0.0)
        GPIO.pwmWrite(GREEN, 0.6)
        GPIO.pwmWrite(BLUE, 0.8)
        lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
        lcd.lcd_string("openbuilds.com")
        lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
        lcd.lcd_string("Build Anything")
        time.sleep(2)

        GPIO.pwmWrite(RED, 1.0)
        GPIO.pwmWrite(GREEN, 1.0)
        GPIO.pwmWrite(BLUE, 0.0)
        lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
        lcd.lcd_string("Dream It")
        lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
        lcd.lcd_string("")
        time.sleep(1)

        GPIO.pwmWrite(RED, 0.0)
        GPIO.pwmWrite(GREEN, 1.0)
        GPIO.pwmWrite(BLUE, 1.0)
        lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
        lcd.lcd_string("Build It")
        lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
        lcd.lcd_string("")
        time.sleep(1)

        GPIO.pwmWrite(RED, 1.0)
        GPIO.pwmWrite(GREEN, 0.0)
        GPIO.pwmWrite(BLUE, 1.0)
        lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
        lcd.lcd_string("Share It")
        lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
        lcd.lcd_string("")
        time.sleep(2)

        GPIO.pwmWrite(RED, 1.0)
        GPIO.pwmWrite(GREEN, 1.0)
        GPIO.pwmWrite(BLUE, 1.0)
        lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
        lcd.lcd_string("")
        lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
        lcd.lcd_string("")
    finally:
        webiopi.sleep(5)
Esempio n. 27
0
import time
#import RPi.GPIO as GPIO
import lcd
from Acquisition import read_data

lcd.lcd_init()
LINE1 = lcd.LCD_LINE_1
LINE2 = lcd.LCD_LINE_2
CMD = lcd.LCD_CMD
CHR = lcd.LCD_CHR

try:
    while True:
        temp, humid = read_data()
        if (temp == None or humid == None):
            lcd.lcd_byte(0x01, CMD)
            lcd.lcd_string("Retrieving data..", LINE1)
            time.sleep(1)
        else:
            lcd.lcd_byte(0x01, CMD)
            lcd.lcd_string("Temperature", LINE1)
            lcd.lcd_string("%.1f degC" % temp, LINE2 + 1)
            time.sleep(3)

            lcd.lcd_byte(0x01, CMD)
            lcd.lcd_string("Humidity", LINE1)
            lcd.lcd_string("%.1f" % humid, LINE2 + 1)
            lcd.lcd_string("%", LINE2 + 6)
            time.sleep(1)

except KeyboardInterrupt:
Esempio n. 28
0
            vorigeWaarde = sensorwaarde

        else:
            vorigeWaarde = sensorwaarde

        tijd2 = time.time()

    #omtrek wiel 21,6769 cm

    return ((omwenteligen / 2) * 0.2167) * 3.6


try:

    while True:
        tekst = round(meterPerSecondeKenneth(), 2)
        lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
        lcd.lcd_byte(0x01, False)
        time.sleep(0.03)
        lcd.lcd_string(str(tekst), 2)

        # lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
        # lcd.lcd_string(lcd.get_ip_son(), 2)

        # print("--------------------------------------------")

        # time.sleep(0.1)
        # print(duration)
except KeyboardInterrupt:
    GPIO.cleanup()