Esempio n. 1
0
#Written By Tom Paulus, @tompaulus, www.tompaulus.com

from lib.Char_Plate.Adafruit_CharLCDPlate import Adafruit_CharLCDPlate
import WUndergroundAPI
import time
import smbus
import os
import RPi.GPIO as GPIO  # For Demo Only

locations = {}
version = 0
app_info_folder = '/etc/WeatherUnderground'
LocationData = app_info_folder + '/locations.conf'
parameters = app_info_folder + '/parameters.conf'
boardVersion = '/proc/cpuinfo'
lcd = Adafruit_CharLCDPlate(busnum=version)
API = WUndergroundAPI.WebAPI()
lcd.clear()
color = lcd.ON
lcd.backlight(color)

GPIO.setmode(GPIO.BCM)  # For Demo Only
GPIO.setup(25, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)  # For Demo Only
try:
    info = open(LocationData)
    data = info.readlines()
    length = int(str(data).count(',')) + 1
    l1 = data[0].split(',')
    for x in range(0, length):
        l2 = l1[x].split(':')
        locations[str(x) + 's'] = l2[0]
Esempio n. 2
0
#! /usr/bin/python
#Written By Tom Paulus, @tompaulus, www.tompaulus.com

from lib.Char_Plate.Adafruit_CharLCDPlate import Adafruit_CharLCDPlate
import socket
import fcntl
import struct
import time
import smbus


lcd = Adafruit_CharLCDPlate(busnum=0)
lcd.clear()
lcd.backlight(lcd.ON)
ip = None
interface = 0


def get_ip_address(ifname):
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    return socket.inet_ntoa(fcntl.ioctl(s.fileno(), 0x8915, struct.pack('256s', ifname[:15]))[20:24])


while ip is None and interface <= 10:
    try:
        ip = get_ip_address('eth' + str(interface))
    except IOError:
        pass

    try:
        ip = get_ip_address('wlan' + str(interface))
Esempio n. 3
0
#! /usr/bin/python
#Written By Tom Paulus, @tompaulus, www.tompaulus.com

from lib.Char_Plate.Adafruit_CharLCDPlate import Adafruit_CharLCDPlate
import WUndergroundAPI
import time
import smbus
import os

locations = {}

app_info_folder = '/etc/WeatherUnderground'
LocationData = app_info_folder + '/locations.conf'
parameters = app_info_folder + '/parameters.conf'

lcd = Adafruit_CharLCDPlate(busnum = 1)
API = WUndergroundAPI.WebAPI()
lcd.clear()
lcd.backlight(lcd.ON)

try:
    info = open(LocationData)
    data = info.readlines()
    length = int(str(data).count(',')) + 1
    l1 = data[0].split(',')
    for x in range (0,length):
        l2 = l1[x].split(':')
        locations[str(x)+'s'] = l2[0]
        locations[str(x)+'c'] = l2[1]
    info.close()
Esempio n. 4
0
#! /usr/bin/python
#Written By Tom Paulus, @tompaulus, www.tompaulus.com

from time import sleep
import spidev
import RPi.GPIO as GPIO
from lib.Char_Plate.Adafruit_CharLCDPlate import Adafruit_CharLCDPlate
import smbus

GPIO.setmode(GPIO.BCM)
lcd = Adafruit_CharLCDPlate()
spi = spidev.SpiDev()
light_adc = 1       # ADC
pot_adc = 0         # ADC
statusLED = 23
green = 25                          # Makes the LCD Green
light_Average = []                  # Average list used by the movavg function
l = 0                               # display  value for the light sensor
pot_Average = []                    # Average list used by the movavg function
p = 0                               # display value for the pot
rate = .1                           # The delay between refreshes + .125 seconds
bounce = 400
color = lcd.ON
print "Press CTRL+C to exit"

GPIO.setup(green, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(statusLED, GPIO.OUT)

lcd.backlight(color)
lcd.clear()
Esempio n. 5
0
#! /usr/bin/python
#Written By Tom Paulus, @tompaulus, www.tompaulus.com

from time import sleep
import spidev
import RPi.GPIO as GPIO
from lib.Char_Plate.Adafruit_CharLCDPlate import Adafruit_CharLCDPlate
import smbus

GPIO.setmode(GPIO.BCM)
lcd = Adafruit_CharLCDPlate(busnum=0)
spi = spidev.SpiDev()
pot_adc = 0         # ADC
l = []              # List for Light Sensor Averaging
statusLED = 23
print "Press CTRL+C to exit"
GPIO.setup(statusLED, GPIO.OUT)
lcd.backlight(lcd.ON)
lcd.clear()


def analogRead(port):
    """Read the given ADC port and preform the necessary shifting of bits"""
    spi.open(0, 0)
    if (port > 7) or (port < 0):
        print 'analogRead -- Port Error, Must use a port between 0 and 7'
        return -1
    r = spi.xfer2([1, (8 + port) << 4, 0])
    value = ((r[1] & 3) << 8) + r[2]
    spi.close()
    return value
Esempio n. 6
0
#! /usr/bin/python
#Written By Tom Paulus, @tompaulus, www.tompaulus.com

from time import sleep
import spidev
import RPi.GPIO as GPIO
from lib.Char_Plate.Adafruit_CharLCDPlate import Adafruit_CharLCDPlate
import smbus

GPIO.setmode(GPIO.BCM)
lcd = Adafruit_CharLCDPlate(busnum=0)
spi = spidev.SpiDev()
light_adc = 1  # ADC
pot_adc = 0  # ADC
statusLED = 23
green = 25  # Makes the LCD Green
light_Average = []  # Average list used by the movavg function
l = 0  # display  value for the light sensor
pot_Average = []  # Average list used by the movavg function
p = 0  # display value for the pot
rate = .1  # The delay between refreshes + .125 seconds
bounce = 400
color = lcd.ON
print "Press CTRL+C to exit"

GPIO.setup(green, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(statusLED, GPIO.OUT)

lcd.backlight(color)
lcd.clear()
Esempio n. 7
0
def init():
    global lcd
    if version == 0:
        lcd = Adafruit_CharLCDPlate(busnum=0)
        lcd.clear()
        lcd.backlight(lcd.ON)
    elif version == 1:
        lcd = Adafruit_CharLCDPlate(busnum=1)
        lcd.clear()
        lcd.backlight(lcd.ON)
    else:
        quit("Raspberry Pi Version Error!")

    lcd.clear()
    lcd.backlight(lcd.ON)
    lcd.message('News Client\nfor Raspberry Pi')
    time.sleep(1)
    lcd.clear()
    lcd.message('Version 1.0\nTom Paulus 2013')
    time.sleep(1)
    lcd.clear()