Beispiel #1
0
def ScreenOutput(TopLine, BottomLine):

    wiringpi2.lcdClear(lcdHandle)
    wiringpi2.lcdPosition(lcdHandle, lcdCol, lcdRow)
    wiringpi2.lcdPrintf(lcdHandle, TopLine)
    wiringpi2.lcdPosition(lcdHandle, lcdCol, lcdRow + 1)
    wiringpi2.lcdPrintf(lcdHandle, BottomLine)
Beispiel #2
0
def lcdloop():
    """LCD display handler"""
    while(1):
        wiringpi.lcdHome(LCD_HANDLE)
        IO.delay(2)
        LCD_LOCK.acquire()
        try:
            lcd_one = LCD_ONE
            lcd_two = LCD_TWO
        finally:
            LCD_LOCK.release()

        # Only printable chars, no tabs nor newlines
        lcd_one = filter( lambda x: 32 <= ord(x) <= 126, lcd_one)
        lcd_two = filter( lambda x: 32 <= ord(x) <= 126, lcd_two)

        line_one = lcd_one[0:16]
        line_two = lcd_two[0:16]

        wiringpi.lcdPosition (LCD_HANDLE, 0, 0)
        IO.delay(2)
        wiringpi.lcdPuts(LCD_HANDLE, line_one.ljust(16))
        IO.delay(2)
        wiringpi.lcdPosition (LCD_HANDLE, 0, 1)
        IO.delay(2)
        wiringpi.lcdPuts(LCD_HANDLE, line_two.ljust(16))
        time.sleep(5)
def processSensor(dataIn):
    officeData = json.loads(dataIn)

    wiringpi.lcdPosition(display, 0, 0)
    now = datetime.datetime.now().strftime("%m/%d/%y %I:%M%p")
    wiringpi.lcdPuts(display, now)
    if 'temperatureF' in officeData:
        out = "%2dF" % (officeData['temperatureF'])
        wiringpi.lcdPosition(display, 0, 1)
        wiringpi.lcdPuts(display, out)
    else:
        print "Temp missing"
        pp = pprint.PrettyPrinter(indent=4)
        pp.pprint(officeData)

    if 'pressure' in officeData:
        out = "%4dMb" % (officeData['pressure'])
        wiringpi.lcdPosition(display, 4, 1)
        wiringpi.lcdPuts(display, out)
    else:
        print "Pressure missing"
        pp = pprint.PrettyPrinter(indent=4)
        pp.pprint(officeData)

    if 'lux' in officeData:
        wiringpi.lcdPosition(display, 11, 1)
        out = "%3dLx" % (officeData['lux'])
        wiringpi.lcdPuts(display, out)
    else:
        print "lux missing"
        pp = pprint.PrettyPrinter(indent=4)
        pp.pprint(officeData)
Beispiel #4
0
    def write(self, lcd_one, lcd_two):
        """Write to the display Only printable chars, no tabs nor newlines"""
        lcd_one = filter(lambda x: 32 <= ord(x) <= 126, lcd_one)
        lcd_two = filter(lambda x: 32 <= ord(x) <= 126, lcd_two)

        line_one = lcd_one[0:self.chars]
        line_two = lcd_two[0:self.chars]

        wiringpi.lcdPosition(self.lcd, 0, 0)
        self.io.delay(2)
        wiringpi.lcdPuts(self.lcd, line_one.ljust(self.chars))
        self.io.delay(2)
        wiringpi.lcdPosition(self.lcd, 0, 1)
        self.io.delay(2)
        wiringpi.lcdPuts(self.lcd, line_two.ljust(self.chars))
Beispiel #5
0
    def write(self, lcd_one, lcd_two):
        """Write to the display Only printable chars, no tabs nor newlines"""
        lcd_one = filter( lambda x: 32 <= ord(x) <= 126, lcd_one)
        lcd_two = filter( lambda x: 32 <= ord(x) <= 126, lcd_two)

        line_one = lcd_one[0:self.chars]
        line_two = lcd_two[0:self.chars]

        wiringpi.lcdPosition (self.lcd, 0, 0)
        self.io.delay(2)
        wiringpi.lcdPuts(self.lcd, line_one.ljust(self.chars))
        self.io.delay(2)
        wiringpi.lcdPosition (self.lcd, 0, 1)
        self.io.delay(2)
        wiringpi.lcdPuts(self.lcd, line_two.ljust(self.chars))
def showSensors():
    global lcdFD
    global datas

    while True:
        threadLock.acquire()
        lst = datas
        threadLock.release()
        for x in xrange(0, len(lst)):
            wiringpi.lcdClear(lcdFD)
            data1 = lst[x]
            wiringpi.lcdPosition(lcdFD, 0, 0)
            wiringpi.lcdPrintf(lcdFD, "%s:" % (data1["name"]))
            wiringpi.lcdPosition(lcdFD, 0, 1)
            wiringpi.lcdPrintf(lcdFD, "%s%s" % (data1["data"], data1["symbol"]))
            time.sleep(5)
Beispiel #7
0
def showSensors():
    global lcdFD
    global datas

    while True:
        threadLock.acquire()
        lst = datas
        threadLock.release()
        for x in xrange(0, len(lst)):
            wiringpi.lcdClear(lcdFD)
            data1 = lst[x]
            wiringpi.lcdPosition(lcdFD, 0,0)
            wiringpi.lcdPrintf(lcdFD,"%s:"%(data1["name"]))
            wiringpi.lcdPosition(lcdFD, 0,1)
            wiringpi.lcdPrintf(lcdFD,"%s%s"%(data1["data"],data1["symbol"]))
            time.sleep(5)
Beispiel #8
0
def lcdloop():
    """LCD display handler"""
    depeche = 0
    while(1):
        wiringpi.lcdHome(LCD_HANDLE)
        IO.delay(2)
        LCD_LOCK.acquire()
        try:
            key = LCD_ROTATOR.keys()[depeche]
            if len(LCD_ROTATOR[key]): 
              lcd_one = LCD_ROTATOR[key][0]
            if len(LCD_ROTATOR[key]) > 1:
              lcd_two = LCD_ROTATOR[key][1]
            else:
              lcd_two = ""

            depeche = (depeche + 1) % len(LCD_ROTATOR)
        except TypeError:
          pass
        finally:
            LCD_LOCK.release()

        # Only printable chars, no tabs nor newlines
        lcd_one = filter( lambda x: 32 <= ord(x) <= 126, lcd_one)
        lcd_two = filter( lambda x: 32 <= ord(x) <= 126, lcd_two)

        line_one = lcd_one[0:16]
        line_two = lcd_two[0:16]

        wiringpi.lcdPosition (LCD_HANDLE, 0, 0)
        IO.delay(2)
        wiringpi.lcdPuts(LCD_HANDLE, line_one.ljust(16))
        IO.delay(2)
        wiringpi.lcdPosition (LCD_HANDLE, 0, 1)
        IO.delay(2)
        wiringpi.lcdPuts(LCD_HANDLE, line_two.ljust(16))
        time.sleep(5)
Beispiel #9
0
def printLCD(line0="", line1=""):
    wiringpi2.lcdPosition(lcd, 0, 0)
    wiringpi2.lcdPrintf(lcd, line0 + BNK)
    wiringpi2.lcdPosition(lcd, 0, 1)
    wiringpi2.lcdPrintf(lcd, line1 + BNK)
Beispiel #10
0
    wiringpi.digitalWrite(E, OFF)
    wiringpi.digitalWrite(F, OFF)
    wiringpi.digitalWrite(G, OFF)
    wiringpi.digitalWrite(H, OFF)
    wiringpi.digitalWrite(ONE, OFF)
    wiringpi.digitalWrite(TWO, OFF)
    wiringpi.digitalWrite(THR, OFF)
    wiringpi.digitalWrite(FOU, OFF)
    wiringpi.digitalWrite(FIV, OFF)
    wiringpi.digitalWrite(SIX, OFF)
    wiringpi.digitalWrite(SEV, OFF)
    wiringpi.digitalWrite(EIG, OFF)
    wiringpi.digitalWrite(WHI, OFF)
    wiringpi.digitalWrite(BLA, OFF)


# LCD_RS = 83
# LCD_EN  = 84
# LCD_D4 = 85
# LCD_D5 = 86
# LCD_D6 = 87
# LCD_D7 = 88

lcd = wiringpi.lcdInit(2, 16, 4, LCD_RS, LCD_EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7, 0, 0, 0, 0)
wiringpi.lcdHome(lcd)
wiringpi.lcdClear(lcd)
wiringpi.lcdPosition(lcd, 0, 0)
wiringpi.lcdPuts(lcd, "oh yeah!")
wiringpi.lcdPosition(lcd, 0, 1)
wiringpi.lcdPuts(lcd, "it works!")
Beispiel #11
0
 
 # stop it trashing the CPU
 time.sleep(0.1)
 
 elapsed_time = 0
 if GPIO.event_detected(buttonPin):
     start_time = time.time()
     
     while (GPIO.input(buttonPin)):
         time.sleep(0.2)
         elapsed_time = time.time() - start_time
         if (elapsed_time > shutdown):
             logging.info('Shutting down... (Elapsed time: ' + str(elapsed_time)[:4] + ')')
             os.system("kill $(pgrep -f RPizeBox.py)")
             wp.lcdClear(lcd)
             wp.lcdPosition(lcd, 0, 0)
             wp.lcdPuts(lcd,shutdownMessage[0][:16])
             wp.lcdPosition(lcd, 0, 1)
             wp.lcdPuts(lcd,shutdownMessage[1][:16]) 
             os.system("shutdown -h now +1")
             break
     
     #ignore knocks but reboot if proper press
     if (elapsed_time > accidental and elapsed_time <= shutdown):
         logging.info('Rebooting... (Elapsed time: ' + str(elapsed_time)[:4] + ")")
         os.system("kill $(pgrep -f RPizeBox.py)")
         wp.lcdClear(lcd)
         wp.lcdPosition(lcd, 0, 0)
         wp.lcdPuts(lcd,rebootMessage[0][:16])
         wp.lcdPosition(lcd, 0, 1)
         wp.lcdPuts(lcd,rebootMessage[1][:16])  
Beispiel #12
0
######################### reset/reboot button #########################
# Best used in another script since it takes 30s to initialise
# 
os.chdir(os.path.dirname(os.path.realpath(__file__)))
os.system("python buttonWatch.py &")



########################### 16 x 2 display ############################
# set up the 16x2 display - 4 bit to save pins - apparently slower but marginal
# https://projects.drogon.net/raspberry-pi/wiringpi/lcd-library/
wp.wiringPiSetup();
lcd = wp.lcdInit (2, 16, 4,  11,10 , 0,1,2,3,0,0,0,0)
wp.lcdClear(lcd)		    # clear the lcd
wp.lcdPosition(lcd, 0, 0)	# cursor to start of row

################################# LMS ################################    
# connect to the LMS
sc = Server(hostname=getExternalIP("eth0"), port=RPizeBox.scPort, username=RPizeBox.scUser, password=RPizeBox.scPassword)
    
# log in to the LMS server - can't do much until that has happened.
while RPizeBox.loggedin != True:
    try:
        sc.connect()    #throws ugly error if LMS not there
        RPizeBox.loggedin = sc.logged_in
        logging.debug('Success: Logged in to LMS.')
    except:
        logging.debug('LMS not there.  Trying again in %i seconds.' % RPizeBox.logInWait)
        wp.lcdPosition(lcd, 0, 0)
        wp.lcdPuts(lcd,welcomeMessage[0][:16])
Beispiel #13
0
        # stop it trashing the CPU
        time.sleep(0.1)

        elapsed_time = 0
        if GPIO.event_detected(buttonPin):
            start_time = time.time()

            while (GPIO.input(buttonPin)):
                time.sleep(0.2)
                elapsed_time = time.time() - start_time
                if (elapsed_time > shutdown):
                    logging.info('Shutting down... (Elapsed time: ' +
                                 str(elapsed_time)[:4] + ')')
                    os.system("kill $(pgrep -f RPizeBox.py)")
                    wp.lcdClear(lcd)
                    wp.lcdPosition(lcd, 0, 0)
                    wp.lcdPuts(lcd, shutdownMessage[0][:16])
                    wp.lcdPosition(lcd, 0, 1)
                    wp.lcdPuts(lcd, shutdownMessage[1][:16])
                    os.system("shutdown -h now +1")
                    break

            #ignore knocks but reboot if proper press
            if (elapsed_time > accidental and elapsed_time <= shutdown):
                logging.info('Rebooting... (Elapsed time: ' +
                             str(elapsed_time)[:4] + ")")
                os.system("kill $(pgrep -f RPizeBox.py)")
                wp.lcdClear(lcd)
                wp.lcdPosition(lcd, 0, 0)
                wp.lcdPuts(lcd, rebootMessage[0][:16])
                wp.lcdPosition(lcd, 0, 1)
Beispiel #14
0
def lcd_update(string, row):
	string = string[0:16]
	string = string.ljust(16)
        wiringpi2.lcdPosition(lcdHandle, lcdCol, lcdRow + row)
	wiringpi2.lcdPuts(lcdHandle, string)
Beispiel #15
0
def draw_lcd(lcd_line1, lcd_line2):
    wiringpi2.lcdClear(lcdHandle)
    wiringpi2.lcdPosition(lcdHandle, lcdCol, lcdRow)
    wiringpi2.lcdPrintf(lcdHandle, lcd_line1[:LCD_COL])
    wiringpi2.lcdPosition(lcdHandle, lcdCol, lcdRow + 1)
    wiringpi2.lcdPrintf(lcdHandle, lcd_line2[:LCD_COL])
Beispiel #16
0
 def printlcd(self):
     if conf.lcdput.empty() == True:
         strstatus = ['off' for i in range(len(self.valve_ob))]
         for r in range(len(self.valve_ob)):
             if int(self.valve_ob[r].read('valve')) == 1:
                 strstatus[r] = 'on '
             else:
                 strstatus[r] = 'off'
         stringLCD0 = ''.join(['1-', strstatus[0], ' 2-', strstatus[1]])
         stringLCD1 = ''.join(['3-', strstatus[2], ' 4-', strstatus[3]])
         stringLCD2 = ''
         stringLCD3 = datetime.now().strftime('%H:%M:%S %d-%m')
         if (tm.time() - self.timeclear) > 10:
             wpi.lcdHome(self.lcd_ob)
             tm.sleep(0.005)
             wpi.lcdClear(self.lcd_ob)
             tm.sleep(0.005)
             self.timeclear = tm.time()
             # conf.lcd = wpi.lcdInit(
             #     4, 16, 4,
             #     conf.RS, conf.E, conf.DB4, conf.DB5, conf.DB6, conf.DB7,
             #     0,0,0,0
             #     )
             # self.lcd_ob = conf.lcd
         wpi.lcdPosition(self.lcd_ob, 0, 0)
         tm.sleep(0.005)
         wpi.lcdPuts(self.lcd_ob, stringLCD0)
         tm.sleep(0.005)
         wpi.lcdPosition(self.lcd_ob, 0, 1)
         tm.sleep(0.005)
         wpi.lcdPuts(self.lcd_ob, stringLCD1)
         tm.sleep(0.005)
         wpi.lcdPosition(self.lcd_ob, -4, 2)
         tm.sleep(0.005)
         wpi.lcdPuts(self.lcd_ob, stringLCD2)
         tm.sleep(0.005)
         wpi.lcdPosition(self.lcd_ob, -4, 3)
         tm.sleep(0.005)
         wpi.lcdPuts(self.lcd_ob, stringLCD3)
         tm.sleep(0.005)
     elif conf.lcdput.get() == 'restart':
         wpi.lcdHome(self.lcd_ob)
         tm.sleep(0.005)
         wpi.lcdClear(self.lcd_ob)
         tm.sleep(0.005)
         wpi.lcdPosition(self.lcd_ob, 0, 0)
         tm.sleep(0.005)
         wpi.lcdPuts(self.lcd_ob, 'RIAVVIO')
         tm.sleep(0.005)
         wpi.lcdPosition(self.lcd_ob, 0, 1)
         while True:
             wpi.lcdPuts(self.lcd_ob, '*')
             tm.sleep(0.5)
     else:
         pass