コード例 #1
0
ファイル: display.py プロジェクト: tpaulus/RPi-IPDisplay
#! /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))
コード例 #2
0
ファイル: Main.py プロジェクト: tpaulus/SCC-USC2013
#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]