コード例 #1
0
ファイル: lcd.py プロジェクト: nakacodejuice/i2cbananalcd
 def run(self):
     i = 0
     while (True):
         try:
             if (i == 0):
                 data = self.getdata()
             for pak in data:
                 lcd = lcddriver.lcd()
                 lcd.lcd_clear()
                 st = lcd_rus.convertToRUSchar1602(pak['alltext'])
                 lcd.lcd_load_custom_chars(st['chardata'])
                 for l in pak['list']:
                     structtext = lcd_rus.convertToRUSchar1602(l['text'])
                     self.display(structtext, l['line'], lcd)
                 sleep(5)
             if (i == 6):
                 i = -1
         except:
             lcd = lcddriver.lcd()
             lcd.lcd_clear()
             st = lcd_rus.convertToRUSchar1602(u'Ошибка!!!')
             lcd.lcd_load_custom_chars(st['chardata'])
             self.display(st, 1, lcd)
             sleep(120)
         i += 1
コード例 #2
0
def adduser(request):
    GPIO.setmode(GPIO.BOARD)
    reader = SM()
    display = lcddriver.lcd()

    if request.method == 'POST':
        first_name = request.POST['first_name']
        last_name = request.POST['last_name']
        try:
            display.lcd_clear()  # Write line of text to first line of display

            display.lcd_display_string(
                "Pointez ici !",
                1)  # Write line of text to first line of display

            id, text = reader.read()
        finally:
            GPIO.cleanup()
        rfid = id

        Utlisateur.objects.create(rfid=rfid,
                                  first_name=first_name,
                                  last_name=last_name)
        return redirect(users)

    else:
        return render(request, 'base2.html', locals())
コード例 #3
0
class Search:
    global display
    display = lcddriver.lcd()
    baseMethod = baseMethods.BaseMethods()

    def __init__(self):
        pass

    def main(self):
        
        temp = self.baseMethod.genImg()
        
        if temp == 2:
            return [404]
            pass 
        elif (temp == 0):
            if self.baseMethod.img2Tz(1):
                display.lcd_clear()
                display.lcd_display_string('Conversion Error',1)
                time.sleep(2)
                display.lcd_clear()
                sys.exit(0)
            r = self.baseMethod.search()  # template conversion done. Now check whether the finger
            if r[0] == 0:
                return [r[0], r[1], r[2]]
            else:
                return [304]
        else:
            sys.exit(0)
コード例 #4
0
ファイル: Password.py プロジェクト: Peelawit/ProjectBro
    def checkpass() :
        kp = keypad()
        txt = password_txt()
        display = lcddriver.lcd()
        display.lcd_clear()
        time.sleep(1)
        check = 0
        arrayPass = []
        show = ""
        count = 0
        rounds = 0
        display.lcd_display_string("Enter Password    ",1)
        while True :
            # Loop while waiting for a keypress
            digit = None
            while digit == None:
                digit = kp.getKey()
                time.sleep(0.1)
                rounds += 1
                if(rounds == 150):
                    break
            if(rounds == 150):
                break
                
            if(digit != "A" and digit != "B" and digit != "C" and digit != "D" and digit != "*" and digit != "#"):
                time.sleep(0.4)
                arrayPass.append(str(digit))
                count += 1
                rounds = 0
                
            if digit == "B" :
                    time.sleep(0.4)
                    if(count != 0) :
                        count = count - 1
                        arrayPass.pop(count)
                        display.lcd_display_string("                ",2)
                        rounds = 0
                        
            show = ""
            if(count != 0):
                for i in range(count):
                    show += str(arrayPass[i])     
            display.lcd_display_string(show,2)
            time.sleep(0.4)

            if(count == 4):
                password = txt.read()
                if(str(show) == str(password)):
                    check = 1
                else:
                    display.lcd_display_string("Incorrect!!!    ",2)
                    time.sleep(3)
                break

        display.lcd_clear()
        time.sleep(1)
        if(check == 1):
            return True
        else:
            return False
コード例 #5
0
ファイル: emonPiLCD.py プロジェクト: jda0012/IIOT-mill
    def __init__(self, logger):
        # Scan I2C bus for LCD I2C addresses as defined in led_i2c, we have a couple of models of LCD which have different adreses that are shipped with emonPi. First I2C device to match address is used.
        self.logger = logger
        for i2c_address in lcd_i2c:
            lcd_status = subprocess.check_output(
                [path + "/emonPiLCD_detect.sh",
                 "%s" % i2c_address])
            if lcd_status.rstrip() == 'True':
                print "I2C LCD DETECTED Ox%s" % i2c_address
                logger.info("I2C LCD DETECTED 0x%s" % i2c_address)
                current_lcd_i2c = "0x%s" % i2c_address
                # add file to identify device as emonpi
                open('/home/pi/data/emonpi', 'a').close()
                break

        if lcd_status.rstrip() == 'False':
            print("I2C LCD NOT DETECTED on either 0x" + str(lcd_i2c) +
                  " ...exiting LCD script")
            logger.error("I2C LCD NOT DETECTED on either 0x" + str(lcd_i2c) +
                         " ...exiting LCD script")
            # add file to identify device as emonbase
            open('/home/pi/data/emonbase', 'a').close()
            sys.exit(1)

        # Init LCD using detected I2C address with 16 characters
        self.lcd = lcddriver.lcd(int(current_lcd_i2c, 16))
        self._display = ['', '']
コード例 #6
0
def weathertom():
    lcd = lcddriver.lcd()
    lcd.lcd_clear()
    d = str(datetime.date.today() + datetime.timedelta(days=-1))

    params = {
        'access_key': 'b4b8c3cd76ddc589b6c3962ba7a45a66',
        'query': 'Paris'
    }
    api_result2 = requests.get(
        'http://api.weatherstack.com/forecast?access_key=b4b8c3cd76ddc589b6c3962ba7a45a66&query=Paris',
        params)
    api_response2 = api_result2.json()
    mintemptom = int(api_response2['forecast'][d]['mintemp'])
    maxtemptom = int(api_response2['forecast'][d]['maxtemp'])
    if mintemptom < 15:
        lcd.lcd_display_string("Tommorow, min temp is ", 1)
        lcd.lcd_display_string(str(mintemptom) + " think to", 2)
        lcd.lcd_display_string("put the heating on", 3)
    if maxtemptom > 28:
        lcd.lcd_display_string("Tommorow, max temp is", 1)
        lcd.lcd_display_string(str(maxtemptom) + " think about", 2)
        lcd.lcd_display_string("put the air", 3)
        lcd.lcd_display_string("conditionning on", 4)
    if maxtemptom < 28 and mintemptom > 15:
        lcd.lcd_display_string("Tommorow's temp", 1)
        lcd.lcd_display_string("don't need", 2)
        lcd.lcd_display_string("heating nor air con", 3)
    time.sleep(5)
コード例 #7
0
ファイル: main.py プロジェクト: teopicca/w_station
def loading():
    lcd = lcddriver.lcd()
    lcd.lcd_clear()

    lcd.lcd_display_string('loading......', 1)

    time.sleep(5)
コード例 #8
0
def display(temp, humidity, resair, sound):
    lcd = lcddriver.lcd()
    lcd.lcd_clear()
    if temp < 24 and temp > 19:
        lcd.lcd_display_string(str(temp) + " °C ideal temp", 1)
    if temp < 18:
        lcd.lcd_display_string(str(temp) + " °C low temp", 1)
    if temp > 24:
        lcd.lcd_display_string(str(temp) + " °C high temp", 1)
    if humidity < 60 and humidity > 40:
        lcd.lcd_display_string(str(humidity) + " correct hum", 2)
    if humidity > 60:
        lcd.lcd_display_string(str(humidity) + " open window", 2)
    if humidity < 40:
        lcd.lcd_display_string(str(humidity) + " low hum", 2)
    resair = abs((160000 - resair) / 160000)
    if resair > 10:
        lcd.lcd_display_string("Open the windows", 3)
    if resair < 10:
        lcd.lcd_display_string("Nice IAQ", 3)
    if sound > 350:
        lcd.lcd_display_string(str(sound) + " TOO LOUD", 4)
    if sound < 350:
        lcd.lcd_display_string(str(sound) + " It's calm", 4)
    time.sleep(11)
コード例 #9
0
 def __init__(self):
     self.power = True
     self.text = ["", ""]
     self.previous_text = ["", ""]
     self.setGPIO()
     self.display = lcddriver.lcd()
     os.chdir("/home/pi/Desktop/Sudoku-Plotter/script/lcd")
コード例 #10
0
 def __init__(self, title, index):
     self.title = title
     self.menuIndex = index
     self.prevMenu = self
     self.subMenuObj = []
     self.display = lcddriver.lcd()
     self.button = keypaddriver.keypad()
コード例 #11
0
ファイル: Power.py プロジェクト: Peelawit/ProjectBro
 def menu(self):
     display = lcddriver.lcd()
     kp = keypad()
     display.lcd_clear()
     time.sleep(1)
     while True :
         display.lcd_display_string("A)Shutdown",1)
         display.lcd_display_string("B)Reboot",2)
         key = None
         while key == None:
             key = kp.getKey()
         if(key == "A"):
             display.lcd_clear()
             time.sleep(1)
             display.lcd_display_string("Shutdown...",1)
             time.sleep(2)
             display.lcd_clear()
             print(subprocess.call("shutdown -h now", shell=True))
             break
         if(key == "B"):
             display.lcd_clear()
             time.sleep(1)
             display.lcd_display_string("Reboot...",1)
             print(subprocess.call("sudo reboot", shell=True))
             break
         if(key == "C"):
             password.changepass()
             break
         if(key == "D"):
             display.lcd_clear()
             time.sleep(1)
             display.lcd_display_string("Cancel...",1)
             time.sleep(2)
             break
コード例 #12
0
 def __init__(self,LCDQueue,LCDEvent):
    super(LCDControl, self).__init__()
    self.LCDQueue = LCDQueue
    self.LCDEvent = LCDEvent
    self.rowSize = [14,0]
    self.lcd = lcddriver.lcd()   
    self.lcd.lcd_display_string("System Running", 1) 
    self.lcd.lcd_display_string("v3.00", 2) 
コード例 #13
0
 def __init__(self):
     self.lcd = lcddriver.lcd()
     self.lcd.lcd_clear()
     self.lcd.lcd_display_string("                    ", 1)
     self.lcd.lcd_display_string("  *** PI ALARM ***  ", 2)
     self.lcd.lcd_display_string("", 3)
     self.lcd.lcd_display_string("(c) BARTHELEMY      ", 4)
     sleep(5)
コード例 #14
0
ファイル: 07_meteo.py プロジェクト: HellTech/NAG_IoE_2016
def init_lcd_display():
  global lcd
  try:
    lcd = lcddriver.lcd()
    lcd.lcd_clear();
    lcd.lcd_display_string("Meteo HellTech", 1)    
  except:
    pass 
コード例 #15
0
ファイル: GullibotCmd.py プロジェクト: dablackwood/gullibot
 def initCharDisplay(self):
     if self.lcdActive:
         import lcddriver
         self.lcd = lcddriver.lcd()
     else:
         self.lcd = None
     self.lcdLineLength = 20
     self.lcdNumLines = 4
コード例 #16
0
class RegisterUser:
    global display
    display = lcddriver.lcd()
    srh = search.Search()
    enr = enroll.Enroll()

    def __init__(self):
        pass

    def main(self):
        b = False
        timeStamp = time.time()
        while (time.time() - timeStamp) <= 120:
            display.lcd_clear()
            display.lcd_display_string("Put Authorizer's", 1)
            display.lcd_display_string("Finger", 2)
            a = self.srh.main()
            if a[0] != 404 and a[0] != 304:
                try:
                    fp = open('records.txt', 'r')
                    for line in fp:
                        arg1, arg2 = line.split(',')
                        if arg1 == str(a[1]) and arg2 == (str(a[2]) + "\n"):
                            b = True
                            break
                        else:
                            b = False
                finally:
                    fp.close()
                break
            else:
                pass

        if b:
            timeStamp = time.time()
            while (time.time() - timeStamp) <= 120:
                display.lcd_clear()
                display.lcd_display_string("Put New Finger", 1)
                c = self.srh.main()
                if c[0] == 404:
                    pass
                elif c[0] == 304:
                    self.enr.main(1)
                    break
                else:
                    display.lcd_clear()
                    display.lcd_display_string("Already", 1)
                    display.lcd_display_string("Registered", 2)
                    time.sleep(2)
                    display.lcd_clear()
                    break
        else:
            display.lcd_clear()
            display.lcd_display_string("Finger Isn't", 1)
            display.lcd_display_string("Authorized", 2)
            time.sleep(2)
            display.lcd_clear()
コード例 #17
0
def main():
  # Main program block
  lcd = lcddriver.lcd()
  while True:
    print("Escribe un texto por líneas de 20 caracteres y pulsa Enter seguido de Ctrl+D")
    msg = sys.stdin.readlines()
    lcd.lcd_clear()
    for x in range(len(msg)):
        lcd.lcd_display_string(msg[x].replace("\n", ""), x+1)
コード例 #18
0
ファイル: menu.py プロジェクト: gauthimd/AcidDipTest
 def __init__(self):
     self.stringdict = {1: "", 2: "", 3: "", 4: ""}
     self.blinkline = 1
     self.blinkon = 0
     self.button = 0
     self.lcd = lcddriver.lcd()
     self.rot = KY040.KY040(21, 20, 24, self.rotarycallback,
                            self.switchcallback)
     self.rot.start()
コード例 #19
0
ファイル: GardenPi.py プロジェクト: max-Behr/GardenPi
def lcdInfo():
    print(Fore.YELLOW + "[!] Checkt LCD Display...")
    lcd = lcddriver.lcd()
    time = datetime.datetime.now()

    lcd.lcd_backlight("off")
    lcd.lcd_clear()
    lcd.lcd_display_string("     GreenPi    ", 1)
    lcd.lcd_display_string(str(time), 2)
    print(Fore.GREEN + "[" + u'\u2713' + "] LCD Display aktualisiert!")
コード例 #20
0
def long_string(display, text='', num_line=1, num_cols=20):
    if (len(text) > num_cols):
        display.lcd_display_string(text[:num_cols], num_line)
        time.sleep(1)
        for i in range(len(text) - num_cols + 5):
            text_to_print = text[i:i + num_cols]
            display.lcd_display_string(text_to_print, num_line)
            time.sleep(0.2)
    else:
        display.lcd_display_string(text, num_line)
        display = lcddriver.lcd()
コード例 #21
0
def printLCD(string):
    lines = string
    if lines == "off":
        my_lcd = lcd()
        my_lcd.backlight_off()
        quit()

    if lines == "on":
        my_lcd = lcd()
        my_lcd.backlight_on()
        quit()

    my_lcd = lcd()
    my_lcd.clear()
    lines = lines.split('~')
    for (i, line) in enumerate(lines):
        line = line.replace('_', ' ')
        if len(line) > 16:
            line = lines[0:16]
        my_lcd.display_string(line, i + 1)
コード例 #22
0
ファイル: main.py プロジェクト: teopicca/w_station
def wind():

    lcd = lcddriver.lcd()

    while True:

        w = wind_arduino()
        v_w = w.wind()
        lcd.lcd_display_string(v_w, 4, 8)

        time.sleep(1)
コード例 #23
0
ファイル: main.py プロジェクト: jaschawilcox/raspi-lockout
    def __init__(self, session):
        self._session = session

        # Setup hardware
        self._lcd = lcddriver.lcd()
        self._lcd.lcd_clear()

        self._state = 'locked'

        self._timestr = ''
        self._messageTimeout = 0
        self.update()
コード例 #24
0
ファイル: emonPiLCD.py プロジェクト: delphsoft/emonpi
 def __init__(self, logger):
     # Check to see if LCD is connected if not then stop here
     self.logger = logger
     lcd_status = subprocess.check_output(["/home/pi/emonpi/lcd/emonPiLCD_detect.sh", "27"])
     if lcd_status.rstrip() == 'False':
         print "I2C LCD NOT DETECTED...exiting LCD script"
         logger.error("I2C LCD NOT DETECTED...exiting LCD script")
         sys.exit(1)
     else:
         logger.info("I2C LCD Detected on 0x27")
     self.lcd = lcddriver.lcd()
     self._display = ['', '']
コード例 #25
0
ファイル: remotecontrol.py プロジェクト: tvk/musicserver
	def updateLcd(self):
		lcd = lcddriver.lcd()
		while True:
			if (time.time() + 8 > self.lcdTimeout and self.lcdAltSecondLine is not None):
				self.lcdSecondLine = self.lcdAltSecondLine 
			if (time.time() < self.lcdTimeout):
				lcd.lcd_backlight("on")
				lcd.lcd_display_string(time.ctime(), 1)
				lcd.lcd_display_string(self.lcdSecondLine, 2)
			if (time.time() > self.lcdTimeout):
				lcd.lcd_backlight("off")
			time.sleep(0.25)
コード例 #26
0
    def setUp():
        
        display = lcddriver.lcd()
        
        display.lcd_clear()
        
        if not os.path.exists(ALARM_FILE):
            open(ALARM_FILE,"a").close()

        alsaaudio.Mixer('PCM').setvolume(70)
        
        GPIO.setmode(GPIO.BCM)
コード例 #27
0
def print_on_lcd(txt="Hello World", time_on=5, waiting=False):
    display = lcddriver.lcd()
    display.lcd_display_string(txt, 1)
    try:
        if waiting:
            pass
        else:
            time.sleep(time_on)
            display.lcd_clear()
    except KeyboardInterrupt:
        display.lcd_clear()
        exit()
コード例 #28
0
 def __init__(self, logger):
     # Check to see if LCD is connected if not then stop here
     self.logger = logger
     lcd_status = subprocess.check_output(["/home/pi/emonpi/lcd/emonPiLCD_detect.sh", "27"])
     if lcd_status.rstrip() == 'False':
         print "I2C LCD NOT DETECTED...exiting LCD script"
         logger.error("I2C LCD NOT DETECTED...exiting LCD script")
         sys.exit(1)
     else:
         logger.info("I2C LCD Detected on 0x27")
     self.lcd = lcddriver.lcd()
     self._display = ['', '']
コード例 #29
0
def update_lcd(temps, temp_names):
    try:
        #print("Updating LCD \n Temp 1",temps[0])
        lcd = lcddriver.lcd()
        for i in range(0, 3):
            lcd.lcd_display_string(temp_names[i] + str(temps[i]) + "DegC", i)
        print("Temp 1:", str(temps[0]))
        print("Temp 2:", str(temps[1]))
        print("Temp 3:", str(temps[2]))
    except Exception as e:
        lcd.lcd_clear()
        lcd.lcd_display_string("Error Displaying Temps", 1)
        lcd.lcd_display_string(str(e), 2)
コード例 #30
0
ファイル: lcdcontrol.py プロジェクト: 3dh-de/pishower
 def open(self):
     """ Open connection to LCD display """
     try:
         self.__outputDevice = lcddriver.lcd()
         if self.__outputDevice is None:
             raise RuntimeWarning
         self.__outputDevice.lcd_clear()
         time.sleep(1.0)  # prevent timing issues
     except:
         if self.__deviceOpenRetries < 1:
             logger.error('Unable to open HD44780 LCD display!')
         self.__outputDevice = None
         self.__deviceOpenRetries += 1
コード例 #31
0
 def updateLcd(self):
     lcd = lcddriver.lcd()
     while True:
         if (time.time() + 8 > self.lcdTimeout
                 and self.lcdAltSecondLine is not None):
             self.lcdSecondLine = self.lcdAltSecondLine
         if (time.time() < self.lcdTimeout):
             lcd.lcd_backlight("on")
             lcd.lcd_display_string(time.ctime(), 1)
             lcd.lcd_display_string(self.lcdSecondLine, 2)
         if (time.time() > self.lcdTimeout):
             lcd.lcd_backlight("off")
         time.sleep(0.25)
コード例 #32
0
ファイル: rss_reader.py プロジェクト: fhaverkamp/RaspberryPi2
def main(argv):
	global mode

	try:
		opts, args = getopt.getopt(argv, "rh",
			[ "help", "verbose" ])
	except getopt.GetoptError:
		usage()
		sys.exit(2)

	for opt, arg in opts:
		if opt in ("-h", "--help"):
			usage()
			sys.exit()
		elif opt in ("-v", "--verbose"):
			global verbose
			verbose = True
	source = "".join(args)

	init_temperature_measurement()
	init_buttons()

	lcd = lcddriver.lcd()
	lcd.lcd_create_umlaute()
	lcd_banner(lcd)

	rss = rss_lib.rss_reader(feed_url, feed_db, LCD_WIDTH)
	post_list = rss.parse_feeds()

	while True:
		if mode == MODE_CLOCK:
			lcd.lcd_clear()
			lcd_create_bigfont(lcd)
			lcd_bigfont_clock(lcd)

		if mode == MODE_RSS:
			lcd.lcd_clear()
			lcd.lcd_create_umlaute()
			if len(post_list) == 0:
				post_list = rss.parse_feeds()
			if len(post_list) != 0:
				post = post_list[0]
				post_list.pop(0)
			lcd_print_text(lcd, post)

		if mode == MODE_TEMP:
			lcd.lcd_clear()
			lcd.lcd_create_umlaute()
			lcd_statistics(lcd)
			lcd_temperatures(lcd)
			lcd_weather(lcd)
コード例 #33
0
    def init(self):
        """ initialize display """

        # initialize data structures
        self._content_deque = collections.deque(maxlen=self._rows - 1)
        self._fmt_line = u"{0:%d.%ds}" % (self._cols, self._cols)

        # initialize hardware
        try:
            self._lcd = lcddriver.lcd(port=self._i2c, tmap=self._transmap)
        except NameError:
            self.debug("no display detected")
            self.have_disp = False
        title = self._content_provider.get_title()
        self._update_display(self._format_title(*title), [], True)
コード例 #34
0
ファイル: main.py プロジェクト: teopicca/w_station
def display():
    lcd = lcddriver.lcd()

    lcd.lcd_clear()

    lcd.lcd_display_string('temp =', 1)

    lcd.lcd_display_string('C', 1, 12)

    lcd.lcd_display_string('press = ', 2)

    lcd.lcd_display_string('atm', 2, 12)
    lcd.lcd_display_string('hum = ', 3)
    lcd.lcd_display_string('%', 3, 12)

    lcd.lcd_display_string('wind = ', 4)
    lcd.lcd_display_string('km/h', 4, 13)
コード例 #35
0
ファイル: Camera.py プロジェクト: Peelawit/ProjectBro
    def camera_on(self):
        try:
            display = lcddriver.lcd()
            display.lcd_clear()
            time.sleep(1)
            display.lcd_display_string("Camera Detect", 1)
            cap = cv2.VideoCapture(0)
            snd = sound()
            check_eye = 0
            sound_alert = 0
            display.lcd_display_string("Ready...     ", 2)
            while (True):
                ret, frame = cap.read()
                frame = cv2.resize(frame, (240, 160),
                                   interpolation=cv2.INTER_AREA)
                frame, check_eye = self.detect(frame, self.eyeCascade,
                                               check_eye)
                if (sound_alert == 0 and check_eye > 11):
                    snd.on()
                    sound_alert = 1
                    display.lcd_display_string("Detected !!!", 2)

                elif (sound_alert == 1 and check_eye == 0):
                    snd.off()
                    sound_alert = 0
                    display.lcd_display_string("Ready...     ", 2)
                kp = keypad()
                if (kp.getKey() == "D"):
                    time.sleep(0.4)
                    display.lcd_display_string("Stopping...  ", 2)
                    time.sleep(2)
                    display.lcd_clear()
                    if (sound_alert == 1):
                        snd.off()
                    break

            cap.release()
            cv2.destroyAllWindows()

        except:
            display.lcd_display_string("Port Error!!!  ", 2)
            time.sleep(3)
            display.lcd_clear()
            time.sleep(1)
            display.lcd_display_string("Reboot...", 1)
            print(subprocess.call("sudo reboot", shell=True))
コード例 #36
0
ファイル: lcdpanel.py プロジェクト: jncl/AirPi
 def __init__(self, data):
     self.log = logging.getLogger('airpi.lcdpanel')
     self.cols = int(data["cols"])
     self.rows = int(data["rows"])
     self.delay = float(data["delay"])
     self.sl = [0, 1 ,1 ,1] # first line is static others scroll
     try:
         self.lcd = lcddriver.lcd()
         self.lcd.display_string("  Airpi LCD panel   ", 2)
         self.lcd.display_string(" Init was a Success ", 3)
         # setup LcdScroller thread object
         data = (u" Airpi Sensor Info. ", u"Temp: Unknown, P: Unknown, RH: Unknown ", u"LL: Unknown, LLl: Unknown, Vol: Unknown ", u"NO2: Unknown, CO: Unknown ")
         self.scroller = LcdScroller(self.lcd, self.rows, self.cols, self.delay, self.sl, data)
         self.scroller.start()
     except Exception as e:
         self.log.error("Error initialising LCDpanel: {}".format(e))
         raise
     else:
         self.log.debug("Initialised successfully")
コード例 #37
0
ファイル: emonPiLCD.py プロジェクト: Woobatron/emonpi
 def __init__(self, logger):
     # Scan I2C bus for LCD I2C addresses as defined in led_i2c, we have a couple of models of LCD which have different adreses that are shipped with emonPi. First I2C device to match address is used.
     self.logger = logger
     for i2c_address in lcd_i2c:
       lcd_status = subprocess.check_output(["/home/pi/emonpi/lcd/emonPiLCD_detect.sh", "%s" % i2c_address])
       if lcd_status.rstrip() == 'True':
         print "I2C LCD DETECTED Ox%s" % i2c_address
         logger.info("I2C LCD DETECTED 0x%s" % i2c_address)
         current_lcd_i2c = "0x%s" % i2c_address
         break
     
     if lcd_status.rstrip() == 'False':
       print ("I2C LCD NOT DETECTED on either 0x" + str(lcd_i2c) + " ...exiting LCD script")
       logger.error("I2C LCD NOT DETECTED on either 0x" + str(lcd_i2c) + " ...exiting LCD script")
       sys.exit(1)
     
     # Init LCD using detected I2C address with 16 characters
     self.lcd = lcddriver.lcd(int(current_lcd_i2c, 16))
     self._display = ['', '']
コード例 #38
0
ファイル: display.py プロジェクト: Surras/python-i2c-lcd
from lcddriver import lcd
import sys

lines = str(sys.argv[1])

if lines == "off" :
  my_lcd = lcd()
  my_lcd.backlight_off();
  quit()

if lines == "on" :
  my_lcd = lcd()
  my_lcd.backlight_on();
  quit()

  my_lcd = lcd()
  my_lcd.clear()

lines = lines.split('~')
my_lcd = lcd()
for (i, line) in enumerate(lines):
  line = line.replace('_', ' ')
  if len(line) > 16 :
    line = lines[0:16]
  my_lcd.display_string(line, i+1)
コード例 #39
0
ファイル: lcdclock.py プロジェクト: khelif96/piClock
import string
import sys
import time
from time import gmtime,strftime

#Config Variables
global timeSinceRefresh
ZipCode = '11209' #ZipCode for weather
PianobarOutLocation = '/home/pi/projects/piclock/out' #Location of the file Pianobar is writing the song name and artist output strings
hourFormat12H = True #Change this if you want the time to be displayed in 12h format or 24h format
	#True for 12h format or False for 24h format
CelciusUnit = False #Variable for weather unit; True for Celcius, False for Fahrenheit,
weatherRefreshInterval = 3600 #Interval to check the weather in Seconds, 3600 is 1 hour

#Initialize import items
lcd = lcddriver.lcd() # Set Up LCD Display
REMOTE_SERVER = "www.google.com" #Url to check if data connection is available

timeDelay = 4 #Refreshes clock every 4 Seconds


refreshInterval = 4

weatherRefreshInterval = weatherRefreshInterval/refreshInterval


timeSinceRefresh = 3500

global SongValue
SongValue = 0
コード例 #40
0
ファイル: weather_16x2.py プロジェクト: RXCORE/analogzero
#!/usr/bin/python3
from time import sleep
from gpiozero import MCP3008
import lcddriver
vref = 3.3
channels = [0,0,0,0,0,0,0,0]
temperatures = [0,0]
light_levels = [0,0]
count = 0

lcd = lcddriver.lcd()    # create object for lcd control
lcd.lcd_clear()          # clear LCD ready for start

def update():
    lcd.lcd_display_string('{:^16}'.format(row_one), 1)
    lcd.lcd_display_string('{:^16}'.format(row_two), 2)

# display a centered intro message
row_one   = '{:^16}'.format("RasPiO Analog Zero")
row_two = '{:^16}'.format("16x2 Weather Kit")
update()
sleep(3)

# Wiring instructions
#
# Wire up 2x TMP36 so the middle pins go to A0 and A1
# Wire up 2x LDR. One leg to 3V3 other leg to one end 
# of 10k resistor AND A6 or A7. 
# Other end of 10k resistor goes to GND

while True:
コード例 #41
0
 def __init__(self):
     self.display = lcddriver.lcd()
コード例 #42
0
ファイル: lcd_digits.py プロジェクト: mmmarq/raspberry_lcd
def main():
   #Constant needed by lcd driver
   mRs = 0b00000001
   #Initialize var to check if threads were initialized
   running = False
   #Array to keep thread process
   my_threads = []
   #Global var to make threads exit
   global goodBye

   #Semaphore to control display usage
   lock = threading.Lock()
   #Semaphore to control display usage between run_localdata and run_date
   proc_lock = threading.Lock()

   #Keep it running forever
   while True:
      #Verify whether i2c display can be detected or not
      p1 = Popen(["/usr/sbin/i2cdetect","-y","1"], stdout=PIPE)
      p2 = Popen(["grep", "20:"], stdin=p1.stdout, stdout=PIPE)
      p1.stdout.close()
      output = p2.communicate()[0]
      p2.stdout.close()
      #Keep display i2c address
      devAddr = output.split()[8]

      #If i2c display was found and threads were not running, start them
      if ((devAddr == "27")  and  (not running)):
         print "Starting threads..."

         try:
            #Load LCD driver
            lcd = lcddriver.lcd()
            #Load user-defined graphs
            lcd.lcd_write(0x40)
            for mycells in ['1','2','3','4','5','6','7','8']:
               for cell in cells[mycells]:
                  lcd.lcd_write(cell,mRs)
            #Clear LCD
            lcd.lcd_clear()
         except:
            #If LCD initialization fails, try again in next loop iteration
            time.sleep(1)
            continue

         #Build thread parameters array
         my_thread_args = {}
         my_thread_args["run_clock"] = (lcd,mRs,lock)
         my_thread_args["run_banner"] = (lcd,lock)
         my_thread_args["run_date"] = (lcd,mRs,lock,proc_lock)
         my_thread_args["run_localdata"] = (lcd,mRs,lock,proc_lock)
         #Build array with functions that threads should run
         my_thread_targets = [run_clock,run_banner,run_date,run_localdata]
         #Builds array with initialized (not running) threads
         my_threads = [threading.Thread(target=my_thread_targets[0], args=my_thread_args["run_clock"]),
                       threading.Thread(target=my_thread_targets[1], args=my_thread_args["run_banner"]),
                       threading.Thread(target=my_thread_targets[2], args=my_thread_args["run_date"]),
                       threading.Thread(target=my_thread_targets[3], args=my_thread_args["run_localdata"])]

         #Start threads
         for th in my_threads:
            th.start()

         #Set running as True
         running = True

      #If i2c display was not found and threads are running, kill them
      if ((devAddr != "27") and (running)):
         #Set global var to make threads die
         goodBye = True
         #Wait until all threads die
         while (my_threads[0].isAlive() or my_threads[1].isAlive() or my_threads[2].isAlive() or my_threads[3].isAlive()):
            for th in [0,1,2,3]:
               if (my_threads[th].isAlive()):
                  print "Thread " + my_thread_targets[th].__name__  + " still alive"
            time.sleep(3)
            print ""
         #When all threads dies, set control var and jump to next loop iteration
         print "All tasks killed!!! lets restart..."
         running = False
         goodBye = False
         continue

      #Just wait a while before start next loop iteration
      time.sleep(5)
コード例 #43
0
ファイル: weather.py プロジェクト: fidepus/YAWP
pressure_sensor = BMP085(0x77)
pressure = pressure_sensor.readPressure()
# Altitude correction for pressure at sea level.
psea = pressure / pow(1.0 - altitude/44330.0, 5.255)
psea_dec = psea / 100.0
pressure_relative = decimal.Decimal(psea_dec)
rounded_pressure_relative = pressure_relative.quantize(decimal.Decimal('.01'), rounding=decimal.ROUND_HALF_UP)

# Humidty stuff happens here
humidityr = humidity.get_humidity()

##################################
#   LCD stuff happening here     #
##################################

lcd2 = lcddriver.lcd()

backlight.switch_light()
lcd2.lcd_clear()
lcd2.lcd_display_string(time.strftime("%d.%m.%Y %H:%M"), 1)
lcd2.lcd_display_string('Innen: {0} Grad'.format(Temperature_In), 2)
lcd2.lcd_display_string('Aussen: {0} Grad'.format(Temperature_Out), 3)
lcd2.lcd_display_string(str(Weather_Text) + ' ' + str(humidityr) + '%', 4)
backlight.switch_light()

# Write the data to a webpage on the local server
# Get some weather icons that are compliant with Yahoo condition codes.
# The ones by MerlinTheRed are nice and work well
# <http://merlinthered.deviantart.com/art/plain-weather-icons-157162192> CC-BY-NC-SA
with open('/var/www/aktuell.html','w') as index:
    index.write('<style type="text/css">'
コード例 #44
0
ファイル: lcd_test.py プロジェクト: Woobatron/emonpi
#!/usr/bin/env python

import lcddriver
import time

lcd = lcddriver.lcd(0x27)

lcd.backlight =1
lcd.lcd_display_string("emonPi", 1)
lcd.lcd_display_string("test 123",2)
time.sleep(5)
lcd.lcd_display_string("Backlight off", 1)
lcd.lcd_display_string("in 5 seconds..",2)
time.sleep(5)
lcd.backlight = 0
time.sleep(5)
lcd.backlight =1
lcd.lcd_clear()
lcd.lcd_display_string("Backlight on", 1)
lcd.lcd_display_string("end of test", 2)




コード例 #45
0
ファイル: four20lcd.py プロジェクト: earion/smartHome
 def __init__(self):
   if platform.processor() != 'x86_64':
     self.lcd = lcddriver.lcd()
     self.lcd.lcd_clear()
   else:
     self.lcd = lcd_moc.LcdMoc()
コード例 #46
0
ファイル: demo_lcd.py プロジェクト: fecori/lcd
# Simple string program. Writes and updates strings.
# Demo program for the I2C 16x2 Display from Ryanteck.uk
# Created by Matthew Timmons-Brown for The Raspberry Pi Guy YouTube channel

# Import necessary libraries for commuunication and display use
import lcddriver
import time

# Load the driver and set it to "display"
# If you use something from the driver library use the "display." prefix first
display = lcddriver.lcd()

# Main body of code
try:
    while True:
        # Remember that your sentences can only be 16 characters long!
        print("Writing to display")
        display.lcd_display_string("Greetings Human!", 1) # Write line of text to first line of display
        display.lcd_display_string("Demo Pi Guy code", 2) # Write line of text to second line of display
        time.sleep(2)                                     # Give time for the message to be read
        display.lcd_display_string("I am a display!", 1)  # Refresh the first line of display with a different message
        time.sleep(2)                                     # Give time for the message to be read
        display.lcd_clear()                               # Clear the display of any data
        time.sleep(2)                                     # Give time for the message to be read

except KeyboardInterrupt: # If there is a KeyboardInterrupt (when you press ctrl+c), exit the program and cleanup
    print("Cleaning up!")
    display.lcd_clear()
コード例 #47
0
# INSTRUCTIONS: git clone https://github.com/adafruit/Adafruit_Python_DHT.git
# INSTRUCTIONS: sudo apt-get install build-essential python-dev python-openssl
# INSTRUCTIONS: sudo python setup.py install
# INSTRUCTIONS: FIND DHT11 or DHT22 INFO ONLINE FOR CONNECTING. 10k resister required
#Written by Bradley Gillap 2016

import Adafruit_DHT as dht	#Arguments dht instead of Adafruit_DHT, DHT11 device, GPIO26
import lcddriver
import time

#Assign to variables

pin = 26   					#GPIO pin we are communicating on CHANGE THIS
h,t = dht.read_retry(dht.DHT11, pin)		#Refreshes the DHT sensor. ARG DHT11 or DHT22 sensor
display = lcddriver.lcd()			#Refering to the LCD
temp = 'Temp:{0:0.1f} C'.format(t)		#Store temp string info 
humid = 'Humidity:{1:0.1f}%'.format(t,h)	#Store Humidity info

try:
	while True:
			h,t = dht.read_retry(dht.DHT11, pin)		#Loop the check sensor check DHT11 or DHT22 sensor 
			temp = 'Temp:{0:0.1f} C'.format(t)		#Update variable temperature
			humid = 'Humidity:{1:0.1f}%'.format(t,h)	#Update variable humidity
			display.lcd_clear()				#Clear screen
			display.lcd_display_string(temp, 1)		#write temp to screen
			display.lcd_display_string(humid, 2)		#write humdity to screen
			time.sleep(2)
 
except KeyboardInterrupt: # If there is a KeyboardInterrupt (when you press ctrl+c), exit the program and cleanup
    print("Cleaning up!")
コード例 #48
0
# Name: Krystal, Anna, Ian
# Date: 8/24/2015 
# Description: Traffic and Pedestrian Lights with LCD
#!/user/bin/env python

import RPi.GPIO as GPIO
import time
import lcddriver

lcd = lcddriver.lcd()
lcd.lcd_clear();

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(25, GPIO.OUT)
GPIO.setup(16, GPIO.OUT)
GPIO.setup(24, GPIO.OUT)
GPIO.setup(5, GPIO.OUT)
GPIO.setup(13, GPIO.OUT)
GPIO.setup(12, GPIO.IN, pull_up_down = GPIO.PUD_UP)

def flash():
  GPIO.output(13, False)
  GPIO.output(5, True)
  lcd.lcd_display_string("To Cross 5",2)
  time.sleep(0.5)
  GPIO.output(5, False)
  time.sleep(0.5)
  GPIO.output(5, True)
  lcd.lcd_display_string("To Cross 4",2)
  time.sleep(0.5)
コード例 #49
0
ファイル: emonPiLCD_update.py プロジェクト: Woobatron/emonpi
import sys
import subprocess

# ------------------------------------------------------------------------------------
# Check to see if LCD is connected if not then stop here
# ------------------------------------------------------------------------------------
lcd_i2c = ['27', '3f']
current_lcd_i2c = ''

for i2c_address in lcd_i2c:
  lcd_status = subprocess.check_output(["/home/pi/emonpi/lcd/emonPiLCD_detect.sh", "%s" % i2c_address])
  if lcd_status.rstrip() == 'True':
    print "I2C LCD DETECTED Ox%s" % i2c_address
    current_lcd_i2c = "0x%s" % i2c_address
    break

if lcd_status.rstrip() == 'False':
  print ("I2C LCD NOT DETECTED on either 0x" + str(lcd_i2c) + " ...exiting LCD script")
  sys.exit(1)
  
lcd = lcddriver.lcd(int(current_lcd_i2c, 16))

# ------------------------------------------------------------------------------------
# Display update in progress update
# ------------------------------------------------------------------------------------
lcd.backlight = 1
lcd.lcd_display_string("Updating........", 1)
lcd.lcd_display_string("DO NOT UNPLUG!  ",2)
time.sleep(1)
sys.exit()
コード例 #50
0
def start():
    global lcd
    lcd = lcddriver.lcd()
コード例 #51
0
ファイル: templcdexample.py プロジェクト: majikpig/ubtech
import tempsensor
import lcddriver
import time
import RPi.GPIO as GPIO 
import btnlib as btn


GPIO.setmode(GPIO.BCM)
GPIO.setup(18,GPIO.OUT) #channel 18 turns on the backlight of the LCD

lcd = lcddriver.lcd() #sets up the LCD screen

while btn.isOn(btn.switch): #while the switch is on:
	if btn.isOn(btn.yellow) : #if the yellow button gets pressed
		GPIO.output(18, True) #turns on the backlight
		temp = -700
		humid = -700
		tempsensor.print_temp()
		temp = tempsensor.tempF()
		humid = tempsensor.humid()
		if temp > -700 :
			lcd.lcd_display_string("Temperature: %d F" % temp,1)
		if humid > -700 :
			lcd.lcd_display_string("Humidity: %d %%" % humid,2)
		time.sleep(5)
		GPIO.output(18, False) #turns off the backlight after 5 secs
	time.sleep(0.1)

lcd.lcd_clear()
GPIO.cleanup()
コード例 #52
0
    return socket.inet_ntoa(fcntl.ioctl(
        s.fileno(),
        0x8915,  # SIOCGIFADDR
        struct.pack('256s', ifname[:15])
    )[20:24])

#Initialize Hostname Check
socket.gethostbyname(socket.gethostname())

#VARIABLES
# If you use something from the driver library use the "display." prefix first
pin = 26												#GPIO pin we are communicating on CHANGE THIS
h,t = dht.read_retry(dht.DHT11, pin)					#Refreshes the DHT sensor. ARG DHT11 or DHT22 sensor
temp =  'Temp : {0:0.1f}C'.format(t)						#Store temp string info 
humid = 'Humid: {1:0.1f}%'.format(t,h)				#Store Humidity info
display = lcddriver.lcd()                               #Load lcddriver and set it to display
ipaddy = get_ip_address('eth0')                         #Define Ip address variable
url = ("http://" + str(ipaddy) + "/admin/api.php")     #Connect to pihole API

#INIT FUNCTIONS KILLING KITTENS
def pihole_hit():								#Function to poll the API for pihole.					
	global data
	global blocked
	global percent
	global queries
	global domains
	data = json.load(urllib2.urlopen(url))		#Store pihole api data.
	blocked = data['ads_blocked_today']
	percent = data['ads_percentage_today']
	queries = data['dns_queries_today']
	domains = data['domains_being_blocked']