Exemplo n.º 1
0
from datetime import datetime
from subprocess import *
from time import sleep, strftime
from Queue import Queue
from threading import Thread
import os
from nanpy import Arduino, Lcd

Arduino.pinMode(14, input)

lcd = Lcd([8, 9, 4, 5, 6, 7],
          [16, 2])  # Setup the LCD pins for the Sainsmart Shield
lcd.printString("Jess's Web Radio", 0, 0)
lcd.printString("Loading" + "." * 3, 0, 1)
sleep(5)
max_trax = 74
x = 1
loop_menu = 1
loop_radio = 1


def display_ipaddr():
    show_wlan0 = "ip addr show wlan0 | cut -d/ -f1 | awk '/inet/ {printf \"w%15.15s\", $2}'"
    show_eth0 = "ip addr show eth0  | cut -d/ -f1 | awk '/inet/ {printf \"e%15.15s\", $2}'"
    ipaddr = run_cmd(show_eth0)
    if ipaddr == "":
        ipaddr = run_cmd(show_wlan0)
    lcd.printString('IP Address:', 0, 0)
    lcd.printString(ipaddr, 0, 1)
    sleep(2)
Exemplo n.º 2
0
            else:
                pass

        self.__data = raw

    def getCelsius(self):
        if self.__fetchAddress():
            self.__fetchData()
        return self.__data / 16.0

    def getFahrenheit(self):
        if self.__fetchAddress():
            self.__fetchData()
        return self.getCelsius() * 1.8 + 32.0


from nanpy import Lcd

if __name__ == "__main__":

    lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2])
    lcd.printString("Loc. London")

    temp_int = FakeDallasTemperature(6)
    temp_ext = FakeDallasTemperature(5)

    while(1):
        lcd.setCursor(0, 1)
        lcd.printString("Ex.%0.0f\xDFC  In.%0.0f\xDFC" % (temp_int.getCelsius(), temp_ext.getCelsius()))

Exemplo n.º 3
0
import os
from nanpy import Arduino, Lcd

Arduino.pinMode(14, input)

lcd = Lcd([8, 9, 4, 5, 6, 7], [16, 2])

max_trax = 6


def getKey():
    val = Arduino.analogRead(14)
    if val == 1023:
        return "NONE"
    elif val < 100:
        return "RIGHT"
    elif val < 150:
        return "UP"
    elif val < 330:
        return "DOWN"
    elif val < 510:
        return "LEFT"
    elif val < 750:
        return "SEL"
    else:
        return "KBD_FAULT"


def getTrack():
    L = [S.strip('\n') for S in os.popen('mpc').readlines()]
    station = L[0][0:15]
Exemplo n.º 4
0
import os
from nanpy import Arduino, Lcd

# Initialize buttons and states
buttonPin = 7
buttonPin2 = 8
buttonState = 0
buttonState2 = 0

# Activate buttons
Arduino.pinMode(buttonPin, input)
Arduino.pinMode(buttonPin2, input)

# Initialize LCD
lcd = Lcd([12, 11, 5, 4, 3, 2], [16, 2])

# Maximum number of stations held in the mpc list
max_trax = 4


# Print station info to LCD
def getTrack():
    L = [S.strip('\n') for S in os.popen('mpc').readlines()]
    station = L[0][0:15]
    track = L[0][-16:-1]
    lcd.printString(16 * " ", 0, 0)
    lcd.printString(station, 0, 0)
    lcd.printString(16 * " ", 0, 1)
    lcd.printString(track, 0, 1)
    print(L)
    print(station)
Exemplo n.º 5
0
# Description: get the current time from a ntp server and show it on a lcd
# Dependencies: ntplib (http://pypi.python.org/pypi/ntplib/)

import ntplib
from nanpy import (SerialManager, Lcd)
from datetime import datetime
from time import sleep

connection = SerialManager()

ntp_client = ntplib.NTPClient()
response = ntp_client.request('europe.pool.ntp.org', version=3)

time = int(response.tx_time)

pins = [7, 8, 9, 10, 11, 12]
cols, rows = 16, 2
lcd = Lcd(pins, [cols, rows], connection=connection)

while (1):
    lcd.setCursor(0, 0)
    lcd.printString((datetime.fromtimestamp(time)).strftime('%Y-%m-%d'))
    if time % 2:
        time_format = '%H:%M'
    else:
        time_format = '%H %M'
    lcd.setCursor(0, 1)
    lcd.printString((datetime.fromtimestamp(time)).strftime(time_format))
    sleep(1)
    time += 1