Exemple #1
0
def main():

	HOME = os.path.dirname(os.path.realpath(__file__))
	f = file(HOME+'/sensors.cfg')
	CFG = Config(f)
	logging.basicConfig(filename=HOME+'/sensors.log', level=logging.INFO, format='%(asctime)s %(message)s', datefmt='%Y-%m-%d %H:%M')

	tz = pytz.timezone(CFG.timezone)
	date = datetime.now(tz)

	GPIO.setwarnings(False)
	m = date.strftime("%Y-%m-%d\n%H:%M:%S")
	lcd.init()
	lcd.message(m)

	if date.hour >= 0 and date.hour <= 5:
		lcd.backlight(False)
	else:
		lcd.backlight(True)

	d = [] # read sensor data
	for s in CFG.sensors:

		if s.id < 0: continue # skip disabled sensors

		try:
			if s.name == 'DS18B20':
				v = w1.readTemp(s.rom_code)
			elif s.name == 'DHT22' and s.rom_code == 'H':
				v = dht.readHumidity()
			elif s.name == 'DHT22' and s.rom_code == 'T':
				v = dht.readTemperature()
			else:
				raise Exception('unknown sensor name')
				continue
		except Exception as e:
			logging.error("| Can't read sensor %d | %s | %s" % (s.id, s.rom_code, str(e)))
			continue

		try:
			db.updateSensor(s.id, v, date)
			if(s.type == 'H'):
				d.append('%d%%' % v)
			else:
				d.append(v)
#			print "#%d %s, %s: %.1f" % (s.id, s.rom_code, s.label, v)
		except Exception as e:
			logging.error("| Can't update sensor %d | %s | %s" % (s.id, s.rom_code, str(e)))
			continue

	m = buildMessage(d, date)	
	lcd.message(m)
Exemple #2
0
def main():

	HOME = os.path.dirname(os.path.realpath(__file__))
	f = file(HOME+'/sensors.cfg')
	CFG = Config(f)

	tz = pytz.timezone(CFG.timezone)
	date = datetime.now(tz)

	GPIO.setwarnings(False)
	lcd.init()
	lcd.message('Raspberry Pi\n%s' % date.strftime("%Y-%m-%d %H:%M"))
	lcd.backlight(True)
Exemple #3
0
def main():

	HOME = os.path.dirname(os.path.realpath(__file__))
	f = file(HOME+'/sensors.cfg')
	CFG = Config(f)
	logging.basicConfig(filename=HOME+'/sensors.log', level=logging.INFO, format='%(asctime)s %(message)s', datefmt='%Y-%m-%d %H:%M')

	tz = pytz.timezone(CFG.timezone)
	date = datetime.now(tz)

	m = date.strftime("%Y-%m-%d\n%H:%M:%S")
	GPIO.setwarnings(False)
	lcd.init()
	lcd.backlight(True)
	lcd.message(m)

	d = [] # read sensor data
	for s in CFG.sensors:

		if s.id < 0: continue # skip disabled sensors

		try:
			if s.name == 'DS18B20':
				v = w1.readTemp(s.rom_code)
			elif s.name == 'DHT22' and s.type == 'H':
				v = dht.readHumidity()
			elif s.name == 'DHT22' and s.type == 'T':
				v = dht.readTemperature()
			else:
				raise Exception('unknown sensor name')
				continue
		except Exception as e:
			logging.error("| Can't read sensor %d | %s | %s" % (s.id, s.rom_code, str(e)))
			continue

		try:
			print "%s, %s: %.1f" % (s.rom_code, s.label, v)
			if(s.type == 'H'):
				d.append('%d%%' % v)
			else:
				d.append(v)			
		except Exception as e:
			print "Can't print sensor %d" % s.id

	m = scan.buildMessage(d, date)
	lcd.message(m)
Exemple #4
0
#!/usr/bin/env python

#import pcd8544.lcd as lcd
import lcd
import time
import A20_GPIO as GPIO

def demo():
    lcd.locate(0,0)
    lcd.text("TEST")        

if __name__ == "__main__":
    lcd.init()
    lcd.backlight(1)
    demo()
    GPIO.cleanup()

Exemple #5
0
def main():
    lcd.init()
    lcd.backlight(1)
    stats()
Exemple #6
0
        lcd.gotoxy(0,3)
        lcd.pr(padN('{:20}'.format(wstr),lcd_width,True))

        
if __name__ == '__main__':

    s = 'This is a very long string that must be rotated'
    r = RotatingString(s,16)
    for i in range(50):
        print(r.tick())

    if False:
        import bb595
        import lcd
        import random
        s8 = bb595.bb595()
        lcd = lcd.LCD(s8)
        lcd.begin()
        lcd.clear()
        lcd.backlight(0)
        last = datetime.datetime.now()

        while True:
            now = datetime.datetime.now()
            if now > (last + datetime.timedelta(seconds=1)):
                update_display(lcd,{'zones':'3', 'remaining':4922},None)
                last = now
            else:
                s8.shift8(random.randrange(256),'triacs')