Exemplo n.º 1
0
def main():
    lcd.init()
    lcd.set_contrast(190)
    lcd.backlight(1)
    lcd.text("adresses:")
    ip = subprocess.check_output("hostname -I", shell=True)
    lcd.locate(0,1)
    lcd.text(str(ip.strip()) )
Exemplo n.º 2
0
 def update_display(self):
     ip_addr = ni.ifaddresses('eth0')[ni.AF_INET][0]['addr']
     now = time()
     if now < self.display_expiry:
         im = Image.new('1', (84, 48))
         draw = ImageDraw.Draw(im)
         draw.text((0, 5), self.latest_raw_val, font=disp_font, fill=1)
         draw.text((0, 0), ip_addr, font=disp_font_sm, fill=1)
         draw.text((5, 36), "mm to surface", font=disp_font_sm, fill=1)
         lcd.show_image(im)
         # clean up
         del draw
         del im
         lcd.set_contrast(disp_contrast_on)
     else:
         lcd.set_contrast(disp_contrast_off)
         lcd.cls()
Exemplo n.º 3
0
		 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x60, 0x60, 0xE3, 0xC7, 0xC3, 0xC7, 0xC3,
		 0xC3, 0x83, 0x83, 0x83, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x70,
		 0xF1, 0xF1, 0xF3, 0xF3, 0xF3, 0xF7, 0xE7, 0xE7, 0xE7, 0xC7, 0xC7, 0x06, 0x06, 0x00, 0x00, 0x00,
		 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		 0x00, 0x00, 0x00, 0xCC, 0xDC, 0xDE, 0xBE, 0xFE, 0xBF, 0xFF, 0x9F, 0xBF, 0xBD, 0xBD, 0x9D, 0x88,
		 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		 0x00, 0x00, 0x00, 0x38, 0x30, 0x70, 0x70, 0x72, 0x72, 0xEA, 0x77, 0xF3, 0xE3, 0xF3, 0xE3, 0xF3,
		 0x63, 0xF1, 0x61, 0x70, 0x60, 0x70, 0x20, 0x30, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
		]

def demo():
	lcd.locate(0,0)
	lcd.data(logo)
if __name__ == "__main__":
	lcd.init()
	lcd.backlight(0)
	lcd.set_contrast(190)
	demo()
Exemplo n.º 4
0
if __name__ == "__main__":
    event_router = SockJSRouter(EventConnection, '/event')
    handlers = [
        (r'/', MainPageHandler),
        (r'/logger/(.*)', LogDownloadHandler),  # arg is log interval
        (r'/valve', ValveHandler)
    ]
    handlers += event_router.urls
    tornado_settings = {
        'static_path': 'static',
        'template_path': 'templates',
        'debug': True
    }
    lcd.init()
    lcd.gotoxy(0, 0)
    lcd.set_contrast(disp_contrast_on)
    lcd.cls()
    lcd.text("LCD Init")
    wiringpi.pinMode(BTN_OUT, 1)
    wiringpi.digitalWrite(BTN_OUT, 1)
    wiringpi.pinMode(VALVE_GPIO, 1)
    wiringpi.digitalWrite(VALVE_GPIO, 0)
    wiringpi.pinMode(BTN_IN, 0)

    app = TankMonitor(handlers, **tornado_settings)
    maxbotix = MaxbotixHandler(tank_monitor=app, port='/dev/ttyAMA0', timeout=10)
    maxbotix.calibrate(appconfig.MAXBOTICS['calibrate_m'],
                       appconfig.MAXBOTICS['calibrate_b'])
    ioloop = IOLoop.instance()
    disp_print_cb = PeriodicCallback(app.update_display, callback_time=500, io_loop=ioloop)
    disp_print_cb.start()
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
]


def demo():
    lcd.locate(0, 0)
    lcd.data(logo)


if __name__ == "__main__":
    lcd.init()
    lcd.backlight(1)
    lcd.set_contrast(190)
    demo()
Exemplo n.º 6
0
#!/usr/bin/python
import pcd8544.lcd as lcd
import time, sys, os, subprocess
from datetime import datetime

# optional load of drivers if not listed in /etc/modules
#os.system('modprobe w1-gpio')
#os.system('modprobe w1-therm')

#Initiate LCD
lcd.init()
# Turn backlight on/off. The number corrensponds to backlight
# brightness, 0 being light off, 10 being the brightest.
lcd.backlight(5)
lcd.set_contrast(512)
# Prepare degrees celsius symbol
lcd.define_custom_char([0x00, 0x07, 0x05, 0x07, 0x00])


def get_temp(file):
    # The '28-xxx' in the file name should be changed accordingly
    # to name in your /sys/bus/w1/devices folder.
    file = "/sys/bus/w1/devices/28-000004e4b880/w1_slave"
    # Open file written to by temp sensor
    tfile = open(file)
    # Read all text in file
    text = tfile.read()
    # Close file once text is read
    tfile.close()
    # Pull out the temperature value
Exemplo n.º 7
0
 def contrastup(self):
   self.contrast +=1
   lcd.set_contrast(self.contrast)
Exemplo n.º 8
0
#!/usr/bin/python
import pcd8544.lcd as lcd
import time, sys ,os, subprocess
from datetime import datetime

    # optional load of drivers if not listed in /etc/modules
#os.system('modprobe w1-gpio')
#os.system('modprobe w1-therm')

    #Initiate LCD
lcd.init()
        # Turn backlight on/off. The number corrensponds to backlight
        # brightness, 0 being light off, 10 being the brightest.
lcd.backlight(5)
lcd.set_contrast(512)
        # Prepare degrees celsius symbol
lcd.define_custom_char([0x00, 0x07, 0x05, 0x07, 0x00])

def get_temp(file):
        # The '28-xxx' in the file name should be changed accordingly 
        # to name in your /sys/bus/w1/devices folder.
    file = "/sys/bus/w1/devices/28-000004e4b880/w1_slave"
        # Open file written to by temp sensor
    tfile = open(file)
        # Read all text in file
    text = tfile.read()
        # Close file once text is read
    tfile.close()
        # Pull out the temperature value
    temprdata = text.split("\n")[1].split(" ")[9]
Exemplo n.º 9
0
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,   # 0x01B0 (432) pixels
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,   # 0x01C0 (448) pixels
 0x03, 0x03, 0x07, 0x07, 0x0F, 0x1F, 0x1F, 0x3F, 0x3B, 0x71, 0x60, 0x60, 0x60, 0x60, 0x60, 0x71,   # 0x01D0 (464) pixels
 0x3B, 0x1F, 0x0F, 0x0F, 0x0F, 0x07, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,   # 0x01E0 (480) pixels
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,   # 0x01F0 (496) pixels
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
 ]
     # Initiate LCD
 lcd.init()
     # Turn slowly backlight on. To switch backlight off change the below
     # for loop for lcd.backlight(0)
 for i in range(0,1000,16):
     lcd.set_brightness(i)
     time.sleep(0.025)
     # Set specific contrast
 lcd.set_contrast(256)
     # Display Raspberry logo
 lcd.cls()
 lcd.gotorc(0,0)
 for x in logo:
     lcd.lcd_data(x)
 time.sleep(2)
 lcd.cls()
     # Display welcome note
 lcd.define_custom_char([0x19, 0x25, 0x5A, 0x25, 0x19])
 lcd.gotorc(0,0)
 lcd.text("\x7f \x7f \x7f \x7f \x7f \x7f \x7f ")
 lcd.centre_text(2,"Welcome")
 lcd.centre_text(3,"Bubbl")
 lcd.gotorc(5,0)
 lcd.text("\x7f \x7f \x7f \x7f \x7f \x7f \x7f ")
Exemplo n.º 10
0
    pid=str(os.getpid())
    if os.path.isfile(PIDFILE):
        print "%s already exists, exiting" % PIDFILE
        sys.exit()
    else:
        file(PIDFILE, 'w').write(pid)
        signal.signal(signal.SIGINT,INTHandler)
        signal.signal(signal.SIGTERM,INTHandler)

    parseConf(CONF_FILE)

    Log('Starting')

    lcd.init()
    Log('Setting contrast to '+CONF['LCD_CONTRAST'])
    lcd.set_contrast(int(CONF['LCD_CONTRAST']))
    client=etcd.Client(port=int(CONF['ETCD_PORT']))
    aToDisplay={}
    while True:
        aStatus=parseEtcd(client)
        sFrom=aStatus[0]
        sWhat=aStatus[1]
        sValue=aStatus[2]
        if sFrom == 'Wifite':
            aToDisplay=status_wifite(sWhat,sValue)
        if sFrom=='cfs':
            aToDisplay=status_cfs(sWhat,sValue)
        if sFrom=='run-at-boot':
            aToDisplay=status_rab(sWhat,sValue)

        display(aToDisplay)
Exemplo n.º 11
0
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
]


def demo():
    lcd.locate(0, 0)
    lcd.data(logo)


if __name__ == "__main__":
    lcd.init()
    lcd.set_contrast(180)
    demo()
Exemplo n.º 12
0
     0x00,
     0x00,
     0x00,
     0x00,
     0x00,
     0x00
 ]
 # Initiate LCD
 lcd.init()
 # Turn slowly backlight on. To switch backlight off change the below
 # for loop for lcd.backlight(0)
 for i in range(0, 1000, 16):
     lcd.set_brightness(i)
     time.sleep(0.025)
     # Set specific contrast
 lcd.set_contrast(256)
 # Display Raspberry logo
 lcd.cls()
 lcd.gotorc(0, 0)
 for x in logo:
     lcd.lcd_data(x)
 time.sleep(2)
 lcd.cls()
 # Display welcome note
 lcd.define_custom_char([0x19, 0x25, 0x5A, 0x25, 0x19])
 lcd.gotorc(0, 0)
 lcd.text("\x7f \x7f \x7f \x7f \x7f \x7f \x7f ")
 lcd.centre_text(2, "Welcome")
 lcd.centre_text(3, "Bubbl")
 lcd.gotorc(5, 0)
 lcd.text("\x7f \x7f \x7f \x7f \x7f \x7f \x7f ")
Exemplo n.º 13
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pcd8544.lcd as lcd
import time, os, sys

if not os.geteuid() == 0:
    sys.exit('Script must be run as root')

ON, OFF = [1, 0]

try:
  lcd.init()
  lcd.cls()
  lcd.backlight(ON)
  lcd.centre_text(2,"contrast")
  for i in range(150,200,5):
      lcd.set_contrast(i)
      lcd.centre_text(3,"%d" % i)
      time.sleep(1)
  for i in range(200,150,-5):
      lcd.set_contrast(i)
      lcd.centre_text(3,"%d" % i)
      time.sleep(1)
except KeyboardInterrupt:
  pass
finally:
  lcd.cls()
  lcd.backlight(OFF)

Exemplo n.º 14
0
#!/usr/bin/env python

import pcd8544.lcd as lcd
import sys

backlight={'ON':0,'OFF':1}

if __name__ == "__main__":
    lcd.init()
    lcd.set_contrast(180)
    if sys.argv[1] == 'text':
        lcd.locate(int(sys.argv[2]),int(sys.argv[3]))
        lcd.text(sys.argv[4])
    if sys.argv[1] == 'backlight':
        lcd.backlight(backlight[sys.argv[2].upper()])
    if sys.argv[1] == 'cls':
        lcd.cls()
Exemplo n.º 15
0
import pcd8544.lcd as lcd
import time, os, sys, commands
import Adafruit_BMP.BMP085 as BMP085								
sensor = BMP085.BMP085()								
if not os.geteuid() == 0:
    sys.exit('Script must be run as root')

ON, OFF = [1, 0]

try:
  lcd.init()
  lcd.cls()
  lcd.backlight(ON)

  lcd.set_contrast(185)

  while 1:
    lcd.centre_text(0,commands.getoutput("hostname"))
    lcd.centre_text(1,commands.getoutput("hostname -I"))
    lcd.centre_text(3,time.strftime("%d %b %Y", time.localtime()))
    lcd.centre_text(4,time.strftime(" %H:%M:%S ", time.localtime()))
    lcd.centre_text(5, "   ")
    temp = '{0:0.2f} *C'.format(sensor.read_temperature())								
    lcd.centre_text(6, temp)
    ii=0
    while ii<4*60:
      lcd.centre_text(3,time.strftime("%d %b %Y", time.localtime()))
      lcd.centre_text(4,time.strftime(" %H:%M:%S ", time.localtime()))
      ii=ii+1
      time.sleep(0.25)
Exemplo n.º 16
0
    pid = str(os.getpid())
    if os.path.isfile(PIDFILE):
        print "%s already exists, exiting" % PIDFILE
        sys.exit()
    else:
        file(PIDFILE, 'w').write(pid)
        signal.signal(signal.SIGINT, INTHandler)
        signal.signal(signal.SIGTERM, INTHandler)

    parseConf(CONF_FILE)

    Log('Starting')

    lcd.init()
    Log('Setting contrast to ' + CONF['LCD_CONTRAST'])
    lcd.set_contrast(int(CONF['LCD_CONTRAST']))
    client = etcd.Client(port=int(CONF['ETCD_PORT']))
    aToDisplay = {}
    while True:
        aStatus = parseEtcd(client)
        sFrom = aStatus[0]
        sWhat = aStatus[1]
        sValue = aStatus[2]
        if sFrom == 'Wifite':
            aToDisplay = status_wifite(sWhat, sValue)
        if sFrom == 'cfs':
            aToDisplay = status_cfs(sWhat, sValue)
        if sFrom == 'run-at-boot':
            aToDisplay = status_rab(sWhat, sValue)

        display(aToDisplay)
Exemplo n.º 17
0
    MSL = "%07.2f" % float(msl(float(press)))
    press = "%07.2f" % float(press)
    if press[0] == "0": digit_0 = " "
    else: digit_0 = press[0]
    
    lcd.locate(1,3)
    lcd.text("QFE:"+digit_0+press[1:6])

    if MSL[0] == "0": digit_0 = " "
    else: digit_0 = MSL[0]

    lcd.locate(1,4)
    lcd.text("QNH:"+digit_0+MSL[1:6])

lcd.init()
lcd.set_contrast(29)
lcd.backlight(1)

# Prime the variables in case the database is unavailable
l_date = "0000-00-00 00:00:00"
l_temp = "99.9"
l_press = "9999.99"
l_msl = "9999.99"

while True:
  endTime = datetime.datetime.now()
  sqlEnd = endTime.strftime('%Y-%m-%d %H:%M:59')
  startTime = datetime.datetime.now() - datetime.timedelta(seconds=150)
  sqlStart = startTime.strftime('%Y-%m-%d %H:%M:00')
  row = None
  sensorData = sql.connect('/shared/bmp180/sensordata.db')
Exemplo n.º 18
0
#		GPIO.setmode(GPIO.BCM) 
#		GPIO.setup(25, GPIO.IN, pull_up_down = GPIO.PUD_UP)  
	#	GPIO.setup(22, GPIO.IN, pull_up_down = GPIO.PUD_UP)  
#		GPIO.add_event_detect(25, GPIO.FALLING, callback = Int_shutdown, bouncetime = 2000)
	#	GPIO.add_event_detect(22, GPIO.RISING, callback = Int_shutdown2, bouncetime = 1000)
		RPIO.add_interrupt_callback(22, Int_shutdown2, edge='rising', debounce_timeout_ms=1000)
		RPIO.add_interrupt_callback(25, Int_shutdown, edge='rising', debounce_timeout_ms=1000)
		RPIO.wait_for_interrupts(threaded=True)
	except Exception,e:
		print 'Error al iniciar botones'
		print e
	try:
		print 'Iniciando LCD'
		lcd.init()
		lcd.cls()
		lcd.set_contrast(250)
		lcd.backlight(OFF)
	except:
		print 'Error al iniciar LCD'

	lcd.centre_text(0,"Verificando Internet...")
	print "Verificando Internet"
	if internet_on():
		lcd.cls()
		lcd.centre_text(0,"Bajando Registro de nombres...")
		print "Bajando registro de nombres"
		try:
			dowloadNombreTarjeta()
		except:
			print "No se pudo bajar registro"
	else:
Exemplo n.º 19
0
Arquivo: b.py Projeto: azat385/rpiplc
     i=0
     q=[]
     while i<len(j):
         #print i,j[i],ord(j[i]),hex(ord(j[i]))
         if ord(j[i])>127:
             q.append(j[i:i+2])
             i=i+2
         else:
             q.append(j[i])
             i+=1
     return q;

try:
  lcd.init()
  lcd.cls()
  lcd.set_contrast(155)
  lcd.backlight(ON)
  LastTime=0
  invert_arr=[0,0,0,0,0,0]
  i_int=-1
  while 1:
     if time.time()-LastTime > 3 :
    	 mycpu=" CPU: "+(str(psutil.cpu_percent(0))).rjust(5,' ')+"%  "
	 LastTime=time.time()
	 i_int+=1
	 if i_int>5: i_int=0
	 for i in range(0,len(invert_arr)):
		if i==i_int: invert_arr[i]=1
		else: invert_arr[i]=0
     lcd.gotorc(0,0)
     lcd.text(" 0.RPI PLC    ",invert=invert_arr[0])
Exemplo n.º 20
0
 def contrastdown(self):
   self.contrast -=1
   lcd.set_contrast(self.contrast)
Exemplo n.º 21
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pcd8544.lcd as lcd
import time, os, sys

if not os.geteuid() == 0:
    sys.exit('Script must be run as root')

ON, OFF = [1, 0]

try:
    lcd.init()
    lcd.cls()
    lcd.backlight(ON)
    lcd.centre_text(2, "contrast")
    for i in range(150, 200, 5):
        lcd.set_contrast(i)
        lcd.centre_text(3, "%d" % i)
        time.sleep(1)
    for i in range(200, 150, -5):
        lcd.set_contrast(i)
        lcd.centre_text(3, "%d" % i)
        time.sleep(1)
except KeyboardInterrupt:
    pass
finally:
    lcd.cls()
    lcd.backlight(OFF)