コード例 #1
0
ファイル: display.py プロジェクト: tpaulus/RPi-IPDisplay
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))
    except IOError:
        pass
    interface += 1

if ip is not None:
    lcd.message('My IP address is:\n' + get_ip_address('wlan0'))

else:
    lcd.backlight(lcd.RED)
    lcd.message("It seems that I\ndon't have an IP")

while not lcd.buttonPressed(lcd.SELECT):
    time.sleep(.1)

lcd.clear()
lcd.backlight(lcd.OFF)
コード例 #2
0
ファイル: Main.py プロジェクト: tpaulus/Weather_Client
        string1 = API.Display1(high,low,windSpeed,units_Speed,windDir,language)
        lcd.message(string1)

    if display == 1:
        lcd.clear()
        rain = API.rain(json)
        humidity = API.humidity(json)
        string2 = API.Display2(rain,humidity,language)
        lcd.message(string2)

    if display == 2:
        lcd.clear()
        lcd.message('More Data\nComing Soon!')

    while True:
        if lcd.buttonPressed(lcd.DOWN):
            display = (display + 1)%displayCount
            break

        if lcd.buttonPressed(lcd.UP):
            display = (display -1)%displayCount
            break


        if lcd.buttonPressed(lcd.LEFT):
            location = locationChanger('left',locations,location)
            update = True
            break
#            Jump to location Menu Function

        if lcd.buttonPressed(lcd.RIGHT):
コード例 #3
0
ファイル: Main.py プロジェクト: tpaulus/SCC-USC2013
                                   language)
            lcd.message(string1)

        if display == 1:
            lcd.clear()
            rain = API.rain(json)
            humidity = API.humidity(json)
            string2 = API.Display2(rain, humidity, language)
            lcd.message(string2)

        if display == 2:
            lcd.clear()
            lcd.message('More Data\nComing Soon!')

        while True:
            if lcd.buttonPressed(lcd.DOWN):
                display = (display + 1) % displayCount
                break

            if lcd.buttonPressed(lcd.UP):
                display = (display - 1) % displayCount
                break

            if lcd.buttonPressed(lcd.LEFT):
                location = locationChanger('left', locations, location)
                update = True
                break
                #            Jump to location Menu Function

            if lcd.buttonPressed(lcd.RIGHT):
                location = locationChanger('right', locations, location)
コード例 #4
0

def movavg(ave_list, length, value):
    """A function that smooths the results by averaging a list"""
    ave_list.append(value)
    if length < len(ave_list):
        del ave_list[0]
    value = 0
    for x in ave_list[:]:
        value += x
    return value / len(ave_list)

try:
    while True:
        # Change the Back-light based on what button has been pressed
        if lcd.buttonPressed(lcd.DOWN):
            lcd.backlight(lcd.ON)
        if lcd.buttonPressed(lcd.UP):
            lcd.backlight(lcd.OFF)
        lcd.home()                                                  # Tell the LCD to go back to the first character
        GPIO.output(statusLED, True)                                # Status Led On
        lcd.message('Potentiometer:\n' + str(
            movavg(l, 4, analogRead(pot_adc))) + '     ')           # Read analog value and send it to the display
        sleep(.1)                                                   # Wait a little
        GPIO.output(statusLED, False)                               # Status Led off
        sleep(.155)                                                 # Wait a bit longer

except KeyboardInterrupt:
    GPIO.output(statusLED, False)
    spi.close()