コード例 #1
0
ファイル: Main.py プロジェクト: tpaulus/DCC-13
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()
コード例 #2
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)
コード例 #3
0
ファイル: Main.py プロジェクト: tpaulus/SCC-USC2013
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]
        locations[str(x) + 'c'] = l2[1]
    info.close()

except IOError:
    lcd.message('Welcome\nNew User!')
    print 'Adding New Location...'
    State = raw_input(
        'Enter The name of the State your desired location is in, using the abbreviation -CA\n'
    )
    City = raw_input('Now, Enter the name of the City\n')
    print '\nThank You!'
    State = State.upper()
    City = City.capitalize()
    if not os.path.exists(app_info_folder):
        os.makedirs(app_info_folder)
    info = open(LocationData, 'w')
    info.write(State + ':' + City)
    locations = {'0' + 's': State, '0' + 'c': City}
    info.close()
コード例 #4
0
ファイル: Main.py プロジェクト: tpaulus/Weather_Client
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()

except IOError:
    lcd.message('Welcome\nNew User!')
    print 'Adding New Location...'
    State = raw_input('Enter The name of the State your desired location is in, using the abbreviation -CA\n')
    City = raw_input('Now, Enter the name of the City\n')
    print '\nThank You!'
    State = State.replace('\n', '').upper()
    City = City.replace('\n', '').capitalize()
    if not os.path.exists(app_info_folder):
        os.makedirs(app_info_folder)
    info = open(LocationData, 'w')
    info.write(State + ':' + City)
    locations = {'0' + 's': State, '0' + 'c': City}
    info.close()

try:
    pram = open(parameters,'r')
コード例 #5
0
ファイル: ADC3.py プロジェクト: EricRBruck/SCC-SD2013
        if color == lcd.ON:
            color = lcd.GREEN
        elif color == lcd.GREEN:
            color = lcd.OFF
        else:
            color = lcd.ON
    for i in range(3):
        lcd.backlight(color)
        sleep(.01)
    sleep(bounce/1000)


try:
    GPIO.add_event_detect(green, GPIO.RISING, callback=colorChange, bouncetime=bounce)

    while True:
        GPIO.output(statusLED, True)                                # Status Led On
        l = movavg(light_Average, 4, analogRead(light_adc))         # Read the light sensor and calculate the average
        lcd.home()                                                  # Tell the LCD to go back to the first character
        lcd.message('Pot: ' + str(analogRead(pot_adc)) + '         \nLight: ' + str(l) + '       ')  # Print info
        GPIO.output(statusLED, False)                               # Status Led Off
        sleep(rate)                                                 # Wait a little

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

finally:
    lcd.clear()
    lcd.backlight(lcd.OFF)
    GPIO.cleanup()
コード例 #6
0
    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()

finally:
    lcd.clear()
    lcd.backlight(lcd.OFF)
    GPIO.cleanup()
コード例 #7
0
ファイル: ADC3.py プロジェクト: tpaulus/SCC-USC2013
            color = lcd.ON
    for i in range(3):
        lcd.backlight(color)
        sleep(.01)
    sleep(bounce / 1000)


try:
    GPIO.add_event_detect(green,
                          GPIO.RISING,
                          callback=colorChange,
                          bouncetime=bounce)

    while True:
        GPIO.output(statusLED, True)  # Status Led On
        l = movavg(light_Average, 4, analogRead(
            light_adc))  # Read the light sensor and calculate the average
        lcd.home()  # Tell the LCD to go back to the first character
        lcd.message('Pot: ' + str(analogRead(pot_adc)) + '         \nLight: ' +
                    str(l) + '       ')  # Print info
        GPIO.output(statusLED, False)  # Status Led Off
        sleep(rate)  # Wait a little

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

finally:
    lcd.clear()
    lcd.backlight(lcd.OFF)
    GPIO.cleanup()